/* ===========================================================================
   KHC Message Center — "Premium Healthcare Calm" design system
   Warm surfaces · sage/teal accent · gold reserved for rewards · calm motion.
   One scale for type, spacing, radius, shadow. Light + dark. Reduced-motion safe.
   =========================================================================== */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}

:root {
  /* ---- Type scale (single ramp; tabular numerals for counts/timers) ---- */
  --font: 'Inter', ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t-xs: 12px; --t-sm: 13px; --t-base: 14px; --t-md: 16px; --t-lg: 20px; --t-xl: 24px;

  /* ---- Spacing scale ---- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;

  /* ---- Radius scale ---- */
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-full: 999px;

  /* ---- Light theme surfaces (warm, airy) ---- */
  --bg: #f1f4f2;
  --surface: #ffffff;
  --surface-2: #f6f8f6;
  --surface-3: #eef2ef;
  --ink: #17251f;
  --ink-soft: #33443c;
  --muted: #64756c;
  --line: #e3e9e4;
  --line-strong: #d3dcd5;

  /* ---- Sage/teal primary (calm, medical-grade) ---- */
  --primary: #1f8a76;
  --primary-hover: #1a7365;
  --primary-ink: #0f5d52;
  --primary-soft: rgba(31,138,118,.10);
  --primary-softer: rgba(31,138,118,.055);
  --on-primary: #ffffff;

  /* ---- Channel accents (calm, distinguishable) ---- */
  --email: #2a7d8c;   /* teal-blue for email */
  --text-c: #5a8f5f;  /* sage-green for text */

  /* ---- Status (muted, not neon) ---- */
  --good: #2f8f6f;
  --warn: #b9822e;
  --danger: #bf5a4f;
  --danger-soft: #fbeeec;

  /* ---- Reward gold — used ONLY for coins/celebration ---- */
  --gold: #bf9130;
  --gold-2: #d8b054;
  --gold-soft: #f4ead0;
  --gold-ink: #6f5210;

  /* ---- Shadows (three soft levels) ---- */
  --sh-1: 0 1px 2px rgba(22,40,34,.05), 0 1px 3px rgba(22,40,34,.04);
  --sh-2: 0 2px 8px rgba(22,40,34,.06), 0 4px 16px rgba(22,40,34,.05);
  --sh-3: 0 8px 24px rgba(22,40,34,.10), 0 2px 8px rgba(22,40,34,.06);
  --ring: 0 0 0 3px rgba(31,138,118,.20);

  /* ---- Motion ---- */
  --ease: cubic-bezier(.2,.6,.2,1);
  --dur: 160ms;
}

/* ---- Dark theme (auto by OS, or forced via [data-theme]) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1815; --surface: #16221d; --surface-2: #1b2823; --surface-3: #21302a;
    --ink: #e9efeb; --ink-soft: #c2ccc6; --muted: #91a099; --line: #263630; --line-strong: #32453d;
    --primary: #3fb59e; --primary-hover: #55c2ad; --primary-ink: #8fd9cb;
    --primary-soft: rgba(63,181,158,.14); --primary-softer: rgba(63,181,158,.07); --on-primary: #06231d;
    --email: #4aa5b5; --text-c: #7fb884; --good: #45b48f; --warn: #d3a24e;
    --danger: #e08a7f; --danger-soft: rgba(224,138,127,.12);
    --gold: #d8b054; --gold-2: #e6c877; --gold-soft: rgba(216,176,84,.16); --gold-ink: #f0dca6;
    --sh-1: 0 1px 2px rgba(0,0,0,.28); --sh-2: 0 2px 10px rgba(0,0,0,.34); --sh-3: 0 10px 30px rgba(0,0,0,.44);
    --ring: 0 0 0 3px rgba(63,181,158,.28);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1815; --surface: #16221d; --surface-2: #1b2823; --surface-3: #21302a;
  --ink: #e9efeb; --ink-soft: #c2ccc6; --muted: #91a099; --line: #263630; --line-strong: #32453d;
  --primary: #3fb59e; --primary-hover: #55c2ad; --primary-ink: #8fd9cb;
  --primary-soft: rgba(63,181,158,.14); --primary-softer: rgba(63,181,158,.07); --on-primary: #06231d;
  --email: #4aa5b5; --text-c: #7fb884; --good: #45b48f; --warn: #d3a24e;
  --danger: #e08a7f; --danger-soft: rgba(224,138,127,.12);
  --gold: #d8b054; --gold-2: #e6c877; --gold-soft: rgba(216,176,84,.16); --gold-ink: #f0dca6;
  --sh-1: 0 1px 2px rgba(0,0,0,.28); --sh-2: 0 2px 10px rgba(0,0,0,.34); --sh-3: 0 10px 30px rgba(0,0,0,.44);
  --ring: 0 0 0 3px rgba(63,181,158,.28);
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--t-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  font-feature-settings: "cv02","cv03","cv04","ss01";
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 15% 0%, var(--primary-softer), transparent 70%),
    radial-gradient(50% 45% at 100% 100%, rgba(191,145,48,.05), transparent 70%);
}
h1, h2, h3 { letter-spacing: -.01em; }
.num, .coin-pill span, .lb-coins, .count, .level-badge { font-variant-numeric: tabular-nums; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit;
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease); }
input, select, textarea { font: inherit; color: var(--ink); }
a { color: var(--primary-ink); }
.hidden { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-full); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: var(--s5); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); padding: var(--s6); border: 1px solid var(--line); position: relative; }
.login-card h1 { margin: 0 0 var(--s2); font-size: var(--t-xl); font-weight: 700; color: var(--ink); }
.login-brandmark { width: 44px; height: 44px; border-radius: var(--r-md); background: var(--primary);
  display: grid; place-items: center; margin-bottom: var(--s4); box-shadow: var(--sh-2); }
.login-brandmark svg { width: 24px; height: 24px; color: var(--on-primary); }
.login-card p.sub { margin: 0 0 var(--s5); color: var(--muted); font-size: var(--t-base); }
.field { margin-bottom: var(--s4); }
.field label { display: block; font-size: var(--t-xs); color: var(--muted); margin-bottom: var(--s2); font-weight: 600; letter-spacing: .02em; }
.field input { width: 100%; padding: 12px var(--s4); border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.field input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.btn-primary { width: 100%; padding: 13px; background: var(--primary); color: var(--on-primary); font-weight: 600; border-radius: var(--r-md); box-shadow: var(--sh-1); }
.btn-primary:hover { background: var(--primary-hover); }
.err { color: var(--danger); font-size: var(--t-sm); margin: var(--s3) 0 0; min-height: 18px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: var(--t-md); display: flex; align-items: center; gap: var(--s2); color: var(--ink); }
.brand .logo { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--primary); display: grid; place-items: center; color: var(--on-primary); flex: none; }
.brand .logo svg { width: 17px; height: 17px; }
.spacer { flex: 1; }

.icon { width: 18px; height: 18px; display: inline-block; vertical-align: -.18em; flex: none; stroke-width: 2; }
.icon-sm { width: 15px; height: 15px; }
.tab .icon { width: 17px; height: 17px; }

.hud { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2); border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line); }
.level-badge { width: 30px; height: 30px; border-radius: var(--r-full); display: grid; place-items: center; font-weight: 700; font-size: var(--t-sm); color: var(--on-primary); background: var(--primary); }
.xp-wrap { width: 84px; height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: var(--primary); border-radius: var(--r-full); transition: width .5s var(--ease); }
.coin-pill { display: flex; align-items: center; gap: var(--s2); background: var(--gold-soft); color: var(--gold-ink); font-weight: 700; padding: var(--s1) var(--s3); border-radius: var(--r-full); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); }
.role-badge { font-size: var(--t-xs); font-weight: 600; padding: var(--s1) var(--s3); border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line); letter-spacing: .01em; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.role-owner { color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }
.role-superadmin { color: var(--email); } .role-admin { color: var(--primary-ink); }
.icon-btn { background: var(--surface-2); border: 1px solid var(--line); width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center; color: var(--ink-soft); }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.body { display: grid; grid-template-columns: 232px 1fr 320px; gap: var(--s4); padding: var(--s4); min-height: 0; }
@media (max-width: 1100px){ .body { grid-template-columns: 210px 1fr; } .rail-right{ display:none; } }
@media (max-width: 760px){ .body { grid-template-columns: 1fr; } .rail-left{ display:none; } }

.rail-left { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s2); height: fit-content; box-shadow: var(--sh-1); }
.tab { display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left; padding: var(--s3); background: transparent; color: var(--muted); border-radius: var(--r-md); margin-bottom: 2px; font-weight: 600; font-size: var(--t-base); position: relative; }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.active { background: var(--primary-soft); color: var(--primary-ink); }
.tab.active::before { content:""; position:absolute; left:0; top:22%; bottom:22%; width:3px; border-radius:var(--r-full); background: var(--primary); }
.tab .count { margin-left: auto; font-size: var(--t-xs); background: var(--surface-3); color: var(--muted); border-radius: var(--r-full); padding: 1px var(--s2); min-width: 22px; text-align: center; font-weight: 600; }
.tab.active .count { background: var(--primary); color: var(--on-primary); }

.rail-center { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); display: flex; flex-direction: column; overflow: hidden; }
.list-head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: var(--s3); }
.list-head h2 { margin: 0; font-size: var(--t-lg); font-weight: 700; }
.cat-filter { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.cat-filter button { padding: 6px var(--s3); border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); font-weight: 600; font-size: var(--t-sm); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.cat-filter button:hover { background: var(--surface-3); }
.cat-filter button.active { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.list { overflow-y: auto; padding: var(--s2); }
.msg { display: grid; grid-template-columns: 42px 1fr auto; gap: var(--s3); padding: var(--s3); margin-bottom: var(--s2); border-radius: var(--r-md); cursor: pointer; border: 1px solid transparent; position: relative; background: var(--surface); transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.msg:hover { background: var(--surface-2); border-color: var(--line); }
.msg.selected { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 32%, transparent); }
.msg:focus-visible { box-shadow: var(--ring); }
.msg.overdue { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 6%, var(--surface)); }
.msg.overdue::before { background: var(--warn); }
.overdue-flag { color: var(--warn); font-weight: 700; font-size: var(--t-xs); display: inline-flex; align-items: center; gap: 3px; }
.avatar { width: 42px; height: 42px; border-radius: var(--r-md); display: grid; place-items: center; font-weight: 700; color: var(--on-primary); font-size: var(--t-base); }
.avatar svg { width: 18px; height: 18px; }
.av-email { background: var(--email); }
.av-text { background: var(--text-c); }
.msg::before { content:""; position:absolute; left:0; top:12px; bottom:12px; width:3px; border-radius:0 var(--r-full) var(--r-full) 0; background: var(--email); }
.msg.text-type::before { background: var(--text-c); }
.msg .prev .type-tag { font-weight: 600; }
.msg.email-type .who .type-tag { color: var(--email); } .msg.text-type .who .type-tag { color: var(--text-c); }
.msg .who { font-weight: 600; display: flex; align-items: center; gap: 6px; color: var(--ink); }
.msg .prev { color: var(--muted); font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.msg .prev b { color: var(--ink-soft); font-weight: 600; }
.msg .meta { text-align: right; color: var(--muted); font-size: var(--t-xs); display:flex; flex-direction:column; gap:6px; align-items:flex-end; }
.chip { font-size: var(--t-xs); font-weight: 600; padding: 2px var(--s2); border-radius: var(--r-full); display:inline-flex; align-items:center; gap:4px; }
.chip-new { background: var(--primary-soft); color: var(--primary-ink); }
.chip-pending { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--warn); }
.chip-resolved { background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good); }
.chip-notes { background: var(--surface-3); color: var(--muted); }
.chip-chart { background: color-mix(in srgb, var(--email) 14%, var(--surface)); color: var(--email); }
.chip-esc { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.empty { padding: 56px var(--s5); text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; opacity: .5; margin-bottom: var(--s3); }
.skel-row { display:grid; grid-template-columns:42px 1fr; gap:var(--s3); padding:var(--s3); margin-bottom:var(--s2); }
.skel { background: var(--surface-3); border-radius: var(--r-sm); position: relative; overflow: hidden; }
.skel::after { content:""; position:absolute; inset:0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-av { width:42px; height:42px; border-radius: var(--r-md); }
.skel-line { height: 11px; margin-bottom: 8px; }

.rail-right { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s5); }
.card h3 { margin: 0 0 var(--s4); font-size: var(--t-base); font-weight: 700; display: flex; align-items: center; gap: var(--s2); color: var(--ink); }
.card h3 svg { width: 17px; height: 17px; color: var(--muted); }
.lb-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.lb-rank { font-weight: 700; color: var(--muted); font-size: var(--t-sm); text-align: center; }
.lb-bar-wrap { background: var(--surface-3); border-radius: var(--r-full); height: 22px; overflow: hidden; position: relative; }
.lb-bar { height: 100%; background: color-mix(in srgb, var(--primary) 55%, var(--surface-3)); border-radius: var(--r-full); transition: width .6s var(--ease); min-width: 4px; }
.lb-name { position: absolute; left: var(--s3); top: 0; line-height: 22px; font-size: var(--t-xs); font-weight: 600; color: var(--ink); }
.lb-coins { font-weight: 700; color: var(--gold-ink); font-size: var(--t-sm); }
.lb-me .lb-bar { background: var(--primary); }
.lb-me .lb-name { color: var(--on-primary); }
.lb-row:first-child .lb-bar { background: var(--gold); }
.lb-row:first-child .lb-name { color: var(--gold-ink); }

.detail { position: fixed; top: 0; right: 0; height: 100%; width: min(480px, 100%); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--sh-3); z-index: 40; transform: translateX(100%); transition: transform .28s var(--ease); display: flex; flex-direction: column; }
.detail.open { transform: translateX(0); }
.detail-head { padding: var(--s4); border-bottom: 1px solid var(--line); display: flex; gap: var(--s3); align-items: center; background: var(--surface-2); }
.detail-body { padding: var(--s4); overflow-y: auto; flex: 1; }
.detail-body .from { font-weight: 700; }
.thread-subject { font-weight: 700; font-size: var(--t-md); margin-bottom: var(--s4); }
.bubble { max-width: 82%; padding: var(--s3) var(--s4); border-radius: var(--r-lg); margin-bottom: var(--s3); line-height: 1.5; }
.bubble-meta { font-size: var(--t-xs); color: var(--muted); margin-bottom: var(--s1); }
.bubble-body { white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: var(--r-sm); margin-right: auto; }
.bubble.out { background: var(--primary); color: var(--on-primary); border-bottom-right-radius: var(--r-sm); margin-left: auto; }
.bubble.out .bubble-meta { color: color-mix(in srgb, var(--on-primary) 82%, transparent); }
.bubble.email-bubble { max-width: 100%; background: transparent; border: 0; padding: 0; }
.bubble.email-bubble .bubble-meta { color: var(--muted); margin-bottom: var(--s2); }
.email-frame { width: 100%; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; min-height: 120px; }
.attach-img { max-width: 240px; max-height: 240px; border-radius: var(--r-md); margin-top: var(--s2); display: block; cursor: pointer; border: 1px solid var(--line); }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; margin: var(--s2) var(--s2) 0 0; padding: var(--s2) var(--s3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: var(--t-sm); text-decoration: none; }
.attach-chip:hover { background: var(--surface-3); }
.attach-chip svg { width: 15px; height: 15px; color: var(--muted); }
.reply-input-wrap { position: relative; }
.reply-input-wrap textarea { width: 100%; min-height: 66px; padding: var(--s3) 46px var(--s3) var(--s3); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); resize: vertical; }
.reply-input-wrap textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.reply-send { position: absolute; right: var(--s2); bottom: var(--s2); width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.reply-send:hover { background: var(--primary-hover); }
.reply-send svg { width: 16px; height: 16px; }
.notes-box { background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); border-radius: var(--r-md); padding: var(--s3); margin-bottom: var(--s4); }
.notes-title { font-weight: 700; font-size: var(--t-sm); color: var(--gold-ink); margin-bottom: var(--s2); }
.note-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s2) var(--s3); margin-bottom: 6px; }
.note-item .note-meta { font-size: var(--t-xs); color: var(--muted); margin-bottom: 2px; }
.detail-actions { padding: var(--s4); border-top: 1px solid var(--line); display: grid; gap: var(--s3); background: var(--surface-2); }
.action-row { display: flex; gap: var(--s2); flex-wrap: wrap; }

.btn { padding: var(--s3) var(--s4); border-radius: var(--r-md); font-weight: 600; font-size: var(--t-base); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 16px; height: 16px; }
.btn-done { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn-done:hover { background: var(--primary-hover); }
.btn-good { background: var(--good); color: #fff; border-color: transparent; }
.btn-warn { background: var(--warn); color: #fff; border-color: transparent; }
.btn-esc  { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn-esc:hover { background: var(--danger-soft); }
.btn-good:hover { filter: brightness(.96); } .btn-warn:hover { filter: brightness(.96); }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: var(--s3); border-bottom: 1px solid var(--line); font-size: var(--t-base); }
.admin-table th { color: var(--muted); font-weight: 600; font-size: var(--t-xs); letter-spacing: .02em; }
.pill-select { padding: var(--s2) var(--s3); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); }
.pill-select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-3); border-radius: var(--r-full); padding: var(--s3) var(--s5); font-weight: 600; font-size: var(--t-base); color: var(--ink); display: flex; align-items: center; gap: var(--s2); animation: toast-in .22s var(--ease); }
.toast.celebrate { background: var(--primary); color: var(--on-primary); }
.toast.house { font-size: var(--t-base); }
.toast.house-plus { background: var(--gold-soft); color: var(--gold-ink); border-color: color-mix(in srgb, var(--gold) 30%, transparent); }
.toast.house-minus { background: var(--surface); color: var(--ink); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.coin { display:inline-block; width:18px; height:18px; border-radius:50%; background: radial-gradient(circle at 35% 30%, var(--gold-2), var(--gold) 60%, var(--gold-ink)); border: 1px solid color-mix(in srgb, var(--gold-ink) 50%, transparent); }
.coin.spin { animation: coinspin .7s var(--ease); }
@keyframes coinspin { 0% { transform: rotateY(0); } 100% { transform: rotateY(360deg); } }

.fxlayer { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
.fxlayer i { position: absolute; }
.confetti-p { width: 8px; height: 12px; top: -20px; opacity: .9; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }
.spark { width: 6px; height: 6px; border-radius: 50%; animation: spark ease-out forwards; }
@keyframes spark { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.sparkle { position: absolute; animation: sparklefloat ease-out forwards; opacity: .9; }
@keyframes sparklefloat { 0% { transform: translateY(0) scale(.4); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-64px) scale(1.1); opacity: 0; } }
.balloon { width: 36px; height: 46px; border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%; bottom: -70px; opacity: .9; animation: floatup ease-in forwards; }
.balloon::after { content:""; position:absolute; left:50%; top:100%; width:1px; height:36px; background: rgba(0,0,0,.15); }
@keyframes floatup { 0% { transform: translateY(0) rotate(0); } 100% { transform: translateY(-115vh) rotate(var(--rot)); opacity: 0; } }

.office-choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.office-choices button { padding: var(--s4); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); font-weight: 600; }
.office-choices button:hover { background: var(--primary-soft); color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }

.team-dock { position: fixed; right: 20px; bottom: 0; width: 320px; max-width: calc(100vw - 40px); z-index: 50; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--sh-3); }
.team-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); cursor: pointer; font-weight: 700; color: var(--on-primary); background: var(--primary); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.team-head svg { width: 17px; height: 17px; }
.team-badge { background: var(--danger); color: #fff; border-radius: var(--r-full); font-size: var(--t-xs); padding: 1px 7px; }
.team-body { height: 380px; display: flex; flex-direction: column; }
#teamRoster { overflow-y: auto; flex: 1; }
.roster-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-bottom: 1px solid var(--line); }
.roster-row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); flex: none; }
.roster-row .ri { flex: 1; min-width: 0; } .roster-row .rn { font-weight: 600; } .roster-row .rmeta { font-size: var(--t-xs); color: var(--muted); }
.roster-row .rb { display: flex; gap: 6px; }
.roster-row .rb button { width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); position: relative; display: grid; place-items: center; }
.roster-row .rb button:hover { background: var(--surface-3); }
.roster-row .rb button svg { width: 15px; height: 15px; }
.roster-empty { padding: var(--s6) var(--s4); text-align: center; color: var(--muted); font-size: var(--t-base); }
.mini-badge { position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff; border-radius: var(--r-full); font-size: 10px; padding: 0 5px; }
#teamChat { display: flex; flex-direction: column; height: 100%; }
.team-chat-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); }
.team-chat-msgs { flex: 1; overflow-y: auto; padding: var(--s3); display: flex; flex-direction: column; gap: 6px; }
.tc-msg { max-width: 80%; padding: var(--s2) var(--s3); border-radius: var(--r-md); font-size: var(--t-base); line-height: 1.4; }
.tc-msg.me { background: var(--primary); color: var(--on-primary); align-self: flex-end; border-bottom-right-radius: var(--r-sm); }
.tc-msg.them { background: var(--surface-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: var(--r-sm); }
.team-chat-input { display: flex; gap: 6px; padding: var(--s2); border-top: 1px solid var(--line); }
.team-chat-input input { flex: 1; padding: var(--s3); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); }
.team-chat-input input:focus { outline: none; border-color: var(--primary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(20,32,28,.4); backdrop-filter: blur(4px); z-index: 70; display: grid; place-items: start center; padding-top: 8vh; }
.modal { width: min(520px, 94vw); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-weight: 700; display: flex; align-items: center; gap: var(--s2); }
.modal-head h3 svg { width: 17px; height: 17px; color: var(--muted); }
.modal-body { padding: var(--s4) var(--s5); }
.field-input { width: 100%; padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); margin-bottom: var(--s2); }
.field-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.contact-results { max-height: 320px; overflow-y: auto; }
.contact-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-radius: var(--r-md); }
.contact-row:hover { background: var(--surface-2); }
.contact-row .ci { flex: 1; min-width: 0; } .contact-row .cn { font-weight: 600; } .contact-row .cd { font-size: var(--t-sm); color: var(--muted); }
.contact-row .ca { display: flex; gap: 6px; }
.contact-row .ca button { padding: var(--s2) var(--s3); border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.contact-row .ca button:hover { background: var(--surface-3); }
.compose-to { font-weight: 600; padding: var(--s2) 0; }

.call-panel { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 80; width: min(320px, 92vw); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-3); padding: var(--s5); text-align: center; }
.call-avatar { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto var(--s3); display: grid; place-items: center; font-size: 26px; font-weight: 700; color: var(--on-primary); background: var(--primary); }
.call-avatar svg { width: 30px; height: 30px; }
.call-name { font-weight: 700; font-size: var(--t-lg); }
.call-status { color: var(--muted); margin: var(--s1) 0 var(--s4); font-weight: 600; }
.call-actions { display: flex; gap: var(--s3); justify-content: center; }
.call-actions .btn { padding: var(--s3) var(--s5); }

.reconn-pill { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(60px); background: var(--ink); color: var(--surface); padding: var(--s2) var(--s4); border-radius: var(--r-full); font-size: var(--t-sm); font-weight: 600; opacity: 0; pointer-events: none; transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease); z-index: 9999; display: flex; align-items: center; gap: var(--s2); }
.reconn-pill.show { opacity: .96; transform: translateX(-50%) translateY(0); }
.reconn-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .fxlayer { display: none !important; }
}

/* ===========================================================================
   Phase 2 — Responsiveness & interaction surfaces
   =========================================================================== */

/* ---- Keyboard focus on list rows ---- */
.msg { outline: none; }
.msg.kbfocus { box-shadow: var(--ring); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }

/* ---- List head hint ---- */
.list-head .hint { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--t-xs); }

/* ---- Skeleton loading ---- */
.skel-wrap { padding: var(--s2); }

/* ---- Error state (an outage must never look like an empty inbox) ---- */
.error-state { padding: 48px var(--s5); text-align: center; color: var(--muted); }
.error-state svg { width: 32px; height: 32px; color: var(--warn); margin-bottom: var(--s3); }
.error-state .msg-text { color: var(--ink); font-weight: 600; margin-bottom: var(--s1); }
.error-state .btn { margin-top: var(--s4); }

/* ---- Undo toast (must accept clicks; .toasts is pointer-events:none) ---- */
.toast-undo { pointer-events: auto; gap: var(--s4); }
.undo-btn { background: transparent; color: var(--primary-ink); font-weight: 700; padding: 3px 10px;
  border-radius: var(--r-sm); border: 1px solid transparent; }
.undo-btn:hover { background: var(--primary-soft); }

/* ---- Command palette (Cmd/Ctrl+K) ---- */
.cmdk-overlay { position: fixed; inset: 0; background: rgba(20,32,28,.45); backdrop-filter: blur(6px);
  z-index: 90; display: grid; place-items: start center; padding-top: 12vh; }
.cmdk { width: min(560px, 94vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden; }
.cmdk-input { width: 100%; padding: var(--s4) var(--s5); border: 0; background: transparent;
  font-size: var(--t-md); outline: none; color: var(--ink); }
.cmdk-list { max-height: 46vh; overflow-y: auto; border-top: 1px solid var(--line); }
.cmdk-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5);
  cursor: pointer; color: var(--ink); font-size: var(--t-base); }
.cmdk-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.cmdk-item .cmdk-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item.sel, .cmdk-item:hover { background: var(--primary-soft); }
.cmdk-item .sub { color: var(--muted); font-size: var(--t-xs); margin-left: auto; flex: none; }
.cmdk-empty { padding: var(--s5); text-align: center; color: var(--muted); }
.cmdk-foot { display: flex; gap: var(--s4); padding: var(--s2) var(--s5); border-top: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); font-size: var(--t-xs); }

/* ---- Keyboard shortcuts overlay (?) ---- */
.shortcuts-overlay { position: fixed; inset: 0; background: rgba(20,32,28,.5); backdrop-filter: blur(6px);
  z-index: 95; display: grid; place-items: center; padding: var(--s4); }
.shortcuts-card { width: min(520px, 94vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); padding: var(--s5); }
.shortcuts-card h3 { margin: 0 0 var(--s4); font-size: var(--t-md); font-weight: 700; }
.sc-row { display: flex; justify-content: space-between; align-items: center; padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.sc-row:last-child { border-bottom: 0; }
.sc-row span { color: var(--ink-soft); }
kbd { font-family: var(--font); font-size: var(--t-xs); font-weight: 600; background: var(--surface-2);
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-sm);
  padding: 2px 7px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---- "Your Progress" card ---- */
.goal-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s2); }
.goal-num { font-weight: 700; font-size: var(--t-lg); color: var(--ink); font-variant-numeric: tabular-nums; }
.goal-target { color: var(--muted); font-size: var(--t-sm); }
.goal-bar { height: 8px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.goal-fill { height: 100%; width: 0; background: var(--primary); border-radius: var(--r-full); transition: width .6s var(--ease); }
.goal-fill.reached { background: var(--gold); }
.goal-note { margin-top: var(--s3); color: var(--muted); font-size: var(--t-sm); line-height: 1.45; }
.goal-note strong { color: var(--good); font-weight: 600; }

/* ---- Mobile bottom navigation (the left rail disappears below 760px) ---- */
.mobile-nav { display: none; }
@media (max-width: 760px) {
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .mobile-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px; border-radius: var(--r-sm); color: var(--muted); font-size: 10px; font-weight: 600; position: relative; }
  .mobile-nav button.active { color: var(--primary-ink); background: var(--primary-soft); }
  .mobile-nav svg { width: 20px; height: 20px; }
  .mobile-nav .mcount { position: absolute; top: 1px; right: 22%; background: var(--primary); color: var(--on-primary);
    border-radius: var(--r-full); font-size: 9px; font-weight: 700; padding: 0 4px; min-width: 15px; text-align: center; }
  .body { padding-bottom: 74px; }
  .detail { width: 100%; }
  .detail-actions { padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom, 0px)); }
  .team-dock { display: none; }
  .topbar { padding: var(--s2) var(--s3); gap: var(--s2); }
  .hud, #officeChip { display: none; }
  .toasts { top: 64px; }
  .cmdk-overlay { padding-top: 6vh; }
}

/* Fix: the right rail's hide-on-narrow rule must come AFTER its base display:flex.
   (In the original file the media query preceded the base rule, so it never won.) */
@media (max-width: 1100px) { .rail-right { display: none; } }
@media (max-width: 760px)  { .rail-left { display: none; } html, body { overflow-x: hidden; } }

/* ==========================================================================
   Phase 3 — Game engine: claims, streaks, shields, badges, adaptive goal
   ========================================================================== */

/* Streak flame in the top bar. Warm gold only when the streak is alive. */
.streak-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); font-weight: 700; font-size: var(--t-sm);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.streak-pill.lit { color: var(--gold-ink); background: var(--gold-soft); border-color: var(--gold-2); }
.streak-pill.lit .icon { color: var(--gold); }

/* "Who's on it" chip in the list rows. Teal = you, quiet gray = a coworker. */
.chip-claim {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--line);
}
.chip-claim-me { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }

/* Banner in the thread panel when a coworker holds the claim. */
.claim-banner {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s3); margin-bottom: var(--s2);
  border-radius: var(--r-md); font-size: var(--t-sm); color: var(--ink-soft);
  background: var(--surface-2); border: 1px dashed var(--line-strong);
}
.claim-banner .icon { color: var(--primary); flex: none; }

/* Claim button — inviting but not shouty. */
.btn-claim { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }
.btn-claim:hover { background: var(--primary); color: var(--on-primary); }

/* Paused tools while someone else works the thread. */
.detail-actions button[disabled], .detail-actions textarea[disabled] {
  opacity: .45; cursor: not-allowed; pointer-events: none;
}

/* Progress card: streak line + shield dots + badge shelf. */
.streak-line {
  display: flex; align-items: center; gap: 6px;
  margin-top: var(--s3); font-size: var(--t-sm); color: var(--ink-soft);
}
.streak-line .icon { color: var(--gold); }
.streak-best { color: var(--muted); font-size: var(--t-xs); }
.shield-dots { display: inline-flex; gap: 2px; margin-left: auto; }
.shield-dot .icon { color: var(--line-strong); }
.shield-dot.full .icon { color: var(--primary); }

.badge-row {
  display: flex; align-items: center; gap: var(--s1);
  margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line);
}
.badge-tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: var(--gold-soft); color: var(--gold-ink);
  border: 1px solid var(--gold-2);
}
.badge-tile .icon { width: 14px; height: 14px; }
.badge-count { margin-left: auto; color: var(--muted); font-size: var(--t-xs); font-weight: 700; }

/* ==========================================================================
   Phase 4 — Manager command center
   ========================================================================== */
.cc-note { color: var(--muted); font-size: var(--t-xs); margin: 8px 2px 0; line-height: 1.5; }
.cc-card { margin-top: 12px; box-shadow: none; }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.cc-head h3 { margin: 0; }
.btn-sm { padding: 5px 10px; font-size: var(--t-xs); }

/* Clinic pulse tiles */
.pulse-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s2); margin-bottom: var(--s2);
}
.pulse-stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s3); box-shadow: var(--sh-1);
}
.pulse-stat.good { border-left: 3px solid var(--good); }
.pulse-stat.warn { border-left: 3px solid var(--warn); }
.pulse-stat.bad  { border-left: 3px solid var(--danger); }
.ps-num { font-size: var(--t-xl); font-weight: 800; color: var(--ink); line-height: 1.1; }
.ps-lbl { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--t-xs); margin-top: 4px; }
.ps-lbl .icon { width: 13px; height: 13px; }
.trend { font-size: 10px; font-weight: 700; margin-left: auto; padding-left: 6px; }
.trend.up { color: var(--good); }
.trend.down { color: var(--warn); }

/* Aging list */
.aging-list { display: flex; flex-direction: column; }
.aging-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.aging-row:last-child { border-bottom: none; }
.aging-row:hover { background: var(--surface-2); }
.aging-who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aging-age { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; }
.aging-age.bad { color: var(--danger); font-weight: 700; }

/* Scorecard metric cell colours (manager-only, advisory) */
.sc-table td.m-good { color: var(--good); font-weight: 700; }
.sc-table td.m-warn { color: var(--warn); font-weight: 700; }
.sc-table td.m-bad  { color: var(--danger); font-weight: 700; }

/* Audit log */
.audit-list { margin-top: 8px; max-height: 340px; overflow-y: auto; }
.audit-row {
  display: grid; grid-template-columns: 120px 90px 110px 1fr; gap: var(--s2);
  padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: var(--t-xs); align-items: baseline;
}
.au-time { color: var(--muted); }
.au-actor { font-weight: 700; }
.au-action { color: var(--primary-ink); font-weight: 600; }
.au-detail { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .audit-row { grid-template-columns: 1fr 1fr; } .au-detail { grid-column: 1 / -1; white-space: normal; } }

/* Weekly digest preview */
.digest-pre {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s3); font-size: var(--t-xs); line-height: 1.55; white-space: pre-wrap;
  max-height: 320px; overflow-y: auto; color: var(--ink-soft); font-family: var(--font);
}

/* Canned reply picker (in the reply box) */
.canned-menu {
  margin-top: 6px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--sh-2); max-height: 260px; overflow-y: auto;
}
.canned-loading { padding: var(--s3); color: var(--muted); font-size: var(--t-sm); }
.canned-item {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  padding: 9px var(--s3); border: none; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer; color: var(--ink);
}
.canned-item:last-child { border-bottom: none; }
.canned-item:hover { background: var(--primary-soft); }
.canned-title { font-weight: 700; font-size: var(--t-sm); }
.canned-body { color: var(--muted); font-size: var(--t-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Canned reply manager (admin portal) */
.canned-manage-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.canned-manage-row:last-child { border-bottom: none; }

/* ==========================================================================
   v-next: text vs email distinction, resolved-late, overdue report, window buttons
   ========================================================================== */
/* Channel chips — texts (sage) vs emails (teal-blue), unmistakable at a glance. */
.chip-ch { font-weight: 700; letter-spacing: .01em; }
.chip-ch .icon { width: 12px; height: 12px; }
.chip-ch-text  { background: color-mix(in srgb, var(--text-c) 16%, transparent); color: var(--text-c); }
.chip-ch-email { background: color-mix(in srgb, var(--email) 16%, transparent); color: var(--email); }
/* Reinforce with a stronger left rail + faint row tint per channel. */
.msg.text-type  { border-left: 3px solid var(--text-c); }
.msg.email-type { border-left: 3px solid var(--email); }
.msg.text-type::before, .msg.email-type::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .04; border-radius: inherit; }
.msg.text-type::before  { background: var(--text-c); }
.msg.email-type::before { background: var(--email); }
.msg { position: relative; }

/* "Resolved late" — permanent amber marker in the Completed box. */
.chip-late { background: var(--gold-soft); color: var(--gold-ink); border: 1px solid var(--gold-2); font-weight: 700; }
.chip-late .icon { width: 12px; height: 12px; }

/* Overdue report table emphasis */
.od-late { color: var(--danger); font-weight: 700; }
.od-open { color: var(--warn); font-weight: 700; }

/* Detail window: expanded (full-screen) mode + button row */
.detail.expanded {
  left: 0; width: 100vw; max-width: 100vw; border-radius: 0;
}
.detail-head .win-btns { display: inline-flex; gap: 2px; margin-left: auto; }

/* ==========================================================================
   Overdue: RED + gentle bounce to demand attention in the inbox.
   Placed LAST so it wins over the channel-color left border / ::before tint.
   ========================================================================== */
@keyframes overdue-bounce {
  0%, 100% { transform: translateY(0); }
  35%      { transform: translateY(-4px); }
  70%      { transform: translateY(-1px); }
}
.msg.overdue {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));  /* top/right/bottom */
  background: color-mix(in srgb, var(--danger) 13%, var(--surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent);
  animation: overdue-bounce 1.1s var(--ease) infinite;
  border-left: 4px solid var(--danger);   /* LAST so the true-red left rail isn't reset by border-color */
}
.msg.overdue::before { background: var(--danger); opacity: .1; }
.msg.overdue.selected { animation: none; }          /* don't bob the thread you're reading */
.overdue-flag { color: var(--danger); }
.overdue-flag .icon { color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .msg.overdue { animation: none; } }
