/* =====================================================================
   IRE — Investor Relationship Engine
   Design language: "Pulse, refined" — a modern operations tool with a
   strict accent budget. Cool graphite neutrals, one cobalt accent used
   as text-on-tint everywhere except the single primary action, hairline
   structure instead of floating shadows, 10px cards / 6px controls,
   weight-led type on a 500/600/650 scale, tabular numerals, severity
   as a 2px left edge. Red means overdue or failed — nothing else;
   unread is cobalt. Dual theme: tokens flip with the OS preference.
   Every color decision lives in the tokens below — pages must not
   hard-code hex values except for user-chosen status/category colors,
   which are data.
   ===================================================================== */

/* ---- Tokens ---- */
:root {
  color-scheme: light dark;

  /* Neutrals — cool graphite */
  --bg: #f4f5f8;           /* app ground */
  --bg-subtle: #f7f8fb;    /* table heads, quiet fills */
  --bg-hover: #eceef4;     /* row + button hover */
  --inset: #eceef4;        /* segmented controls, markers, inset fills */
  --panel: #ffffff;
  --border: #e5e8ef;       /* hairline */
  --border-strong: #d6dbe5;/* inputs, emphasized rules */
  --text: #131820;         /* ink */
  --muted: #5b6472;
  --faint: #8f97a5;

  /* Accent — cobalt. Budgeted: solid fill is reserved for the primary
     button; everything else (nav, tabs, chips, counts) is cobalt text
     on --accent-tint / --accent-soft. */
  --accent: #2e4fe3;
  --accent-ink: #ffffff;
  --accent-dark: #2440bf;
  --accent-hover: #2440bf;
  --accent-tint: rgba(46, 79, 227, .07);
  --accent-soft: #e8ecfc;

  /* Semantic. Red = overdue/failed only. */
  --ok: #17824f;        --ok-soft: #e3f2ea;
  --warn: #9a6a14;      --warn-soft: #f6eedb;
  --danger: #bb3540;    --danger-soft: #f9e8e9;
  --neutral-ink: #5b6472; --neutral-soft: #eceef4;

  /* Channels */
  --email: #2e4fe3;     --email-soft: #e8ecfc;
  --sms: #6d5bd0;       --sms-soft: #edeafc;      --sms-ink: #ffffff;

  /* Shape & depth. Cards sit on a 1px border + a barely-there shadow;
     real elevation is reserved for overlays (modals, bulk bar). */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --shadow: 0 1px 2px rgba(19, 24, 32, .04);
  --shadow-sm: 0 1px 2px rgba(19, 24, 32, .04);
  --shadow-pop: 0 8px 28px rgba(19, 24, 32, .14);

  /* Legacy aliases still referenced by a few components */
  --ink: var(--text);
  --paper: var(--panel);
  --surface-subtle: var(--bg-subtle);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141d;
    --bg-subtle: #141927;
    --bg-hover: #1c2230;
    --inset: #1e2432;
    --panel: #161b26;
    --border: #242b3b;
    --border-strong: #303a4f;
    --text: #e7ebf4;
    --muted: #99a3b5;
    --faint: #6c7588;

    --accent: #8ba0ff;
    --accent-ink: #10141d;
    --accent-dark: #a3b4ff;
    --accent-hover: #a3b4ff;
    --accent-tint: rgba(139, 160, 255, .09);
    --accent-soft: #222d4e;

    --ok: #4cc98d;        --ok-soft: #16332a;
    --warn: #d8a94e;      --warn-soft: #362c17;
    --danger: #ec7680;    --danger-soft: #3d2129;
    --neutral-ink: #99a3b5; --neutral-soft: #1e2432;

    --email: #8ba0ff;     --email-soft: #222d4e;
    --sms: #a99df2;       --sms-soft: #2c2850;    --sms-ink: #181228;

    --shadow: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow-pop: 0 8px 28px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
}
html, body { margin: 0; padding: 0; }
body {
  font: 13px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Display type: a weight scale, not a shout — 650 headings, 600 controls, 500 nav. */
h1 { font-weight: 650; font-size: 19px; letter-spacing: -.015em; margin: 0 0 4px; }
h2 { font-weight: 650; font-size: 15px; letter-spacing: -.005em; margin: 24px 0 8px; }
h3 { font-weight: 650; font-size: 13px; margin: 16px 0 6px; }

/* One visible focus treatment everywhere. */
a:focus-visible, button:focus-visible, .btn:focus-visible, .chip:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}

/* Inline SVG icons (see Services/Icons.cs) inherit size and color. */
svg.ico { width: 1em; height: 1em; vertical-align: -0.125em; flex-shrink: 0; }

/* ---- App shell ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 204px; flex-shrink: 0; background: var(--panel); color: var(--muted);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 14px 12px 12px; margin: 0 10px; font-size: 14px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font: 800 11px/1 "Inter", sans-serif; flex-shrink: 0;
}
.brand a { color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
.sidebar nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; margin: 1px 0; color: var(--muted);
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm); text-decoration: none; font-weight: 500; font-size: 13px;
}
.sidebar nav a:hover { background: var(--inset); color: var(--text); text-decoration: none; }
.sidebar nav a.active {
  background: var(--accent-tint); color: var(--accent-dark); font-weight: 650;
  border-left-color: var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.nav-section {
  margin: 16px 10px 5px; font-size: 9.5px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .1em; color: var(--faint);
}
.sidebar-footer { padding: 11px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 9px; }
.user-avatar {
  position: relative; width: 28px; height: 28px; border-radius: 8px;
  background: var(--inset); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 650; flex-shrink: 0;
}
.user-avatar .status-dot {
  position: absolute; bottom: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); border: 2px solid var(--panel);
}
.user-info { min-width: 0; flex: 1; }
.user-name { font-size: 12px; color: var(--text); font-weight: 600; margin-bottom: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name a { color: inherit; }
.link-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 0; font-size: 12px;
}
.link-btn:hover { color: var(--text); text-decoration: underline; }
.content { flex: 1; padding: 22px 26px; max-width: 1400px; min-width: 0; }
.anon-content {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: var(--bg);
}

/* ---- Mobile app shell: hamburger + off-canvas sidebar + bottom tab bar ---- */
.mobile-topbar { display: none; }
.mobile-tabbar { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 760px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 40;
    background: var(--panel); border-bottom: 1px solid var(--border); padding: 10px 14px;
  }
  .mobile-topbar .hamburger {
    width: 22px; height: 15px; display: flex; flex-direction: column; justify-content: space-between;
    background: none; border: none; padding: 0; cursor: pointer; flex-shrink: 0;
  }
  .mobile-topbar .hamburger span { display: block; height: 2px; background: var(--text); border-radius: 1px; }
  .mobile-topbar .mobile-brand { font-weight: 700; font-size: 14px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }

  .app { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 60; width: 260px;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-pop); }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(10, 13, 19, .45); z-index: 55; }
  .content { padding: 16px 14px 84px; max-width: 100%; }

  .mobile-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--panel); border-top: 1px solid var(--border); padding: 0 4px 6px;
  }
  .mobile-tabbar a {
    flex: 1; text-align: center; padding: 9px 2px 4px; font-size: 10px; font-weight: 600;
    color: var(--faint); text-decoration: none;
    border-top: 2px solid transparent; margin-top: -1px;
  }
  .mobile-tabbar a.active { color: var(--accent-dark); border-top-color: var(--accent); }
  .mobile-tabbar .dot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .processing-dot { animation: none; }
}

/* ---- Page header ----
   kicker (where you are) · 650-weight title · subtitle.
   Top-level pages skip the kicker; sub-pages name their parent. */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.page-head .sub { color: var(--faint); font-size: 12.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kicker, .dashboard-kicker {
  color: var(--faint); font-size: 10px; font-weight: 650; letter-spacing: .09em;
  text-transform: uppercase; margin-bottom: 4px;
}

/* ---- Panels & cards ---- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 16px; }
.panel-pad > h2:first-child, .panel-pad > h3:first-child, .modal > h2:first-child { margin-top: 0; }
.platform-toggle-panel { margin-bottom: 14px; border-left: 3px solid var(--warn); }
.platform-toggle-panel h2 { margin: 4px 0 6px; }
.platform-toggle-copy { max-width: 760px; margin: 0; }
.platform-toggle-form { margin-top: 14px; }
/* Instrument strip — one panel, hairline-divided cells, tabular figures. */
.cards {
  display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 20px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card {
  flex: 1 1 150px; padding: 13px 18px 11px; border-right: 1px solid var(--border);
  text-decoration: none !important; color: inherit;
}
.card:last-child { border-right: none; }
a.card:hover { background: var(--bg-subtle); }
.card .num { font-size: 25px; font-weight: 650; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.card .lbl { color: var(--faint); font-size: 10px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
/* Label above figure: markup order is num-then-lbl, flip visually. */
.card { display: flex; flex-direction: column; }
.card .lbl { order: 1; }
.card .num { order: 2; }
.card.warn .num { color: var(--warn); }
.card.danger .num { color: var(--danger); }
.card.ok .num { color: var(--ok); }

/* ---- Buttons: flat, 6px, weight 600; solid cobalt only on .btn-primary ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--text); font-size: 12.5px; font-weight: 600; cursor: pointer;
  text-decoration: none !important;
}
.btn:hover { background: var(--inset); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn { padding: 5px 8px; line-height: 1; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; font-size: 12.5px; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=datetime-local], input[type=url],
input[type=file], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font: inherit; background: var(--panel); color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 18px; }
.form-row-inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.form-row-inline > div { flex: 1; min-width: 140px; }
.form-row-inline label { margin-top: 0; }
.checkbox-line { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-weight: 500; }
.checkbox-line input, .chip input { width: auto; }
.checkbox-line label { margin: 0; }
.help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.validation-error, .field-validation-error { color: var(--danger); font-size: 12px; }
.form-actions { margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.color-input { width: 44px; height: 34px; padding: 2px; flex: 0 0 auto; }

/* ---- Layout utilities (replace per-page inline styles) ---- */
.page-narrow { max-width: 640px; }
.page-mid { max-width: 760px; }
.page-wide { max-width: 860px; }
.row-split { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-stack { display: grid; gap: 14px; align-content: start; }
.row-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-line .grow { flex: 1; min-width: 120px; }

/* ---- Flash ---- */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 600; font-size: 12.5px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--danger-soft); color: var(--danger); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }

/* ---- Tables / grid ---- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 12.5px; }
table.grid th, table.grid td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid th { background: var(--bg-subtle); font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); position: sticky; top: 0; }
table.grid th a { color: var(--faint); }
table.grid th a.sorted { color: var(--accent-dark); }
table.grid td { font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover { background: var(--bg-subtle); }
table.grid td.actions { text-align: right; }
.grid-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.grid-toolbar input[type=text] { width: 220px; }
.grid-toolbar select { width: auto; }
.filter-panel { padding: 12px 14px; margin-bottom: 12px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border-strong);
  font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none !important; color: var(--muted);
}
.chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 650; }
.chip .x { color: inherit; opacity: .6; }

/* Checkbox filter chips: one element, colored identity dot, no nested badge. */
.filter-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  margin: 2px 6px 2px 0; padding: 5px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--panel);
  font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.filter-chip input { position: absolute; opacity: 0; pointer-events: none; }
.filter-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--faint); }
.filter-chip:hover { border-color: var(--accent); }
.filter-chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); font-weight: 650; }
.filter-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Tags & pills ----
   Semantic tags are tinted: colored text on a soft ground (AA-checked).
   Bare .tag/.pill with an inline background remains solid — those colors
   are user data (statuses, categories). Squared, not pill-shaped. */
.pill {
  display: inline-block; padding: 3px 8px; border-radius: var(--radius-xs);
  font-size: 11px; font-weight: 600; color: #fff;
}
.tag {
  display: inline-block; padding: 2px 7px; border-radius: var(--radius-xs); font-size: 10.5px;
  font-weight: 600; color: #fff; margin-right: 3px;
}
.tag-email   { background: var(--email-soft);   color: var(--email); }
.tag-sms     { background: var(--sms-soft);     color: var(--sms); }
.tag-ok      { background: var(--ok-soft);      color: var(--ok); }
.tag-warn    { background: var(--warn-soft);    color: var(--warn); }
.tag-danger  { background: var(--danger-soft);  color: var(--danger); }
.tag-neutral { background: var(--neutral-soft); color: var(--neutral-ink); }

/* Bulk-send + recipient statuses (replaces per-page C# color maps). */
.status-queued, .status-pending, .status-cancelled { background: var(--neutral-soft); color: var(--neutral-ink); }
.status-sending, .status-sent, .status-submitted { background: var(--email-soft); color: var(--email); }
.status-completed, .status-delivered { background: var(--ok-soft); color: var(--ok); }
.status-failed { background: var(--danger-soft); color: var(--danger); }
.status-paused, .status-suppressed { background: var(--warn-soft); color: var(--warn); }
.status-opened, .status-clicked { background: var(--sms-soft); color: var(--sms); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.overdue { color: var(--danger); font-weight: 650; }
.due-today { color: var(--warn); font-weight: 650; }

/* ---- Bulk bar (overlay — carries real elevation) ---- */
.bulk-bar {
  display: none; position: sticky; bottom: 12px; margin: 10px auto 0; width: fit-content; max-width: 100%;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius);
  align-items: center; gap: 10px; flex-wrap: wrap; box-shadow: var(--shadow-pop);
}
.bulk-bar.visible { display: flex; }
.bulk-bar select, .bulk-bar input { width: auto; padding: 5px 8px; }
.bulk-bar .count { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---- Pagination ---- */
.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; }
.pager a, .pager span.cur {
  padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel); text-decoration: none !important; font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 12px;
}
.pager span.cur { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent); }

/* ---- Avatars: neutral rounded squares — people aren't interactive elements ---- */
.avatar-circle {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 8px; background: var(--inset); color: var(--muted);
  font-size: 10px; font-weight: 650; line-height: 1;
}
.avatar-sm { width: 20px; height: 20px; font-size: 9px; border-radius: 6px; }
.avatar-md { width: 28px; height: 28px; font-size: 10.5px; border-radius: 8px; }
.avatar-lg { width: 38px; height: 38px; font-size: 12.5px; border-radius: 11px; }

/* ---- Contact detail ---- */
.detail-layout { display: grid; grid-template-columns: 330px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .detail-layout { grid-template-columns: 1fr; } }
.detail-fields dt { font-size: 10px; font-weight: 650; text-transform: uppercase; color: var(--faint); letter-spacing: .08em; margin-top: 10px; }
.detail-fields dd { margin: 1px 0 0; font-weight: 500; }

/* icon-prefixed detail rows */
.drow { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.drow:last-child { border-bottom: none; }
.drow .ic { color: var(--faint); width: 18px; flex-shrink: 0; text-align: center; }
.drow .lbl {
  color: var(--faint); width: 118px; flex-shrink: 0; font-size: 10px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; padding-top: 1px;
}

/* vertical timeline (Contact detail) */
.timeline-v { position: relative; padding-left: 18px; margin: 6px 0 0; }
.timeline-v::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-v li { position: relative; padding-bottom: 14px; font-size: 12.5px; list-style: none; }
.timeline-v li:last-child { padding-bottom: 0; }
.timeline-v li::before {
  content: ""; position: absolute; left: -18px; top: 3px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--border);
}
.timeline-v li.future::before { background: var(--panel); }
.timeline-v .t-label { font-weight: 650; }
.timeline-v .t-when { color: var(--faint); font-size: 11.5px; }

/* ---- Timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.tl-icon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; background: var(--inset);
}
.tl-icon.email-out { background: var(--accent-soft); }
.tl-icon.email-in { background: var(--ok-soft); }
.tl-icon.sms-out { background: var(--sms-soft); }
.tl-icon.sms-in { background: var(--warn-soft); }
.tl-body { flex: 1; min-width: 0; }
.tl-meta { color: var(--faint); font-size: 11px; font-weight: 550; font-variant-numeric: tabular-nums; }
.tl-expand { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 6px; background: var(--panel); }
.tl-expand img { max-width: 100%; }
details.tl-details summary { cursor: pointer; color: var(--accent-dark); font-size: 12px; font-weight: 600; }

/* ---- SMS chat ---- */
.sms-thread { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; padding: 8px 0; }
.sms-bubble { max-width: 78%; padding: 9px 13px 10px; border-radius: 16px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.sms-bubble.out { align-self: flex-end; background: var(--sms); color: var(--sms-ink); border-bottom-right-radius: 5px; }
.sms-bubble.in { align-self: flex-start; background: var(--panel); box-shadow: var(--shadow); border-bottom-left-radius: 5px; }
.sms-bubble .meta, .sms-bubble .tl-meta { display: block; font-size: 10px; color: inherit; opacity: .7; margin-top: 3px; font-weight: 550; }

/* ---- Tabs: a segmented control — bounded sets read as one instrument ---- */
.tabs {
  display: inline-flex; gap: 1px; margin-bottom: 14px; flex-wrap: wrap;
  background: var(--inset); border-radius: 7px; padding: 2px;
}
.tabs a, .tabs button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border: none; border-radius: 5px;
  background: none; font: inherit; font-size: 12px; font-weight: 550;
  color: var(--muted); cursor: pointer; text-decoration: none !important;
}
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs a.active, .tabs button.active { background: var(--panel); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }

/* ---- Modal (overlay — carries real elevation) ---- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10, 13, 19, .55);
  z-index: 50; align-items: flex-start; justify-content: center; padding: 5vh 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 20px;
}
.modal.wide { max-width: 860px; }
.modal h2 { margin-top: 0; }

/* ---- Compose / Quill ---- */
.compose-editor .ql-container { min-height: 180px; border-bottom-left-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); background: var(--panel); }
.compose-editor .ql-toolbar { border-top-left-radius: var(--radius-sm); border-top-right-radius: var(--radius-sm); background: var(--panel); }
/* Theme the third-party Quill chrome with our tokens (incl. dark mode). */
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--border-strong); }
.ql-snow .ql-stroke { stroke: var(--muted); }
.ql-snow .ql-fill { fill: var(--muted); }
.ql-snow .ql-picker { color: var(--muted); }
.ql-snow .ql-picker-options { background: var(--panel); border-color: var(--border-strong); }
.ql-editor.ql-blank::before { color: var(--faint); }
.attach-list { list-style: none; padding: 0; margin: 6px 0; }
.attach-list li { display: flex; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.attach-pill {
  display: inline-flex; gap: 6px; align-items: center; background: var(--inset);
  border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 3px 9px; font-size: 12px; font-weight: 550;
}
.char-counter { color: var(--faint); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Anonymous pages: sign-in, reset, unsubscribe, error ---- */
.login-box, .auth-card { width: 380px; max-width: 92vw; }
.login-box .brand-lg, .auth-card .brand-lg {
  text-align: center; font-weight: 700;
  font-size: 26px; letter-spacing: -.02em; margin-bottom: 2px;
}
.auth-tagline { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.auth-foot { text-align: center; margin-top: 14px; }
.auth-center { text-align: center; }
.center-box { margin: 48px auto; text-align: center; }

/* ---- Misc ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: none; }

/* ---- AI governance ----
   Teal is reserved for generated assistance; deterministic urgency keeps its
   existing semantic palette. The hairline/tint treatment makes this feel like
   a controlled instrument rather than a promotional AI feature. */
.ai-governance-head { align-items: flex-end; }
.ai-state { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.ai-state-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.ai-state.enabled { color: #0f766e; border-color: #99d5ce; background: #effcf9; }
.ai-state.enabled .ai-state-dot { background: #0f766e; box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
.ai-governance-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 16px; align-items: start; }
.ai-control-panel { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: 16px; overflow: hidden; }
.ai-control-panel::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: #0f766e; }
.ai-section-mark, .ai-generated-mark { display: inline-grid; place-items: center; background: #e4f7f3; color: #0f766e; border: 1px solid #a8dcd5; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.ai-section-mark { width: 42px; height: 42px; border-radius: 12px; grid-row: 1 / span 2; }
.ai-settings-form { grid-column: 1 / -1; margin-top: 12px; display: grid; gap: 16px; }
.ai-toggle-card { margin: 0; padding: 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); display: flex; justify-content: space-between; align-items: center; gap: 20px; cursor: pointer; background: var(--bg-subtle); }
.ai-toggle-card strong, .ai-toggle-card small { display: block; }
.ai-toggle-card small, .ai-choice small { color: var(--faint); margin-top: 4px; font-weight: 450; line-height: 1.4; }
.switch { position: relative; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { display: block; width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); transition: background .18s ease; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform .18s ease; }
.switch input:checked + span { background: #0f766e; }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid rgba(15,118,110,.24); outline-offset: 2px; }
.ai-choice-group { margin: 0; padding: 0; border: 0; }
.ai-choice-group legend { font-weight: 700; margin-bottom: 2px; }
.ai-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.ai-choice { position: relative; display: block; margin: 0; cursor: pointer; }
.ai-choice input { position: absolute; opacity: 0; }
.ai-choice span { display: block; height: 100%; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); }
.ai-choice input:checked + span { border-color: #0f766e; box-shadow: inset 3px 0 #0f766e; background: #effcf9; }
.ai-choice input:focus-visible + span { outline: 3px solid rgba(15,118,110,.24); outline-offset: 2px; }
.ai-choice strong, .ai-choice small { display: block; }
.ai-cap-field { max-width: 360px; }
.money-input { display: flex; align-items: stretch; }
.money-input > span { display: grid; place-items: center; padding: 0 11px; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--bg-subtle); color: var(--faint); font-size: 11px; font-weight: 700; }
.money-input input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 0; }
.ai-usage-panel { border-top: 3px solid #0f766e; }
.ai-spend-figure { margin: 20px 0 2px; color: var(--text); font-size: clamp(28px, 4vw, 42px); font-weight: 750; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.ai-spend-figure span { margin-right: 8px; color: #0f766e; font-size: 11px; letter-spacing: .08em; vertical-align: middle; }
.ai-budget-track { height: 7px; margin-top: 22px; overflow: hidden; border-radius: 999px; background: var(--inset); }
.ai-budget-track span { display: block; height: 100%; border-radius: inherit; background: #0f766e; }
.ai-budget-meta { margin-top: 8px; font-size: 11px; color: var(--faint); }
.ai-budget-meta strong { color: var(--text); }
.ai-empty-usage { display: grid; gap: 3px; margin-top: 24px; padding: 14px; border: 1px dashed #99d5ce; border-radius: var(--radius-sm); background: #effcf9; }
.ai-empty-usage strong { color: #0f766e; }
.ai-empty-usage span { color: var(--muted); font-size: 12px; }
.ai-entry-points { display: inline-flex; align-items: center; gap: 7px; }
.ai-generated-mark { width: 27px; height: 27px; border-radius: 8px; }
.ai-entry { border-color: #99d5ce; color: #0f766e; background: #effcf9; opacity: 1; }
.ai-entry:disabled { cursor: not-allowed; opacity: .82; }
.ai-entry span { margin-left: 4px; color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.message-intelligence { width: min(680px, 86%); margin: 5px 0 13px; }
.message-intelligence-action { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border: 0; background: transparent; color: #0f766e; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer; }
.message-intelligence-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.message-intelligence-action small { color: var(--faint); font-size: 9px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.message-intelligence-state { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 5px 9px; border-left: 2px solid #99d5ce; color: #0f766e; font-size: 11px; font-weight: 700; }
.message-intelligence-state small { color: var(--faint); font-weight: 450; }
.message-intelligence-state.unavailable { color: var(--muted); border-color: var(--border-strong); }
.message-intelligence-state form { margin-left: auto; }
.message-intelligence-state button { border: 0; background: transparent; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
.message-intelligence-mark { display: inline-flex; align-items: center; min-height: 23px; border-radius: 999px; font-size: 10px; line-height: 1.2; padding: 0 8px; border: 1px solid #99d5ce; background: #effcf9; color: #0f766e; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.message-intelligence-obligations { margin-top: 6px; padding: 7px 10px 9px; border-left: 2px solid #99d5ce; background: color-mix(in srgb, #effcf9 45%, transparent); font-size: 11.5px; }
.message-intelligence-obligations ul { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.message-obligation { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.message-obligation-kind { flex: 0 0 auto; display: inline-flex; align-items: center; border-radius: 4px; padding: 1px 7px; font-size: 10px; font-weight: 650; letter-spacing: .02em; background: var(--inset); color: var(--muted); white-space: nowrap; }
.message-obligation[data-kind="ask"] .message-obligation-kind,
.message-obligation[data-kind="our_commitment"] .message-obligation-kind { background: var(--accent-soft); color: var(--accent-dark); }
.message-obligation[data-kind="deadline"] .message-obligation-kind { background: var(--warn-soft); color: var(--warn); }
.message-obligation-date { font-variant-numeric: tabular-nums; }
.message-intelligence-obligations footer { margin-top: 10px; color: var(--faint); line-height: 1.45; }
@media (prefers-color-scheme: dark) {
  .ai-state.enabled, .ai-choice input:checked + span, .ai-empty-usage, .ai-entry { color: #72d5ca; border-color: #276d66; background: #112a29; }
  .ai-section-mark, .ai-generated-mark { color: #72d5ca; border-color: #276d66; background: #173331; }
  .message-intelligence-action, .message-intelligence-details summary { color: #72d5ca; }
  .message-intelligence-mark { color: #72d5ca; border-color: #276d66; background: #112a29; }
  .message-intelligence-details { border-color: #276d66; background: rgba(17, 42, 41, .42); }
  .ai-empty-usage strong { color: #72d5ca; }
}
@media (max-width: 900px) {
  .ai-governance-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .ai-choice-grid { grid-template-columns: 1fr; }
  .ai-entry-points { width: 100%; flex-wrap: wrap; }
  .message-intelligence { width: 100%; }
}
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv:last-child { border-bottom: none; }
pre.wrap { white-space: pre-wrap; font-size: 12px; background: var(--bg-subtle); padding: 10px; border-radius: var(--radius-sm); }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
.empty a { font-weight: 600; }

/* Background processing notice (imports, transcription). */
.processing-note { display: flex; gap: 12px; align-items: center; padding: 12px; margin-top: 16px; border-radius: var(--radius-sm); background: var(--bg-subtle); }
.processing-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.75); } }

/* Merge comparison: rows whose values differ get a quiet flag. */
tr.diff td:not(:first-child) { background: var(--warn-soft); }

/* ---- Dashboard: the day's operations board ---- */
.dashboard-head { padding-bottom: 2px; }
.dashboard-head h1 { font-size: clamp(19px, 2.6vw, 24px); line-height: 1.1; margin-bottom: 4px; }
.dashboard-metrics { }
.dashboard-grid {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr);
  gap: 16px; align-items: start;
}
.dashboard-briefing { overflow: hidden; }
.dashboard-section-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 13px 16px 11px; border-bottom: 1px solid var(--border);
}
.dashboard-section-head h2, .dashboard-rail h2 { margin: 0; font-size: 13.5px; }
.dashboard-clear {
  min-height: 200px; display: grid; place-content: center; justify-items: center;
  gap: 7px; padding: 32px; text-align: center; color: var(--muted);
  background: var(--bg-subtle);
}
.dashboard-clear strong { color: var(--text); font-size: 15px; font-weight: 650; }
.priority-list { list-style: none; margin: 0; padding: 0; }
.priority-item {
  --priority-color: var(--faint); display: grid; grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px; padding: 13px 16px 13px 14px; border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent; background: var(--panel);
}
.priority-item:last-child { border-bottom: 0; }
.priority-item:hover { background: var(--bg-subtle); }
.priority-item.urgent { --priority-color: var(--danger); border-left-color: var(--danger); }
.priority-item.due { --priority-color: var(--warn); border-left-color: var(--warn); }
.priority-item.waiting { --priority-color: var(--accent-dark); border-left-color: var(--accent); }
.priority-item.quiet { --priority-color: var(--faint); }
/* Score: a bare colored figure, not a chip. */
.priority-score {
  width: 34px; padding-top: 1px; text-align: left;
  color: var(--priority-color);
  font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums;
}
.priority-title-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
/* Kind: colored dot + word — no background. */
.priority-kind { flex: 0 0 auto; color: var(--priority-color); font-size: 11px; font-weight: 650; }
.priority-kind::before { content: "●"; font-size: 7px; vertical-align: 2px; margin-right: 5px; }
.priority-body p { margin: 4px 0; color: var(--muted); font-size: 12.5px; }
.priority-links { display: flex; gap: 12px; font-size: 11.5px; }
.priority-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 132px; }
.priority-actions form { margin: 0; }
.priority-actions .btn { width: 100%; justify-content: center; }
.snooze-form { display: grid; grid-template-columns: 1fr auto; gap: 5px; }
.snooze-form select { min-width: 0; padding: 4px 6px; font-size: 11.5px; }
.priority-dismiss { width: 100%; text-align: center; color: var(--faint); }
.dashboard-rail { display: grid; gap: 16px; }
.brief-list { list-style: none; margin: 12px 0; padding: 0; }
.brief-list li { position: relative; padding: 9px 0; border-bottom: 1px solid var(--border); }
.brief-list li:first-child { padding-top: 0; }
.brief-list li:last-child { border-bottom: 0; }
.brief-list .overdue { float: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.brief-list p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.dashboard-campaigns { margin-top: 16px; }
.dashboard-campaigns .dashboard-section-head { padding: 0 0 12px; }
.campaign-list { display: grid; gap: 0; }
.campaign-row {
  display: grid; grid-template-columns: minmax(180px, 1fr) minmax(120px, 260px) auto auto;
  gap: 16px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border);
  color: inherit; text-decoration: none;
}
.campaign-row:last-child { border-bottom: 0; }
.campaign-row:hover { background: var(--bg-subtle); text-decoration: none; }
.campaign-row > div:first-child { display: flex; flex-direction: column; }
.campaign-progress { height: 4px; overflow: hidden; border-radius: 2px; background: var(--inset); }
.campaign-progress span { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .campaign-row { grid-template-columns: minmax(150px, 1fr) minmax(100px, 220px) auto; }
  .campaign-row .overdue { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  /* Instrument strip folds to a 2×2 ruled grid. */
  .card { flex: 1 1 40%; border-bottom: 1px solid var(--border); }
  .card:nth-child(even) { border-right: none; }
  .card:nth-last-child(-n+2) { border-bottom: none; }
  .card .num { font-size: 21px; }
  .priority-item { grid-template-columns: 34px 1fr; padding: 13px 14px 13px 12px; }
  .priority-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 2fr 1fr; min-width: 0; }
  .campaign-row { grid-template-columns: 1fr; gap: 7px; }
}

/* ---- Conversations workspace ---- */
.conv-left { display: flex; flex-direction: column; min-height: 0; }
.conv-left-head { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); }
.conv-left-head .tabs { margin-bottom: 8px; }
.conv-filter-rail {
  display: flex; gap: 6px; overflow-x: auto; padding: 1px 1px 8px;
  scrollbar-width: thin; overscroll-behavior-inline: contain;
}
.conv-filter-rail .chip { flex: 0 0 auto; min-height: 34px; align-items: center; }
.conv-sms-toggle { margin-left: 4px; border-style: dashed; }
.conv-search { display: flex; flex-direction: column; gap: 6px; }
.conv-search .btn { justify-content: center; }
.conv-shared-read { margin: 6px 0 0; }
.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.conv-section { padding: 8px 12px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 650; }
.conv-row { display: block; padding: 8px 12px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.conv-row:hover { background: var(--bg-subtle); text-decoration: none; }
.conv-row.active { background: var(--accent-tint); box-shadow: inset 2px 0 0 var(--accent); }
.conv-row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.conv-name { font-weight: 650; font-size: 13px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.conv-time { color: var(--faint); font-size: 10.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conv-row-bottom { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; }
.conv-snippet { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conv-wait { color: var(--warn); font-size: 11px; font-weight: 650; white-space: nowrap; }
.conv-blocked { color: var(--danger); font-size: 10.5px; font-weight: 650; white-space: nowrap; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
/* Counts are cobalt — red is reserved for overdue/failed. */
.badge {
  display: inline-block; min-width: 17px; text-align: center; padding: 2px 5px;
  border-radius: var(--radius-xs); background: var(--accent-soft); color: var(--accent-dark);
  font-size: 10.5px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.conv-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.conv-main-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.conv-main-head .who { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.conv-main-head .who strong { font-size: 14px; }
.conv-stream { flex: 1; overflow-y: auto; min-height: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.conv-day {
  display: flex; align-items: center; gap: 12px; color: var(--faint);
  font-size: 10px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; margin: 10px 0 6px;
}
.conv-day::before, .conv-day::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.conv-marker { align-self: center; background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 12px; font-size: 12px; margin: 4px 0; max-width: 90%; }
.conv-marker .tl-meta { margin-left: 6px; }
.conv-hairline { text-align: center; color: var(--faint); font-size: 11px; font-weight: 550; margin: 4px 0; }
.conv-hairline span { padding: 0 8px; }
/* Direction reads as silhouette: inbound left on panel, outbound right filled —
   same grammar as the SMS bubbles, so email and SMS read as one relationship. */
.email-msg { display: flex; flex-direction: column; max-width: 78%; margin: 3px 0 14px; }
.email-msg.out { align-self: flex-end; align-items: flex-end; }
.email-msg.in { align-self: flex-start; align-items: flex-start; }
.email-subject-tag {
  display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650;
  color: var(--faint); margin: 0 2px 6px; max-width: 100%;
}
.email-card { border-radius: 16px; padding: 9px 13px 10px; font-size: 13px; line-height: 1.5; max-width: 100%; }
.email-card.out { background: var(--email); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.email-card.in { background: var(--panel); color: var(--text); box-shadow: var(--shadow); border-bottom-left-radius: 5px; }
.email-body { max-height: 280px; overflow-y: auto; }
.email-body img { max-width: 100%; }
.email-card .attach-list { margin: 8px 0 0; }
.email-card .attach-pill { border-radius: 10px; }
.email-card.out .attach-pill { background: rgba(255, 255, 255, .2); border-color: transparent; color: var(--accent-ink); }
.email-card.in .attach-pill { background: var(--bg); color: var(--muted); }
.email-meta { font-size: 10.5px; color: var(--faint); margin: 3px 2px 0; display: flex; align-items: center; gap: 6px; }
.email-meta .dot::before { content: "·"; margin: 0 1px; }
.email-meta .reply-btn {
  font: 650 10.5px/1 inherit; color: var(--accent-dark); background: none; border: none; padding: 0; cursor: pointer;
  display: inline-flex; gap: 4px; align-items: center;
}
.email-meta .reply-btn:hover { text-decoration: underline; }

/* A reply gets a stacked/peeking look — there's history behind it — plus a
   label naming the thread and how deep into it this message is, a detached
   count badge at the row's right, and a "Show N earlier messages" affordance.
   Opening (anywhere on the card or the link) swaps the whole entry for a
   thread tile: a header naming the thread — icon, title, latest snippet,
   total count, latest time — over the full conversation, every message at
   equal weight. The same tile opens from any reply in the thread. */
.thread-tile { width: 100%; margin: 3px 0 14px; }
.thread-tile summary.tile-summary { list-style: none; cursor: pointer; padding: 0; }
.thread-tile summary.tile-summary::-webkit-details-marker { display: none; }
.collapsed-view { position: relative; display: flex; flex-direction: column; }
.thread-tag {
  display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 650;
  color: var(--accent-dark); margin: 0 2px 6px;
}
.thread-tile.out .thread-tag { justify-content: flex-end; margin-right: 34px; }
.thread-tag .tl-meta { color: var(--faint); font-weight: 500; }
.stack-badge {
  position: absolute; top: 24px; right: 0; width: 23px; height: 23px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font: 700 11px/23px "Inter", sans-serif; text-align: center;
  box-shadow: 0 0 0 3px var(--bg); z-index: 2;
}
/* Earlier messages peek out below-left of the newest card. */
.stack-wrap { max-width: 78%; align-self: flex-start; margin: 0 0 10px 16px; }
.thread-tile.out .stack-wrap { align-self: flex-end; margin-right: 34px; }
.stack-wrap .email-msg { max-width: 100%; margin: 0; }
.stack-wrap .email-card {
  box-shadow:
    -7px 7px 0 -2px var(--bg), -7px 7px 0 0 var(--border-strong),
    -14px 14px 0 -2px var(--bg), -14px 14px 0 0 var(--border-strong);
}
/* Inbound cards are panel-on-bg; keep their elevation under the stack layers
   so the card's own edge stays visible. */
.stack-wrap .email-card.in {
  border: 1px solid var(--border);
  box-shadow:
    var(--shadow),
    -7px 7px 0 -2px var(--bg), -7px 7px 0 0 var(--border-strong),
    -14px 14px 0 -2px var(--bg), -14px 14px 0 0 var(--border-strong);
}
.show-earlier {
  align-self: flex-end; margin: 0 2px; font-size: 12px; font-weight: 650; color: var(--accent-dark);
}
.thread-tile summary.tile-summary:hover .show-earlier { text-decoration: underline; }
/* Closed: the collapsed view (thread tag + stacked bubble + show-earlier) is
   the whole summary, chrome-less, reading like any other message in the flow.
   Open: swap to the tile header — icon, title, snippet, count, time — and
   let it visually merge into the expanded panel below it. */
.thread-tile[open] summary.tile-summary .collapsed-view { display: none; }
.tile-open-header { display: none; align-items: center; gap: 12px; }
.thread-tile[open] summary.tile-summary .tile-open-header {
  display: flex; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.tile-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
}
.tile-main { flex: 1; min-width: 0; }
.tile-title { font-weight: 650; font-size: 13.5px; display: block; }
.tile-snippet { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-side { flex-shrink: 0; text-align: right; }
.tile-count {
  display: inline-block; font: 700 11px/1 "Inter", sans-serif; background: var(--accent); color: var(--accent-ink);
  border-radius: 100px; padding: 3px 8px; margin-bottom: 4px;
}
.tile-time { display: block; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tile-expanded { display: none; flex-direction: column; }
.thread-tile[open] .tile-expanded {
  display: flex; background: var(--panel); border: 1px solid var(--border-strong); border-top: 1px dashed var(--border);
  border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); margin-top: -1px; padding: 14px 14px 16px;
}
/* Inbound bubbles sit on the panel itself here; a hairline keeps them legible. */
.tile-expanded .email-card.in { box-shadow: none; border: 1px solid var(--border); }
.conv-composer { border-top: 1px solid var(--border); padding: 10px 16px 14px; background: var(--bg-subtle); border-radius: 0 0 var(--radius) var(--radius); }
.conv-composer .tabs { margin-bottom: 4px; }
.conv-composer .compose-editor .ql-container { min-height: 110px; }
.scheduled-sms-list {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
  display: grid; gap: 6px;
}
.scheduled-sms-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 9px; border-radius: var(--radius-sm); background: var(--bg-hover);
}
.scheduled-sms-row > div { min-width: 0; display: flex; flex-direction: column; }
.scheduled-sms-row .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-empty { display: flex; }
.composer-panel.hidden { display: none; }
/* Voice recorder: idle → live (waveform + timer) → review. Audio is private
   until the transcript is accepted, and the copy says so on every stage. */
.voice-recorder { padding: 12px; }
.voice-stage.hidden { display: none; }
.voice-idle { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.voice-start .voice-rec-glyph { color: currentColor; font-size: 10px; }
.voice-live-head { display: flex; align-items: center; gap: 8px; }
.voice-live-head strong { font-size: 12.5px; }
.voice-recorder-time {
  margin-left: auto; min-width: 54px; text-align: center; padding: 3px 8px; border-radius: var(--radius-xs);
  background: var(--inset); color: var(--text); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 650;
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1.4s ease-in-out infinite; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 36px; margin-top: 10px; }
.voice-wave i { flex: 1; min-height: 4px; background: var(--ok); opacity: .55; border-radius: 2px; transition: height .1s linear; }
.voice-live-controls { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.voice-recorder-preview { width: 100%; height: 38px; margin-top: 2px; }
.voice-privacy { margin: 10px 0 0; padding-left: 10px; border-left: 2px solid var(--ok); line-height: 1.5; }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } .voice-wave i { transition: none; } }
.voice-note-queue { display: grid; gap: 5px; margin-top: 10px; }
.voice-note-queue > a {
  display: flex; justify-content: space-between; gap: 12px; padding: 7px 9px;
  border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); text-decoration: none; color: inherit;
}
.voice-note-queue > a:hover { border-color: var(--accent); }
.eyebrow { margin-bottom: 4px; color: var(--faint); font-size: 10px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.callout { margin: 14px 0; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-subtle); }
.callout-danger { border-color: transparent; background: var(--danger-soft); color: var(--danger); }
.validation, .validation-summary-errors { color: var(--danger); font-size: 12px; }
.voice-status-pendingreview { background: var(--warn-soft); color: var(--warn); }
.voice-status-accepted { background: var(--ok-soft); color: var(--ok); }
.voice-status-failed { background: var(--danger-soft); color: var(--danger); }
.voice-status-recorded, .voice-status-transcribing { background: var(--neutral-soft); color: var(--neutral-ink); }
.voice-review-grid { display: grid; grid-template-columns: minmax(280px, .75fr) minmax(0, 1.25fr); gap: 16px; }
.voice-review-audio audio, .voice-timeline-detail audio { width: 100%; margin-top: 14px; }
.voice-review-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.voice-transcript { max-height: 440px; overflow: auto; }
.voice-timeline-detail { margin-top: 5px; text-align: left; }
.voice-timeline-detail pre { max-height: 180px; overflow: auto; font-size: 11.5px; }
.voice-timeline-detail summary { cursor: pointer; color: var(--accent-dark); }
.timeline-source-anchor { display: block; position: relative; top: -90px; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.timeline-source-anchor:target + * { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---- Privacy-preserving Catch Me Up drawer ---- */
/* ---- Relationship brief: full-width panel above the timeline ---- */
.ai-brief { margin-bottom: 14px; padding: 16px 18px; }
.ai-brief-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.ai-brief-head h2 { margin: 6px 0 0; }
.ai-brief-meta { display: flex; align-items: center; gap: 8px; }
.ai-brief-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 4px 24px; margin-top: 6px; }
.ai-brief-grid section h3 { margin-top: 12px; }
.ai-brief-recommended { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.ai-brief-recommended p { margin: 0; font-weight: 600; }
.ai-brief-foot { color: var(--muted); font-size: 12px; line-height: 1.5; border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
.ai-brief-state { text-align: center; padding: 28px 20px; }.ai-brief-state form { margin-top: 16px; }
.ai-brief[data-state="completed"]:has(.ai-freshness) { border-left: 2px solid var(--warn); }
.ai-spinner { display: inline-block; width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: ai-spin .8s linear infinite; }
.ai-freshness { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); }
.ai-claims { padding-left: 20px; }.ai-claims li { margin-bottom: 16px; }.ai-source-chips { display: flex; flex-wrap: wrap; gap: 6px; }.ai-source-chips .tag { text-decoration: none; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ai-spinner { animation: none; } }
@media (max-width: 760px) { .voice-review-grid { grid-template-columns: 1fr; } }

/* ---- Settings area rows (statuses, categories, team) ---- */
.setting-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.setting-row .grow { flex: 1; min-width: 120px; }
.setting-row .count { flex: 0 0 auto; }
.member-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.member-row .who { min-width: 0; }
.member-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.ai-provider-response { min-width: 180px; max-width: 420px; }
.ai-provider-response summary { cursor: pointer; color: var(--accent); }
.ai-provider-response pre {
  margin: 8px 0 0; padding: 10px; max-height: 260px; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
/* Invite / set-password toggle: password fields appear only when chosen. */
.add-member .pw-only { display: none; }
.add-member:has(input[value="password"]:checked) .pw-only { display: block; }

/* ---- Responsive stacked-card table (opt-in via .grid-stack) ---- */
@media (max-width: 760px) {
  table.grid.grid-stack thead { display: none; }
  table.grid.grid-stack, table.grid.grid-stack tbody, table.grid.grid-stack tr { display: block; width: 100%; }
  table.grid.grid-stack tbody tr {
    border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px;
    padding: 10px 12px; background: var(--panel);
  }
  table.grid.grid-stack td {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    border-bottom: none; padding: 4px 0; white-space: normal;
  }
  table.grid.grid-stack td::before {
    content: attr(data-label); font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--faint); font-weight: 650; flex-shrink: 0;
  }
  table.grid.grid-stack td:not([data-label]) { justify-content: flex-start; }
}

/* ---- Contact relationship timeline ---- */
.contact-conv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 16px; align-items: start; }
.contact-conv-main { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 620px; overflow: hidden; }
.contact-conv-main #streamPane { flex: 1; min-height: 260px; overflow-y: auto; padding: 16px; }
.timeline-filters { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.timeline-filters, .chip-rail { scrollbar-width: none; -ms-overflow-style: none; }
.timeline-filters::-webkit-scrollbar, .chip-rail::-webkit-scrollbar { display: none; }
.timeline-filters .filter-chip { text-decoration: none; white-space: nowrap; }
.timeline-filters .active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 650; }
.contact-sidebar { display: grid; gap: 14px; }
.contact-sidebar .panel { margin: 0; }
.contact-sidebar form { display: grid; gap: 8px; }
.contact-sidebar h3:not(:first-child) { margin-top: 18px; }

/* Commitments: severity as the standard 2px left edge; red is earned only by an overdue date. */
.commitment-item { border-left: 2px solid var(--border); padding: 2px 0 8px 10px; margin-bottom: 10px; }
.commitment-item.overdue { border-left-color: var(--danger); }
.commitment-item p { margin: 4px 0; }
.commitment-item .row-line { gap: 8px; flex-wrap: wrap; }
.commitment-edit summary, .commitment-add summary { list-style: none; cursor: pointer; }
.commitment-edit summary::-webkit-details-marker, .commitment-add summary::-webkit-details-marker { display: none; }
.commitment-edit form, .commitment-add form { margin-top: 8px; }

/* Reply assistant: draft preview + variant chips inside the composer card. */
.suggestion-draft-preview { margin: 8px 0; padding: 8px 12px; border-left: 2px solid var(--border-strong); background: var(--bg-subtle); white-space: pre-wrap; font-size: 12.5px; }
.suggestion-points .kicker { font-size: 10px; }
.suggestion-variants { gap: 6px; flex-wrap: wrap; align-items: center; }
.suggestion-variants form { display: inline; }
.suggestion-variants .chip[disabled] { opacity: .5; cursor: not-allowed; }

/* Human-confirmed AI item actions: inline disclosure forms, never direct writes. */
.ai-item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ai-item-action summary { list-style: none; cursor: pointer; display: inline-flex; }
.ai-item-action summary::-webkit-details-marker { display: none; }
.ai-item-action summary[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.ai-item-action form { display: grid; gap: 6px; margin-top: 6px; max-width: 320px; }

/* Voice-note interaction insights: opt-in checkboxes; nothing applies without acceptance. */
.voice-insights { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; display: grid; gap: 8px; }
.voice-insights ul { margin: 0; padding-left: 18px; }
.voice-insight-commitments { display: grid; gap: 8px; }
.voice-insight-commitment { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }

/* Usefulness summary: uppercase labels, tabular numerals, no color. */
.ai-usefulness-kicker { margin-top: 18px; }
.ai-usefulness { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin: 8px 0 0; }
.ai-usefulness > div { padding: 8px 10px; border-right: 1px solid var(--border); }
.ai-usefulness > div:last-child { border-right: none; }
.ai-usefulness dt { color: var(--faint); font-size: 10px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.ai-usefulness dd { margin: 2px 0 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ai-usefulness dd .muted { font-size: 12px; font-weight: 500; }

/* Today-card enrichment: one bounded block below the deterministic reason. */
.priority-brief { display: flex; gap: 8px; align-items: flex-start; border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 8px; }
.priority-brief ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 12px; }
.priority-brief strong { color: var(--muted); font-weight: 650; }

/* One-time re-opt-in notice after the automatic-mode replacement. */
.ai-reoptin-notice { border-left: 2px solid var(--warn); background: var(--warn-soft); color: var(--warn); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 10px 12px; font-size: 12.5px; }
.composer-tabs { margin-bottom: 10px; }

/* ---- Composer (contact page): Email · SMS · Log ---- */
/* Shared grammar: content lives on a .composer-card; every text surface gets
   a { } Field affordance in its .editor-foot; the action row keeps context on
   the left and draft state + the single primary Send on the right. */
.composer-card { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.hdr-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 10px; border-bottom: 1px solid var(--border);
}
.hdr-label { flex-shrink: 0; min-width: 42px; text-align: right; color: var(--faint); font-size: 11.5px; font-weight: 600; }
input.hdr-input { flex: 1; min-width: 120px; width: auto; border: none; background: transparent; padding: 2px; font: inherit; color: var(--text); border-radius: 0; }
input.hdr-input:focus { outline: none; }
.hdr-row:focus-within { background: var(--bg-subtle); }
.hdr-select {
  width: auto; max-width: 150px; padding: 3px 7px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); border-color: transparent; background: transparent;
}
.hdr-select:hover { border-color: var(--border-strong); }
.hdr-toggle {
  margin-left: auto; border: none; background: none; padding: 2px 6px; border-radius: var(--radius-xs);
  color: var(--faint); font-size: 11px; font-weight: 600; cursor: pointer;
}
.hdr-toggle:hover { color: var(--accent-dark); background: var(--accent-tint); }
.rcpt-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 4px;
  background: var(--accent-soft); color: var(--accent-dark); border-radius: 20px;
  font-size: 11.5px; font-weight: 600; max-width: 100%;
}
.rcpt-avatar {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; flex-shrink: 0;
}
.rcpt-mail { color: var(--accent-dark); opacity: .65; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.card-textarea { border: none; background: transparent; padding: 9px 10px; display: block; resize: vertical; }
.card-textarea:focus { outline: none; }
.editor-foot {
  position: relative; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px; border-top: 1px solid var(--border);
}
.editor-foot .composer-actions-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.composer-card .compose-editor .ql-toolbar, .composer-card .compose-editor .ql-container { border-left: none; border-right: none; border-radius: 0; }
.composer-card .compose-editor .ql-toolbar { border-top: none; }
.composer-card .compose-editor .ql-container { border-bottom: none; }

/* { } Field: one insertion affordance on every composer text surface. */
.mf-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--muted);
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.mf-btn:hover { color: var(--accent-dark); border-color: var(--accent); }
.mf-braces { color: var(--accent-dark); font-weight: 700; }
.mf-tok {
  background: var(--accent-tint); color: var(--accent-dark); border: 1px solid var(--accent-soft);
  border-radius: var(--radius-xs); padding: 0 4px; font-weight: 600; font-size: 11px; white-space: nowrap;
}
.mf-pop {
  position: absolute; left: 8px; bottom: calc(100% + 6px); z-index: 30; width: 240px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
}
input.mf-search { margin-bottom: 5px; padding: 5px 8px; font-size: 12px; }
.mf-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.mf-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 6px 8px; border: none; border-radius: var(--radius-xs); background: none;
  font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.mf-item:hover { background: var(--accent-tint); }
.mf-ex { color: var(--faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* SMS */
.sms-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.sms-meter { height: 3px; margin: 0 10px 8px; background: var(--inset); border-radius: 2px; overflow: hidden; }
.sms-meter i { display: block; width: 0; height: 100%; background: var(--accent); border-radius: 2px; transition: width .15s ease; }
.sms-meter i.multi { background: var(--warn); }
.schedule-at { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.schedule-at input { width: auto; padding: 4px 8px; font-size: 12px; }

/* Segmented choice (SMS Now/Schedule, call outcome) */
.seg { display: inline-flex; background: var(--inset); border-radius: 7px; padding: 2px; }
.seg-btn {
  position: relative; display: inline-flex; align-items: center; border: none; background: none; cursor: pointer;
  padding: 4px 10px; border-radius: 5px; color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 600; margin: 0;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active, .seg-btn:has(input:checked) { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; }
.seg-btn:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Log group: Note / Call / Voice sub-tabs under the Log tab */
.composer-log-group.hidden { display: none; }
.composer-subtabs { display: flex; gap: 2px; background: var(--inset); border-radius: 7px; padding: 2px; margin-bottom: 10px; width: fit-content; }
.composer-subtabs .subtab {
  display: inline-flex; align-items: center; gap: 6px; border: none; background: none; cursor: pointer;
  padding: 4px 12px; border-radius: 5px; color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 600;
}
.composer-subtabs .subtab:hover { color: var(--text); }
.composer-subtabs .subtab.active { background: var(--panel); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }

/* Note: rests as a one-line prompt, expands into the full card */
.note-rest {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px;
  border: none; background: none; color: var(--faint); font: inherit; font-size: 12.5px; text-align: left; cursor: text;
}
.note-rest.hidden, .note-open.hidden { display: none; }
.call-card .card-textarea { border-bottom: none; }
.follow-up-line { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.follow-up-line input[type=date] { width: auto; padding: 3px 7px; font-size: 11.5px; }

.attach-btn { position: relative; margin: 0; cursor: pointer; }
.composer-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.composer-actions-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.suggested-next-action { margin: 8px 0 12px; }
.suggested-next-action > form { margin: 0; }
.suggestion-state, .suggestion-card { padding: 12px; border: 1px solid #99d5ce; border-radius: var(--radius-sm); background: #effcf9; }
.suggestion-state { display: flex; align-items: center; gap: 9px; color: #0f766e; }
.suggestion-state .ai-spinner { width: 18px; height: 18px; border-width: 2px; }
.suggestion-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; color: #0f766e; }
.suggestion-head .muted { margin-left: auto; }
.suggestion-head form { margin: 0; }
.suggestion-considerations { margin: 10px 0; padding-left: 20px; }
.suggestion-considerations li { margin: 8px 0; }
.suggestion-considerations .ai-source-chips { margin-top: 4px; }
.suggestion-checklist { list-style: none; padding-left: 0; }
.suggestion-checklist label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.suggestion-checklist input { margin-top: 3px; }
.suggestion-card .ai-freshness { display: block; color: var(--text); }
.ai-draft-notice { margin: 8px 0 0; color: #0f766e; font-weight: 700; }
.danger { color: var(--danger); }
.triage-bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 6px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 12px;
}
.triage-position { font-weight: 650; min-width: 68px; text-align: center; font-variant-numeric: tabular-nums; }
.btn.disabled { opacity: .45; pointer-events: none; }
.tl-consent span { color: var(--accent-dark); }
.consent-history { margin-top: 14px; }
.consent-history summary { cursor: pointer; font-weight: 650; }

/* ---- Conversations inbox ---- */
.inbox-panel { max-width: 880px; margin: 0 auto; overflow: hidden; }
.inbox-tabs { margin: 12px 18px; }
.inbox-toolbar { padding: 0 18px 14px; border-bottom: 1px solid var(--border); }
.chip-rail { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
.chip-rail a { text-decoration: none; white-space: nowrap; }
.chip-rail .active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 650; }
.inbox-search { display: grid; grid-template-columns: auto minmax(180px, 1fr) 180px auto; gap: 8px; align-items: center; }
.inbox-section h2 { font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 650; padding: 14px 18px 6px; margin: 0; }
.inbox-row { display: flex; gap: 11px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--border); text-decoration: none; color: inherit; border-left: 2px solid transparent; }
.inbox-row:hover { background: var(--bg-subtle); text-decoration: none; }
.inbox-row-body { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.inbox-row-body > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-row.unread { background: var(--accent-tint); border-left-color: var(--accent); }
.unmatched-list form { display: flex; gap: 7px; margin-left: auto; }
.contact-head .page-actions form { display: inline-flex; margin: 0; }
@media (max-width: 1000px) {
  .contact-conv-layout { grid-template-columns: 1fr; }
  .contact-conv-main { height: auto; min-height: 0; }
  .contact-conv-main #streamPane { max-height: 60vh; }
  .contact-sidebar { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 760px) {
  .triage-bar { justify-content: flex-start; overflow-x: auto; }
  .triage-bar .tag { display: none; }
  .contact-head { align-items: flex-start; }
  .composer-actions { align-items: stretch; }
  .composer-actions > * { flex: 1 1 100%; }
  .inbox-search { grid-template-columns: 1fr; }
  .unmatched-list .inbox-row { align-items: flex-start; flex-direction: column; }
  .unmatched-list form { margin: 0; width: 100%; flex-wrap: wrap; }
}
