/* Midstone design tokens. Brand board round 02: Espresso, Sandstone, Cream. Large, calm, readable.
   Every colour and font in the app lives here. Swap a value below and the whole app follows.
   Notes for people: ../../../brand/APP-TOKENS.md */
:root {
  /* ---- Brand palette (round 02) ---- */
  --espresso: #2D2018;        /* primary, type, dark grounds */
  --walnut: #4D372B;          /* cards on dark, badges */
  --sandstone: #B99067;       /* the keystone: rules, rings, markers. Not for small text on light grounds */
  --cream: #EEE7D7;           /* light grounds */
  --limestone: #F7F4EB;       /* cards on light, paper */
  --white: #FFFFFF;           /* interface surface */
  --stone: #6B655F;           /* secondary text */
  --mist: #D9D3CB;            /* lines, light text on dark */
  /* Brand helpers (derived from the palette) */
  --sandstone-ink: #7A5A3A;   /* Sandstone deepened for small accent text on light grounds (5:1 on Cream) */
  --sandstone-soft: #F1E6D6;  /* Sandstone tint: highlights, selected rows, notes */
  --sandstone-line: #DCC7AC;  /* border around Sandstone tints */
  --mist-deep: #C8BFB3;       /* stronger line: inputs, dashed borders */
  --dusk: #A89C8E;            /* quiet text on Espresso (5.9:1) */

  /* ---- Roles: views use these, not the palette names ---- */
  --ink: var(--espresso);
  --ink-2: var(--walnut);
  --on-ink: var(--limestone);
  --paper: var(--white);
  --bg: var(--limestone);
  --bg-2: var(--cream);
  --hover: #FBF9F4;
  --line: #E4DED4;
  --line-2: var(--mist-deep);
  --muted: var(--stone);
  --accent: var(--sandstone);
  --on-accent: var(--espresso);
  --accent-hover: #C8A47E;   /* lighter on hover so Espresso text keeps its contrast */
  --accent-ink: var(--sandstone-ink);
  --accent-soft: var(--sandstone-soft);
  --accent-line: var(--sandstone-line);
  --focus: var(--sandstone);
  --focus-dark: var(--espresso);

  /* Sidebar (dark ground) */
  --side-bg: var(--espresso);
  --side-text: var(--mist);
  --side-muted: var(--dusk);
  --side-hover: #3B2B21;
  --side-active: var(--walnut);
  --side-line: #4A3A30;

  /* Semantic states, tuned to sit with the browns. Text on its own -bg passes WCAG AA. */
  --green: #2E6B46;   --green-bg: #E3EEDF;  --green-line: #B9D3BE;  --green-hover: #24563A;
  --red: #A63A2A;     --red-bg: #F7E3DD;    --red-line: #E8BCB1;
  --amber: #8A5A12;   --amber-bg: #F6E9CF;  --amber-line: #E5CD9C;
  --blue: #2F5D7C;    --blue-bg: #E2EBF1;   --blue-line: #B8CCDA;
  --violet: #6E4A7E;  --violet-bg: #EEE6F0; --violet-line: #D5C3DB;

  /* Avatars: white initials on each passes AA */
  --avatar-1: #8C4A2F; --avatar-2: #2F5D7C; --avatar-3: #2E6B46; --avatar-4: #6E4A7E;
  --avatar-5: #A63A2A; --avatar-6: #3E6A6A; --avatar-7: #7A5A3A; --avatar-8: #4D372B;

  /* Chat bubbles in the Inbox and Live simulation */
  --chat-bg: var(--cream);
  --bubble-in: var(--white);
  --bubble-out: #E4EFD9;
  --bubble-human: #E2EBF1;

  /* Simulator phone (familiar messaging look; not brand colours) */
  --wa-bar: #F0F2F5;
  --wa-header: #008069;       /* white text on it: 4.9:1 */
  --wa-on-header: #FFFFFF;
  --wa-font: "Segoe UI", "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
  --wa-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  --wa-text: #111B21;
  --wa-muted: #54656F;
  --wa-time: #56656E;
  --wa-wall: #EFEAE2;
  --wa-wall-dot: rgba(124, 110, 92, .09);
  --wa-wall-line: rgba(124, 110, 92, .045);
  --wa-in: #FFFFFF;
  --wa-out: #D9FDD3;
  --wa-green: #00A884;
  --wa-green-dark: #008069;
  --wa-tick: #8696A0;
  --wa-tick-read: #53BDEB;
  --wa-chip: #FFFFFF;
  --wa-system: #FFEECD;
  --wa-system-text: #54656F;
  --wa-unread: #25D366;
  --wa-line: #E9EDEF;
  --phone-frame: #1C1612;
  --phone-ring: rgba(185, 144, 103, .25);
  --wa-green-hover: #00705B;
  --wa-header-hover: rgba(255, 255, 255, .16);
  --wa-filter-on-bg: #E7FCE3;
  --wa-filter-on: #0A5C46;
  --wa-shadow-lift: 0 3px 8px rgba(11, 20, 26, .25);

  /* Video previews */
  --media-bg: #120D0A;
  --media-text: var(--mist);

  /* Shape and depth */
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(45, 32, 24, .06), 0 4px 16px rgba(45, 32, 24, .05);
  --shadow-lg: 0 20px 60px rgba(45, 32, 24, .25);
  --shadow-xs: 0 1px 2px rgba(45, 32, 24, .08);
  --accent-glow: rgba(185, 144, 103, .3);
  --scrim: rgba(45, 32, 24, .45);

  /* ---- Type: Google Fonts with offline fallbacks ---- */
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --display: "Roboto Slab", "Rockwell", "Roboto Serif", "Cambria", Georgia, serif;
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, "SF Mono", monospace;
  --fs: 15px;
}
:root.large { --fs: 18px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 400 var(--fs)/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 1.85em; font-weight: 700; }
h2 { font-size: 1.22em; font-weight: 600; }
h3 { font-size: 1em; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.btn.accent:focus-visible, .chip:focus-visible { outline-color: var(--focus-dark); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.accent-phrase { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: 0; }

.ico { width: 18px; height: 18px; flex: none; }
.bubble .by .ico { width: 13px; height: 13px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chips.scroll .chip { white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-text); padding: 20px 12px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side :focus-visible { outline-color: var(--accent); }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 18px; text-decoration: none; border-bottom: 1px solid var(--side-line); margin-bottom: 4px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--walnut); color: var(--sandstone); display: grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1px var(--accent-glow); }
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.32em; letter-spacing: -0.01em; color: var(--limestone); line-height: 1.1; }
.brand-sub { font-family: var(--serif); font-style: italic; font-size: 1em; color: var(--side-muted); line-height: 1.2; margin-top: 2px; }
.nav-group { margin-top: 14px; }
.nav-title { font-family: var(--mono); font-size: .7em; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--sandstone); padding: 6px 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; text-decoration: none; color: var(--side-text); font-weight: 500; position: relative; }
.nav a:hover { background: var(--side-hover); color: var(--limestone); }
.nav a.active { background: var(--side-active); color: var(--limestone); font-weight: 650; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav a .ico { width: 20px; height: 20px; flex: none; opacity: .9; }
.nav a.active .ico { color: var(--accent); opacity: 1; }
.nav a .count { margin-left: auto; background: var(--walnut); color: var(--limestone); font-family: var(--mono); font-size: .74em; font-weight: 600; padding: 1px 8px; border-radius: 99px; }
.nav a.active .count { background: var(--accent); color: var(--on-accent); }
.nav a .soon { margin-left: auto; font-family: var(--mono); font-size: .66em; color: var(--side-muted); border: 1px solid var(--side-line); padding: 0 6px; border-radius: 6px; }
.nav a.active .soon { color: var(--mist); border-color: var(--mist); }
.body { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; border: 1px solid var(--line-2); background: var(--bg); border-radius: 10px; padding: 9px 12px 9px 38px; }
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); background: var(--paper); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.search-results a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; }
.search-results a:hover, .search-results a:focus { background: var(--bg); }
.search-results .kind { font-family: var(--mono); font-size: .72em; color: var(--muted); width: 72px; flex: none; padding-top: 3px; text-transform: uppercase; letter-spacing: .06em; }
.safety { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: .74em; font-weight: 500; letter-spacing: .04em; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--walnut); padding: 6px 12px; border-radius: 99px; white-space: nowrap; }
.safety .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
main { padding: 26px 28px 60px; min-width: 0; outline: none; }

/* Page header */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 6px; max-width: 72ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: .72em; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--paper); border-radius: 10px; padding: 8px 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px; color: var(--ink); }
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.accent:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.ghost.accent { background: var(--accent-soft); border-color: var(--accent-line); }
.btn.danger { color: var(--red); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .88em; border-radius: 8px; }
.btn.done { background: var(--green); border-color: var(--green); color: var(--white); min-width: 112px; min-height: 52px; font-size: 1.05em; border-radius: 12px; }
.btn.done:hover { background: var(--green-hover); }
.btn .ico { width: 18px; height: 18px; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-xs); }
.seg button .n { font-family: var(--mono); font-size: .86em; font-weight: 500; color: var(--muted); margin-left: 4px; }

/* Cards, panels */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.card.note { background: var(--accent-soft); border-color: var(--accent-line); }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 16px 18px; }
.stat .label { font-family: var(--mono); color: var(--muted); font-size: .72em; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.stat .value { font-family: var(--display); font-size: 2em; font-weight: 700; margin-top: 4px; }
.stat .hint { color: var(--muted); font-size: .82em; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: .86em; }
.tiny { font-size: .76em; }
.strong { font-weight: 650; }
.mono { font-family: var(--mono); font-size: .86em; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.text-red { color: var(--red); font-weight: 600; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .76em; font-weight: 650; padding: 2px 9px; border-radius: 99px; background: var(--bg-2); color: var(--ink-2); white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.violet { background: var(--violet-bg); color: var(--violet); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.accent { background: var(--accent-soft); color: var(--walnut); box-shadow: inset 0 0 0 1px var(--accent-line); }
.badge.ink { background: var(--walnut); color: var(--limestone); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-family: var(--mono); font-size: .7em; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--hover); }
.table-wrap { overflow-x: auto; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .85em; font-weight: 650; }
.input, select.input, textarea.input { border: 1px solid var(--line-2); background: var(--paper); border-radius: 10px; padding: 9px 12px; width: 100%; }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.45; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 4px var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--espresso); }

/* Today */
.task { display: flex; gap: 16px; align-items: center; padding: 16px 18px; }
.task + .task { border-top: 1px solid var(--line); }
.task .area-bar { width: 6px; align-self: stretch; border-radius: 6px; flex: none; }
.task .title { font-weight: 650; font-size: 1.04em; }
.task .meta { color: var(--muted); font-size: .86em; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; align-items: center; }
.task .meta a { color: var(--ink); text-underline-offset: 3px; }
.task .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: none; }
.task.is-done .title { text-decoration: line-through; color: var(--muted); }
.area-sales { background: var(--blue); }
.area-marketing { background: var(--violet); }
.area-operations { background: var(--green); }
button.card.stat.on { border: 2px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Empty, toasts, modal */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 1.15em; }
.empty p { font-family: var(--serif); font-style: italic; font-size: 1.25em; line-height: 1.35; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: var(--on-ink); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; gap: 14px; align-items: center; font-weight: 500; border-left: 4px solid var(--accent); }
.toast button { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 8px; padding: 5px 12px; font-weight: 700; cursor: pointer; }
.modal-back { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 150; padding: 20px; }
.modal { background: var(--paper); border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: var(--shadow-lg); border-top: 4px solid var(--accent); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* Inbox */
.inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 320px; height: calc(100vh - 66px - 52px); min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); box-shadow: var(--shadow); }
.inbox .col { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.conv-list, .ctx { min-height: 0; }
.inbox .col + .col { border-left: 1px solid var(--line); }
.inbox .col-head, .col-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; text-decoration: none; position: relative; }
.conv:hover { background: var(--hover); }
.conv.on { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--white); flex: none; font-size: .9em; }
.conv .who { font-weight: 650; display: flex; gap: 6px; align-items: center; }
.conv .preview { color: var(--muted); font-size: .88em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-left: auto; flex: none; align-self: center; }
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 18px 10px; background: var(--chat-bg); display: flex; flex-direction: column; gap: 8px; }
.thread .day { align-self: center; margin: 6px 0; font-family: var(--mono); font-size: .7em; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); background: var(--limestone); padding: 3px 10px; border-radius: 99px; }
.bubble { max-width: 74%; padding: 9px 13px; border-radius: 14px; box-shadow: var(--shadow-xs); white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 4px; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 4px; }
.bubble.out.human { background: var(--bubble-human); }
.bubble .by { font-size: .74em; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.bubble.note { align-self: center; background: var(--accent-soft); border: 1px dashed var(--sandstone); font-size: .86em; max-width: 86%; text-align: center; box-shadow: none; color: var(--walnut); }
.typing { align-self: flex-start; background: var(--paper); border-radius: 14px; padding: 10px 14px; display: flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--sandstone); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; opacity: .7; } }
.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--paper); }
.composer .row textarea { flex: 1; min-height: 48px; max-height: 160px; }
.pencil-bar { padding: 10px 14px; background: var(--accent-soft); border-top: 1px solid var(--accent-line); gap: 8px; }
.ctx { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.ctx section h3 { font-family: var(--mono); font-size: .7em; font-weight: 500; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin-bottom: 8px; }
.ctx .unconfirmed { margin-top: 6px; background: var(--amber-bg); color: var(--ink); padding: 8px 10px; border-radius: 8px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 10px; font-size: .9em; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--paper); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: .88em; }
.chip:hover { background: var(--accent-soft); border-color: var(--accent-line); }

/* Simulation trace ("How it decided") */
.trace { display: flex; flex-direction: column; gap: 0; }
.trace-head { font-family: var(--mono); font-size: .72em; letter-spacing: .04em; color: var(--muted); font-weight: 500; }
.trace-turn { border-left: 2px solid var(--accent-line); margin-left: 9px; padding: 2px 0 10px 16px; }
.trace-step { position: relative; padding: 5px 0; }
.trace-step::before { content: ""; position: absolute; left: -23px; top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--line-2); }
.trace-step.k-ai::before { border-color: var(--violet); background: var(--violet-bg); }
.trace-step.k-check::before { border-color: var(--green); background: var(--green-bg); }
.trace-step.k-block::before, .trace-step.k-warn::before { border-color: var(--red); background: var(--red-bg); }
.trace-step.k-action::before, .trace-step.k-task::before { border-color: var(--blue); background: var(--blue-bg); }
.trace-step.k-handoff::before { border-color: var(--sandstone-ink); background: var(--accent); }
.trace-step.k-calendar::before, .trace-step.k-plan::before, .trace-step.k-time::before { border-color: var(--ink); }
.trace-step .l { font-weight: 650; font-size: .9em; }
.trace-step .d { color: var(--muted); font-size: .84em; }

/* Kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.lane { background: var(--bg-2); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.lane-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; font-weight: 650; }
.kcard { background: var(--paper); border-radius: 12px; padding: 12px; border: 1px solid var(--line); box-shadow: var(--shadow-xs); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 10px; overflow-x: auto; }
.cal-day { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; min-height: 220px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day .dh { font-weight: 650; display: flex; justify-content: space-between; }
.cal-ev { border-radius: 9px; padding: 7px 9px; font-size: .84em; border-left: 4px solid var(--ink); background: var(--bg); }

/* Simple bars (Reports, Leads) */
.bar-track { flex: 1; background: var(--bg-2); border-radius: 8px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--ink); }
.bar-fill.good { background: var(--green); }
.bar-fill.mid { background: var(--accent); }
.bar-fill.quiet { background: var(--line-2); }

/* Placeholder screens */
.soon-card { border: 2px dashed var(--line-2); border-radius: 18px; padding: 36px; text-align: center; background: var(--paper); }

@media (max-width: 1180px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .ctx-col { display: none; }
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 25; height: auto; padding: 8px 12px; display: flex; align-items: center; gap: 8px; }
  .brand { padding: 0; flex: none; border-bottom: 0; margin: 0; }
  .brand-name, .brand-sub { display: none; }
  .nav { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .nav-group { display: contents; }
  .nav-title { display: none; }
  .nav a { white-space: nowrap; flex: none; padding: 7px 10px; }
  .nav a.active::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .top { position: static; }
  .search { flex-basis: 100%; max-width: none; order: 3; }
  .grid.k4 { grid-template-columns: 1fr; }
  main { padding: 18px 16px 50px; }
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .grid.k3, .grid.k2 { grid-template-columns: 1fr; }
  .task { flex-wrap: wrap; }
  .task .acts { margin-left: 0; }
  h1 { font-size: 1.6em; }
}

/* ---------- Sign-in (server mode only) ---------- */
.user-slot { display: contents; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 600; font-size: .9em; padding-left: 4px; }
.user-chip .avatar { width: 28px; height: 28px; font-size: .75em; }
.user-chip .user-role { color: var(--muted); font-weight: 600; font-size: .85em; }
.login-screen { position: fixed; inset: 0; z-index: 300; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--cream); overflow: auto; }
.login-side { font-size: 18px; background: var(--espresso); color: var(--mist); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-side .login-brand .brand-name { font-size: 1.5em; }
.login-hero { display: flex; flex-direction: column; gap: 18px; max-width: 460px; }
.login-hero .eyebrow { color: var(--sandstone); }
.login-hero h2 { font-size: 2.6em; line-height: 1.08; color: var(--limestone); font-weight: 700; }
.login-hero .rule { width: 72px; height: 3px; border-radius: 3px; background: var(--sandstone); }
.login-hero .accent-phrase { font-size: 1.6em; color: var(--mist); line-height: 1.2; }
.login-foot { font-family: var(--mono); font-size: .72em; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); }
.login-main { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 32px; display: flex; flex-direction: column; gap: 16px; font-size: 18px; border-top: 4px solid var(--accent); }
.login-card h1 { font-size: 1.6em; }
.login-card .field label { font-size: .9em; }
.login-card .input { min-height: 52px; font-size: 1em; padding: 12px 14px; }
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; text-decoration: none; }
.login-btn { min-height: 54px; font-size: 1.05em; border-radius: 12px; margin-top: 4px; }
.login-error { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--red-bg); color: var(--red); font-weight: 600; }
.login-error[hidden] { display: none; }
@media (max-width: 860px) {
  .login-screen { grid-template-columns: 1fr; align-content: start; }
  .login-side { padding: 22px 20px; }
  .login-side .brand-name { display: block; }
  .login-hero h2 { font-size: 1.8em; }
  .login-hero .accent-phrase { font-size: 1.3em; }
  .login-foot { display: none; }
}

/* Logo pack: full lockup in the sidebar, the mark alone on phones. */
.brand-lockup { display: block; height: 35px; width: auto; max-width: 100%; }
.brand > .brand-mark { display: none; }
.brand-mark img { width: 24px; height: 24px; display: block; }
.login-lockup { display: block; height: 50px; width: auto; max-width: 100%; }
@media (max-width: 860px) {
  .brand-lockup { display: none; }
  .brand > .brand-mark { display: grid; }
  .login-lockup { height: 40px; }
}

/* Role preview ("View as") in the top bar. */
.view-as-slot { display: contents; }
.view-as { width: auto; min-height: 36px; padding: 5px 10px; font-size: .86em; }
.view-as.previewing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); font-weight: 600; }
