/* ==========================================================================
   Canopy theme: March house style (Nov 2026)
   Loaded AFTER app.css. app.css keeps layout and behaviour; this file sets the look.

   Canopy now matches the other March web apps (March Vault, March Vision, Knowledge Hub),
   which share the "March Atlas" tokens (march-vault/public/vault.css, Knowledge Hub app.css):
   - Navy sidebar (#0B2338) with the app name block on top, white top bar, soft grey page.
   - March navy #1B4A72 for primary buttons, links and selection; CU orange #E2954A as a
     small accent only (New status, unread dot), never under text.
   - Inter, 14px body; small UPPERCASE section labels; 12px-corner panels with a header strip;
     tinted 6px-corner status chips; a coloured status bar on the left of each queue row
     (Vision's task-row pattern).
   - Message bodies stay at 15px / 1.6 with ~68 characters per line for reading.
   Every text colour is >= 4.5:1 on its own background (WCAG AA), light and dark.
   ========================================================================== */

/* ---------- Font: Inter (SIL OFL, fonts/Inter-LICENSE.txt), served from Canopy itself ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-var-latin-italic.woff2") format("woff2");
}

/* ---------- Tokens: light (March Atlas values) ---------- */
:root {
  /* Surfaces and text (Vault neutrals) */
  --bg: #f4f6f9;            /* page */
  --surface: #ffffff;       /* panels, lists, messages */
  --surface-2: #f7f8fa;     /* row hover, panel header strip */
  --surface-3: #edeff3;     /* pressed, chips */
  --border: #dde1e8;        /* hairlines */
  --border-strong: #c3c9d4; /* button outlines */
  --border-input: #7c8494;  /* text fields: 3:1 on white (WCAG 1.4.11) */
  --text: #21252c;
  --muted: #5a6170;         /* 6.1:1 on white */
  --faint: #8a92a1;         /* placeholders and icons only */

  /* Brand: March navy, CU orange */
  --accent: #1b4a72;        /* 9.6:1 on white */
  --accent-hover: #163d5f;
  --accent-text: #ffffff;
  --accent-soft: #eef3f8;
  --accent-soft-2: #d9e5f0;
  --accent-strong: #10304a;
  --orange: #e2954a;
  --orange-soft: #fdf3e9;
  --focus: rgba(74, 121, 163, 0.35);

  /* Sidebar (always navy) */
  --sb-w: 248px;
  --sb-bg: #0b2338;
  --sb-text: rgba(255, 255, 255, 0.84);
  --sb-muted: rgba(255, 255, 255, 0.58);
  --sb-hover: rgba(255, 255, 255, 0.08);
  --sb-active: rgba(255, 255, 255, 0.14);
  --sb-line: rgba(255, 255, 255, 0.1);

  /* Internal notes: warm amber, clearly "not to the customer" */
  --note-bg: #fbf3e2;
  --note-border: #ecd6a6;
  --danger: #c0392b;
  --warn: #7a4b00;

  /* Status: bar/dot (--st-*), chip fill (--st-*-bg), chip text (--st-*-fg) */
  --st-new: #e2954a;     --st-new-bg: #fdf0e1;     --st-new-fg: #8a4f12;
  --st-open: #c0392b;    --st-open-bg: #fbe4e1;    --st-open-fg: #8c2318;
  --st-pending: #2b6cb0; --st-pending-bg: #e1edfa; --st-pending-fg: #1c4f86;
  --st-hold: #343a44;    --st-hold-bg: #e6e9ee;    --st-hold-fg: #343a44;
  --st-solved: #1a7f52;  --st-solved-bg: #dcf0e5;  --st-solved-fg: #12603d;
  --st-closed: #b4bbc7;  --st-closed-bg: transparent; --st-closed-fg: #5a6170;

  /* Shape and depth */
  --radius: 12px;           /* panels */
  --radius-md: 8px;         /* buttons, fields */
  --radius-sm: 6px;         /* chips */
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.06);

  /* Type */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-read: 15px;
  --text-lg: 17px;
  --text-xl: 24px;
  --control-h: 32px;
  --topbar-h: 56px;

  font: 400 var(--text-md)/1.5 var(--font-ui);
  font-feature-settings: "cv11";
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}

/* ---------- Tokens: dark (same two selectors as app.css so these win) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1520; --surface: #142030; --surface-2: #192739; --surface-3: #213248;
    --border: #253549; --border-strong: #354a63; --border-input: #5f7590;
    --text: #e6ebf2; --muted: #a5b1c2; --faint: #75849a;
    --accent: #8db0d3; --accent-hover: #a8c4e0; --accent-text: #071726;
    --accent-soft: #1a2f47; --accent-soft-2: #22405f; --accent-strong: #c4d8ec;
    --orange-soft: #3a2814; --focus: rgba(141, 176, 211, 0.4);
    --sb-bg: #08121d; --sb-hover: rgba(255, 255, 255, 0.06); --sb-active: rgba(255, 255, 255, 0.12);
    --note-bg: #2a2314; --note-border: #5a4820; --danger: #f08a80; --warn: #f2b45c;
    --st-new-bg: #3a2814;     --st-new-fg: #f4b77c;
    --st-open: #f0776b;    --st-open-bg: #3b1b19;    --st-open-fg: #f6a69d;
    --st-pending: #6aa6e6; --st-pending-bg: #15283f; --st-pending-fg: #a1c6f0;
    --st-hold: #c3c9d4;    --st-hold-bg: #26303d;    --st-hold-fg: #dde1e8;
    --st-solved: #3dbe85;  --st-solved-bg: #12301f;  --st-solved-fg: #7ed8ab;
    --st-closed: #4b5566;  --st-closed-fg: #a5b1c2;
    --shadow: none; --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1520; --surface: #142030; --surface-2: #192739; --surface-3: #213248;
  --border: #253549; --border-strong: #354a63; --border-input: #5f7590;
  --text: #e6ebf2; --muted: #a5b1c2; --faint: #75849a;
  --accent: #8db0d3; --accent-hover: #a8c4e0; --accent-text: #071726;
  --accent-soft: #1a2f47; --accent-soft-2: #22405f; --accent-strong: #c4d8ec;
  --orange-soft: #3a2814; --focus: rgba(141, 176, 211, 0.4);
  --sb-bg: #08121d; --sb-hover: rgba(255, 255, 255, 0.06); --sb-active: rgba(255, 255, 255, 0.12);
  --note-bg: #2a2314; --note-border: #5a4820; --danger: #f08a80; --warn: #f2b45c;
  --st-new-bg: #3a2814;     --st-new-fg: #f4b77c;
  --st-open: #f0776b;    --st-open-bg: #3b1b19;    --st-open-fg: #f6a69d;
  --st-pending: #6aa6e6; --st-pending-bg: #15283f; --st-pending-fg: #a1c6f0;
  --st-hold: #c3c9d4;    --st-hold-bg: #26303d;    --st-hold-fg: #dde1e8;
  --st-solved: #3dbe85;  --st-solved-bg: #12301f;  --st-solved-fg: #7ed8ab;
  --st-closed: #4b5566;  --st-closed-fg: #a5b1c2;
  --shadow: none; --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ---------- Base ---------- */
body { background: var(--bg); }
h1, h2, h3, h4 { letter-spacing: -0.01em; }
.small { font-size: var(--text-sm); }
::placeholder { color: var(--faint); opacity: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { text-underline-offset: 2px; }
code, pre, kbd, .tpl-body { font-family: var(--font-mono); }

/* The house "micro label": small caps-style section headings used everywhere */
.sidebar h2, .card > h3, .card-head h3, details.card > summary, details.card > summary h3,
.tpl-list h2, .api-table th, .guide-table th, .report-table th, dialog.shortcuts h3, .card .sub-head {
  font-size: var(--text-2xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
}

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--control-h); padding: 0 12px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: var(--text-sm); font-weight: 600; line-height: 1;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); filter: none; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.btn.link { border-color: transparent; background: none; color: var(--muted); }
.btn.link:hover { background: var(--surface-3); color: var(--text); }
.btn:disabled, .btn:disabled:hover { opacity: 0.5; background: var(--surface); border-color: var(--border-strong); }
.btn.primary:disabled, .btn.primary:disabled:hover { background: var(--accent); border-color: var(--accent); }

.field, select.field, .topbar select {
  border: 1px solid var(--border-input); border-radius: var(--radius-md);
  background-color: var(--surface); padding: 5px 10px;
}
/* Height only for one-line controls; textareas keep the heights app.css gives them */
input.field, select.field, .topbar select { min-height: var(--control-h); }
textarea.field { padding: 9px 11px; line-height: 1.5; }
.field:focus, .topbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
select.field, .topbar select, .prop select, .bar select:not(.send-as-pick), .card select {
  appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237c8494' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 10px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; }
.linkish { color: var(--accent); font-weight: 500; }
.chip { border-radius: 999px; background: var(--surface); border-color: var(--border-strong); font-size: var(--text-xs); font-weight: 600; padding: 3px 11px; }
.chip:hover { background: var(--accent-soft); border-color: var(--accent-soft-2); color: var(--accent); }
kbd { border-color: var(--border-strong); background: var(--surface-2); font-size: 11px; }

/* ---------- Top bar: navy name block over the sidebar, white bar to the right ---------- */
.topbar {
  height: var(--topbar-h); padding: 0 20px 0 0; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
}
.topbar .logo {
  align-self: stretch; flex: none; width: var(--sb-w); margin: 0 8px -1px 0; padding: 0 18px;
  gap: 10px; background: var(--sb-bg); color: #fff; border-bottom: 1px solid var(--sb-line);
}
.logo img {
  width: 30px; height: 30px; padding: 5px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.12); filter: brightness(0) invert(1);
}
.logo-text { display: flex; flex-direction: column; font-size: var(--text-md); font-weight: 700; line-height: 1.15; letter-spacing: -0.005em; }
.logo-text::after { content: "by March Products"; font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0; color: var(--sb-muted); }
.search { max-width: 520px; }
.topbar .search {
  background: var(--surface-2) no-repeat 11px center / 15px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237c8494' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5l3 3'/%3E%3C/svg%3E");
  border-color: var(--border); padding-left: 34px;
}
.topbar .search:hover { border-color: var(--border-strong); }
.topbar .search:focus { background-color: var(--surface); border-color: var(--accent); }
.topbar select { width: auto; max-width: 220px; border-color: var(--border-strong); font-size: var(--text-sm); font-weight: 500; }
.me { gap: 6px; }
.me .name { font-size: var(--text-sm); font-weight: 500; margin: 0 6px; }
.bell { width: 32px; height: 32px; border-radius: var(--radius-md); }
.bell:hover, .bell[aria-expanded="true"] { background: var(--surface-3); }
.bell-count { background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.news-count { background: var(--orange); color: #21252c; }

/* ---------- Sidebar: navy, white text ---------- */
.shell { grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); align-self: start; height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  background: var(--sb-bg); border-right: 0; padding: 6px 12px 28px; color: var(--sb-text);
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.sidebar h2 { color: var(--sb-muted); margin: 20px 10px 6px; }
.sidebar > h2:first-child { margin-top: 14px; }
.view-link {
  min-height: 34px; padding: 6px 10px; border-radius: var(--radius-md);
  color: var(--sb-text); font-weight: 500; transition: background-color 0.1s;
}
.view-link:hover { background: var(--sb-hover); color: #fff; }
.view-link.active { background: var(--sb-active); color: #fff; font-weight: 600; }
.count {
  min-width: 24px; padding: 1px 7px; border-radius: 999px; text-align: center;
  background: rgba(255, 255, 255, 0.1); color: var(--sb-text); font-size: var(--text-2xs); font-weight: 600; line-height: 16px;
}
.view-link.active .count { background: var(--orange); color: #21252c; }
.nav-group > summary h2::after { color: var(--sb-muted); }
.nav-group > summary:hover h2 { color: #fff; }
.sidebar kbd { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.22); color: var(--sb-text); }

/* ---------- Page headings ---------- */
.main { padding: 26px 32px 56px; }
.list-head { margin-bottom: 16px; align-items: center; }
.list-head h1, .ticket-head h1, .guide-head h1 { font-size: var(--text-xl); font-weight: 700; line-height: 1.25; }
.main h1 { font-weight: 700; letter-spacing: -0.01em; }
.list-head > .muted { font-size: var(--text-sm); }
.live-note { font-size: var(--text-xs); }
.live-note::before { background: var(--st-solved); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-solved) 20%, transparent); }

/* ---------- Status chips: tinted, 6px corners (house .pill) ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 74px;
  padding: 3px 8px; border-radius: var(--radius-sm);
  font-size: var(--text-2xs); font-weight: 700; line-height: 16px; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
}
.pill.new     { background: var(--st-new-bg);     color: var(--st-new-fg); }
.pill.open    { background: var(--st-open-bg);    color: var(--st-open-fg); }
.pill.pending { background: var(--st-pending-bg); color: var(--st-pending-fg); }
.pill.hold    { background: var(--st-hold-bg);    color: var(--st-hold-fg); }
.pill.solved  { background: var(--st-solved-bg);  color: var(--st-solved-fg); }
.pill.closed  { background: transparent; color: var(--st-closed-fg); box-shadow: inset 0 0 0 1px var(--border-strong); }

.brand, .tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0 6px; line-height: 17px; border-radius: 5px; border: 0; background: var(--surface-3); color: var(--muted);
}
.tag.ok { background: var(--st-solved-bg); color: var(--st-solved-fg); }
.tag.warn { background: var(--note-bg); border: 0; color: var(--warn); }
.tag.bad { background: var(--danger); color: #fff; }

/* ---------- Ticket list: one panel, status bar on the left of each row ---------- */
.table { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.row {
  grid-template-columns: 96px minmax(0, 1fr) 150px 132px; gap: 18px;
  min-height: 64px; padding: 10px 20px 10px 18px; border-top: 1px solid var(--border);
  transition: background-color 0.1s;
}
.row:hover { background: var(--surface-2); }
.row:has(.pill.new)     { box-shadow: inset 3px 0 0 var(--st-new); }
.row:has(.pill.open)    { box-shadow: inset 3px 0 0 var(--st-open); }
.row:has(.pill.pending) { box-shadow: inset 3px 0 0 var(--st-pending); }
.row:has(.pill.hold)    { box-shadow: inset 3px 0 0 var(--st-hold); }
.row:has(.pill.solved)  { box-shadow: inset 3px 0 0 var(--st-solved); }
.row .subject { font-weight: 600; font-size: var(--text-md); color: var(--text); line-height: 1.4; }
.row.unread .subject { font-weight: 700; }
.row.unread .subject::before { width: 8px; height: 8px; background: var(--orange); margin-right: 8px; vertical-align: 1px; }
.row .who { font-size: var(--text-sm); line-height: 1.5; margin-top: 2px; }
.row .who .brand, .row .who .tag { margin-left: 8px; vertical-align: 1px; }
.row .assignee { font-size: var(--text-sm); }
.row .when { font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .when.wait { color: var(--warn); font-weight: 700; }
.row .when.wait.late { color: var(--danger); }
.ticket-list .row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.agent-row { grid-template-columns: minmax(0, 1fr) 180px 120px 140px 120px; align-items: center; min-height: 60px; }
.empty { padding: 64px 24px; font-size: var(--text-md); }
.more .btn { min-width: 140px; }

/* ---------- Ticket page ---------- */
.ticket { grid-template-columns: minmax(0, 1000px) 340px; gap: 24px; }
.ticket-head { margin-bottom: 18px; }
.ticket-head .crumbs { font-size: var(--text-sm); gap: 8px; color: var(--muted); margin-bottom: 8px; }
.ticket-head .crumbs a { color: var(--muted); font-weight: 500; }
.ticket-head .crumbs a:hover { color: var(--accent); }
.ticket-head h1 { padding: 0 4px; margin-left: -4px; }
.banner { border-radius: var(--radius-md); border-color: var(--border); background: var(--surface); font-size: var(--text-sm); padding: 10px 14px; }

/* Messages: panels with a reading-width body */
.msg { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; background: var(--surface); }
.msg-head { padding: 14px 18px 0; gap: 12px; align-items: flex-start; }
.msg-head .name { font-weight: 700; font-size: var(--text-md); }
.msg-head .meta { font-size: var(--text-sm); }
.msg-head .meta .muted, .msg-head > .muted, .msg-head time { font-size: var(--text-xs); }
.avatar { width: 34px; height: 34px; font-size: 12px; font-weight: 700; background: var(--accent-soft-2); color: var(--accent-strong); }
.msg-body { padding: 8px 18px 16px 64px; font-size: var(--text-read); line-height: 1.6; max-width: calc(68ch + 82px); }
.msg-actions { padding: 0 18px 14px 64px; font-size: var(--text-sm); }
.msg-actions a, .msg-actions button { color: var(--muted); font-weight: 500; }
.msg-actions a:hover, .msg-actions button:hover { color: var(--accent); }
.msg iframe { width: calc(100% - 82px); margin: 8px 18px 16px 64px; border-color: var(--border); border-radius: var(--radius-md); }
.atts { padding: 0 18px 16px 64px; }
.att { border-color: var(--border); border-radius: var(--radius-md); }
.att:hover { border-color: var(--accent); background: var(--accent-soft); }
/* Our replies: navy avatar + navy edge. Notes: amber. */
.msg.outbound { border-left: 1px solid var(--border); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.msg.outbound .avatar { background: var(--accent); color: var(--accent-text); }
.msg.note { background: var(--note-bg); border-color: var(--note-border); box-shadow: inset 3px 0 0 var(--orange); }
.msg.note .avatar { background: var(--note-border); color: var(--text); }
.msg.note .tag { background: var(--note-border); color: var(--text); }
.msg.auto { opacity: 1; }
.msg.auto .msg-body { color: var(--muted); }
.thread-order { font-size: var(--text-sm); color: var(--muted); margin: 20px 0 12px; }

/* Composer */
.composer { border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 16px 14px; }
.composer.reply { border-color: var(--border-strong); }
.composer.reply:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.composer.note { background: var(--note-bg); border-color: var(--note-border); }
.tabs { margin: 0 -16px 12px; padding: 0 12px; gap: 4px; }
.tabs button { padding: 11px 8px 9px; font-weight: 600; font-size: var(--text-sm); }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); }
.composer.note .tabs button.active { color: var(--warn); border-bottom-color: var(--orange); }
.composer textarea { font-size: var(--text-read); line-height: 1.6; border-color: var(--border-strong); }
.composer.collapsed textarea { font-size: var(--text-md); }
.send-mode { border-radius: var(--radius-md); font-size: var(--text-sm); }
.send-as-pick { border-radius: 0 var(--radius-md) var(--radius-md) 0; background-color: var(--accent); }
.send-as-pick:hover, .send-as .btn.primary:hover + .send-as-pick { background-color: var(--accent-hover); }
.fill-ins code { font-size: 12px; }
.ai-draft { border-radius: var(--radius-md); border-color: var(--accent-soft-2); background: var(--accent-soft); }

/* Right rail and every settings card: house panels with a header strip */
.props { top: calc(var(--topbar-h) + 20px); gap: 12px; }
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; background: var(--surface); }
.card:has(> h3:first-child), .card:has(> .card-head:first-child), details.card { padding-top: 0; }
.card > h3:first-child, .card > .card-head:first-child, details.card > summary {
  margin: 0 -16px 14px; padding: 11px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; color: var(--muted);
}
.card > .card-head:first-child h3 { margin: 0; color: var(--muted); }
.card-head { align-items: center; }
details.card > summary, .card.warranty > summary { list-style-position: inside; cursor: pointer; margin-bottom: 0; }
details.card:not([open]) { padding-bottom: 0; }
details.card[open] > summary { margin-bottom: 14px; }
details.card:not([open]) > summary { border-bottom: 0; border-radius: var(--radius); }
details.card > summary h3 { color: var(--muted); font-size: inherit; margin: 0; }
.card.activity > summary h3::after { text-transform: none; letter-spacing: 0; font-size: var(--text-xs); }
.card .sub-head { color: var(--muted); }
.card details > summary, .policy summary { list-style-position: inside; cursor: pointer; }
details.card > summary::marker, .card details > summary::marker, .policy summary::marker { color: var(--faint); }
.prop { margin-bottom: 12px; }
.prop label { font-size: var(--text-xs); font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.kv { grid-template-columns: 104px 1fr; gap: 7px 10px; font-size: var(--text-sm); }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; }
.events { font-size: var(--text-sm); }
.events li { padding: 7px 0; }
.policy summary { font-size: var(--text-sm); font-weight: 600; }
.decision { font-size: var(--text-md); }

/* Menus, popovers, dialogs */
.menu-panel, .bell-panel, .mention-menu, dialog.shortcuts, dialog.outcome-dialog { border-color: var(--border); box-shadow: var(--shadow-pop); border-radius: var(--radius); }
.menu-item { border-radius: var(--radius-md); padding: 8px 10px; }
.menu-item:hover, .menu-item:focus-visible, .mention-option:hover, .mention-option.active, .bell-item:hover { background: var(--surface-2); }
.bell-item.unread, .news-entry.unread { border-left-color: var(--orange); }
dialog::backdrop { background: rgba(16, 24, 40, 0.45); }
.toast { border-radius: var(--radius-md); box-shadow: var(--shadow-pop); font-weight: 600; background: var(--text); }

/* ---------- Settings pages ---------- */
.tpl-list { border-color: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 8px 12px; }
.tpl-list h2 { color: var(--muted); margin: 16px 10px 6px; }
.tpl-item { border-radius: var(--radius-md); padding: 7px 10px; font-size: var(--text-md); line-height: 1.4; }
.tpl-item:hover { background: var(--surface-2); }
.tpl-item.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.tpl-item > :last-child { flex: none; white-space: nowrap; font-size: var(--text-xs); color: var(--muted); padding-top: 2px; }
.tpl-body { font-size: var(--text-sm); line-height: 1.6; }
.tpl-hints, .guide-tip, .order-note, .send-row { border-radius: var(--radius-md); }
.send-row.live { background: var(--st-solved-bg); border-color: color-mix(in srgb, var(--st-solved) 35%, transparent); }
.mailbox-address { font-size: var(--text-lg); font-weight: 700; }
.api-table th, .guide-table th, .report-table th { color: var(--muted); background: var(--surface-2); padding: 8px 10px; }
.api-table td, .guide-table td, .report-table td { padding: 9px 10px; }
.cs-item { border-color: var(--border); border-radius: var(--radius-md); background: var(--surface); }
.cs-preview { border-color: var(--border); border-radius: var(--radius); }
.cs-opt { border-color: var(--accent); color: var(--accent); }
.cs-me { background: var(--accent); color: var(--accent-text); }
.integ-cmd, .api-code code, .api-code pre, pre.headers { font-family: var(--font-mono); border-radius: var(--radius-md); }
.health-banner { font-weight: 600; top: var(--topbar-h); }
.integ-ok, .health-ok { color: var(--st-solved-fg); }
.reports h4 { font-size: var(--text-sm); font-weight: 700; }
.report-table .bar { background: var(--accent); opacity: 1; border-radius: 3px; }
.guide { max-width: 780px; }
.guide-section { line-height: 1.6; }
.guide-section h2 { font-size: var(--text-lg); font-weight: 700; }
.guide-section > h3 { font-size: var(--text-md); font-weight: 700; text-transform: none; letter-spacing: -0.005em; color: var(--text); }
.api-h2 { font-size: var(--text-lg); font-weight: 700; }

/* ---------- Narrow screens ---------- */
/* Column widths are re-stated here because this file loads after app.css,
   so app.css's own narrow-screen switches would otherwise lose to the rules above. */
@media (max-width: 1200px) {
  :root { --sb-w: 220px; }
  .ticket { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1000px) {
  .ticket { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { height: auto; padding: 8px 12px; gap: 8px; }
  .topbar .logo { align-self: center; width: auto; margin: 0; padding: 0; background: none; border: 0; color: var(--text); }
  .logo img { background: var(--accent-soft-2); filter: none; width: 30px; height: 30px; }
  .main { padding: 16px; }
  .sidebar { position: static; height: auto; padding: 8px 10px; }
  .view-link { min-height: 32px; }
  .nav-group > summary h2 { color: var(--sb-text); text-transform: none; letter-spacing: 0; font-size: var(--text-md); font-weight: 500; }
  /* Rows: subject block on the left; status dot over the wait time on the right */
  .row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 14px; min-height: 0; }
  .row > div:nth-child(2) { grid-column: 1; grid-row: 1 / span 2; }
  .row .pill-cell { display: block; grid-column: 2; grid-row: 1; justify-self: end; }
  .row .pill-cell .pill { min-width: 0; padding: 0; background: none; box-shadow: none; font-size: 0; gap: 0; }
  .row .pill-cell .pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
  .row .when { grid-column: 2; grid-row: 2; justify-self: end; }
  .msg-body, .msg-actions, .atts { padding-left: 18px; }
  .msg iframe { width: calc(100% - 36px); margin-left: 18px; }
}

/* ==========================================================================
   Layout and UX pass (Nov 2026): driven by the persona tests in Canopy/ux-tests.
   ========================================================================== */

/* ---------- Icons ---------- */
.ico { display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; }
.ico svg { width: 100%; height: 100%; }
.btn .ico { width: 15px; height: 15px; }

/* ---------- Sidebar: icon tiles colour-coded like the status chips, hint lines ---------- */
.sidebar .view-link { --tone: #b8c2cf; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 36px; padding: 5px 8px; }
.sidebar .tone-queue { --tone: #f2b57a; }
.sidebar .tone-mine { --tone: #9cc4f0; }
.sidebar .tone-unassigned { --tone: #f6d08a; }
.sidebar .tone-chats { --tone: #7fd6c8; }
.sidebar .tone-pending { --tone: #8fbceb; }
.sidebar .tone-hold { --tone: #cbd2dc; }
.sidebar .tone-solved { --tone: #7ed8ab; }
.sidebar .tone-closed { --tone: #8a97a8; }
.sidebar .tone-bulk { --tone: #c4b5f0; }
.sidebar .tone-spam { --tone: #f0a39b; }
.sidebar .tone-reports { --tone: #9cc4f0; }
.nav-ico { display: grid; place-items: center; width: 20px; height: 20px; color: var(--tone); }
.nav-ico .ico { width: 18px; height: 18px; }
.nav-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-hint { font-size: var(--text-2xs); font-weight: 500; color: var(--sb-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-link.active .nav-hint { color: rgba(255, 255, 255, 0.72); }

/* ---------- Top bar: What's new carries its name ---------- */
.bell.labelled { width: auto; padding: 0 10px 0 8px; gap: 6px; display: inline-flex; align-items: center; color: var(--muted); }
.bell.labelled svg { width: 18px; height: 18px; }
.bell-label { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.bell.labelled .bell-count { position: static; margin-left: 2px; }
@media (max-width: 1180px) { .bell-label { display: none; } }

/* ---------- Ticket list: column labels, plain hint, unassigned stands out ---------- */
.list-hint { margin: -8px 0 14px; }
.list-cols {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) 150px 132px; gap: 18px;
  padding: 0 20px 6px 18px; font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.list-cols > :last-child { text-align: right; }
.row .assignee.unassigned { justify-self: start; padding: 1px 8px; border-radius: 5px; background: var(--st-new-bg); color: var(--st-new-fg); font-weight: 600; }

/* ---------- Ticket header: title, quick actions, one strip of facts ---------- */
.ticket-head .title-row { align-items: center; }
.head-actions { display: flex; gap: 8px; flex: none; }
.btn.note-btn { background: var(--note-bg); border-color: var(--note-border); color: var(--warn); }
.btn.note-btn:hover { background: color-mix(in srgb, var(--note-border) 45%, var(--note-bg)); }
.ticket-facts {
  display: flex; flex-wrap: wrap; gap: 10px 32px; margin-top: 14px; padding: 12px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.fact { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact-label { font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.fact-value { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-weight: 600; min-height: 26px; }
.fact-hint { flex-basis: 100%; font-weight: 400; font-size: var(--text-xs); color: var(--muted); }
.fact .pill { min-width: 0; }
.unassigned { color: var(--st-new-fg); }
.wait-text.late { color: var(--danger); }
.btn.btn-xs { min-height: 26px; padding: 0 9px; font-size: var(--text-xs); }

/* ---------- Thread: who wrote it, and who saw it ---------- */
.thread-order { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin: 22px 0 12px; }
.thread-count { font-weight: 600; color: var(--text); }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface); }
.seg button { border: 0; background: none; padding: 3px 10px; border-radius: 6px; font: inherit; font-size: var(--text-xs); font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.jump-latest { display: inline-flex; align-items: center; gap: 4px; }
.jump-latest .ico { width: 14px; height: 14px; }

/* Customer messages sit left; ours and notes are indented, so the back-and-forth reads at a glance */
.msg { overflow: hidden; }
.msg.ours, .msg.note { margin-left: 56px; }
.msg.ours { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); border-color: var(--accent-soft-2); box-shadow: var(--shadow); }
.msg.ours .avatar { background: var(--accent); color: var(--accent-text); }
.msg.note { box-shadow: var(--shadow); }
.msg.note .avatar { background: var(--note-border); color: var(--warn); }
.msg.note .avatar .ico { width: 15px; height: 15px; }
.msg-head { align-items: center; }
.meta-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.meta-line .tag { margin: 0; }
.msg-time { flex: none; font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.role { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0 6px; line-height: 17px; border-radius: 5px; }
.role-customer { background: var(--surface-3); color: var(--muted); }
.role-ours { background: var(--accent-soft-2); color: var(--accent-strong); }
.role-note { background: var(--note-border); color: var(--warn); }
.msg-actions { padding-bottom: 12px; }
.msg-vis { display: flex; align-items: center; gap: 7px; padding: 8px 18px 9px 64px; border-top: 1px solid var(--border); font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
.msg-vis .ico { width: 14px; height: 14px; }
.msg.ours .msg-vis { border-top-color: var(--accent-soft-2); }
.msg-vis.sent .ico { color: var(--accent); }
.msg-vis.team { border-top-color: var(--note-border); color: var(--warn); }
.msg-vis.warn { background: var(--note-bg); color: var(--warn); border-top-color: var(--note-border); }
.msg-vis.bad { background: var(--st-open-bg); color: var(--st-open-fg); }

/* Automatic messages: one quiet line, open to read */
.msg-event { margin: 0 0 12px; }
.msg-event.ours { margin-left: 56px; }
.msg-event > summary {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; cursor: pointer; list-style: none;
  border: 1px dashed var(--border-strong); border-radius: 10px; color: var(--muted); font-size: var(--text-sm);
}
.msg-event > summary::-webkit-details-marker { display: none; }
.msg-event > summary:hover { background: var(--surface-2); color: var(--text); }
.msg-event .event-text { flex: 1; min-width: 0; font-weight: 500; }
.msg-event[open] > summary { border-radius: 10px 10px 0 0; border-bottom-style: solid; }
.event-body { border: 1px dashed var(--border-strong); border-top: 0; border-radius: 0 0 10px 10px; background: var(--surface); }
.event-body .msg-body { padding: 10px 16px 14px; color: var(--muted); }
.event-body .msg-actions { padding: 0 16px 12px; }

/* Website chat transcript: visitor on the left, the bot (automatic) on the right */
.chat-lines { display: grid; gap: 10px; white-space: normal; }
.chat-line { max-width: 85%; padding: 8px 12px 9px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); justify-self: start; }
.chat-line.bot, .chat-line.agent { justify-self: end; background: var(--surface); border-style: dashed; border-color: var(--border-strong); }
.chat-line.agent { border-style: solid; background: var(--accent-soft); border-color: var(--accent-soft-2); }
.chat-who { display: flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.chat-who .ico { width: 13px; height: 13px; }
.chat-said { white-space: pre-wrap; }

/* ---------- Reply box: two unmistakable modes ---------- */
.composer { padding: 0 16px 14px; }
.composer .tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; padding: 14px 0 0; border-bottom: 0; }
.composer .tabs button.mode {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.composer .tabs button.mode:hover { border-color: var(--border-strong); }
.composer .tabs button.mode .ico { width: 18px; height: 18px; color: var(--muted); }
.mode-text { display: flex; flex-direction: column; line-height: 1.25; }
.mode-text strong { font-size: var(--text-sm); }
.mode-text span { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.composer .tabs button.mode.reply.active { border-color: var(--accent); background: var(--accent-soft); }
.composer .tabs button.mode.reply.active .ico { color: var(--accent); }
.composer .tabs button.mode.note.active { border-color: var(--orange); background: var(--note-bg); }
.composer .tabs button.mode.note.active .ico { color: var(--warn); }
.composer.note { background: var(--note-bg); border-color: var(--orange); }
.composer.note .tabs button.mode:not(.active) { background: var(--surface); }
.composer.reply:not(.collapsed) { border-color: var(--accent); }
.mode-hint { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; margin-bottom: 10px; border-radius: var(--radius-md); font-size: var(--text-sm); }
.mode-hint .ico { margin-top: 2px; }
.mode-hint.reply { background: var(--accent-soft); color: var(--accent-strong); }
.mode-hint.note { background: color-mix(in srgb, var(--note-border) 40%, var(--note-bg)); color: var(--text); }
.mode-hint.note .ico { color: var(--warn); }
.composer.collapsed textarea { min-height: 60px; height: 60px; }

/* ---------- Right panel ---------- */
.prop-hint { font-size: var(--text-xs); color: var(--muted); margin-top: 4px; }
.prop-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.prop-label-row label { margin: 0; }
.field-form-label { font-size: var(--text-xs); font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.field-form-label + .inline-form { margin-top: 0; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1000px) {
  .msg.ours, .msg.note, .msg-event.ours { margin-left: 28px; }
}
@media (max-width: 760px) {
  .sidebar { flex-wrap: wrap; overflow-x: visible; gap: 4px; }
  .sidebar .view-link { grid-template-columns: 16px auto auto; gap: 6px; min-height: 30px; padding: 2px 8px 2px 6px; font-size: var(--text-sm); }
  .sidebar .shortcuts-link { display: none; }
  .nav-ico { width: 16px; height: 16px; }
  .nav-ico .ico { width: 15px; height: 15px; }
  .nav-hint { display: none; }
  .list-cols, .list-hint { display: none; }
  .ticket-head .title-row { flex-wrap: wrap; }
  .head-actions { order: 3; width: 100%; }
  .head-actions .btn { flex: 1; }
  .ticket-facts { gap: 10px 20px; padding: 10px 14px; }
  .msg.ours, .msg.note, .msg-event.ours { margin-left: 16px; }
  .msg-vis { padding-left: 18px; }
  .composer .tabs { grid-template-columns: 1fr 1fr; }
}

/* ---------- Round 2 fixes: controls live in the header strip; long threads fold ---------- */
.ticket-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 20px; padding: 14px 18px; }
.fact.control .field { width: 100%; }
.fact-label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 18px; }
.fact-label-row .btn-xs { min-height: 22px; padding: 0 8px; font-size: 11px; }
.fact > .fact-value { min-height: var(--control-h); }
.fact-hint { font-size: var(--text-xs); }
@media (max-width: 1200px) { .ticket-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.msg-fold { margin: 0 0 8px; }
.msg-fold.ours, .msg-fold.note { margin-left: 56px; }
.msg-fold > summary {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: var(--text-sm);
}
.msg-fold > summary::-webkit-details-marker { display: none; }
.msg-fold > summary:hover { border-color: var(--border-strong); }
.msg-fold.ours > summary { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); border-color: var(--accent-soft-2); }
.msg-fold.note > summary { background: var(--note-bg); border-color: var(--note-border); }
.msg-fold .name { font-weight: 700; white-space: nowrap; }
.fold-snippet { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.msg-fold[open] > summary { display: none; }
.msg-fold[open] > .msg { margin-left: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.msg-fold.ours .avatar.sm { background: var(--accent); color: var(--accent-text); }
.msg-fold.note .avatar.sm { background: var(--note-border); color: var(--warn); }
.avatar.sm .ico { width: 13px; height: 13px; }

@media (max-width: 1000px) { .msg-fold.ours, .msg-fold.note { margin-left: 28px; } }
@media (max-width: 760px) {
  .ticket-facts { grid-template-columns: 1fr 1fr; padding: 12px 14px; }
  .msg-fold.ours, .msg-fold.note { margin-left: 16px; }
  .msg-fold .fold-snippet { display: none; }
}

/* ---------- Round 3 fixes: phone menu folds behind one button; assign link under the picker ---------- */
.nav-toggle { display: none; }
.fact-hint .assign-me { font-size: var(--text-xs); font-weight: 600; }
@media (max-width: 760px) {
  .nav-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border: 0; border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  }
  .nav-toggle-label { font-size: var(--text-2xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sb-muted); }
  .nav-toggle-here { flex: 1; text-align: left; }
  .nav-toggle .ico { width: 16px; height: 16px; transition: transform 0.15s; }
  .sidebar.open .nav-toggle .ico { transform: rotate(180deg); }
  .sidebar:not(.open) > :not(.nav-toggle) { display: none !important; }
  .sidebar.open { padding-bottom: 12px; }
}

/* Agents page on a phone: one column, in reading order (name, customers see, role, status, button).
   The ticket-row placement above would otherwise move the second block beside the name. */
@media (max-width: 760px) {
  .agent-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .agent-row > div:nth-child(n) { grid-column: 1; grid-row: auto; justify-self: start; }
  .agent-name-edit .agent-name { max-width: none; width: 100%; }
}

/* "as Ella": the alias the customer saw, right after the agent's real name. */
.msg-head .sent-as { color: var(--muted); font-weight: 400; font-size: 0.92em; }
