/* The opening splash's fonts (admin/splash.js, the same as the admin area's: development's entry 66). Grid Central
   Modern is the owner's own font; DM Mono is under the SIL Open Font License (fonts/OFL-DMMono.txt). */
@font-face { font-family: "Grid Central Modern"; src: url("/admin/fonts/GridCentralModern-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url("/admin/fonts/DMMono-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* Grid Central Pitlane admin, in the same look as the membership admin (development's /membership page): a sidebar,
   dark surfaces, lime, rounded cards and Lucide icons (admin/icons.js). On a phone the sidebar becomes a slide-in menu
   with a top bar and a tab bar. The admin's Content-Security-Policy allows no inline styles, so every look is here.
   assets/themes.css (copied in as /admin/themes.css) adds the light scheme, accents and text sizes from Settings. */
:root {
  color-scheme: dark;
  --bg: #101112; --panel: #17191a; --surface-2: #1d2021; --surface-3: #23272a; --line: #2a2d2e; --border-2: #34383a;
  --text: #e9eae5; --soft: #c9ccc5; --muted: #9a9f98; --faint: #868b84;
  --accent: #d2ff50; --accent-text: #151810; --chip: #1d2021; --field: #101112; --edge: #34383a;
  --bad: #ff8f8f; --warn: #ffbe7a; --note: #2a2214; --hover: #1a1c1d;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --display: "Space Grotesk", "DM Sans", "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 14px;
}
:root[data-theme="light"] {
  --surface-2: #e4e6e7; --surface-3: #dcdfe0; --border-2: #c3c7c9; --soft: #2f322d; --faint: #6c716b;
  --note: #f6efd6; --hover: #e4e6e7; --warn: #8a5a00;
}

/* One colour per meaning, like the membership page's plans. */
.tone-lime { --tone: var(--accent); --tone-bg: color-mix(in srgb, var(--accent) 12%, transparent); }
.tone-blue { --tone: #8fd0ff; --tone-bg: rgba(143, 208, 255, 0.13); }
.tone-orange { --tone: #ffbe7a; --tone-bg: rgba(255, 190, 122, 0.13); }
.tone-violet { --tone: #cdb8ff; --tone-bg: rgba(205, 184, 255, 0.14); }
.tone-teal { --tone: #7ee0c3; --tone-bg: rgba(126, 224, 195, 0.12); }
.tone-pink { --tone: #ff9cc0; --tone-bg: rgba(255, 156, 192, 0.12); }
.tone-grey { --tone: #c3c7bf; --tone-bg: rgba(195, 199, 191, 0.1); }
.tone-red { --tone: #ff8f8f; --tone-bg: rgba(255, 143, 143, 0.12); }
:root[data-theme="light"] .tone-blue { --tone: #1f5fa8; --tone-bg: rgba(31, 95, 168, 0.1); }
:root[data-theme="light"] .tone-orange { --tone: #9a5000; --tone-bg: rgba(154, 80, 0, 0.1); }
:root[data-theme="light"] .tone-violet { --tone: #6d3fd1; --tone-bg: rgba(109, 63, 209, 0.1); }
:root[data-theme="light"] .tone-teal { --tone: #0a6a5a; --tone-bg: rgba(10, 106, 90, 0.1); }
:root[data-theme="light"] .tone-pink { --tone: #b01b7b; --tone-bg: rgba(176, 27, 123, 0.1); }
:root[data-theme="light"] .tone-grey { --tone: #4f534d; --tone-bg: rgba(79, 83, 77, 0.1); }
:root[data-theme="light"] .tone-red { --tone: #b42318; --tone-bg: rgba(180, 35, 24, 0.1); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.hidden { display: none !important; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: 10px; background: var(--accent);
  color: var(--accent-text); font-weight: 700; text-decoration: none; }
.skip:focus { top: 12px; }
[data-icon], .icon { display: inline-grid; place-items: center; flex: none; }
svg { flex: none; }

/* ---- Layout ---- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 18px; background: var(--panel); border-right: 1px solid var(--line); }
.page { min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 1260px; margin: 0 auto; padding: 32px 40px 56px; outline: none; }
.topbar, .tabbar, .sidebar .menu-close { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(5, 6, 6, 0.6); }

/* ---- Sidebar ---- */
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand a.home { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; color: var(--text); }
.logo { display: block; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; gap: 3px; }
.brand-text strong { font: 700 14px/1.1 var(--display); letter-spacing: 0.08em; }
.brand-text small { font-size: 11px; line-height: 1.1; letter-spacing: 0.14em; color: var(--muted); }
.finder { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--muted); }
.finder:focus-within { border-color: var(--border-2); }
.finder input[type="search"] { flex: 1; min-width: 0; height: auto; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; padding: 0; }
.finder input::-webkit-search-cancel-button { display: none; }
kbd { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; }
.nav { display: flex; flex-direction: column; gap: 18px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 9px; color: var(--soft);
  font-size: 14px; font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.nav-count { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.nav a[aria-current="page"] .nav-count { color: var(--accent); }
.me { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.me-person { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.me-text { min-width: 0; display: flex; flex-direction: column; }
.me-text span:first-child { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span:last-child { font-size: 12px; }
.me-link { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px; border-radius: 8px; font-size: 13px;
  color: var(--soft); text-decoration: none; }
.me-link:hover { color: var(--text); }
.avatar { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--accent); font: 600 13px/1 var(--display); }
.icon-button { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid transparent;
  border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.icon-button:hover { background: var(--surface-3); color: var(--text); }

/* ---- Page heads ---- */
h1 { font-size: 32px; line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin: 0 0 20px; }
.view-head h1 { margin: 0; }
.eyebrow { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.sub { margin: 6px 0 0; font-size: 14px; color: var(--muted); max-width: 760px; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: 0 0 12px; font-size: 14px; font-weight: 600; text-decoration: none; }
.banner { display: flex; gap: 12px; align-items: flex-start; background: color-mix(in srgb, var(--warn) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); color: var(--soft); border-radius: var(--radius); padding: 14px 18px; margin: 0 0 16px; font-size: 14px; }
.banner.bad { background: color-mix(in srgb, var(--bad) 8%, transparent); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }

/* ---- Cards ---- */
.card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card > h2:first-child { margin-top: 0; }
.group-head { margin: 32px 0 14px; padding-top: 20px; border-top: 1px solid var(--line); }
.group-head h2 { font-size: 22px; margin: 0; }
.stack { display: grid; gap: 12px; }
.stack label, .stack .group { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title h2 { margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- Fields and buttons ---- */
input[type="search"], input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-width: 0; font-size: 15px; color: var(--text); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; height: 44px; }
textarea { height: auto; padding: 10px 14px; resize: vertical; min-height: 96px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--border-2); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--faint); }
textarea.mono, pre { font-family: var(--mono); font-size: 13px; }
button.btn, a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: var(--accent-text);
  font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer; }
button.btn:hover, a.btn:hover { filter: brightness(1.08); }
button.btn.secondary, a.btn.secondary, button.btn.ghost, a.btn.ghost { border-color: var(--border-2); background: var(--surface-2); color: var(--text); font-weight: 600; filter: none; }
button.btn.secondary:hover, a.btn.secondary:hover, button.btn.ghost:hover, a.btn.ghost:hover { background: var(--surface-3); }
button.btn.danger { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; color: var(--bad); font-weight: 600; }
button.btn.danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); filter: none; }
button.btn.small { min-height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
button.btn[disabled] { opacity: 0.6; cursor: progress; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; color: var(--text) !important; }
.check input { accent-color: var(--accent); margin: 0; width: 16px; height: 16px; }

/* ---- Filters and chips ---- */
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(120px, 1fr)); gap: 10px; margin: 0 0 14px; }
.filters label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters input[type="search"], .filters input[type="text"], .filters select { height: 40px; font-size: 14px; padding: 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chips button { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--soft); font-size: 14px; font-weight: 600; cursor: pointer; }
.chips button:hover { border-color: var(--border-2); color: var(--text); }
.chips button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.chips-label { font-size: 13px; color: var(--muted); align-self: center; }

/* ---- Tables ---- */
.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.list th { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.list td { padding: 12px; border-bottom: 1px solid var(--surface-3); vertical-align: top; }
.list th:first-child, .list td:first-child { padding-left: 20px; }
.list th:last-child, .list td:last-child { padding-right: 20px; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.list tbody tr:hover td { background: var(--hover); }
.list td.num a { font-family: var(--display); font-weight: 700; text-decoration: none; white-space: nowrap; }
.list td.sum { width: 40%; min-width: 0; overflow-wrap: anywhere; }
.list td.sum > div:first-child { font-weight: 500; }
.list td.when { white-space: nowrap; color: var(--muted); font-size: 13px; }
.list .email { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.card .list { border: 0; border-radius: 0; background: transparent; }
.card .list th:first-child, .card .list td:first-child { padding-left: 0; }
.card .list th:last-child, .card .list td:last-child { padding-right: 0; }
.list.plain tbody tr { cursor: default; }
.list.plain tbody tr:hover td { background: none; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 16px; border: 1px dashed var(--border-2);
  border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty p { margin: 8px 0 0; }
.more { margin: 16px 0 40px; text-align: center; }

/* ---- Pills: ticket types, statuses and priorities ---- */
.badge { --tone: var(--soft); --tone-bg: var(--surface-2); display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--tone); background: var(--tone-bg); vertical-align: middle; }
.badge.type-bug, .badge.bad, .badge.pr-critical { --tone: #ff8f8f; --tone-bg: rgba(255, 143, 143, 0.12); }
.badge.type-feature, .badge.st-fixed_in_dev { --tone: #8fd0ff; --tone-bg: rgba(143, 208, 255, 0.13); }
.badge.type-help { --tone: #cdb8ff; --tone-bg: rgba(205, 184, 255, 0.14); }
.badge.st-new { --tone: var(--accent-text); --tone-bg: var(--accent); }
.badge.st-needs_info, .badge.note, .badge.pr-high { --tone: #ffbe7a; --tone-bg: rgba(255, 190, 122, 0.13); }
.badge.st-confirmed, .badge.ok { --tone: #7ee0c3; --tone-bg: rgba(126, 224, 195, 0.12); }
.badge.st-closed, .badge.pr-low { --tone: var(--muted); --tone-bg: transparent; box-shadow: inset 0 0 0 1px var(--line); }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-top: 1px solid var(--line); }
.kb-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.kb-hit { border-top: 1px solid var(--line); padding: 8px 0; }
.kb-hit summary { cursor: pointer; font-weight: 600; }
.kb-hit .kb-body { margin: 6px 0 8px; max-height: 240px; overflow: auto; }
.mention-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.badge.who { --tone: #b8e07e; --tone-bg: rgba(184, 224, 126, 0.12); margin-left: 4px; }
.badge.plan { --tone: #cdb8ff; --tone-bg: rgba(205, 184, 255, 0.13); margin-left: 4px; }
:root[data-theme="light"] .badge.plan { --tone: #6d3fd1; --tone-bg: rgba(109, 63, 209, 0.1); }
.badge.pr-medium { --tone: #ff9cc0; --tone-bg: rgba(255, 156, 192, 0.12); }
.badge.pr-critical { --tone: #2a0d0e; --tone-bg: #ff8f8f; }
:root[data-theme="light"] .badge.type-bug, :root[data-theme="light"] .badge.bad { --tone: #b42318; --tone-bg: rgba(180, 35, 24, 0.1); }
:root[data-theme="light"] .badge.type-feature, :root[data-theme="light"] .badge.st-fixed_in_dev { --tone: #1f5fa8; --tone-bg: rgba(31, 95, 168, 0.1); }
:root[data-theme="light"] .badge.type-help { --tone: #6d3fd1; --tone-bg: rgba(109, 63, 209, 0.1); }
:root[data-theme="light"] .badge.st-needs_info, :root[data-theme="light"] .badge.note, :root[data-theme="light"] .badge.pr-high { --tone: #8a4a00; --tone-bg: rgba(154, 80, 0, 0.1); }
:root[data-theme="light"] .badge.st-confirmed, :root[data-theme="light"] .badge.ok { --tone: #0a6a3a; --tone-bg: rgba(10, 106, 58, 0.1); }
:root[data-theme="light"] .badge.pr-medium { --tone: #a0186f; --tone-bg: rgba(176, 27, 123, 0.1); }
:root[data-theme="light"] .badge.pr-critical { --tone: #ffffff; --tone-bg: #b42318; }

/* ---- One ticket ---- */
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 8px; }
.title-row h1 { min-width: 0; overflow-wrap: anywhere; margin: 0; font-size: 28px; }
.title-row .num { color: var(--accent); }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 20px; }
.meta b { color: var(--soft); font-weight: 600; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; margin-bottom: 48px; }
.answers { display: grid; gap: 16px; }
.answer .q { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.answer .a { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer .a.none { color: var(--faint); }
.answer.code .a { font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; max-height: 360px; overflow: auto; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.files li { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.files .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.files .name { font-weight: 600; overflow-wrap: anywhere; }
.files img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-top: 10px; background: #000; }
.files pre, pre.lines { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0 0;
  max-height: 300px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
/* The history, as a timeline like the membership page's change history. */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history li { --tone: var(--muted); position: relative; padding: 0 0 18px 26px; }
.history li::before { content: ""; position: absolute; left: 0; top: 5px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--tone); box-sizing: border-box; }
.history li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 19px; bottom: 0; width: 2px; background: var(--line); }
.history li.created { --tone: var(--accent); }
.history li.reply { --tone: var(--accent); }
.history li.note { --tone: var(--warn); }
.history li.status, .history li.priority { --tone: #8fd0ff; }
.history li.failed { --tone: var(--bad); }
:root[data-theme="light"] .history li.status, :root[data-theme="light"] .history li.priority { --tone: #1f5fa8; }
.history li.note .body { background: var(--note); border-radius: 10px; padding: 8px 12px; }
.history .when { color: var(--muted); font-size: 12px; }
.history .what { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; font-weight: 500; }
.history .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; font-size: 14px; }
.history .err { color: var(--bad); font-size: 13px; overflow-wrap: anywhere; }
.dev textarea { min-height: 320px; }
.settings { max-width: 760px; margin: 0 0 48px; }

/* ---- Time ---- */
.time-now { margin: 0 0 2px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.time-now::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.time-now.on::before { background: var(--accent); }
.entries { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; }
.entries > li { padding: 8px 0; border-top: 1px solid var(--surface-3); }
.entries > li:first-child { border-top: 0; }
.entries .row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.log-time { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px; }
.log-time .btn { grid-column: 1 / -1; justify-self: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin: 0 0 16px; }
.tile { display: flex; flex-direction: column; gap: 12px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tile-name { font-size: 13px; font-weight: 600; color: var(--soft); }
.tile-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--tone-bg); color: var(--tone); }
.tile-value { font: 600 32px/1 var(--display); font-variant-numeric: tabular-nums; }
.tile .muted { font-size: 13px; }
.bar { display: block; width: 140px; max-width: 30vw; height: 6px; margin-top: 8px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 16px; }

/* ---- Notices ---- */
#toast { position: fixed; right: 24px; bottom: 24px; max-width: min(440px, calc(100% - 32px)); z-index: 60;
  display: none; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--border-2); border-radius: 12px;
  background: var(--surface-2); color: var(--text); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); font-size: 14px; }
#toast::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
#toast.show { display: flex; }
#toast.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
#toast.bad::before { background: var(--bad); }
:root[data-theme="light"] #toast { box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15); }

/* ---- Phones and small windows ---- */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(300px, 86vw); height: 100%; transform: translateX(-105%); transition: transform 0.2s ease; }
  .menu-open .sidebar { transform: none; }
  .sidebar .menu-close { display: inline-grid; margin-left: auto; }
  .topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 12px 0 16px;
    background: var(--panel); border-bottom: 1px solid var(--line); }
  .topbar .logo { width: 32px; height: 32px; flex-basis: 32px; }
  .topbar-title { flex: 1; font: 600 15px var(--display); }
  .topbar .icon-button { width: 44px; height: 44px; color: var(--text); }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; gap: 4px; height: calc(72px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0;
    border: 0; border-radius: 12px; background: transparent; color: var(--soft); font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; }
  .tabbar a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
  main { padding: 16px 16px 100px; }
  h1 { font-size: 26px; }
  .title-row h1 { font-size: 22px; }
  .detail { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label:first-child { grid-column: 1 / -1; }
  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; width: 100% !important; }
  .list tr { border-bottom: 1px solid var(--surface-3); padding: 10px 0; }
  .list tbody tr:last-child { border-bottom: 0; }
  .list td, .list td:first-child, .list td:last-child { border: 0; padding: 2px 16px; }
  .card .list td, .card .list td:first-child, .card .list td:last-child { padding: 2px 0; }
  #toast { right: 16px; left: 16px; bottom: 88px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Automatic emails: each email's wording, opened under its switch. */
.preview summary { cursor: pointer; font-size: 13px; color: var(--accent); width: max-content; }
.preview pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0 0;
  white-space: pre-wrap; overflow-wrap: anywhere; }
.row-actions > label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.row-actions input[type="number"] { width: 120px; }

/* Languages: a ticket in Spanish or German, shown in English (admin.js languageCard, translator). */
.badge.lang-es, .badge.lang-de { --tone: #cdb8ff; --tone-bg: rgba(205, 184, 255, 0.14); }
:root[data-theme="light"] .badge.lang-es, :root[data-theme="light"] .badge.lang-de { --tone: #6d3fd1; --tone-bg: rgba(109, 63, 209, 0.1); }
.original-title { margin: -4px 0 10px; font-size: 14px; }
.lang-card .row-actions { align-items: center; flex-wrap: nowrap; }
.lang-card .row-actions p { flex: 1; margin: 0; color: var(--soft); }
.lang-card .row-actions svg { flex: 0 0 auto; color: var(--accent); }
.lang-card.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
details.original { margin-top: 6px; font-size: 14px; }
details.original summary { color: var(--muted); cursor: pointer; }
details.original .a, details.original .body { margin-top: 4px; padding-left: 10px; border-left: 2px solid var(--line); color: var(--soft); }
.history .body.translated { color: var(--soft); }
.translator { border-top: 1px dashed var(--line); padding-top: 12px; }
.back-check .back-text { margin-top: 4px; padding-left: 10px; border-left: 2px solid var(--line); color: var(--soft);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.back-check .back-text:empty { display: none; }
.back-check .row-actions { align-items: center; }
.back-check .row-actions p { margin: 0; }
.warn-text { color: var(--warn); margin: 0; }
@media (max-width: 560px) { .lang-card .row-actions { flex-wrap: wrap; } }

/* Buttons above a page's cards (the audit log). */
.page-tools { margin-bottom: 16px; }
.nav-count.alert { color: var(--bad); font-weight: 700; }

/* Settings, Routing: one box per rule. */
fieldset.rule { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0; min-width: 0; }
fieldset.rule h3 { margin: 0 0 8px; font-size: 15px; }
fieldset.rule .filters { margin: 0 0 8px; }

/* Settings, Spike alerts: the numbers sit in the sentence. */
.spike-line { margin: 0; }
.spike-line input[type="number"] { width: 5.5em; display: inline-block; margin: 0 4px; }

/* Settings, Webhooks */
.hook-events { display: flex; flex-wrap: wrap; gap: 6px 18px; }
code.secret { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; background: var(--chip, transparent); padding: 1px 5px; border-radius: 5px; }

/* The customer panel's account facts (lib/customer.js). */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Security training: one question per fieldset (admin.js showTraining). */
fieldset.quiz-q { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
fieldset.quiz-q legend { padding: 0; margin-bottom: 8px; }
