/* ISP Platform staff UI: tokens, shell and components (docs/DESIGN.md).
   Light by default, dark with the operating system. Logical properties throughout, so Arabic (dir="rtl") mirrors. */

/* ------------------------------------------------------------------ 1. Tokens */
:root {
  color-scheme: light;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", "Noto Sans", "Noto Sans Arabic", "Segoe UI Arabic", sans-serif;
  --mono: "Cascadia Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-base: .875rem;
  --fs-md: 1rem;
  --fs-lg: 1.1875rem;
  --fs-xl: 1.4375rem;
  --fs-2xl: 1.75rem;

  --sp-1: .25rem;
  --sp-2: .5rem;
  --sp-3: .75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;

  --r-sm: 4px;
  --r: 6px;
  --r-lg: 10px;
  --r-full: 999px;

  /* Neutrals lean toward the brand hue (256, the cobalt the platform has always used). */
  --bg: oklch(0.975 0.004 256);
  --surface: oklch(1 0 256);
  --surface-2: oklch(0.965 0.005 256);
  --surface-3: oklch(0.935 0.007 256);
  --ink: oklch(0.23 0.02 256);
  --ink-2: oklch(0.43 0.02 256);
  --ink-3: oklch(0.53 0.016 256);
  --line: oklch(0.905 0.008 256);
  --line-2: oklch(0.85 0.01 256);

  --accent: oklch(0.50 0.15 256);
  --accent-hover: oklch(0.45 0.15 256);
  --accent-soft: oklch(0.95 0.025 256);
  --accent-ink: oklch(0.44 0.14 256);
  --link: oklch(0.47 0.15 256);
  --on-accent: #fff;
  --focus: oklch(0.60 0.17 256);

  --ok: oklch(0.56 0.13 152);
  --ok-soft: oklch(0.955 0.035 152);
  --ok-ink: oklch(0.40 0.10 152);
  --warn: oklch(0.74 0.15 72);
  --warn-soft: oklch(0.965 0.045 85);
  --warn-ink: oklch(0.47 0.11 60);
  --danger: oklch(0.56 0.19 27);
  --danger-soft: oklch(0.96 0.025 25);
  --danger-ink: oklch(0.48 0.17 27);

  --nav-bg: oklch(0.235 0.03 258);
  --nav-ink: oklch(0.88 0.015 256);
  --nav-ink-2: oklch(0.70 0.025 256);
  --nav-hover: oklch(0.29 0.035 258);
  --nav-active: oklch(0.34 0.065 258);
  --nav-active-icon: oklch(0.82 0.09 256);
  --nav-line: oklch(0.31 0.03 258);

  --shadow-1: 0 1px 2px oklch(0.25 0.03 256 / .06);
  --shadow-2: 0 1px 2px oklch(0.25 0.03 256 / .06), 0 6px 16px oklch(0.25 0.03 256 / .07);
  --shadow-pop: 0 4px 8px oklch(0.25 0.03 256 / .08), 0 14px 36px oklch(0.25 0.03 256 / .16);

  --z-sticky: 10;
  --z-dropdown: 20;
  --z-skip: 50;

  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur: 160ms;
  --sidebar-w: 15rem;
  --topbar-h: 3.5rem;

  --icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5M12 7.5h.01'/%3E%3C/svg%3E");
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 4.2 2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 4.2a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9.5v4M12 17h.01'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12.5 2.7 2.7 5.3-5.7'/%3E%3C/svg%3E");
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23808a9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Dark: when the switch says so, or when the device is dark and nothing was chosen (the same tokens twice: a media
   query cannot share a rule with an attribute selector). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: oklch(0.175 0.012 256);
    --surface: oklch(0.215 0.014 256);
    --surface-2: oklch(0.245 0.015 256);
    --surface-3: oklch(0.285 0.017 256);
    --ink: oklch(0.935 0.008 256);
    --ink-2: oklch(0.77 0.015 256);
    --ink-3: oklch(0.67 0.015 256);
    --line: oklch(0.30 0.015 256);
    --line-2: oklch(0.37 0.02 256);
    --accent: oklch(0.52 0.15 256);
    --accent-hover: oklch(0.57 0.15 256);
    --accent-soft: oklch(0.30 0.06 256);
    --accent-ink: oklch(0.83 0.08 256);
    --link: oklch(0.77 0.12 256);
    --focus: oklch(0.70 0.15 256);
    --ok: oklch(0.66 0.14 152);
    --ok-soft: oklch(0.29 0.05 152);
    --ok-ink: oklch(0.84 0.12 152);
    --warn: oklch(0.78 0.14 75);
    --warn-soft: oklch(0.31 0.05 75);
    --warn-ink: oklch(0.87 0.12 80);
    --danger: oklch(0.66 0.18 27);
    --danger-soft: oklch(0.30 0.07 25);
    --danger-ink: oklch(0.85 0.09 25);
    --nav-bg: oklch(0.15 0.014 256);
    --nav-hover: oklch(0.21 0.02 256);
    --nav-active: oklch(0.27 0.05 256);
    --nav-line: oklch(0.23 0.015 256);
    --shadow-1: 0 1px 2px oklch(0 0 0 / .3);
    --shadow-2: 0 1px 2px oklch(0 0 0 / .3), 0 6px 16px oklch(0 0 0 / .25);
    --shadow-pop: 0 8px 28px oklch(0 0 0 / .5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.175 0.012 256);
  --surface: oklch(0.215 0.014 256);
  --surface-2: oklch(0.245 0.015 256);
  --surface-3: oklch(0.285 0.017 256);
  --ink: oklch(0.935 0.008 256);
  --ink-2: oklch(0.77 0.015 256);
  --ink-3: oklch(0.67 0.015 256);
  --line: oklch(0.30 0.015 256);
  --line-2: oklch(0.37 0.02 256);
  --accent: oklch(0.52 0.15 256);
  --accent-hover: oklch(0.57 0.15 256);
  --accent-soft: oklch(0.30 0.06 256);
  --accent-ink: oklch(0.83 0.08 256);
  --link: oklch(0.77 0.12 256);
  --focus: oklch(0.70 0.15 256);
  --ok: oklch(0.66 0.14 152);
  --ok-soft: oklch(0.29 0.05 152);
  --ok-ink: oklch(0.84 0.12 152);
  --warn: oklch(0.78 0.14 75);
  --warn-soft: oklch(0.31 0.05 75);
  --warn-ink: oklch(0.87 0.12 80);
  --danger: oklch(0.66 0.18 27);
  --danger-soft: oklch(0.30 0.07 25);
  --danger-ink: oklch(0.85 0.09 25);
  --nav-bg: oklch(0.15 0.014 256);
  --nav-hover: oklch(0.21 0.02 256);
  --nav-active: oklch(0.27 0.05 256);
  --nav-line: oklch(0.23 0.015 256);
  --shadow-1: 0 1px 2px oklch(0 0 0 / .3);
  --shadow-2: 0 1px 2px oklch(0 0 0 / .3), 0 6px 16px oklch(0 0 0 / .25);
  --shadow-pop: 0 8px 28px oklch(0 0 0 / .5);
}

/* ------------------------------------------------------------------ 2. Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-size: .9375rem; line-height: 1.6; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
p a { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { color: var(--ink); text-wrap: balance; }
h1 { font-size: var(--fs-xl); font-weight: 650; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 var(--sp-4); }
h2 { font-size: var(--fs-md); font-weight: 600; line-height: 1.35; margin: var(--sp-6) 0 var(--sp-3); }
h3 { font-size: var(--fs-base); font-weight: 600; margin: var(--sp-5) 0 var(--sp-2); }
p { margin: 0 0 var(--sp-3); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .08em .35em; border-radius: var(--r-sm); user-select: all; overflow-wrap: anywhere; }
kbd { font-family: var(--mono); font-size: var(--fs-xs); padding: .05rem .35rem; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: var(--r-sm); color: var(--ink-3); background: var(--surface); }
small { font-size: var(--fs-xs); }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; }
.skip { position: absolute; inset-inline-start: -999px; top: var(--sp-2); z-index: var(--z-skip); padding: .5rem .8rem; border-radius: var(--r); background: var(--accent); color: var(--on-accent); }
.skip:focus { inset-inline-start: var(--sp-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.icon { width: 1.125rem; height: 1.125rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.22em; }
.icon.sm { width: 1rem; height: 1rem; }
[dir="rtl"] .icon.flip { transform: scaleX(-1); }

/* ------------------------------------------------------------------ 3. Shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--nav-bg); color: var(--nav-ink);
  scrollbar-width: thin; scrollbar-color: var(--nav-hover) transparent;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-4) var(--sp-4) var(--sp-2); }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 650; font-size: var(--fs-md); letter-spacing: -.005em; line-height: 1.2; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 1.9rem; height: 1.9rem; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: #fff; }
.brand-mark .icon { width: 1.15rem; height: 1.15rem; stroke-width: 2; }
.nav { flex: 1; padding: var(--sp-2) var(--sp-3) var(--sp-6); }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav-heading { margin: var(--sp-5) var(--sp-3) var(--sp-1); font-size: var(--fs-xs); font-weight: 600; color: var(--nav-ink-2); }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .44rem .65rem; border-radius: var(--r); color: var(--nav-ink); font-size: var(--fs-base); line-height: 1.3; }
.nav a .icon { color: var(--nav-ink-2); }
.nav a:hover { background: var(--nav-hover); color: #fff; text-decoration: none; }
.nav a:hover .icon { color: inherit; }
.nav a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav a.active .icon { color: var(--nav-active-icon); }
.nav a:focus-visible { outline-offset: -2px; }
.sidebar-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--nav-line); font-size: var(--fs-xs); color: var(--nav-ink-2); }
.sidebar-foot code { background: none; padding: 0; color: inherit; user-select: text; }
.nav-toggle-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.nav-toggle { display: none; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; margin: 0; border: 1px solid var(--nav-line); border-radius: var(--r); color: var(--nav-ink); cursor: pointer; }
.nav-toggle-input:focus-visible ~ .sidebar .nav-toggle { outline: 2px solid var(--focus); outline-offset: 2px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--sp-4);
  height: var(--topbar-h); padding: 0 var(--sp-8);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.search { position: relative; flex: 1; max-width: 34rem; margin: 0; }
.search > .icon { position: absolute; inset-inline-start: .7rem; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; max-width: none; height: 2.25rem; padding-inline: 2.3rem 2.5rem; background: var(--surface-2); border-color: transparent; }
.search input:hover { border-color: var(--line-2); }
.search input:focus { background: var(--surface); }
.search kbd { position: absolute; inset-inline-end: .6rem; top: 50%; translate: 0 -50%; pointer-events: none; }
.search input:focus ~ kbd { display: none; }
.topbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-3); }
.lang { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: var(--fs-xs); font-weight: 600; }
.lang a, .lang strong { padding: .3rem .55rem; color: var(--ink-2); }
.lang a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.lang strong { background: var(--surface-3); color: var(--ink); }
.theme-switch a, .theme-switch strong { display: inline-flex; align-items: center; padding: .3rem .45rem; }
.auth-foot .lang { background: var(--surface); }

.menu { position: relative; }
.menu > summary { list-style: none; display: flex; align-items: center; gap: .5rem; padding: .25rem .45rem; padding-inline-start: .25rem; border-radius: var(--r); cursor: pointer; color: var(--ink); font-weight: 550; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--surface-2); }
.menu > summary .icon { color: var(--ink-3); }
.avatar { width: 1.9rem; height: 1.9rem; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 700; }
.menu-panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: var(--z-dropdown);
  min-width: 14rem; padding: var(--sp-1);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
}
.menu[open] .menu-panel { animation: pop var(--dur) var(--ease-out); }
.menu-head { padding: .45rem .65rem .55rem; margin-bottom: var(--sp-1); border-bottom: 1px solid var(--line); }
.menu-head strong { display: block; }
.menu-head span { font-size: var(--fs-xs); color: var(--ink-3); }
.menu-panel form { margin: 0; }
.menu-panel a, .menu-panel button {
  display: flex; width: 100%; height: auto; align-items: center; justify-content: flex-start; gap: .6rem;
  padding: .5rem .65rem; border: 0; border-radius: var(--r); box-shadow: none;
  background: none; color: var(--ink); font: inherit; font-weight: 400; text-align: start; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.menu-panel .icon { color: var(--ink-3); }
@keyframes pop { from { opacity: 0; translate: 0 -4px; } }

main { width: 100%; max-width: 92rem; padding: var(--sp-6) var(--sp-8) var(--sp-10); }

/* ------------------------------------------------------------------ 4. Page structure */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head h1 { display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem .6rem; margin: 0; }
.page-head h1 .muted, .page-head h1 .count { font-size: var(--fs-md); font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.page-head .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.page-sub { margin: var(--sp-1) 0 0; color: var(--ink-2); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0 0 var(--sp-2); font-size: var(--fs-sm); color: var(--ink-3); }
.crumbs a { color: var(--ink-2); }
.crumbs .icon { width: .9rem; height: .9rem; }

.layout-2col { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: var(--sp-5); align-items: start; }
.layout-2col > div { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0 var(--sp-5); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.grid > :is(.card, .panel) { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-5); }
.form-grid .span-2 { grid-column: 1 / -1; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }

.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); margin-bottom: var(--sp-5); }
.card { padding: var(--sp-5); }
.card > h2:first-child, .card > :first-child > h2:first-child { margin-top: 0; }
.card.narrow { max-width: 26rem; margin: 3rem auto; }
.stack > .card, .stack > .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) var(--sp-5); min-height: 3.25rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: var(--fs-md); display: flex; align-items: center; gap: .5rem; }
.panel-head .actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.panel-body { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.panel-body > :last-child { margin-bottom: 0; }
.panel-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-2); display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.panel > table th:first-child, .panel > table td:first-child, .panel > .table-scroll > table :is(th, td):first-child { padding-inline-start: var(--sp-5); }
.panel > table th:last-child, .panel > table td:last-child, .panel > .table-scroll > table :is(th, td):last-child { padding-inline-end: var(--sp-5); }
.panel > table:last-child tbody tr:last-child td:first-child { border-end-start-radius: var(--r-lg); }
.panel > table:last-child tbody tr:last-child td:last-child { border-end-end-radius: var(--r-lg); }

/* A form opened from a "New …" button: above the list, with its own close link. */
.form-panel { border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); box-shadow: var(--shadow-2); }
.form-panel > .panel-head { background: color-mix(in oklab, var(--accent) 5%, var(--surface)); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ 5. Buttons */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 2.125rem; padding: 0 .9rem;
  font: inherit; font-size: var(--fs-base); font-weight: 550; line-height: 1; white-space: nowrap;
  color: var(--on-accent); background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r);
  box-shadow: var(--shadow-1); cursor: pointer;
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); text-decoration: none; }
button:active, .button:active { translate: 0 1px; }
button.secondary, .button.secondary { color: var(--ink); background: var(--surface); border-color: var(--line-2); }
button.secondary:hover, .button.secondary:hover { color: var(--ink); background: var(--surface-2); border-color: var(--line-2); }
button.danger, .button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
button.danger:hover, .button.danger:hover { background: color-mix(in oklab, var(--danger) 86%, black); border-color: color-mix(in oklab, var(--danger) 86%, black); }
button.ghost, .button.ghost { color: var(--ink-2); background: transparent; border-color: transparent; box-shadow: none; }
button.ghost:hover, .button.ghost:hover { color: var(--ink); background: var(--surface-2); }
button.sm, .button.sm { height: 1.75rem; padding: 0 .6rem; font-size: var(--fs-sm); }
button:disabled, button:disabled:hover { opacity: .5; cursor: not-allowed; translate: none; }
button .icon, .button .icon { width: 1rem; height: 1rem; }
form > button[type="submit"], form > .button { margin-top: var(--sp-4); }

/* ------------------------------------------------------------------ 6. Forms */
input, select, textarea {
  font: inherit; font-size: var(--fs-base); color: var(--ink);
  height: 2.125rem; min-width: 0; padding: 0 .7rem;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
textarea { height: auto; padding: .5rem .7rem; line-height: 1.5; resize: vertical; }
select { appearance: none; padding-inline-end: 2rem; background-image: var(--chevron); background-repeat: no-repeat; background-size: 1rem; background-position: right .55rem center; }
[dir="rtl"] select { background-position: left .55rem center; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-3); }
input[type="checkbox"], input[type="radio"] { width: 1rem; height: 1rem; padding: 0; margin: 0; accent-color: var(--accent); vertical-align: -.15em; box-shadow: none; }
input[type="file"] { height: auto; padding: .3rem; }
input[type="file"]::file-selector-button { font: inherit; font-size: var(--fs-sm); font-weight: 550; margin-inline-end: .75rem; padding: .3rem .75rem; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface-2); color: var(--ink); cursor: pointer; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }
.validation-message { color: var(--danger-ink); font-size: var(--fs-sm); margin-top: .25rem; }

label { display: block; margin: var(--sp-4) 0 .35rem; font-size: var(--fs-sm); font-weight: 550; color: var(--ink); }
label .muted { font-weight: 400; }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
form :is(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"]), select, textarea) { width: 100%; max-width: 32rem; }
:is(.grid-2, .form-grid, .panel-body, .auth-card) :is(input:not([type="checkbox"], [type="radio"], [type="file"]), select, textarea) { max-width: none; }
.hint { display: block; margin-top: .3rem; font-size: var(--fs-xs); font-weight: 400; color: var(--ink-3); }
fieldset { margin: var(--sp-4) 0; padding: var(--sp-3) var(--sp-4) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-lg); }
legend { padding: 0 .35rem; font-size: var(--fs-sm); font-weight: 600; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .35rem 1rem; margin: .5rem 0; }
.checks label { margin: 0; font-size: var(--fs-base); font-weight: 400; }

form.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3);
  margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
form.filters label { display: flex; flex-direction: column; gap: .3rem; margin: 0; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
form.filters :is(input, select) { width: auto; max-width: none; }
form.filters input[type="search"], form.filters input[type="text"] { min-width: 15rem; }
form.filters select { min-width: 8.5rem; }
form.filters > button, form.filters > .button { margin: 0; }
.filters-actions { display: flex; gap: var(--sp-2); margin-inline-start: auto; }

.views { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 var(--sp-3); font-size: var(--fs-sm); }
.views form { display: inline-flex; align-items: center; gap: .3rem; margin: 0; }
.views .pill { height: 1.625rem; background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2); }
.views .pill:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.views form :is(input, select) { width: 11rem; max-width: none; height: 1.75rem; font-size: var(--fs-sm); }
.views form button { height: 1.75rem; padding: 0 .55rem; font-size: var(--fs-sm); box-shadow: none; margin: 0; }
.views > form:not(:last-child) button { color: var(--ink-3); background: transparent; border-color: transparent; padding: 0 .3rem; }
.views > form:last-child { margin-inline-start: auto; }

.row-form { display: inline-flex; margin: 0; }
.row-form button { height: 1.75rem; padding: 0 .6rem; font-size: var(--fs-sm); box-shadow: none; margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-2); }
.inline-form :is(input, select) { width: auto; }
.inline-form > button { margin: 0; }

/* ------------------------------------------------------------------ 7. Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
th, td { padding: .6rem .85rem; text-align: start; vertical-align: middle; border-bottom: 1px solid var(--line); }
th { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in oklab, var(--accent) 4%, var(--surface)); }
td > a:first-child { font-weight: 550; }
td[colspan].muted { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--ink-3); }
tbody tr:has(td[colspan].muted):hover td { background: none; }
:is(main > table, main > .table-scroll > table, .table-wrap > table) {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); margin-bottom: var(--sp-5);
}
:is(main > table, main > .table-scroll > table, .table-wrap > table) > thead > tr:first-child > th:first-child { border-start-start-radius: calc(var(--r-lg) - 1px); }
:is(main > table, main > .table-scroll > table, .table-wrap > table) > thead > tr:first-child > th:last-child { border-start-end-radius: calc(var(--r-lg) - 1px); }
:is(main > table, main > .table-scroll > table, .table-wrap > table) > tbody > tr:last-child > td:first-child { border-end-start-radius: calc(var(--r-lg) - 1px); }
:is(main > table, main > .table-scroll > table, .table-wrap > table) > tbody > tr:last-child > td:last-child { border-end-end-radius: calc(var(--r-lg) - 1px); }
.card table th { background: transparent; }
.card table th, .card table td { padding-inline: .5rem; }
.table-scroll { overflow-x: auto; }
.cell-main { display: block; font-weight: 550; }
.cell-sub { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
tr.group-head td { border-top: 2px solid var(--line-2); font-weight: 600; }
tr.voided td { color: var(--ink-3); text-decoration: line-through; }

/* ------------------------------------------------------------------ 8. Badges, alerts, lists */
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  height: 1.375rem; padding: 0 .55rem; margin-inline-end: .25rem;
  font-size: var(--fs-xs); font-weight: 550; line-height: 1; white-space: nowrap; vertical-align: middle;
  color: var(--ink-2); background: var(--surface-3); border-radius: var(--r-full);
}
.pill.ok { color: var(--ok-ink); background: var(--ok-soft); }
.pill.warn { color: var(--warn-ink); background: var(--warn-soft); }
.pill.danger { color: var(--danger-ink); background: var(--danger-soft); }
.pill.off { color: var(--ink-3); background: var(--surface-2); }
.pill.info { color: var(--accent-ink); background: var(--accent-soft); }
.pill:is(.ok, .warn, .danger, .off)::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; }
.tag { display: inline-flex; align-items: center; height: 1.375rem; padding: 0 .5rem; margin-inline-end: .25rem; font-size: var(--fs-xs); font-weight: 500; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--r); white-space: nowrap; vertical-align: middle; }
a.pill:hover, a.tag:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-ink); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem; border-radius: var(--r-full); background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.online-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 20%, transparent); margin-inline-end: .35rem; vertical-align: .05em; }
.offline-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--line-2); margin-inline-end: .35rem; vertical-align: .05em; }

.alert {
  display: flex; align-items: flex-start; gap: .6rem;
  margin: 0 0 var(--sp-4); padding: .7rem .9rem;
  color: var(--accent-ink); background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent) 25%, transparent); border-radius: var(--r-lg);
}
.alert::before { content: ""; flex: none; width: 1.1rem; height: 1.1rem; margin-top: .1rem; background: currentColor; mask: var(--icon-info) center / contain no-repeat; }
.alert.error { color: var(--danger-ink); background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 30%, transparent); }
.alert.error::before { mask-image: var(--icon-alert); }
.alert.warn { color: var(--warn-ink); background: var(--warn-soft); border-color: color-mix(in oklab, var(--warn) 40%, transparent); }
.alert.warn::before { mask-image: var(--icon-alert); }
.alert.ok { color: var(--ok-ink); background: var(--ok-soft); border-color: color-mix(in oklab, var(--ok) 30%, transparent); }
.alert.ok::before { mask-image: var(--icon-check); }
.alert code { background: color-mix(in oklab, currentColor 10%, transparent); color: inherit; }
.status-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; margin: 0 0 var(--sp-4); padding: .7rem 1rem; color: var(--warn-ink); background: var(--warn-soft); border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent); border-radius: var(--r-lg); }
.status-banner.danger { color: var(--danger-ink); background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 30%, transparent); }
.status-banner.off { color: var(--ink-2); background: var(--surface-2); border-color: var(--line); }
.status-banner .muted { color: inherit; opacity: .8; }

.kv { display: grid; grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr); gap: .55rem var(--sp-4); margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Key figures under a record's title: one band, dividers between the figures. */
.facts { display: flex; flex-wrap: wrap; gap: var(--sp-3) 0; margin: 0 0 var(--sp-5); padding: var(--sp-4) 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.facts > div { min-width: 9rem; padding-inline: var(--sp-5); }
.facts > div + div { border-inline-start: 1px solid var(--line); }
.facts dt { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.facts dd { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .2rem 0 0; font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.facts dd .pill { font-size: var(--fs-xs); margin: 0; }
.facts dd .muted { font-size: var(--fs-sm); font-weight: 400; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; }
.title-row h1 { margin: 0; }
.page-sub .tag { margin-inline-start: .15rem; }
.panel-body + .panel-head { border-top: 1px solid var(--line); }
.form-page { max-width: 52rem; }
.form-host { background: color-mix(in oklab, var(--accent) 4%, var(--surface)); border-bottom: 1px solid var(--line); }
.form-host h3:first-child { margin-top: 0; }
.status-form { margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-5)) var(--sp-4); padding: var(--sp-4) var(--sp-5); background: color-mix(in oklab, var(--accent) 4%, var(--surface)); border-bottom: 1px solid var(--line); }
.status-form label:first-of-type { margin-top: 0; }
.note-composer { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.note-composer textarea { max-width: none; }
.note-composer button { justify-self: start; margin: 0; }
.contact-card + .contact-card { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.contact-card strong { display: block; }
.contact-card .muted { font-size: var(--fs-sm); }
.aging { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 var(--sp-3); }

.note { margin: 0 0 var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.note.pinned { background: color-mix(in oklab, var(--warn) 7%, var(--surface)); border-color: color-mix(in oklab, var(--warn) 35%, var(--line)); }
.note header { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .35rem; font-size: var(--fs-xs); color: var(--ink-2); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note header form { margin: 0; }
.note header .row-form:first-of-type { margin-inline-start: auto; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-block: 0 var(--sp-4); padding-inline: var(--sp-6) 0; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: .2rem; top: .4rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: .46rem; top: 1.15rem; bottom: .15rem; width: 1px; background: var(--line-2); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
.timeline strong { font-weight: 600; }
details > summary { cursor: pointer; }
.timeline details summary { font-size: var(--fs-xs); color: var(--link); }

.tabs { display: flex; gap: var(--sp-1); margin: 0 0 var(--sp-5); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { position: relative; display: inline-flex; align-items: center; gap: .45rem; padding: .7rem .85rem; color: var(--ink-2); font-weight: 550; white-space: nowrap; border-radius: var(--r) var(--r) 0 0; }
.tabs a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.tabs a:is([aria-current="page"], .active) { color: var(--accent-ink); }
.tabs a:is([aria-current="page"], .active)::after { content: ""; position: absolute; inset-inline: .5rem; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.tabs a:is([aria-current="page"], .active) .count { background: var(--accent-soft); color: var(--accent-ink); }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); margin: calc(-1 * var(--sp-2)) 0 var(--sp-6); font-size: var(--fs-sm); color: var(--ink-2); }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  min-width: 2rem; height: 2rem; padding: 0 .55rem;
  font-weight: 550; font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
}
a.page-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.page-link.current { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.page-link.disabled { color: var(--ink-3); background: transparent; border-color: var(--line); cursor: default; }
.page-gap { padding: 0 .2rem; color: var(--ink-3); }
.pager-note { margin: calc(-1 * var(--sp-4)) 0 var(--sp-6); font-size: var(--fs-sm); color: var(--ink-2); }
th .sort { display: inline-flex; align-items: center; gap: .3rem; color: inherit; font-weight: inherit; white-space: nowrap; }
th .sort:hover { color: var(--ink); text-decoration: none; }
th .sort .icon { color: var(--ink-3); opacity: .55; }
th .sort:hover .icon { opacity: 1; }
th .sort.active { color: var(--ink); }
th .sort.active .icon { color: var(--accent); opacity: 1; }

.empty { display: grid; justify-items: center; gap: .35rem; padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--ink-2); }
.empty .icon { width: 1.75rem; height: 1.75rem; color: var(--ink-3); margin-bottom: .25rem; }
.empty strong { color: var(--ink); font-weight: 600; }
.empty p { margin: 0; max-width: 34rem; }

.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.see-all { display: inline-flex; align-items: center; gap: .3rem; font-size: var(--fs-sm); font-weight: 550; }

/* ------------------------------------------------------------------ 9. Dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(12.5rem, 100%), 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat { display: flex; flex-direction: column; gap: .2rem; padding: var(--sp-4) var(--sp-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); color: var(--ink); }
a.stat:hover { border-color: color-mix(in oklab, var(--accent) 40%, var(--line)); text-decoration: none; }
.stat-label { display: flex; align-items: center; gap: .45rem; font-size: var(--fs-sm); font-weight: 550; color: var(--ink-2); }
.stat-label .icon { color: var(--ink-3); }
.stat-value { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat-note { font-size: var(--fs-sm); color: var(--ink-2); }
.stat .meter { margin-top: .5rem; }
.stat .spark { margin-top: .35rem; }
.meter { display: flex; height: .45rem; overflow: hidden; background: var(--surface-3); border-radius: var(--r-full); }
.meter span { display: block; height: 100%; }
.meter .ok { background: var(--ok); }
.meter .warn { background: var(--warn); }
.meter .danger { background: var(--danger); }
.meter .info { background: var(--accent); }
.meter .off { background: var(--line-2); }
.legend-list { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-top: .45rem; font-size: var(--fs-xs); color: var(--ink-2); }
.legend-list span { display: inline-flex; align-items: center; gap: .3rem; }
.swatch { width: .5rem; height: .5rem; border-radius: 2px; }
.swatch.ok { background: var(--ok); }
.swatch.warn { background: var(--warn); }
.swatch.danger { background: var(--danger); }
.swatch.info { background: var(--accent); }
.swatch.off { background: var(--line-2); }
.spark { display: block; width: 100%; height: 2.5rem; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); gap: var(--sp-5); align-items: start; }
.dash-grid > .panel { margin: 0; }
.quick { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ------------------------------------------------------------------ 10. Feature bits */
.bar { display: inline-block; width: 7rem; height: .45rem; overflow: hidden; vertical-align: middle; margin-inline-end: .5rem; background: var(--surface-3); border-radius: var(--r-full); }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.big { font-size: var(--fs-lg); font-weight: 600; margin: .3rem 0; }
.bars { display: block; width: 100%; height: 9rem; }
.bar-accept { fill: color-mix(in oklab, var(--ok) 75%, transparent); }
.bar-reject { fill: color-mix(in oklab, var(--danger) 80%, transparent); }
.bar-axis { stroke: var(--line-2); stroke-width: 1; }
.legend::before { content: ""; display: inline-block; width: .7rem; height: .7rem; margin-inline: .6rem .25rem; border-radius: 2px; vertical-align: -1px; }
.legend.accept::before { background: color-mix(in oklab, var(--ok) 75%, transparent); }
.legend.reject::before { background: color-mix(in oklab, var(--danger) 80%, transparent); }
.warn-text { color: var(--warn-ink); font-weight: 600; }
/* The MFA QR code stays black on white in both themes: phone cameras read dark modules on a light background. */
.qr { display: block; padding: 8px; background: #fff; border-radius: var(--r); image-rendering: pixelated; }
ul.codes { columns: 2; padding-inline-start: 1.2rem; font-family: var(--mono); }
.secret-box { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* ------------------------------------------------------------------ 11. Sign-in */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-5); padding: var(--sp-8) var(--sp-4); }
.auth-main { width: 100%; max-width: 25rem; padding: 0; }
.auth-card { padding: var(--sp-8); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2); }
.auth-brand { display: flex; align-items: center; gap: .65rem; margin-bottom: var(--sp-6); font-size: var(--fs-md); font-weight: 650; color: var(--ink); }
.auth-card h1 { margin-bottom: var(--sp-1); }
.auth-card .lede { margin-bottom: var(--sp-5); color: var(--ink-2); }
.auth-card label:first-of-type { margin-top: 0; }
.auth-card input:not([type="checkbox"]) { height: 2.5rem; }
.auth-card button[type="submit"] { width: 100%; height: 2.5rem; margin-top: var(--sp-6); }
.auth-foot { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-xs); color: var(--ink-3); }

/* ------------------------------------------------------------------ 12. Small screens */
@media (max-width: 1100px) {
  .layout-2col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; overflow: visible; }
  .sidebar-head { padding-block: var(--sp-3); }
  .nav, .sidebar-foot { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav-toggle-input:checked ~ .sidebar :is(.nav, .sidebar-foot) { display: block; }
  .topbar { position: static; padding: 0 var(--sp-4); gap: var(--sp-2); }
  .user-name, .search kbd { display: none; }
  main { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
  :is(main > table, .table-wrap > table, .panel > table) { display: block; overflow-x: auto; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  form.filters input[type="search"], form.filters input[type="text"] { min-width: 0; width: 100%; }
  form.filters > label { flex: 1 1 10rem; }
  .facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) 0; }
  .facts > div { min-width: 0; padding-inline: var(--sp-4); }
  .facts > div + div { border-inline-start: 0; }
  .panel, .card { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

@media print {
  .sidebar, .topbar, .skip, .no-print, .actions, form, .tabs, .alert.ok, .nav-toggle-input { display: none !important; }
  .app { display: block; }
  main, .print-sheet { max-width: none; margin: 0; padding: 0; }
  body { background: #fff; color: #000; }
  a { color: inherit; text-decoration: none; }
  .card, .panel, main > table { box-shadow: none; border-color: #ccc; }
}

/* Statements and receipts (print sheets) */
.print-sheet { max-width: 60rem; }
.print-head { display: flex; justify-content: space-between; gap: 2rem; padding-bottom: .5rem; margin-bottom: 1rem; border-bottom: 2px solid currentColor; }
.print-seller { font-weight: 700; font-size: 1.1rem; }
.print-title { font-weight: 700; font-size: 1.4rem; text-align: end; }
.print-meta th { text-align: start; padding-inline-end: 1.5rem; background: none; }

/* A form split into sections inside one panel: the section heading carries the space above the first row. */
.panel-body.form-grid { padding-top: var(--sp-1); }

/* Related records: native server-search fallback, enhanced as one searchable combobox. */
.lookup-select, .address-picker, .filter-field { min-width: 0; max-width: 100%; }
.lookup-search-row { display: flex; align-items: center; gap: var(--sp-2); margin-block-end: var(--sp-2); }
.lookup-search-row .lookup-search { flex: 1 1 0; min-width: 0; margin: 0; }
.lookup-search-row .lookup-submit { flex: 0 0 auto; margin: 0; }
.remote-lookup[aria-busy="true"] .lookup-status { color: var(--ink-2); }
.lookup-select select { width: 100%; max-width: 100%; }
.lookup-select .lookup-search { margin-block-end: var(--sp-2); }
.lookup-select [hidden] { display: none !important; }
.lookup-select select[multiple] { min-height: 8rem; }
.address-picker > button { margin-block: var(--sp-2); }
.address-picker .form-actions { align-items: center; flex-wrap: wrap; }
.filters .filter-field { display: flex; flex-direction: column; gap: var(--sp-1); flex: 1 1 13rem; max-width: 24rem; }

.lookup-enhanced > :is(.lookup-search-row, .lookup-fallback-hint) { display: none; }
.remote-lookup .ts-wrapper { width: 100%; min-width: 0; font: inherit; color: var(--ink); }
.remote-lookup .ts-wrapper .ts-control {
  min-height: 2.125rem; padding: .25rem 2rem .25rem .65rem; padding-inline: .65rem 2rem !important;
  gap: .25rem; align-items: center; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); color: var(--ink); box-shadow: none; overflow: hidden;
  font: inherit; line-height: 1.5; cursor: text;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.remote-lookup .ts-control::after {
  content: ""; position: absolute; inset-inline-end: .55rem; top: .6rem; width: 1rem; height: 1rem;
  background: var(--chevron) center / 1rem no-repeat; pointer-events: none;
}
.remote-lookup .ts-control:hover { border-color: var(--ink-3); }
.remote-lookup .ts-wrapper.single.input-active .ts-control { background: var(--surface); }
.remote-lookup .ts-wrapper:is(.focus, :focus-within) .ts-control {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
}
.remote-lookup .ts-wrapper.invalid .ts-control { border-color: var(--danger); }
.remote-lookup .ts-wrapper.disabled .ts-control { background: var(--surface-2); color: var(--ink-3); }
.remote-lookup .ts-control > input {
  width: auto; min-width: min(8rem, 100%); flex: 1 1 8rem; height: 1.5rem; font: inherit; color: var(--ink);
}
.remote-lookup .ts-wrapper.single .ts-control > .item { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remote-lookup .ts-wrapper.single.input-active .ts-control > .item { display: none; }
.remote-lookup .ts-wrapper.multi .ts-control > .item {
  display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; min-width: 0; margin: 0;
  padding: 0 0 0 .5rem; padding-inline: .5rem 0; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink); overflow-wrap: anywhere; overflow: visible;
}
.remote-lookup .ts-wrapper.multi .ts-control > .item.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.remote-lookup .ts-wrapper .item button.remove {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 1.625rem;
  width: 1.625rem; min-width: 1.625rem; height: 1.625rem; min-height: 1.625rem;
  margin: 0; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; box-shadow: none;
  font-size: 1.125rem; line-height: 1; color: var(--ink-2); cursor: pointer;
}
.remote-lookup .ts-wrapper .item button.remove:hover { background: var(--surface-3); color: var(--ink); }
.remote-lookup .ts-wrapper .item button.remove:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.ts-dropdown.record-dropdown {
  z-index: var(--z-dropdown); padding: .25rem 0 0; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); font: inherit; font-size: var(--fs-base);
  overflow: hidden; display: flex; flex-direction: column;
}
.ts-dropdown.record-dropdown.record-open { display: flex !important; }
.record-dropdown .ts-dropdown-content { flex: 1 1 auto; min-height: 0; max-height: 16rem; scroll-behavior: auto; overscroll-behavior: contain; }
.record-dropdown .option { padding: .5rem .75rem; min-height: 2.125rem; overflow-wrap: anywhere; }
.record-dropdown .option.active { background: var(--accent-soft); color: var(--accent-ink); }
.record-dropdown .option.selected { font-weight: 600; }
.record-dropdown .record-empty { display: none; }
.record-dropdown .lookup-status {
  flex: 0 0 auto; margin: 0; padding: .5rem .75rem; border-top: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); line-height: 1.5;
}
.record-dropdown:is(.record-loading, .record-failed) .ts-dropdown-content { display: none; }
.record-dropdown.record-failed .lookup-status { color: var(--danger-ink); }
.record-dropdown.record-loading .lookup-status { border-top-color: transparent; }
@media (pointer: coarse) {
  .remote-lookup .ts-wrapper .ts-control, .record-dropdown .option { min-height: 2.75rem; }
  .remote-lookup .ts-wrapper .item button.remove { width: 2.75rem; height: 2.75rem; flex-basis: 2.75rem; }
}

/* ------------------------------------------------------------------ System map (Shared/SystemMapPanel.razor, wwwroot/sysmap.js)
   One status line, the map (SVG drawn by script), what needs attention and the servers. Status colours are the
   ok / warn / danger tokens, so both themes follow; the SVG keeps left-to-right geometry and mirrors its own layout. */
.sysmap {
  display: grid; gap: var(--sp-4); margin-bottom: var(--sp-5); padding: var(--sp-4) var(--sp-5) var(--sp-5);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.sysmap h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-md); }
.sysmap-status {
  display: flex; align-items: center; flex-wrap: wrap; gap: .35rem var(--sp-3); padding: .6rem var(--sp-4);
  border-radius: var(--r); background: var(--ok-soft); color: var(--ok-ink);
}
.sysmap-status.is-warn { background: var(--warn-soft); color: var(--warn-ink); }
.sysmap-status.is-bad { background: var(--danger-soft); color: var(--danger-ink); }
.sysmap-status.is-off { background: var(--surface-2); color: var(--ink-2); }
.sysmap-light { flex: none; width: .7rem; height: .7rem; border-radius: 50%; background: currentColor; }
.sysmap-status.is-bad .sysmap-light { animation: sysmap-pulse 1.6s ease-out infinite; }
@keyframes sysmap-pulse {
  from { box-shadow: 0 0 0 0 color-mix(in oklch, currentColor 50%, transparent); }
  to { box-shadow: 0 0 0 .55rem transparent; }
}
.sysmap-headline { font-weight: 600; }
.sysmap-when { margin-inline-start: auto; font-size: var(--fs-sm); opacity: .85; }
.sysmap-when.is-stale { opacity: 1; font-weight: 600; color: var(--danger-ink); }
.sysmap-status .see-all { color: inherit; font-weight: 600; text-decoration: underline; }
.sysmap-notice { margin: 0; padding: .5rem var(--sp-3); border-radius: var(--r); background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-sm); }
.sysmap-canvas { min-height: 6rem; overflow-x: auto; padding: var(--sp-2); border-radius: var(--r); background: var(--surface-2); }
.sysmap-svg { display: block; width: 100%; height: auto; margin-inline: auto; direction: ltr; font-family: var(--font); }
.sysmap-lower { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
.sysmap.compact .sysmap-lower { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) { .sysmap-lower { grid-template-columns: minmax(0, 1fr); } }

.sm-node { cursor: pointer; outline: none; }
.sm-box { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; transition: stroke .15s; }
.sm-node:hover .sm-box { stroke: var(--accent); }
.sm-node.is-warn .sm-box { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 1.5; }
.sm-node.is-bad .sm-box { fill: var(--danger-soft); stroke: var(--danger); stroke-width: 1.75; }
.sm-node.is-off .sm-box { fill: var(--surface-2); stroke-dasharray: 4 4; }
.sm-node.is-selected .sm-box, .sm-node:focus-visible .sm-box { stroke: var(--focus); stroke-width: 2.5; }
.sm-dot { fill: var(--ok); }
.sm-node.is-warn .sm-dot { fill: var(--warn); }
.sm-node.is-bad .sm-dot { fill: var(--danger); }
.sm-node.is-off .sm-dot { fill: var(--ink-3); }
.sm-title { fill: var(--ink); font-size: 13px; font-weight: 600; }
.sm-sub { fill: var(--ink-2); font-size: 11.5px; }
.sm-node.is-warn .sm-sub { fill: var(--warn-ink); }
.sm-node.is-bad .sm-sub { fill: var(--danger-ink); font-weight: 600; }
.sm-sep { stroke: var(--line); stroke-width: 1; }
.sm-row-name { fill: var(--ink); font-size: 11.5px; }
.sm-row-value { fill: var(--ink-2); font-size: 11.5px; }
.sm-row-value.is-warn { fill: var(--warn-ink); }
.sm-row-value.is-bad { fill: var(--danger-ink); font-weight: 600; }
.sm-row-dot.is-ok { fill: var(--ok); }
.sm-row-dot.is-warn { fill: var(--warn); }
.sm-row-dot.is-bad { fill: var(--danger); }
.sm-row-dot.is-off { fill: var(--ink-3); }
.sm-link { fill: none; stroke: var(--line-2); stroke-width: 1.6; }
.sm-link.is-ok { stroke: color-mix(in oklch, var(--ok) 55%, var(--line-2)); }
.sm-link.is-warn { stroke: var(--warn); stroke-width: 2; }
.sm-link.is-bad { stroke: var(--danger); stroke-width: 2.2; stroke-dasharray: 6 5; animation: sysmap-dash 1s linear infinite; }
.sm-link.is-off { stroke-dasharray: 3 5; }
@keyframes sysmap-dash { to { stroke-dashoffset: -11; } }
.sm-flow { fill: var(--ok); }
.sm-flow.is-warn { fill: var(--warn); }
.sm-link-bg { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.sm-link-label { fill: var(--ink-2); font-size: 11px; font-family: var(--mono); }
.sm-link-label.is-bad { fill: var(--danger-ink); font-weight: 600; }

.sysmap-detail { position: sticky; top: var(--sp-4); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.sysmap-detail-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.sysmap-detail h3 { margin: 0; font-size: var(--fs-md); }
.sysmap-detail p { margin: var(--sp-2) 0 0; }
.sysmap-detail-summary { font-weight: 600; }
.sysmap-detail .button { margin-top: var(--sp-3); }
.sysmap-rows { display: grid; gap: .3rem; margin: var(--sp-2) 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); }
.sysmap-rows li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; }
.sysmap-row-value { color: var(--ink-2); text-align: end; }
.sysmap-rows li.is-warn .sysmap-row-value { color: var(--warn-ink); }
.sysmap-rows li.is-bad .sysmap-row-value { color: var(--danger-ink); font-weight: 600; }
.sm-swatch { display: inline-block; flex: none; width: .55rem; height: .55rem; border-radius: 50%; background: var(--ok); }
.sm-swatch.is-warn, .is-warn > .sm-swatch { background: var(--warn); }
.sm-swatch.is-bad, .is-bad > .sm-swatch { background: var(--danger); }
.sm-swatch.is-off, .is-off > .sm-swatch { background: var(--ink-3); }

.sysmap-legend { display: flex; flex-wrap: wrap; gap: .35rem var(--sp-4); margin: 0; padding: 0; list-style: none; font-size: var(--fs-xs); color: var(--ink-2); }
.sysmap-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.sysmap-problem-list { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.sysmap-problem-list li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--sp-3);
  padding: .6rem var(--sp-3); border: 1px solid var(--line); border-radius: var(--r);
}
.sysmap-problem-list li.is-bad { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 45%, var(--line)); }
.sysmap-problem-list li.is-warn { background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 45%, var(--line)); }
.sysmap-problem-text { display: grid; gap: .15rem; min-width: 0; }
.sysmap-problem-text span { color: var(--ink-2); font-size: var(--fs-sm); }
.sysmap.compact .sysmap-problem-text span { display: none; }
.sysmap-machines-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--sp-3); }
.sysmap-machine { display: grid; align-content: start; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r); }
.sysmap-machine.is-warn { border-color: var(--warn); }
.sysmap-machine.is-bad { border-color: var(--danger); }
.sysmap-machine.is-off { border-style: dashed; }
.sysmap-machine-head { display: flex; align-items: start; justify-content: space-between; gap: var(--sp-2); }
.sysmap-machine-head div { display: grid; }
.sysmap-machine-head .muted { font-size: var(--fs-xs); }
.sysmap-meter { display: grid; gap: .2rem; font-size: var(--fs-xs); }
.sysmap-meter-top { display: flex; justify-content: space-between; gap: var(--sp-2); color: var(--ink-2); }
.sysmap-bar { height: .4rem; overflow: hidden; border-radius: var(--r-full); background: var(--surface-3); }
.sysmap-bar span { display: block; height: 100%; border-radius: inherit; background: var(--ok); }
.sysmap-bar.is-warn span { background: var(--warn); }
.sysmap-bar.is-bad span { background: var(--danger); }
@media (prefers-reduced-motion: reduce) {
  .sysmap-status.is-bad .sysmap-light, .sm-link.is-bad { animation: none; }
}
