/* ─── Geist Font ─────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Geist';
  src: url('/fonts/GeistVF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('/fonts/GeistMonoVF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ─── Order Care Hub — Slate + Teal ─────────────────────────────────────── */

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

/* Native form-control chrome (select popups, scrollbars, date pickers) follows
   the app theme. Without this Chrome paints select DROPDOWN LISTS light inside
   the dark UI — the jarring pale bar over the reply composer. Default is dark
   (matches the :root palette below); the light theme opts back out. */
:root, [data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

:root {
  /* Surfaces — dark slate ladder (retuned: lifted + wider steps for clearer elevation) */
  --bg:         #0d1218;   /* app canvas (darkest)             was #0b1014 */
  --surface:    #141b22;   /* primary cards/panels             was #0f161c */
  --surface-2:  #1b242d;   /* inputs, hover, inset sub-panels  was #131b23 */
  --surface-3:  #232f3a;   /* raised/active chips              was #19232d */
  --border:     #2b3947;   /* default separators (stronger)    was #1f2a35 */
  --border-2:   #3a4a5a;   /* hover/active edges               was #2a3744 */

  /* Text */
  --text:       #e6edf3;
  --text-soft:  #c2ccd6;
  --muted:      #93a1b1;
  --muted-2:    #7c8a99;   /* de-emphasized labels/icons — lifted to pass AA; was #5b6775 (~2.7:1) */

  /* Accent — calm teal */
  --accent:       #2dd4bf;
  --accent-soft:  rgba(45, 212, 191, 0.12);
  --accent-line:  rgba(45, 212, 191, 0.35);
  --accent-dark:  #14b8a6;
  --accent-text:  #0b1014;

  /* Status — base palette (muted, not neon) */
  --red:     #f87171;
  --red-soft:   rgba(248, 113, 113, 0.12);
  --amber:   #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --green:   #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --blue:    #60a5fa;
  --blue-soft:  rgba(96, 165, 250, 0.12);

  /* Status — semantic aliases (prefer these going forward). They reference the base
     tokens above, so light mode re-themes them automatically via the [data-theme="light"]
     block — no separate light overrides needed. Consolidates the forked Tailwind-500 set. */
  --danger:       var(--red);
  --danger-soft:  var(--red-soft);
  --warn:         var(--amber);
  --warn-soft:    var(--amber-soft);
  --success:      var(--green);
  --success-soft: var(--green-soft);
  --info:         var(--blue);
  --info-soft:    var(--blue-soft);

  /* Type scale — one source of truth, replaces ad-hoc 11/12/12.5/13/14px */
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;
  --line-tight: 1.35;
  --line-base: 1.6;
  --line-relaxed: 1.7;

  /* Radius scale — replaces ad-hoc 6/7/8/10/20px */
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Spacing rhythm */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --radius-sm: 6px;

  /* Avatar palette — dark enough for white initials; legible on both light + dark page bg */
  --av-1: #0891b2;  /* cyan-600    */
  --av-2: #7c3aed;  /* violet-600  */
  --av-3: #b45309;  /* amber-700   */
  --av-4: #059669;  /* emerald-600 */
  --av-5: #b91c1c;  /* red-700     */
  --av-6: #4f46e5;  /* indigo-600  */
  --av-text: #fff;  /* initials color */

  /* Type */
  --font-sans: "Geist", ui-sans-serif, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv01";
  min-width: 0;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
input, textarea, select { font: inherit; color: inherit; }

code, .mono {
  font-family: var(--font-mono);
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--text-soft);
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  max-width: 100%;
}
.page-content > .container { max-width: 1200px; margin: 0 auto; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar-brand { padding: 20px 16px 4px; position: relative; }
.brand-switcher-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, background .15s ease;
}
.brand-switcher-btn:hover { border-color: var(--border-2); background: var(--surface-3); }
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(45,212,191,0.18);
}
.brand-name { letter-spacing: -0.01em; }
.chevron { margin-left: auto; color: var(--muted); }

.sidebar-nav { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: color .15s ease, background .15s ease;
}
.nav-item svg { color: var(--muted-2); transition: color .15s ease; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover svg { color: var(--muted); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active svg { color: var(--accent); }
.nav-label { flex: 1; letter-spacing: -0.005em; }

.sidebar-collapse-btn { display: none; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 20px;
  flex-shrink: 0;
}
.topbar-left { flex: 1; display: flex; align-items: center; gap: 18px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }

.search-form { flex-shrink: 0; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; color: var(--muted-2); pointer-events: none; }
.search-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px 8px 34px;
  font-size: 13px;
  width: 320px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.search-input::placeholder { color: var(--muted-2); }
.search-input:focus { border-color: var(--accent-line); background: var(--surface-3); }

/* Bank-page tab strip */
.bank-tabs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.bank-tab {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.bank-tab:hover { color: var(--text); background: var(--surface-2); }
.bank-tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-2);
}
.bank-tab .bank-dot {
  width: 6px; height: 6px; border-radius: 50%;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
}

.user-btn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none;
  color: var(--text); cursor: pointer;
  font-size: 13px; padding: 6px 8px; border-radius: var(--radius-sm);
  transition: background .15s ease;
}
.user-btn:hover { background: var(--surface-2); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-menu-wrap { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: 42px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); min-width: 160px; z-index: 100;
  padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.dropdown-item {
  display: block; width: 100%;
  background: none; border: none;
  color: var(--text); cursor: pointer;
  font-size: 13px; padding: 9px 12px;
  text-align: left; border-radius: var(--radius-sm);
}
.dropdown-item:hover { background: var(--surface-3); }
.dropdown-item.danger:hover { color: var(--red); }

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 28px;
}
.page-title {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
}
.page-subtitle {
  color: var(--muted);
  font-size: 13.5px;
}
.page-header-meta { display: flex; gap: 8px; margin-left: auto; }

.count-pill {
  display: inline-flex; align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}
.count-pill.open    { background: var(--blue-soft);  color: var(--blue);  border-color: rgba(96,165,250,0.22); }
.count-pill.pending { background: var(--amber-soft); color: var(--amber); border-color: rgba(251,191,36,0.22); }
.count-pill.resolved{ background: var(--green-soft); color: var(--green); border-color: rgba(74,222,128,0.22); }

/* ─── Filters ────────────────────────────────────────────────────────────── */
.filter-bar { margin-bottom: 18px; }
.filter-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color .15s ease;
}
.filter-select:focus { border-color: var(--accent-line); }

/* ─── Ticket list ────────────────────────────────────────────────────────── */
.ticket-list { display: flex; flex-direction: column; gap: 4px; }

.pagebar { display: flex; flex-direction: column; gap: 6px; padding: 10px 4px 2px; }
.pagebar-center { text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pagebar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pagebar-pp { padding: 5px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-soft); font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; }
.pagebar-pp:hover { border-color: var(--border-2); }
.pagebar-right { display: flex; align-items: center; gap: 8px; }
.pagebar-pageof { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pagebar-btn { padding: 5px 12px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border); }
a.pagebar-btn:hover { color: var(--text); border-color: var(--border-2); }
.pagebar-btn.disabled { opacity: .4; cursor: default; }
.ticket-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.ticket-row:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
}
.ticket-row.urgent {
  border-left: 3px solid var(--red);
  padding-left: 17px;
}
.ticket-row.unread { background: var(--surface-2); }

.ticket-row-urgency { flex-shrink: 0; }
.urgency-dot { width: 8px; height: 8px; border-radius: 50%; display: block; }
.urgency-dot.high, .urgency-dot.urgent { background: var(--red); }
.urgency-dot.normal { background: var(--muted-2); }
.urgency-dot.low    { background: var(--border-2); }

.ticket-row-main { flex: 1; min-width: 0; }
.ticket-row-subject {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}
.ticket-row-subject.bold { font-weight: 600; }
.ticket-row-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; font-size: 12.5px;
  color: var(--muted);
}
.meta-sep { color: var(--border-2); }
.ticket-row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ticket-time { font-size: 12px; color: var(--text-soft); white-space: nowrap; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge-open       { background: var(--blue-soft);   color: var(--blue);    border-color: rgba(96,165,250,0.22); }
.badge-pending    { background: var(--amber-soft);  color: var(--amber);   border-color: rgba(251,191,36,0.22); }
.badge-resolved   { background: var(--green-soft);  color: var(--green);   border-color: rgba(74,222,128,0.22); }
.badge-urgent,
.badge-high       { background: var(--red-soft);    color: var(--red);     border-color: rgba(248,113,113,0.25); }
.badge-normal     { background: var(--surface-3);   color: var(--muted);   border-color: var(--border-2); }
.badge-low        { background: var(--surface-2);   color: var(--muted-2); }
.badge-cat        { background: var(--surface-3);   color: var(--text-soft); border-color: var(--border-2); }
.badge-shipped    { background: var(--blue-soft);   color: var(--blue); }
.badge-delivered  { background: var(--green-soft);  color: var(--green); }
.badge-processing { background: var(--amber-soft);  color: var(--amber); }
.badge-cancelled  { background: var(--red-soft);    color: var(--red); }
.badge-xs { font-size: 10px; padding: 2px 7px; }

/* ─── Ticket detail ──────────────────────────────────────────────────────── */
.ticket-page { padding-top: 4px; }
.ticket-back { margin-bottom: 18px; }
.back-link { color: var(--text-soft); font-size: 13px; }
.back-link:hover { color: var(--text); }
.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) 320px;
  gap: 32px;
  align-items: start;
  /* FLUID — no max-width (owner ruling 2026-07-09: "it needs to scale with
     the size of the page"). Two capped variants were tried and rejected the
     same day: centered stranded a gap beside the split-view rail; left-
     aligned stranded dead space right of the sidebar. The layout fills the
     viewport; message bubbles cap their own line length. Do not re-add a cap
     here without an owner instruction. */
}
.ticket-header { margin-bottom: 24px; }
.ticket-toolbar { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; margin-top:12px; }
.billing-provider { border:0; padding:0; margin:0 0 16px; min-width:0; }
.billing-provider legend { font-size:12px; font-weight:600; margin-bottom:10px; color:var(--text-soft); }
.billing-provider-options { display:flex; flex-wrap:wrap; gap:8px; }
.billing-provider-options label { display:flex; align-items:center; gap:8px; min-height:42px; padding:9px 14px; border:1px solid var(--border); border-radius:9px; background:var(--surface); cursor:pointer; font-size:13px; }
.billing-provider-options label:has(:checked) { border-color:var(--accent); background:var(--accent-soft); }
.billing-provider-options input { accent-color:var(--accent); }
.billing-provider-help,.billing-provider [role=status] { font-size:12px; color:var(--text-soft); margin:10px 0 0; }
.connection-card[data-active=true] { box-shadow:inset 0 0 0 1px var(--accent-line),var(--crm-raised-shadow); }
.spam-exceptions summary { cursor:pointer; padding:12px 0; color:var(--text-soft); font-size:13px; }
.spam-exceptions input { min-height:40px; padding:8px 12px; border:1px solid var(--border); border-radius:8px; color:var(--text); background:var(--surface); }
.template-library-page .page-header { justify-content:space-between; align-items:center; gap:16px; }
.template-library-intro { margin:8px 0 0; color:var(--text-soft); font-size:13px; }
.template-admin { margin:0 0 18px; border-bottom:1px solid var(--border); }
.template-admin > summary { padding:12px 0; font-size:12px; color:var(--text-soft); cursor:pointer; }
.template-admin-body { padding:16px; margin-bottom:16px; background:var(--surface); border:1px solid var(--border); border-radius:12px; }
.template-library-toolbar { display:flex; align-items:flex-end; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.template-library-toolbar label { display:flex; flex-direction:column; gap:7px; font-size:11px; font-weight:600; color:var(--text-soft); }
.template-library-toolbar .template-search { flex:1; min-width:180px; }
.template-library-toolbar :is(input,select) { min-height:42px; border:1px solid var(--border); border-radius:9px; background:var(--surface); color:var(--text); padding:9px 12px; font:inherit; font-size:13px; }
.template-library-toolbar #templateCount { font-size:12px; color:var(--text-soft); padding-bottom:12px; font-variant-numeric:tabular-nums; }
.template-library-layout { display:grid; grid-template-columns:minmax(240px,320px) minmax(0,1fr); gap:20px; align-items:start; }
.template-library-results { display:flex; flex-direction:column; gap:6px; max-height:calc(100dvh - 285px); overflow:auto; padding:2px; }
.template-result { display:flex; flex-direction:column; gap:8px; text-align:left; width:100%; padding:16px; border:1px solid transparent; border-radius:11px; color:var(--text); background:var(--surface); cursor:pointer; transition:background-color 180ms,border-color 180ms; }
.template-result:hover { background:var(--surface-2); border-color:var(--border); }
.template-result[aria-pressed=true] { background:var(--accent-soft); border-color:var(--accent); }
.template-result strong { font-size:13px; line-height:1.5; }
.template-result-category,.template-preview-category { color:var(--text-soft); font-size:10px; letter-spacing:.04em; text-transform:uppercase; }
.template-result-subject { font-size:12px; color:var(--text-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.template-result .tpl-badge { align-self:flex-start; }
.template-result[data-tpl-status="deprecated"] { opacity:.65; }
.template-preview { min-width:0; background:var(--surface); border:1px solid var(--border); border-radius:16px; box-shadow:var(--crm-raised-shadow); overflow:hidden; }
.template-preview-heading { padding:24px; border-bottom:1px solid var(--border); }
.template-preview-heading h2 { font-size:20px; line-height:1.4; margin:12px 0 8px; text-wrap:balance; }
.template-preview-meta { margin:0; font-size:12px; color:var(--text-soft); }
.template-preview-subject { padding:18px 24px; border-bottom:1px solid var(--border); }
.template-preview-subject > span { font-size:11px; color:var(--text-soft); }
.template-preview-subject p { margin:8px 0 0; font-size:14px; }
.template-preview-body { padding:24px; white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; line-height:1.85; color:var(--text); min-height:220px; }
.template-preview-footer { display:flex; flex-wrap:wrap; gap:8px; padding:18px 24px; border-top:1px solid var(--border); background:var(--surface-2); }
.template-empty { padding:24px; color:var(--text-soft); }
@media(max-width:800px) { .template-library-layout { grid-template-columns:minmax(0,1fr); } .template-library-results { max-height:260px; } .template-preview-heading,.template-preview-subject,.template-preview-body,.template-preview-footer { padding:18px; } }
.ticket-status-actions { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.ticket-action-menu { position:relative; }
.ticket-action-menu summary,.ticket-outcome-menu summary { cursor:pointer; list-style:none; }
.ticket-action-menu summary::-webkit-details-marker,.ticket-outcome-menu summary::-webkit-details-marker { display:none; }
.ticket-action-popover { position:absolute; top:calc(100% + 6px); left:0; z-index:20; padding:8px; min-width:170px; background:var(--surface); border:1px solid var(--border-2); border-radius:12px; box-shadow:0 12px 28px #0004; }
.ticket-action-popover .btn { width:100%; min-height:40px; justify-content:flex-start; }
.ticket-action-popover form + form { margin-top:4px !important; }
.ticket-outcome-menu { margin-top:8px; }
.ticket-outcome-menu summary { display:inline-flex; align-items:center; gap:6px; min-height:40px; color:var(--text-soft); font-size:12px; }
.ticket-outcome-menu summary:focus-visible,.ticket-action-menu summary:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.ticket-outcome-menu .qol-action-bar { border:0; margin:0; padding:4px 0 8px; }
body.embedded .app-shell .page-content,body.embedded .page-content.ticket-page { padding:16px !important; }
body.embedded .ticket-layout { gap:24px; }
body.embedded .ticket-sidebar-col { gap:16px; }
body.embedded .ticket-sidebar-col > .panel { margin-bottom:0 !important; }
@media(min-width:760px) { body.embedded .ticket-layout { grid-template-columns:minmax(0,1fr) minmax(240px,28%); } }
@media(max-width:759px) { body.embedded .ticket-layout { grid-template-columns:minmax(0,1fr); } }
.ticket-subject-row {
  display: flex; align-items: flex-start; gap: 12px;
  flex-wrap: wrap;
}
.ticket-subject {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  flex: 1;
  line-height: 1.3;
}
.ticket-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ticket-id-line { font-size: 12.5px; margin-top: 8px; color: var(--muted); }

/* ─── Thread ─────────────────────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 18px; margin-bottom: 28px; }
.thread-message { display: flex; gap: 12px; align-items: flex-start !important; }
.thread-message.msg-customer { align-items: flex-start !important; }
.thread-message.msg-agent { align-items: flex-start !important; flex-direction: row-reverse; }
.thread-message.msg-note { align-items: flex-start !important; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.avatar-agent    { background: var(--accent); color: var(--accent-text); }
.avatar-customer { background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text-soft); }
.msg-body-wrap {
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: 70%;
  min-width: 0;
  height: auto !important;
  justify-content: flex-start !important;
  align-items: flex-start !important;
  align-self: flex-start !important;
}
.msg-customer .msg-body-wrap { align-items: flex-start; }
.msg-agent    .msg-body-wrap { align-items: flex-end; align-self: flex-start; }
.msg-meta {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 6px; font-size: 12px;
}
.msg-agent .msg-meta { flex-direction: row-reverse; }
.msg-from { font-weight: 500; color: var(--text-soft); }
.msg-time { color: var(--muted); }
.msg-sent-from { align-self:flex-end; display:flex; flex-wrap:wrap; gap:4px; max-width:100%; margin-top:5px; color:var(--muted); font-size:11px; line-height:1.4; }
.msg-sent-from span { overflow-wrap:anywhere; }
.msg-translation { max-width:100%; margin-top:6px; }
.msg-translate-button { display:inline-flex; align-items:center; min-height:40px; padding:6px 0; border:0; background:transparent; color:var(--accent); font:inherit; font-size:12px; cursor:pointer; }
.msg-translate-button:hover { text-decoration:underline; }
.msg-translate-button:focus-visible { outline:2px solid var(--accent); outline-offset:3px; border-radius:4px; }
.msg-translate-button:disabled { color:var(--muted); cursor:wait; }
.msg-translation-result { padding:12px 14px; border:1px solid var(--border); border-left:2px solid var(--accent); border-radius:10px; background:var(--surface); }
.msg-translation-label { display:block; margin-bottom:8px; color:var(--muted); font-size:11px; font-weight:600; }
.msg-translation-text { white-space:pre-wrap; overflow-wrap:anywhere; font-size:13px; line-height:1.6; }
.msg-translation-status { margin:2px 0 8px; color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.msg-translation [hidden] { display:none !important; }
.delivery-failure-notice { width:100%; padding:14px 16px; border:1px solid var(--amber); border-radius:12px; background:var(--amber-soft); color:var(--text); }
.delivery-failure-heading { display:flex; align-items:center; gap:8px; color:var(--amber); font-size:13px; }
.delivery-failure-heading>span { display:grid; place-items:center; width:20px; height:20px; border:1px solid currentColor; border-radius:50%; font-weight:700; flex-shrink:0; }
.delivery-failure-heading time { margin-left:auto; font-size:11px; color:var(--muted); }
.delivery-failure-notice p { margin-top:10px; font-size:13px; line-height:1.5; }
.delivery-failure-recipient { display:block; margin-top:5px; font-size:12px; color:var(--text-soft); overflow-wrap:anywhere; }
.delivery-failure-notice summary { display:flex; align-items:center; min-height:40px; margin-top:5px; cursor:pointer; font-size:12px; color:var(--text-soft); }
.delivery-failure-notice pre { padding:12px; border-radius:8px; background:var(--surface); font:11px/1.6 'Geist Mono',monospace; white-space:pre-wrap; overflow-wrap:anywhere; }
.msg-body {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  height: auto;
  min-height: 0;
  align-self: flex-start;
  flex: 0 0 auto;
}
.msg-agent .msg-body {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

/* ── Thread readability pass (hybrid: minimal calm + soft bubbles) ──────── */
.thread { gap: var(--space-5); }

.thread-message .msg-body {
  font-size: var(--text-base);
  line-height: var(--line-relaxed);
  padding: 12px 15px;
  border-radius: var(--radius-lg);
}
/* Asymmetric corner toward the avatar — signals direction without color */
.thread-message.msg-customer .msg-body { border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg); }
.thread-message.msg-agent .msg-body { border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); }

.msg-from { font-size: var(--text-sm); }
.msg-time { font-size: var(--text-xs); }
.msg-meta { margin-bottom: 5px; }

/* Internal note → quiet, centered, unmistakably not a reply */
.thread-message.msg-note {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 3px;
  background: transparent !important;
  border: none !important;
  padding: 4px 0 !important;
  margin: 2px 0 !important;
}
.thread-message.msg-note .msg-avatar { display: none; }
.thread-message.msg-note .msg-body-wrap { align-items: flex-start; width: fit-content; max-width: 80%; }
.thread-message.msg-note .msg-meta { justify-content: flex-start; gap: 6px; flex-wrap: wrap; color: var(--text-soft); }
.thread-message.msg-note .msg-from { color: var(--amber); font-weight: 600; }
/* Draft bubble — unmistakably "not sent": dashed amber edge, dimmed fill, badge */
.thread-message.msg-draft .msg-body {
  background: rgba(245, 158, 11, 0.06);
  border: 1px dashed rgba(245, 158, 11, 0.45);
  opacity: 0.92;
}
.draft-badge {
  display: inline-flex; align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
  white-space: nowrap;
}
.draft-load-btn {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  cursor: pointer;
  transition-property: background-color, border-color;
  transition-duration: 0.15s;
}
.draft-load-btn:hover { background: var(--surface-2); border-color: var(--accent); }
[data-theme="light"] .thread-message.msg-draft .msg-body { background: rgba(180, 83, 9, 0.05); border-color: rgba(180, 83, 9, 0.4); }
[data-theme="light"] .draft-badge { background: rgba(180, 83, 9, 0.1); color: #b45309; border-color: rgba(180, 83, 9, 0.3); }

.thread-message.msg-note .msg-body {
  align-self: stretch;
  background: var(--amber-soft);
  color: var(--text);
  font-size: var(--text-sm);
  line-height: var(--line-base);
  text-align: left;
  border-left: 2px solid var(--amber);
  border-radius: var(--radius);
  padding: 8px 12px;
}

/* Phoenix action note → a recorded cancel/refund action. Same quiet note layout as .msg-note, but a
   distinct VIOLET label + accent so it reads as a system action, not a plain amber internal note.
   (These rules follow .msg-note above; an action note carries BOTH classes so they win the overrides.) */
.thread-message.msg-action .msg-from { color: #8b5cf6; }
.thread-message.msg-action .msg-body {
  background: rgba(139, 92, 246, 0.10);
  border-left-color: #8b5cf6;
}

/* ─── Reply box ──────────────────────────────────────────────────────────── */
.reply-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.reply-tabs {
  display: flex; gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.reply-tab {
  background: none; border: none;
  color: var(--muted); font-size: 13px;
  cursor: pointer; padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.reply-tab:hover { color: var(--text); }
.reply-tab.active { color: var(--text); background: var(--surface-2); }
.template-picker { margin-bottom: 12px; }
/* A select's natural width = its LONGEST option name. Long template names
   (e.g. the 97-char subscription-confirmation one) made the picker grow past
   the composer panel and overlap the page. Pin it to the panel; the closed
   control ellipsizes long names, the popup still shows them in full. */
.template-picker .filter-select { display: block; width: 100%; max-width: 100%; }
.reply-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color .15s ease;
}
.reply-textarea:focus { border-color: var(--accent-line); }
.reply-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.reply-hint { font-size: 11.5px; color: var(--muted); }

/* ─── Ticket sidebar panels ──────────────────────────────────────────────── */
.ticket-sidebar-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  /* Note: border-radius clip handled per-child */
}
.panel-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.panel-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.cust-name { font-weight: 600; color: var(--text); }
.cust-email, .cust-phone { font-size: 12.5px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: break-all; }
.cust-email { word-break: break-all; white-space: normal; }

/* Order detail grid — stack on narrow viewports */
@media (max-width: 1100px) {
  .order-detail-grid { grid-template-columns: minmax(0, 1fr) !important; }
}
.cust-stats { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.order-id { font-weight: 700; font-size: 14px; color: var(--text); font-family: var(--font-mono); }
.order-product { font-size: 13px; color: var(--text-soft); }
.order-status { display: flex; align-items: center; gap: 8px; }
.order-tracking { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.other-ticket-link {
  display: block; font-size: 12.5px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  color: var(--text-soft);
}
.other-ticket-link:last-child { border-bottom: none; }
.other-ticket-link:hover { color: var(--text); }
.other-ticket-link .muted { margin-right: 6px; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-3); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-danger:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm  { padding: 6px 12px; font-size: 12.5px; }
.btn-full { width: 100%; }
.mt8 { margin-top: 8px; }

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login-body {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(45,212,191,0.06), transparent 60%),
    var(--bg);
}
.login-container { width: 100%; max-width: 400px; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px;
  margin-bottom: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.02em; }
.login-sub { margin-bottom: 24px; color: var(--muted); }
.login-hint { font-size: 12px; text-align: center; color: var(--muted); }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; color: var(--text-soft); }
.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s ease;
}
.form-input:focus { border-color: var(--accent-line); }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
}
.alert-error {
  background: var(--red-soft);
  border: 1px solid rgba(248,113,113,0.25);
  color: var(--red);
}

/* ─── Misc ───────────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.bold  { font-weight: 600; }
.empty-state {
  padding: 72px 32px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty-state h3 { color: var(--text-soft); font-weight: 600; margin-bottom: 6px; }
.coming-soon { padding: 64px 32px; text-align: center; color: var(--muted); }

/* ─── Hamburger / sidebar overlay ───────────────────────────────────────── */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  transition: background .15s, border-color .15s;
}
.hamburger-btn:hover { background: var(--surface-2); border-color: var(--border-2); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  backdrop-filter: blur(1px);
}
.sidebar-backdrop.open { display: block; }

/* Compact mailbox select (shown on narrow when pills hidden) */
.mailbox-select {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  max-width: 160px;
  transition: border-color .15s;
}
.mailbox-select:focus { border-color: var(--accent-line); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .search-input { width: 220px; }
}
@media (max-width: 980px) {
  .ticket-layout { grid-template-columns: minmax(0,1fr); }
  .ticket-sidebar-col { position: static; }
  .page-content { padding: 24px; }
  .topbar { padding: 0 18px; gap: 14px; }
}
@media (max-width: 820px) {
  /* mailbox-seg hidden via its own rule; show compact select */
  .mailbox-select { display: block; }
}
@media (max-width: 680px) {
  .search-input { width: 160px; }
  .bank-tabs { display: none; }
}

/* ─── Tablet (640–1024px) ────────────────────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 641px) {
  .page-content { padding: 24px; }
}

/* ─── Mobile (<640px) ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Show hamburger */
  .hamburger-btn { display: inline-flex; }

  /* Sidebar: slide-in overlay */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    will-change: transform;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.6);
  }

  /* Keep the app shell as the desktop flex column (100vh, overflow:hidden) so
     .page-content stays the internal scroll container. The sidebar is
     position:fixed on mobile, so it's already out of flow — switching the shell
     to display:block (the old rule) was unnecessary and collapsed the flex
     height chain, leaving .page-content unconstrained: content overflowed the
     100vh/overflow:hidden body and could not be scrolled to. main-area just
     needs full width now that the sidebar reserves none. */
  .main-area { width: 100%; }

  /* Page padding */
  .page-content { padding: 16px; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 10px; height: var(--topbar-h); }
  .topbar-left { gap: 10px; }
  .search-input { width: 130px; }
  /* Hide brand pill in topbar-right on mobile */
  .topbar-right .brand-pill { display: none; }
  /* Hide user name, keep avatar */
  .topbar-right .user-name { display: none; }

  /* Mailbox selector: hide pills, show select */
  .mailbox-seg { display: none !important; }
  .mailbox-select { display: block; max-width: 140px; }

  /* Ticket rows */
  .ticket-row { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .ticket-row-right { width: 100%; justify-content: flex-start; padding-left: 22px; margin-top: 2px; }
  .ticket-row-meta { flex-wrap: wrap; }

  /* Thread messages */
  .msg-body-wrap { max-width: calc(100% - 40px); }
  .thread-message { gap: 8px; }
  .msg-body { padding: 10px 12px; font-size: 13px; }

  /* Reply box */
  .reply-box { padding: 12px; }
  .reply-actions { flex-wrap: wrap; gap: 8px; }

  /* Page header stack on mobile */
  .page-header { flex-wrap: wrap; gap: 8px; }
  .page-header-meta { margin-left: 0; }

  /* Ticket subject */
  .ticket-subject { font-size: 17px; }

  /* Filter bar */
  .filter-form { flex-wrap: wrap; }
  .filter-select { flex: 1; min-width: 120px; }

  /* Toast */
  #toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { font-size: 12.5px; }

  /* Flow chip wraps */
  .ticket-flow { flex-wrap: wrap; gap: 6px; }
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 28px; right: 28px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  display:flex; align-items:center; gap:12px; overflow-wrap:anywhere;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  animation: fadeIn .22s ease;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.toast>span { flex:1; min-width:0; }
.toast-dismiss { flex-shrink:0; width:40px; height:40px; border:0; border-radius:6px; color:inherit; background:transparent; cursor:pointer; font-size:20px; }
.toast-dismiss:hover { background:var(--surface-2); }
.toast-dismiss:focus-visible { outline:2px solid var(--accent); }
.toast-error {
  background: var(--red-soft);
  border-color: rgba(248,113,113,0.3);
  color: var(--red);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Scrollbar polish (webkit) ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ─── Theme toggle button ──────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-3); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ─── Stronger bold for the right things ──────────────────────────────── */
.ticket-row.unread .ticket-row-subject,
.ticket-row .ticket-row-subject.bold { font-weight: 650; color: var(--text); }
.cust-name      { font-weight: 650; letter-spacing: -0.01em; }
.order-id       { font-weight: 700; letter-spacing: -0.005em; }
.ticket-subject { font-weight: 700; }
.page-title     { font-weight: 700; }
.msg-from       { font-weight: 600; }
.brand-name     { font-weight: 650; }

/* ─── LIGHT THEME — Reamaze style ─────────────────────────────────────── */
[data-theme="light"] {
  --bg:         #f0f2f5;
  --surface:    #ffffff;
  --surface-2:  #f7f8fa;
  --surface-3:  #eef0f3;
  --border:     #a3acb8;     /* crisp, clearly-defined separators (~2.1:1 on white) — high-contrast, not soft grey */
  --border-2:   #828d9c;     /* strong hover/active edges (~2.9:1) */

  --text:       #0c1016;     /* near-black body text — maximum crispness */
  --text-soft:  #1b232e;     /* crisp secondary */
  --muted:      #29323e;     /* darkened meta text — stays sharp on white */
  --muted-2:    #394353;     /* de-emphasized but still well-defined */

  --accent:       #0593b0;     /* vivid, saturated cyan that pops on white (kept punchy per request) */
  --accent-soft:  rgba(5, 147, 176, 0.12);
  --accent-line:  rgba(5, 147, 176, 0.40);
  --accent-dark:  #03708a;     /* saturated hover/pressed */
  --accent-text:  #ffffff;

  --red:        #c53030;
  --red-soft:   rgba(197, 48, 48, 0.10);
  --amber:      #c05621;
  --amber-soft: rgba(192, 86, 33, 0.10);
  --green:      #276749;
  --green-soft: rgba(39, 103, 73, 0.10);
  --blue:       #2b6cb0;
  --blue-soft:  rgba(43, 108, 176, 0.10);
}

/* Base */
[data-theme="light"] body { background: var(--bg); color: var(--text); }
[data-theme="light"] a { color: inherit; }
[data-theme="light"] code, [data-theme="light"] .mono { background: var(--surface-3); color: var(--text-soft); }

/* Sidebar — dark slate (readable) */
[data-theme="light"] .sidebar { background: #ffffff; border-right-color: #e1e4e8; }
[data-theme="light"] .sidebar-brand { border-bottom: 1px solid #e1e4e8; }
[data-theme="light"] .brand-switcher-btn { background: rgba(255,255,255,0.06); border-color: #2d3748; color: #e2e8f0; }
[data-theme="light"] .brand-switcher-btn:hover { background: rgba(255,255,255,0.1); }
[data-theme="light"] .brand-switcher-btn .brand-name { color: #e2e8f0; }
[data-theme="light"] .brand-switcher-btn .chevron { color: #718096; }
[data-theme="light"] .brand-dot { box-shadow: 0 0 0 2px rgba(0,184,200,0.35); }
[data-theme="light"] .nav-item { color: #2d3748; }
[data-theme="light"] .nav-item svg { color: #718096; }
[data-theme="light"] .nav-item:hover { background: #f7f8fa; color: #1a202c; }
[data-theme="light"] .nav-item:hover svg { color: #4a5568; }
[data-theme="light"] .nav-item.active { background: rgba(0,153,168,0.10); color: #0099a8; font-weight: 600; }
[data-theme="light"] .nav-item.active svg { color: #0099a8; }
[data-theme="light"] .sidebar-section-label { color: #4a5568; font-weight: 700; letter-spacing: 0.07em; }
[data-theme="light"] .mailbox-item { color: #a0aec0; }
[data-theme="light"] .mailbox-item svg { color: #718096; }
[data-theme="light"] .mailbox-item:hover { background: #f7f8fa; color: #1a202c; }
[data-theme="light"] .mailbox-item.active { background: rgba(0,184,200,0.18); color: #00d4e6; }
[data-theme="light"] .mailbox-item.active svg { color: #00d4e6; }
[data-theme="light"] .sidebar-footer { border-top-color: #2d3748; }
[data-theme="light"] .sidebar-footer-link { color: #4a5568; }
[data-theme="light"] .sidebar-footer-link:hover { color: #e2e8f0; }

/* Topbar */
[data-theme="light"] .topbar { background: #fff; border-bottom-color: var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
[data-theme="light"] .mailbox-bar { background: #fff; border-bottom-color: var(--border); }
[data-theme="light"] .search-input { background: var(--surface-2); border-color: var(--border); color: var(--text); }
[data-theme="light"] .search-input::placeholder { color: var(--muted); }
[data-theme="light"] .search-input:focus { border-color: var(--accent-line); background: #fff; }
[data-theme="light"] .theme-toggle { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
[data-theme="light"] .theme-toggle:hover { color: var(--text); border-color: var(--border-2); }
[data-theme="light"] .user-btn { color: var(--text); }
[data-theme="light"] .user-btn:hover { background: var(--surface-2); }
[data-theme="light"] .user-avatar { background: #00b8c8; color: #fff; }
[data-theme="light"] .user-dropdown { background: #fff; border-color: var(--border); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
[data-theme="light"] .dropdown-item { color: var(--text); }
[data-theme="light"] .dropdown-item:hover { background: var(--surface-2); }
[data-theme="light"] .brand-pill { background: rgba(0,184,200,0.1); color: #007a87; border-color: rgba(0,184,200,0.25); }

/* Page content */
[data-theme="light"] .page-content { background: var(--bg); }
[data-theme="light"] .page-title { color: var(--text); }
[data-theme="light"] .page-subtitle { color: var(--muted); }
[data-theme="light"] .muted { color: var(--muted); }

/* Count pills */
[data-theme="light"] .count-pill.open    { background: rgba(43,108,176,0.10); color: #2b6cb0; border-color: rgba(43,108,176,0.2); }
[data-theme="light"] .count-pill.pending { background: rgba(192,86,33,0.10);  color: #c05621; border-color: rgba(192,86,33,0.2); }
[data-theme="light"] .count-pill.resolved{ background: rgba(39,103,73,0.10);  color: #276749; border-color: rgba(39,103,73,0.2); }

/* Filters */
[data-theme="light"] .filter-select { background: #fff; border-color: var(--border-2); color: var(--text); font-weight: 500; }
[data-theme="light"] .filter-select:focus { border-color: var(--accent-line); }

/* Ticket rows */
[data-theme="light"] .ticket-row { background: #fff; border-color: var(--border); }
[data-theme="light"] .ticket-row:hover { background: #f5fdfe; border-color: rgba(0,184,200,0.5); }
[data-theme="light"] .ticket-row.unread { background: #f0fafc; }
[data-theme="light"] .ticket-row.urgent { border-left-color: var(--red); }
[data-theme="light"] .ticket-row-subject { color: var(--text); }
[data-theme="light"] .ticket-row-meta { color: #4a5568; }
[data-theme="light"] .ticket-time { color: #4a5568; }

/* Badges */
[data-theme="light"] .badge-open     { background: rgba(43,108,176,0.10); color: #2b6cb0; border-color: rgba(43,108,176,0.2); }
[data-theme="light"] .badge-pending  { background: rgba(192,86,33,0.10);  color: #c05621; border-color: rgba(192,86,33,0.2); }
[data-theme="light"] .badge-resolved { background: rgba(39,103,73,0.10);  color: #276749; border-color: rgba(39,103,73,0.2); }
[data-theme="light"] .badge-urgent,
[data-theme="light"] .badge-high     { background: rgba(197,48,48,0.10);  color: #c53030; border-color: rgba(197,48,48,0.2); }
[data-theme="light"] .badge-normal   { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
[data-theme="light"] .badge-cat      { background: var(--surface-2); color: var(--text-soft); border-color: var(--border); }
[data-theme="light"] .badge-shipped  { background: rgba(43,108,176,0.10);  color: #2b6cb0; }
[data-theme="light"] .badge-delivered{ background: rgba(39,103,73,0.10);   color: #276749; }
[data-theme="light"] .badge-processing{ background: rgba(192,86,33,0.10);  color: #c05621; }

/* Ticket detail */
[data-theme="light"] .back-link { color: var(--muted); }
[data-theme="light"] .back-link:hover { color: var(--text); }
[data-theme="light"] .ticket-subject { color: var(--text); }
[data-theme="light"] .ticket-id-line { color: var(--muted); }
[data-theme="light"] .ticket-flow { background: var(--surface-2); border-color: var(--border); }
[data-theme="light"] .flow-chip { background: #fff; border-color: var(--border); color: var(--text-soft); }
[data-theme="light"] .flow-chip.flow-inbox { color: #007a87; }
[data-theme="light"] .flow-chip.flow-inbox svg { color: #007a87; }
[data-theme="light"] .flow-arrow { color: var(--muted-2); }

/* Thread */
[data-theme="light"] .msg-body { background: var(--surface-2); border-color: var(--border); color: var(--text); }
[data-theme="light"] .msg-agent .msg-body { background: rgba(0,184,200,0.08); border-color: rgba(0,184,200,0.25); color: var(--text); }
[data-theme="light"] .avatar-customer { background: var(--surface-3); border-color: var(--border-2); color: var(--muted); }
[data-theme="light"] .msg-from { color: var(--text-soft); }
[data-theme="light"] .msg-time { color: var(--muted); }

/* Reply box */
[data-theme="light"] .reply-box { background: #fff; border-color: var(--border); }
[data-theme="light"] .reply-tabs { border-bottom-color: var(--border); }
[data-theme="light"] .reply-tab { color: var(--muted); }
[data-theme="light"] .reply-tab:hover { color: var(--text); }
[data-theme="light"] .reply-tab.active { background: var(--surface-2); color: var(--text); }
[data-theme="light"] .reply-textarea { background: var(--surface-2); border-color: var(--border); color: var(--text); }
[data-theme="light"] .reply-textarea:focus { border-color: var(--accent-line); background: #fff; }
[data-theme="light"] .reply-hint { color: var(--muted); }

/* Panels (ticket sidebar) */
[data-theme="light"] .panel { background: #fff; border-color: var(--border); }
[data-theme="light"] .panel-title { background: var(--surface-2); color: #4a5568; border-bottom-color: var(--border); font-weight: 700; }
[data-theme="light"] .panel-body { color: var(--text); }
[data-theme="light"] .cust-name { color: var(--text); }
[data-theme="light"] .cust-email, [data-theme="light"] .cust-phone { color: var(--text-soft); }
[data-theme="light"] .cust-stats { color: var(--muted); }
[data-theme="light"] .order-id { color: var(--text); }
[data-theme="light"] .order-product { color: var(--text-soft); }
[data-theme="light"] .order-tracking { color: var(--muted); }
[data-theme="light"] .other-ticket-link { color: var(--text-soft); border-bottom-color: var(--border); }
[data-theme="light"] .other-ticket-link:hover { color: var(--text); }

/* Buttons */
[data-theme="light"] .btn-ghost { background: var(--surface-2); color: var(--text-soft); border-color: var(--border); }
[data-theme="light"] .btn-ghost:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-3); }

/* Forms */
[data-theme="light"] .form-input { background: #fff; border-color: var(--border); color: var(--text); }
[data-theme="light"] .form-input:focus { border-color: var(--accent-line); }
[data-theme="light"] .form-label { color: var(--text-soft); }

/* Login */
[data-theme="light"] .login-body { background: linear-gradient(135deg, #00b8c8 0%, #0099a8 100%); }
[data-theme="light"] .login-card { background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
[data-theme="light"] .login-title { color: var(--text); }
[data-theme="light"] .login-sub { color: var(--muted); }

/* Empty state */
[data-theme="light"] .empty-state { background: #fff; border-color: var(--border); color: var(--muted); }
[data-theme="light"] .empty-state h3 { color: var(--text-soft); }

/* Toast */
[data-theme="light"] .toast { background: #fff; border-color: var(--border); color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

/* Scrollbar */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border-2); border-color: var(--bg); }

/* ─── Mailbox segmented selector (replaces bank-tabs) ─────────────────── */
.mailbox-seg {
  display: inline-flex;
  align-items: stretch;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
  min-width: 0;
}
.mailbox-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.mailbox-seg-btn:hover { color: var(--text); background: var(--surface-3); }
.mailbox-seg-btn.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-2);
  box-shadow: 0 1px 0 rgba(255,255,255,0.02), 0 1px 6px rgba(0,0,0,0.18);
  font-weight: 600;
}
.mailbox-seg-btn svg { color: var(--muted-2); }
.mailbox-seg-btn.active svg { color: var(--accent); }
.mailbox-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.mailbox-email {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: -0.005em;
}

[data-theme="light"] .mailbox-seg-btn.active {
  box-shadow: 0 1px 2px rgba(15,23,42,0.06), 0 1px 0 rgba(255,255,255,0.6) inset;
}

@media (max-width: 1100px) {
  .mailbox-email { font-size: 12px; }
}
@media (max-width: 820px) {
  .mailbox-seg { display: none; }
}

/* ─── Ticket flow strip (inbox ↔ customer) ────────────────────────────── */
.ticket-flow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 6px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
}
.flow-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.flow-chip svg { color: var(--muted); }
.flow-chip.flow-inbox { color: var(--accent); }
.flow-chip.flow-inbox svg { color: var(--accent); }
.flow-chip .mono { background: transparent; padding: 0; font-size: 12.5px; color: inherit; }
.flow-arrow {
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1;
}

/* ─── Mailbox sub-bar (below topbar) ─────────────────────────────────── */
.mailbox-bar {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 28px;
  display: flex;
  align-items: center;
  height: 46px;
  flex-shrink: 0;
}
.mailbox-bar .mailbox-seg {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  gap: 2px;
}
.mailbox-bar .mailbox-seg-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
}
.mailbox-bar .mailbox-seg-btn.active {
  background: var(--surface-2);
  border-color: var(--border-2);
  box-shadow: none;
}

/* ─── Page header count pills — properly aligned ─────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}
.count-pill {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  line-height: 1;
}

/* ─── Main area — flex accounts for sub-bar ──────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Sidebar sections (inboxes) ─────────────────────────────────────── */
.sidebar-section { padding: 8px 10px 4px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  padding: 4px 12px 6px;
  margin-bottom: 2px;
}
.mailbox-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
  text-decoration: none;
  transition: color .15s, background .15s;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
}
.mailbox-item svg { color: var(--muted-2); flex-shrink: 0; width: 13px; height: 13px; }
.mailbox-item:hover { background: var(--surface-2); color: var(--text); }
.mailbox-item:hover svg { color: var(--muted); }
.mailbox-item.active { color: var(--accent); font-weight: 600; }
.mailbox-item.active svg { color: var(--accent); }
.mailbox-item .mailbox-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.mailbox-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-footer-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.sidebar-footer-link:hover { color: var(--text); }

/* Light theme sidebar section */
[data-theme="light"] .sidebar-section-label { color: #4a5568; font-weight: 700; letter-spacing: 0.07em; }
[data-theme="light"] .mailbox-item { color: rgba(255,255,255,0.92); }
[data-theme="light"] .mailbox-item svg { color: rgba(255,255,255,0.85); }
[data-theme="light"] .mailbox-item:hover { background: #f7f8fa; color: #1a202c; }
[data-theme="light"] .mailbox-item.active { background: rgba(0,184,200,0.18); color: #00d4e6; }
[data-theme="light"] .mailbox-item.active svg { color: #00d4e6; }
[data-theme="light"] .sidebar-footer { border-top-color: #2d3748; }
[data-theme="light"] .sidebar-footer-link { color: #4a5568; }
[data-theme="light"] .sidebar-footer-link:hover { color: #e2e8f0; }

/* ═══════════════════════════════════════════════════════════════════════════
   INBOX UPGRADE — New ticket row (Reamaze style), Tags, Sidebar filters
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Sidebar divider ──────────────────────────────────────────────────── */
.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 10px;
}

/* ─── Sidebar filter items (FILTERS + TAGS sections) ─────────────────── */
.sidebar-filter-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  transition: color .15s, background .15s;
  cursor: pointer;
}
.sidebar-filter-item svg { color: var(--muted-2); flex-shrink: 0; width: 13px; height: 13px; }
.sidebar-filter-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar-filter-item:hover svg { color: var(--muted); }
.sidebar-filter-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-filter-item.active svg { color: var(--accent); }
.sidebar-filter-item.active .count-badge { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.filter-label { flex: 1; }

/* ─── Count badge (sidebar right side) ────────────────────────────────── */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
  font-family: var(--font-mono);
}
.count-badge-amber { background: var(--amber-soft); color: var(--amber); border-color: rgba(251,191,36,0.3); }
.count-badge-blue  { background: var(--blue-soft);  color: var(--blue);  border-color: rgba(96,165,250,0.3); }
.count-badge-green { background: var(--green-soft); color: var(--green); border-color: rgba(74,222,128,0.3); }

/* ─── Tag swatch (small colored dot in sidebar) ───────────────────────── */
.tag-swatch {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ─── New ticket row v2 (Reamaze style) ───────────────────────────────── */
.ticket-row-v2 {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.ticket-row-v2:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
}
.ticket-row-v2.urgent {
  border-left: 3px solid var(--red);
  padding-left: 15px;
}
/* Status-based row differentiation — VA should know state in 2 seconds */

/* Unread (customer replied — needs VA attention) — most prominent */
.ticket-row-v2.unread {
  background: rgba(45, 212, 191, 0.05);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}
.ticket-row-v2.unread .ticket-v2-name { color: var(--text); font-weight: 700; }
.ticket-row-v2.unread .ticket-preview { color: var(--text-soft); }

/* Pending (VA replied — waiting on customer) — dimmed */
.ticket-row-v2.ts-pending {
  opacity: 0.7;
}
.ticket-row-v2.ts-pending:hover { opacity: 1; }

/* On Hold — parked, amber tint */
.ticket-row-v2.ts-onhold {
  border-left: 3px solid var(--amber);
  padding-left: 11px;
  background: rgba(245, 158, 11, 0.04);
}

/* Muted — very dimmed */
.ticket-row-v2.ts-muted {
  opacity: 0.45;
  filter: saturate(0.4);
}
.ticket-row-v2.ts-muted:hover { opacity: 0.8; filter: saturate(1); }

/* Resolved — almost invisible, for archive view */
.ticket-row-v2.ts-resolved {
  opacity: 0.5;
}

/* Unread dot */
.inbox-unread-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-right: 4px;
  vertical-align: middle;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Inline status pill next to name (for non-open states) */
.inbox-status-inline {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.inbox-status-inline.pending  { background: var(--amber-soft); color: var(--amber); }
.inbox-status-inline.onhold   { background: var(--amber-soft); color: var(--amber); }
.inbox-status-inline.muted    { background: rgba(148,163,184,0.15); color: var(--muted); }

/* Override: urgent + unread together — urgent border wins */
.ticket-row-v2.urgent.unread { border-left-color: var(--red); }
.ticket-row-v2.urgent.ts-onhold { border-left-color: var(--red); }

/* Checkbox */
.ticket-v2-check {
  padding-top: 2px;
  flex-shrink: 0;
}
.v2-checkbox {
  display: block;
  width: 15px; height: 15px;
  border: 1.5px solid var(--border-2);
  border-radius: 4px;
  background: transparent;
  transition: background .12s, border-color .12s;
  cursor: pointer;
}
.ticket-v2-check.checked .v2-checkbox {
  background: var(--accent);
  border-color: var(--accent);
  /* white checkmark so a selected row reads at a glance */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-6' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}
/* Hover affordance — hint the checkbox is interactive */
.ticket-row-v2:hover .v2-checkbox { border-color: var(--accent); }
/* Selected-row highlight — accent tint + left accent bar */
.ticket-row-v2.checked {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Avatar — color set via .av-N classes backed by CSS vars */
.ticket-avatar {
  width: 23px; height: 23px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
  color: var(--av-text);
  flex-shrink: 0;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.ticket-avatar.av-1 { background: var(--av-1); }
.ticket-avatar.av-2 { background: var(--av-2); }
.ticket-avatar.av-3 { background: var(--av-3); }
.ticket-avatar.av-4 { background: var(--av-4); }
.ticket-avatar.av-5 { background: var(--av-5); }
.ticket-avatar.av-6 { background: var(--av-6); }

/* Per-letter avatar: hue comes from the first letter via --avh (set inline).
   Tinted fill + colored initials + soft same-hue ring (inset shadow, no border)
   — reads as color-coded without 26 saturated discs shouting in the list. */
.ticket-avatar.av-letter {
  background: hsla(var(--avh, 210), 60%, 56%, 0.16);
  color: hsl(var(--avh, 210), 72%, 64%);
  box-shadow: inset 0 0 0 1px hsla(var(--avh, 210), 65%, 62%, 0.28);
  text-shadow: none;
}
[data-theme="light"] .ticket-avatar.av-letter {
  background: hsla(var(--avh, 210), 65%, 46%, 0.12);
  color: hsl(var(--avh, 210), 68%, 36%);
  box-shadow: inset 0 0 0 1px hsla(var(--avh, 210), 60%, 42%, 0.25);
}

/* Main content column — 4-tier stacked hierarchy */
.ticket-v2-main {
  flex: 1;
  min-width: 0;
}
/* Tier 1: sender name + status pills */
.ticket-v2-sender {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 1px;
  min-width: 0;
  overflow: hidden;
}
.ticket-v2-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.ticket-v2-name.bold { font-weight: 700; }
/* Tier 2: subject line */
.ticket-v2-subj {
  font-size: 13px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  min-width: 0;
}

/* Preview — expands to fill row width with ellipsis */
.ticket-preview {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
  line-height: 1.45;
  max-width: 100%;
  min-width: 0;
}

/* Source row */
.ticket-source-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
}
.ticket-source-chip {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.ticket-source-chip.inbox-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Reply state pills — tells VA at a glance what needs doing */
.reply-state-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.reply-state-pill.no-reply       { background: var(--red-soft);    color: var(--red); }
.reply-state-pill.customer-replied{ background: var(--accent-soft); color: var(--accent); }
.reply-state-pill.replied         { background: var(--green-soft);  color: var(--green); }
.src-sep { color: var(--border-2); font-size: 11px; }


/* Status badge (right column: Open/Pending/OnHold/Muted/Resolved) */
.ticket-status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-transform: capitalize;
}
.ticket-status-badge.status-open    { background: var(--blue-soft);  color: var(--blue); }
.ticket-status-badge.status-pending { background: var(--amber-soft); color: var(--amber); }
.ticket-status-badge.status-onhold  { background: rgba(245,158,11,0.12); color: #f59e0b; }
.ticket-status-badge.status-muted   { background: rgba(148,163,184,0.12); color: var(--muted); }
.ticket-status-badge.status-resolved { background: var(--green-soft); color: var(--green); }

/* Inbox triage new-data — same .ticket-status-badge shape as the existing pills.
   Waiting SLA is the ONE new visual: filled amber/red so it reads as an alert,
   with theme-flipped text verified ≥4.5:1 AA in both themes (dark 10.9:1/6.7:1,
   light 4.6:1/5.5:1). .jbadge only adds icon spacing to the James chip. */
.ticket-status-badge.sla-amber { background: var(--amber); color: #1c1403; }
.ticket-status-badge.sla-red   { background: var(--red);   color: #2a0806; }
[data-theme="light"] .ticket-status-badge.sla-amber { color: #fff; }
[data-theme="light"] .ticket-status-badge.sla-red   { color: #fff; }
.ticket-status-badge.jbadge { gap: 4px; }
.ticket-status-badge.jbadge svg { flex-shrink: 0; }

/* Right column — fixed-width vertical stack: time → badge → count */
.ticket-v2-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  width: 72px;
  padding-top: 1px;
}
/* Category badge in right column */
.ticket-cat-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border-2);
}
.ticket-reply-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ─── Tag pills ────────────────────────────────────────────────────────── */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.tag-pill-removable { padding-right: 4px; }
.tag-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  color: inherit;
  opacity: 0.7;
  transition: opacity .12s;
}
.tag-remove-btn:hover { opacity: 1; }

/* ─── Tag dropdown ─────────────────────────────────────────────────────── */
.tag-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 9000;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.tag-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background .12s;
}
.tag-dropdown-item:hover { background: var(--surface-3); }

/* ─── Ticket tags list (in ticket detail panel) ───────────────────────── */
.ticket-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─── count-pill onhold ─────────────────────────────────────────────────── */
.count-pill.onhold { background: var(--blue-soft); color: var(--blue); border-color: rgba(96,165,250,0.22); }

/* ─── badge-onhold ──────────────────────────────────────────────────────── */
.badge-onhold { background: var(--blue-soft); color: var(--blue); border-color: rgba(96,165,250,0.25); }

/* ─── Settings page ─────────────────────────────────────────────────────── */
.settings-section { max-width: 640px; margin-bottom: 40px; }
.settings-section-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
.settings-section-desc { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.tags-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.tag-settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tag-color-swatch {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
}
.tag-settings-name { font-size: 13.5px; font-weight: 500; color: var(--text); }
.btn-danger-ghost { color: var(--red) !important; }
.btn-danger-ghost:hover { border-color: var(--red) !important; background: var(--red-soft) !important; }

/* ─── Color swatch picker (settings) ─────────────────────────────────── */
.color-swatches { display: flex; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.color-swatch-label { cursor: pointer; }
.color-swatch-pick {
  display: block;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s, border-color .1s;
}
.color-swatch-pick.selected {
  border-color: var(--text);
  transform: scale(1.2);
}

/* ─── Light theme overrides for new elements ──────────────────────────── */
[data-theme="light"] .sidebar-divider { background: #2d3748; }
[data-theme="light"] .sidebar-filter-item { color: #a0aec0; }
[data-theme="light"] .sidebar-filter-item svg { color: #718096; }
[data-theme="light"] .sidebar-filter-item:hover { background: #f7f8fa; color: #1a202c; }
/* light-mode active overridden below */

[data-theme="light"] .ticket-row-v2 { background: #fff; border-color: var(--border); }
[data-theme="light"] .ticket-row-v2:hover { background: #f5fdfe; border-color: rgba(0,184,200,0.5); }
[data-theme="light"] .ticket-row-v2.unread { background: #f0fafc; }
[data-theme="light"] .ticket-v2-name { color: var(--text); }
[data-theme="light"] .ticket-v2-subj { color: var(--text-soft); }
[data-theme="light"] .ticket-preview { color: var(--muted); }
[data-theme="light"] .ticket-source-chip { color: var(--muted); }
[data-theme="light"] .ticket-reply-count { background: var(--surface-3); border-color: var(--border); color: var(--muted); }

[data-theme="light"] .ticket-status-badge.status-open    { background: rgba(43,108,176,0.10); color: #2b6cb0; }
[data-theme="light"] .ticket-status-badge.status-pending { background: rgba(192,86,33,0.10);  color: #c05621; }
[data-theme="light"] .ticket-status-badge.status-onhold  { background: rgba(245,158,11,0.10); color: #f59e0b; }
[data-theme="light"] .ticket-status-badge.status-muted   { background: rgba(148,163,184,0.10); color: #718096; }
[data-theme="light"] .ticket-status-badge.status-resolved { background: rgba(39,103,73,0.10);  color: #276749; }
[data-theme="light"] .v2-checkbox { border-color: var(--border-2); }

[data-theme="light"] .tag-dropdown { background: #fff; border-color: var(--border-2); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
[data-theme="light"] .tag-dropdown-item { color: var(--text); }
[data-theme="light"] .tag-dropdown-item:hover { background: var(--surface-2); }

[data-theme="light"] .count-badge { background: var(--surface-3); color: var(--muted); border-color: var(--border-2); }
[data-theme="light"] .tag-settings-row { background: #fff; border-color: var(--border); }
[data-theme="light"] .settings-section-title { color: var(--text); }
[data-theme="light"] .color-swatch-pick.selected { border-color: var(--text); }

[data-theme="light"] .badge-onhold { background: rgba(43,108,176,0.10); color: #2b6cb0; border-color: rgba(43,108,176,0.2); }
[data-theme="light"] .count-pill.onhold { background: rgba(43,108,176,0.10); color: #2b6cb0; border-color: rgba(43,108,176,0.2); }

/* ─── Panel title corner fix (overflow:visible on panel) ─────────────── */
.panel-title:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}
.panel-body:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ─── Light mode sidebar item fixes ──────────────────────────────────── */
[data-theme="light"] .mailbox-item { color: #1a202c; }
[data-theme="light"] .mailbox-item:hover { background: #f7f8fa; color: #1a202c; }
[data-theme="light"] .mailbox-item.active { color: #0099a8; font-weight: 600; }
[data-theme="light"] .sidebar-filter-item { color: #1a202c; }
[data-theme="light"] .sidebar-filter-item:hover { background: #f7f8fa; color: #1a202c; }
[data-theme="light"] .sidebar-filter-item.active { background: rgba(0,153,168,0.12); color: #0099a8; font-weight: 600; }
[data-theme="light"] .sidebar-filter-item.active svg { color: #0099a8; }
[data-theme="light"] .count-badge { background: #eef0f3; color: #2d3748; border-color: #c8cdd5; font-weight: 700; }
[data-theme="light"] .sidebar-filter-item.active .count-badge { background: rgba(0,153,168,0.10); color: #0099a8; border-color: rgba(0,153,168,0.25); }
[data-theme="light"] .sidebar-section-label { color: #718096; }

/* ═══════════════════════════════════════════════════════════════════════════
   ANALYTICS PAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.analytics-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 32px;
}

.page-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.page-subtitle-badge {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-weight: 500;
}

/* ── Summary cards grid ─────────────────────────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

@media (max-width: 1100px) {
  .analytics-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .analytics-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--accent); }

.stat-card-danger { border-left: 3px solid var(--danger); }

.stat-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.stat-trend {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}
.stat-trend-up   { color: var(--success); }
.stat-trend-down { color: var(--danger); }

/* ── Chart cards ────────────────────────────────────────────────────────── */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .chart-row { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.va-card { grid-column: 1 / -1; }

.chart-card-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}

.chart-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.chart-card-sub {
  font-size: 11px;
  color: var(--muted);
}

.chart-wrap { position: relative; }
.chart-wrap-lg     { height: 200px; }
.chart-wrap-md     { height: 180px; }
.chart-wrap-donut  { height: 200px; }

/* ── VA Leaderboard ─────────────────────────────────────────────────────── */
.va-table-wrap {
  overflow-x: auto;
}

.va-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.va-table thead th {
  text-align: left;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.va-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.va-table tbody tr:last-child { border-bottom: none; }
.va-table tbody tr:nth-child(even) { background: var(--surface-2); }
.va-table tbody tr:hover { background: rgba(45,212,191,0.05); }

.va-table tbody td {
  padding: 11px 14px;
  color: var(--text);
}

.va-name     { font-weight: 600; }
.va-resolved { font-weight: 500; color: var(--text); }
.va-response { color: var(--muted); }

.csat-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}
.csat-green { background: var(--success-soft); color: var(--success); border-color: rgba(16,185,129,0.25); }
.csat-amber { background: var(--warn-soft); color: var(--warn); border-color: rgba(245,158,11,0.25); }
.csat-red   { background: var(--danger-soft);  color: var(--danger); border-color: rgba(239,68,68,0.25); }

.va-trend { font-size: 16px; font-weight: 700; }
.trend-up   { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--muted); }

.va-csat-note {
  margin-top: 14px;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ── Light theme overrides for analytics ────────────────────────────────── */
[data-theme="light"] .stat-card      { background: #fff; border-color: var(--border); }
[data-theme="light"] .stat-card:hover { border-color: var(--accent); }
[data-theme="light"] .stat-number    { color: #1a202c; }
[data-theme="light"] .chart-card     { background: #fff; border-color: var(--border); }
[data-theme="light"] .chart-card-title { color: #1a202c; }
[data-theme="light"] .va-table thead th { color: #718096; border-bottom-color: var(--border); }
[data-theme="light"] .va-table tbody tr { border-bottom-color: var(--border); }
[data-theme="light"] .va-table tbody tr:nth-child(even) { background: #f7f8fa; }
[data-theme="light"] .va-table tbody tr:hover { background: #f0fdfc; }
[data-theme="light"] .va-table tbody td { color: #1a202c; }
[data-theme="light"] .va-response    { color: #718096; }
[data-theme="light"] .page-subtitle-badge { background: #f0f2f5; color: #718096; border-color: #dde1e7; }

/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS ADMIN PANEL
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout ────────────────────────────────────────────────────────────── */
.settings-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  max-width: 1100px;
}

/* ── Left sidenav ──────────────────────────────────────────────────────── */
.settings-sidenav {
  flex-shrink: 0;
  width: 172px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 24px;
}

.settings-sidenav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}
.settings-sidenav-item:hover { background: var(--surface-3); color: var(--text); }
.settings-sidenav-item.active { background: var(--accent-soft); color: var(--accent); }
.settings-sidenav-item svg { opacity: 0.7; flex-shrink: 0; }
.settings-sidenav-item.active svg { opacity: 1; }

/* ── Right body ────────────────────────────────────────────────────────── */
.settings-body { flex: 1; min-width: 0; }
.settings-detail-layout { max-width:none; }
.settings-detail-layout .j2 { padding:0; max-width:none; }
.settings-detail-layout .bank-page-editor,
.settings-detail-layout .store-delete-editor { max-width:none; margin:0; padding:0; }
.settings-section-panel { display: none; }

/* ── Section header ────────────────────────────────────────────────────── */
.settings-section-hd { margin-bottom: 20px; }
.settings-section-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 5px; }
.settings-section-desc  { font-size: 13px; color: var(--muted); }

/* ── Toast notifications ───────────────────────────────────────────────── */
.settings-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  border: 1px solid transparent;
  max-width: 640px;
}
.settings-toast-success {
  background: var(--green-soft);
  border-color: rgba(74,222,128,0.25);
  color: var(--green);
}
.settings-toast-error {
  background: var(--red-soft);
  border-color: rgba(248,113,113,0.25);
  color: var(--red);
}

/* ── Admin table ───────────────────────────────────────────────────────── */
.sadmin-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 4px;
}
.sadmin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.sadmin-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.sadmin-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.sadmin-table tbody tr:last-child { border-bottom: none; }
.sadmin-table tbody tr:hover { background: var(--surface-2); }
.sadmin-table tbody td { padding: 11px 14px; vertical-align: middle; }

/* ── Table helpers ─────────────────────────────────────────────────────── */
.sadmin-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
  flex-shrink: 0;
}
.sadmin-dot-xs {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.sadmin-fw     { font-weight: 600; }
.sadmin-mono   { font-family: var(--font-mono); font-size: 12px; }
.sadmin-mono-sm{ font-family: var(--font-mono); font-size: 12px; }
.sadmin-muted  { color: var(--muted); }
.sadmin-tagline{ font-size: 11.5px; color: var(--muted); margin-left: 8px; }
.sadmin-actions{ text-align: right; white-space: nowrap; }

.sadmin-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.sadmin-chip-muted { color: var(--muted); }

.sadmin-biz-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-soft);
}

/* ── Divider ───────────────────────────────────────────────────────────── */
.sadmin-divider {
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}

/* ── Form card ─────────────────────────────────────────────────────────── */
.sadmin-form-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sadmin-form-card-title {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}
.sadmin-form { padding: 20px 18px; }
.sadmin-form .form-group:last-of-type { margin-bottom: 20px; }
.sadmin-form-actions { display: flex; gap: 10px; align-items: center; }
.sadmin-opt { font-size: 11px; color: var(--muted); font-weight: 400; }

/* ── Empty state ───────────────────────────────────────────────────────── */
.sadmin-empty {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  font-style: italic;
}

/* ── Color swatches (sadmin variant) ───────────────────────────────────── */
.sadmin-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.sadmin-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
}
.sadmin-swatch:hover { transform: scale(1.15); }
.sadmin-swatch-sel {
  border-color: var(--text);
  transform: scale(1.15);
}

/* ── Tags list ─────────────────────────────────────────────────────────── */
.sadmin-tags-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
  max-width: 540px;
}
.sadmin-tag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.sadmin-tag-swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sadmin-tag-name {
  font-size: 13.5px;
  font-weight: 500;
  flex: 1;
}
.sadmin-tag-del-form { margin-left: auto; }
.sadmin-tag-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
}
.sadmin-tag-del:hover { color: var(--red); background: var(--red-soft); }

/* ── Coming soon ───────────────────────────────────────────────────────── */
.sadmin-coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 32px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 440px;
}
.sadmin-coming-soon p { font-size: 13px; line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════════════════════
   TEAM SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Next-up banner ────────────────────────────────────────────────────── */
.team-nextup-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 20px;
  max-width: 640px;
}
.team-nextup-label { color: var(--muted); font-weight: 500; }
.team-nextup-name  { font-weight: 700; color: var(--accent); }
.team-nextup-muted { color: var(--muted); font-size: 12px; }

/* ── Team table specifics ──────────────────────────────────────────────── */
.team-table { width: 100%; }
.team-row-inactive { opacity: 0.5; }
.team-order-num { color: var(--muted); font-size: 12px; font-weight: 600; width: 32px; }

.team-agent-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.team-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--accent-line);
}
.team-agent-name  { font-weight: 600; font-size: 13px; }
.team-agent-email { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }

/* ── Weight input ──────────────────────────────────────────────────────── */
.team-weight-form {
  display: flex;
  align-items: center;
  gap: 5px;
}
.team-weight-input {
  width: 52px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: center;
}
.team-weight-input:focus { outline: none; border-color: var(--accent-line); }

/* ── Active toggle button ──────────────────────────────────────────────── */
.team-toggle-btn {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s;
  white-space: nowrap;
}
.team-toggle-on {
  background: rgba(74,222,128,0.12);
  color: var(--green);
  border-color: rgba(74,222,128,0.3);
}
.team-toggle-on:hover { background: rgba(74,222,128,0.22); }
.team-toggle-off {
  background: var(--surface-3);
  color: var(--muted);
  border-color: var(--border);
}
.team-toggle-off:hover { background: var(--surface-2); color: var(--text-soft); }

/* ── Team table row styling ────────────────────────────────────────────── */
.sadmin-table.team-table tbody td {
  padding: 8px 12px;
  vertical-align: middle;
  height: 44px;  /* Fixed tight row height */
}

/* ── Reorder arrows ────────────────────────────────────────────────────── */
.team-reorder-btns {
  display: flex;
  gap: 4px;
  align-items: center;
}
.team-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  font: inherit;
  line-height: 1;
  padding: 0;
}
.team-arrow-btn:hover { background: var(--surface-3); border-color: var(--accent-line); color: var(--accent); }
/* ── Action buttons (Edit/Remove) ─────────────────────────────────────── */
.team-action-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
.team-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.team-action-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}
.team-action-btn-remove {
  border-color: #fca5a5;
  color: #dc2626;
}
.team-action-btn-remove:hover {
  background: rgba(220, 38, 38, 0.05);
  border-color: #f87171;
  color: #b91c1c;
}

/* ── Rotation preview strip ────────────────────────────────────────────── */
.team-rotation {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.team-rotation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.team-rotation-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.team-rotation-cycle {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.team-rotation-seq {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.team-rotation-chip {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.team-rotation-chip-sm { width: 20px; height: 20px; font-size: 10.5px; }
.team-rotation-arrow { color: var(--muted-2); font-size: 12px; }
.team-rotation-repeat { background: var(--surface-3); border-color: var(--border-2); color: var(--muted); }
.team-rotation-more { color: var(--muted); font-size: 16px; letter-spacing: 1px; padding: 0 2px; }
.team-rotation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.team-rotation-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.team-rotation-empty { color: var(--muted); font-size: 12.5px; }
.team-rotation-meta { display: inline-flex; align-items: center; gap: 16px; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.team-rotation-meta b { color: var(--text); font-weight: 700; }

/* Role badge */
.team-role-badge { display: inline-block; margin-top: 3px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }
.team-role-agent   { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
.team-role-limited { background: var(--surface-3); color: var(--muted); border: 1px solid var(--border-2); }

/* Reorder buttons: disabled state */
.team-arrow-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.team-arrow-btn:disabled:hover { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

/* Actions bar under the table */
.team-actions-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.team-actions-right { display: inline-flex; align-items: center; gap: 12px; }

/* Success / notice banner (above auto-assign) */
.team-banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; line-height: 1.45; transition: opacity 0.2s; }
.team-banner-success { background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text); }
.team-banner-error   { background: var(--red-soft); border: 1px solid var(--red); color: var(--text); }
.team-banner-icon { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; margin-top: 1px; }
.team-banner-success .team-banner-icon { background: var(--accent); }
.team-banner-error .team-banner-icon { background: var(--red); }
.team-banner-text { flex: 1; }
.team-banner-close { flex-shrink: 0; background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.team-banner-close:hover { color: var(--text); }

/* Password field with eye toggle */
.pw-field { position: relative; }
.pw-field .form-input { padding-right: 40px; }
.pw-eye { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); background: none; border: none; padding: 4px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; }
.pw-eye:hover { color: var(--text); }

/* ── Light theme overrides ─────────────────────────────────────────────── */
[data-theme="light"] .settings-sidenav-item        { color: #4a5568; }
[data-theme="light"] .settings-sidenav-item:hover  { background: #f0f2f5; color: #1a202c; }
[data-theme="light"] .settings-sidenav-item.active { background: rgba(45,212,191,0.1); color: #0d7a72; }
[data-theme="light"] .sadmin-table-wrap            { border-color: var(--border); }
[data-theme="light"] .sadmin-table thead th        { background: #f7f8fa; color: #718096; }
[data-theme="light"] .sadmin-table tbody tr        { border-bottom-color: var(--border); }
[data-theme="light"] .sadmin-table tbody tr:hover  { background: #f7fffe; }
[data-theme="light"] .sadmin-table tbody td        { color: #1a202c; }
[data-theme="light"] .sadmin-form-card             { background: #fff; border-color: var(--border); }
[data-theme="light"] .sadmin-form-card-title       { background: #f7f8fa; color: #4a5568; }
[data-theme="light"] .sadmin-tag-row               { background: #fff; border-color: var(--border); }
[data-theme="light"] .sadmin-chip                  { background: #f0f2f5; border-color: #dde1e7; color: #4a5568; }
[data-theme="light"] .sadmin-coming-soon           { background: #fff; }
[data-theme="light"] .team-weight-input            { background: #fff; border-color: var(--border); color: #1a202c; }
[data-theme="light"] .team-rotation                { background: #f7f8fa; border-color: var(--border); }
[data-theme="light"] .team-rotation-repeat         { background: #eef0f3; border-color: #dde1e7; color: #718096; }
[data-theme="light"] .settings-toast-success       { background: rgba(16,185,129,0.08); }
[data-theme="light"] .settings-toast-error         { background: rgba(239,68,68,0.08); }



/* ─── Demo mode toggle ──────────────────────────────────────────────── */
.settings-demo-section {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid rgba(251,191,36,0.2);
}
.demo-toggle-card {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: var(--radius);
}
.demo-toggle-label { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.demo-toggle-desc { font-size: 13px; color: var(--muted); }
[data-theme="light"] .demo-toggle-card { background: #fff; border-color: rgba(192,86,33,0.2); }
[data-theme="light"] .settings-demo-section { border-top-color: rgba(192,86,33,0.2); }

/* ─── Team weight cell ──────────────────────────────────────────────── */
.team-weight-cell {
  display: flex; align-items: center; gap: 4px;
}
.team-weight-input {
  width: 60px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  text-align: center;
}
.team-weight-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(45,212,191,0.1); }
.team-weight-pct { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ─── Data table ────────────────────────────────────────────────────────── */
.table-wrap { margin-top: 16px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.data-table thead { background: var(--bg); border-bottom: 1px solid var(--border); }
.data-table th { padding: 8px 12px; text-align: left; font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.2s; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table td { padding: 8px 12px; font-size: 13px; color: var(--text); vertical-align: middle; }
.data-table .mono { font-family: 'Geist Mono', monospace; }

.order-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.order-status-shipped { background: var(--success-soft); color: var(--success); }
.order-status-processing { background: var(--info-soft); color: var(--info); }
.order-status-delivered { background: rgba(168,85,247,0.15); color: #a855f7; }
.order-status-delayed { background: var(--warn-soft); color: var(--warn); }

[data-theme="light"] .data-table { background: #fff; }
[data-theme="light"] .data-table thead { background: #f5f7fa; }

/* ─── Template modal ────────────────────────────────────────────────────── */
.template-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.template-modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.template-modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.template-modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.template-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-modal-close:hover { color: var(--text); }

.template-modal-body {
  padding: 20px;
}

.template-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

[data-theme="light"] .template-card { background: #fff; }
[data-theme="light"] .template-modal-content { background: #fff; }

/* ─── Polish layer: depth, hover glow, micro-motion ─── */

/* Buttons — lift + soft accent glow on hover */
.btn {
  transition: background .18s ease, border-color .18s ease, color .18s ease,
              transform .12s ease, box-shadow .2s ease;
  will-change: transform;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px var(--accent-soft), 0 0 0 1px var(--accent-line);
}
.btn-ghost:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.btn-danger-ghost:hover {
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.18) !important;
}

/* Panels — subtle lift on hover (keeps cards feeling tactile) */
.panel {
  transition: border-color .2s ease, box-shadow .25s ease, transform .12s ease;
}
.panel:hover {
  border-color: var(--border-2, var(--border));
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}

/* Sidebar filter rows — slide-in indicator on hover */
.sidebar-filter-item {
  position: relative;
  transition: background .15s ease, color .15s ease, padding-left .15s ease;
}
.sidebar-filter-item:hover {
  padding-left: calc(var(--sidebar-item-pl, 12px) + 4px);
}
.sidebar-filter-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity .15s ease;
}
.sidebar-filter-item:hover::before,
.sidebar-filter-item.active::before {
  opacity: 1;
}

/* Table rows (orders, customers, etc.) — row glow on hover */
.data-row, .data-table tbody tr {
  transition: background .15s ease, box-shadow .2s ease, transform .12s ease;
}
.data-row:hover, .data-table tbody tr:hover {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Ticket / inbox list cards */
a[href*="/tickets/"]:hover,
.ticket-card:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

/* Inputs / textareas — soft accent focus ring */
.form-input:focus,
.reply-textarea:focus,
.filter-select:focus,
textarea:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft);
  transition: border-color .15s ease, box-shadow .15s ease;
}

/* Badges — soft pulse on real-time-ish updates */
.count-badge,
.badge {
  transition: transform .15s ease, box-shadow .2s ease;
}
.sidebar-filter-item:hover .count-badge,
.data-row:hover .badge {
  transform: scale(1.05);
}

/* Tag pills */
.tag-pill {
  transition: transform .12s ease, box-shadow .2s ease, filter .15s ease;
}
.tag-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* Links inside panels */
.panel-body a:not(.btn) {
  transition: color .15s ease, text-shadow .2s ease;
}
.panel-body a:not(.btn):hover {
  text-shadow: 0 0 8px var(--accent-soft);
}

/* Light theme — softer shadows so it doesn’t feel heavy */
[data-theme="light"] .btn:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
[data-theme="light"] .btn-primary:hover { box-shadow: 0 4px 14px var(--accent-soft); }
[data-theme="light"] .panel:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08); }
[data-theme="light"] .data-row:hover, [data-theme="light"] .data-table tbody tr:hover { box-shadow: inset 3px 0 0 var(--accent); }

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  .btn, .panel, .data-row, .data-table tbody tr,
  .sidebar-filter-item, .tag-pill, .badge, .count-badge,
  a[href*="/tickets/"], .ticket-card {
    transition: none !important;
  }
  .btn:hover, .panel:hover, .data-row:hover,
  a[href*="/tickets/"]:hover, .ticket-card:hover {
    transform: none !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE OPTIMIZATION
   Breakpoints: 320px base | 480px | 640px | 768px | 1024px
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Base (320px+): touch-friendly defaults ────────────────────────────── */

/* Touch targets: minimum 44px height for all interactive elements */
.btn {
  min-height: 44px;
}
.btn-sm {
  min-height: 36px;
}

/* iOS input zoom fix: 16px minimum font on all inputs prevents auto-zoom */
@media (max-width: 1024px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  input[type="tel"],
  textarea,
  select,
  .form-input,
  .filter-select,
  .reply-textarea,
  .search-input,
  .mailbox-select,
  .team-weight-input {
    font-size: 16px !important;
  }
}

/* ─── Table horizontal scroll (mobile & tablet) ─────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sadmin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.va-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure tables don't squish below 480px */
.data-table,
.sadmin-table,
.va-table {
  min-width: 480px;
}

/* ─── 480px: Small phones ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  /* Tighter page content */
  .page-content { padding: 12px; }

  /* Page header: always stack vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .page-header-meta { margin-left: 0; flex-wrap: wrap; }

  /* Full-width buttons in reply actions on very small screens */
  .reply-actions > .btn { flex: 1; min-width: 0; justify-content: center; }

  /* Page title smaller */
  .page-title { font-size: 18px; }

  /* Login card: no padding */
  .login-card { padding: 24px 16px; }
  .login-container { padding: 12px; }

  /* Stats grid: 1 column */
  .analytics-grid { grid-template-columns: 1fr; }
}

/* ─── 640px: Mobile/tablet boundary ─────────────────────────────────────── */
@media (max-width: 640px) {
  /* Forms: stack all inline groups vertically, full width */
  .form-group { margin-bottom: 14px; }
  .form-input  { font-size: 16px; }

  /* Inline flex form rows (brand contacts etc) — override inline style */
  .sadmin-form .form-group [style*="flex"] {
    width: 100% !important;
    flex: unset !important;
  }
  .sadmin-form-actions { flex-wrap: wrap; }
  .sadmin-form-actions .btn { flex: 1; min-width: 120px; }

  /* Filter bar: wrap and full-width selects */
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-select { width: 100%; min-width: unset; }
  .filter-form .btn { width: 100%; justify-content: center; }

  /* Ticket detail: full-width layout */
  .ticket-layout { grid-template-columns: minmax(0,1fr); }
  .ticket-sidebar-col { position: static; }
  .ticket-subject { font-size: 16px; }

  /* Calls / orders: card-layout for data rows */
  .data-table,
  .sadmin-table {
    min-width: 560px;
  }

  /* Search: hide on mobile if needed, or shrink */
  .search-input { width: 120px; }

  /* Topbar adjustments */
  .topbar { padding: 0 10px; gap: 8px; height: 52px; }
  .topbar-right .user-name { display: none; }
  .topbar-right .brand-pill { display: none; }

  /* Reply box */
  .reply-box { padding: 10px; }
  .reply-actions { flex-wrap: wrap; gap: 8px; }

  /* Thread messages: full width */
  .msg-body-wrap { max-width: calc(100% - 36px); }

  /* Ticket rows v1 */
  .ticket-row { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .ticket-row-right { width: 100%; justify-content: flex-start; padding-left: 0; }

  /* Ticket rows v2 — on mobile collapse right column to inline row */
  .ticket-v2-right {
    flex-direction: row;
    width: auto;
    align-items: center;
    gap: 6px;
  }
  .ticket-v2-sender { flex-wrap: wrap; gap: 4px; }

  /* Settings layout: stack sidebar above content */
  .settings-layout {
    flex-direction: column;
    gap: 16px;
  }
  .settings-sidenav {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    position: static;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
  }
  .settings-sidenav-item {
    flex: 1 1 auto;
    min-width: 120px;
    justify-content: center;
    font-size: 12px;
    padding: 8px 10px;
  }
  .settings-body { min-width: 0; }
  .settings-section { max-width: 100%; }

  /* sadmin form card: full width */
  .sadmin-form-card { width: 100%; }
  .sadmin-tags-list { max-width: 100%; }

  /* Team table: scroll */
  .sadmin-table-wrap { overflow-x: auto; }
  .team-table { min-width: 500px; }

  /* Pagination / action rows */
  .sadmin-form-actions { gap: 8px; }
}

/* ─── 768px: Tablet ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Modals: full-screen on mobile */
  .template-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  .template-modal {
    align-items: flex-end;
  }
  .template-modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Ticket layout: single column */
  .ticket-layout { grid-template-columns: minmax(0,1fr); gap: 20px; }
  .ticket-sidebar-col { position: static; }

  /* Analytics charts: single column */
  .chart-row { grid-template-columns: 1fr; }

  /* Settings sidenav: scrollable row */
  .settings-sidenav {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    position: static;
    gap: 4px;
    padding-bottom: 4px;
  }
  .settings-sidenav-item {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Table scroll */
  .table-wrap,
  .sadmin-table-wrap { overflow-x: auto; }

  /* Buttons in panels: touch friendly */
  .panel-body .btn { min-height: 44px; }

  /* Page content padding */
  .page-content { padding: 16px 18px; }
}

/* ─── 1024px: Desktop threshold ─────────────────────────────────────────── */
@media (min-width: 1024px) {
  /* Reset iOS font-size override — let desktop use its native 13px */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  input[type="tel"],
  textarea,
  select,
  .form-input,
  .filter-select,
  .reply-textarea,
  .search-input,
  .mailbox-select,
  .team-weight-input {
    font-size: inherit !important;
  }
}

/* ─── Grid system: mobile-first ─────────────────────────────────────────── */
/* 1 column on <640px, 2 on 640-1024px, 3+ on 1024px+ */
.analytics-grid {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 1024px) {
  .analytics-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 480px) {
  .analytics-grid { grid-template-columns: 1fr; }
}

/* ─── Topbar search: hide on very small screens ─────────────────────────── */
@media (max-width: 400px) {
  .search-form { display: none; }
  .topbar { padding: 0 8px; gap: 6px; }
}

/* ─── Safe area insets (notch/home bar) ─────────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-shell {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .page-content {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* ─── Light theme overrides for new mobile elements ─────────────────────── */
[data-theme="light"] .settings-sidenav {
  background: #f7f8fa;
  border-color: var(--border);
}


/* ─── QOL batch 1: one-click resolution actions (additive) ──────────────── */
.qol-action-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.qol-action-label { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.qol-action-btn { font-size: 12px; padding: 5px 10px; gap: 5px; }
.qol-action-btn .qol-check { display: none; flex-shrink: 0; }
.qol-action-btn.qol-done {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.qol-action-btn.qol-done .qol-check { display: inline; }
.qol-action-btn:disabled { opacity: 0.6; cursor: default; }
/* Light theme: outrank [data-theme="light"] .btn-ghost, and use --accent-dark —
   light --accent (#0593b0) is 3.62:1 on white, below AA; --accent-dark is 4.96:1. */
[data-theme="light"] .qol-action-btn.qol-done {
  color: var(--accent-dark);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.qol-reason-select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}
.qol-reason-select:focus { outline: none; border-color: var(--accent); }

.toast.qol-undo-toast { display: flex; align-items: center; gap: 12px; }
.qol-undo-btn {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.qol-undo-btn:hover { background: var(--surface-2); border-color: var(--accent); }
.qol-undo-btn:disabled { opacity: 0.6; cursor: default; }

/* ─── Inbox sort toggle (QOL inbox-upgrade-v2, additive) ────────────────── */
.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.sort-toggle .sort-opt {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  transition: color .18s ease, background .18s ease;
}
.sort-toggle .sort-opt:hover:not(.active) { color: var(--text); background: var(--surface-3); }
.sort-toggle .sort-opt.active { color: var(--accent); background: var(--accent-soft); }

.sortbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sortbar-row .sort-toggle { margin-left: 0; }
.mini-pager { display: flex; align-items: center; gap: 5px; }
.mini-pager .mp-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: var(--radius-sm); color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.mini-pager a.mp-btn:hover { color: var(--text); border-color: var(--border-2); }
.mini-pager .mp-btn.disabled { opacity: .35; }
.mini-pager .mp-info { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 26px; text-align: center; }


/* ─── Icon system (inbox-upgrade-v2) — sprite refs via <svg class="ic"><use> ──
   One cohesive set: 1.5px stroke, currentColor. Contextual sizes preserve the
   original per-surface footprints; crisp at 14–16px. */
.ic { width: 15px; height: 15px; display: inline-block; vertical-align: -0.14em; flex-shrink: 0; }
.sidebar-filter-item .ic { width: 14px; height: 14px; }
.nav-item .ic { width: 16px; height: 16px; }
.btn .ic, .page-header-meta .ic { width: 14px; height: 14px; vertical-align: -0.12em; margin-right: 1px; }
.settings-nav-item .ic, .settings-sidenav a .ic, .settings-nav a .ic { width: 15px; height: 15px; }

/* ─── James identity avatar (James-sent replies only) ─────────────────────
   Additive: styles ONLY the new .avatar-james box (rendered when a message is
   provably James-sent — lib/jamesAvatar.js). Generic .avatar-agent /
   .avatar-customer rules above are untouched. Same 32px .msg-avatar box →
   zero layout shift; the crown is absolutely positioned so it adds no size. */
.avatar-james { position: relative; overflow: visible; }
.avatar-james .james-mark { display: block; }
.avatar-james .james-crown {
  position: absolute;
  top: -7px;              /* sits on the top edge, ~3px overlap onto the circle */
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;   /* pure decoration — never intercepts clicks */
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); /* subtle lift, both themes */
}

/* ─── WS8: slim custom scrollbars (app-wide, palette-matched) ─────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); border: 2px solid transparent; background-clip: content-box; }

/* Shared responsive shell: fit the actual panel width, including narrow app panes. */
.app-shell { height:100dvh; }
.main-area,.page-content,.settings-layout { min-width:0; min-height:0; }
.topbar .search-form { display:block; flex:1; min-width:0; max-width:400px; }
.topbar .search-wrap,.topbar .search-input { width:100%; min-width:0; }
.topbar-right { gap:8px; }
.topbar .theme-toggle,.topbar .hamburger-btn,.topbar .user-btn { min-width:40px; min-height:40px; }
.page-header,.page-header-meta { flex-wrap:wrap; }
.page-title { overflow-wrap:anywhere; }
.customers-search-bar { flex-wrap:wrap; }
.customers-search-bar input[type="search"] { min-width:0; flex-basis:180px; }
.customers-search-bar button { min-height:40px; }
@media(max-width:900px) {
  .app-shell > .sidebar { position:fixed; inset:0 auto 0 0; height:100dvh; max-width:calc(100vw - 32px); z-index:200; transform:translateX(-100%); transition:transform 250ms ease; }
  .app-shell > .sidebar.open { transform:translateX(0); }
  .topbar .hamburger-btn { display:inline-flex; }
  .app-shell > .main-area { width:100%; }
  .settings-layout { flex-direction:column; gap:20px; }
  .settings-sidenav { position:static; width:100%; max-width:100%; flex-direction:row; flex-wrap:nowrap; overflow-x:auto; }
  .settings-sidenav-item { flex:0 0 auto; white-space:nowrap; }
  .settings-body { width:100%; }
}
@media(max-width:480px) {
  .page-content { padding:16px 12px; }
  .topbar { gap:6px; padding:0 8px; }
  .topbar .user-btn { padding:4px; gap:4px; }
  .topbar-right { gap:4px; }
  .topbar .search-input { padding-left:28px; padding-right:6px; }
  .topbar .search-icon { left:8px; }
}
@media(prefers-reduced-motion:reduce) { .app-shell > .sidebar { transition:none; } }

/* Shared CRM visual system. Org colours identify brands, not the app chrome.
   html:root wins over older per-page :root brand accent declarations. */
html:root {
  --bg:#08080d; --surface:#11111d; --surface-2:#191927; --surface-3:#242437;
  --border:#303043; --border-2:#53536c;
  --raised-surface:#1b1b2d; --raised-edge:#3d3d55;
  --raised-shadow:inset 0 1px 0 rgba(255,255,255,.07),0 2px 4px rgba(0,0,0,.24),0 12px 26px rgba(0,0,0,.17);
  --text:#eeeef5; --text-soft:#c8c8d6; --muted:#a2a2b5; --muted-2:#a2a2b5;
  --accent:#ae91ff; --accent-dark:#7559db; --accent-soft:#211a36; --accent-line:#40305f;
  --accent-text:#08080d; --button-bg:#7154cf; --button-hover:#6143bd; --button-text:#fff;
  --sidebar-bg:#0e0e17; --sidebar-w:244px; --topbar-h:52px;
  --font-sans:"Geist",Arial,"Helvetica Neue",sans-serif;
}
html:root[data-theme="light"] {
  --bg:#f8f8fc; --surface:#ffffff; --surface-2:#f0eef8; --surface-3:#e7e3f2;
  --border:#dedbe9; --border-2:#a19aae;
  --raised-surface:#fff; --raised-edge:#c9c3d9;
  --raised-shadow:inset 0 1px 0 rgba(255,255,255,.95),0 2px 4px rgba(36,33,51,.05),0 10px 24px rgba(36,33,51,.06);
  --text:#242133; --text-soft:#443d57; --muted:#60596f; --muted-2:#60596f;
  --accent:#6441ba; --accent-dark:#5732a8; --accent-soft:#eee8fa; --accent-line:#d3c4ef;
  --accent-text:#fff; --button-bg:#6441ba; --button-hover:#5732a8; --sidebar-bg:#fff;
}
body { font-family:var(--font-sans); }
.app-shell .topbar { background:var(--bg); border-color:var(--border); box-shadow:none; min-height:52px; }
.app-shell .page-content { padding:28px 32px 40px; }
.app-shell .page-title { font-size:24px; font-weight:700; letter-spacing:-.5px; line-height:1.3; }
.app-shell .page-subtitle { font-size:13px; color:var(--muted); }
.app-shell .page-header { gap:12px; margin-bottom:24px; }
.app-shell .btn { border-radius:8px; min-height:40px; font-size:13px; font-weight:600; transition:background-color 180ms,border-color 180ms,color 180ms; }
.btn.btn-primary { background:var(--button-bg); color:var(--button-text); border-color:var(--button-bg); }
.btn.btn-primary:hover { background:var(--button-hover); border-color:var(--button-hover); }
.app-shell .user-avatar { background:var(--button-bg); color:var(--button-text); }
.app-shell .search-input { background:var(--surface-2); color:var(--text); border-color:var(--border); border-radius:8px; }
.app-shell :is(input,textarea,select):focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.app-shell :is(a,button,summary):focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
.app-shell .crm-sidebar { background:var(--sidebar-bg); border-color:var(--border); padding:0; width:var(--sidebar-w); }
.crm-sidebar-art { height:96px; flex-shrink:0; overflow:hidden; }
.crm-sidebar-art svg { width:100%; height:100%; display:block; }
.crm-logo { display:flex; align-items:center; gap:9px; height:100%; padding:8px 18px; color:var(--text); text-decoration:none; }
.crm-logo .crm-logo-mark { width:34px; height:34px; flex:0 0 34px; color:var(--accent); }
.crm-logo-check { color:var(--text); }
.crm-logo-type { display:flex; flex-direction:column; gap:3px; }
.crm-logo-name { font-size:17px; font-weight:750; line-height:1; letter-spacing:-.6px; }
.crm-logo-hub { font-size:8px; font-weight:700; line-height:1; letter-spacing:3.5px; color:var(--muted); }
.crm-logo:hover .crm-logo-name { color:var(--accent); }
.crm-logo-name { transition:color 180ms ease; }

.connection-setup-guide { margin:0 0 24px; border:1px solid var(--border); border-radius:12px; background:var(--surface); }
.connection-setup-guide summary { padding:16px 18px; min-height:48px; cursor:pointer; font-size:14px; font-weight:600; color:var(--text); }
.connection-setup-guide summary:focus-visible { outline:2px solid var(--accent); outline-offset:3px; border-radius:12px; }
.connection-setup-guide-body { padding:0 18px 16px; border-top:1px solid var(--border); font-size:13px; line-height:1.7; color:var(--text-soft); }
.connection-setup-guide ol { padding-left:20px; margin:16px 0; }
.connection-setup-guide li { padding-left:4px; margin-bottom:14px; }
.connection-setup-guide li::marker { color:var(--accent); font-weight:600; }
.connection-setup-guide strong { color:var(--text); }
.connection-setup-guide a { color:var(--accent); text-underline-offset:3px; }
.connection-guide-note { padding:12px; background:var(--bg); border-radius:8px; font-size:12px; }
.connection-guide-links { display:flex; flex-wrap:wrap; gap:4px 16px; margin-top:12px; }
.connection-guide-links a { display:inline-flex; align-items:center; min-height:40px; font-size:12px; }
.connection-guide-links a.btn { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
.connection-guide-copy { display:flex; gap:8px; align-items:center; margin-top:6px; }
.connection-guide-copy input { min-width:0; flex:1; font-size:12px; }
.connection-guide-copy button { flex-shrink:0; }
.zoho-address-picker { margin:24px 0; padding:18px; border:1px solid var(--border); border-radius:12px; background:var(--surface); }
.zoho-picker-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.zoho-picker-heading h3 { margin:0; font-size:14px; }
.zoho-picker-heading span { color:var(--accent); font-size:12px; white-space:nowrap; font-variant-numeric:tabular-nums; }
.zoho-address-picker p { font-size:12px; color:var(--muted); line-height:1.6; }
.zoho-picker-options { max-height:330px; overflow:auto; margin:12px 0; }
.zoho-picker-option { display:flex; align-items:center; gap:12px; padding:12px 8px; border-bottom:1px solid var(--border); cursor:pointer; }
.zoho-picker-option[hidden] { display:none; }
.zoho-picker-option:has(input:checked) { background:var(--surface-2); border-radius:6px; }
.zoho-picker-option input { width:16px; height:16px; flex-shrink:0; accent-color:var(--accent); }
.zoho-picker-option strong,.zoho-picker-option small { display:block; overflow-wrap:anywhere; }
.zoho-picker-option strong { font-size:12px; font-weight:500; }
.zoho-picker-option small { margin-top:3px; color:var(--muted); font-size:11px; }
.zoho-picker-footer { display:flex; flex-wrap:wrap; align-items:center; gap:10px; }
.zoho-picker-footer [role="status"] { flex:1 1 160px; color:var(--muted); font-size:12px; }
.zoho-picker-footer [data-address-retry][hidden] { display:none; }
.crm-sidebar .sidebar-brand { padding:14px 12px 4px; border:0; }
.crm-sidebar .brand-switcher-btn { min-height:40px; gap:10px; background:var(--surface); border:1px solid var(--border); color:var(--text); font-size:13px; border-radius:8px; }
.crm-sidebar .brand-switcher-btn .brand-name { color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; }
.crm-sidebar .sidebar-org-name { padding:10px 4px; color:var(--text); font-size:13px; font-weight:600; overflow-wrap:anywhere; }
.crm-sidebar .sidebar-nav { flex:0 0 auto; gap:3px; padding:8px 12px 14px; }
.crm-sidebar .sidebar-section-label { color:var(--muted); font-size:10px; font-weight:600; letter-spacing:.8px; padding:12px 12px 8px; }
.crm-sidebar .nav-item { min-height:40px; padding:10px 12px; font-size:13px; gap:12px; border-radius:8px; color:var(--muted); }
.crm-sidebar .nav-item svg { color:inherit; }
.crm-sidebar .nav-item:hover { background:var(--surface); color:var(--text); }
.crm-sidebar .nav-item.active { background:var(--accent-soft); color:var(--text); font-weight:600; }
.crm-sidebar .nav-item.active svg { color:var(--accent); }
.crm-sidebar .sidebar-footer { margin-top:auto; padding:12px; border-top:1px solid var(--border); flex-shrink:0; }
.crm-sidebar .sidebar-footer-link { min-height:40px; display:flex; align-items:center; padding:10px 12px; color:var(--muted); font-size:12px; }
.crm-sidebar .sidebar-footer-link:hover { color:var(--text); }
.crm-inbox-tools { border-top:1px solid var(--border); margin:0 12px 16px; }
.crm-inbox-tools>summary { min-height:40px; padding:12px; display:flex; justify-content:space-between; align-items:center; cursor:pointer; color:var(--text-soft); font-size:12px; list-style:none; }
.crm-inbox-tools>summary::-webkit-details-marker { display:none; }
.crm-inbox-tools[open]>summary .ic { transform:rotate(180deg); }
.crm-inbox-tools .sidebar-section { padding-left:0; padding-right:0; }
.crm-inbox-tools .sidebar-divider { margin:8px 0; background:var(--border); }
.crm-sidebar :is(.mailbox-item,.sidebar-filter-item) { min-height:40px; border-radius:8px; color:var(--muted); }
.crm-sidebar :is(.mailbox-item,.sidebar-filter-item):hover { background:var(--surface); color:var(--text); }
.crm-sidebar :is(.mailbox-item,.sidebar-filter-item).active { background:var(--accent-soft); color:var(--accent); }
.crm-sidebar .mailbox-item.active svg { color:var(--accent); }
.crm-sidebar .sidebar-filter-item.active::before { background:var(--accent); }
.app-shell .settings-sidenav-item { min-height:40px; border-radius:8px; }
.app-shell .settings-sidenav-item.active { background:var(--accent-soft); color:var(--accent); }
.app-shell .filter-tabs { flex-wrap:wrap; }
.app-shell .tpl-card { min-width:0; }
.app-shell .tpl-list { grid-template-columns:minmax(0,1fr); }
.app-shell .tpl-card__head { flex-wrap:wrap; }
.app-shell .tpl-card__head>div { min-width:0; }
.app-shell .tpl-card__subject { overflow-wrap:anywhere; }
.app-shell .tpl-card__actions { flex-wrap:wrap; }
.app-shell .filter-tab { min-height:40px; display:inline-flex; align-items:center; }
.app-shell .filter-tab.active { background:var(--button-bg); color:var(--button-text); border-color:var(--button-bg); }
.app-shell .chart-row { grid-template-columns:repeat(2,minmax(0,1fr)); }
.app-shell :is(.chart-card,.chart-wrap,.stat-card) { min-width:0; }
.app-shell .chart-card-header { flex-wrap:wrap; gap:8px; }
.app-shell .chart-wrap canvas { max-width:100%; }
.app-shell .analytics-grid { grid-template-columns:repeat(5,minmax(0,1fr)); }
@media(max-width:1200px) { .app-shell .analytics-grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media(max-width:980px) { .app-shell .chart-row { grid-template-columns:minmax(0,1fr); } }
@media(max-width:600px) { .app-shell .analytics-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:380px) { .app-shell .analytics-grid { grid-template-columns:minmax(0,1fr); } }
.app-shell :is(.ticket-row:hover,.ticket-row.unread) { background:var(--surface-2); border-color:var(--border-2); }
.app-shell :is(.thread-message.msg-agent .msg-body,.brand-pill) { background:var(--accent-soft); color:var(--text); border-color:var(--accent-line); }
.app-shell :is(.count-badge,.count-pill,.stat-value) { font-variant-numeric:tabular-nums; }
@media(max-width:900px) { .app-shell .page-content { padding:24px; } }
@media(max-width:480px) {
  .app-shell .page-content { padding:20px 12px; }
  .app-shell .page-title { font-size:22px; }
  .crm-sidebar-art { height:72px; }
}
/* The reply simulator keeps its fitted chat workspace within the same shell. */
.app-shell .page-content.j2.is-chat-view { padding:20px 28px 16px; }
@media(max-width:600px) { .app-shell .page-content.j2.is-chat-view { padding:14px 12px 10px; } }

/* The split inbox keeps its list/reading pane inside the same CRM shell. */
body.inbox-shell { font-family:var(--font-sans); }
.inbox-shell .app { flex:1; min-height:0; height:auto; display:grid; grid-template-columns:minmax(280px,var(--sv-list-w,380px)) minmax(0,1fr); }
.inbox-shell .inbox-actions { position:static; flex-shrink:0; min-height:40px; height:auto; padding:0; background:transparent; border:0; flex-wrap:nowrap; backdrop-filter:none; }
.inbox-shell .inbox-actions :is(.refresh,.compose) { min-height:40px; font-size:12px; border-radius:8px; box-shadow:none; transition:background-color 180ms,color 180ms; }
.inbox-shell .inbox-actions { justify-content:flex-end; }
.inbox-shell .inbox-actions .ihx-chip { min-height:40px; }
.inbox-shell .inbox-actions .refresh { margin-left:0; background:var(--button-bg); color:var(--button-text); }
.inbox-shell .inbox-actions .compose { background:var(--accent-soft); color:var(--accent); }
.inbox-shell .storedd summary { min-height:40px; border-radius:8px; }
.inbox-shell .storedd-pop { min-width:0; width:240px; max-width:calc(100vw - 40px); }
.inbox-shell .inbox-scope { flex-shrink:0; padding:12px 12px 0; }
.inbox-shell .inbox-scope summary { padding:8px 12px; font-size:12px; background:var(--surface); }
.inbox-shell .inbox-scope-label { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.inbox-shell .inbox-scope summary :is(.dot,.ic) { flex-shrink:0; }
.inbox-shell .inbox-scope .storedd-pop { width:100%; max-height:320px; overflow-y:auto; }
.inbox-shell .inbox-scope .storedd-pop a { min-height:40px; overflow-wrap:anywhere; }
.inbox-shell .inbox-scope + .inbox-search-form { margin-top:8px; }
.inbox-shell :is(.listcol,.pane) { min-width:0; background:var(--bg); }
.inbox-shell .listcol > .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
.inbox-shell .row { background:var(--surface); border-color:var(--border); }
.inbox-shell .row:hover,.inbox-shell .row.picked { background:var(--surface-2); }
.inbox-shell .filterstrip select { max-width:100%; min-height:36px; }
html[data-theme="light"] .inbox-shell { --urgent:var(--danger); --done:var(--success); --await:var(--warn); --amber:#955000; }
html[data-theme="light"] .inbox-shell .tcard-v.ok { color:var(--success); }
html[data-theme="light"] .inbox-shell .tcard-v.amber { color:#955000; }
@media(max-width:1100px) { .inbox-shell .app { grid-template-columns:minmax(0,1fr); } .inbox-shell .pane { display:none; } }
.topbar-mail-tools { position:relative; }
.topbar-actions-toggle { display:none; width:40px; height:40px; align-items:center; justify-content:center; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text-soft); cursor:pointer; }
@media(max-width:1200px) { .inbox-shell .topbar .inbox-actions .lbl { display:none; } .inbox-shell .topbar .inbox-actions :is(.refresh,.compose) { width:40px; justify-content:center; padding:0; } }
@media(max-width:700px) {
  .topbar-actions-toggle { display:inline-flex; }
  .inbox-shell .topbar .inbox-actions { display:none; position:fixed; right:8px; top:60px; width:180px; max-width:calc(100vw - 16px); padding:8px; border:1px solid var(--border); border-radius:12px; background:var(--surface); box-shadow:0 12px 32px rgba(0,0,0,.25); }
  .inbox-shell .topbar .inbox-actions.is-open { display:flex; flex-direction:column; align-items:stretch; }
  .inbox-shell .topbar .inbox-actions .lbl { display:inline; }
  .inbox-shell .topbar .inbox-actions :is(.refresh,.compose) { width:100%; padding:8px 12px; justify-content:flex-start; }
}

/* Inbox navigation puts daily work first; workspace tools stay below it. */
.app-shell .crm-sidebar--inbox { overflow:hidden; }
.crm-sidebar--inbox .crm-sidebar-art { height:52px; border-bottom:1px solid var(--border); }
.crm-sidebar--inbox .sidebar-brand { height:61px; padding:10px 12px; flex-shrink:0; border-bottom:1px solid var(--border); }
.crm-sidebar--inbox .sidebar-brand :is(.brand-switcher-btn,.sidebar-org-name) { height:40px; padding:8px 12px; display:flex; align-items:center; }
.crm-sidebar--inbox .crm-inbox-tools { flex:1 1 auto; min-height:100px; overflow-y:auto; border:0; margin:0; padding:0 12px 12px; }
.crm-inbox-title { display:flex; align-items:center; gap:10px; height:56px; margin:0 -12px; padding:8px 24px; border-bottom:1px solid var(--border); color:var(--text); text-decoration:none; font-size:14px; font-weight:650; }
.crm-primary-filters { display:flex; flex-direction:column; gap:3px; padding-top:8px; }
.app-shell .crm-sidebar--inbox .sidebar-filter-item .count-badge { background:var(--surface-2); color:var(--text); border-color:var(--border); }
.crm-secondary-filters { margin-top:8px; }
.crm-secondary-filters>summary { min-height:40px; padding:10px 12px; display:flex; align-items:center; justify-content:space-between; cursor:pointer; list-style:none; color:var(--muted); font-size:12px; }
.crm-secondary-filters>summary::-webkit-details-marker { display:none; }
.crm-secondary-filters[open]>summary .ic { transform:rotate(180deg); }
.crm-clear-filters { display:flex; align-items:center; min-height:40px; padding:10px 12px; color:var(--muted); font-size:12px; }
.crm-sidebar--inbox .crm-workspace-nav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; flex:0 0 auto; border-top:1px solid var(--border); padding:10px 12px; }
.crm-sidebar--inbox .crm-workspace-nav .sidebar-section-label { grid-column:1/-1; padding:2px 8px 4px; }
.crm-sidebar--inbox .crm-workspace-nav .nav-item { padding:8px; gap:7px; font-size:12px; min-width:0; }
.crm-sidebar--inbox .crm-workspace-nav .nav-item .ic { width:14px; height:14px; flex-shrink:0; }
.crm-sidebar--inbox .sidebar-footer { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); margin-top:0; padding:8px 12px; }
.crm-sidebar--inbox .sidebar-footer .nav-item { padding:8px; gap:7px; font-size:12px; }
.crm-sidebar--inbox .sidebar-footer-link { grid-column:1/-1; padding:8px; }
.inbox-search-form { display:flex; gap:0; margin:12px 12px 8px; padding:0; border:1px solid var(--border); border-radius:10px; background:var(--surface); }
.inbox-search-form .sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.inbox-search-form input[type="search"] { flex:1; min-width:0; min-height:40px; padding:8px 12px; border:0; border-radius:10px 0 0 10px; color:var(--text); background:transparent; font:inherit; font-size:12px; }
.inbox-search-form:focus-within { outline:2px solid var(--accent); outline-offset:2px; }
.inbox-search-form input[type="search"]:focus-visible { outline:none; }
.inbox-search-form button { flex:0 0 40px; width:40px; min-height:40px; display:grid; place-items:center; border:0; border-radius:0 10px 10px 0; color:var(--text-soft); background:transparent; cursor:pointer; transition:background-color 180ms,color 180ms; }
.inbox-search-form button:hover { background:var(--surface-2); }
.inbox-shell .sortbar { padding:0 12px 12px; }
.inbox-shell .sort-toggle { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); width:100%; margin:0; padding:3px; gap:3px; border-radius:11px; background:var(--surface); }
.inbox-shell .sort-toggle .sort-opt { min-height:40px; display:flex; align-items:center; justify-content:center; padding:6px 8px; border-radius:7px; font-size:12px; }
.inbox-shell .sort-toggle .sort-opt.active { box-shadow:inset 0 0 0 1px var(--accent-line); }
.inbox-shell .sort-toggle .sort-opt:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }

/* Quiet elevation for the shared sidebar, without changing its layout. */
.app-shell .crm-sidebar {
  --sidebar-raised-shadow:0 2px 5px rgba(0,0,0,.24),0 8px 18px rgba(0,0,0,.12);
  --sidebar-top-light:rgba(255,255,255,.045);
  box-shadow:4px 0 16px rgba(0,0,0,.12);
}
html[data-theme="light"] .app-shell .crm-sidebar {
  --sidebar-raised-shadow:0 2px 5px rgba(36,33,51,.06),0 8px 18px rgba(36,33,51,.04);
  --sidebar-top-light:rgba(255,255,255,.75);
  box-shadow:4px 0 16px rgba(36,33,51,.035);
}
.crm-sidebar .brand-switcher-btn {
  box-shadow:inset 0 1px 0 var(--sidebar-top-light),var(--sidebar-raised-shadow);
  transition:background-color 180ms,border-color 180ms,box-shadow 180ms;
}
.crm-sidebar :is(.nav-item,.mailbox-item,.sidebar-filter-item,.crm-secondary-filters>summary,.sidebar-footer-link) {
  transition:background-color 180ms,color 180ms,box-shadow 180ms;
}
.crm-sidebar :is(.nav-item,.mailbox-item,.sidebar-filter-item,.crm-secondary-filters>summary,.sidebar-footer-link):hover {
  background:var(--surface-2); color:var(--text); border-radius:8px;
}
.crm-sidebar :is(.nav-item,.mailbox-item,.sidebar-filter-item).active {
  background:var(--accent-soft);
  box-shadow:inset 0 0 0 1px var(--accent-line),inset 0 1px 0 var(--sidebar-top-light),0 3px 8px rgba(0,0,0,.12);
}
.crm-sidebar--inbox .crm-workspace-nav,.crm-sidebar .sidebar-footer {
  background:var(--surface);
  box-shadow:inset 0 1px 0 var(--sidebar-top-light);
}
.crm-sidebar .sidebar-footer-link { color:var(--muted); }
.settings-hub { max-width:1060px; }
.settings-hub-intro { color:var(--muted); font-size:13px; margin:6px 0 24px; }
.settings-hub-group { font-size:14px; font-weight:650; margin:28px 0 12px; color:var(--text); }
.settings-card-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px; }
.settings-hub-card { display:flex; flex-direction:column; align-items:flex-start; gap:12px; min-width:0; min-height:200px; padding:20px; border:1px solid var(--border); border-radius:14px; background:var(--surface); color:var(--text); text-decoration:none; box-shadow:inset 0 1px 0 rgba(255,255,255,.035),0 4px 14px rgba(0,0,0,.08); transition:background-color 180ms,border-color 180ms,box-shadow 180ms; }
.settings-hub-card:hover { background:var(--surface-2); border-color:var(--accent-line); box-shadow:0 4px 18px rgba(0,0,0,.12); }
.app-shell :is(.settings-hub-card,.j2-card,.cc-panel,.sadmin-form-card) {
  background:var(--raised-surface); border-color:var(--raised-edge); box-shadow:var(--raised-shadow);
}
.app-shell .settings-hub-card:hover { background:var(--surface-3); border-color:var(--accent); box-shadow:var(--raised-shadow); }
.app-shell :is(.crm-sidebar .nav-item,.crm-sidebar .sidebar-filter-item,.settings-sidenav-item).active {
  box-shadow:inset 0 0 0 1px var(--accent),inset 0 1px 0 rgba(255,255,255,.1),0 3px 9px rgba(0,0,0,.16);
}
.app-shell .crm-sidebar .brand-switcher-btn { background:var(--raised-surface); border-color:var(--raised-edge); box-shadow:var(--raised-shadow); }
.app-shell .settings-card-icon { background:var(--surface-3); box-shadow:inset 0 1px 0 rgba(255,255,255,.09),0 3px 8px rgba(0,0,0,.18); }
.app-shell .settings-card-status { background:var(--bg); box-shadow:inset 0 0 0 1px var(--border); }
.settings-card-top,.settings-card-bottom { display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; flex-wrap:wrap; }
.settings-card-icon { display:grid; place-items:center; width:40px; height:40px; border-radius:10px; background:var(--accent-soft); color:var(--accent); box-shadow:inset 0 0 0 1px var(--accent-line); }
.settings-card-icon .ic { width:20px; height:20px; }
.settings-hub-card h3 { font-size:15px; line-height:1.3; margin:0; }
.settings-hub-card p { font-size:13px; line-height:1.55; color:var(--muted); margin:0 0 6px; }
.settings-card-status { font-size:11px; padding:4px 8px; background:var(--surface-2); border-radius:999px; color:var(--text-soft); }
.settings-card-manage { display:inline-flex; align-items:center; gap:12px; font-size:12px; font-weight:600; color:var(--text-soft); margin-top:auto; }
.settings-card-bottom { margin-top:auto; }
.settings-card-bottom small { color:var(--muted); font-size:11px; }
.connections-hub .settings-hub-intro { margin-bottom:22px; }
.connection-group-heading { margin:28px 0 12px; }
.connection-group-heading h3 { font-size:14px; font-weight:650; margin:0 0 5px; }
.connection-group-heading p { font-size:12px; color:var(--muted); line-height:1.5; }
.connection-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px; }
.app-shell .connection-card { min-height:174px; padding:16px; border-radius:12px; gap:14px; }
.connection-card-head,.connection-card-footer { display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; }
.connection-card-copy h3 { font-size:14px; margin-bottom:6px; }
.connection-card-copy p { font-size:12px; margin:0; line-height:1.5; }
.connection-card-footer { margin-top:auto; flex-wrap:wrap; }
.connection-icon { --provider-color:#6748bd; display:grid; place-items:center; width:36px; height:36px; flex:0 0 36px; border-radius:10px; background:var(--provider-color); color:#fff; box-shadow:inset 0 1px 0 rgba(255,255,255,.24),0 3px 9px rgba(0,0,0,.22); }
.connection-icon svg { width:23px; height:23px; }
.connection-icon--shopify { --provider-color:#527d20; }
.connection-icon--champ { --provider-color:#b74612; }
.connection-icon--phoenix { --provider-color:#146b75; }
.connection-icon--zoho { --provider-color:#245ed1; }
.connection-icon--claude { --provider-color:#a64e35; }
.connection-status { font-size:10px; font-weight:550; border-radius:999px; padding:3px 7px; color:var(--muted); background:var(--surface-3); line-height:1.4; max-width:150px; text-align:right; }
.connection-card[data-state="connected"] { border-color:color-mix(in srgb,var(--green) 45%,var(--raised-edge)); }
.connection-card[data-state="connected"] .connection-status { color:var(--green); background:var(--green-soft); }
.connection-card[data-state="error"] .connection-status { color:var(--amber); background:var(--amber-soft); }
html[data-theme="light"] .connection-card[data-state="error"] .connection-status { color:#8a3b12; background:#fff0e8; }
.connection-scope { display:inline-flex; align-items:center; gap:5px; border:1px solid var(--accent-line); background:var(--accent-soft); color:var(--text-soft); font-size:10px; border-radius:999px; padding:4px 7px; }
.connection-scope .ic { width:12px; height:12px; }
.connection-action { display:inline-flex; align-items:center; justify-content:center; gap:9px; font-size:11px; font-weight:600; color:var(--text); border:1px solid var(--raised-edge); background:var(--surface-3); border-radius:7px; padding:6px 9px; box-shadow:inset 0 1px 0 rgba(255,255,255,.04); }
.app-shell .connection-store { flex-direction:row; align-items:center; min-height:100px; gap:22px; padding:20px; border-radius:13px; }
.connection-store-icons { display:flex; align-items:center; flex-shrink:0; }
.connection-app-icon { width:36px; height:36px; border-radius:10px; background:var(--bg); color:var(--accent); display:grid; place-items:center; box-shadow:inset 0 0 0 1px var(--border); }
.connection-app-icon .ic { width:21px; height:21px; }
.connection-wire { width:35px; border-top:1px dashed var(--border-2); margin:0 7px; }
.connection-store-copy { flex:1; min-width:0; }
.connection-eyebrow { display:block; font-size:9px; font-weight:600; letter-spacing:1px; text-transform:uppercase; color:var(--muted); margin-bottom:5px; }
.connection-store-copy h3 { font-size:14px; margin:0 0 4px; }
.connection-store-copy p { font-size:12px; margin:0; }
.connection-store[data-state="connected"] { border-color:var(--green); }
.connection-store[data-state="connected"] .connection-store-copy p { color:var(--green); }
.connection-store .connection-action { padding:8px 12px; }
@media(max-width:600px) {
  .connection-grid { grid-template-columns:minmax(0,1fr); }
  .app-shell .connection-store { flex-wrap:wrap; gap:14px; padding:16px; }
  .connection-store-icons .connection-app-icon,.connection-store-icons .connection-wire { display:none; }
  .connection-store-copy { flex-basis:calc(100% - 50px); }
  .connection-store>.connection-action { margin-left:50px; }
}
.settings-hub-back { display:inline-flex; min-height:40px; align-items:center; color:var(--muted); font-size:12px; margin-bottom:12px; text-decoration:none; }
.settings-hub-back:hover { color:var(--accent); }
@media(max-width:520px) { .settings-card-grid { grid-template-columns:minmax(0,1fr); } .settings-hub-card { min-height:180px; padding:18px; } }
@media(prefers-reduced-motion:reduce) { .settings-hub-card { transition:none; } }
.inbox-shell .listcol { position:relative; }
.inbox-shell .listcol[aria-busy="true"]::after { content:""; position:absolute; top:0; left:0; right:0; height:2px; background:var(--accent); z-index:5; }
.inbox-shell .inbox-list-updated .row { animation:none; }
.inbox-nav-error { padding:12px; color:var(--text); background:var(--surface-2); font-size:12px; }
@media(max-width:900px) {
  .settings-layout .settings-sidenav { flex-wrap:wrap; overflow:visible; }
}
@media(max-width:600px) {
  .settings-layout .settings-sidenav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .settings-layout .settings-sidenav-item { white-space:normal; min-width:0; }
  .settings-detail-layout .bank-page-editor .header,
  .settings-detail-layout .bank-page-editor .form-actions { flex-wrap:wrap; }
}
@media(prefers-reduced-motion:reduce) {
  .crm-sidebar :is(.brand-switcher-btn,.nav-item,.mailbox-item,.sidebar-filter-item,.crm-secondary-filters>summary,.sidebar-footer-link) { transition:none; }
}
.ticket-champ-actions { padding:16px; }
.ticket-champ-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:14px; }
.ticket-champ-heading h3 { margin:0; font-size:13px; font-weight:600; letter-spacing:0; color:var(--text); }
.ticket-champ-heading>span { font-size:10px; color:var(--muted); }
.ticket-champ-buttons { display:grid; gap:8px; }
.ticket-champ-button { display:flex; align-items:center; gap:10px; width:100%; min-height:48px; padding:8px 12px 8px 8px; border:1px solid var(--border); border-radius:9px; background:var(--surface); color:var(--text); font:inherit; font-size:12px; font-weight:600; text-align:left; white-space:nowrap; cursor:pointer; box-shadow:0 1px 2px #0000000a; transition:background-color 160ms,border-color 160ms; }
.ticket-champ-icon { display:grid; place-items:center; width:30px; height:30px; flex:none; border-radius:7px; background:color-mix(in srgb,var(--accent) 12%,transparent); color:var(--accent); }
.ticket-champ-icon svg { width:17px; height:17px; }
.ticket-champ-arrow { width:14px; height:14px; margin-left:auto; color:var(--muted); flex:none; }
.ticket-champ-button:hover:not(:disabled) { border-color:color-mix(in srgb,var(--accent) 45%,var(--border)); background:color-mix(in srgb,var(--accent) 6%,var(--surface)); }
.ticket-champ-button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.ticket-champ-button:disabled { opacity:.45; cursor:not-allowed; }
.ticket-champ-hint { font-size:11px; line-height:1.5; color:var(--muted); margin:12px 0 0; }
.ticket-champ-dialog { position:fixed; inset:0; width:min(520px,calc(100vw - 24px)); height:fit-content; margin:auto; max-height:calc(100dvh - 32px); max-width:none; min-width:0; overflow:hidden; padding:0; border:1px solid var(--border); border-radius:16px; background:var(--surface); color:var(--text); box-shadow:0 24px 80px #0006; }
.ticket-champ-dialog[open] { display:flex; flex-direction:column; }
.ticket-champ-dialog::backdrop { background:#0009; }
.ticket-champ-dialog>header { display:flex; flex-shrink:0; justify-content:space-between; align-items:center; gap:12px; padding:14px 20px; border-bottom:1px solid var(--border); }
.ticket-champ-dialog>header>div { min-width:0; overflow-wrap:anywhere; }
.ticket-champ-dialog h2 { font-size:17px; margin:0; }
.ticket-champ-dialog>header button { min-width:40px; min-height:40px; }
.ticket-champ-dialog iframe { flex:1; min-height:0; width:100%; border:0; }
.ticket-champ-actions { margin-bottom:20px; }
.ticket-billing-match { margin-bottom:12px; font-size:12px; }
.ticket-billing-email { color:var(--muted); overflow-wrap:anywhere; margin:4px 0 8px; }
.ticket-billing-status,.ticket-action-step { font-size:12px; color:var(--muted); line-height:1.5; margin:6px 0; }
.ticket-billing-followup-warning { padding:12px; margin-top:14px; border:1px solid color-mix(in srgb,var(--warn) 35%,var(--border)); border-radius:8px; background:var(--warn-soft); color:var(--warn); text-wrap:pretty; }
.ticket-match-badge { display:inline-block; font-size:10px; padding:3px 6px; border-radius:5px; background:var(--surface-2); color:var(--muted); }
.ticket-billing-refresh { display:block; background:none; border:0; padding:8px 0; min-height:36px; font:inherit; font-size:11px; color:var(--accent); cursor:pointer; text-align:left; }
.ticket-billing-person { display:flex; align-items:center; gap:11px; padding:2px 0 16px; }
.ticket-billing-person>div { min-width:0; }
.ticket-billing-person strong { display:block; font-size:13px; line-height:1.5; overflow-wrap:anywhere; }
.ticket-billing-avatar { display:grid; place-items:center; width:38px; height:38px; flex:none; border-radius:12px; background:var(--surface-2); color:var(--text-soft); font-size:15px; font-weight:650; box-shadow:inset 0 0 0 1px var(--border); }
.ticket-billing-person .ticket-billing-email { font-size:11px; line-height:1.5; margin:2px 0 4px; }
.ticket-billing-link { font-size:10px; line-height:1.5; color:var(--muted); }
.ticket-subscriptions { display:grid; gap:10px; }
.ticket-subscription { padding:14px; border:1px solid var(--border); border-radius:11px; background:var(--surface-2); }
.ticket-subscription-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.ticket-subscription-heading strong { font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.ticket-subscription-badge { flex:none; display:inline-flex; align-items:center; padding:3px 7px; border-radius:6px; background:var(--accent-soft); color:var(--accent); font-size:10px; line-height:1.4; font-weight:600; }
.ticket-subscription[data-status=cancelled] { border-color:color-mix(in srgb,var(--success) 38%,var(--border)); border-left:3px solid var(--success); background:color-mix(in srgb,var(--success) 6%,var(--surface-2)); }
.ticket-subscription-cancelled-title { display:inline-flex; align-items:center; gap:6px; margin:0 0 12px; padding:5px 8px; border-radius:6px; background:var(--success-soft); color:var(--success); font-size:12px; line-height:1.5; font-weight:700; }
.ticket-subscription-cancelled-title::before { content:'✓'; font-size:13px; }
.ticket-subscription-amount { display:flex; flex-wrap:wrap; align-items:baseline; gap:7px; padding-top:12px; }
.ticket-subscription-amount strong { color:var(--text); font-size:22px; letter-spacing:-.5px; line-height:1.3; font-variant-numeric:tabular-nums; }
.ticket-subscription-amount span { color:var(--muted); font-size:11px; }
.ticket-subscription-stopped { display:flex; align-items:center; gap:7px; color:var(--success); font-size:11px; line-height:1.5; margin:9px 0 0; }
.ticket-subscription-stopped::before { content:''; width:5px; height:5px; flex:none; border-radius:50%; background:currentColor; }
.ticket-match-tools { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:4px 12px; margin-top:10px; }
.ticket-match-tools .ticket-billing-refresh { min-height:40px; padding:8px 0; }
.ticket-match-tools .ticket-billing-refresh:last-child { color:var(--text-soft); }
.ticket-recent-charges { margin:14px 0 0; border-top:1px solid var(--border); padding-top:6px; }
.ticket-recent-charges summary { display:flex; align-items:center; gap:8px; min-height:40px; padding:6px 0; list-style:none; cursor:pointer; color:var(--text-soft); font-size:11px; font-weight:600; border-radius:5px; }
.ticket-recent-charges summary::-webkit-details-marker { display:none; }
.ticket-recent-charges summary::before { content:''; width:6px; height:6px; flex:none; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:rotate(-45deg); margin:0 3px 0 2px; transition:transform 160ms; }
.ticket-recent-charges[open] summary::before { transform:rotate(45deg); }
.ticket-recent-charges summary:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.ticket-recent-charges summary .ticket-match-count { margin-left:auto; }
.ticket-billing-orders { display:grid; gap:8px; padding:6px 0 2px; }
.ticket-billing-order { padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.ticket-billing-order-heading { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:6px 8px; }
.ticket-billing-order-heading strong { min-width:0; color:var(--text-soft); font-size:11px; line-height:1.5; font-weight:600; overflow-wrap:anywhere; }
.ticket-billing-order-status { flex:none; padding:3px 6px; border-radius:5px; color:var(--text-soft); background:var(--surface-3); font-size:9px; line-height:1.4; }
.ticket-billing-order-status[data-status=complete] { color:var(--success); background:var(--success-soft); }
.ticket-billing-order-status[data-status=partial],.ticket-billing-order-status[data-status=pending] { color:var(--warn); background:var(--warn-soft); }
.ticket-billing-order-total { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:5px 10px; margin-top:10px; }
.ticket-billing-order-total strong { font-size:19px; font-weight:650; line-height:1.3; letter-spacing:-.4px; font-variant-numeric:tabular-nums; color:var(--text); }
.ticket-billing-order-missing,.ticket-billing-order-date { color:var(--muted); font-size:10px; line-height:1.6; }
.ticket-action-body { padding:20px; overflow-y:auto; overscroll-behavior:contain; min-height:0; min-width:0; scrollbar-gutter:stable; }
.ticket-action-step { margin:5px 0 0; }
.ticket-action-status { color:var(--muted); font-size:13px; line-height:1.5; margin:0 0 12px; }
.ticket-action-status:empty { display:none; }
.ticket-action-status.has-error { color:var(--danger,#e97d87); }
.ticket-action-content { display:grid; gap:10px; }
.ticket-order-choice { display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px; padding:14px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--text); text-align:left; font:inherit; font-size:13px; cursor:pointer; width:100%; transition:border-color 160ms,background-color 160ms; }
.ticket-order-choice small { flex-basis:100%; color:var(--muted); font-size:11px; }
.ticket-order-choice:hover:not(:disabled),.ticket-order-choice[aria-pressed=true] { border-color:var(--accent); }
.ticket-match-heading { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:2px 0 8px; }
.ticket-match-heading strong { font-size:13px; font-weight:650; color:var(--text); }
.ticket-match-count { flex:none; padding:3px 7px; border-radius:6px; background:var(--surface-2); color:var(--text-soft); font-size:10px; line-height:1.4; font-variant-numeric:tabular-nums; }
.ticket-match-help { margin:0 0 12px; color:var(--muted); font-size:11px; line-height:1.6; text-wrap:pretty; }
.ticket-match-choices { display:grid; gap:8px; }
.ticket-match-choice { display:grid; grid-template-columns:32px minmax(0,1fr); gap:8px 10px; align-items:start; width:100%; min-width:0; padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--text); text-align:left; font:inherit; cursor:pointer; box-shadow:0 2px 5px #0000000a; transition:border-color 160ms,background-color 160ms,box-shadow 160ms; }
.ticket-match-avatar { display:grid; place-items:center; width:32px; height:32px; border-radius:8px; color:var(--accent); background:var(--accent-soft); font-size:11px; font-weight:650; }
.ticket-match-identity { display:grid; gap:3px; min-width:0; }
.ticket-match-identity strong { font-size:13px; line-height:1.5; font-weight:650; overflow-wrap:anywhere; }
.ticket-match-email { color:var(--text-soft); font-size:11px; line-height:1.6; overflow-wrap:anywhere; }
.ticket-match-select { grid-column:2; display:flex; align-items:center; gap:6px; color:var(--accent); font-size:11px; font-weight:600; line-height:1.5; }
.ticket-match-select svg { width:13px; height:13px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.ticket-match-choice:hover { border-color:var(--accent); background:color-mix(in srgb,var(--accent) 4%,var(--surface-2)); box-shadow:0 3px 10px #00000012; }
.ticket-match-choice:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.ticket-match-tools.is-choosing { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; margin-top:14px; padding-top:12px; border-top:1px solid var(--border); }
.ticket-match-tools.is-choosing .ticket-billing-refresh { padding:8px 10px; border:1px solid var(--border); border-radius:7px; background:var(--surface-2); color:var(--text-soft); text-align:center; font-size:10px; transition:border-color 160ms,background-color 160ms; }
.ticket-match-tools.is-choosing .ticket-billing-refresh:hover { border-color:var(--border-2); background:var(--surface-3); }
.ticket-match-tools.is-choosing .ticket-billing-refresh:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.ticket-order-choice[aria-pressed=true] { background:color-mix(in srgb,var(--accent) 10%,var(--surface)); }
.ticket-order-choice:disabled { opacity:.5; cursor:default; }
.ticket-refund-label,.ticket-action-search label { display:grid; gap:8px; font-size:12px; font-weight:600; }
.ticket-refund-label input,.ticket-action-search input { width:100%; min-height:46px; padding:12px; border:1px solid var(--border); border-radius:8px; background:var(--bg); color:var(--text); font:inherit; box-sizing:border-box; }
.ticket-refund-label input { font-size:24px; font-variant-numeric:tabular-nums; }
.ticket-action-search { display:grid; gap:10px; margin-bottom:16px; }
.ticket-action-search[hidden] { display:none; }
.ticket-champ-dialog footer { display:flex; flex-shrink:0; justify-content:flex-end; gap:10px; padding:16px 20px; border-top:1px solid var(--border); }
.ticket-champ-dialog footer button { min-height:42px; }
.ticket-champ-dialog footer [data-action-back] { margin-right:auto; }
.ticket-champ-dialog button[hidden] { display:none; }
.ticket-champ-dialog:has(.ticket-refund-charges) { width:min(600px,calc(100vw - 24px)); }
.ticket-charge-tools { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:2px 0 6px; }
.ticket-charge-all { display:flex; align-items:center; gap:10px; min-height:40px; font-size:12px; font-weight:600; cursor:pointer; }
.ticket-charge-full { min-height:40px; padding:8px 12px; border:1px solid var(--border); border-radius:8px; background:var(--surface-2); color:var(--text); font:inherit; font-size:11px; font-weight:600; cursor:pointer; transition:background-color 160ms,border-color 160ms; }
.ticket-charge-full:hover:not(:disabled) { background:var(--surface-3); border-color:var(--border-2); }
.ticket-charge-full:disabled { opacity:.45; cursor:default; }
.ticket-refund-charges { display:grid; gap:12px; }
.ticket-refund-charge { position:relative; display:grid; grid-template-columns:minmax(0,1fr) 128px; align-items:center; gap:20px; padding:18px; border:1px solid var(--border); border-radius:12px; background:var(--surface-2,var(--bg)); box-shadow:0 1px 2px #0001; transition:border-color 160ms,background-color 160ms,box-shadow 160ms; }
.ticket-refund-charge.is-renewal { background:color-mix(in srgb,var(--info) 6%,var(--surface-2)); border-color:color-mix(in srgb,var(--info) 32%,var(--border)); box-shadow:inset 3px 0 var(--info),0 1px 2px #0001; }
.ticket-refund-charge.is-selected { border-color:var(--accent); box-shadow:0 0 0 1px color-mix(in srgb,var(--accent) 35%,transparent); }
.ticket-refund-charge.is-renewal.is-selected { box-shadow:inset 3px 0 var(--info),0 0 0 1px color-mix(in srgb,var(--accent) 35%,transparent); }
.ticket-refund-charge.is-unavailable { opacity:.65; }
.ticket-charge-select { display:flex; align-items:flex-start; gap:10px; cursor:pointer; min-width:0; }
.ticket-charge-select input,.ticket-charge-all input { width:17px; height:17px; flex:none; margin:3px 0 0; accent-color:var(--accent); }
.ticket-charge-details { display:grid; justify-items:start; gap:7px; min-width:0; }
.ticket-charge-details strong { font-size:13px; font-weight:650; line-height:1.5; text-wrap:pretty; }
.ticket-charge-details .ticket-charge-kind { display:inline-flex; align-items:center; gap:5px; padding:3px 7px; border-radius:5px; font-size:10px; line-height:1.4; font-weight:650; color:var(--text-soft); background:var(--surface-3); }
.is-renewal .ticket-charge-details .ticket-charge-kind { color:var(--info); background:color-mix(in srgb,var(--info) 13%,transparent); }
.is-upsell .ticket-charge-details .ticket-charge-kind { color:var(--accent); background:var(--accent-soft); }
.ticket-charge-kind svg { width:12px; height:12px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.ticket-charge-details .ticket-charge-date { color:var(--text-soft); font-size:11px; line-height:1.5; }
.ticket-charge-details small,.ticket-charge-amount small { color:var(--muted); font-size:10px; line-height:1.5; overflow-wrap:anywhere; }
.ticket-charge-amount { display:grid; align-content:start; gap:8px; font-size:10px; color:var(--text-soft); }
.ticket-charge-amount input { width:100%; min-width:0; min-height:46px; padding:10px 12px; border:1px solid var(--border-2); border-radius:8px; background:var(--bg); color:var(--text); font:inherit; font-weight:650; font-size:20px !important; font-variant-numeric:tabular-nums; transition:border-color 160ms,box-shadow 160ms; }
.ticket-charge-amount input:focus-visible { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.ticket-charge-amount input:disabled { opacity:.7; }
.ticket-refund-total,.ticket-refund-review-row { display:flex; justify-content:space-between; gap:14px; align-items:center; padding:12px 0; font-variant-numeric:tabular-nums; }
.ticket-refund-total { border-top:1px solid var(--border); margin-top:6px; padding:16px 0 2px; font-size:12px; color:var(--text-soft); }
.ticket-refund-total strong { font-size:26px; color:var(--text); letter-spacing:-.5px; }
.ticket-refund-review-row { border-top:1px solid var(--border); font-size:12px; }
.ticket-match-search { display:flex; flex-wrap:wrap; gap:12px; margin-top:8px; }
.ticket-shopify-order[hidden] { display:none !important; }
.ticket-match-search input { width:100%; min-width:0; min-height:40px; padding:8px 10px; border:1px solid var(--border); border-radius:7px; background:var(--bg); color:var(--text); }
.ticket-customer-search { padding:14px; margin-top:0; border:1px solid var(--border); border-radius:12px; background:var(--surface-2); box-shadow:0 3px 12px #0001; }
.ticket-customer-search-title { width:100%; font-size:13px; color:var(--text); }
.ticket-customer-search-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px; width:100%; padding:3px; border:1px solid var(--border); border-radius:9px; background:var(--bg); }
.ticket-customer-search-tabs button { min-height:40px; border:1px solid transparent; border-radius:6px; background:transparent; color:var(--muted); font-size:12px; font-weight:600; cursor:pointer; }
.ticket-customer-search-tabs button[aria-selected=true] { color:var(--text); background:var(--surface-3); border-color:var(--border-2); box-shadow:0 1px 3px #0002; }
.ticket-customer-search [hidden],.ticket-billing-match>[hidden] { display:none !important; }
.ticket-customer-email-field { display:grid; gap:6px; width:100%; min-width:0; color:var(--text-soft); font-size:11px; }
.ticket-customer-search-footer { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; width:100%; }
.ticket-customer-search-footer button { min-height:40px; font-size:12px; padding:8px 12px; }
.ticket-match-name-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; width:100%; }
.ticket-match-name-fields[hidden] { display:none; }
.ticket-match-name-fields label { display:grid; gap:5px; min-width:0; color:var(--text-soft); font-size:11px; }
.ticket-image-dialog { position:fixed; inset:0; margin:auto; width:min(1080px,calc(100vw - 24px)); max-width:none; max-height:calc(100dvh - 24px); padding:0; overflow:hidden; border:1px solid var(--border); border-radius:14px; background:var(--surface); color:var(--text); box-shadow:0 24px 80px #0008; }
.ticket-image-dialog[open] { display:flex; flex-direction:column; }
.ticket-image-dialog::backdrop { background:#000b; }
.ticket-image-dialog header,.ticket-image-dialog footer { display:flex; align-items:center; gap:8px; padding:10px 14px; flex-shrink:0; }
.ticket-image-dialog header { border-bottom:1px solid var(--border); }
.ticket-image-dialog h2 { margin:0; min-width:0; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
.ticket-image-dialog button,.ticket-image-dialog footer a { display:inline-flex; align-items:center; justify-content:center; min-width:40px; min-height:40px; padding:8px 10px; border:1px solid var(--border); border-radius:7px; background:var(--surface-2); color:var(--text); font-size:12px; text-decoration:none; cursor:pointer; }
.ticket-image-dialog button:disabled { opacity:.4; cursor:default; }
.ticket-image-dialog footer a { margin-left:auto; }
.ticket-image-dialog [hidden] { display:none; }
.ticket-image-count { font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; white-space:nowrap; }
.ticket-image-stage { display:grid; grid-template: minmax(0,1fr) / minmax(0,1fr); place-items:center; height:min(72dvh,800px); min-height:0; overflow:auto; padding:12px; background:#0004; }
.ticket-image-stage img { display:block; width:100%; height:100%; min-width:0; min-height:0; object-fit:contain; }
.ticket-image-stage.is-zoomed { grid-template:max-content / max-content; place-items:start; }
.ticket-image-stage.is-zoomed img { width:auto; height:auto; max-width:none; max-height:none; }
.ticket-image-status { padding:24px; color:var(--muted); font-size:13px; }
@media (max-width:400px) { .ticket-image-dialog header,.ticket-image-dialog footer { gap:5px; padding:8px; } .ticket-image-dialog footer button,.ticket-image-dialog footer a { padding:8px; font-size:11px; } }
@media(max-width:480px) { .ticket-refund-charge { grid-template-columns:minmax(0,1fr) 106px; gap:12px; padding:14px 12px; } .ticket-charge-tools { gap:8px; flex-wrap:wrap; } .ticket-charge-full { padding:8px; } .ticket-charge-details strong { font-size:12px; } .ticket-charge-details .ticket-charge-kind { font-size:9px; padding:3px 5px; } .ticket-charge-amount input { padding:10px; font-size:18px !important; } }
@media(max-width:380px) { .ticket-action-body { padding:16px; } .ticket-champ-dialog>header,.ticket-champ-dialog footer { padding:12px 16px; } .ticket-refund-charge { grid-template-columns:minmax(0,1fr); gap:14px; } .ticket-charge-amount { grid-template-columns:minmax(0,1fr) 112px; align-items:center; margin-left:27px; } .ticket-charge-amount small { grid-column:1/-1; text-align:right; } }
@media(max-height:500px) { .ticket-champ-dialog { max-height:calc(100dvh - 16px); } .ticket-champ-dialog>header,.ticket-champ-dialog footer { padding-top:10px; padding-bottom:10px; } }
.ticket-action-total { font-size:26px; font-variant-numeric:tabular-nums; letter-spacing:-.5px; }
.ticket-champ-dialog:has(.ticket-action-success) { width:min(460px,calc(100vw - 24px)); }
.ticket-action-success { display:grid; justify-items:center; text-align:center; gap:12px; padding:10px 4px 18px; }
.ticket-action-success-icon { display:grid; place-items:center; width:54px; height:54px; margin-bottom:3px; border-radius:18px; background:var(--success-soft); color:var(--success); box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--success) 22%,transparent); }
.ticket-action-success-icon svg { width:27px; height:27px; }
.ticket-action-success-title { font-size:22px; letter-spacing:-.6px; font-weight:650; line-height:1.35; text-wrap:balance; }
.ticket-action-success .ticket-billing-status { margin:0; max-width:290px; text-wrap:pretty; }
.ticket-action-receipt { display:grid; gap:14px; padding:16px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.ticket-action-receipt>div { display:flex; justify-content:space-between; align-items:baseline; gap:16px; font-size:12px; line-height:1.5; }
.ticket-action-receipt span { flex:none; color:var(--muted); }
.ticket-action-receipt strong { text-align:right; overflow-wrap:anywhere; min-width:0; font-weight:550; }
.ticket-champ-dialog [data-action-done] { min-width:104px; }
@media(max-width:380px) { .ticket-subscription-heading { flex-wrap:wrap; } .ticket-action-success-title { font-size:20px; } .ticket-action-receipt>div { gap:8px; } }
