@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

/* ─────────────────────────────────────────
   DESIGN TOKENS
───────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;

  /* Borders */
  --border:       #e2e8f0;
  --border-mid:   #cbd5e1;
  --border-strong:#b0bec5;

  /* Text */
  --ink:   #0f1923;
  --ink-2: #475569;
  --ink-3: #94a3b8;

  /* Brand — Bradesco vermelho + navy */
  --red:      #cc1f38;
  --red-2:    #a8192e;
  --red-light:#fff0f2;
  --red-glow: rgba(204,31,56,0.18);
  --navy:     #1a3a5c;
  --navy-2:   #234e7d;
  --navy-light:#eef3fa;

  /* Status accents */
  --green:     #059669;
  --green-bg:  #ecfdf5;
  --green-bd:  #a7f3d0;
  --amber:     #d97706;
  --amber-bg:  #fffbeb;
  --amber-bd:  #fcd34d;
  --violet:    #7c3aed;
  --violet-bg: #f5f3ff;
  --violet-bd: #c4b5fd;
  --sky:       #0284c7;
  --sky-bg:    #f0f9ff;
  --sky-bd:    #7dd3fc;
  --rose:      #e11d48;
  --rose-bg:   #fff1f2;
  --rose-bd:   #fda4af;

  /* Shape */
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;

  /* Shadow */
  --shadow-xs: 0 1px 3px rgba(15,25,35,0.07), 0 1px 2px rgba(15,25,35,0.04);
  --shadow-sm: 0 4px 12px rgba(15,25,35,0.08), 0 1px 3px rgba(15,25,35,0.05);
  --shadow-md: 0 10px 28px rgba(15,25,35,0.10), 0 2px 6px rgba(15,25,35,0.06);
  --shadow-lg: 0 24px 60px rgba(15,25,35,0.14), 0 4px 12px rgba(15,25,35,0.06);
}

/* ─────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Inter", sans-serif;
  letter-spacing: -0.025em;
  margin-bottom: 2px;
  color: var(--ink);
  font-weight: 800;
}

h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 20px; line-height: 1.2; }
h3 { font-size: 15px; line-height: 1.3; }

p { margin-bottom: 0; }

/* ─────────────────────────────────────────
   LAYOUT
───────────────────────────────────────── */
.workspace {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  position: relative;
}

/* ─────────────────────────────────────────
   PANELS BASE
───────────────────────────────────────── */
.masthead,
.filters-panel,
.panel,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

/* ─────────────────────────────────────────
   MASTHEAD / HEADER
───────────────────────────────────────── */
.masthead {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  padding: 16px 22px;
  margin-bottom: 16px;
  align-items: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.masthead.compact {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.masthead-brand,
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.masthead-brand.only-logo { display: block; }

.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.hero-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
}

.masthead-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.user-badge {
  text-align: right;
  line-height: 1.4;
}

.user-badge strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
}

.user-badge span {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Eyebrow / tiny labels */
.eyebrow,
.summary-label,
label span,
.meta-caption,
.lead-meta dt,
.readonly-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-3);
}

.eyebrow {
  color: var(--red);
  display: block;
  margin-bottom: 4px;
}

.masthead-copy,
.panel-subtitle,
.updated-at,
.followup-copy,
.login-footer p,
.intro-copy {
  color: var(--ink-2);
  line-height: 1.65;
  font-size: 13px;
}

.masthead-copy { max-width: 50ch; }

/* ─────────────────────────────────────────
   FILTERS PANEL
───────────────────────────────────────── */
.filters-panel {
  padding: 14px 20px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.filters-grid {
  display: grid;
  grid-template-columns: 200px 200px minmax(240px, 1fr);
  gap: 12px;
  align-items: end;
}

/* ─────────────────────────────────────────
   SUMMARY CARDS
───────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 16px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: default;
  box-shadow: var(--shadow-xs);
}

.summary-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--navy-2));
  border-radius: 3px 3px 0 0;
}

.summary-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.summary-label { color: var(--ink-3); }

.summary-value {
  display: block;
  margin-top: 10px;
  font-family: "Inter", sans-serif;
  font-size: 34px;
  font-weight: 900;
  color: var(--navy);
  line-height: 1;
  letter-spacing: -0.03em;
}

/* ─────────────────────────────────────────
   PANEL (Lead list)
───────────────────────────────────────── */
.panel {
  padding: 20px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.panel-subtitle {
  margin-top: 2px;
  font-size: 12px;
}

/* ─────────────────────────────────────────
   LEAD GRID
───────────────────────────────────────── */
.lead-grid {
  display: grid;
  gap: 12px;
  transition: opacity 0.15s;
}

/* ─────────────────────────────────────────
   MASTER ROW (admin view)
───────────────────────────────────────── */
.master-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.15s;
  box-shadow: var(--shadow-xs);
}

.master-row:hover {
  border-color: var(--border-mid);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.master-row-main {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  align-items: center;
}

.master-row-title h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.master-badges {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.master-row-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.master-row-grid strong,
.master-detail-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.master-row-action {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.master-row-action .toggle-details {
  width: auto;
  min-width: 120px;
}

.master-row-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  animation: fadeSlideDown 0.2s ease;
}

@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.master-row-detail.is-collapsed { display: none; }

.master-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* ─────────────────────────────────────────
   VENDOR LEAD CARD
───────────────────────────────────────── */
.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.15s;
  box-shadow: var(--shadow-xs);
}

.lead-card:hover {
  border-color: var(--border-mid);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.lead-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.lead-topline {
  display: flex;
  gap: 7px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.lead-owner  { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.lead-created { white-space: nowrap; color: var(--ink-3); font-size: 12px; }

.lead-body { padding: 14px 0 0; }

.lead-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.lead-meta dt,
.meta-caption,
.readonly-label { color: var(--ink-3); }

.lead-meta dd {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

/* ─────────────────────────────────────────
   PILLS / BADGES
───────────────────────────────────────── */
.operator-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border: 1px solid transparent;
}

/* Operator pill */
.operator-pill {
  background: var(--navy-light);
  color: var(--navy);
  border-color: rgba(26,58,92,0.15);
}

/* Status pills — default */
.status-pill {
  background: var(--sky-bg);
  color: var(--sky);
  border-color: var(--sky-bd);
}

/* Dynamic via data-status */
.status-pill[data-status="novo"]               { background: var(--sky-bg);    color: var(--sky);    border-color: var(--sky-bd); }
.status-pill[data-status="em_tratativa"]       { background: var(--amber-bg);  color: var(--amber);  border-color: var(--amber-bd); }
.status-pill[data-status="aguardando_cliente"] { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-bd); }
.status-pill[data-status="convertido"]         { background: var(--green-bg);  color: var(--green);  border-color: var(--green-bd); }
.status-pill[data-status="perdido"]            { background: var(--rose-bg);   color: var(--rose);   border-color: var(--rose-bd); }

/* ─────────────────────────────────────────
   NOTES & TIMELINE
───────────────────────────────────────── */
.lead-note-block { margin-bottom: 14px; }

.lead-note,
.timeline-note {
  margin: 6px 0 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--ink-2);
  line-height: 1.65;
  min-height: 60px;
  font-size: 13px;
}

.timeline-block { margin-top: 12px; }

/* ─────────────────────────────────────────
   FOLLOW-UP PANEL
───────────────────────────────────────── */
.followup-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}

.followup-head { margin-bottom: 12px; }

.update-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
}

.full-width { grid-column: 2; }

.update-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

/* ─────────────────────────────────────────
   FORM ELEMENTS
───────────────────────────────────────── */
input,
select,
textarea,
button {
  width: 100%;
  border-radius: var(--radius-md);
  font: 500 13px "Inter", sans-serif;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.15s;
}

input,
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  color: var(--ink);
  padding: 10px 13px;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2394a3b8' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

input::placeholder,
textarea::placeholder { color: var(--ink-3); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(26,58,92,0.10);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */
button {
  border: 0;
  cursor: pointer;
  padding: 10px 18px;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  background: linear-gradient(135deg, var(--red), var(--red-2));
  box-shadow: 0 2px 10px var(--red-glow);
  letter-spacing: 0.01em;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px var(--red-glow);
}

button:active { transform: translateY(0); opacity: 0.9; }

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

button.secondary {
  background: linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: none;
  backdrop-filter: blur(4px);
}

button.secondary:hover {
  background: rgba(255,255,255,0.22);
  box-shadow: none;
}

/* Export button — inside masthead */
#exportBtn {
  background: linear-gradient(135deg, var(--red), var(--red-2));
  box-shadow: 0 2px 12px var(--red-glow);
}

button.ghost {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.20);
  color: rgba(255,255,255,0.75);
  box-shadow: none;
}

button.ghost:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* Ghost buttons outside the dark masthead */
.master-row-action .ghost,
.lead-card .ghost {
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  color: var(--ink-2);
}

.master-row-action .ghost:hover,
.lead-card .ghost:hover {
  background: var(--surface);
  border-color: var(--navy-2);
  color: var(--navy);
  transform: none;
  box-shadow: none;
}

/* ─────────────────────────────────────────
   LOGIN PAGE
───────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(150deg, #e8eef6 0%, #f0f4f8 50%, #e8eef0 100%);
}

.login-shell {
  width: min(100%, 460px);
  position: relative;
}

.login-panel {
  padding: 38px 36px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

/* Top accent stripe on login card */
.login-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red), var(--navy-2));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

/* Login logo */
.brand-lockup .brand-logo {
  box-shadow: none;
}

.brand-lockup h1 {
  font-size: 26px;
  color: var(--ink);
}

.intro-copy {
  margin: 0 0 26px;
  font-size: 13px;
  color: var(--ink-2);
}

.stack { display: grid; gap: 14px; }

label span {
  display: block;
  margin-bottom: 6px;
}

.login-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.error-text {
  color: var(--red);
  min-height: 18px;
  font-size: 12px;
  font-weight: 500;
}

/* ─────────────────────────────────────────
   MISC
───────────────────────────────────────── */
.readonly-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.readonly-value {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  color: var(--ink);
}

.lead-head-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

/* ─────────────────────────────────────────
   SCROLLBAR
───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ─────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────── */
@media (max-width: 1180px) {
  .masthead { grid-template-columns: 1fr; }
  .masthead-side { justify-content: flex-start; }
  .toolbar-actions { justify-content: flex-start; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .masthead.compact { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .filters-grid,
  .lead-meta,
  .update-grid,
  .readonly-grid,
  .master-row-main,
  .master-row-grid,
  .master-detail-grid { grid-template-columns: 1fr; }

  .full-width { grid-column: auto; }
  .lead-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .workspace { padding: 12px 14px 32px; }

  .masthead,
  .filters-panel,
  .panel,
  .login-panel { padding: 16px; border-radius: var(--radius-lg); }

  .lead-card-head,
  .update-foot { grid-template-columns: 1fr; display: grid; }

  .lead-created { white-space: normal; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  h1 { font-size: 26px; }
  h2 { font-size: 18px; }
  h3 { font-size: 14px; }

  .summary-value { font-size: 28px; }
}

@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .toolbar-actions { flex-direction: column; }
  .toolbar-actions button { width: 100%; }
}
