/* Shopmorphic platform pages. Lightmorphic house style: solid panels,
   one accent, self-hosted Manrope, no framework, nothing loaded from
   outside this origin. */

@font-face {
  font-family: "Manrope";
  src: url("../fonts/Manrope-Variable.woff2") format("woff2-variations"),
       url("../fonts/Manrope-Variable.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #f4f4f6;  --fg: #09090b;
  --panel: #ffffff;  --panel-border: rgba(24, 24, 40, 0.10);
  --border: #c9cbd3;  --muted: #f4f4f5;  --muted-fg: #71717a;
  --shadow-panel: 0 1px 2px rgba(24,24,40,.05), 0 8px 24px -16px rgba(24,24,40,.18);

  /* Shopmorphic's own accent: Lightmorphic palette Blue. (Lightmorphic is
     yellow, Castmorphic is orange; each product gets one colour.) */
  --accent: #2295f1;  --accent-hover: #1e83d4;  --on-accent: #0a2a43;
  --accent-container: #e4f2fd;  --on-accent-container: #0d395c;

  --brand-navy: #111827;
  --link: #1b74bc;
  --danger: #cc372d;   --danger-bg: #fef2f1;
  --success: #38813a;  --success-bg: #f2f9f3;
  --warning: #8f6c03;  --warning-bg: #fffbee;
  --info: #1b74bc;     --info-bg: #f0f8fe;

  --radius: 0.875rem;
  --panel-radius: 1.375rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;  --fg: #fafafa;
    --panel: #1b1d29;  --panel-border: rgba(255,255,255,.09);
    --border: #444756;  --muted: #1c1c1f;  --muted-fg: #a1a1aa;
    --shadow-panel: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -16px rgba(0,0,0,.6);
    --accent-hover: #3da2f3;
    --accent-container: #0a2d48;  --on-accent-container: #9ccff9;
    --link: #2295f1;
    --danger: #f34236;   --danger-bg: #350f0c;
    --success: #4bae4f;  --success-bg: #102611;
    --warning: #ffc006;  --warning-bg: #382a01;
    --info: #2295f1;     --info-bg: #072135;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1117;  --fg: #fafafa;
  --panel: #1b1d29;  --panel-border: rgba(255,255,255,.09);
  --border: #444756;  --muted: #1c1c1f;  --muted-fg: #a1a1aa;
  --shadow-panel: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -16px rgba(0,0,0,.6);
  --accent-hover: #3da2f3;
  --accent-container: #0a2d48;  --on-accent-container: #9ccff9;
  --link: #2295f1;
  --danger: #f34236;   --danger-bg: #350f0c;
  --success: #4bae4f;  --success-bg: #102611;
  --warning: #ffc006;  --warning-bg: #382a01;
  --info: #2295f1;     --info-bg: #072135;
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -999px; top: 0.5rem;
  background: var(--panel); color: var(--fg); padding: .5rem .75rem;
  border-radius: var(--radius); border: 1px solid var(--panel-border);
}
.skip-link:focus { left: 0.5rem; z-index: 10; }

.site-header, .site-main, .site-footer {
  width: min(100% - 2.5rem, 68rem);
  margin-inline: auto;
}
.site-header { padding: 1.5rem 0; }
.brand {
  display: inline-flex; align-items: center; gap: .625rem;
  text-decoration: none; color: var(--fg); font-weight: 700; font-size: 1.125rem;
}
.brand-mark { width: 1.75rem; height: 1.75rem; color: var(--brand-navy); fill: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-mark { color: var(--accent); }
}

.site-main { flex: 1; padding: 2rem 0 4rem; }
.site-footer { padding: 1.5rem 0 2.5rem; color: var(--muted-fg); font-size: .8125rem; }

.hero { max-width: 44rem; padding: 2rem 0 2.5rem; }
.eyebrow {
  display: inline-block; margin: 0 0 1rem;
  padding: .25rem .75rem; border-radius: 999px;
  background: var(--accent-container); color: var(--on-accent-container);
  font-size: .8125rem; font-weight: 600;
}
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 1rem; }
.lede { font-size: 1.125rem; color: var(--muted-fg); margin: 0; max-width: 40rem; }

.points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--shadow-panel);
  padding: 1.5rem;
}
.panel h2 { font-size: 1.0625rem; font-weight: 600; margin: 0 0 .5rem; }
.panel p { margin: 0; color: var(--muted-fg); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- App shell (dashboard and platform admin) ----------
   Same shape as Lightmorphic Portal: floating sidebar panel, an optional
   second column for the section's pages, and the content panel, all
   sitting on the page background with air between them. */
body.shell { display: block; }
.app { display: flex; align-items: stretch; gap: 20px; padding: 20px; min-height: 100vh; box-sizing: border-box; }
@media (min-width: 900px) { .app { max-width: 96rem; margin: 0 auto; } }
.sidebar {
  flex-shrink: 0; width: 240px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--panel-radius); box-shadow: var(--shadow-panel);
  padding: 16px 12px; position: sticky; top: 20px; height: calc(100vh - 40px); overflow-y: auto; box-sizing: border-box; z-index: 100;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; margin: 4px 4px 12px 8px; }
.brand { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--fg); font-weight: 700; font-size: 1.0625rem; }
.brand-mark { width: 1.5rem; height: 1.5rem; color: var(--brand-navy); fill: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-mark { color: var(--accent); } }
.nav-burger { display: none; font-size: 1.25rem; cursor: pointer; padding: .25rem .5rem; border-radius: var(--radius); }
.nav-toggle { position: absolute; opacity: 0; width: 0; height: 0; }
.sidebar-menu { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-fg); }
.sidenav .nav-group:first-child { margin-top: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; width: 100%; box-sizing: border-box;
  border-radius: var(--radius); color: var(--muted-fg); text-decoration: none; font-size: 14px; font-weight: 500;
  background: none; border: 0; font-family: inherit; cursor: pointer; text-align: left;
}
.nav-link:hover { background: var(--muted); color: var(--fg); }
.nav-link.is-active { background: var(--accent-container); color: var(--on-accent-container); font-weight: 600; }
.nav-icon { width: 18px; height: 18px; flex: none; }
.nav-badge { margin-left: auto; min-width: 18px; padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; background: var(--accent-container); color: var(--on-accent-container); }
.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.sidebar-shop { margin: 0 10px 8px; font-size: .8125rem; color: var(--muted-fg); word-break: break-word; }
.sidebar-shop a { color: var(--muted-fg); }
.avail { margin: 0 4px 6px; }
.avail-switch { margin: 0; min-height: 2.5rem; font-size: 14px; color: var(--fg); }
.subnav {
  flex-shrink: 0; width: 13rem; display: flex; flex-direction: column; gap: 2px; padding: 10px; position: sticky; top: 20px;
  height: calc(100vh - 40px); box-sizing: border-box; overflow-y: auto;
}
.subnav a { display: block; padding: 9px 12px; border-radius: var(--radius); color: var(--fg); text-decoration: none; font-size: 15px; font-weight: 500; }
.subnav a:hover { background: var(--muted); }
.subnav a[aria-current="page"] { background: var(--accent-container); color: var(--on-accent-container); font-weight: 600; }
.content { flex: 1; min-width: 0; padding: clamp(1.25rem, 3vw, 2rem); }
.content.panel { border-radius: var(--panel-radius); }
@media (max-width: 900px) {
  .app { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar { position: static; height: auto; width: auto; }
  .nav-burger { display: inline-block; }
  .sidebar-menu { display: none; }
  .nav-toggle:checked ~ .sidebar .sidebar-menu { display: flex; }
  .subnav { position: static; width: auto; height: auto; flex-direction: row; flex-wrap: wrap; }
}

.page-title { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 1.5rem; }
.panel-title { font-size: 1.0625rem; font-weight: 600; margin: 0 0 1rem; }
.panel + .panel, .form-panel + .panel { margin-top: 1.25rem; }
.panel-title + .panel-title, .field + .panel-title { margin-top: 1.5rem; }
.lede-small { color: var(--muted-fg); max-width: 60ch; margin: -0.75rem 0 1.5rem; }
.narrow { max-width: 28rem; margin: 2rem auto; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .grid-2-1 { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; gap: .25rem; }
.stat-n { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-l { color: var(--muted-fg); font-size: .875rem; }
.stat-bad .stat-n { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Forms ---------- */
.field { margin: 0 0 1.125rem; }
.field label { display: block; font-size: .9375rem; font-weight: 600; margin-bottom: .375rem; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  display: block; width: 100%; box-sizing: border-box;
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: .625rem .875rem; min-height: 2.75rem;
}
.field textarea { min-height: 7rem; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.hint { font-size: .8125rem; color: var(--muted-fg); margin: .375rem 0 0; }
.hint-inline { font-size: .8125rem; color: var(--muted-fg); font-weight: 400; }
.error { font-size: .8125rem; color: var(--danger); margin: .375rem 0 0; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1.25rem; }
.secret-row { display: flex; gap: .75rem; align-items: center; }
.secret-row input { flex: 1; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875em; background: var(--muted); padding: .1em .35em; border-radius: .35em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: .625rem 1.125rem; min-height: 2.75rem; border-radius: var(--radius);
  border: 1px solid transparent; transition: background .15s ease;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--muted); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger, .btn.is-armed { background: var(--danger); color: #fff; border-color: transparent; }
.btn-small { padding: .375rem .75rem; min-height: 2.25rem; font-size: .875rem; }
.btn-link { background: none; border: 0; color: var(--link); font: inherit; cursor: pointer; padding: 0; }

.switch { display: inline-flex; align-items: center; gap: .625rem; cursor: pointer; min-height: 2.75rem; margin-bottom: .75rem; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { flex: none; width: 2.75rem; height: 1.5rem; background: var(--border); border: 1px solid var(--panel-border); border-radius: 999px; position: relative; transition: background .15s ease; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 1.125rem; height: 1.125rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(24,24,40,.3); transition: transform .15s ease; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(1.25rem); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"]:not(.switch input), input[type="radio"] { width: 1.125rem; height: 1.125rem; flex: none; accent-color: var(--accent); cursor: pointer; }
.field-check { display: flex; align-items: center; gap: .625rem; min-height: 2.75rem; cursor: pointer; }

/* ---------- Feedback ---------- */
.flashes { display: none; }
.notes { display: flex; flex-direction: column; gap: .5rem; }
.notes-inline { width: 100%; margin-top: .75rem; }
.notes-fixed { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 200; max-width: 22rem; }
.note { display: flex; align-items: flex-start; gap: .625rem; padding: .625rem .875rem; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow-panel); font-size: .9375rem; transition: opacity .4s ease; }
.note.is-fading { opacity: 0; }
.note-mark { flex: none; width: 1.25rem; height: 1.25rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; background: var(--success-bg); color: var(--success); }
.note-error .note-mark { background: var(--danger-bg); color: var(--danger); }
.note-warning .note-mark { background: var(--warning-bg); color: var(--warning); }
.note-info .note-mark { background: var(--info-bg); color: var(--info); }
.note-close { margin-left: auto; background: none; border: 0; font: inherit; font-size: 1.125rem; line-height: 1; color: var(--muted-fg); cursor: pointer; padding: 0 .125rem; }
.note-close:hover { color: var(--fg); }
/* Standing notices on a page: a neutral panel with a coloured mark, never a painted box. */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-weight: 500; background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow-panel); margin-bottom: 1rem; display: flex; gap: .625rem; align-items: flex-start; }
.alert::before { content: "i"; flex: none; width: 1.25rem; height: 1.25rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; background: var(--info-bg); color: var(--info); }
.alert-success::before { content: "✓"; background: var(--success-bg); color: var(--success); }
.alert-error::before { content: "!"; background: var(--danger-bg); color: var(--danger); }
.alert-warning::before { content: "!"; background: var(--warning-bg); color: var(--warning); }
.alert a { color: var(--link); }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; background: var(--muted); color: var(--muted-fg); white-space: nowrap; }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-bad { background: var(--danger-bg); color: var(--danger); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }

/* ---------- Tables and lists ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-fg); padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.table td { padding: .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .wrap { max-width: 24rem; word-break: break-word; font-size: .8125rem; color: var(--muted-fg); }
.table form { display: inline; }
.panel:has(> .table) { overflow-x: auto; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .625rem; }
.checklist li { display: flex; gap: .625rem; align-items: baseline; }
.checklist .mark { width: 1.25rem; text-align: center; color: var(--muted-fg); font-weight: 700; }
.checklist li.done { color: var(--muted-fg); }
.checklist li.done .mark { color: var(--success); }
.checklist a { color: var(--fg); }

/* ---------- Catalogue ---------- */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.title-row .page-title { margin: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .row-2 { grid-template-columns: 1fr; } }
.subform { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.thumb { width: 3rem; height: 3rem; object-fit: cover; border-radius: .5rem; display: block; background: var(--muted); }
.thumb-empty { border: 1px dashed var(--border); }
.thumb-cell { width: 3.5rem; }
.image-grid { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.image-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .75rem; background: var(--muted); display: block; }
.image-actions { display: flex; gap: .375rem; flex-wrap: wrap; margin-top: .375rem; align-items: center; }
.cell { width: 6rem; font: inherit; padding: .375rem .5rem; border: 1.5px solid var(--border); border-radius: .5rem; background: var(--bg); color: var(--fg); }
.cell-s { width: 4.5rem; }
.plain-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .25rem 1rem; margin-bottom: .5rem; }
.field input[type="file"] { padding: .5rem; }

/* ---------- Design page ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; }
.swatch { position: relative; width: 2.25rem; height: 2.25rem; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch .dot { display: block; width: 100%; height: 100%; border-radius: 50%; border: 3px solid transparent; }
.swatch input:checked + .dot { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg) inset; }
.swatch input:focus-visible + .dot { outline: 2px solid var(--accent); outline-offset: 2px; }
.dot-red{background:#f34236}.dot-pink{background:#e8207e}.dot-purple{background:#9b26ae}.dot-deep_purple{background:#6639ab}.dot-indigo{background:#3d51b4}.dot-blue{background:#2295f1}.dot-light_blue{background:#03a8f3}.dot-cyan{background:#00bcd3}.dot-teal{background:#019587}.dot-green{background:#4bae4f}.dot-light_green{background:#8ac248}.dot-lime{background:#cbdc38}.dot-yellow{background:#fbc711}.dot-amber{background:#ffc006}.dot-orange{background:#fe9700}.dot-deep_orange{background:#ff5721}.dot-brown{background:#795649}.dot-grey{background:#9e9d9e}.dot-blue_grey{background:#607c8b}
.logo-preview { max-width: 100%; max-height: 6rem; margin-bottom: .75rem; background: var(--muted); padding: .5rem; border-radius: var(--radius); }

/* ---------- Docs ---------- */
.doc { max-width: 70ch; }
.doc h1 { font-size: 2rem; letter-spacing: -0.02em; }
.doc h2 { font-size: 1.375rem; margin-top: 2rem; }
.doc pre { background: var(--muted); padding: 1rem; border-radius: var(--radius); overflow-x: auto; font-size: .875rem; }
.doc code { font-size: .875em; }
.doc pre code { background: none; padding: 0; }
.doc li { margin: .25rem 0; }

/* ---------- Orders ---------- */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { text-decoration: none; color: var(--muted-fg); padding: .5rem .875rem; border-radius: var(--radius); font-weight: 500; }
.tabs a[aria-current="page"] { background: var(--accent-container); color: var(--on-accent-container); font-weight: 600; }
.totals-list { list-style: none; margin: 1rem 0 0; padding: 0; max-width: 24rem; margin-left: auto; }
.totals-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; }
.totals-list .grand { border-top: 1px solid var(--border); margin-top: .5rem; padding-top: .5rem; font-weight: 700; }
.row-actions { white-space: nowrap; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--accent); }

/* ---------- Analytics ---------- */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 8rem; padding-top: .5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; }
.bar { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-dot { position: absolute; top: -.25rem; width: .375rem; height: .375rem; border-radius: 50%; background: var(--success); }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: minmax(16rem, 1fr) 2fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .inbox { grid-template-columns: 1fr; } }
.inbox-list { padding: .5rem; max-height: 75vh; overflow-y: auto; }
.inbox-row { display: grid; grid-template-columns: auto 1fr auto; gap: .625rem; align-items: center; padding: .625rem .75rem; border-radius: var(--radius); text-decoration: none; color: inherit; }
.inbox-row:hover { background: var(--muted); }
.inbox-row.is-current { background: var(--accent-container); }
.inbox-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: .625rem; height: .625rem; border-radius: 50%; background: var(--border); }
.dot-wait { background: var(--warning); }
.dot-new { background: var(--info); }
.thread-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.thread { display: flex; flex-direction: column; gap: .625rem; max-height: 50vh; overflow-y: auto; padding: 1rem; background: var(--muted); border-radius: var(--radius); margin-bottom: 1rem; }
.tmsg { max-width: 85%; }
.tmsg-operator, .tmsg-ai { align-self: flex-end; text-align: right; }
.tbubble { display: inline-block; padding: .5rem .8rem; border-radius: 12px; background: var(--panel); border: 1px solid var(--panel-border); white-space: pre-wrap; text-align: left; }
.tmsg-operator .tbubble { background: var(--accent-container); color: var(--on-accent-container); }
.tmsg-ai .tbubble { background: var(--info-bg); color: var(--info); }
.tmsg-system .tbubble { background: transparent; border-style: dashed; color: var(--muted-fg); font-size: .875rem; }
.tmeta { font-size: .75rem; color: var(--muted-fg); margin-top: .2rem; }
.qr { position: relative; display: inline-block; }
.qr summary { list-style: none; display: inline-flex; }
.qr-list { position: absolute; z-index: 5; top: 2.5rem; left: 0; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow-panel); padding: .5rem; width: 20rem; max-height: 18rem; overflow-y: auto; display: flex; flex-direction: column; gap: .25rem; }
.qr-list input { font: inherit; padding: .4rem .6rem; border: 1.5px solid var(--border); border-radius: .5rem; background: var(--bg); color: var(--fg); }
.qr-item { text-align: left; font: inherit; background: none; border: 0; padding: .4rem .5rem; border-radius: .5rem; cursor: pointer; color: var(--fg); }
.qr-item:hover { background: var(--muted); }
.codes { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .375rem; }

/* ---------- Emails screen ---------- */
.emails { display: grid; grid-template-columns: minmax(14rem, 1fr) 2.2fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .emails { grid-template-columns: 1fr; } }
.email-list { padding: .75rem; display: flex; flex-direction: column; gap: .125rem; }
.email-list a { display: block; padding: .5rem .75rem; border-radius: var(--radius); color: var(--fg); text-decoration: none; font-size: .9375rem; }
.email-list a:hover { background: var(--muted); }
.email-list a[aria-current="page"] { background: var(--accent-container); color: var(--on-accent-container); font-weight: 600; }
.email-preview { width: 100%; height: 30rem; border: 1px solid var(--border); border-radius: var(--radius); background: #f4f4f5; }
.digest-form { padding: .5rem .75rem; }
.thread-tall { max-height: 60vh; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: inherit; color: var(--link); cursor: pointer; }
.edit-form { margin-top: .5rem; display: flex; gap: .5rem; align-items: flex-start; }
.edit-form textarea { flex: 1; font: inherit; padding: .5rem; border: 1.5px solid var(--border); border-radius: .5rem; background: var(--bg); color: var(--fg); }
.tick { color: var(--muted-fg); }
.fields li { align-items: baseline; }
.btn-reset { margin-left: .5rem; min-height: 1.75rem; padding: .1rem .5rem; font-size: .75rem; font-weight: 600; vertical-align: middle; }

body.public { background: var(--panel); }

/* ---------- System page ---------- */
.health__verdict { margin: 0 0 .75rem; }
.health__warnings { margin: 0 0 1rem; padding-left: 1.25rem; }
.health__charts { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; margin: 1rem 0; }
.health__ring, .health__pie { margin: 0; display: flex; flex-direction: column; align-items: center; gap: .25rem; width: 8.5rem; }
.ring, .pie { width: 7.5rem; height: 7.5rem; }
.ring__track { stroke: var(--border); }
.ring__big { font-size: 22px; font-weight: 700; fill: var(--fg); font-family: inherit; }
.ring__small { font-size: 11px; fill: var(--muted-fg); }
.ring__label { font-size: .8125rem; color: var(--muted-fg); text-align: center; }
.pie__legend { list-style: none; margin: 0; padding: 0; font-size: .8125rem; color: var(--muted-fg); }
.health__strips { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem; margin: 1rem 0; }
.health__h3 { font-size: .9375rem; margin: 0 0 .5rem; }
.hbar { display: grid; grid-template-columns: 6rem 1fr; gap: .625rem; align-items: center; margin: .35rem 0; font-size: .8125rem; color: var(--muted-fg); }
.hbar svg { height: .625rem; width: 100%; }
.hbar__track { fill: var(--border); }
.jobdots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .375rem; font-size: .9375rem; }
.jobdots .dot { display: inline-block; margin-right: .5rem; vertical-align: middle; }
.dot-ok { background: var(--success); } .dot-bad { background: var(--danger); }
.health__facts summary, .health__facts { margin-top: .5rem; }
.health__facts summary { cursor: pointer; font-weight: 600; }
.health__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-top: .75rem; }
.health__group { margin: 0; }
.health__group dt { font-weight: 600; margin-bottom: .25rem; }
.health__group dd { margin: 0 0 .25rem; font-size: .9375rem; color: var(--muted-fg); }
.chat-pub { max-width: 44rem; margin: 1rem auto; }
.chat-pub .thread { max-height: 55vh; }
.search-inline { display: flex; gap: .5rem; align-items: center; }
.search-inline input[type="search"] { font: inherit; padding: .4rem .7rem; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--fg); min-width: 14rem; }
.tabs-top { margin-bottom: 1rem; }

/* Second column with a conversation list under a separator (Ask us, Enquiries) */
.subnav-wide { width: 19rem; }
.subnav-sep { border: 0; border-top: 1px solid var(--border); margin: .5rem 0; }
.subnav .inbox-list { padding: 0; max-height: none; overflow: visible; display: flex; flex-direction: column; gap: 2px; }
.subnav .inbox-row { padding: .5rem .625rem; }
.inbox-thread-only { grid-template-columns: 1fr; }
@media (max-width: 900px) { .subnav-wide { width: auto; } .subnav .inbox-list { width: 100%; } }

.impersonation-banner { justify-content: space-between; align-items: center; }
.impersonation-banner form { margin-left: auto; }

/* Dots on conversation lists: yellow = waiting for somebody, red = somebody has it open */
.dot-wait { background: #ffc006; }
.dot-claimed { background: #f34236; }

.perm { display: inline-block; position: relative; }
.perm summary { list-style: none; display: inline-flex; }
.perm-form { position: absolute; z-index: 5; right: 0; top: 2.5rem; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow-panel); padding: .75rem 1rem; width: 22rem; display: flex; flex-direction: column; }
.perm-form .switch { margin: 0; }

/* ---------- Bento (Settings) ---------- */
/* Charlie's rule: a bento packs the most information into the least space.
   Every card is a regular width (three per row); bento-pack.js measures each
   card and sets its row span over 8px rows, so dense flow slots a short card
   under a short one and no hole is left. Start alignment: nothing stretches. */
.bento { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 8px; grid-auto-flow: dense; gap: 1.25rem; align-items: start; }
.bento > .panel { margin: 0; }
@media (max-width: 1100px) { .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .bento { grid-template-columns: 1fr; grid-auto-rows: auto; } }
.bento .panel + .panel { margin-top: 0; }

/* ---------- Message box (Ask us and Enquiries, both sides) ---------- */
.compose { display: flex; gap: .6rem; align-items: flex-end; margin-top: .75rem; }
.compose-box { flex: 1; min-width: 0; }
.compose textarea { display: block; width: 100%; box-sizing: border-box; font: inherit; font-size: .95rem; line-height: 1.45; padding: .6rem .8rem; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--fg); resize: none; overflow: hidden; min-height: calc(3 * 1.45 * .95rem + 1.2rem + 3px); }
.compose-btn { flex: 0 0 auto; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 1.5px solid var(--border); background: var(--panel); color: var(--fg); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; list-style: none; }
.compose-btn::-webkit-details-marker { display: none; }
.compose-send { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.compose-send:hover { filter: brightness(1.08); }
.compose-plus { position: relative; }
.compose-menu { position: absolute; z-index: 6; bottom: 3.1rem; left: 0; min-width: 16rem; max-width: 22rem; max-height: 20rem; overflow-y: auto; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow-panel); padding: .5rem; display: flex; flex-direction: column; gap: .125rem; }
.compose-menu hr { border: 0; border-top: 1px solid var(--panel-border); margin: .375rem 0; }
.compose-menu input[type=search] { font: inherit; padding: .4rem .6rem; border: 1.5px solid var(--border); border-radius: .5rem; background: var(--bg); color: var(--fg); margin-bottom: .25rem; }
.compose-item { display: block; text-align: left; font: inherit; background: none; border: 0; padding: .5rem .625rem; border-radius: .5rem; cursor: pointer; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose-item:hover { background: var(--muted); }
.compose-file { display: block; margin: .25rem .5rem 0; }
.compose-picker { display: flex; flex-wrap: wrap; gap: .375rem; align-items: center; margin-top: .75rem; }
.compose-picker input[type=search] { font: inherit; font-size: .9rem; padding: .35rem .6rem; border: 1.5px solid var(--border); border-radius: .5rem; background: var(--bg); color: var(--fg); width: 11rem; }
.compose-picker .qr-item { font: inherit; font-size: .875rem; padding: .3rem .7rem; border: 1.5px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--fg); cursor: pointer; max-width: 16rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose-picker .qr-item:hover { background: var(--muted); }
.compose-picker + .compose { margin-top: .5rem; }
.compose-hint { margin: .375rem 0 0; }
