/* ==========================================================================
   Xyron Relay — UI layer v5 ("signal console")
   Loaded after styles.css. Idea: a calm graphite call console where the only
   loud thing is the orange signal dot — live, active, next action.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3f3f1;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --surface-3: #ececea;
  --ink: #141414;
  --ink-2: #2b2b2b;
  --muted: #66665f;
  --line: #e4e4e0;
  --line-strong: #d3d3cd;
  --signal: #ff5a1f;
  --accent: #e0531c;
  --accent-dark: #b23c0c;
  --button-accent: #c2410c;
  --button-accent-hover: #a8380a;
  --accent-soft: #fff1ea;
  --green: #12805a;
  --green-soft: #e7f5ee;
  --amber: #8a5a00;
  --amber-soft: #fdf3dc;
  --red: #b42335;
  --red-soft: #fdedef;
  --blue: #2f5b85;
  --blue-soft: #ebf2fa;
  --shadow: 0 18px 50px rgba(20, 20, 20, .12);
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, .04);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 248px;
  --rail: #111111;
  --rail-2: #1b1b1b;
  --rail-ink: #f2f2ef;
  --rail-muted: #8f8f88;
  --focus: color-mix(in srgb, var(--signal) 55%, transparent);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-family: var(--font);
}

[data-theme="dark"] {
  --bg: #0d0d0d;
  --surface: #151515;
  --surface-2: #1b1b1b;
  --surface-3: #252525;
  --ink: #f2f2ef;
  --ink-2: #dcdcd7;
  --muted: #a3a39c;
  --line: #262626;
  --line-strong: #333333;
  --accent: #ff7a45;
  --accent-dark: #ff8f61;
  --button-accent: #c2410c;
  --button-accent-hover: #d34a12;
  --accent-soft: #2a1a12;
  --green: #4cc790;
  --green-soft: #12291f;
  --amber: #e7ae45;
  --amber-soft: #2b2312;
  --red: #ff7d8a;
  --red-soft: #321a1e;
  --blue: #86b3ec;
  --blue-soft: #16243a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --rail: #0a0a0a;
  --rail-2: #171717;
}

/* ---------- base ---------- */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; font-feature-settings: "ss01", "cv11"; }
.mono, code { font-family: var(--mono); }
::selection { background: color-mix(in srgb, var(--signal) 28%, transparent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font: 500 .68rem/1.2 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ---------- brand ---------- */
.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: #fff;
  background: #1a1a1a;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  font: 600 .7rem/1 var(--mono);
  letter-spacing: -.02em;
}
.brand-mark::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent);
}
.brand-copy strong { font-size: .98rem; font-weight: 650; letter-spacing: -.02em; }
.brand-copy small { font-size: .66rem; font-weight: 500; letter-spacing: .02em; }

/* ---------- forms ---------- */
label { color: var(--muted); font-size: .72rem; font-weight: 550; letter-spacing: .02em; text-transform: none; }
input, select, textarea {
  min-height: 42px;
  border-color: var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--surface);
  font-size: .9rem;
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent); }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--button-accent); }

/* ---------- buttons ---------- */
.button, .icon-button, .nav-button, .mobile-nav-button { border-radius: 9px; }
.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: .86rem;
  font-weight: 600;
  letter-spacing: -.005em;
  text-decoration: none;
  white-space: nowrap;
}
.button:hover, .icon-button:hover { transform: none; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--button-accent); box-shadow: inset 0 -1px 0 rgba(0,0,0,.18); }
.button.primary:hover { background: var(--button-accent-hover); }
.button.secondary { border: 1px solid var(--line-strong); background: var(--surface); box-shadow: var(--shadow-sm); }
.button.secondary:hover { border-color: color-mix(in srgb, var(--ink) 35%, var(--line-strong)); background: var(--surface-2); }
.button.ghost { color: var(--ink-2); }
.button.ghost:hover { background: var(--surface-3); }
.button.danger { border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.button.small { min-height: 34px; padding: 6px 11px; font-size: .8rem; }
.icon-button { min-height: 36px; padding: 6px 10px; color: var(--ink-2); background: var(--surface-3); font-size: .8rem; font-weight: 600; }
.whatsapp-button { border: 1px solid color-mix(in srgb, #1f9d60 35%, var(--line)); }

/* ---------- login ---------- */
.login-shell { grid-template-columns: minmax(480px, 1.1fr) minmax(420px, .9fr); }
.login-intro {
  color: #f2f2ef;
  background:
    radial-gradient(600px 400px at 85% 10%, rgba(255, 90, 31, .16), transparent 60%),
    #0f0f0f;
}
.login-intro::before {
  opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 85%);
}
.login-intro-copy .eyebrow { color: var(--signal); }
.login-intro-copy .eyebrow::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 4px rgba(255,90,31,.2); vertical-align: 1px; }
.login-intro-copy h1 { font-size: clamp(2.8rem, 5.6vw, 5.4rem); font-weight: 650; line-height: .95; letter-spacing: -.055em; }
.login-intro-copy > p:last-child { color: rgba(242,242,239,.62); font-size: 1.02rem; }
.login-capabilities { border-color: rgba(255,255,255,.1); border-radius: 14px; background: rgba(255,255,255,.08); }
.login-capabilities article { min-height: 0; padding: 18px 20px; background: #141414; }
.capability-index { color: var(--signal); font-family: var(--mono); }
.login-capabilities strong { font-weight: 600; }
.login-capabilities p { color: rgba(242,242,239,.5); }
.assurance-dot { background: var(--signal); box-shadow: 0 0 0 4px rgba(255,90,31,.18); }
.login-access { background: var(--bg); }
.login-card { border-radius: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 24px 60px rgba(20,20,20,.08); }
.login-card h2 { font-size: clamp(1.7rem, 2.6vw, 2.1rem); font-weight: 650; letter-spacing: -.04em; }
.secure-kicker { color: var(--ink-2); font-weight: 600; }
.secure-icon { background: var(--ink); }
.login-card .button.primary.full { min-height: 46px; font-size: .92rem; }
.login-card .button.secondary.full { min-height: 46px; }

/* ---------- app shell: sidebar ---------- */
.sidebar {
  padding: 18px 12px 14px;
  border-right: 1px solid rgba(255,255,255,.06);
  background: var(--rail);
}
.sidebar-brand { padding: 2px 8px 18px; }
.account-chip {
  position: relative;
  margin: 0 0 14px;
  padding: 10px 12px 10px 30px;
  border-color: rgba(255,255,255,.07);
  border-radius: 10px;
  background: var(--rail-2);
}
.account-chip::before { content: ""; position: absolute; left: 12px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: #3ccf8e; box-shadow: 0 0 0 3px rgba(60,207,142,.18); }
.account-chip strong { font-size: .84rem; font-weight: 600; }
.account-chip span { margin-top: 2px; color: var(--rail-muted); font-size: .7rem; text-transform: none; }
.main-nav { gap: 2px; }
.nav-group-label {
  display: block;
  margin: 14px 10px 6px;
  color: #6d6d67;
  font: 500 .64rem/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.nav-group-label:first-child { margin-top: 2px; }
.nav-button {
  position: relative;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  color: #b4b4ad;
  font-size: .86rem;
  font-weight: 500;
}
.nav-button > span:first-child { width: 18px; height: 18px; border-radius: 0; color: inherit; background: transparent; }
.nav-button:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-button.active { color: #fff; background: rgba(255,255,255,.08); }
.nav-button.active > span:first-child { color: var(--signal); background: transparent; }
.nav-button.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--signal); }
.sidebar-foot { gap: 2px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot .nav-button { min-height: 34px; font-size: .8rem; color: #8f8f88; }
.sidebar-foot .nav-button > span:first-child { font-size: .8rem; }
.sidebar .danger-text { color: #f0a0a0; }

/* SVG line icons drawn with masks (no emoji, inherits currentColor) */
.nav-icon { display: inline-block; flex: none; width: 18px; height: 18px; font-size: 0 !important; color: inherit; background-color: currentColor !important; -webkit-mask: var(--icon) center / 18px 18px no-repeat; mask: var(--icon) center / 18px 18px no-repeat; }
.nav-icon[data-icon="overview"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3Cpath d='M10 21v-6h4v6'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="communications"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 12h-6l-2 3h-4l-2-3H2'/%3E%3Cpath d='M5.5 5.1 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.5-6.9A2 2 0 0 0 16.8 4H7.2a2 2 0 0 0-1.7 1.1z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="dialer"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8 9.8a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.7 2z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="whatsapp"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.9 20A9 9 0 1 0 4 16.1L2 22z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="leads"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.9'/%3E%3Cpath d='M16 3.1a4 4 0 0 1 0 7.8'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="followups"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="appointments"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="distribution"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 3h5v5'/%3E%3Cpath d='M8 3H3v5'/%3E%3Cpath d='M12 22v-8.3a4 4 0 0 0-1.2-2.9L3 3'/%3E%3Cpath d='m15 9 6-6'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="team"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="quality"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 12h-4l-3 9L9 3l-3 9H2'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="commissions"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2v20'/%3E%3Cpath d='M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/%3E%3C/svg%3E"); }
.nav-icon[data-icon="more"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Ccircle cx='5' cy='12' r='1.8'/%3E%3Ccircle cx='12' cy='12' r='1.8'/%3E%3Ccircle cx='19' cy='12' r='1.8'/%3E%3C/svg%3E"); }

/* ---------- topbar ---------- */
.workspace { background: var(--bg); }
.topbar {
  min-height: 64px;
  gap: 14px;
  padding: 12px clamp(18px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
}
.topbar .eyebrow { margin-bottom: 3px; font-size: .62rem; }
.topbar h1 { font-size: 1.28rem; font-weight: 650; letter-spacing: -.03em; }
.topbar-actions { gap: 8px; align-items: center; }
.page-content { max-width: 1480px; padding: 22px clamp(18px, 3vw, 36px) 64px; }

/* ---------- surfaces ---------- */
.metric-card, .panel { border-color: var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel { padding: 18px; }
.page-content > .panel + .panel, .page-content > .panel + section, .page-content > section + .panel, .page-content > section + section { margin-top: 14px; }
.dashboard-grid > .panel { margin-top: 0; }
.dashboard-grid .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-head { margin-bottom: 14px; }
.panel-head h2, .collapsible-panel > summary h2 { font-size: .98rem; font-weight: 620; letter-spacing: -.015em; }
.panel-head p, .collapsible-panel > summary p { font-size: .78rem; }
.notice { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }

/* compact greeting strip instead of the marketing hero */
.workspace-hero {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  margin-bottom: 14px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.workspace-hero::after { display: none; }
.workspace-hero .eyebrow { color: var(--muted); }
.workspace-hero h2 { margin: 0; font-size: 1.5rem; font-weight: 650; line-height: 1.15; letter-spacing: -.035em; }
.workspace-hero-copy > p:last-of-type { margin: 4px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.4; }
.workspace-hero-copy > p:last-of-type::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 20%, transparent); vertical-align: 1px; }
.workspace-hero-actions { margin-top: 0; gap: 8px; flex-wrap: nowrap; }
.workspace-hero .button.secondary { color: var(--ink); border-color: var(--line-strong); background: var(--surface); }
.workspace-safeguards { display: none; }

/* metrics */
.metrics-grid { gap: 10px; }
.metric-card { min-height: 0; padding: 14px 16px 13px; }
.metric-card::after { display: none; }
.metric-top, .metric-label { color: var(--muted); font: 500 .66rem/1.25 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.metric-value { margin-top: 10px; font: 600 1.85rem/1 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.04em; color: var(--ink); }
.metric-value.accent { color: var(--ink); }
.metric-value.accent::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--signal); vertical-align: 6px; }
.metric-value.green { color: var(--green); }
.metric-value.amber { color: var(--amber); }
.metric-value.red { color: var(--red); }
.metric-foot, .metric-note { display: block; margin-top: 6px; color: var(--muted); font-size: .74rem; }
.dialer-metrics .metric-card { display: grid; align-content: start; }
.dialer-metrics .metric-value { margin-top: 8px; font-family: var(--font); }

.dashboard-grid { gap: 14px; margin-top: 14px; }
.quick-grid { gap: 8px; }
.quick-action {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  min-height: 0;
  padding: 13px 14px;
  border-radius: 11px;
  background: var(--surface);
}
.quick-action > span:first-child { grid-row: span 2; width: 34px; height: 34px; border-radius: 9px; color: var(--ink); background: var(--surface-3); font-size: .9rem; }
.quick-action strong { margin-top: 0; font-size: .86rem; font-weight: 600; }
.quick-action span { margin-top: 2px; font-size: .74rem; }
.quick-action:hover { border-color: var(--line-strong); background: var(--surface-2); }
.quick-action:hover > span:first-child { color: #fff; background: var(--button-accent); }

.activity-list { gap: 0; }
.activity-item { grid-template-columns: 8px 1fr auto; padding: 9px 0; border-top: 1px solid var(--line); }
.activity-item:first-child { border-top: 0; padding-top: 0; }
.activity-dot { width: 7px; height: 7px; margin-top: 6px; background: var(--line-strong); }
.activity-item:first-child .activity-dot { background: var(--signal); }
.activity-item strong { font-weight: 560; }
.activity-item time { font-family: var(--mono); font-size: .68rem; }
.avatar, .dialer-avatar { color: var(--ink); background: var(--surface-3); font-weight: 600; }

/* ---------- badges ---------- */
.badge { min-height: 22px; padding: 2px 8px; border-radius: 6px; font-size: .7rem; font-weight: 560; }

/* ---------- leads ---------- */
.lead-controls { padding: 12px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.quick-filter-row { flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin: -2px -12px 10px; padding: 2px 12px 2px; scrollbar-width: none; }
.quick-filter-row::-webkit-scrollbar { display: none; }
.filter-kicker { flex: none; font-family: var(--mono); font-weight: 500; }
.filter-chip { flex: none; min-height: 30px; padding: 4px 11px; border-radius: 999px; background: var(--surface); font-size: .74rem; font-weight: 550; white-space: nowrap; }
.filter-chip:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-2); }
.filter-chip.active, .filter-chip[aria-pressed="true"] { border-color: var(--ink); color: #fff; background: var(--ink); box-shadow: none; }
.toolbar { gap: 8px; }
.toolbar .field { display: grid; gap: 5px; min-width: 140px; }
.advanced-filters summary { color: var(--ink-2); font-size: .78rem; font-weight: 600; }
.advanced-filters summary::marker { color: var(--muted); }
.lead-actions-row { flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 10px; }
.result-summary { color: var(--ink-2); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border-radius: 11px; background: var(--ink); }
.bulk-actions.hidden { display: none !important; }
.bulk-count { margin-right: 4px; color: #fff; font-size: .78rem; font-weight: 600; }
.bulk-actions .button { min-height: 32px; padding: 5px 10px; font-size: .76rem; }
.bulk-actions .button.secondary { color: #fff; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); box-shadow: none; }
.bulk-actions .button.ghost { color: #d9d9d4; }
.bulk-actions .button.danger { color: #ffb4bd; border-color: rgba(255,120,135,.35); background: rgba(255,120,135,.12); }

.table-panel { padding: 0; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); font: 500 .66rem var(--mono); letter-spacing: .06em; }
td { padding: 12px 12px; font-size: .84rem; }
td:last-child, th:last-child { padding-right: 16px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
.business-cell strong { font-weight: 600; letter-spacing: -.01em; }
.business-cell .website-state { padding: 2px 7px; border-radius: 6px; font: 500 .64rem var(--mono); text-transform: none; }
.business-cell .website-state.pending, .business-cell .website-state.verified { box-shadow: none; }
.phone-link, .email-link { color: var(--ink); font-weight: 550; }
.contact-cell { font-family: var(--mono); font-size: .8rem; }
.email-state { font-family: var(--mono); font-weight: 500; text-transform: none; letter-spacing: 0; }
.rating { display: inline-block; color: var(--ink); font-weight: 600; }
.rating::first-letter { color: #e0a100; }
.table-actions { flex-wrap: nowrap; align-items: center; gap: 4px; min-width: 0; }
.business-cell { min-width: 170px; max-width: 260px; }
.contact-cell { min-width: 180px; max-width: 210px; }
.contact-cell .phone-link, .contact-cell > span { white-space: nowrap; }
.contact-cell .email-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
td[data-label="Rating"] { white-space: nowrap; }
.activity-cell { display: grid; gap: 2px; min-width: 140px; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.activity-cell .activity-owner { color: var(--ink); font-size: .82rem; font-weight: 550; }
.activity-cell .followup-due { color: var(--amber); font-weight: 600; }
td[data-label="Rating"] .muted { font-size: .74rem; }
.row-menu { position: relative; }
.row-menu > summary.button { gap: 4px; }
.row-menu > summary::after { content: "▾"; margin-left: 2px; font-size: .62rem; }
.action-menu-popover { min-width: 210px; padding: 5px; border-radius: 11px; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 14px 40px rgba(20,20,20,.16); }
.menu-action { display: block; width: 100%; padding: 9px 10px; color: var(--ink); font-size: .82rem; font-weight: 500; text-decoration: none; }
.menu-action:hover, .menu-action:focus-visible { color: var(--ink); background: var(--surface-3); }
.menu-action.danger-text { color: var(--red); }
.menu-action.danger-text:hover { color: var(--red); background: var(--red-soft); }
.pagination { padding: 10px 14px; }

/* ---------- dialer ---------- */
.dialer-setup { border: 1px solid var(--line); border-left: 3px solid var(--line-strong); background: var(--surface); }
.dialer-setup.ready { border-left-color: var(--green); }
.dialer-setup.waiting { border-left-color: var(--signal); }
.dialer-setup h2 { font-size: 1.08rem; font-weight: 620; letter-spacing: -.02em; }
.dialer-ready-badge { min-height: 26px; padding: 3px 10px; border-radius: 6px; font: 600 .66rem var(--mono); }
.dialer-queue { gap: 6px; }
.dialer-queue-item { gap: 12px; padding: 11px 12px; border-radius: 11px; background: var(--surface); }
.dialer-queue-item:hover { border-color: var(--line-strong); background: var(--surface-2); }
.dialer-queue-copy strong { font-weight: 600; }
.dialer-avatar { width: 38px; height: 38px; }
.dialer-display { border-color: var(--line); background: var(--surface-2); }
.dialer-status { font-family: var(--mono); font-weight: 500; }
.dialer-timer { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; }
.dialer-context span { font-family: var(--mono); font-weight: 500; }

/* ---------- inbox ---------- */
.page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.status-strip { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.status-strip > div { display: grid; gap: 2px; min-width: 0; }
.status-strip strong { font-size: .86rem; font-weight: 600; overflow-wrap: anywhere; }
.status-strip span.muted { font-size: .76rem; }
.status-strip.warn { border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); background: color-mix(in srgb, var(--amber-soft) 45%, var(--surface)); }
.status-dot.good { background: #18a56b; }
.comms-call-toolbar, .android-status-card, .incoming-call-row { border-radius: 11px; }
.sms-shell, .wa-shell { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.comms-avatar { background: #1d1d1d; color: #fff; }
.sms-conversation-item:hover, .sms-conversation-item.selected { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.sms-message.outbound { background: color-mix(in srgb, var(--accent-soft) 85%, var(--surface)); }
.sms-chat-pane { background: var(--surface-2); }

/* ---------- modals ---------- */
.modal { border-radius: 16px; }
.modal::backdrop { background: rgba(10, 10, 10, .5); backdrop-filter: blur(3px); }
.modal-card { gap: 12px; padding: 22px; }
.modal-head h2 { font-size: 1.25rem; font-weight: 650; letter-spacing: -.03em; }
.form-grid > div { gap: 5px; }

/* ---------- toasts ---------- */
.toast-region { top: auto; right: 18px; bottom: 18px; pointer-events: none; }
.toast {
  position: relative;
  min-width: 240px;
  padding: 11px 14px 11px 30px;
  border: 0;
  border-radius: 11px;
  color: #f2f2ef;
  background: #161616;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  font-size: .82rem;
  pointer-events: auto;
  cursor: pointer;
  animation: relay-toast-in .18s ease both;
}
.toast::before { content: ""; position: absolute; left: 13px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: #3ccf8e; }
.toast.error::before { background: #ff6b6b; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes relay-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- loading: skeleton instead of a spinner box ---------- */
.loading-state { display: grid; gap: 10px; padding: 18px; border-style: solid; color: transparent; font-size: 0; }
.loading-state .spinner { display: none; }
.loading-state::before, .loading-state::after { content: ""; display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: relay-shimmer 1.1s linear infinite; }
.loading-state::before { width: 42%; }
.loading-state::after { height: 120px; }
@keyframes relay-shimmer { to { background-position: -200% 0; } }

/* ---------- team & admin tidy-ups ---------- */
.team-stat strong { font-family: var(--font); font-weight: 600; font-variant-numeric: tabular-nums; }
.team-stat span { font-family: var(--mono); }
.role-control-card { background: var(--surface); }
.number-fleet-row { border-radius: 11px; background: var(--surface); }
.health-chip { border-radius: 6px; }
.quality-metrics .metric-card { cursor: pointer; }

/* ==========================================================================
   Tablet (≤ 1180px)
   ========================================================================== */
@media (max-width: 1180px) {
  .workspace-hero { grid-template-columns: 1fr; }
  .workspace-hero-actions { flex-wrap: wrap; }

  /* lead table becomes compact cards before it starts to squeeze */
  .leads-table { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .leads-table .table-scroll { overflow: visible; }
  .leads-table .table-scroll table, .leads-table .table-scroll tbody { display: block; }
  .leads-table .table-scroll thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .leads-table .table-scroll tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; }
  .leads-table .table-scroll tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .leads-table .table-scroll tr:hover { background: var(--surface); border-color: var(--line-strong); }
  .leads-table .table-scroll td { display: block; min-height: 0; padding: 0; border: 0; font-size: .8rem; }
  .leads-table .table-scroll td::before { display: none; }
  .leads-table .table-scroll td[data-label="Business"] { grid-column: 1; }
  .leads-table .table-scroll td[data-label="Status"] { grid-column: 2; grid-row: 1; justify-self: end; }
  .leads-table .table-scroll td[data-label="Contact"] { grid-column: 1 / -1; }
  .leads-table .table-scroll td[data-label="Rating"] { grid-column: 1 / -1; display: flex; gap: 6px; align-items: baseline; color: var(--muted); }
  .leads-table .table-scroll td[data-label="Rating"] .muted::before { content: "· "; }
  .leads-table .table-scroll td[data-label="Activity"] { grid-column: 1 / -1; }
  .activity-cell { display: flex; flex-wrap: wrap; gap: 2px 12px; min-width: 0; white-space: normal; }
  .activity-cell .activity-owner { font-size: .76rem; }
  .leads-table .table-scroll td[data-label="Actions"] { grid-column: 1 / -1; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
  .leads-table .table-scroll td.select-column { position: absolute; top: 14px; right: 14px; width: auto; }
  .leads-table .table-scroll tr:has(td.select-column) td[data-label="Status"] { margin-right: 30px; }
  .leads-table .table-scroll .table-actions { display: flex; flex-wrap: nowrap; gap: 6px; }
  .leads-table .table-scroll .table-actions > .button, .leads-table .table-scroll .table-actions > .row-menu { flex: 1 1 0; min-width: 0; }
  .leads-table .table-scroll .table-actions .button { min-height: 40px; width: 100%; }
  .leads-table .table-scroll .row-menu > summary { width: 100%; }
  .leads-table .table-scroll .row-menu .action-menu-popover { right: 0; left: auto; }
  .business-cell span { margin-top: 2px; }
  .contact-cell { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
  .leads-table .pagination { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
}

/* ==========================================================================
   Phone + small tablet (≤ 820px)
   ========================================================================== */
@media (max-width: 820px) {
  :root { --sidebar: 280px; }
  .login-intro { padding: 28px 22px 30px; }
  .login-intro-copy { margin: 44px 0 0; }
  .login-intro-copy h1 { font-size: clamp(2.3rem, 10vw, 3.6rem); }
  .login-intro-copy > p:last-child { margin-top: 14px; font-size: .92rem; }
  .login-capabilities, .login-assurance { display: none; }
  .login-access { padding: 18px 14px 40px; }

  .sidebar { box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .topbar { min-height: 58px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: color-mix(in srgb, var(--bg) 90%, transparent); }
  .topbar h1 { font-size: 1.08rem; }
  #mobile-menu { position: relative; display: grid; place-items: center; width: 40px; min-width: 40px; min-height: 40px; padding: 0; border-radius: 10px; color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 0; }
  #mobile-menu::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h10'/%3E%3C/svg%3E") center / 18px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h10'/%3E%3C/svg%3E") center / 18px no-repeat; }
  .topbar-actions #refresh-button { width: 40px; min-width: 40px; min-height: 40px; }
  .topbar-actions #primary-action { min-height: 40px; }
  .page-content { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }

  .mobile-nav {
    min-height: 62px;
    gap: 0;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: none;
    backdrop-filter: saturate(1.4) blur(16px);
  }
  .mobile-nav-button { position: relative; gap: 3px; min-height: 52px; padding: 6px 2px 4px; border-radius: 10px; color: var(--muted); font-size: .64rem; font-weight: 550; }
  .mobile-nav-button .nav-icon { width: 20px; height: 20px; -webkit-mask-size: 20px 20px; mask-size: 20px 20px; }
  .mobile-nav-button.active { color: var(--ink); background: transparent; }
  .mobile-nav-button.active::before { content: ""; position: absolute; top: 2px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--signal); }
  .mobile-nav-button.active .nav-icon { color: var(--ink); }

  .workspace-hero { padding: 14px 14px; gap: 12px; margin-bottom: 10px; }
  .workspace-hero h2 { font-size: 1.25rem; }
  .workspace-hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .workspace-hero-actions .button { width: 100%; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric-card { padding: 12px 13px; }
  .metric-value { font-size: 1.55rem; }
  .metrics-grid > .metric-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .panel { padding: 14px; }
  .dashboard-grid { gap: 10px; margin-top: 10px; }

  .lead-controls { padding: 10px; }
  .quick-filter-row { margin: -2px -10px 8px; padding: 2px 10px; }
  .filter-chip { flex: none; text-align: center; }
  .filter-kicker { width: auto; }
  .primary-filters { display: grid; grid-template-columns: 1fr 1fr; }
  .primary-filters .search-field { grid-column: 1 / -1; }
  .primary-filters .field:last-child:nth-child(even) { grid-column: 1 / -1; }
  .primary-filters .field, .primary-filters .search-field, .advanced-toolbar .field { min-width: 0; }
  .advanced-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .lead-actions-row .toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .lead-actions-row .toolbar-actions > .button, .lead-actions-row .toolbar-actions > .action-menu { flex: 1 1 28%; min-width: 0; }
  .lead-actions-row .toolbar-actions > .action-menu > summary { width: 100%; justify-content: center; }
  .bulk-actions { width: 100%; }
  .table-scroll td::before { font-family: var(--mono); font-weight: 500; }
  .toast-region { right: 12px; left: 12px; bottom: calc(74px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }

  .page-actions { justify-content: flex-start; }
  .status-strip { align-items: flex-start; }
}

@media (max-width: 680px) {
  .leads-table .table-scroll tbody { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .advanced-toolbar { grid-template-columns: 1fr; }
  .filter-chip { flex: none; }
  .quick-filter-row { align-items: center; }
  .dialer-queue-actions { gap: 6px; }
  .button.small { min-height: 40px; }
}

/* touch devices: make every target at least 44px, keep hover looks off */
@media (hover: none), (pointer: coarse) {
  .button, .button.small, .filter-chip, .nav-button, .menu-action { min-height: 44px; }
  .filter-chip { min-height: 36px; }
  tbody tr:hover { background: inherit; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-state::before, .loading-state::after { animation: none; }
}

/* ---------- v5 fixes: inbox lists, overflow buttons ---------- */
.wa-conversation-list, .sms-conversation-list, .wa-shortcut-list, .dialer-queue, .incoming-call-list { align-content: start; }
.wa-conversation-item, .sms-conversation-item { align-content: center; align-items: center; }
.table-actions > .button { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 820px) {
  .page-actions .badge { display: none; }
  .page-actions .button { width: 100%; }
}
.modal-card > label, .modal-card > .stack > label { margin-bottom: -6px; }
@media (max-width: 820px) {
  .bulk-actions { display: grid; grid-template-columns: 1fr 1fr; padding: 8px; }
  .bulk-actions .bulk-count { grid-column: 1 / -1; padding: 2px 4px; }
  .bulk-actions .button { width: 100%; white-space: normal; }
}
.page-content.is-loading > :not(.loading-state) { opacity: .55; pointer-events: none; transition: opacity .15s ease .05s; }

/* other data tables: keep the action column in view on desktop */
@media (min-width: 821px) {
  .table-panel:not(.leads-table) .table-scroll th:last-child,
  .table-panel:not(.leads-table) .table-scroll td:last-child { position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: -1px 0 0 var(--line); }
  .table-panel:not(.leads-table) .table-scroll th:last-child { background: var(--surface-2); }
  .table-panel:not(.leads-table) td:first-child { white-space: nowrap; }
}
@media (max-width: 820px) {
  .table-panel:not(.leads-table) .table-scroll tr { border-radius: var(--radius); }
  .table-panel:not(.leads-table) .table-scroll td { display: block; min-height: 0; padding: 9px 12px; overflow-wrap: anywhere; }
  .table-panel:not(.leads-table) .table-scroll td::before { display: block; margin-bottom: 3px; font: 500 .62rem/1.2 var(--mono); letter-spacing: .06em; }
  .table-panel:not(.leads-table) .table-scroll td:not([data-label])::before, .table-panel:not(.leads-table) .table-scroll td[data-label=""]::before { display: none; }
  .table-panel:not(.leads-table) .table-scroll td .table-actions, .table-panel:not(.leads-table) .table-scroll td > div:only-child:has(> .button) { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .table-panel:not(.leads-table) .table-scroll td .button { width: 100%; min-height: 42px; }
  .table-panel:not(.leads-table) .clamp-text { max-width: none; white-space: normal; }
}

/* ---------- call screen: call controls always in view on desktop ---------- */
@media (min-width: 821px) {
  .mobile-only { display: none !important; }
  .dialer-modal { width: min(1080px, calc(100vw - 40px)); }
  .dialer-modal-card { width: 100%; padding: 0; gap: 0; overflow: hidden; }
  .dialer-modal-card > .modal-head { margin: 0; padding: 18px 22px; border-bottom: 1px solid var(--line); }
  .dialer-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); min-height: 0; max-height: calc(100vh - 120px); }
  .dialer-col-info { display: grid; align-content: start; gap: 12px; padding: 18px 22px 22px; overflow-y: auto; }
  .dialer-col-call { display: grid; align-content: start; gap: 12px; padding: 18px 22px 22px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface-2); }
  .dialer-col-call .dialer-audio-panel { grid-template-columns: 1fr; background: var(--surface); }
  .dialer-col-call .dialer-audio-controls { grid-template-columns: 1fr 1fr; }
  .dialer-col-call .dialer-audio-buttons { justify-content: flex-start; }
  .dialer-col-call .dialer-display { order: -1; padding: 22px 16px; background: var(--surface); }
  .dialer-col-call .dialer-controls { order: -1; grid-template-columns: 1.4fr 1fr 1fr; }
  .dialer-col-call #dialer-error { order: -1; min-height: 0; margin: 0; }
  .dialer-col-call #dialer-error:empty { display: none; }
  .dialer-col-call .dialer-controls .button { min-height: 48px; font-size: .92rem; }
  .dialer-col-info .dialer-context-actions .button { min-height: 36px; padding: 6px 11px; font-size: .8rem; }
}
.dialer-layout { display: contents; }
@media (min-width: 821px) { .dialer-layout { display: grid; } }
.dialer-col-info, .dialer-col-call { min-width: 0; }
@media (max-width: 820px) {
  .dialer-col-info, .dialer-col-call { display: contents; }
}
.dialer-contact strong { font-size: 1.05rem; font-weight: 620; letter-spacing: -.02em; }
.dialer-timer { font-size: 2.6rem; letter-spacing: 0; }
.call-readiness { display: none; }
.workflow-strip { display: none; }
@media (max-width: 820px) {
  .dialer-audio-panel { order: 10; }
  #dialer-log-outcome { order: 11; }
  .dialer-safety-note { order: 12; }
  .dialer-display { padding: 18px 12px; }
}
#dialer-error:empty { display: none; }
