/* ============================================================
   Handcrafted AI — design system + app shell
   Token-based. Every color routes through a CSS variable so
   light/dark is a single attribute flip on <html>.
   ============================================================ */

/* ---- Non-color tokens (shared) ---- */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --num: 'Inter', sans-serif;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --pill: 999px;
  --maxw: 640px;
  --header-h: 56px;
  --tab-h: 60px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---- Dark theme (default) ---- */
:root,
[data-theme="dark"] {
  --bg: #0d0d10;
  --surface: #16161a;
  --surface-2: #1e1e24;
  --elevated: #232329;
  --border: #2b2b33;
  --border-soft: #202027;
  --text: #f4f4f6;
  --text-dim: #a2a2ad;
  --text-faint: #6c6c77;
  --accent: #e0b058;
  --accent-press: #c99c47;
  --accent-soft: rgba(224, 176, 88, .16);
  --on-accent: #2b1e00;
  --positive: #2ecd77;
  --negative: #ff5a5f;
  --shadow: 0 10px 34px rgba(0, 0, 0, .5);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, .4);
  --backdrop: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ef;
  --elevated: #ffffff;
  --border: #e6e6e2;
  --border-soft: #eeeeeb;
  --text: #18181b;
  --text-dim: #6b6b73;
  --text-faint: #9a9aa2;
  --accent: #c79333;
  --accent-press: #ab7d24;
  --accent-soft: rgba(199, 147, 51, .14);
  --on-accent: #ffffff;
  --positive: #1faa5d;
  --negative: #d23b3f;
  --shadow: 0 10px 34px rgba(0, 0, 0, .12);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, .06);
  --backdrop: rgba(0, 0, 0, .35);
  color-scheme: light;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  transition: background .3s var(--ease), color .3s var(--ease);
}
button { font-family: inherit; }
a { color: inherit; }

/* ---- App shell layout ---- */
.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.header-left { display: flex; align-items: center; gap: .5rem; z-index: 1; }
.header-right { display: flex; align-items: center; z-index: 1; }
.header-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center;
}
.hc-logo { height: 26px; width: auto; display: block; flex-shrink: 0; }
.bubbles-logo { height: 35px; width: auto; display: block; }
.mgr-pill {
  font-size: .58rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent); border-radius: var(--pill);
  padding: .12rem .4rem;
}
/* theme-based logo swap */
[data-theme="dark"] .logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; }

/* ---- Avatar + menu ---- */
.avatar-btn {
  width: 34px; height: 34px; border-radius: var(--pill);
  border: none; cursor: pointer; padding: 0; overflow: hidden;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

.menu-pop {
  position: fixed; top: calc(var(--header-h) + 4px); right: 12px;
  width: 230px; background: var(--elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 60;
  padding: .4rem; opacity: 0; transform: translateY(-8px) scale(.98);
  pointer-events: none; transition: opacity .16s var(--ease), transform .16s var(--ease);
  transform-origin: top right;
}
.menu-pop.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.menu-head {
  padding: .6rem .7rem .7rem; display: flex; align-items: center; gap: .6rem;
  border-bottom: 1px solid var(--border-soft); margin-bottom: .35rem;
}
.menu-head .name { font-weight: 700; font-size: .9rem; }
.menu-head .sub { font-size: .72rem; color: var(--text-faint); text-transform: capitalize; }
.menu-item {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .65rem .7rem; background: none; border: none; cursor: pointer;
  text-align: left; color: var(--text); font-size: .9rem; font-weight: 500;
  border-radius: 10px; text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item svg { width: 17px; height: 17px; color: var(--text-dim); flex-shrink: 0; }
.menu-item.danger { color: var(--negative); }
.menu-item.danger svg { color: var(--negative); }
.menu-badge {
  margin-left: auto; font-size: .62rem; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: .1rem .4rem; border-radius: var(--pill);
}
.menu-sep { height: 1px; background: var(--border-soft); margin: .35rem .2rem; }

/* ---- Main content ---- */
.content {
  flex: 1;
  padding: 1.1rem 1rem calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 1.5rem);
}

/* ---- Greeting ---- */
.greeting { margin: .3rem 0 1.2rem; }
.greeting h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.greeting p { color: var(--text-dim); font-size: .92rem; margin-top: .15rem; }

/* ---- Coming soon ---- */
.coming-soon {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; min-height: 56vh; gap: .9rem; padding: 2rem 1rem;
}
.coming-soon .cs-icon {
  width: 72px; height: 72px; border-radius: var(--radius-lg);
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.coming-soon .cs-icon svg { width: 34px; height: 34px; }
.coming-soon h2 { font-size: 1.3rem; font-weight: 800; }
.coming-soon p { color: var(--text-dim); font-size: .92rem; max-width: 300px; line-height: 1.55; }
.coming-soon .cs-pill {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: .35rem .8rem; border-radius: var(--pill);
}

/* ---- Cards (foundation for Phase 2) ---- */
.card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 1rem;
}

/* ---- Bottom tab bar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--maxw);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: stretch; z-index: 40;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; background: none; border: none;
  cursor: pointer; color: var(--text-faint); text-decoration: none;
  font-size: .64rem; font-weight: 600; letter-spacing: .01em;
  transition: color .15s var(--ease);
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }
.tab-center { position: relative; }
.ai-fab {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  width: 60px; height: 60px; border-radius: var(--pill);
  background: var(--surface); padding: 0; overflow: hidden;
  border: 4px solid var(--bg); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(224, 176, 88, .28), var(--shadow-sm);
  transition: transform .18s var(--ease);
}
.ai-fab:active { transform: translateX(-50%) scale(.92); }
.ai-fab img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tab-center .tab-label { margin-top: 38px; font-size: .64rem; color: var(--text-faint); font-weight: 600; }

/* ---- Generic backdrop ---- */
.backdrop {
  position: fixed; inset: 0; background: var(--backdrop); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .22s var(--ease);
}
.backdrop.open { opacity: 1; pointer-events: auto; }

/* ---- Settings panel (slide-over) ---- */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(86vw, 380px); background: var(--bg); z-index: 70;
  transform: translateX(100%); transition: transform .28s var(--ease);
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.panel.open { transform: translateX(0); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--border-soft);
}
.panel-head h2 { font-size: 1.05rem; font-weight: 800; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text-dim);
  width: 34px; height: 34px; border-radius: 9px; display: flex;
  align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }
.panel-body { padding: 1.1rem; overflow-y: auto; }
.setting-row { margin-bottom: 1.4rem; }
.setting-label { font-size: .8rem; font-weight: 700; color: var(--text-dim); margin-bottom: .55rem; text-transform: uppercase; letter-spacing: .05em; }
.setting-hint { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-faint); font-size: .7rem; margin-left: .4rem; }

/* Voice picker (Settings) */
.voice-list { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.voice-opt {
  display: flex; align-items: center; gap: .4rem; cursor: pointer;
  padding: .5rem .55rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
}
.voice-opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.voice-opt .vo-check { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); opacity: 0; }
.voice-opt .vo-check svg { width: 16px; height: 16px; }
.voice-opt.selected .vo-check { opacity: 1; }
.voice-opt .vo-name { flex: 1; font-size: .85rem; font-weight: 600; }
.voice-opt .vo-play {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
  border: none; background: var(--surface); color: var(--text-dim);
  font-size: .7rem; display: flex; align-items: center; justify-content: center;
}
.voice-opt .vo-play:disabled { opacity: .5; }

/* ---- Segmented control ---- */
.segmented {
  display: flex; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 3px; gap: 3px;
}
.segmented button {
  flex: 1; padding: .55rem .4rem; border: none; background: none; cursor: pointer;
  border-radius: 8px; font-size: .85rem; font-weight: 600; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented button svg { width: 15px; height: 15px; }
.segmented button.active { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-sm); }

/* ---- AI sheet ---- */
.ai-sheet {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(100%);
  bottom: var(--kb, 0px); width: 100%; max-width: var(--maxw);
  height: min(88dvh, calc(100dvh - var(--kb, 0px) - 6px));
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 80; display: flex; flex-direction: column;
  box-shadow: var(--shadow); will-change: transform;
  transition: transform .3s var(--ease);
  border: 1px solid var(--border); border-bottom: none;
}
.ai-sheet.open { transform: translateX(-50%) translateY(0); }
.ai-sheet.dragging { transition: none; }

/* thinking indicator */
.think { display: inline-flex; align-items: center; gap: .5rem; color: var(--text-dim); }
.think .face { font-style: normal; animation: bob 1.8s ease-in-out infinite; }
.think .phrase { font-style: italic; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.sheet-handle-wrap { padding: .55rem 0 .3rem; display: flex; justify-content: center; cursor: grab; touch-action: none; flex-shrink: 0; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .1rem 1.1rem .65rem; flex-shrink: 0;
}
.sheet-title { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: .98rem; }
.sheet-title .spark { color: var(--accent); display: flex; }
.sheet-title .spark svg { width: 18px; height: 18px; }

/* ---- Chat ---- */
.chat-area {
  flex: 1; overflow-y: auto; padding: .5rem 1rem;
  display: flex; flex-direction: column; gap: .6rem;
}
.chat-welcome { text-align: center; color: var(--text-faint); font-size: .88rem; margin: auto 0; padding: 1.5rem; line-height: 1.6; }
.chat-welcome strong { display: block; color: var(--text); font-size: 1rem; margin-bottom: .3rem; }
.bubble {
  max-width: 86%; padding: .7rem .95rem; border-radius: 16px;
  font-size: .92rem; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 5px; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 5px; }
.bubble.devnote { align-self: center; background: var(--accent-soft); color: var(--accent); font-size: .82rem; font-style: italic; border-radius: var(--pill); padding: .4rem .9rem; }
.tool-chip { align-self: flex-start; font-size: .76rem; color: var(--text-faint); font-style: italic; padding: .1rem .5rem; }

.composer {
  display: flex; gap: .55rem; align-items: flex-end;
  padding: .7rem 1rem calc(.7rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-soft); flex-shrink: 0; background: var(--surface);
}
.composer textarea {
  flex: 1; resize: none; border: 1.5px solid var(--border); background: var(--bg);
  color: var(--text); border-radius: 14px; padding: .65rem .9rem; font-size: .95rem;
  font-family: inherit; outline: none; max-height: 140px; line-height: 1.45;
  transition: border-color .15s var(--ease);
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:focus { border-color: var(--accent); }
.send-btn {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--accent); color: var(--on-accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: opacity .15s;
}
.send-btn:disabled { opacity: .4; cursor: default; }
.send-btn svg { width: 18px; height: 18px; }

.mic-btn {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border-soft);
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.mic-btn svg { width: 19px; height: 19px; }
.mic-btn.recording { background: var(--negative); color: #fff; border-color: var(--negative); animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,60,60,.45); } 50% { box-shadow: 0 0 0 6px rgba(220,60,60,0); } }

/* Voice status: speaking indicator / tap-to-play fallback (above composer) */
.voice-status {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin: 0 1rem .15rem; padding: .45rem .7rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  font-size: .8rem; font-weight: 600; color: var(--text-dim);
}
.voice-status.blocked { background: var(--accent); border-color: var(--accent); }
.voice-status.error { color: var(--negative); }
.voice-status .vs-btn {
  margin-left: auto; border: none; border-radius: 7px; cursor: pointer;
  padding: .25rem .6rem; font-size: .75rem; font-weight: 700;
  background: var(--surface); color: var(--text-dim);
}
.voice-status .vs-btn.primary { margin: 0 auto; background: var(--on-accent); color: var(--accent); padding: .35rem 1rem; }
.vs-spin { width: 13px; height: 13px; border: 2px solid var(--border-soft); border-top-color: var(--accent); border-radius: 50%; animation: vs-spin .7s linear infinite; }
@keyframes vs-spin { to { transform: rotate(360deg); } }
.vs-eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.vs-eq i { width: 3px; background: var(--accent); border-radius: 1px; animation: vs-eq .9s ease-in-out infinite; }
.vs-eq i:nth-child(2) { animation-delay: .15s; } .vs-eq i:nth-child(3) { animation-delay: .3s; } .vs-eq i:nth-child(4) { animation-delay: .45s; }
@keyframes vs-eq { 0%,100% { height: 4px; } 50% { height: 14px; } }
.vs-eq.paused i { animation-play-state: paused; height: 8px; }

/* ---- Quick chips (starter prompts inside sheet) ---- */
.quick-row { display: flex; gap: .5rem; flex-wrap: wrap; padding: 0 1rem .6rem; flex-shrink: 0; }
.quick-chip {
  background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--text-dim);
  border-radius: var(--pill); padding: .4rem .8rem; font-size: .8rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.quick-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Rep shadow bottom sheet (manager) ---- */
.rep-sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%) translateY(100%);
  width: 100%; max-width: var(--maxw); background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; z-index: 80;
  max-height: 72dvh; display: flex; flex-direction: column;
  box-shadow: var(--shadow); transition: transform .28s var(--ease);
  border: 1px solid var(--border); border-bottom: none;
}
.rep-sheet.open { transform: translateX(-50%) translateY(0); }
.rep-search {
  margin: .2rem 1rem .5rem; padding: .65rem .9rem; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text); border-radius: 12px; font-size: .9rem;
  font-family: inherit; outline: none; flex-shrink: 0;
}
.rep-search:focus { border-color: var(--accent); }
.rep-list { overflow-y: auto; flex: 1; padding-bottom: env(safe-area-inset-bottom, 1rem); }
.rep-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: .7rem 1.1rem; border: none; background: none; cursor: pointer; text-align: left;
}
.rep-row:hover { background: var(--surface-2); }
.rep-row .rn { font-size: .9rem; font-weight: 600; color: var(--text); }
.rep-row .rl { font-size: .75rem; color: var(--text-faint); margin-top: .1rem; }
.rep-row .rc { color: var(--accent); font-weight: 700; }
.rep-row.sel .rn { color: var(--accent); }
.rep-divider { height: 1px; background: var(--border-soft); margin: .2rem 0; }
.rep-empty { padding: 2rem; text-align: center; color: var(--text-faint); font-size: .88rem; }

/* shadow chip in header */
.shadow-chip {
  display: inline-flex; align-items: center; gap: .3rem; margin-right: .5rem;
  background: var(--accent-soft); color: var(--accent); border-radius: var(--pill);
  padding: .2rem .3rem .2rem .6rem; font-size: .72rem; font-weight: 700; max-width: 130px;
}
.shadow-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shadow-chip button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: .85rem; line-height: 1; padding: 0; }

/* ── My Day ─────────────────────────────────────────────── */
.day-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: 1.1rem;
}
.day-nav { display: flex; align-items: center; gap: .5rem; }
.day-arrow {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.day-arrow:hover { border-color: var(--accent); color: var(--accent); }
.day-arrow svg { width: 18px; height: 18px; }
.day-label { text-align: center; }
.day-label .dl-main { font-weight: 800; font-size: 1.05rem; }
.day-label .dl-sub { font-size: .72rem; color: var(--text-faint); }
.day-today-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  border-radius: var(--pill); padding: .35rem .8rem; font-size: .78rem; font-weight: 600;
  cursor: pointer;
}
.day-today-btn:hover { border-color: var(--accent); color: var(--accent); }
.day-date-input {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}

.agenda { display: flex; flex-direction: column; gap: .6rem; }
.agenda-empty, .agenda-loading {
  text-align: center; color: var(--text-faint); font-size: .9rem; padding: 3rem 1rem;
}
.cal-note { font-size: .78rem; color: var(--text-faint); text-align: center; padding: .4rem; }

/* event row */
.ev {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: .7rem .9rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border-soft);
}
.ev-time { font-size: .74rem; font-weight: 700; color: var(--text-dim); min-width: 62px; padding-top: .1rem; }
.ev-body { flex: 1; min-width: 0; }
.ev-title { font-size: .92rem; font-weight: 600; }
.ev-loc { font-size: .76rem; color: var(--text-faint); margin-top: .1rem; }
.ev-cal-icon { color: var(--text-faint); flex-shrink: 0; }
.ev-cal-icon svg { width: 16px; height: 16px; }
.ev.past .ev-title { color: var(--text-faint); text-decoration: line-through; }
.ev.past .ev-time { color: var(--text-faint); }

/* stop card */
.stop {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden;
}
.stop.done { border-color: color-mix(in srgb, var(--positive) 45%, var(--border-soft)); }
.stop-head {
  display: flex; align-items: center; gap: .8rem; padding: .85rem .9rem; cursor: pointer;
}
.stop-status {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--border); color: var(--text-faint);
}
.stop.done .stop-status { background: var(--positive); border-color: var(--positive); color: #fff; }
.stop-status svg { width: 14px; height: 14px; }
.stop-seq { font-size: .68rem; color: var(--text-faint); font-weight: 700; }
.stop-main { flex: 1; min-width: 0; }
.stop-name { font-size: .95rem; font-weight: 700; }
.stop.done .stop-name { color: var(--text-dim); }
.stop-meta { font-size: .76rem; color: var(--text-faint); margin-top: .1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.risk-badge { color: var(--negative); font-weight: 700; }
.stop-chev { color: var(--text-faint); transition: transform .2s var(--ease); flex-shrink: 0; }
.stop-chev svg { width: 18px; height: 18px; }
.stop.open .stop-chev { transform: rotate(180deg); }

.stop-body { max-height: 0; overflow: hidden; transition: max-height .26s var(--ease); }
.stop.open .stop-body { max-height: 320px; }
.stop-tasks { padding: .2rem .9rem 1rem; border-top: 1px solid var(--border-soft); }
.task {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .6rem .2rem; background: none; border: none; cursor: pointer;
  text-align: left; color: var(--text); font-size: .88rem; font-weight: 500;
}
.task:hover { color: var(--accent); }
.task .tbox {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: transparent;
}
.task.done .tbox { background: var(--positive); border-color: var(--positive); color: #fff; }
.task .tbox svg { width: 12px; height: 12px; }
.task.done .tlabel { color: var(--text-dim); text-decoration: line-through; }
.task .tgo { margin-left: auto; color: var(--text-faint); }
.task .tgo svg { width: 16px; height: 16px; }

/* ── Markdown in chat replies ───────────────────────────── */
.md-tablewrap { overflow-x: auto; margin: .5rem 0; -webkit-overflow-scrolling: touch; }
.md-table { border-collapse: collapse; width: 100%; font-size: .82rem; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: .4rem .55rem; text-align: left; white-space: nowrap; }
/* First column (usually a product/account name) wraps so long names don't force a
   horizontal scroll on mobile; numeric/date columns stay tight (nowrap above). */
.md-table th:first-child, .md-table td:first-child { white-space: normal; overflow-wrap: break-word; }
.md-table th { background: var(--surface-2); font-weight: 700; }
.bubble .md-h { font-weight: 800; margin: .5rem 0 .2rem; }
.bubble .md-h1 { font-size: 1.05rem; } .bubble .md-h2 { font-size: .98rem; } .bubble .md-h3 { font-size: .9rem; }
.bubble .md-list { margin: .3rem 0 .3rem 1.15rem; } .bubble .md-list li { margin: .15rem 0; }
/* Same list indent for markdown rendered in note/reply bodies (else bullets hang outside the card). */
.mn-msg .md-list, .mn-reply-body .md-list { margin: .3rem 0 .3rem 1.15rem; }
.mn-msg .md-list li, .mn-reply-body .md-list li { margin: .15rem 0; }
.bubble p { margin: .35rem 0; } .bubble p:first-child { margin-top: 0; } .bubble p:last-child { margin-bottom: 0; }
.bubble code { background: var(--surface-2); padding: .05rem .3rem; border-radius: 5px; font-size: .85em; }

/* ── Customer: search view ──────────────────────────────── */
.cust-search-wrap { padding-top: 1rem; }
.cust-search-box {
  display: flex; align-items: center; gap: .5rem; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 14px; padding: .15rem .9rem;
}
.cust-search-box:focus-within { border-color: var(--accent); }
.cust-search-box svg { width: 18px; height: 18px; color: var(--text-faint); flex-shrink: 0; }
.cust-search-box input {
  flex: 1; border: none; background: none; outline: none; color: var(--text);
  font-size: 1rem; font-family: inherit; padding: .7rem 0;
}
.cust-scope { display: flex; gap: .4rem; margin: .7rem 0; }
.cust-scope button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  border-radius: var(--pill); padding: .3rem .8rem; font-size: .78rem; font-weight: 600; cursor: pointer;
}
.cust-scope button.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.cust-results { margin-top: .5rem; display: flex; flex-direction: column; }
.cust-result {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: .8rem .4rem; background: none; border: none; border-bottom: 1px solid var(--border-soft);
  cursor: pointer; text-align: left;
}
.cust-result:hover { background: var(--surface-2); }
.cust-result .cr-name { font-size: .92rem; font-weight: 600; }
.cust-result .cr-sub { font-size: .76rem; color: var(--text-faint); margin-top: .1rem; }
.cust-result .cr-go { color: var(--text-faint); }
.cust-result .cr-go svg { width: 16px; height: 16px; }

/* ── Customer: scorecard ────────────────────────────────── */
.sc-back { display: inline-flex; align-items: center; gap: .3rem; color: var(--text-dim); background: none; border: none; cursor: pointer; font-size: .85rem; font-weight: 600; padding: .2rem 0; margin-bottom: .6rem; }
.sc-back svg { width: 16px; height: 16px; }
.sc-name { font-size: 1.4rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.sc-tag { font-size: .8rem; color: var(--text-dim); margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .35rem .6rem; }
.sc-tag .dot { color: var(--text-faint); }
.sc-rep { font-size: .78rem; color: var(--text-faint); margin-top: .25rem; }

.sc-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: 1.1rem 0; }
.sc-act { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .7rem .2rem; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); cursor: pointer; color: var(--text); }
.sc-act:hover { border-color: var(--accent); color: var(--accent); }
.sc-act svg { width: 20px; height: 20px; }
.sc-act span { font-size: .68rem; font-weight: 600; }

.sc-section { margin: 1.4rem 0; }
.sc-section-title { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: .6rem; display: flex; align-items: center; justify-content: space-between; }

/* chart */
.chart-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 1rem; }
.chart-hero-val { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.chart-hero-sub { font-size: .8rem; color: var(--text-dim); margin-top: .1rem; }
.chart-delta.up { color: var(--positive); } .chart-delta.down { color: var(--negative); }
.chart-svg { width: 100%; height: 120px; display: block; margin: .6rem 0 .4rem; overflow: visible; }
.chart-ranges { display: flex; gap: .3rem; }
.chart-ranges button { flex: 1; border: none; background: var(--surface-2); color: var(--text-dim); border-radius: 8px; padding: .4rem; font-size: .78rem; font-weight: 700; cursor: pointer; }
.chart-ranges button.active { background: var(--accent); color: var(--on-accent); }

/* placements */
.pl-row { display: flex; align-items: center; gap: .6rem; padding: .65rem .2rem; border-bottom: 1px solid var(--border-soft); }
.pl-main { flex: 1; min-width: 0; }
.pl-name { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-meta { font-size: .73rem; color: var(--text-faint); margin-top: .1rem; }
.pl-pill { font-size: .64rem; font-weight: 700; padding: .15rem .5rem; border-radius: var(--pill); white-space: nowrap; flex-shrink: 0; }
.pl-pill.active { background: color-mix(in srgb, var(--positive) 18%, transparent); color: var(--positive); }
.pl-pill.risk { background: color-mix(in srgb, var(--negative) 16%, transparent); color: var(--negative); }
.pl-pill.lost, .pl-pill.disc { background: var(--surface-2); color: var(--text-faint); }
.sc-more { background: none; border: none; color: var(--accent); font-size: .82rem; font-weight: 600; cursor: pointer; padding: .6rem 0; }

/* recs / activity */
.rec-row, .inv-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .65rem .2rem; border-bottom: 1px solid var(--border-soft); }
.rec-name { font-size: .88rem; font-weight: 600; }
.rec-sub, .inv-sub { font-size: .73rem; color: var(--text-faint); margin-top: .1rem; }
.inv-amt { font-size: .9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.inv-uom { font-size: .7rem; font-weight: 600; color: var(--text-faint); letter-spacing: .02em; }
.sc-loading { color: var(--text-faint); font-size: .85rem; padding: .8rem .2rem; }
.sc-empty { color: var(--text-faint); font-size: .85rem; padding: .8rem .2rem; }

/* notes */
.note-tools { display: flex; gap: .5rem; margin-bottom: .7rem; }
.note-search { flex: 1; border: 1.5px solid var(--border); background: var(--bg); color: var(--text); border-radius: 10px; padding: .5rem .7rem; font-size: .85rem; font-family: inherit; outline: none; }
.note-search:focus { border-color: var(--accent); }
.note-add { background: var(--accent); color: var(--on-accent); border: none; border-radius: 10px; padding: 0 .9rem; font-size: .82rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.note-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 12px; padding: .7rem .8rem; margin-bottom: .5rem; }
.note-head { display: flex; align-items: center; gap: .5rem; font-size: .73rem; color: var(--text-faint); margin-bottom: .25rem; }
.note-type { font-weight: 700; color: var(--accent); text-transform: capitalize; }
.note-body { font-size: .87rem; line-height: 1.45; }
.note-tags { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.note-tag { font-size: .66rem; background: var(--surface-2); color: var(--text-dim); border-radius: var(--pill); padding: .1rem .45rem; }

/* ── Customer chart: plot interactions ──────────────────── */
.chart-plot { position: relative; }
.chart-marker { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent); opacity: .5; display: none; pointer-events: none; transform: translateX(-0.5px); }
.chart-tip {
  position: absolute; top: -4px; transform: translateX(-50%);
  background: var(--elevated); border: 1px solid var(--border); border-radius: 9px;
  padding: .25rem .55rem; font-size: .72rem; display: none; flex-direction: column;
  align-items: center; box-shadow: var(--shadow-sm); pointer-events: none; white-space: nowrap; z-index: 3;
}
.chart-tip strong { font-size: .82rem; }
.chart-tip span { color: var(--text-faint); }
.chart-xaxis { display: flex; justify-content: space-between; font-size: .64rem; color: var(--text-faint); margin: .35rem 0 .1rem; }

/* ── Home dashboard ─────────────────────────────────────── */
.brief-btn {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  background: var(--accent); color: var(--on-accent); border: none;
  border-radius: var(--radius); padding: .9rem 1rem; cursor: pointer;
  font-size: .98rem; font-weight: 800; margin-bottom: 1.3rem; box-shadow: var(--shadow-sm);
}
.brief-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.brief-btn .sub { font-size: .75rem; font-weight: 500; opacity: .85; margin-top: .1rem; }

.seg-toggle { display: flex; gap: .3rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; margin-bottom: .7rem; }
.seg-toggle button { flex: 1; border: none; background: none; color: var(--text-dim); border-radius: 8px; padding: .45rem; font-size: .78rem; font-weight: 700; cursor: pointer; }
.seg-toggle button.active { background: var(--accent); color: var(--on-accent); }

.mv-group-label { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: .7rem 0 .1rem; }
.dash-mv-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem .2rem; border-bottom: 1px solid var(--border-soft); }
.mv-name { font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-sub { font-size: .72rem; color: var(--text-faint); margin-top: .1rem; }
.mv-delta { font-size: .84rem; font-weight: 700; white-space: nowrap; }
.mv-delta.up { color: var(--positive); }
.mv-delta.down { color: var(--negative); }

.idx-row { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .55rem .2rem; border-bottom: 1px solid var(--border-soft); }
.idx-name { font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idx-sub { font-size: .72rem; color: var(--text-faint); margin-top: .1rem; }
.idx-badge { font-size: .9rem; font-weight: 800; white-space: nowrap; }
.idx-badge.under { color: var(--accent); }
.idx-badge.over { color: var(--positive); }

.inc-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .2rem; border-bottom: 1px solid var(--border-soft); }
.inc-date { font-size: .78rem; font-weight: 700; color: var(--text-dim); white-space: nowrap; }

/* ── Collapsible dashboard sections ─────────────────────── */
.sc-collapse-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; cursor: pointer; padding: 0 0 .6rem; color: inherit;
}
.sc-collapse-head span {
  font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim);
}
.sc-chev { width: 18px; height: 18px; color: var(--text-faint); transition: transform .2s var(--ease); flex-shrink: 0; }
.sc-chev.rot { transform: rotate(-90deg); }
.sc-collapse-body { overflow: hidden; transition: max-height .25s var(--ease); max-height: 1600px; }
.sc-collapse-body.collapsed { max-height: 0; }

.note-live { margin-left: auto; font-size: .64rem; font-weight: 700; color: var(--accent); }
.note-mgr { font-size: .6rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  background: #6c4cd1; color: #fff; border-radius: var(--pill); padding: .08rem .4rem; }
.note-mgr.note-rep { background: var(--accent); color: var(--on-accent); }  /* REP badge: brand accent */
.note-by { font-size: .66rem; font-weight: 700; color: var(--text-dim); }   /* who submitted it */
.note-loc { font-size: .58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  background: var(--surface-2); color: var(--text-dim); border-radius: var(--pill); padding: .08rem .4rem; }
/* User Notes inbox filter bar (search + reps/managers toggle). */
.un-filters { display: flex; gap: .5rem; align-items: center; margin: 0 0 .6rem; flex-wrap: wrap; }
.un-filters .note-search { flex: 1; min-width: 150px; }
.un-seg { flex: 0 0 auto; }
/* User Notes — reply threads */
.mn-reply-row { margin-top: .5rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.mn-reply-btn { background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: .2rem .6rem; font-size: .76rem; font-weight: 700; cursor: pointer; }
.mn-bubbles-btn { background: var(--accent); color: var(--on-accent); border: none;
  border-radius: 8px; padding: .2rem .6rem; font-size: .76rem; font-weight: 700; cursor: pointer; }
.mn-bubbles-btn:hover { filter: brightness(1.05); }
.mn-reply-btn:hover { color: var(--text); border-color: var(--text-dim); }
.mn-thread { margin-top: .5rem; }
.mn-replies-toggle { background: none; border: none; color: var(--accent); font-size: .76rem;
  font-weight: 700; cursor: pointer; padding: .15rem 0; display: inline-flex; align-items: center; gap: .35rem; }
.mn-replies-toggle .mn-caret { transition: transform .15s; display: inline-block; }
.mn-replies-toggle.open .mn-caret { transform: rotate(90deg); }
.mn-newdot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }
.mn-replies { margin: .4rem 0 .2rem; padding-left: .6rem; border-left: 2px solid var(--border);
  flex-direction: column; gap: .4rem; display: none; }   /* collapsed by default */
.mn-replies.open { display: flex; }
.mn-reply { background: var(--surface-2); border-radius: 8px; padding: .35rem .55rem; }
.mn-reply.mine { background: var(--surface); border: 1px solid var(--accent); }
.mn-reply-head { font-size: .66rem; font-weight: 700; color: var(--text-dim); margin-bottom: .15rem; }
.mn-reply-body { font-size: .84rem; color: var(--text); }
/* Markdown bodies (Bubbles replies can carry tables) — tighten paragraph spacing. */
.mn-msg p, .mn-reply-body p { margin: 0 0 .4rem; }
.mn-msg p:last-child, .mn-reply-body p:last-child { margin-bottom: 0; }
.mn-reply-body .md-tablewrap { margin: .25rem 0; }
.mn-reply-composer { margin-top: .5rem; margin-bottom: .25rem; }
/* Tracked rep tasks */
.note-status.st-task { background: #e67e2233; color: #e67e22; }
.mn-task { margin-top: .5rem; font-size: .82rem; color: var(--text); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.mn-task.done { color: #2ecc71; font-weight: 700; }
.mn-task-bar { flex: 1; min-width: 90px; height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.mn-task-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.mn-task-done { background: #2ecc71; color: #07210f; border: none; border-radius: 8px; padding: .25rem .7rem; font-size: .78rem; font-weight: 700; cursor: pointer; }
.mn-task-due { font-size: .72rem; color: var(--text-dim); }
.gd-track { font-size: .78rem; color: var(--text-dim); margin: .15rem 0 .1rem; }
/* Inline "+ Add" note composer on the account card (deterministic rep account note). */
.note-composer { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: .55rem; margin: 0 0 .5rem; }
.note-composer-body { width: 100%; box-sizing: border-box; resize: vertical; border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .55rem; font: inherit; font-size: .86rem; background: var(--surface); color: var(--text); }
.note-composer-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .45rem; }
.note-composer-cancel { background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; padding: .25rem .7rem; font-size: .8rem; font-weight: 700; cursor: pointer; }
.note-composer-send { background: var(--accent); color: var(--on-accent); border: none; border-radius: 8px;
  padding: .25rem .8rem; font-size: .8rem; font-weight: 700; cursor: pointer; }
.note-composer-status { font-size: .74rem; color: var(--text-dim); margin-top: .3rem; min-height: 1em; }
.note-status { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  border-radius: var(--pill); padding: .08rem .4rem; background: var(--surface-2); color: var(--text-dim); }
.note-status.st-open { background: #e67e2233; color: #e67e22; }
.note-status.st-completed { background: #2ecc7133; color: #2ecc71; }
.note-result { margin-top: .25rem; font-size: .76rem; color: var(--text-dim); font-style: italic; }
.note-prod { font-size: .66rem; background: var(--surface-2); color: var(--text-dim); border-radius: var(--pill); padding: .1rem .45rem; }

/* ── Manager Notes review screen ──────────────────────────────────────────── */
.mn-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px;
  padding: .9rem 1rem; margin-bottom: .8rem; }
.mn-title { font-weight: 800; display: flex; align-items: center; gap: .5rem; }
.mn-exp { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  background: #e67e2233; color: #e67e22; border-radius: var(--pill); padding: .08rem .45rem; }
.mn-msg { margin: .5rem 0 .6rem; color: var(--text); line-height: 1.45; }
.rn-edit { width: 100%; box-sizing: border-box; margin: .5rem 0 .2rem; padding: .5rem .6rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--border-soft);
  border-radius: 10px; font: inherit; line-height: 1.45; resize: vertical; }
.rn-edit:focus { border-color: var(--accent); outline: none; }
.mn-hint { font-size: .72rem; color: var(--text-faint); margin: 0 0 .6rem; }
.mn-aud { font-size: .85rem; color: var(--text-dim); margin-bottom: .7rem; }
.mn-expand { color: var(--accent); font-weight: 700; cursor: pointer; }
.mn-prev { color: var(--text-faint); }
.mn-byrep { margin-top: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.mn-rep { font-size: .8rem; }
.mn-rep-cust { color: var(--text-faint); font-size: .74rem; margin-top: .1rem; }
.mn-actions { display: flex; gap: .5rem; }
.mn-approve, .mn-reject { flex: 1; border: none; border-radius: 10px; padding: .55rem; font-weight: 700;
  font-size: .85rem; cursor: pointer; }
.mn-approve { background: var(--accent); color: var(--on-accent); }
.mn-reject { background: var(--surface-2); color: var(--text-dim); }
.mn-tabs { margin-bottom: 1rem; }
.cmp-stats { display: flex; gap: 1rem; align-items: center; font-size: .82rem; color: var(--text-dim); margin: .5rem 0 .4rem; }
.cmp-stats .up b { color: #2ecc71; }
.cmp-pct { margin-left: auto; font-weight: 800; color: var(--text); }
.cmp-bar { background: var(--surface-2); border-radius: var(--pill); height: 8px; overflow: hidden; margin-bottom: .5rem; }
.cmp-bar-fill { background: #2ecc71; height: 100%; border-radius: var(--pill); }

/* campaign status tags (active = green, expired = muted/red, draft = amber) */
.note-status.st-active    { background: #2ecc7133; color: #2ecc71; }
.note-status.st-expired   { background: var(--surface-2); color: var(--text-faint); }
.note-status.st-draft     { background: #e67e2233; color: #e67e22; }
.note-status.st-new       { background: var(--accent); color: var(--on-accent); }
.note-status.st-cat       { background: var(--surface-2); color: var(--text-dim); }

/* ── Manager Notes: rep-facing log + home banner (§0.19 Phase 2b) ─────────── */
.mgr-note-bar { display: flex; align-items: center; gap: .6rem; width: 100%;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border-soft));
  border-radius: 14px; padding: .7rem .9rem; margin-bottom: 1rem; text-decoration: none;
  font-size: .9rem; }
.mgr-note-bar svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent); }
.mgr-note-bar span { flex: 1; }
.mgr-note-bar b { color: var(--accent); }
.mn-by { color: var(--text-dim); font-weight: 600; font-size: .82rem; }
.mn-when { margin-left: auto; color: var(--text-faint); font-weight: 500; font-size: .75rem; }
.mn-focus { font-size: .78rem; color: var(--text-dim); margin-top: .1rem; }
.mn-from { font-size: .76rem; color: var(--text-faint); font-style: italic; margin-top: .4rem; }
.mn-cust-link { font-weight: 800; color: var(--accent); text-decoration: none; }
.mn-unread { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-soft));
  box-shadow: inset 3px 0 0 var(--accent); }
.tool-ic { position: relative; }
.tool-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px;
  padding: 0 4px; border-radius: 9px; background: #e74c3c; color: #fff; font-size: .68rem;
  font-weight: 800; display: flex; align-items: center; justify-content: center; }

/* ── Campaign Manager: Builder tab (embedded chat) ───────────────────────── */
.cm-suggest { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.cm-chip { font-size: .76rem; background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border-soft);
  border-radius: var(--pill); padding: .35rem .7rem; cursor: pointer; text-align: left; }
.cm-chip:hover { color: var(--text); border-color: var(--accent); }
.cm-chat { min-height: 38vh; max-height: 56vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: 14px; padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.cm-welcome { color: var(--text-dim); font-size: .9rem; line-height: 1.5; margin: auto 0; }
.cm-b { max-width: 88%; padding: .55rem .8rem; border-radius: 14px; font-size: .9rem; line-height: 1.45; word-wrap: break-word; }
.cm-b.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 5px; }
.cm-b.assistant { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 5px; }
.cm-b.devnote { align-self: center; background: #2ecc7122; color: #2ecc71; font-size: .8rem; font-weight: 700; }
.cm-b.assistant table { width: 100%; font-size: .8rem; border-collapse: collapse; margin: .3rem 0; }
.cm-b.assistant th, .cm-b.assistant td { text-align: left; padding: .2rem .35rem; border-bottom: 1px solid var(--border-soft); }
/* sticky just above the fixed bottom tab bar so the box never hides behind it as it grows */
.cm-inputrow { display: flex; gap: .5rem; align-items: flex-end; margin-top: .6rem;
  position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + .5rem);
  background: var(--bg); padding-top: .5rem; z-index: 5; }
.cm-input { flex: 1; resize: none; border: 1px solid var(--border-soft); border-radius: 12px; padding: .6rem .8rem;
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }
.cm-send { flex-shrink: 0; width: 42px; height: 42px; border: none; border-radius: 50%; background: var(--accent);
  color: var(--on-accent); font-size: 1.2rem; font-weight: 700; cursor: pointer; }
.cm-send:disabled { opacity: .5; }
.cm-sec { font-weight: 800; font-size: .8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;
  margin: 1rem 0 .5rem; }

/* ── Tools landing grid ───────────────────────────────────────────────── */
.tools-wrap { padding: 1rem 1rem 2rem; }
.tools-h { font-size: 1.5rem; font-weight: 700; margin: .25rem 0 .15rem; }
.tools-sub { color: var(--text-dim); margin: 0 0 1.25rem; font-size: .92rem; line-height: 1.45; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: .5rem;
  padding: 1rem; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: transform .12s ease, border-color .12s ease;
}
.tool-card:active { transform: scale(.98); }
.tool-card:not(.disabled):hover { border-color: var(--accent); }
.tool-card.disabled { opacity: .55; pointer-events: none; }
.tool-ic {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.tool-ic svg { width: 22px; height: 22px; }
.tool-name { font-weight: 650; font-size: 1rem; }
.tool-desc { color: var(--text-dim); font-size: .8rem; line-height: 1.4; }
.tool-soon {
  position: absolute; top: .8rem; right: .8rem; font-size: .62rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 999px; padding: .12rem .45rem;
}

/* ── Product Expert detail ────────────────────────────────────────────── */
.pe-attrs { display: flex; flex-direction: column; gap: .1rem; }
.pe-attr { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border-soft); }
.pe-attr:last-child { border-bottom: none; }
.pe-attr-k { color: var(--text-dim); font-size: .85rem; }
.pe-attr-v { font-weight: 550; text-align: right; }
.pe-price-row, .pe-attr { font-size: .92rem; }
.pe-price-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--border-soft); }
.pe-price-row:last-child { border-bottom: none; }
.pe-price-amt { font-weight: 700; white-space: nowrap; }
.pe-price-amt span { font-weight: 500; color: var(--text-faint); font-size: .8em; }
.pe-unit { color: var(--text-dim) !important; font-weight: 500 !important; }

/* ── Ask the Expert ───────────────────────────────────────────────────── */
.pe-ask { }
.pe-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .7rem; }
.pe-chip {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: .42rem .8rem; font-size: .82rem; font-weight: 550; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.pe-chip:hover { border-color: var(--accent); }
.pe-chip:active { background: var(--accent-soft); }
.pe-askbox { display: flex; gap: .5rem; align-items: center; }
.pe-askbox input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: .7rem 1rem; font-size: .92rem; outline: none;
}
.pe-askbox input:focus { border-color: var(--accent); }
.pe-ask-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #1a1206; display: grid; place-items: center;
}
.pe-ask-btn svg { width: 20px; height: 20px; }
.pe-answer { margin-top: .9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.pe-answer-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .5rem; }
.pe-q { font-weight: 650; font-size: .9rem; color: var(--text-dim); }
.pe-cached { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); border: 1px solid var(--border); border-radius: 999px; padding: .1rem .4rem; }
.pe-md { font-size: .92rem; line-height: 1.5; }
.pe-md p { margin: .4rem 0; }
.pe-md ul, .pe-md ol { margin: .4rem 0; padding-left: 1.2rem; }
.pe-md strong { font-weight: 650; }
.pe-md h1, .pe-md h2, .pe-md h3 { font-size: 1rem; margin: .6rem 0 .3rem; }
.pe-thinking { color: var(--text-dim); font-size: .9rem; display: flex; align-items: center; gap: .35rem; }
.pe-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; animation: peblink 1.2s infinite both; }
.pe-dot:nth-child(2) { animation-delay: .2s; }
.pe-dot:nth-child(3) { animation-delay: .4s; }
@keyframes peblink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.pe-sources { margin-top: .8rem; padding-top: .6rem; border-top: 1px solid var(--border-soft); }
.pe-sources-t { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: .4rem; }
.pe-source { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
  margin: 0 .35rem .35rem 0; padding: .3rem .6rem; font-size: .78rem; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; text-decoration: none; }

/* ── Devnote Log (DDM) ───────────────────────────────────── */
.dn-wrap { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.dn-summary { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.dn-fchip { display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .7rem; border-radius: 999px;
  font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--muted, #9aa);
  background: transparent; border: 1px solid var(--border); }
.dn-fchip:hover { background: rgba(255,255,255,.03); }
.dn-fchip .dn-fcount { font-size: .72rem; padding: .02rem .4rem; border-radius: 999px; background: rgba(255,255,255,.06); }
.dn-fchip.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.dn-fchip.active .dn-fcount { background: rgba(224,176,88,.22); color: var(--accent); }

.dn-pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .72rem;
  font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.dn-new        { background: rgba(224,176,88,.16); color: var(--accent); }
.dn-in_process { background: rgba(88,150,224,.16); color: #6db0ff; }
.dn-resolved   { background: rgba(80,200,120,.16); color: #5fd08a; }
.dn-future_feature { background: rgba(168,130,224,.16); color: #b79cf0; }
.dn-ignored    { background: rgba(150,150,160,.16); color: #aab; }

.dn-list { display: flex; flex-direction: column; gap: .5rem; }
.dn-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dn-row { display: flex; align-items: flex-start; gap: .6rem; width: 100%; text-align: left;
  background: none; border: 0; color: inherit; padding: .8rem .9rem; cursor: pointer; font: inherit; }
.dn-row:hover { background: rgba(255,255,255,.02); }
.dn-caret { flex-shrink: 0; width: 18px; height: 18px; margin-top: .15rem; color: var(--muted, #9aa);
  transition: transform .15s ease; }
.dn-row.open .dn-caret { transform: rotate(90deg); }
.dn-caret svg { width: 100%; height: 100%; }
.dn-main { display: flex; flex-direction: column; gap: .3rem; min-width: 0; flex: 1; }
.dn-line1 { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.dn-sub { font-size: .82rem; color: var(--muted, #9aa); }
.dn-preview { font-size: .92rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dn-row.open .dn-preview { -webkit-line-clamp: unset; }
.dn-muted { color: var(--muted, #9aa); font-style: italic; }
.dn-prb { display: inline-block; padding: .1rem .45rem; border-radius: 6px; font-size: .72rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); }

.dn-details { padding: 0 .9rem 1rem 2.3rem; border-top: 1px solid var(--border); }
.dn-d-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted, #9aa);
  margin: .9rem 0 .25rem; }
.dn-d-text { font-size: .9rem; line-height: 1.5; }
.dn-d-res { color: #5fd08a; }
.dn-prob { margin-top: .5rem; padding: .6rem .7rem; background: rgba(255,255,255,.02);
  border: 1px solid var(--border); border-radius: 10px; }
.dn-prob-head { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.dn-prob-title { font-weight: 600; }
.dn-prob-desc { margin-top: .35rem; font-size: .86rem; line-height: 1.5; color: var(--muted, #cbd); white-space: normal; }

/* PRB-centric layout */
.dn-ptitle { font-weight: 600; }
.dn-section-h { display: flex; align-items: baseline; gap: .5rem; margin: .4rem 0 .5rem; font-size: .8rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.dn-section-hint { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: .76rem; color: var(--text-faint); }
.dn-inbox { border-left: 3px solid var(--accent); }
.dn-inbox .dn-note { padding: .7rem .9rem; }

/* a single devnote inside a PRB (or the inbox) */
.dn-note { padding: .6rem 0; border-bottom: 1px solid var(--border-soft); }
.dn-note:last-child { border-bottom: 0; }
.dn-note-head { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; margin-bottom: .25rem; }
.dn-dn { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px;
  background: rgba(255,255,255,.06); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.dn-note-text { font-size: .9rem; line-height: 1.45; }

/* Ignored bucket — pinned to the bottom, dimmed and out of the active flow */
.dn-ignored-wrap { margin-top: 1.6rem; padding-top: .4rem; border-top: 1px dashed var(--border); opacity: .6; }
.dn-section-muted { color: var(--text-faint); }
.dn-ignored-item { background: transparent; border-style: dashed; }

/* ── Ops console ─────────────────────────────────────────────────────────── */
.ops-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin: .2rem 0 1.4rem; }
.ops-kpi { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: .7rem .8rem; }
.ops-kpi.wide { grid-column: 1 / -1; }
.ops-kpi .k-label { font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.ops-kpi .k-val { font-size: 1.5rem; font-weight: 800; margin-top: .15rem; line-height: 1.1; }
.ops-kpi .k-sub { font-size: .72rem; color: var(--text-dim); margin-top: .15rem; }

.ops-bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin: .3rem 0 .2rem; }
.ops-bar { flex: 1; background: var(--accent); opacity: .68; border-radius: 2px 2px 0 0; min-height: 2px; position: relative; transition: opacity .12s var(--ease); }
.ops-bar:hover { opacity: 1; }
.ops-bars-x { display: flex; justify-content: space-between; font-size: .64rem; color: var(--text-faint); margin-bottom: 1rem; }

.ops-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.ops-table th { text-align: right; font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: .4rem .35rem; border-bottom: 1px solid var(--border-soft); }
.ops-table th:first-child, .ops-table td:first-child { text-align: left; }
.ops-table td { padding: .5rem .35rem; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.ops-table .r-name { font-weight: 600; }
.ops-table .r-role { font-size: .68rem; color: var(--text-faint); }
.ops-err { color: var(--negative); font-weight: 700; }
.ops-note { font-size: .8rem; color: var(--text-faint); padding: .7rem .2rem; line-height: 1.5; }

/* ── Customer Expert ─────────────────────────────────────────────────────── */
.ce-capture { display: flex; flex-direction: column; align-items: center; gap: .3rem; cursor: pointer;
  border: 1.5px dashed var(--border-soft); border-radius: var(--radius-sm); padding: 1.1rem; margin-bottom: 1rem;
  background: var(--surface); color: var(--text-dim); text-align: center; }
.ce-capture svg { width: 30px; height: 30px; color: var(--accent); }
.ce-capture span:nth-of-type(1) { font-weight: 700; font-size: .95rem; color: var(--text); }
.ce-cap-hint { font-size: .72rem; color: var(--text-faint); }
.ce-scan { display: flex; align-items: center; gap: .5rem; color: var(--text-dim); font-size: .85rem; padding: .8rem .2rem; }

.ce-review-head { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin: .4rem 0 .5rem; }
.ce-rh-hint { display: block; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-faint); font-size: .72rem; margin-top: .15rem; }
.ce-row { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; padding: .55rem .6rem; margin-bottom: .5rem; }
.ce-row.ce-low { border-color: var(--accent); }
.ce-row-top { display: flex; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.ce-name { flex: 1; font-size: .9rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 7px; padding: .35rem .5rem; color: var(--text); }
.ce-del { flex-shrink: 0; width: 28px; height: 28px; border: none; border-radius: 7px; background: var(--surface-2); color: var(--text-faint); cursor: pointer; }
.ce-row-bot { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.ce-sel { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 7px; padding: .3rem .4rem; color: var(--text); font-size: .78rem; }
.ce-ck { flex: 1; min-width: 90px; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 7px; padding: .3rem .45rem; color: var(--text); font-size: .78rem; }
.ce-match { font-size: .68rem; font-weight: 800; border-radius: 6px; padding: .25rem .45rem; border: none; }
.ce-match.yes { background: rgba(90,180,120,.16); color: var(--positive); cursor: pointer; }
.ce-match.no { background: var(--surface-2); color: var(--text-faint); }
.ce-actions { display: flex; gap: .5rem; margin: .7rem 0 1.2rem; }
.ce-save { flex: 1; background: var(--accent); color: var(--on-accent); border: none; border-radius: 10px; padding: .65rem; font-weight: 800; cursor: pointer; }
.ce-save:disabled { opacity: .5; }
.ce-cancel { background: var(--surface-2); color: var(--text-dim); border: none; border-radius: 10px; padding: .65rem .9rem; font-weight: 700; cursor: pointer; }
.ce-saved { color: var(--positive); font-weight: 700; font-size: .9rem; padding: .6rem .2rem 1rem; }

.ce-intel-head { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin: .6rem 0 .5rem; }
.ce-tag { font-size: .6rem; font-weight: 800; border-radius: 5px; padding: .12rem .35rem; }
.ce-tag.ours { background: rgba(90,180,120,.16); color: var(--positive); }
.ce-tag.comp { background: var(--surface-2); color: var(--text-faint); }
.ce-ck-tag { font-size: .68rem; color: var(--text-faint); font-style: italic; }

/* Customer Expert link on the scorecard */
.sc-ce-link { display: flex; align-items: center; gap: .6rem; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: .7rem .8rem; margin: .2rem 0 1rem; color: var(--text); }
.sc-ce-link > svg:first-child { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
.sc-ce-main { flex: 1; font-weight: 700; font-size: .9rem; display: flex; flex-direction: column; }
.sc-ce-sub { font-weight: 500; font-size: .72rem; color: var(--text-faint); margin-top: .1rem; }
.sc-ce-go { width: 18px; height: 18px; color: var(--text-faint); flex-shrink: 0; }

/* ── Gmail draft confirmation card (chat) ──────────────────────────────── */
.gmail-draft { align-self: stretch; max-width: 92%; margin: .35rem 0 .9rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: .85rem .9rem; display: flex; flex-direction: column; gap: .5rem; }
.gd-head { font-weight: 700; font-size: .9rem; color: var(--text); }
.gd-row { display: flex; flex-direction: column; gap: .2rem; font-size: .72rem;
  color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.gd-row input, .gd-body { width: 100%; box-sizing: border-box; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; padding: .55rem .65rem;
  color: var(--text); font-size: .9rem; font-family: inherit; }
.gd-body { resize: vertical; line-height: 1.45; }
.gd-row input:focus, .gd-body:focus { outline: none; border-color: var(--accent); }
.gd-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .15rem; }
.gd-actions button { border-radius: 999px; padding: .55rem 1.1rem; font-weight: 700;
  font-size: .85rem; border: 1px solid var(--border); cursor: pointer; }
.gd-cancel { background: transparent; color: var(--text-dim); }
.gd-send { background: var(--accent); color: #1b1206; border-color: var(--accent); }
.gd-send:disabled { opacity: .55; cursor: default; }
.gd-status { font-size: .78rem; color: var(--text-dim); min-height: 1em; }
.gd-sent .gd-head { color: var(--accent); }
.gd-sent-to { font-size: .82rem; color: var(--text-dim); }

/* ── Brief Text Replies toggle (Settings) ──────────────────────────────── */
.setting-toggle { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; cursor: pointer; }
.setting-toggle-text { display: flex; flex-direction: column; }
.setting-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.setting-toggle .switch { flex-shrink: 0; width: 46px; height: 27px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); position: relative;
  transition: background .15s ease, border-color .15s ease; }
.setting-toggle .switch::after { content: ""; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%; background: var(--text-faint);
  transition: transform .15s ease, background .15s ease; }
.setting-toggle input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.setting-toggle input:checked + .switch::after { transform: translateX(19px); background: #1b1206; }

/* ── Conversational Mode active glow on the Bubbles fab ─────────────────── */
.ai-fab.conv-on { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 16px 2px var(--accent);
  animation: convPulse 2s ease-in-out infinite; }
@keyframes convPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 14px 1px var(--accent); }
  50%      { box-shadow: 0 0 0 4px var(--accent-soft), 0 0 22px 4px var(--accent); }
}
.tab-center .tab-label { transition: color .15s ease; }
.ai-fab.conv-on + .tab-label, #aiFabLabel:not(:empty) { /* label updates via JS */ }

/* ── Wide screens: dock Bubbles as a permanent right rail (iPad landscape / desktop) ── */
@media (min-width: 1024px) {
  /* Rail scales with the viewport (wider Bubbles) instead of a fixed 400px. */
  :root { --rail: clamp(400px, 36vw, 600px); }
  /* Reserve the rail for the docked pane. */
  body { padding-right: var(--rail); }
  /* Let the page fill the left region instead of a narrow column floating in space. */
  .shell { max-width: none; }
  .content { padding-left: clamp(1rem, 4vw, 3rem); padding-right: clamp(1rem, 4vw, 3rem); }
  /* Bubbles becomes an always-on right column instead of a bottom slide-up sheet. */
  .ai-sheet {
    left: auto; right: 0; top: 0; bottom: 0;
    transform: none !important;            /* always visible, regardless of .open */
    width: var(--rail); max-width: var(--rail); height: 100dvh;
    border-radius: 0; border: 0; border-left: 1px solid var(--border);
    box-shadow: none; transition: none; z-index: 60;
  }
  .ai-sheet .sheet-handle-wrap { display: none; }      /* no drag-to-dismiss when docked */
  .ai-sheet .sheet-head .icon-btn { display: none; }   /* no close button on a permanent pane */
  /* Keep the tab bar + backdrop in the left region (not under the rail). */
  .tabbar { left: 0; right: var(--rail); transform: none; margin: 0 auto; max-width: var(--maxw); width: auto; }
  .backdrop { right: var(--rail); }
  /* Avatar menu was pinned to the viewport edge (hidden behind Bubbles) — move it
     left of the rail and above it. */
  .menu-pop { right: calc(var(--rail) + 12px); z-index: 90; }
}

/* ── Manager home: team leaderboard ──────────────────────────────────────── */
.mgr-summary { display: flex; gap: .6rem; margin: .2rem 0 1rem; }
.mgr-sum-cell { flex: 1; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: .7rem .6rem; text-align: center; }
.mgr-sum-val { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.mgr-sum-val.up { color: #2ecc71; } .mgr-sum-val.down { color: #e74c3c; }
.mgr-sum-lbl { font-size: .68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin-top: .15rem; }
.mgr-locwrap { display: flex; align-items: center; gap: .5rem; margin: 0 0 .8rem; }
.mgr-loclbl { font-size: .72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.mgr-locsel { flex: 1; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: .55rem .7rem; font-size: .9rem; font-family: inherit; }
.mgr-collist-head { display: flex; justify-content: space-between; font-size: .68rem; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .05em; padding: 0 .3rem .35rem; }
.mgr-replist { display: flex; flex-direction: column; gap: .5rem; }
.mgr-rep { display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: .7rem .8rem; text-decoration: none; color: var(--text); }
.mgr-rep:active { background: var(--surface-2); }
.mgr-rep-name { font-weight: 700; font-size: .95rem; }
.mgr-rep-loc { font-size: .72rem; color: var(--text-faint); margin-top: .05rem; }
.mgr-rep-stats { display: flex; gap: .7rem; margin-top: .4rem; flex-wrap: wrap; }
.mgr-stat { font-size: .74rem; color: var(--text-dim); display: inline-flex; align-items: center; gap: .25rem; }
.mgr-stat b { font-weight: 700; color: var(--text-faint); font-size: .66rem; }
.mgr-chip { font-weight: 700; font-size: .74rem; padding: .05rem .35rem; border-radius: 6px; }
.mgr-chip.up { color: #2ecc71; background: rgba(46,204,113,.12); }
.mgr-chip.down { color: #e74c3c; background: rgba(231,76,60,.12); }
.mgr-chip.flat { color: var(--text-faint); }
.mgr-rep-dials { display: flex; gap: .4rem; flex-shrink: 0; }
.mgr-dial { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-weight: 800; font-size: .9rem;
  color: hsl(var(--h), 65%, 42%); background: hsla(var(--h), 70%, 50%, .14); }
.mgr-empty { color: var(--text-dim); font-size: .85rem; padding: 1rem .3rem; }

/* ── Sales Rep Expert ────────────────────────────────────────────────────── */
.rx-back { display: inline-block; color: var(--text-dim); text-decoration: none; font-size: .85rem; margin: 0 0 .4rem; }
.rx-head h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.rx-loc { color: var(--text-dim); font-size: .85rem; margin-top: .1rem; }
.rx-hero { display: flex; gap: .6rem; margin: 1rem 0 1.4rem; flex-wrap: wrap; }
.rx-stat { flex: 1; min-width: 120px; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: .8rem .7rem; text-align: center; }
.rx-stat-val { font-size: 1.25rem; font-weight: 800; }
.rx-stat-lbl { font-size: .7rem; color: var(--text-dim); margin-top: .25rem; }
.rx-section { margin: 1.4rem 0; }
.rx-sec-title { font-weight: 800; font-size: 1rem; margin-bottom: .6rem; }
/* Coaching Profile (manager-only) */
.rx-coach { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 14px; padding: 1rem; }
.rx-coach-priv { font-size: .68rem; font-weight: 600; color: var(--text-faint); text-transform: none; margin-left: .4rem; }
.rx-coach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 560px) { .rx-coach-grid { grid-template-columns: 1fr; } }
.rx-coach-fld { display: flex; flex-direction: column; font-size: .72rem; font-weight: 700; color: var(--text-dim); gap: .25rem; }
.rx-coach-fld textarea, .rx-cg-txt, .rx-cg-add input { width: 100%; box-sizing: border-box; background: var(--bg);
  color: var(--text); border: 1px solid var(--border-soft); border-radius: 9px; padding: .45rem .55rem; font: inherit; resize: vertical; }
.rx-coach-fld textarea:focus, .rx-cg-txt:focus, .rx-cg-add input:focus { border-color: var(--accent); outline: none; }
.rx-coach-save, .rx-coach-suggest, .rx-cg-add button, .rx-cg-acc { margin-top: .6rem; padding: .45rem .8rem; border-radius: 9px;
  border: 1px solid var(--border-soft); background: var(--bg); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.rx-coach-suggest { color: var(--accent); }
.rx-coach-hint { font-size: .72rem; color: var(--text-faint); margin: .2rem 0 .5rem; }
.rx-cg-item, .rx-cg-sug { display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.rx-cg-sug { font-size: .86rem; }
.rx-cg-sug span { flex: 1; }
.rx-cg-src { flex-shrink: 0; }
.rx-cg-rm { flex-shrink: 0; background: transparent; border: none; color: var(--text-faint); cursor: pointer; font-size: 1rem; }
.rx-cg-add { display: flex; gap: .4rem; margin-top: .5rem; }
.rx-cg-add input { margin: 0; } .rx-cg-add button { margin: 0; }
.rx-cg-acc { margin: 0; padding: .3rem .6rem; font-size: .78rem; }
.rx-tbl { width: 100%; border-collapse: collapse; font-size: .8rem; }
.rx-tbl th { text-align: right; font-size: .64rem; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: .04em; padding: .3rem .35rem; border-bottom: 1px solid var(--border-soft); }
.rx-tbl th:first-child, .rx-tbl td:first-child { text-align: left; }
.rx-tbl td { text-align: right; padding: .45rem .35rem; border-bottom: 1px solid var(--border-soft); }
.rx-nm { font-weight: 600; }
.rx-tiles { display: flex; flex-wrap: wrap; gap: .5rem; }
.rx-tile { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border-soft);
  border-radius: var(--pill); padding: .55rem 1rem; font-weight: 700; font-size: .82rem; cursor: pointer; }
.rx-tile:disabled { opacity: .55; cursor: default; }
.rx-tiles-note { font-size: .74rem; color: var(--text-faint); margin-top: .5rem; }

/* ── Manager scoring explainer ───────────────────────────────────────────── */
.mgr-scoring { margin: 1.2rem 0 1rem; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: .2rem .9rem; }
.mgr-scoring summary { cursor: pointer; font-size: .82rem; font-weight: 700; color: var(--text-dim);
  padding: .6rem 0; list-style: none; }
.mgr-scoring summary::-webkit-details-marker { display: none; }
.mgr-scoring summary::before { content: "ⓘ "; color: var(--accent); }
.mgr-scoring-body { display: flex; flex-wrap: wrap; gap: 1.2rem; padding: .3rem 0 .8rem; }
.mgr-wcol { flex: 1; min-width: 200px; }
.mgr-wtitle { font-weight: 700; font-size: .82rem; margin-bottom: .4rem; }
.mgr-wtitle span { color: var(--text-faint); font-weight: 500; font-size: .72rem; }
.mgr-wlist { list-style: none; }
.mgr-wlist li { display: flex; justify-content: space-between; font-size: .78rem; color: var(--text-dim);
  padding: .22rem 0; border-bottom: 1px solid var(--border-soft); }
.mgr-wlist b { color: var(--text); }
.mgr-wnote { flex-basis: 100%; font-size: .74rem; color: var(--text-faint); line-height: 1.5; margin-top: .3rem; }

/* ── Rep Expert: AI tile output ──────────────────────────────────────────── */
.rx-tile.active { background: var(--accent); color: #1b1206; border-color: var(--accent); }
.rx-ai-out { margin-top: .9rem; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: .9rem 1rem; }
.rx-ai-loading { display: flex; align-items: center; gap: .5rem; color: var(--text-dim); font-size: .88rem; }
.rx-ai-err { color: #e74c3c; font-size: .88rem; }
.rx-ai-body { font-size: .9rem; line-height: 1.55; color: var(--text); }
.rx-ai-body p { margin: .4rem 0; }
.rx-ai-body ul, .rx-ai-body ol { margin: .4rem 0 .4rem 1.1rem; }
.rx-ai-body li { margin: .25rem 0; }
.rx-ai-body strong { font-weight: 700; }

/* ── Rep Expert: placements + movement (charts side-by-side) ─────────────── */
/* Two chart cards side-by-side on desktop, stacked on mobile. */
.rx-plc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; margin: 1.4rem 0; }
.rx-plc-col { min-width: 0; }
.rx-plc-col .rx-sec-title { margin-bottom: .8rem; }
@media (max-width: 720px) { .rx-plc-row { grid-template-columns: 1fr; gap: 1rem; } }

.rx-plc-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.rx-plc-total { font-weight: 500; font-size: .8rem; color: var(--text-dim); }
.rx-plc-toggle { flex-shrink: 0; }
.rx-plc-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.plc-tile { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: .6rem .4rem; text-align: center; }
.plc-ct { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.plc-lbl { font-size: .68rem; color: var(--text-dim); margin-top: .15rem; }
.plc-pct { font-size: .72rem; color: var(--text-faint); font-weight: 600; }
.rx-plc-lost { margin-top: .6rem; font-size: .8rem; color: var(--text-dim); }
.rx-plc-lost b { color: var(--text); font-weight: 700; }
/* donut */
.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex-shrink: 0; }
.donut-center { fill: var(--text); font-size: 8px; font-weight: 800; }
.donut-legend { display: flex; flex-direction: column; gap: .35rem; flex: 1; min-width: 140px; }
.donut-leg { font-size: .82rem; color: var(--text-dim); display: flex; align-items: center; gap: .4rem; }
.donut-leg b { color: var(--text); font-weight: 700; }
.donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-pct { color: var(--text-faint); margin-left: auto; }
@media (max-width: 380px) { .rx-plc-tiles { grid-template-columns: repeat(2, 1fr); } }

/* ── Rep Expert: placement movement (tiles + bars) ───────────────────────── */
/* .mv-row here belongs to the (in-progress) Rep Expert placement-movement tiles.
   The home dashboard Movers list uses its OWN class (.dash-mv-row) so the two never
   collide — this grid is free to evolve with the Rep Expert build. */
.rx-mv-tiles { display: flex; flex-direction: column; gap: .5rem; }
.mv-row { display: grid; grid-template-columns: 64px 1fr 1fr 1fr; gap: .5rem; align-items: stretch; }
.mv-win { display: flex; align-items: center; font-size: .72rem; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .03em; }
.mv-cell { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: .5rem .3rem; text-align: center; }
.mv-v { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.mv-l { font-size: .64rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .03em; margin-top: .1rem; }
.mv-cell.up .mv-v { color: #2ecc71; } .mv-cell.down .mv-v { color: #e74c3c; } .mv-cell.flat .mv-v { color: var(--text-dim); }
/* bar chart */
.rx-mv-chart { display: flex; flex-direction: column; gap: 1rem; }
.mv-grp-head { font-size: .8rem; font-weight: 700; margin-bottom: .4rem; display: flex; align-items: center; gap: .5rem; }
.mv-bar-row { display: grid; grid-template-columns: 42px 1fr; gap: .5rem; align-items: center; margin: .25rem 0; }
.mv-bar-lbl { font-size: .72rem; font-weight: 700; }
.mv-bar-lbl.up { color: #2ecc71; } .mv-bar-lbl.down { color: #e74c3c; }
.mv-bar-track { position: relative; background: var(--surface-2); border-radius: 6px; height: 22px; }
.mv-bar { height: 100%; border-radius: 6px; min-width: 2px; }
.mv-bar.up { background: #2ecc71; } .mv-bar.down { background: #e74c3c; } .mv-bar.react { background: #3aa0d1; }
.mv-bar-lbl.react { color: #3aa0d1; }
/* House Accounts pseudo-row on the leaderboard (clickable, muted, dashed) */
.mgr-house { opacity: .85; border-style: dashed; }
.mgr-house .mgr-rep-name { font-style: italic; color: var(--text); }
.mgr-house-amt { color: var(--text-dim); font-weight: 700; }
/* assigned-rep subtitle under an account name (Rep Expert + House customers) */
.rx-sub { font-size: .72rem; color: var(--text-faint); margin-top: 1px; }
.hx-note { font-size: .82rem; color: var(--text-dim); margin: -.2rem 0 1rem; line-height: 1.4; }
.mv-bar-val { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: .74rem; font-weight: 700; color: var(--text); }
