/* Swaraj Solar operations console.
   Chart colours come from a validated palette: a single blue series for
   magnitude, and an ordinal blue ramp for the HOT/WARM/COLD tiers (the heat
   metaphor was rejected — red vs orange measured ΔE 5.6, indistinguishable
   even with full colour vision). Tier colour never carries meaning alone; the
   word is always present beside it. */

:root {
  color-scheme: light;

  /* Surfaces & ink */
  --plane:        #f2f2ef;
  --surface:      #fcfcfb;
  --surface-2:    #f7f7f4;
  --ink:          #0b0b0b;
  --ink-2:        #52514e;
  --ink-muted:    #898781;
  --hairline:     #e1e0d9;
  --baseline:     #c3c2b7;
  --ring:         rgba(11, 11, 11, .10);

  /* Brand chrome — deliberately not a series colour, so UI never
     impersonates data. */
  --brand:        #b45309;
  --brand-ink:    #ffffff;
  --brand-wash:   #fdf6ec;

  /* Data */
  --series:       #2a78d6;
  --series-soft:  #cde2fb;
  --tier-hot:     #1c5cab;
  --tier-warm:    #3987e5;
  --tier-cold:    #86b6ef;

  /* Status — reserved, always with a label */
  --good:         #0ca30c;
  --good-ink:     #006300;
  --warning:      #fab219;
  --critical:     #d03b3b;

  --radius:       10px;
  --radius-sm:    7px;
  --shadow:       0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05);
  /* Edge cue on a table that scrolls sideways. Dark needs a light shade:
     a black one is invisible against a near-black surface. */
  --scroll-shade: rgba(16, 24, 40, .16);
  --sidebar-w:    236px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:       #0d0d0d;
    --surface:     #1a1a19;
    --surface-2:   #212120;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --ink-muted:   #898781;
    --hairline:    #2c2c2a;
    --baseline:    #383835;
    --ring:        rgba(255, 255, 255, .10);
    --brand:       #e08c3c;
    --brand-ink:   #1a1a19;
    --brand-wash:  #2a1f10;
    --series:      #3987e5;
    --series-soft: #184f95;
    --tier-hot:    #86b6ef;
    --tier-warm:   #3987e5;
    --tier-cold:   #184f95;
    --good-ink:    #0ca30c;
    --shadow:      0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px rgba(0, 0, 0, .3);
    --scroll-shade: rgba(255, 255, 255, .13);
  }
}

/* An author display rule outranks the browser's default [hidden] handling,
   so restore it explicitly. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.011em; }

.wordmark { font-weight: 650; font-size: 15px; letter-spacing: -.015em; }
.wordmark-mark { color: var(--brand); margin-right: 3px; }

/* ============ Sign in ============ */

.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.05fr .95fr; }

.auth-brand {
  background: linear-gradient(160deg, #1c1917 0%, #292524 55%, #3b2a17 100%);
  color: #f5f5f4;
  padding: 48px;
  display: flex;
  align-items: center;
}
.auth-brand-inner { max-width: 420px; }
.auth-brand .wordmark { color: #fff; opacity: .95; }
.auth-brand h1 {
  font-size: clamp(32px, 4vw, 46px);
  line-height: 1.08;
  margin: 28px 0 18px;
  letter-spacing: -.025em;
}
.auth-brand p { color: #d6d3d1; margin: 0 0 32px; font-size: 15px; line-height: 1.6; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.auth-points li {
  display: grid; grid-template-columns: 24px 1fr; gap: 10px;
  color: #d6d3d1; font-size: 13.5px; line-height: 1.5;
}
.auth-points span { color: var(--brand); font-size: 15px; }

.auth-form-pane { display: grid; place-items: center; padding: 40px 32px; background: var(--surface); }
.auth-form { width: min(360px, 100%); display: grid; gap: 16px; }
.auth-form h2 { font-size: 24px; }
.auth-form .sub { margin: -10px 0 6px; color: var(--ink-2); font-size: 13.5px; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 36px 28px; }
  .auth-brand h1 { font-size: 30px; margin: 18px 0 12px; }
  .auth-points { display: none; }
}

/* ============ Shell ============ */

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.sidebar-brand { padding: 0 10px 20px; }
.sidebar nav { display: grid; gap: 2px; flex: 1; align-content: start; }

.sidebar nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit; font-size: 13.5px; color: var(--ink-2);
  cursor: pointer;
}
.sidebar nav button:hover { background: var(--surface-2); color: var(--ink); }
.sidebar nav button[aria-current="true"] {
  background: var(--brand-wash); color: var(--brand); font-weight: 600;
}
.nav-glyph { width: 18px; text-align: center; opacity: .85; font-size: 14px; }

.sidebar-foot { border-top: 1px solid var(--hairline); padding-top: 12px; display: grid; gap: 10px; }
.user { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650; flex: 0 0 auto;
}
.user-meta { display: grid; min-width: 0; }
.user-meta strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 11.5px; color: var(--ink-muted); text-transform: capitalize; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 20;
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar h1 { font-size: 18px; }
.topbar p { margin: 1px 0 0; color: var(--ink-muted); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; }
.topbar .nav-toggle { display: none; }

.view { padding: 24px 26px 56px; max-width: 1280px; width: 100%; }

/* Above the drawer breakpoint the sidebar is always on screen, so the scrim
   must not exist at all — it would cover the whole console. */
.nav-scrim { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; width: var(--sidebar-w);
    height: 100vh; height: 100dvh;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow);
  }
  .shell.nav-open .sidebar { transform: none; }
  .topbar .nav-toggle { display: inline-flex; }
  .view { padding: 18px 16px 48px; }
  .topbar { padding: 14px 16px; }

  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 35;
    border: 0; padding: 0; cursor: pointer;
    background: rgba(0, 0, 0, .42);
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
  }
  .shell.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-scrim { transition: none; }
}

/* ============ Primitives ============ */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--hairline);
}
.card-head h2 { font-size: 13.5px; }
.card-head .hint { color: var(--ink-muted); font-size: 12px; }
.card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.section + .section { margin-top: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-quiet { background: var(--surface); border-color: var(--hairline); color: var(--ink-2); }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 6px 9px; background: var(--surface); border-color: var(--hairline); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  padding: 9px 11px; font: inherit; font-size: 13.5px;
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, nav button:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}
input[type="checkbox"] { width: auto; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.field-row > label { flex: 1 1 150px; }
form.stack { display: grid; gap: 14px; }

.form-msg { margin: 0; font-size: 12.5px; }
.form-msg.err { color: var(--critical); }
.form-msg.ok { color: var(--good-ink); }

/* ============ Stat tiles ============ */

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.stats.fixed-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1080px) { .stats.fixed-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .stats, .stats.fixed-4 { grid-template-columns: 1fr; } }
.stat {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 13px 15px;
}
.stat .label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-muted); font-weight: 550;
}
.stat .value { font-size: 25px; font-weight: 600; margin-top: 5px; letter-spacing: -.02em; }
.stat .foot { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot.hot { background: var(--tier-hot); }
.dot.warm { background: var(--tier-warm); }
.dot.cold { background: var(--tier-cold); }

.hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero .figure { font-size: 48px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.hero .caption { color: var(--ink-2); font-size: 13.5px; }

/* ============ Bars ============ */

.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 58px; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-row .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 20px; position: relative; }
.bar-fill {
  height: 100%; background: var(--series);
  border-radius: 0 4px 4px 0;   /* rounded data-end, square at the baseline */
  min-width: 2px; transition: width .3s ease;
}
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 550; }
.bar-row:hover .bar-fill { filter: brightness(1.08); }

/* ============ Tables ============ */

.table-wrap {
  overflow-x: auto;
  /* Edge shadows that appear only while there is more table to scroll to —
     without them a clipped column on a phone just looks like missing data. */
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-shade), transparent) left center / 11px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-shade), transparent) right center / 11px 100% no-repeat scroll;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-muted); background: var(--surface-2);
  border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--hairline); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.strong { font-weight: 550; }

/* ============ Badges ============ */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--hairline); background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.badge.tier .dot { width: 7px; height: 7px; }
.badge.on { color: var(--good-ink); border-color: currentColor; }
.badge.off { color: var(--ink-muted); }
.badge.alert { color: var(--critical); border-color: currentColor; }

/* ============ Feedback ============ */

.empty { padding: 34px 20px; text-align: center; color: var(--ink-muted); font-size: 13px; }
.empty strong { display: block; color: var(--ink-2); font-size: 13.5px; margin-bottom: 3px; }

.skeleton { display: grid; gap: 10px; }
.skeleton i {
  display: block; height: 13px; border-radius: 5px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--hairline) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton i { animation: none; } }

.notice {
  display: flex; gap: 9px; align-items: flex-start;
  background: var(--brand-wash); border: 1px solid var(--brand);
  color: var(--ink-2); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 12.5px; margin-bottom: 16px;
}
.notice b { color: var(--brand); }

.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast {
  background: var(--surface); border: 1px solid var(--hairline); border-left: 3px solid var(--series);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 11px 14px; font-size: 13px; max-width: 340px;
}
.toast.ok { border-left-color: var(--good); }
.toast.err { border-left-color: var(--critical); }

/* ============ Call review (MVP section 29) ============ */

/* Label/value pairs: call facts and extracted fields. */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; }
.kv > div { display: grid; gap: 2px; min-width: 0; }
.kv span { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); }
.kv b { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }

.player { margin-top: 14px; }
.player audio { width: 100%; }

.summary-text { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }

/* The transcript is the longest thing on the page, so it scrolls in place
   rather than pushing the review controls off the bottom. */
.transcript { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; }
.turn { display: grid; gap: 2px; }
.turn .who {
  font-size: 10.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-muted);
}
.turn p {
  margin: 0; padding: 8px 11px; font-size: 13px; line-height: 1.55;
  border-radius: var(--radius-sm); overflow-wrap: anywhere;
}
/* Who is speaking is carried by the label and the alignment, not by colour
   alone — the same rule the tier badges follow. */
.turn.ai p { background: var(--surface-2); border: 1px solid var(--hairline); }
.turn.customer p { background: var(--brand-wash); border: 1px solid var(--brand); }
.turn.customer { justify-items: end; text-align: right; }

.verdict { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.flags {
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 0 0 14px; display: grid; gap: 8px;
}
.flags legend {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-muted); padding: 0 4px;
}
.flags:disabled { opacity: .5; }
.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}

/* ============ Phone layout ============
   Last in the file on purpose: these override base rules defined above. */

@media (max-width: 900px) {
  /* Thumbs, not mouse pointers. The nav toggle matters most — below this it is
     the only way to reach navigation at all. */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { min-width: 40px; min-height: 40px; justify-content: center; }
  .sidebar nav button { min-height: 40px; }
}

@media (max-width: 560px) {
  /* Two 150px fields side by side truncate "September residential leads"
     and the lead-list name in the select. One field per row instead. */
  .field-row > label,
  .field-row > .btn { flex-basis: 100%; }

  /* A card title and its hint on one line leaves the title wrapping over
     three lines in a narrow column. */
  .card-head { flex-direction: column; align-items: flex-start; gap: 3px; }

  /* Reclaim horizontal room so fewer columns are scrolled out of sight. */
  thead th { padding: 9px 11px; }
  tbody td { padding: 10px 11px; }

  /* Full-width bubbles read better than a narrow column pinned to one side. */
  .turn.customer { justify-items: stretch; text-align: left; }
  .verdict .btn { flex: 1 1 100%; }
}
