/*
 * TNG Portal. One stylesheet: themes and accents as tokens on <html>, set by the server from each
 * login's display settings, then the shell, the overview and the pages. Spacing moves in 4px steps;
 * radius is 12px for panels and dialogs, 7px for controls and 4px for tags. Colour carries meaning:
 * the accent marks what you can act on, green/amber/red/blue are status and never change.
 */

@font-face { font-family: 'Instrument Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/instrument-sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/instrument-sans-500.woff2') format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/instrument-sans-600.woff2') format('woff2'); }

/* Themes ------------------------------------------------------------------------------ */

:root {
  --font: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, 'Courier New', monospace;
  --fs: 14px;
  --fs-sm: 13px;
  --fs-xs: 12px;
  --radius: 12px;
  --radius-sm: 7px;

  color-scheme: dark;
  --bg: #141518;
  --rail: #101114;
  --surface: #191a1e;
  --surface-2: #1f2125;
  --surface-3: #282a30;
  --line: #25272c;
  --line-strong: #353840;
  --ink: #e7e8eb;
  --muted: #a0a4ad;
  --faint: #6c717b;
  --ok: #6cc690;
  --ok-soft: #13261b;
  --warn: #e3b656;
  --warn-soft: #2a2312;
  --warn-line: #4c3d19;
  --bad: #f17c75;
  --bad-soft: #2c1718;
  --bad-line: #5a2b2b;
  --bad-ink: #1a0504;
  --info: #8aadff;
  --shadow: 0 10px 28px rgb(0 0 0 / 0.45);
  --overlay: rgb(0 0 0 / 0.55);

  --accent: #8aadff;
  --accent-hover: #a5c0ff;
  --accent-solid: #3d6ef0;
  --accent-solid-hover: #4b7bf5;
  --accent-ink: #ffffff;
  --accent-soft: #1a2340;
  --accent-line: color-mix(in srgb, var(--accent) 28%, var(--line));
  --panel: color-mix(in srgb, var(--surface) 55%, var(--surface-2));
  --mark: var(--ink);
}

/* Black: near-black and neutral, for the accent to carry the colour. */
html[data-theme='black'] {
  --bg: #0b0b0c;
  --rail: #070708;
  --surface: #121213;
  --surface-2: #18181a;
  --surface-3: #222224;
  --line: #1f1f21;
  --line-strong: #2e2e31;
  --ink: #ececed;
  --muted: #a1a1a7;
  --faint: #6b6b72;
  --ok: #63c27f;
  --ok-soft: #102016;
  --warn: #e2b555;
  --warn-soft: #241d0f;
  --warn-line: #463818;
  --bad: #f07a72;
  --bad-soft: #261414;
  --bad-line: #532828;
  --accent-soft: #141c33;
}

html[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f5f3;
  --rail: #eeeeeb;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --surface-3: #e8e8e4;
  --line: #e2e2de;
  --line-strong: #cbcbc6;
  --ink: #1c1d20;
  --muted: #5b5e65;
  --faint: #8a8d94;
  --ok: #1d8a4b;
  --ok-soft: #e2f3e8;
  --warn: #946500;
  --warn-soft: #fbf2dc;
  --warn-line: #ead39b;
  --bad: #c2352f;
  --bad-soft: #fcebe9;
  --bad-line: #f0bcb7;
  --bad-ink: #ffffff;
  --info: #2c5fd4;
  --shadow: 0 10px 28px rgb(24 26 32 / 0.14), 0 2px 6px rgb(24 26 32 / 0.06);
  --overlay: rgb(24 26 32 / 0.32);
  --accent: #2c5fd4;
  --accent-hover: #234fb8;
  --accent-solid: #2c5fd4;
  --accent-solid-hover: #234fb8;
  --accent-soft: #e8eefc;
  --panel: var(--surface);
}

/* Accents on the dark themes. Each is tuned for contrast; warnings shift yellow beside orange. */
html:not([data-theme='light'])[data-accent='purple'] { --accent: #c3a9f3; --accent-hover: #d3bff7; --accent-solid: #7651b9; --accent-solid-hover: #825ec4; --accent-ink: #ffffff; --accent-soft: #241e36; }
html:not([data-theme='light'])[data-accent='orange'] { --accent: #f29a5c; --accent-hover: #f6ad7a; --accent-solid: #e9823f; --accent-solid-hover: #ef9152; --accent-ink: #1f0e04; --accent-soft: #2c2017; --warn: #e6c650; --warn-soft: #2a2410; --warn-line: #4d4317; }
html:not([data-theme='light'])[data-accent='green'] { --accent: #5fdc7c; --accent-hover: #7ce594; --accent-solid: #2fbf55; --accent-solid-hover: #3fcc64; --accent-ink: #04170a; --accent-soft: #10241a; }
html[data-theme='black'][data-accent='green'] { --accent-soft: #0b1d10; }
html:not([data-theme='light'])[data-accent='mono'] { --accent: #e7e8eb; --accent-hover: #ffffff; --accent-solid: #e7e8eb; --accent-solid-hover: #ffffff; --accent-ink: #141518; --accent-soft: #232428; --accent-line: #3a3c42; }

html[data-theme='light'][data-accent='purple'] { --accent: #6a43b0; --accent-hover: #5a3699; --accent-solid: #6a43b0; --accent-solid-hover: #5a3699; --accent-ink: #ffffff; --accent-soft: #f0eafa; }
html[data-theme='light'][data-accent='orange'] { --accent: #b4500c; --accent-hover: #9a4409; --accent-solid: #b84f0e; --accent-solid-hover: #a3450b; --accent-ink: #ffffff; --accent-soft: #fbeee3; }
html[data-theme='light'][data-accent='green'] { --accent: #1b7f3b; --accent-hover: #156a31; --accent-solid: #1b7f3b; --accent-solid-hover: #156a31; --accent-ink: #ffffff; --accent-soft: #e5f4ea; }
html[data-theme='light'][data-accent='mono'] { --accent: #1c1d20; --accent-hover: #000000; --accent-solid: #1c1d20; --accent-solid-hover: #34363b; --accent-ink: #ffffff; --accent-soft: #ebebe8; --accent-line: #cfcfca; }

/* Base -------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs) / 1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}
h1, h2, h3, p, dl, dd, ol, ul, figure, fieldset { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, summary { touch-action: manipulation; }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
kbd { padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted); font: 500 11px / 18px var(--font); }
code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--ink); font: 12px var(--mono); }
.icon { display: block; flex: none; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link:focus { position: fixed; top: 10px; left: 10px; z-index: 100; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); }
[hidden] { display: none !important; }

h1 { font-size: 26px; font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; }
h2 { font-size: 15px; font-weight: 600; line-height: 1.3; }
h3 { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
p { color: var(--ink); }
.help, .footnote, .aside { color: var(--muted); font-size: var(--fs-sm); line-height: 1.5; }
.meta { color: var(--muted); font-size: var(--fs-sm); font-weight: 400; }
.empty { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.empty .icon { color: var(--ok); }
.footnote { margin-top: 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
  font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled { cursor: not-allowed; opacity: 0.45; }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-primary { border-color: var(--accent-solid); background: var(--accent-solid); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover:not(:disabled) { border-color: var(--accent-solid-hover); background: var(--accent-solid-hover); }
.btn-danger { border-color: var(--bad-line); background: transparent; color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn-danger-solid { border-color: var(--bad); background: var(--bad); color: var(--bad-ink); font-weight: 600; }
.btn-danger-solid:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.text-btn, .text-button {
  padding: 0; border: 0; background: none; color: var(--accent);
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer; text-decoration: none;
}
.text-btn:hover, .text-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.text-btn.muted { color: var(--muted); }
.text-button:disabled { cursor: not-allowed; opacity: 0.4; }
.icon-button {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); cursor: pointer;
}
.icon-button:disabled { cursor: not-allowed; opacity: 0.35; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.busy { opacity: 0.65; pointer-events: none; }

/* Forms */
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
input:not([type='checkbox'], [type='radio'], [type='file']), select, textarea {
  display: block; width: 100%; height: 36px; margin: 0 0 14px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
}
textarea { height: auto; padding: 8px 10px; }
input::placeholder { color: var(--faint); opacity: 1; }
input:autofill { box-shadow: 0 0 0 1000px var(--bg) inset; -webkit-text-fill-color: var(--ink); }
input[type='checkbox'], input[type='radio'] { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent-solid); }
input[type='file'] { display: block; width: 100%; margin: 0 0 14px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: var(--fs-sm); }
input[type='file']::file-selector-button { margin-right: 10px; padding: 5px 10px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-2); color: var(--ink); }
fieldset { min-width: 0; padding: 0; border: 0; }
legend { margin-bottom: 10px; padding: 0; font-weight: 600; }
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 20px; max-width: 640px; }
.field-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 20px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--ink); font-weight: 400; }
.edit-note { margin: 0 0 20px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: var(--fs-sm); }

/* Shell ------------------------------------------------------------------------------- */

body.app { display: grid; grid-template-columns: auto minmax(0, 1fr); height: 100vh; overflow: hidden; }
body.app.has-topbar { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 26px 36px 28px; overflow: auto; }

.mark {
  display: block; width: 36px; height: 36px; background: var(--mark);
  mask: url('tng-logo.svg') center / contain no-repeat;
  -webkit-mask: url('tng-logo.svg') center / contain no-repeat;
}

/* Tooltips: after a short pause on hover, at once on keyboard focus. */
.tipped { position: relative; }
.tip {
  position: absolute; z-index: 60; display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 9px; border-radius: 6px; background: var(--ink); color: var(--bg);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.3; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity 90ms ease;
}
.tip kbd { border-color: color-mix(in srgb, var(--bg) 30%, transparent); color: color-mix(in srgb, var(--bg) 70%, transparent); }
[data-tip='right'] > .tip { top: 50%; left: calc(100% + 10px); transform: translateY(-50%); }
[data-tip='bottom'] > .tip { top: calc(100% + 8px); left: 50%; transform: translateX(-50%); }
[data-tip='bottom'] > .tip.tip-end { right: 0; left: auto; transform: none; }
.tipped:hover > .tip { opacity: 1; transition-delay: 180ms; }
.tipped:focus-visible > .tip { opacity: 1; }

/* Sidebar */
.rail {
  position: relative; z-index: 5; display: flex; flex-direction: column; gap: 16px;
  width: 64px; min-height: 0; padding: 16px 12px 12px;
  background: var(--rail); border-right: 1px solid var(--line);
}
html[data-rail='wide'] .rail { width: 228px; }
.rail-mark { display: flex; align-items: center; height: 46px; padding-left: 2px; }
.rail-mark .mark { width: 36px; height: 36px; }
html[data-rail='wide'] .rail-mark .mark { width: 40px; height: 40px; }
.nav-group { display: grid; gap: 4px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 10px;
  border: 0; border-radius: 8px; background: none; color: var(--muted);
  font-size: var(--fs); font-weight: 500; white-space: nowrap; text-align: left; text-decoration: none; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current='page'] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.nav-item[aria-current='page'] .icon, .tab[aria-current='page'] .icon { color: var(--accent); }
.nav-item[data-on='true'], .tab[data-on='true'] { background: var(--accent-soft); color: var(--accent); }
.nav-label, .nav-kbd { display: none; }
html[data-rail='wide'] .rail .nav-label { display: block; overflow: hidden; text-overflow: ellipsis; }
html[data-rail='wide'] .rail .nav-kbd { display: inline-block; margin-left: auto; }
html[data-rail='wide'] .rail .tip { display: none; }
.rail-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.rail-toggle .when-wide, html[data-rail='wide'] .rail-toggle .when-narrow { display: none; }
html[data-rail='wide'] .rail-toggle .when-wide { display: block; }
.rail-toggle .tip { display: none; }
html[data-rail='narrow'] .rail-toggle .tip { display: inline-flex; }

/* Top bar */
.topbar { position: relative; z-index: 5; display: flex; align-items: center; gap: 22px; height: 58px; padding: 0 18px 0 22px; background: var(--rail); border-bottom: 1px solid var(--line); }
.top-mark .mark { width: 32px; height: 32px; }
.tabs { display: flex; align-items: center; gap: 4px; }
.tab { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; color: var(--muted); }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab[aria-current='page'] { background: var(--surface-3); color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.search-btn {
  display: flex; align-items: center; gap: 8px; width: 210px; height: 32px; margin-right: 4px; padding: 0 6px 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--faint); cursor: pointer;
}
.search-btn:hover { border-color: var(--faint); }
.search-btn span { flex: 1; text-align: left; }

/* Account menu */
.account { position: relative; }
.account-btn { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px; border-radius: 8px; white-space: nowrap; }
.account-btn:hover, .account[open] > .account-btn { background: var(--surface-2); }
.account[open] > .account-btn > .tip { display: none; }
.avatar { display: grid; flex: none; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--ink); font-size: var(--fs-xs); font-weight: 600; }
.account-text { display: grid; min-width: 0; line-height: 1.3; }
.account-text b { font-weight: 600; }
.account-text small { color: var(--faint); font-size: var(--fs-xs); }
.account-text b, .account-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The sidebar shows your name beside the avatar only while it is expanded. */
.account-btn .account-text { display: none; }
html[data-rail='wide'] .rail .account-btn .account-text { display: grid; }
.account-panel {
  position: absolute; z-index: 70; display: grid; gap: 14px; width: 292px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); white-space: normal;
}
.account[data-placement='rail'] .account-panel { bottom: 0; left: calc(100% + 14px); }
.account[data-placement='top'] .account-panel { top: calc(100% + 10px); right: 0; }
.account-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.prefs { display: grid; gap: 14px; }
.pref legend { margin-bottom: 6px; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
.pref-value { margin-left: 4px; color: var(--ink); font-weight: 600; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.seg button { height: 30px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-weight: 500; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.swatches { display: flex; gap: 12px; padding: 2px 0 2px 2px; }
.swatch { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: var(--sw); color: #ffffff; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1); cursor: pointer; }
.swatch[data-swatch='blue'] { --sw: #3d6ef0; }
.swatch[data-swatch='purple'] { --sw: #7651b9; }
.swatch[data-swatch='orange'] { --sw: #e9823f; color: #1f0e04; }
.swatch[data-swatch='green'] { --sw: #2fbf55; color: #04170a; }
.swatch[data-swatch='mono'] { background: linear-gradient(135deg, #e7e8eb 0 50%, #141518 50% 100%); box-shadow: inset 0 0 0 1px var(--line-strong); }
.swatch[data-swatch='mono'] .icon { color: #e7e8eb; mix-blend-mode: difference; }
.swatch .icon { opacity: 0; }
.swatch:hover { box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--line-strong); }
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--surface-2), 0 0 0 4px var(--ink); }
.swatch[aria-pressed='true'] .icon { opacity: 1; }
.account-note { color: var(--faint); font-size: var(--fs-xs); }
.account-note [role='status']:not(:empty) { display: block; margin-top: 4px; color: var(--warn); }
.account-links { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }

.flash { margin-bottom: 16px; padding: 10px 14px; border: 1px solid var(--accent-line); border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: var(--fs-sm); }

/* Pages --------------------------------------------------------------------------------- */

.view { flex: none; }
.page-head { display: grid; gap: 6px; margin-bottom: 22px; }
.page-head p { max-width: 640px; color: var(--muted); }
.panel { margin-bottom: 16px; border-radius: var(--radius); background: var(--panel); }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; padding: 16px 18px 10px; }
.panel-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.panel-body { padding: 0 18px 18px; }
.panel-note { padding: 0 18px 14px; }
.panel-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 18px; border-top: 1px solid var(--line); }
.disclosure-panel > summary { align-items: center; justify-content: space-between; padding-bottom: 16px; }
.disclosure-panel > summary > span { display: grid; gap: 2px; }
.disclosure-panel > summary small { color: var(--muted); font-size: var(--fs-sm); }
.disclosure-panel > summary > .icon, .disclosure > summary > .icon { color: var(--faint); transition: transform 140ms ease; }
.disclosure-panel[open] > summary > .icon, .disclosure[open] > summary > .icon { transform: rotate(180deg); }
.disclosure-panel[open] > summary { padding-bottom: 10px; }
.disclosure { border-top: 1px solid var(--line); }
.disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; }
.disclosure > summary > span:first-child { display: grid; gap: 2px; }
.disclosure > summary small { color: var(--muted); font-size: var(--fs-sm); }
.disclosure > summary .meta { margin-left: auto; }
.disclosure > summary .meta.pending { color: var(--warn); }
.disclosure-body { padding: 0 0 18px; }
.disclosure-body > .help { margin-bottom: 14px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.facts div { padding: 14px 16px; border-radius: var(--radius); background: var(--panel); }
.facts dt { color: var(--muted); font-size: var(--fs-sm); }
.facts dd { margin: 4px 0 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts dd small { color: var(--muted); font-size: var(--fs-sm); font-weight: 400; }
.setting-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 16px 18px; }
.setting-row .help { margin-top: 4px; }
.save-row .help { margin: 0; }
.table-scroll { overflow-x: auto; }

/* Overview ------------------------------------------------------------------------------ */

.overview:not([hidden]) { display: flex; flex: 1 1 auto; flex-direction: column; gap: 18px; min-height: 0; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 32px; }
.hero > * { grid-column: 1 / -1; min-width: 0; }
.hero > .headline { grid-column: 1; }
.hero > .hero-actions { grid-row: 2; grid-column: 2; }
.hero-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
.state { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.state[data-tone='live']::before { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.state[data-tone='between']::before, .state[data-tone='starting']::before { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
.state[data-tone='stopped'], .state[data-tone='stopping'] { color: var(--warn); }
.state[data-tone='stopped']::before, .state[data-tone='stopping']::before { background: var(--warn); }
.state[data-tone='failed'], .state[data-tone='restarting'] { color: var(--bad); }
.state[data-tone='failed']::before, .state[data-tone='restarting']::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.headline { font-size: 36px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.headline:focus { outline: none; }
.matchline { color: var(--muted); font-variant-numeric: tabular-nums; }
.timebar { display: block; width: 100%; max-width: 560px; height: 4px; margin-top: 8px; border: 0; border-radius: 2px; background: var(--surface-3); overflow: hidden; appearance: none; }
.timebar::-webkit-progress-bar { background: var(--surface-3); }
.timebar::-webkit-progress-value { background: var(--accent); }
.timebar::-moz-progress-bar { background: var(--accent); }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.stale { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border: 0; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.stale:hover { text-decoration: underline; text-underline-offset: 3px; }

.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
[data-state='ok'] > .dot { background: var(--ok); }
[data-state='warn'] > .dot { background: var(--warn); }
[data-state='bad'] > .dot { background: var(--bad); }
.pop { position: relative; }
.health-btn { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 4px; border-radius: var(--radius-sm); color: var(--muted); font-size: var(--fs-sm); }
.health-btn:hover, .pop[open] > .health-btn { color: var(--ink); }
.health-btn[data-state='bad'] { color: var(--bad); }
.health-btn[data-state='warn'] { color: var(--warn); }
.pop-panel { position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; width: 300px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); }
.checks { display: grid; gap: 8px; font-size: var(--fs-sm); }
.checks div { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.checks dd { color: var(--muted); text-align: right; }
.checks [data-state='bad'] dd { color: var(--bad); }
.checks [data-state='warn'] dd { color: var(--warn); }
.pop-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--faint); font-size: var(--fs-xs); }

.menu { position: relative; }
.menu > summary .icon { opacity: 0.8; }
.menu-list { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; display: grid; min-width: 300px; padding: 6px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); }
.menu-group { padding: 6px 10px 2px; color: var(--faint); font-size: var(--fs-xs); font-weight: 500; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.menu-item { display: grid; gap: 1px; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item small { color: var(--muted); font-size: var(--fs-xs); }
.menu-item[data-danger] span { color: var(--bad); }

.callout { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 4px 14px; padding: 14px 16px; border: 1px solid var(--accent-line); border-radius: 10px; background: var(--accent-soft); }
.callout > .icon { margin-top: 1px; color: var(--accent); }
.callout[data-tone='bad'] { border-color: var(--bad-line); background: var(--bad-soft); }
.callout[data-tone='bad'] > .icon { color: var(--bad); }
.callout-text { display: grid; gap: 4px; min-width: 0; }
.callout-title { font-weight: 600; }
.callout-body { color: var(--muted); }
.callout-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-self: center; }
.callout[data-kind='scheduled'] { align-items: center; padding: 10px 12px 10px 16px; }
.callout[data-kind='scheduled'] > .icon { margin-top: 0; }
.callout[data-kind='scheduled'] .callout-text { display: block; }
.callout[data-kind='scheduled'] .callout-title, .callout[data-kind='scheduled'] .callout-body { display: inline; }
.callout[data-kind='scheduled'] .callout-body::before { content: '·'; margin: 0 8px; color: var(--faint); }
.steps { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; font-size: var(--fs-sm); }
.steps li { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.steps [data-state='done'] .icon { color: var(--ok); }
.steps [data-state='failed'] { color: var(--bad); font-weight: 600; }
.steps [data-state='skipped'] { color: var(--faint); }
.step-dot { width: 8px; height: 8px; margin: 0 3px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--faint); }

.overview-grid { display: grid; flex: 1 1 auto; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; gap: 20px; min-height: 0; max-height: 100%; }
.col { display: flex; flex-direction: column; gap: 16px; max-height: 100%; min-height: 0; margin: 0 -6px; padding: 0 6px; overflow: hidden auto; }

.fold { position: relative; flex: none; border-radius: var(--radius); background: var(--panel); }
.fold-head { display: flex; align-items: baseline; gap: 10px; min-height: 48px; padding: 14px 18px 12px; }
.fold-head > .icon { align-self: center; margin-left: auto; color: var(--faint); transition: transform 140ms ease; }
.fold[open] > .fold-head > .icon { transform: rotate(180deg); }
.fold[open] > .fold-head { padding-bottom: 8px; }
.fold-title { font-size: 15px; font-weight: 600; white-space: nowrap; }
.fold-summary { min-width: 0; overflow: hidden; color: var(--muted); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.fold[open] .fold-summary { display: none; }
.fold[data-tone='warn']:not([open]) .fold-summary { color: var(--warn); }
.fold[data-tone='bad']:not([open]) .fold-summary { color: var(--bad); }
.fold-tools { position: absolute; top: 10px; right: 48px; display: flex; align-items: center; gap: 8px; }
.fold:not([open]) .fold-tools { display: none; }
.fold-body { display: grid; gap: 10px; padding: 0 18px 16px; }

.table { width: 100%; border-collapse: collapse; }
.table th { padding: 0 0 6px; border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); color: var(--faint); font-size: var(--fs-xs); font-weight: 500; text-align: left; }
.table td { padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent); font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: 0; }
.table th + th, .table td + td { padding-left: 16px; }
.table .num { text-align: right; }
.table td[data-slow] { color: var(--warn); }

.rows { display: grid; }
.rows > li { border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent); }
.rows > li:first-child { border-top: 0; }
.queue > li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 9px 0; }
.q-n { color: var(--faint); font-variant-numeric: tabular-nums; }
.row-main { display: grid; gap: 1px; min-width: 0; }
.row-main b { font-weight: 600; }
.row-main small { overflow: hidden; color: var(--muted); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.row-side { color: var(--faint); font-size: var(--fs-sm); white-space: nowrap; opacity: 0; transition: opacity 120ms ease; }
.queue > li:hover .row-side, .queue > li:focus-within .row-side { opacity: 1; }
@media (hover: none) { .row-side { opacity: 1; } }
.row > summary { display: grid; grid-template-columns: 8px minmax(0, 1fr) 16px; align-items: center; gap: 12px; margin: 0 -8px; padding: 10px 8px; border-radius: var(--radius-sm); }
.row > summary:hover { background: var(--surface-3); }
.row > summary b { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.row > summary .icon { color: var(--faint); transition: transform 140ms ease; }
.row[open] > summary .icon { transform: rotate(90deg); }
.row-detail { display: grid; justify-items: start; gap: 10px; padding: 0 0 12px 20px; }
.row-detail p { color: var(--muted); overflow-wrap: anywhere; }
.mark-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--faint); }
.attention [data-tone='bad'] .mark-dot { background: var(--bad); }
.attention [data-tone='warn'] .mark-dot { background: var(--warn); }
.attention [data-tone='info'] .mark-dot { background: var(--info); }

.fins { display: grid; }
.fins li { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: baseline; gap: 0 12px; padding: 8px 0; border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent); }
.fins li:first-child { border-top: 0; padding-top: 2px; }
.fins li.empty { display: block; border: 0; }
.fin-m { grid-row: span 2; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fin-m small { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.fin-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-who b { font-weight: 600; }
.fin-where { color: var(--muted); font-size: var(--fs-sm); }

.say { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.say input { margin: 0; }
.say-status { grid-column: 1 / -1; color: var(--muted); font-size: var(--fs-sm); }
.say-status:empty { display: none; }

/* Simple view: the same page with the essentials only. Its toggle stays where you pressed it. */
[data-simple-only] { display: none; }
html[data-simple] [data-simple-only] { display: revert; }
html[data-simple] .simple-cols[data-simple-only] { display: grid; }
html[data-simple] [data-full-only] { display: none; }
html[data-simple] .overview:not([hidden]) { width: 100%; max-width: 1040px; margin: 0 auto; gap: 26px; }
html[data-simple] .headline { font-size: 46px; }
html[data-simple] .hero-actions .btn { height: 38px; padding: 0 16px; }
.simple-bar { align-items: center; gap: 14px; }
html[data-simple] .simple-bar[data-simple-only] { display: flex; }
.simple-tag { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: var(--fs-sm); font-weight: 600; line-height: 24px; }
.simple-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
.simple-cols > section { display: grid; align-content: start; gap: 12px; }
.simple-list { display: grid; border-top: 1px solid var(--line); }
.simple-list li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.simple-list li span:last-child { color: var(--muted); }
.simple-foot { padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-sm); }

/* Operations ---------------------------------------------------------------------------- */

.ops-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; gap: 16px; }
.ops-side { display: grid; gap: 16px; }
.ops-side .panel { margin-bottom: 0; }
.console {
  min-height: 360px; max-height: 62vh; margin: 0; padding: 12px 18px; overflow: auto;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font: 12.5px / 1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.console.reports { min-height: 160px; max-height: 300px; border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.command-panel { display: grid; gap: 8px; padding: 16px 18px 18px; }
.command-input { display: flex; align-items: flex-start; gap: 10px; }
.command-input input { flex: 1; min-width: 0; margin: 0; }
.command-result { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); color: var(--ink); font: 12.5px / 1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-feed { max-height: 360px; margin: 0; padding: 0 18px 14px; overflow: auto; }
.chat-feed li { padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.chat-feed li:first-child { border-top: 0; }
.chat-feed .shot { color: var(--accent); }

/* Maps */
.rotation-list { margin: 0; border-top: 1px solid var(--line); }
.rotation-row { display: flex; align-items: center; gap: 14px; padding: 8px 6px 8px 0; border-bottom: 1px solid var(--line); }
.drag-handle { display: grid; flex: none; place-items: center; width: 26px; height: 34px; margin-right: -8px; border-radius: 6px; color: var(--faint); cursor: grab; touch-action: none; user-select: none; }
.drag-handle:hover { background: var(--surface-3); color: var(--ink); }
.rotation-list.reordering { cursor: grabbing; user-select: none; }
.rotation-row.dragging { position: relative; z-index: 1; border-color: transparent; border-radius: var(--radius-sm); background: var(--surface-3); box-shadow: var(--shadow); }
.rotation-row.dragging .drag-handle { color: var(--accent); cursor: grabbing; }
.row-number { width: 24px; color: var(--faint); font-size: var(--fs-sm); text-align: center; font-variant-numeric: tabular-nums; }
.rotation-row select { flex: 1; max-width: 480px; margin: 0; }
.row-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.rotation-tools { display: flex; align-items: center; gap: 16px; margin: 14px 0 18px; }
.selection-tools { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 20px; margin: 6px 0 16px; }
.map-choice { display: flex; align-items: center; gap: 10px; margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 400; }
.map-choice small { display: block; color: var(--muted); font-size: var(--fs-xs); }

/* Players, settings, files */
.activity-now { display: grid; gap: 8px; margin-bottom: 16px; }
.activity-line { color: var(--muted); }
.activity-line b { color: var(--ink); }
.fin-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; margin-bottom: 14px; }
.fin-columns h3 { margin-bottom: 6px; }
.bot-editor { width: 100%; border-collapse: collapse; }
.bot-editor th { padding: 0 8px 6px 0; color: var(--faint); font-size: var(--fs-xs); font-weight: 500; text-align: left; }
.bot-editor td { padding: 4px 8px 4px 0; }
.bot-editor td:first-child { width: 64px; color: var(--faint); font-variant-numeric: tabular-nums; }
.bot-editor input { min-width: 7rem; margin: 0; }
.file-list { padding: 4px 18px; }
.file-action { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 16px 0; border-top: 1px solid var(--line); }
.file-action:first-child { border-top: 0; }
.file-action h2 { margin-bottom: 4px; }
.file-type { display: grid; place-items: center; width: 46px; height: 54px; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }

/* Loadouts */
.picker { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding-top: 18px; }
.picker-field { flex: 1 1 320px; max-width: 520px; }
.picker-field select { margin: 0; }
.loadout-form { display: grid; gap: 18px; }
.name-field { max-width: 420px; }
.name-field input { margin: 0; }
.loadout-weapons { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.loadout-weapons fieldset { padding: 14px 16px 2px; border-radius: 10px; background: var(--surface-2); }
.loadout-form .map-grid { margin-bottom: 0; }
.loadout-form legend .meta { margin-left: 6px; }
.perk-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 24px; }
.perk-slot legend { margin-bottom: 2px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.login-forms { display: grid; gap: 18px; }
.logins form { display: grid; justify-items: start; }
.logins input, .logins select { max-width: 420px; }
.roles { display: grid; gap: 8px; max-width: 720px; margin-bottom: 24px; font-size: var(--fs-sm); line-height: 1.5; }
.roles div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; }
.roles dt { font-weight: 600; }
.roles dd { margin: 0; color: var(--muted); }

/* Mod & map updates. Status tags use the fixed status colours; the accent marks what is staged and actionable. */
.update-status { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 18px; font-size: var(--fs-sm); }
.update-status div { display: flex; align-items: baseline; gap: 8px; }
.update-status dt { color: var(--muted); }
.update-status dd { margin: 0; font-weight: 600; }
.update-status dd small { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.update-status dd[data-running='true'] { color: var(--ok); }
.update-steps { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 18px; font-size: var(--fs-sm); }
.update-steps a { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; }
.update-steps a:hover { color: var(--ink); }
.step-n { display: inline-grid; flex: none; place-items: center; width: 20px; height: 20px; margin-right: 8px; border-radius: 50%; background: var(--surface-3); color: var(--ink); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.update-steps .step-n { margin-right: 0; }
.panel-head h2 { display: inline-flex; align-items: center; }
.state-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.state-tag[data-state='staged'] { background: var(--accent-soft); color: var(--accent); }
.state-tag[data-state='queued'] { background: var(--warn-soft); color: var(--warn); }
.state-tag[data-state='failed'] { background: var(--bad-soft); color: var(--bad); }
.state-tag[data-state='applied'] { background: var(--ok-soft); color: var(--ok); }
.file-status { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; }
.file-status[data-status='new'] { color: var(--info); }
.file-status[data-status='changed'] { color: var(--warn); }
.file-status[data-status='identical'] { color: var(--faint); }
.file-status[data-status='removed'] { color: var(--bad); }
.review { display: grid; gap: 14px; }
.review h3 { margin-top: 6px; }
.files-table { font-size: var(--fs-sm); }
.files-table td { vertical-align: top; }
.files-table td b, .files-table td small { display: block; }
.files-table td small { color: var(--muted); font-size: var(--fs-xs); }
.files-table code { padding: 0; background: none; color: var(--muted); font-size: var(--fs-xs); }
.files-table .hash { display: block; max-width: 34ch; overflow-wrap: anywhere; color: var(--ink); }
.files-table form { margin: 0; }
.version-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; font-weight: 600; }
.version-line > span { display: grid; gap: 1px; }
.version-line small { color: var(--faint); font-size: var(--fs-xs); font-weight: 500; }
.version-line > .icon { color: var(--faint); }
.map-changes { display: grid; }
.map-changes li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.map-changes li:first-child { border-top: 0; }
.map-changes .file-status { min-width: 72px; }
.meta-diff td { overflow-wrap: anywhere; white-space: pre-line; }
.meta-diff th[scope='row'] { padding-right: 16px; font-weight: 500; text-align: left; }
.notes { display: grid; gap: 6px; padding-left: 18px; color: var(--muted); font-size: var(--fs-sm); list-style: disc; }
.notes[data-tone='warn'] li::marker { color: var(--warn); }
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border: 1px solid var(--accent-line); border-radius: var(--radius-sm); background: var(--accent-soft); font-size: var(--fs-sm); }
.notice > .icon { margin-top: 1px; }
.notice[data-tone='bad'] { border-color: var(--bad-line); background: var(--bad-soft); }
.notice[data-tone='bad'] > .icon { color: var(--bad); }
.notice[data-tone='warn'] { border-color: var(--warn-line); background: var(--warn-soft); }
.meta-editor { display: grid; gap: 18px; }
.meta-form .help { margin-bottom: 14px; }
.meta-import { display: grid; justify-items: start; padding-top: 16px; border-top: 1px solid var(--line); }
.meta-import .help { margin-top: 8px; }
.panel-empty { margin: 0 0 16px; padding: 14px 18px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.update-list > li { padding: 10px 0; }
.update-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 6px 14px; }
.update-row form { margin: 0; }
.update-list .row-side { opacity: 1; }
.update-list .help, .update-list .notice { margin-top: 8px; }
.pending-text { color: var(--warn); font-weight: 600; }
.channel .seg { margin-bottom: 8px; }
.channel .seg label { display: flex; align-items: center; justify-content: center; gap: 8px; height: 30px; margin: 0; border-radius: 6px; color: var(--muted); font-weight: 500; cursor: pointer; }
.channel .seg label:has(input:checked) { background: var(--surface-3); color: var(--ink); font-weight: 600; }

/* Dialogs ------------------------------------------------------------------------------- */

dialog { color: var(--ink); }
dialog::backdrop { background: var(--overlay); }
dialog.confirm { width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; overflow: auto; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
dialog.confirm > form { display: grid; gap: 14px; padding: 20px 22px; }
dialog.confirm h2 { font-size: 18px; }
dialog.confirm label { margin-bottom: -8px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.consequences { display: grid; gap: 6px; padding-left: 18px; color: var(--muted); list-style: disc; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
dialog.confirm .disclosure { border-top: 1px solid var(--line); }

.palette { width: min(640px, calc(100vw - 32px)); margin: 12vh auto auto; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--faint); }
.palette-input input { flex: 1; height: auto; margin: 0; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 16px; }
.palette-input input:focus { outline: none; }
.palette-list { max-height: 380px; overflow: auto; padding: 6px; }
.palette-group { margin: 8px 10px 4px; color: var(--faint); font-size: var(--fs-xs); font-weight: 600; }
.palette-opt { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); align-items: baseline; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.palette-opt[aria-selected='true'] { background: var(--surface-3); }
.palette-opt[data-danger] > span:first-child { color: var(--bad); }
.palette-opt small { overflow: hidden; color: var(--muted); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.palette-empty { padding: 10px; color: var(--muted); }

/* Sign in ------------------------------------------------------------------------------- */

.signin { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.signin-card { display: grid; gap: 10px; width: min(380px, 100%); }
.signin-card .mark { width: 48px; height: 48px; margin-bottom: 10px; background: var(--mark); }
.signin-card form { margin: 14px 0 4px; }
.signin-card .btn { width: 100%; height: 38px; margin-top: 4px; }
.signin .flash { width: min(380px, 100%); }

/* Smaller screens ------------------------------------------------------------------------ */

@media (max-width: 1100px) {
  .overview:not([hidden]) { flex: none; }
  .overview-grid, .ops-grid { grid-template-columns: minmax(0, 1fr); max-height: none; }
  .col { max-height: none; overflow: visible; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  html[data-rail] .rail { width: 64px; }
  html[data-rail] .rail .nav-label, html[data-rail] .rail .nav-kbd, html[data-rail] .rail .account-btn .account-text { display: none; }
  html[data-rail] .rail .tip { display: inline-flex; }
  .main { padding: 20px 16px 28px; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero > .hero-actions { grid-row: auto; grid-column: 1; justify-content: flex-start; margin: 6px 0 2px; }
  .headline, html[data-simple] .headline { font-size: 30px; }
  .callout { grid-template-columns: auto minmax(0, 1fr); }
  .callout-actions { grid-column: 2; justify-content: flex-start; }
  .simple-cols, .fin-columns, .loadout-weapons, .field-pair { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .field-trio { grid-template-columns: minmax(0, 1fr); }
  .topbar { gap: 10px; padding: 0 10px; }
  .tabs { gap: 0; overflow-x: auto; scrollbar-width: none; }
  .tab { width: 36px; }
  .search-btn { width: auto; }
  .search-btn span, .search-btn kbd { display: none; }
  .file-action { grid-template-columns: 44px minmax(0, 1fr); }
  .file-action > .btn { grid-column: 2; justify-self: start; }
  .rotation-row { flex-wrap: wrap; gap: 8px; }
  .row-actions { width: 100%; justify-content: flex-end; }
  .update-row { grid-template-columns: auto minmax(0, 1fr); }
  .update-row > .row-side, .update-row > form, .update-row > .btn { grid-column: 2; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
