/* Oxcel Lead Room
   Palette and type follow Ratib's mockup — navy, gold, Space Grotesk.
   Everything is driven by variables so the dark theme is a swap, not a fork. */

:root {
  /* #001732 is sampled from the logo artwork itself, not eyeballed. Every
     other neutral is mixed toward it, so greys read as part of the mark
     rather than sitting beside it. */
  --navy:        #001732;
  --navy-deep:   #000D1E;
  --navy-700:    #123055;
  --gold:        #E7A338;
  --gold-ink:    #8E5E0F;
  --gold-tint:   rgba(231,163,56,.14);

  --bg:          #F1F4F8;
  --surface:     #FFFFFF;
  --surface-2:   #F6F9FC;
  --surface-3:   #E9EFF5;
  --line:        #DEE5EE;
  --line-soft:   #EAEFF5;
  --ink:         #04182E;
  --ink-2:       #33506E;
  /* Dark enough to clear WCAG AA on white, --bg and --surface-2 alike. The
     obvious lighter grey-blue sat at 4.1:1, and this colour carries the small
     mono labels that are already hard to read. */
  --muted:       #5A6E86;
  --header-bg:   #001732;
  --header-ink:  #FFFFFF;

  --green:       #2F9E6A;  --green-ink:  #17653F;  --green-tint:  rgba(47,158,106,.13);
  --blue:        #2F6FA8;  --blue-ink:   #1E5280;  --blue-tint:   rgba(47,111,168,.13);
  --steel:       #4A6E96;  --steel-ink:  #2B4A6B;  --steel-tint:  rgba(74,110,150,.14);
  --red:         #D2565C;  --red-ink:    #9C3339;  --red-tint:    rgba(210,86,92,.12);
  --grey:        #7E8B9B;  --grey-ink:   #4E5B6A;  --grey-tint:   rgba(126,139,155,.16);

  --shadow-1: 0 1px 2px rgba(0,23,50,.06), 0 1px 3px rgba(0,23,50,.04);
  --shadow-2: 0 4px 14px rgba(0,23,50,.08), 0 1px 3px rgba(0,23,50,.05);
  --shadow-3: 0 24px 60px rgba(0,13,30,.28);
  --r-sm: 8px; --r-md: 11px; --r-lg: 15px; --r-xl: 20px;
}

[data-theme="dark"] {
  /* The dark theme is the brand navy taken further down, not neutral grey —
     otherwise the logo floats on a surface that has nothing to do with it. */
  --navy-deep:   #00060F;
  --navy-700:    #1B3F68;
  --gold:        #EDB259;
  --gold-ink:    #F0BE72;
  --gold-tint:   rgba(237,178,89,.15);

  --bg:          #05101C;
  --surface:     #0C1A29;
  --surface-2:   #112234;
  --surface-3:   #182D42;
  --line:        #21384F;
  --line-soft:   #1A2C40;
  --ink:         #E6EDF6;
  --ink-2:       #B2C3D6;
  --muted:       #8298B0;
  --header-bg:   #000E1E;
  --header-ink:  #F1F5FA;

  --green: #45B884; --green-ink: #6BCB9F; --green-tint: rgba(69,184,132,.15);
  --blue:  #5D9AD3; --blue-ink:  #83B4E0; --blue-tint:  rgba(93,154,211,.15);
  --steel: #7C9CBE; --steel-ink: #9DB6D0; --steel-tint: rgba(124,156,190,.16);
  --red:   #E4787A; --red-ink:   #EE9799; --red-tint:   rgba(228,120,122,.15);
  --grey:  #99A3B0; --grey-ink:  #AAB4C0; --grey-tint:  rgba(153,163,176,.16);

  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 4px 16px rgba(0,0,0,.4);
  --shadow-3: 0 24px 60px rgba(0,0,0,.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
[hidden] { display: none !important; }

h1, h2, h3, .display { font-family: 'Space Grotesk', sans-serif; letter-spacing: -.018em; }
.mono { font-family: 'JetBrains Mono', monospace; }

::selection { background: var(--gold-tint); }

/* ------------------------------------------------------------- sign-in */

.gate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(231,163,56,.16), transparent 62%),
    radial-gradient(900px 560px at 96% 108%, rgba(62,124,177,.14), transparent 60%),
    var(--navy-deep);
}
.gate-card {
  width: 100%; max-width: 392px; padding: 34px 32px 26px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); text-align: center;
}
/* The artwork is a fixed-size bitmap, so it is never displayed larger than
   its natural size — that is what keeps it crisp on a retina screen. */
.gate-logo { height: 26px; width: auto; display: block; margin: 0 auto 22px; }
[data-theme="light"] .on-dark, [data-theme="dark"] .on-light { display: none; }
.gate-card h1 { font-size: 25px; font-weight: 700; }
.gate-sub { color: var(--muted); font-size: 13.5px; margin: 5px 0 24px; }
.gate-foot { margin-top: 20px; font-size: 11.5px; color: var(--muted); }

.google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px; border-radius: var(--r-md); font-weight: 600; font-size: 14.5px;
  background: var(--navy); color: #fff; transition: background .15s, transform .06s;
}
.google-btn:hover { background: var(--navy-700); }
.google-btn:active { transform: translateY(1px); }

.dev-note {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--gold-ink); background: var(--gold-tint);
  border-radius: 999px; padding: 5px 11px; display: inline-block; margin-bottom: 14px;
}
.people { display: flex; flex-direction: column; gap: 7px; }
.person {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color .15s, background .15s;
}
.person:hover { border-color: var(--gold); background: var(--surface); }
.person-info strong { display: block; font-size: 13.5px; font-weight: 600; }
.person-info span { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }

.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 12.5px;
  background: var(--steel-tint); color: var(--steel-ink);
}
.avatar.gold { background: var(--gold); color: var(--navy-deep); }

/* -------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--header-bg); color: var(--header-ink);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 12px clamp(16px, 3vw, 28px);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { height: 22px; width: auto; display: block; flex: none; }
.brand-div { width: 1px; height: 20px; background: rgba(255,255,255,.18); }
.brand-title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px; }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.env-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,.72);
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 5px 10px;
}
.env-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex: none; }
/* Live sending and test mode have to look different from a dry run at a glance —
   one of them means real customers are receiving real messages. */
.env-pill.live { border-color: rgba(93,175,123,.45); color: #A9DCBC; }
.env-pill.live .env-dot { background: var(--green); }
.env-pill.alarm { border-color: rgba(228,120,122,.55); color: #F2B4B5; }
.env-pill.alarm .env-dot { background: var(--red); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
@media (max-width: 700px) { .env-pill { display: none; } }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.14); transition: all .15s;
}
.icon-btn:hover { color: #fff; border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.06); }

.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 4px; }
.user-chip .who { text-align: right; line-height: 1.2; }
.user-chip .who strong { display: block; font-size: 12.5px; font-weight: 500; color: rgba(255,255,255,.92); }
.user-chip .who span {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: .07em;
  text-transform: uppercase; color: rgba(255,255,255,.5);
}
@media (max-width: 560px) { .user-chip .who { display: none; } }

/* ---------------------------------------------------------------- page */

.page { max-width: 1240px; margin: 0 auto; padding: clamp(20px, 3vw, 30px) clamp(16px, 3vw, 28px) 90px; }

.viewnav { display: flex; gap: 2px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.viewtab {
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.viewtab:hover { color: var(--ink); }
.viewtab.on { color: var(--ink); border-bottom-color: var(--gold); }

/* ------------------------------------------------------------- reports */

.tablewrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow-x: auto;
}
table.report { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.report th {
  text-align: left; padding: 11px 14px; white-space: nowrap;
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
table.report td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.report tr:last-child td { border-bottom: none; }
table.report tbody tr:hover { background: var(--surface-2); }
table.report .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.report .strong { font-weight: 600; }
table.report .money { font-weight: 600; color: var(--gold-ink); }
table.report .dim { color: var(--muted); }
table.report tfoot td {
  border-top: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; padding: 12px 14px;
}
.cellsub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* one lead inside the dealer drawer */
.dealer-lead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 12px 14px 12px 16px; margin-bottom: 8px; position: relative; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dealer-lead::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sc); }
.dealer-lead:hover { border-color: var(--muted); background: var(--surface); }
.dealer-lead-main { min-width: 0; }

/* Tony: "Add a first line of Broker Note here." One line, clamped — this list
   runs to thirty-five referrals for a busy dealership, and a note that wrapped
   to four lines would undo the point of showing it. */
.dealer-lead-note {
  margin-top: 4px; font-size: 12px; line-height: 1.45; color: var(--ink);
  padding-left: 8px; border-left: 2px solid var(--gold-tint);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.dealer-lead-name {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 15px;
  letter-spacing: -.01em; margin: 1px 0;
}

.count-pill {
  display: inline-block; min-width: 26px; text-align: center; padding: 2px 7px;
  border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; font-weight: 600;
}
.count-pill.zero    { color: var(--muted); background: transparent; }
.count-pill.settled { color: var(--green-ink); background: var(--green-tint); }
.count-pill.stale   { color: var(--red-ink);   background: var(--red-tint); }
.count-pill.open    { color: var(--gold-ink);  background: var(--gold-tint); }

/* ---------------------------------------------------------------- team */

.person-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  margin-bottom: 9px; box-shadow: var(--shadow-1); flex-wrap: wrap;
}
.person-row .who { flex: 1; min-width: 180px; }

/* An avatar showing a real photo rather than initials. */
.avatar.photo { padding: 0; overflow: hidden; background: var(--surface-3); }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Picking a signature photo. */
.photo-row { display: flex; gap: 14px; align-items: flex-start; }
.photo-preview {
  width: 84px; height: 84px; flex: none; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2);
  display: grid; place-items: center; text-align: center;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-preview span {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.photo-actions { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px;
  align-items: flex-start; }
.person-row .who strong { font-size: 14.5px; font-weight: 600; display: block; }
.person-row .who span { font-size: 12px; color: var(--muted); }
.person-row.off { opacity: .55; }
.roleflags { display: flex; gap: 6px; flex-wrap: wrap; }

/* The dealership's phone and email on the Dealers page. */
.dealer-contact { font-size: 12.5px; text-align: right; min-width: 0; }
.dealer-contact .cellsub { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 560px) { .dealer-contact { text-align: left; flex: 1 0 100%; } }

/* The three switches travel together, so they wrap as one block rather than
   one switch dropping to a line of its own. */
.rowswitches { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.switch {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none;
  font-size: 11.5px; font-family: 'JetBrains Mono', monospace; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 21px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--line); position: relative; transition: background .16s, border-color .16s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,23,50,.3);
  transition: transform .16s;
}
.switch input:checked + .track { background: var(--green); border-color: var(--green); }
.switch input:checked + .track::after { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .45; cursor: not-allowed; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 17px; box-shadow: var(--shadow-1); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--gold)); opacity: .85;
}
.stat-n { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 27px; line-height: 1.05; color: var(--accent-ink, var(--ink)); }
.stat-l {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-top: 5px;
}
.stat-hint { font-size: 11.5px; color: var(--muted); margin-top: 7px; }
.stat.gold  { --accent: var(--gold);  --accent-ink: var(--gold-ink); }
.stat.blue  { --accent: var(--blue);  --accent-ink: var(--blue-ink); }
.stat.green { --accent: var(--green); --accent-ink: var(--green-ink); }
.stat.red   { --accent: var(--red);   --accent-ink: var(--red-ink); }

/* ------------------------------------------------------------- toolbar */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px; font-weight: 500;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line);
  transition: all .15s;
}
.tab:hover { color: var(--ink); border-color: var(--muted); }
.tab.on { background: var(--navy); border-color: var(--navy); color: #fff; }
[data-theme="dark"] .tab.on { background: var(--gold); border-color: var(--gold); color: var(--navy-deep); }
.tab .c { font-family: 'JetBrains Mono', monospace; font-size: 11px; opacity: .68; margin-left: 6px; }

.search {
  display: flex; align-items: center; gap: 8px; min-width: 250px; flex: 1; max-width: 340px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 0 11px; color: var(--muted); transition: border-color .15s;
}
.search:focus-within { border-color: var(--gold); }
.search input { flex: 1; border: none; outline: none; background: none; padding: 9px 0; font-size: 13.5px; }
.search kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}
.search:focus-within kbd { display: none; }

/* --------------------------------------------------------------- leads */

.leads { display: flex; flex-direction: column; gap: 12px; }

.lead {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px 14px 21px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-1); transition: box-shadow .18s, border-color .18s, transform .18s;
  animation: rise .3s ease both;
}
.lead:hover { box-shadow: var(--shadow-2); border-color: var(--line); transform: translateY(-1px); }
.lead::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sc); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.s-doc_requested  { --sc: var(--gold);  --sci: var(--gold-ink);  --sct: var(--gold-tint); }
.s-in_progress    { --sc: var(--steel); --sci: var(--steel-ink); --sct: var(--steel-tint); }
.s-pre_approved   { --sc: var(--blue);  --sci: var(--blue-ink);  --sct: var(--blue-tint); }
.s-final_approved { --sc: var(--green); --sci: var(--green-ink); --sct: var(--green-tint); }
.s-settled        { --sc: var(--green); --sci: var(--green-ink); --sct: var(--green-tint); }
.s-stale          { --sc: var(--red);   --sci: var(--red-ink);   --sct: var(--red-tint); }
.s-decline        { --sc: var(--red);   --sci: var(--red-ink);   --sct: var(--red-tint); }
.s-withdrawal     { --sc: var(--grey);  --sci: var(--grey-ink);  --sct: var(--grey-tint); }

.lead-top { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.lead-ref { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; letter-spacing: .06em; color: var(--muted); }
.lead-name { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 17.5px; letter-spacing: -.015em; margin-top: 1px; }
.lead-via { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.lead-via b { color: var(--ink-2); font-weight: 600; }

.badge {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; flex: none;
  padding: 5px 10px; border-radius: 6px; background: var(--sct); color: var(--sci);
  display: inline-flex; align-items: center; gap: 6px;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--sc); }
.badge.solid { background: var(--green); color: #fff; }
.badge.solid::before { background: rgba(255,255,255,.9); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; color: var(--ink-2);
}
.chip .pd { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex: none; }
.chip.warn { background: var(--red-tint); border-color: transparent; color: var(--red-ink); }
/* What the follow-up engine will do next to this lead. */
.chip.chase { background: var(--gold-tint); border-color: transparent; color: var(--gold-ink); }

/* The pending follow-up rounds, in the drawer. */
.chase-list { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.chase-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft); font-size: 12.5px;
}
.chase-row:last-child { border-bottom: none; }
.chase-no {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600;
  color: var(--gold-ink); background: var(--gold-tint);
  border-radius: var(--r-sm); padding: 3px 7px; flex: none;
}
.chase-when { color: var(--ink-2); }
.chip.muted { color: var(--muted); }

/* pipeline rail — where this deal sits, at a glance */
.rail { display: flex; align-items: center; gap: 4px; margin: 14px 0 12px; }
.rail-step { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-3); position: relative; }
.rail-step.done { background: var(--sc); }
.rail-step.done.dim { background: var(--sc); opacity: .35; }
.rail-step.halted { background: repeating-linear-gradient(90deg, var(--sct) 0 5px, transparent 5px 9px); }
.rail-label {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap; margin-left: 4px;
}

.meta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-bottom: 12px; }
.meta-k {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: 9px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 1px;
}
.meta-v { font-size: 13px; font-weight: 500; }
.meta-v.amount { color: var(--gold-ink); font-weight: 600; }

.lead-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; border-top: 1px solid var(--line-soft); padding-top: 11px;
}
.lead-foot .by { font-size: 11.5px; color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; padding: 7px 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: all .14s;
}
.btn:hover { border-color: var(--muted); background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { padding: 10px 16px; font-size: 13.5px; border-radius: var(--r-md); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); border-color: var(--navy-700); }
[data-theme="dark"] .btn-primary { background: var(--gold); border-color: var(--gold); color: var(--navy-deep); }
[data-theme="dark"] .btn-primary:hover { filter: brightness(1.08); background: var(--gold); }
.btn-go { background: var(--green); border-color: var(--green); color: #fff; }
.btn-go:hover { filter: brightness(1.06); background: var(--green); border-color: var(--green); }
.btn-danger { color: var(--red-ink); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn-danger:hover { background: var(--red-tint); border-color: var(--red); }
.btn-ghost { border-color: transparent; background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-block { width: 100%; justify-content: center; }
.btn-mini { padding: 5px 10px; font-size: 11.5px; }

/* --------------------------------------------------------------- empty */

.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty-mark {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 14px;
  display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line);
}
.empty h3 { font-size: 16px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.empty p { font-size: 13px; }

.skeleton { height: 132px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 5%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* -------------------------------------------------------------- drawer */

.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(12,17,23,.5); backdrop-filter: blur(3px); animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 100;
  width: min(560px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-3);
  animation: slide .24s cubic-bezier(.22,.7,.3,1) both;
}
@keyframes slide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.drawer-head h2 { font-size: 19px; font-weight: 700; }
.drawer-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.drawer-head .icon-btn { color: var(--muted); border-color: var(--line); }
.drawer-head .icon-btn:hover { color: var(--ink); background: var(--surface-2); border-color: var(--muted); }
.drawer-head #drawerTitle { flex: 1; min-width: 0; }
.drawer-title-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.drawer-title-row > div:first-child { min-width: 0; }
/* Sits in the header beside the close button, so it reads as an action on this
   dealership rather than one more row in the list below. */
/* A whole channel has stopped. Sits above the counters, because it changes what
   the numbers under it mean. */
.notice.health { margin-bottom: 14px; align-items: flex-start; }
.health-why {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--muted); display: inline-block; margin-top: 4px;
}

/* One person at a dealership, in the dealer drawer. */
.contact-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.contact-row:last-of-type { border-bottom: none; }
.contact-who { min-width: 0; }
.contact-who .chip { margin-left: 6px; }
.contact-acts { display: flex; gap: 4px; flex: none; }
.contact-acts .btn { padding: 5px 9px; font-size: 12px; }

/* Somebody who is not in the round-robin right now. Their numbers still show —
   deciding whether to switch them back on is exactly when you need them — but
   dimmed, so the row does not read as though they are taking leads. */
.chip.quiet { opacity: .55; }

/* The one thing a broker has to know while typing: this line leaves Oxcel. */
.bnote-out {
  font-size: 11.5px; color: var(--gold-ink); margin: 6px 0 0; line-height: 1.45;
}
.btn-share {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; font-size: 12.5px; text-decoration: none; white-space: nowrap;
}
.drawer-body { overflow-y: auto; padding: 18px 20px 30px; flex: 1; }

/* --------------------------------------------------------------- forms */

.section-label {
  font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: .11em;
  text-transform: uppercase; color: var(--gold-ink);
  margin: 22px 0 11px; padding-top: 16px; border-top: 1px solid var(--line-soft);
}
.section-label:first-child { margin-top: 0; padding-top: 0; border-top: none; }

/* Deleting a lead. Tinted so it never reads like the rest of the form. */
.danger-box {
  border: 1px solid color-mix(in srgb, var(--red) 35%, transparent);
  background: var(--red-tint); border-radius: var(--r-md); padding: 14px;
}
.danger-box p {
  font-size: 12.5px; line-height: 1.55; color: var(--ink-2); margin-bottom: 9px;
}
.danger-box .field > label { color: var(--red-ink); }

.field { margin-bottom: 11px; }
.field > label {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.field .req { color: var(--gold); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  outline: none; transition: border-color .15s, background .15s;
}
.field textarea { resize: vertical; min-height: 58px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); background: var(--surface); }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
/* A note inside a checkbox label. Block, so it sits under the label text
   rather than running on from it. */
.hint-inline { display: block; font-size: 11px; font-style: normal;
  color: var(--muted); margin-top: 3px; line-height: 1.45; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 440px) { .row-2 { grid-template-columns: 1fr; } }

.check {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; margin-bottom: 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .15s;
}
.check:hover { border-color: var(--muted); }
.check input { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--gold); flex: none; }
.check span { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.check.required-on { border-color: var(--gold); background: var(--gold-tint); }

.notice {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); line-height: 1.5;
}
.notice.warn { background: var(--gold-tint); border-color: color-mix(in srgb, var(--gold) 35%, transparent); color: var(--ink); }
.notice.danger { background: var(--red-tint); border-color: color-mix(in srgb, var(--red) 32%, transparent); color: var(--ink); }
.notice b { font-weight: 600; }

/* -------------------------------------------------------- drawer detail */

.dtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.dtab {
  padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s;
}
.dtab:hover { color: var(--ink); }
.dtab.on { color: var(--ink); border-bottom-color: var(--gold); }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 14px; font-size: 13px; margin-bottom: 18px; }
.kv dt { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.kv dd { font-weight: 500; overflow-wrap: anywhere; }

.msg { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-bottom: 10px; }
.msg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 13px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.msg-head strong { font-size: 12.5px; font-weight: 600; }
.msg-head .to { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.pill {
  font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: .07em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 5px; white-space: nowrap;
}
.pill.planned   { background: var(--gold-tint);  color: var(--gold-ink); }
.pill.queued    { background: var(--gold-tint);  color: var(--gold-ink); }
.pill.sent      { background: var(--blue-tint);  color: var(--blue-ink); }
.pill.delivered { background: var(--green);       color: #fff; }
.pill.skipped   { background: var(--grey-tint);  color: var(--grey-ink); }
.pill.cancelled { background: var(--grey-tint);  color: var(--grey-ink); }
.pill.failed    { background: var(--red);         color: #fff; }

.msg-error, .msg-note {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 13px; font-size: 12px; line-height: 1.45;
}
.msg-error { background: var(--red-tint); color: var(--red-ink); border-bottom: 1px solid var(--line); }
.msg-note  { background: var(--surface-2); color: var(--muted); border-bottom: 1px solid var(--line); }
.msg-error .btn { flex: none; }
.msg-body { padding: 11px 13px; font-size: 12.5px; white-space: pre-wrap; line-height: 1.55; color: var(--ink-2); }
.msg-subject { font-weight: 600; color: var(--ink); margin-bottom: 5px; font-size: 12.5px; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--gold);
}
.tl-item.system::before { border-color: var(--muted); }
.tl-title { font-size: 13px; font-weight: 600; }
.tl-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.tl-detail { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 300; display: flex; align-items: center; gap: 10px;
  background: var(--navy-deep); color: #fff; padding: 11px 17px;
  border-radius: var(--r-md); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-3); max-width: calc(100% - 32px);
  animation: toastIn .22s cubic-bezier(.22,.7,.3,1) both;
}
[data-theme="dark"] .toast { background: var(--surface-3); border: 1px solid var(--line); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); flex: none; }
.toast.bad .toast-dot { background: var(--red); }

/* ------------------------------------------------------------- mobile */

@media (max-width: 480px) {
  /* The label column left a long email about 200px, which forced a break
     mid-word — "…com.a / u". Stacked, it gets the full width. */
  .kv { grid-template-columns: 1fr; gap: 1px 0; }
  .kv dt { padding-top: 12px; }
  .kv dt:first-child { padding-top: 0; }

  /* A finger is not a mouse pointer. 32px targets are hard to hit and easy to
     mis-hit, and these buttons change a customer's status. */
  .btn { padding: 10px 14px; font-size: 13px; }
  .btn-mini { padding: 8px 12px; font-size: 12px; }
  .tab { padding: 9px 15px; }
  .viewtab { padding: 11px 14px; }
  .icon-btn { width: 36px; height: 36px; }

  /* Long addresses and URLs in a message preview. */
  .msg-body, .msg-head .to { overflow-wrap: anywhere; }

  /* Three switches will not sit on one line at this width. Given a row each,
     the labels line up and every target is a comfortable full-width tap. */
  .rowswitches { flex: 1 0 100%; flex-direction: column; align-items: flex-start; gap: 12px; }
  .rowswitches .switch { width: 100%; padding: 3px 0; }

  .page-title { font-size: 22px; }
  .drawer-body { padding: 16px 16px 30px; }
  .drawer-head { padding: 16px 16px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------- attachments -- */
/* The dealer's invoice or the sales contract, on the lead. Often read on a
   phone in a dealership, so the tap targets are generous. */

.filedrop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 22px 18px; margin-bottom: 12px; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--r-md);
  background: var(--surface-2); text-align: center;
  transition: border-color .15s, background .15s;
}
.filedrop:hover, .filedrop:focus-within { border-color: var(--gold); background: var(--surface); }
.filedrop b { font-size: 14px; }
.filedrop span { font-size: 12px; color: var(--muted); }

.filerow {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.filekind {
  flex: 0 0 auto; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .04em; padding: 5px 7px; border-radius: 5px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.filemeta { flex: 1 1 auto; min-width: 0; }
.filemeta .filename {
  display: block; font-size: 13.5px; font-weight: 500; color: var(--ink);
  text-decoration: none; overflow-wrap: anywhere;
}
.filemeta .filename:hover { color: var(--gold); text-decoration: underline; }
.filerow .by { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

@media (max-width: 440px) {
  .filerow { flex-wrap: wrap; }
  .filerow .btn { margin-left: auto; }
}

/* ------------------------------------------------------- broker note -- */
/* Tony's note on the card. Quiet when there is nothing in it, and obviously
   a field when there is — it has to read as somebody's writing rather than as
   another metadata row. */

.status-filter {
  padding: 8px 11px; font-size: 13px; font-family: inherit;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  max-width: 210px;
}
.status-filter:focus { outline: none; border-color: var(--gold); }

.bnote { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.bnote-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.bnote-k {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.bnote-by { font-size: 11px; color: var(--muted); }

.bnote-read { font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }

/* Tony keeps this as a dated log, newest line first, and it reached seventeen
   lines. Collapsed, the card shows the top line — which in his format is the
   current state of the deal. Expanded, it scrolls rather than growing without
   limit, so no single note can push a whole board off the screen. */
.bnote-lines > div + div { display: none; }
.bnote-lines > div { padding: 1px 0; }
.bnote.open .bnote-lines > div + div { display: block; }
.bnote.open .bnote-lines {
  max-height: 220px; overflow-y: auto;
  padding-right: 4px; margin-top: 2px;
}
.bnote.open .bnote-lines > div + div { color: var(--muted); font-size: 12.5px; }

.bnote-more {
  margin-top: 5px; padding: 0; font-size: 11.5px; font-weight: 500;
  color: var(--muted); background: none; border: none; cursor: pointer;
}
.bnote-more:hover { color: var(--gold); text-decoration: underline; }
.bnote.editable .bnote-read { cursor: text; border-radius: 6px; padding: 4px 6px; margin: -4px -6px; }
.bnote.editable .bnote-read:hover { background: var(--surface-2); }
.bnote-empty { color: var(--muted); font-style: italic; }

.bnote-edit textarea {
  width: 100%; font: inherit; font-size: 13.5px; line-height: 1.5;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--gold); border-radius: var(--r-md);
  padding: 8px 10px; resize: vertical;
}
.bnote-edit textarea:focus { outline: none; }
.bnote-actions { display: flex; gap: 6px; margin-top: 6px; }

/* -------------------------------------------------- team change history -- */
/* Who flipped which switch. Quiet by design — it is a reference, not the
   point of the page. */

.tevent {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 9px 14px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-size: 13px;
}
.tevent .by { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
