/* ===========================================================================
   Vistara Health Advisors — design system
   Brand palette pulled from the logo: deep navy, sunrise orange, road blue.
   =========================================================================== */
:root {
  /* Brand */
  --navy-900: #0E1B3D;
  --navy-800: #14274E;
  --navy-700: #1D3462;
  --navy-600: #294a86;
  --orange:   #EC8324;
  --orange-strong: #D9721A;
  --orange-soft:   #FDECD8;
  --blue:     #2E6FED;
  --blue-soft:#E5EDFD;
  --amber:    #F6A21E;

  /* Neutrals / surfaces */
  --bg: #EEF2F9;
  --panel: #ffffff;
  --panel-raised: #F3F6FB;
  --border: #E4E9F2;
  --border-strong: #D3DBEA;
  --text: #17223D;
  --text-dim: #667089;
  --text-mute: #97A1B5;

  /* Semantic */
  --accent: var(--orange);        /* primary actions */
  --accent-dim: var(--orange-strong);
  --success: #0E9F6E;
  --success-soft: #DFF3EB;
  --danger: #E5484D;
  --danger-soft: #FCE6E7;
  --warn: #D9822B;
  --warn-soft: #FBECD9;
  --info: var(--blue);
  --info-soft: var(--blue-soft);

  /* Shape & depth */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(16,33,62,.06), 0 1px 3px rgba(16,33,62,.05);
  --shadow-md: 0 6px 20px rgba(16,33,62,.08);
  --shadow-lg: 0 18px 48px rgba(16,33,62,.16);
  --ring: 0 0 0 3px rgba(236,131,36,.22);

  --mono: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: 'Marcellus', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

/* Dark mode — overrides the neutral/surface tokens. The navy sidebar already
   reads as dark, so this mainly darkens the content surfaces + soft badges. */
body.theme-dark {
  --bg: #0b1220;
  --panel: #131c31;
  --panel-raised: #1b2740;
  --border: #263450;
  --border-strong: #33456a;
  --text: #e7ecf6;
  --text-dim: #9aa7c2;
  --text-mute: #6b7896;
  --success-soft: rgba(14,159,110,.20);
  --danger-soft: rgba(229,72,77,.20);
  --warn-soft: rgba(217,130,43,.20);
  --info-soft: rgba(46,111,237,.22);
  --orange-soft: rgba(236,131,36,.20);
  --blue-soft: rgba(46,111,237,.22);
  --shadow-md: 0 6px 20px rgba(0,0,0,.4);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
/* Responsive rules live at the end of the file so they override base rules. */

/* ------------------------------------------------------------------ Sidebar */
.sidebar {
  background: #5050ff;
  color: #cdd6ea;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: 0;
  height: 100vh;
  /* Scroll internally when the nav is taller than the viewport so the navy
     background always covers the full column (incl. the footer). */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

/* Brand lockup: logo chip + wordmark */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.sidebar__brand-chip {
  width: 44px; height: 44px;
  flex: none;
  background: transparent;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.sidebar__brand-chip img { width: 40px; height: 40px; display: block; object-fit: contain; }
.sidebar__brand-name {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: .14em;
  color: var(--navy-800);
  line-height: 1;
}
.sidebar__brand-sub {
  font-size: 9px;
  letter-spacing: .22em;
  color: var(--orange);
  font-weight: 600;
  margin-top: 4px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,.92);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background .15s ease, color .15s ease;
}
.sidebar__link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.sidebar__link.active {
  background: rgba(236,131,36,.16);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--orange);
}

.sidebar__footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.09);
  font-size: 12px;
  color: #93a0bd;
}
.sidebar__footer #whoami, .sidebar__footer > div:first-child { padding: 0 8px 4px; color: rgba(255,255,255,.9); font-weight: 600; }
.sidebar__footer .sidebar__link { color: rgba(255,255,255,.8); font-size: 13px; }
.sidebar__footer .sidebar__link:hover { color: #fff; }

/* --------------------------------------------------------------- Main area */
.main {
  padding: 30px 34px 48px;
  overflow-y: auto;
  max-height: 100vh;
}
.main__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.main__title { font-size: 23px; font-weight: 800; margin: 0; letter-spacing: -.01em; color: var(--navy-800); }
.main__subtitle { color: var(--text-dim); font-size: 13px; margin-top: 3px; }

/* -------------------------------------------------------------- Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--orange);
  opacity: .9;
}
.stat-card__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  font-weight: 600;
}
.stat-card__value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 8px;
  color: var(--navy-800);
  letter-spacing: -.02em;
}

/* -------------------------------------- Colored dashboard tiles (EnrollHere-style)
   Each top-of-page metric gets its own hue + icon. Saturated gradient with white
   text so it reads in light AND dark. Use: <div class="tile tile--blue"> with
   .tile__top(.tile__label + .tile__icon) + .tile__value + optional .tile__sub. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.tile {
  --tile-a: #3b82f6; --tile-b: #2563eb;
  position: relative;
  border-radius: var(--radius);
  padding: 15px 17px;
  min-height: 106px;
  color: #fff;
  background: linear-gradient(140deg, var(--tile-a), var(--tile-b));
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
}
.tile__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tile__label { font-size: 12.5px; font-weight: 600; letter-spacing: .01em; opacity: .96; }
.tile__icon {
  flex: none; width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .20);
}
.tile__icon svg { width: 20px; height: 20px; display: block; stroke: #fff; }
.tile__value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; margin-top: 12px; }
.tile__sub { font-size: 11.5px; opacity: .88; margin-top: 4px; }
/* Hue variants — --tile-a lighter (top-left), --tile-b darker (bottom-right). */
.tile--sky    { --tile-a: #38bdf8; --tile-b: #0284c7; }
.tile--blue   { --tile-a: #3b82f6; --tile-b: #2563eb; }
.tile--indigo { --tile-a: #6366f1; --tile-b: #4f46e5; }
.tile--green  { --tile-a: #22c55e; --tile-b: #16a34a; }
.tile--purple { --tile-a: #a855f7; --tile-b: #7c3aed; }
.tile--amber  { --tile-a: #f59e0b; --tile-b: #d97706; }
.tile--pink   { --tile-a: #ec4899; --tile-b: #db2777; }
.tile--teal   { --tile-a: #14b8a6; --tile-b: #0d9488; }
.tile--navy   { --tile-a: var(--navy-600); --tile-b: var(--navy-900); }
.tile--slate  { --tile-a: #64748b; --tile-b: #475569; }
.tile--orange { --tile-a: #f7962f; --tile-b: var(--orange-strong); }

/* ------------------------------------------------------------------ Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.panel__title {
  font-size: 16.5px;
  font-weight: 800;
  margin: 0 0 16px;
  color: var(--navy-800);
  letter-spacing: -.01em;
}
/* A sub-section header inside a panel (any .panel__title that isn't the first
   child) gets a full-width divider above it + generous spacing, so a settings
   page reads as clearly separated blocks (EnrollHere-style sectioning). */
.panel > .panel__title:not(:first-child) {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
/* Optional one-line description under a section header. */
.panel__desc {
  font-size: 13px;
  color: var(--text-dim);
  margin: -10px 0 16px;
}

/* ------------------------------------------------------------------ Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--panel-raised);
  position: sticky; top: 0;
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--panel-raised); }
tr:last-child td { border-bottom: none; }
td.mono, th.mono, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------------------------------------------ Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  background: var(--panel-raised);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge--active, .badge--approved, .badge--completed, .badge--authorized, .badge--available,
.badge--enabled, .badge--standard, .badge--success, .badge--default, .badge--converted,
.badge--sold, .badge--unl-approved, .badge--signed {
  background: var(--success-soft); color: var(--success); border-color: transparent;
}
.badge--inactive, .badge--rejected, .badge--failed, .badge--suspended, .badge--on-call,
.badge--dnc, .badge--do-not-call, .badge--disabled, .badge--dead, .badge--bad-number, .badge--lost {
  background: var(--danger-soft); color: var(--danger); border-color: transparent;
}
.badge--submitted, .badge--pending, .badge--ringing, .badge--in-progress, .badge--wrap-up,
.badge--suppression, .badge--callback, .badge--follow-up, .badge--ic-sent {
  background: var(--warn-soft); color: var(--warn); border-color: transparent;
}
.badge--away, .badge--new, .badge--no-answer, .badge--contacted, .badge--prospect {
  background: var(--info-soft); color: var(--info); border-color: transparent;
}
.badge--offline, .badge--not-interested, .badge--other, .badge--removed {
  background: var(--panel-raised); color: var(--text-dim); border-color: transparent;
}
/* Complaints: severity / status / SLA badges */
.badge--critical, .badge--high, .badge--breached {
  background: var(--danger-soft); color: var(--danger); border-color: transparent;
}
.badge--medium, .badge--at-risk, .badge--open {
  background: var(--warn-soft); color: var(--warn); border-color: transparent;
}
.badge--low, .badge--on-track, .badge--met, .badge--resolved, .badge--scheduled,
.badge--billable, .badge--sold, .badge--sent {
  background: var(--success-soft); color: var(--success); border-color: transparent;
}
.badge--closed, .badge--none {
  background: var(--panel-raised); color: var(--text-dim); border-color: transparent;
}

/* Transcript speaker labels — alternate colors so the two sides of a call read
   at a glance. Odd speakers (A/C/…) blue, even (B/D/…) orange. */
.badge--speaker-a, .badge--speaker-c, .badge--speaker-e {
  background: var(--info-soft); color: var(--info); border-color: transparent;
}
.badge--speaker-b, .badge--speaker-d, .badge--speaker-f {
  background: var(--warn-soft); color: var(--warn); border-color: transparent;
}

/* Grouped sidebar nav (collapsible sections + leaf icons) */
.sidebar__group { display: flex; flex-direction: column; }
.sidebar__group-head {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 12px 5px; margin-top: 2px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  color: rgba(255,255,255,.8); font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.sidebar__group-head:hover { color: #fff; }
.sidebar__group-head svg { width: 13px; height: 13px; flex: none; transition: transform .18s ease; opacity: .8; }
.sidebar__group.collapsed .sidebar__group-head svg { transform: rotate(-90deg); }
.sidebar__group.collapsed .sidebar__group-items { display: none; }
.sidebar__group-items { display: flex; flex-direction: column; gap: 2px; }
.sidebar__link svg.nav-ico { width: 17px; height: 17px; flex: none; opacity: .78; }
.sidebar__link:hover svg.nav-ico, .sidebar__link.active svg.nav-ico { opacity: 1; }

/* Segmented control (period toggles) */
.seg { display: inline-flex; background: rgba(0,0,0,.05); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: none; background: none; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-dim); padding: 6px 13px; border-radius: 7px; cursor: pointer; transition: background .12s, color .12s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel); color: var(--navy-800); box-shadow: 0 1px 3px rgba(20,39,78,.12); }

/* Agent performance cards */
.agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.agent-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 13px; transition: box-shadow .15s ease, border-color .15s ease; }
.agent-card:hover { box-shadow: 0 6px 22px rgba(20,39,78,.10); border-color: var(--border-strong); }
.agent-card__head { display: flex; align-items: flex-start; gap: 11px; }
.agent-card__avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: rgba(46,111,237,.13); color: #2E6FED; }
.agent-card__name { font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.2; }
.agent-card__email { font-size: 11.5px; color: var(--text-dim); word-break: break-all; margin-top: 2px; }
.agent-card__open { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--text-mute); padding: 3px; border-radius: 7px; display: flex; }
.agent-card__open:hover { color: var(--orange); background: rgba(236,131,36,.12); }
.agent-card__grade { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.agent-card__label { font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-mute); font-weight: 700; margin-bottom: 4px; }
.agent-card__grade-val { font-size: 27px; font-weight: 800; line-height: 1; }
.agent-card__grade-val small { font-size: 13px; font-weight: 600; color: var(--text-mute); }
.g-hi { color: #1a9d5a; } .g-mid { color: var(--navy-800); } .g-lo { color: #c2410c; }
.agent-card__stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.agent-card__stat { padding: 10px 4px; text-align: center; }
.agent-card__stat + .agent-card__stat { border-left: 1px solid var(--border); }
.agent-card__stat-val { font-size: 16px; font-weight: 700; color: var(--text); }
.agent-card__foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); }
.agent-card__foot .fu { color: #2E6FED; font-weight: 600; }
.spark { display: block; overflow: visible; }

/* Funnel mini indicator (call grid) + stage filter chips */
.funnel-mini { display: inline-flex; gap: 3px; align-items: center; }
.funnel-mini span { width: 11px; height: 5px; border-radius: 2px; background: var(--border-strong); }
.funnel-mini span.on { background: #6d3bef; }
.funnel-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.funnel-chips button { border: 1px solid var(--border-strong); background: var(--panel); color: var(--text-dim); font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 14px; cursor: pointer; font-family: inherit; transition: background .12s, color .12s, border-color .12s; }
.funnel-chips button:hover { color: var(--text); }
.funnel-chips button.on { background: rgba(109,59,239,.12); border-color: #6d3bef; color: #6d3bef; }

/* Call detail page */
.cd-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .cd-cols { grid-template-columns: 1fr; } }
.cd-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.cd-card__title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.cd-kv { display: flex; gap: 10px; font-size: 13px; padding: 5px 0; }
.cd-kv__k { color: var(--text-dim); min-width: 92px; display: inline-flex; align-items: center; gap: 6px; }
.cd-kv__v { color: var(--text); font-weight: 500; }
.cd-funnel-bar { display: flex; gap: 4px; margin: 12px 0 10px; }
.cd-funnel-bar span { flex: 1; height: 6px; border-radius: 3px; background: var(--border-strong); }
.cd-funnel-bar span.on { background: #6d3bef; }
.cd-tag { display: inline-block; background: rgba(0,0,0,.05); color: var(--text-dim); font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 12px; margin: 0 5px 5px 0; }
.cd-sub { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-mute); font-weight: 700; margin: 10px 0 4px; }

/* ---------------------------------------------------- Dialer shell (agent) */
.sidebar__sub { display: flex; flex-direction: column; }
.sidebar__link--child { padding-left: 28px; font-size: 13px; opacity: 0.9; }
.sidebar__link--parent { display: flex; justify-content: space-between; align-items: center; }
.app.sidebar-collapsed .sidebar { width: 64px; overflow: hidden; }
.app.sidebar-collapsed .sidebar__link,
.app.sidebar-collapsed .sidebar__brand-name,
.app.sidebar-collapsed .sidebar__brand-sub,
.app.sidebar-collapsed .sidebar__sub,
.app.sidebar-collapsed #whoami { display: none; }

/* Persistent softphone bar */
.softphone-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 16px; margin-bottom: 16px;
}
/* display:flex above would override the [hidden] attribute — keep hiding working. */
.softphone-bar[hidden] { display: none; }
.softphone-bar__status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.softphone-bar .incoming-banner,
.softphone-bar .active-call { margin: 0; flex: 1; min-width: 260px; }
.active-call {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, rgba(236,131,36,0.10), rgba(236,131,36,0.02));
  border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px;
}
/* The class sets display:flex, which would override the [hidden] attribute the
   JS uses to hide the panel — this makes hiding it actually work. */
.active-call[hidden] { display: none; }

/* Queue type selector (admin queue editor) */
.qtype-row { display: flex; flex-wrap: wrap; gap: 6px; }
.qtype-btn {
  background: var(--panel-raised); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; color: var(--text-dim); cursor: pointer;
}
.qtype-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* Skill / queue chip pickers (admin agent detail) */
.skill-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-chip {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none;
  background: var(--panel-raised); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; color: var(--text-dim);
}
.skill-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* Appointments calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-dim); font-weight: 600; padding: 2px; }
.cal-cell { min-height: 78px; border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; }
.cal-cell--out { opacity: 0.4; }
.cal-day-num { font-size: 11px; font-weight: 600; color: var(--text-dim); }
.cal-appt {
  background: var(--accent); color: #fff; border-radius: 4px; padding: 1px 5px; margin-top: 3px;
  font-size: 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Performance dashboard (phase e) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.stat-tile__label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.stat-tile__value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-tile__sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.dash-legend { display: flex; flex-direction: column; gap: 8px; }
.dash-legend__item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.dash-legend__swatch { width: 12px; height: 12px; border-radius: 3px; }
.dash-legend__item.off { opacity: 0.4; text-decoration: line-through; }
.dash-bars { overflow-x: auto; }

/* Compact search input used across phase-c filter bars */
.inp {
  background: var(--panel-raised); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; color: var(--text); font-size: 13px; min-width: 200px;
}

/* Call Logs filter bar */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-wrap { position: relative; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-raised); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer;
}
.filter-pill--active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 230px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2); padding: 12px;
}
.filter-panel--wide { min-width: 290px; }
.filter-panel hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.filter-preset { text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 7px 10px; color: var(--text); font-size: 13px; cursor: pointer; }
.filter-preset:hover { background: var(--panel-raised); }
.filter-link { background: transparent; border: 0; color: var(--text-dim); font-size: 13px; cursor: pointer; text-decoration: underline; }
.filter-link--muted { background: var(--panel-raised); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; text-decoration: none; }
/* Classic mode: render filter panels inline instead of as dropdowns. */
.filters--classic .filter-panel { position: static; display: block; box-shadow: none; margin-top: 8px; }

/* Call Logs cell icons */
.cell-icon { display: inline-flex; align-items: center; gap: 6px; }
.cell-icon svg { width: 15px; height: 15px; opacity: 0.7; flex-shrink: 0; }
.cell-icon.dir-in { color: var(--success); }
.cell-icon.dir-out { color: var(--info); }
th .col-menu { float: right; color: var(--text-dim); cursor: pointer; opacity: 0.45; font-weight: 700; padding: 0 2px; }
th .col-menu:hover { opacity: 1; }
.icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 7px; padding: 5px 7px; color: var(--text-dim); cursor: pointer; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 15px; height: 15px; display: block; }

/* Tabs (lead detail) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 12px 0 14px; flex-wrap: wrap; }
.tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px; color: var(--text-dim); font-size: 13px; font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Apps switcher cards */
.apps-card {
  display: block; text-decoration: none; color: var(--text);
  background: var(--panel-raised); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
}
.apps-card:hover { border-color: var(--accent); }
.apps-card--current { opacity: 0.7; }

/* Files drop zone */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: 10px; padding: 26px;
  text-align: center; color: var(--text-dim); font-size: 13px; cursor: pointer;
}
.dropzone.dragover { border-color: var(--accent); background: var(--panel-raised); }

/* --------------------------------------------------- Softphone status bar */
.softphone-controls { display: flex; gap: 8px; align-items: center; }
.status-wrap { position: relative; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel-raised); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.status-pill__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); }
.status-pill.is-available .status-pill__dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-pill.is-follow_up .status-pill__dot { background: var(--info); }
.status-pill.is-paused .status-pill__dot { background: var(--warn); }
.status-pill.is-on_call .status-pill__dot,
.status-pill.is-wrap_up .status-pill__dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-pill.is-offline .status-pill__dot { background: var(--text-dim); }

.status-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); padding: 6px; min-width: 200px;
}
.status-menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: 8px; padding: 9px 12px;
  color: var(--text); font-size: 13px; cursor: pointer;
}
.status-menu__item:hover { background: var(--panel-raised); }
.status-submenu {
  margin: 2px 0 2px 8px; padding-left: 6px; border-left: 2px solid var(--border);
  max-height: 260px; overflow-y: auto;
}
.status-menu .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); display: inline-block; }
.status-menu .dot--available { background: var(--success); }
.status-menu .dot--follow_up { background: var(--info); }
.status-menu .dot--paused { background: var(--warn); }
.status-menu .dot--offline { background: var(--text-dim); }

/* ---------------------------------------------------------------- Kanban */
.viewtoggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.viewtoggle .btn { border-radius: 0; border: none; box-shadow: none; }
.viewtoggle .btn.active { background: var(--navy-800); color: #fff; }
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; overflow-x: auto; }
@media (max-width: 1000px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
.kanban__col { background: var(--panel-raised); border: 1px solid var(--border); border-radius: 14px; padding: 12px; min-height: 140px; transition: background .12s ease, outline .12s ease; }
.kanban__col.drop-over { outline: 2px dashed var(--orange); outline-offset: -2px; background: var(--orange-soft); }
.kanban__colhead { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--navy-800); margin-bottom: 10px; }
.kanban__count { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-family: var(--mono); font-weight: 700; }
.kanban__card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow-sm); cursor: grab; }
.kanban__card:hover { border-color: var(--border-strong); }
.kanban__card.dragging { opacity: .45; }
.kanban__card-name { font-weight: 600; font-size: 13px; color: var(--navy-800); }
.kanban__card-meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.kanban__empty { font-size: 12px; color: var(--text-mute); text-align: center; padding: 14px 0; }

/* ------------------------------------------------------------------- Forms */
.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-mute); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--orange);
  box-shadow: var(--ring);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row--3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .field-row, .field-row--3 { grid-template-columns: 1fr; } }

/* Lead detail — grouped, denser form so it reads at a glance */
.lead-detail .field { margin-bottom: 12px; }
.lead-section { margin-bottom: 26px; }
/* Section headers on internal detail/settings pages (agent detail, lead detail).
   Matches .panel__title: big, bold, title-case navy, with a full-width divider
   under it so each block reads as a clearly separated section. */
.lead-section__head {
  font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; text-transform: none;
  color: var(--navy-800); padding-bottom: 12px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.lead-checks { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 2px 0 12px; }
.lead-checks label {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer;
}
.lead-checks input { width: auto; }
.lead-meta {
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-size: 12px; color: var(--text-dim); margin: 2px 0 14px;
}
.lead-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--border);
}

/* ----------------------------------------------------------------- Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--orange); color: #fff; box-shadow: 0 2px 8px rgba(236,131,36,.32); }
.btn--primary:hover:not(:disabled) { background: var(--orange-strong); box-shadow: 0 4px 14px rgba(236,131,36,.38); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #cf3b40; }
.btn--ghost { background: var(--panel); color: var(--navy-800); border-color: var(--border-strong); }
.btn--ghost:hover:not(:disabled) { background: var(--panel-raised); border-color: var(--navy-600); }
.btn--sm { padding: 6px 12px; font-size: 12px; border-radius: 7px; }

/* ------------------------------------------------------------------ Toasts */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy-700);
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 13px;
  font-weight: 500;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  animation: toastIn .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes admInPulse {
  0%   { box-shadow: 0 10px 34px rgba(0,0,0,.32), 0 0 0 0 rgba(236,131,36,.5); }
  70%  { box-shadow: 0 10px 34px rgba(0,0,0,.32), 0 0 0 12px rgba(236,131,36,0); }
  100% { box-shadow: 0 10px 34px rgba(0,0,0,.32), 0 0 0 0 rgba(236,131,36,0); }
}
.toast--error { border-left-color: var(--danger); color: var(--danger); }
.toast--success { border-left-color: var(--success); color: var(--success); }

.empty-state {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 36px 0;
}

/* ------------------------------------------------------------------ Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,27,61,.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
  animation: overlayIn .18s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay[hidden] { display: none; }
.modal-overlay .panel {
  box-shadow: var(--shadow-lg);
  margin: 0;
  animation: modalIn .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------- Live Operations board */
.live-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 1100px) { .live-board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .live-board { grid-template-columns: 1fr; } }

/* Live board → agent performance: clickable affordance */
.agent-card--clickable { cursor: pointer; }
.agent-card--clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }
tr.live-row { cursor: pointer; }
tr.live-row:hover td { background: var(--panel-raised); }

/* ------------------------------------------------ Agent performance modal */
.perf-modal { width: min(1180px, 96vw); max-height: 92vh; overflow-y: auto; padding: 0; }
.perf-modal__head {
  position: sticky; top: 0; z-index: 2; background: var(--panel);
  border-bottom: 1px solid var(--border); padding: 18px 22px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.perf-modal__title { font-size: 20px; font-weight: 800; color: var(--navy-800); letter-spacing: -.01em; }
.perf-modal__headright { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.perf-modal__body { padding: 22px; display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .perf-modal__body { grid-template-columns: 1fr; } }
.perf-main { min-width: 0; }
.perf-main .stat-grid { margin-bottom: 18px; }
.perf-side { display: flex; flex-direction: column; gap: 16px; }
.perf-card { margin: 0; }
.perf-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.perf-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.perf-sup { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.perf-sup__title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-bottom: 9px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.perf-soon { font-size: 10px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--accent); background: var(--orange-soft); padding: 2px 8px; border-radius: 999px; }
.qpill { display: inline-block; border: 1px solid var(--border-strong); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; color: var(--navy-800); margin: 0 6px 7px 0; background: var(--panel-raised); }
.perf-actions .btn.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }

/* --------------------------------------- Agent Performance snapshot (Productivity) */
.perf-snap { display: grid; grid-template-columns: 1.25fr 1fr 1.05fr; gap: 16px; margin-bottom: 16px; align-items: stretch; }
.perf-snap--nocost { grid-template-columns: 1.3fr 1.1fr; }
@media (max-width: 1000px) { .perf-snap, .perf-snap--nocost { grid-template-columns: 1fr; } }
.cm-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.cm-legs { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--text-dim); }
.cm-leg { display: inline-flex; align-items: center; gap: 8px; }
.cm-leg i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.cm-leg b { color: var(--navy-800); font-variant-numeric: tabular-nums; }
.perf-cps { background: var(--success-soft); border: 1px solid rgba(14, 159, 110, .35); display: flex; flex-direction: column; }
.perf-cps__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--success); }
.perf-cps__value { font-size: 40px; font-weight: 800; letter-spacing: -.02em; color: var(--success); margin: 8px 0 auto; }
.perf-cps__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; border-top: 1px solid rgba(14, 159, 110, .25); padding-top: 12px; margin-top: 14px; }
.perf-cps__stats > div { display: flex; flex-direction: column; }
.perf-cps__stats span { font-size: 11px; color: var(--text-dim); }
.perf-cps__stats b { font-size: 15px; color: var(--navy-800); font-variant-numeric: tabular-nums; }
.perf-kcards { display: grid; grid-template-rows: repeat(3, 1fr); gap: 12px; }
.perf-kcard__head { display: flex; align-items: center; justify-content: space-between; }
.perf-kcard__ico { font-size: 18px; line-height: 1; }
tr.prod-row { cursor: pointer; }
tr.prod-row:hover td { background: var(--panel-raised); }

.live-column {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  min-height: 150px;
  box-shadow: var(--shadow-sm);
}
.live-column__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.live-column__header .count {
  background: var(--panel-raised);
  border-radius: 999px;
  padding: 2px 9px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
}
.live-column--on_call { border-top: 3px solid var(--danger); }
.live-column--wrap_up { border-top: 3px solid var(--warn); }
.live-column--available { border-top: 3px solid var(--success); }
.live-column--away { border-top: 3px solid var(--info); }
.live-column--follow_up { border-top: 3px solid var(--info); }
.live-column--paused { border-top: 3px solid var(--warn); }
.live-column--offline { border-top: 3px solid var(--border-strong); }
.live-column--on_call .live-column__header { color: var(--danger); }
.live-column--wrap_up .live-column__header { color: var(--warn); }
.live-column--available .live-column__header { color: var(--success); }
.live-column--away .live-column__header { color: var(--info); }
.live-column--follow_up .live-column__header { color: var(--info); }
.live-column--paused .live-column__header { color: var(--warn); }
.live-column--offline .live-column__header { color: var(--text-dim); }
.live-column__empty { font-size: 12px; color: var(--text-mute); text-align: center; padding: 18px 0; }

.agent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 9px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.agent-card__name {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.agent-card__meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.agent-card__actions { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }

/* --------------------------------------------------- Funnel breakdown cards */
.funnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
}
.funnel-card__count { font-size: 28px; font-weight: 800; color: var(--navy-800); letter-spacing: -.02em; }
.funnel-card__count-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; margin-left: 6px; font-weight: 600; }
.funnel-row { margin-top: 13px; }
.funnel-row__label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 5px;
  font-weight: 600;
}
.funnel-row__bar { height: 7px; background: var(--panel-raised); border-radius: 5px; overflow: hidden; }
.funnel-row__fill { height: 100%; background: linear-gradient(90deg, var(--amber), var(--orange)); border-radius: 5px; }
.funnel-card__footer {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

/* -------------------------------------------------------------- Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(46,111,237,.10), transparent 60%),
    radial-gradient(760px 420px at 92% 108%, rgba(236,131,36,.12), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 38px 36px;
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 26px; }
.login-brand img { width: 84px; height: 84px; margin-bottom: 10px; object-fit: contain; }
.login-brand__name { font-family: var(--serif); font-size: 30px; letter-spacing: .16em; color: var(--navy-800); line-height: 1; }
.login-brand__sub { font-size: 11px; letter-spacing: .26em; color: var(--orange); font-weight: 600; margin-top: 7px; }
.login-brand__tag { font-size: 11px; letter-spacing: .04em; color: var(--text-dim); margin-top: 12px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; color: var(--navy-800); text-align: center; }
.login-card p { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; text-align: center; }

/* ------------------------------------------------------------- Responsive */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  /* Sidebar becomes a compact top bar; nav wraps instead of eating the screen. */
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
  }
  .sidebar__brand { width: 100%; margin-bottom: 4px; padding-bottom: 12px; }
  .sidebar__link { width: auto; padding: 8px 12px; }
  .sidebar__link.active { box-shadow: inset 0 -3px 0 var(--orange); }
  .sidebar__footer {
    margin-top: 8px; width: 100%; padding-top: 12px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  }
  .sidebar__footer #whoami, .sidebar__footer > div:first-child { padding: 0; }
  .main { max-height: none; padding: 22px 18px 40px; }
  .main__title { font-size: 20px; }
}
