/*! SySys design system v1.0.3 - https://github.com/sysyscorp/sysys-design-system */
@layer ds.tokens, ds.base, ds.layout, ds.components, ds.extras;

/* ---- 00-tokens.css ---- */
@layer ds.tokens {
/* tokens: every colour, size and radius used by the system. Change --hue to re-theme everything.
   Light/dark come from color-scheme + light-dark(); the page follows the OS unless <html data-theme> is set. */

:root {
  color-scheme: light dark;
  --hue: 248;                                   /* brand blue #4277a7 = oklch(0.554 0.094 248) */

  /* brand */
  --brand:        light-dark(oklch(0.554 0.094 var(--hue)), oklch(0.72 0.10 var(--hue)));
  --brand-strong: light-dark(oklch(0.46 0.10 var(--hue)),   oklch(0.80 0.09 var(--hue)));
  --brand-soft:   light-dark(oklch(0.95 0.02 var(--hue)),   oklch(0.27 0.04 var(--hue)));
  --btn-bg:       light-dark(oklch(0.46 0.10 var(--hue)),   oklch(0.72 0.10 var(--hue)));
  --on-brand:     light-dark(oklch(0.99 0 0),               oklch(0.17 0.02 var(--hue)));

  /* surfaces and text */
  --bg:         light-dark(oklch(0.99 0.004 var(--hue)),  oklch(0.19 0.02 var(--hue)));
  --surface:    light-dark(oklch(0.97 0.008 var(--hue)),  oklch(0.235 0.025 var(--hue)));
  --surface-2:  light-dark(oklch(0.94 0.012 var(--hue)),  oklch(0.28 0.03 var(--hue)));
  --border:     light-dark(oklch(0.90 0.012 var(--hue)),  oklch(0.32 0.03 var(--hue)));
  --border-strong: light-dark(oklch(0.80 0.02 var(--hue)), oklch(0.42 0.035 var(--hue)));
  --text:       light-dark(oklch(0.22 0.025 var(--hue)),  oklch(0.95 0.008 var(--hue)));
  --text-mute:  light-dark(oklch(0.48 0.025 var(--hue)),  oklch(0.74 0.02 var(--hue)));

  /* status: used for alerts, badges, status cells. Each has a readable text tone and a soft background. */
  --ok:    light-dark(oklch(0.55 0.14 150), oklch(0.72 0.15 150));
  --warn:  light-dark(oklch(0.62 0.14 75),  oklch(0.80 0.15 80));
  --bad:   light-dark(oklch(0.55 0.19 27),  oklch(0.70 0.19 27));
  --info:  light-dark(oklch(0.52 0.12 235), oklch(0.74 0.11 235));
  --off:   light-dark(oklch(0.62 0.01 var(--hue)), oklch(0.58 0.015 var(--hue)));   /* disabled / unknown */
  --ok-soft:   color-mix(in oklab, var(--ok) 13%, var(--bg));
  --warn-soft: color-mix(in oklab, var(--warn) 16%, var(--bg));
  --bad-soft:  color-mix(in oklab, var(--bad) 13%, var(--bg));
  --info-soft: color-mix(in oklab, var(--info) 13%, var(--bg));
  --off-soft:  color-mix(in oklab, var(--off) 14%, var(--bg));

  /* type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --fs-base: 1rem;                              /* 16px; compact density lowers it */
  --fs-sm: .875em;
  --fs-xs: .75em;
  --lh: 1.55;

  /* space (4px steps) */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem; --s-8: 4.5rem;
  --pad-x: 1rem;                                /* page gutter */

  /* shape */
  --radius: 12px;                               /* cards, panels, dialogs */
  --radius-ctl: 10px;                           /* buttons and form controls share this */
  --radius-sm: 6px;
  --border-w: 1px;

  /* controls */
  --ctl-pad-y: .6em;
  --ctl-pad-x: .9em;
  --cell-pad-y: .65rem;
  --cell-pad-x: .9rem;

  /* depth */
  --shadow-tint: oklch(0.3 0.1 var(--hue));
  --shadow-sm: 0 1px 2px oklch(0.2 0.05 var(--hue) / .08);
  --shadow-md: 0 1px 2px oklch(0.2 0.05 var(--hue) / .06), 0 14px 28px -18px color-mix(in oklch, var(--shadow-tint) 40%, transparent);
  --shadow-lg: 0 24px 48px -20px color-mix(in oklch, var(--shadow-tint) 55%, transparent);
  --focus: 3px solid var(--brand);

  /* layout */
  --max: 72rem;
  --header-h: 3.5rem;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* Compact density for data-heavy screens: <html data-density="compact"> */
:root[data-density="compact"] {
  --fs-base: .875rem; --lh: 1.45;
  --ctl-pad-y: .4em; --ctl-pad-x: .7em;
  --cell-pad-y: .35rem; --cell-pad-x: .65rem;
  --s-4: .85rem; --s-5: 1.15rem;
}
}

/* ---- 10-base.css ---- */
@layer ds.base {
/* base: reset, type, links, code. Element defaults only; no classes here except tiny helpers. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--header-h); }
body { margin: 0; min-height: 100dvh; font: var(--fs-base) / var(--lh) var(--font); color: var(--text); background: var(--bg); }
img, svg, video { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: color-mix(in oklch, var(--brand) 30%, transparent); }

h1, h2, h3, h4, h5, h6 { margin: 0 0 .5em; line-height: 1.2; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: 1.9em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.25em; }
h4 { font-size: 1.1em; }
h5, h6 { font-size: 1em; }
p, ul, ol, dl, pre, table, figure, blockquote { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; }
small { font-size: var(--fs-sm); }
strong, b { font-weight: 650; }
hr { border: 0; border-top: var(--border-w) solid var(--border); margin: var(--s-5) 0; }

a { color: var(--brand-strong); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: var(--focus); outline-offset: 2px; }

code, kbd, samp, pre { font-family: var(--mono); font-size: .9em; }
code, kbd { padding: .1em .35em; background: var(--surface-2); border-radius: var(--radius-sm); }
kbd { border: var(--border-w) solid var(--border-strong); border-bottom-width: 2px; }
pre { padding: var(--s-4); overflow: auto; background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius-ctl); }
pre code { padding: 0; background: none; }
mark { background: color-mix(in oklch, var(--warn) 30%, transparent); color: inherit; padding: 0 .15em; border-radius: 3px; }
blockquote { padding-left: var(--s-4); border-left: 3px solid var(--border-strong); color: var(--text-mute); }

/* helpers used by almost every page */
.mute { color: var(--text-mute); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; z-index: 100; padding: .6rem 1rem; background: var(--bg); }
.skip:focus { left: 0; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
}

/* ---- 20-layout.css ---- */
@layer ds.layout {
/* layout: page frame and a few composable layout primitives. Prefer these over per-page CSS. */

/* Page frame. Works inside the single <form runat="server"> an ASP.NET page wraps everything in:
   <body class="app"> <header class="app-header"> <main class="app-main container"> <footer class="app-footer"> */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.app > .app-main { flex: 1 0 auto; min-width: 0; }
/* ASP.NET emits <div class="aspNetHidden"> (viewstate inputs) as the first child of the form; it must take no space */
.aspNetHidden { display: none; }
.app-main { padding-block: var(--s-6); }
.app-footer { padding-block: var(--s-5); border-top: var(--border-w) solid var(--border); color: var(--text-mute); font-size: var(--fs-sm); }

.container { width: min(100% - 2 * var(--pad-x), var(--max)); margin-inline: auto; }
.container--wide { --max: 96rem; }
.container--narrow { --max: 44rem; }
.container--fluid { width: 100%; padding-inline: var(--pad-x); }

/* Vertical rhythm: children are spaced by --gap */
.stack { display: flex; flex-direction: column; gap: var(--gap, var(--s-4)); }
.stack > * { margin-block: 0; }
/* Horizontal group that wraps */
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--s-3)); }
.cluster--end { justify-content: flex-end; }
.cluster--between { justify-content: space-between; }
.spacer { flex: 1 1 auto; }

/* Auto-fitting grid: .grid sets columns by minimum width; .cols-N forces N columns on wide screens */
.grid { display: grid; gap: var(--gap, var(--s-4)); grid-template-columns: repeat(auto-fit, minmax(var(--min, 16rem), 1fr)); }
@media (min-width: 48rem) {
  .cols-2 { grid-template-columns: repeat(2, 1fr); }
  .cols-3 { grid-template-columns: repeat(3, 1fr); }
  .cols-4 { grid-template-columns: repeat(4, 1fr); }
}
/* Grid and sidebar children may shrink below their content width, so wide tables scroll inside .table-wrap instead of widening the page */
.grid > *, .with-sidebar > * { min-width: 0; }
.col-span-2 { grid-column: span 2; }
.col-full { grid-column: 1 / -1; }

/* Content with a side column that stacks on small screens */
.with-sidebar { display: grid; gap: var(--s-5); }
@media (min-width: 56rem) { .with-sidebar { grid-template-columns: var(--side, 15rem) minmax(0, 1fr); align-items: start; } }

/* Page title row: title on the left, actions on the right */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-5); margin-bottom: var(--s-5); }
.page-head h1 { margin: 0; }
.page-head p { margin: 0; color: var(--text-mute); }

/* Small spacing utilities (margin only; padding belongs to components) */
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); }
.text-center { text-align: center; } .text-end { text-align: end; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
}

/* ---- 30-buttons.css ---- */
@layer ds.components {
/* buttons: <a class="btn"> or <button class="btn">. Variants change colour only; sizes change padding.
   The hover fill grows from where the pointer entered (ds.js sets --x / --y). */

.btn {
  --x: 50%; --y: 50%;
  --btn-fill: color-mix(in oklch, var(--btn-bg), white 14%);
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: var(--ctl-pad-y) calc(var(--ctl-pad-x) * 1.4);
  font: inherit; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; white-space: nowrap;
  color: var(--on-brand); background: var(--btn-bg); border: var(--border-w) solid transparent; border-radius: var(--radius-ctl);
  cursor: pointer; user-select: none;
}
.btn::before {
  content: ""; position: absolute; z-index: -1; left: var(--x); top: var(--y); width: 260%; aspect-ratio: 1; border-radius: 50%;
  background: var(--btn-fill); transform: translate(-50%, -50%) scale(0); transition: transform .55s cubic-bezier(.2, .7, .2, 1); pointer-events: none;
}
@media (hover: hover) { .btn:hover::before { transform: translate(-50%, -50%) scale(1); transition-duration: .9s; } }
.btn:hover { text-decoration: none; }

/* <input type="submit" class="btn"> (what asp:Button renders) cannot hold the growing fill, so it gets a plain colour change instead */
input.btn { transition: background-color .25s; }
input.btn:hover { background-color: var(--btn-fill); }

/* variants */
.btn--secondary { --btn-fill: var(--surface-2); color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.btn--ghost { --btn-fill: color-mix(in oklch, var(--text) 8%, transparent); color: var(--text); background: transparent; border-color: var(--border); }
.btn--link { --btn-fill: transparent; color: var(--brand-strong); background: transparent; padding-inline: .25em; text-decoration: underline; text-underline-offset: .18em; }
.btn--success { --btn-bg: var(--ok);  --on-brand: oklch(0.99 0 0); }
.btn--danger  { --btn-bg: var(--bad); --on-brand: oklch(0.99 0 0); }
.btn--warning { --btn-bg: var(--warn); --on-brand: oklch(0.2 0.05 75); }
.btn--info    { --btn-bg: var(--info); --on-brand: oklch(0.99 0 0); }
.btn--success:hover::before, .btn--danger:hover::before, .btn--warning:hover::before, .btn--info:hover::before { /* same colour family, slightly brighter */ }

/* sizes and shapes */
.btn--sm { padding: calc(var(--ctl-pad-y) * .65) var(--ctl-pad-x); font-size: var(--fs-sm); }
.btn--lg { padding: calc(var(--ctl-pad-y) * 1.25) calc(var(--ctl-pad-x) * 1.8); font-size: 1.1em; }
.btn--block { display: flex; width: 100%; }
.btn--icon { padding: var(--ctl-pad-y); aspect-ratio: 1; }

/* states */
.btn:disabled, .btn[aria-disabled="true"], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn:active { translate: 0 1px; }

/* Buttons that sit edge to edge */
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-radius: var(--radius-ctl) 0 0 var(--radius-ctl); }
.btn-group > .btn:last-child { border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0; }
.btn-group > .btn + .btn { margin-left: -1px; }

/* Square icon button (theme toggle, close, menu) */
.icon-btn { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0; color: var(--text); background: none; border: var(--border-w) solid var(--border); border-radius: var(--radius-ctl); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

@media (prefers-reduced-motion: reduce) { .btn::before, .btn:hover::before { transition: none; } }
}

/* ---- 31-forms.css ---- */
@layer ds.components {
/* forms: .field wraps label + control + help/error. Controls get their look from the element (inside .form or .field)
   or from .input / .select / .textarea so ASP.NET CssClass="input" works too. */

.form { display: grid; gap: var(--s-4); }
.field { display: grid; gap: .35rem; min-width: 0; }
.field > label, .field > .label, legend { font-weight: 600; font-size: var(--fs-sm); }
.field .help { font-size: var(--fs-sm); color: var(--text-mute); }
.field .error, .error-text { font-size: var(--fs-sm); color: var(--bad); font-weight: 600; }
.req::after { content: " *"; color: var(--bad); }

/* Inputs, selects, text areas */
.input, .select, .textarea,
.form :where(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=submit], [type=button], [type=image], [type=hidden]), select, textarea),
.field :where(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=submit], [type=button], [type=image], [type=hidden]), select, textarea) {
  display: block; width: 100%; min-width: 0; padding: var(--ctl-pad-y) var(--ctl-pad-x);
  color: var(--text); background: var(--bg); border: var(--border-w) solid var(--border-strong); border-radius: var(--radius-ctl);
  line-height: 1.3; transition: border-color .15s, box-shadow .15s;
}
.textarea, .form textarea, .field textarea { min-height: 6.5em; resize: vertical; }
:where(.input, .select, .textarea, .form input, .form select, .form textarea, .field input, .field select, .field textarea)::placeholder { color: var(--text-mute); opacity: .8; }
:where(.input, .select, .textarea, .form input, .form select, .form textarea, .field input, .field select, .field textarea):focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 28%, transparent);
}
:where(.input, .select, .textarea, .form input, .form select, .form textarea, .field input, .field select, .field textarea):disabled,
.is-disabled { background: var(--surface); color: var(--text-mute); cursor: not-allowed; }
:where(input, textarea)[readonly] { background: var(--surface); }

/* Select: native control with a chevron drawn in CSS (no image) */
.select, .form select, .field select {
  appearance: none; padding-right: 2.2em; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.15em) 55%, calc(100% - .8em) 55%; background-size: .35em .35em, .35em .35em; background-repeat: no-repeat;
}
select[multiple], select[size]:not([size="1"]) { background-image: none; padding-right: var(--ctl-pad-x); }

/* Validation. .is-invalid is set by the page; :user-invalid covers native validation after interaction. */
.is-invalid, :where(input, select, textarea):user-invalid { border-color: var(--bad) !important; }
.is-invalid:focus, :where(input, select, textarea):user-invalid:focus { box-shadow: 0 0 0 3px color-mix(in oklch, var(--bad) 28%, transparent) !important; }
.is-valid { border-color: var(--ok) !important; }
/* ASP.NET validators render <span class="validator"> (set CssClass="error-text" on asp:RequiredFieldValidator etc.) */
.validation-summary { padding: var(--s-3) var(--s-4); background: var(--bad-soft); border: var(--border-w) solid color-mix(in oklch, var(--bad) 40%, transparent); border-radius: var(--radius-ctl); color: var(--text); }
.validation-summary ul { margin: 0; }

/* Checkbox, radio */
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 1.1em; height: 1.1em; margin: 0; flex: none; }
.check { display: flex; align-items: flex-start; gap: .55em; font-weight: 500; cursor: pointer; }
.check input { margin-top: .2em; }
.check-group { display: grid; gap: var(--s-2); }
.check-group--inline { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
/* asp:CheckBoxList / RadioButtonList with RepeatLayout="UnorderedList" render <ul class="check-group"><li><input><label> */
.check-group:is(ul, ol) { list-style: none; margin: 0; padding: 0; }
.check-group > li { display: flex; align-items: flex-start; gap: .55em; }
.check-group > li > input { margin-top: .2em; }
.check-group > li > label { font-weight: 500; cursor: pointer; }

/* Switch: <label class="switch"><input type="checkbox" role="switch"> Label</label> */
.switch { display: inline-flex; align-items: center; gap: .6em; cursor: pointer; font-weight: 500; }
.switch input { appearance: none; position: relative; width: 2.4em; height: 1.35em; border-radius: 999px; background: var(--border-strong); transition: background .2s; flex: none; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: .15em; left: .15em; width: 1.05em; height: 1.05em; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-sm); transition: translate .2s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { translate: 1.05em 0; }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

/* File input */
input[type=file] { max-width: 100%; }
input[type=file]::file-selector-button { margin-right: .8em; padding: .45em .9em; font: inherit; font-weight: 600; color: var(--text); background: var(--surface); border: var(--border-w) solid var(--border-strong); border-radius: var(--radius-ctl); cursor: pointer; }
input[type=range] { accent-color: var(--brand); width: 100%; }

/* Input with an attached button or text: <div class="input-group"><input><button class="btn">…</button></div> */
.input-group { display: flex; }
.input-group > :where(input, select) { flex: 1 1 auto; border-radius: var(--radius-ctl) 0 0 var(--radius-ctl) !important; }
.input-group > .btn { border-radius: 0 var(--radius-ctl) var(--radius-ctl) 0; }
.input-group > .addon { display: grid; place-items: center; padding-inline: var(--ctl-pad-x); background: var(--surface); border: var(--border-w) solid var(--border-strong); color: var(--text-mute); }
.input-group > .addon:first-child { border-radius: var(--radius-ctl) 0 0 var(--radius-ctl); border-right: 0; }

/* Groups */
fieldset { margin: 0; padding: var(--s-4); border: var(--border-w) solid var(--border); border-radius: var(--radius-ctl); min-width: 0; }
legend { padding-inline: .4em; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); padding-top: var(--s-2); }

/* Label beside the control on wide screens (replaces Bootstrap form-horizontal) */
@media (min-width: 40rem) {
  .form--horizontal .field { grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr); align-items: start; column-gap: var(--s-4); }
  .form--horizontal .field > label { padding-top: calc(var(--ctl-pad-y) + .1em); }
  .form--horizontal .field > .help, .form--horizontal .field > .error { grid-column: 2; }
  .form--horizontal .form-actions { padding-left: calc(min(12rem, 100%) + var(--s-4)); }
}
}

/* ---- 32-tables.css ---- */
@layer ds.components {
/* tables: <div class="table-wrap"><table class="table table--striped table--hover">. Also styles ASP.NET GridView output
   (set CssClass="table"; the legacy border/rules/cellspacing attributes it emits are overridden here). */

.table-wrap { overflow-x: auto; border: var(--border-w) solid var(--border); border-radius: var(--radius); background: var(--bg); }
.table-wrap > .table { margin: 0; }

.table { width: 100%; border-collapse: collapse; border-spacing: 0; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.table caption { padding: var(--cell-pad-y) var(--cell-pad-x); text-align: left; font-weight: 650; color: var(--text-mute); caption-side: top; }
.table :where(th, td) { padding: var(--cell-pad-y) var(--cell-pad-x); text-align: left; vertical-align: middle; border: 0; border-bottom: var(--border-w) solid var(--border); }
.table thead :where(th, td), .table tr:first-child > th { background: var(--surface); font-weight: 650; font-size: var(--fs-xs); letter-spacing: .04em; text-transform: uppercase; color: var(--text-mute); border-bottom-color: var(--border-strong); white-space: nowrap; }
.table tbody tr:last-child > :where(td, th), .table tfoot tr:last-child > :where(td, th) { border-bottom: 0; }
.table tfoot :where(td, th) { background: var(--surface); font-weight: 650; border-top: var(--border-w) solid var(--border-strong); }
.table :where(th, td) a { font-weight: 550; }

.table--striped tbody tr:nth-child(even) > :where(td, th) { background: color-mix(in oklch, var(--surface) 70%, var(--bg)); }
.table--hover tbody tr:hover > :where(td, th) { background: var(--brand-soft); }
.table--bordered :where(th, td) { border: var(--border-w) solid var(--border); }
.table--compact { --cell-pad-y: .3rem; --cell-pad-x: .6rem; }
.table--sticky thead th { position: sticky; top: var(--header-h); z-index: 1; }   /* put in a scrolling .table-wrap with max-height, or the page */
.table--fixed { table-layout: fixed; }

/* Cell and row helpers */
.num, .table td.num, .table th.num { text-align: right; }
.table tbody tr.is-selected > :where(td, th) { background: color-mix(in oklch, var(--brand) 16%, var(--bg)); }
.table tbody tr.is-bad > :where(td, th) { background: var(--bad-soft); }
.table tbody tr.is-warn > :where(td, th) { background: var(--warn-soft); }
.table tbody tr.is-ok > :where(td, th) { background: var(--ok-soft); }
.table tbody tr.is-off { color: var(--text-mute); }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }

/* Sortable headers: <th aria-sort="ascending|descending|none"> with a link or button inside */
.table th[aria-sort] { cursor: pointer; user-select: none; }
.table th[aria-sort]::after { content: "\2195"; margin-left: .4em; opacity: .35; font-size: .9em; }
.table th[aria-sort="ascending"]::after { content: "\2191"; opacity: 1; color: var(--brand); }
.table th[aria-sort="descending"]::after { content: "\2193"; opacity: 1; color: var(--brand); }
.table th a, .table th button { color: inherit; font: inherit; background: none; border: 0; padding: 0; text-decoration: none; cursor: pointer; }

/* GridView pager row: <tr class="pager"><td colspan><table><tr><td><span>1</span></td><td><a>2</a></td>… */
.table tr.pager > td, .table .pager td { padding: var(--s-3); text-align: center; background: var(--surface); text-transform: none; }
.table .pager table { margin: 0 auto; width: auto; border-collapse: separate; border-spacing: .25rem; }
.table .pager table td { padding: 0; border: 0; background: none; }
.table .pager :where(a, span) { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 .5rem; border: var(--border-w) solid var(--border); border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; }
.table .pager span { background: var(--btn-bg); color: var(--on-brand); border-color: transparent; }
.table .pager a:hover { background: var(--brand-soft); }

/* GridView (and other legacy tables) emit border/rules attributes and inline widths; neutralise the attributes */
table.table[border], table.table[rules] { border: 0; }
.table-empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-mute); }

/* Definition list as a two-column table-like block: <dl class="dl"><dt>Label</dt><dd>Value</dd> */
.dl { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: var(--s-2) var(--s-5); margin: 0 0 1em; }
.dl dt { color: var(--text-mute); font-weight: 600; }
.dl dd { margin: 0; }
}

/* ---- 33-navigation.css ---- */
@layer ds.components {
/* navigation: app header (with mobile fly-out), side nav, breadcrumbs, tabs, pagination.
   Header markup:
   <header class="app-header"><div class="container app-header__row">
     <a class="brand" href="/">Name</a>
     <nav class="nav" id="nav" aria-label="Primary"><a href="…" aria-current="page">…</a> …</nav>
     <div class="scrim" data-ds-scrim></div>
     <button class="icon-btn" data-ds-theme-toggle>…</button>
     <button class="icon-btn menu-toggle" data-ds-menu aria-controls="nav" aria-expanded="false"><span></span></button>
   </div></header> */

.app-header { position: sticky; top: 0; z-index: 20; background: color-mix(in oklch, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: var(--border-w) solid var(--border); }
.app-header__row { display: flex; align-items: center; gap: var(--s-3); min-height: var(--header-h); }
.app-header__row > .icon-btn { flex: none; }
.brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; margin-right: auto; font-weight: 800; font-size: 1.25em; letter-spacing: -.03em; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--brand); }
.nav { display: flex; align-items: center; gap: var(--s-1); }
.nav > a:not(.btn), .nav > .dropdown > summary { padding: .45em .8em; color: var(--text-mute); font-weight: 550; font-size: var(--fs-sm); text-decoration: none; border-radius: var(--radius-ctl); cursor: pointer; }
.nav > a:not(.btn):hover, .nav > .dropdown > summary:hover { color: var(--text); background: var(--surface-2); }
.nav > a:not(.btn)[aria-current="page"], .nav > a:not(.btn).active { color: var(--brand-strong); background: var(--brand-soft); }
.menu-toggle, .scrim, .nav-cta { display: none; }   /* .nav-cta: a .btn inside .nav that only appears in the mobile fly-out */
.menu-toggle span, .menu-toggle span::before, .menu-toggle span::after { display: block; content: ""; position: relative; width: 1.1rem; height: 2px; background: currentColor; border-radius: 1px; }
.menu-toggle span::before { position: absolute; top: -6px; }
.menu-toggle span::after { position: absolute; top: 6px; }

@media (max-width: 48rem) {
  .app-header { backdrop-filter: none; background: var(--bg); }     /* a backdrop filter would trap the fixed fly-out */
  .menu-toggle { display: grid; }
  .nav { position: fixed; inset: 0 0 0 auto; z-index: 30; width: min(20rem, 85vw); flex-direction: column; align-items: stretch; gap: .25rem; padding: 4.5rem 1.25rem 1.25rem; overflow-y: auto;
    background: var(--surface); border-left: var(--border-w) solid var(--border); box-shadow: -24px 0 48px -24px oklch(0.1 0.05 var(--hue) / .5);
    transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
  .nav > a:not(.btn), .nav > .dropdown > summary { padding: .8em .4em; font-size: 1.05rem; color: var(--text); border-radius: 0; border-bottom: var(--border-w) solid var(--border); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: oklch(0.1 0.03 var(--hue) / .55); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
  .nav .nav-cta { display: inline-flex; margin-top: var(--s-4); }
  .app-header__row > .btn { display: none; }     /* the header CTA moves into the fly-out */
  .menu-open { overflow: hidden; }
  .menu-open .nav { transform: none; visibility: visible; transition: transform .25s ease; }
  .menu-open .scrim { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) { .nav, .scrim { transition: none; } }

/* Side navigation (use inside .with-sidebar) */
.sidenav { display: grid; gap: 2px; position: sticky; top: calc(var(--header-h) + var(--s-4)); }
.sidenav h2, .sidenav .sidenav__title { margin: var(--s-4) 0 var(--s-1); padding-inline: .8em; font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); }
.sidenav a { padding: .5em .8em; color: var(--text); text-decoration: none; font-size: var(--fs-sm); font-weight: 550; border-radius: var(--radius-ctl); }
.sidenav a:hover { background: var(--surface-2); }
.sidenav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }

/* Breadcrumbs: <nav class="breadcrumb" aria-label="Breadcrumb"><ol><li><a>…</a></li><li aria-current="page">…</li></ol></nav> */
.breadcrumb { margin-bottom: var(--s-4); font-size: var(--fs-sm); }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: .35em; margin: 0; padding: 0; list-style: none; }
.breadcrumb li + li::before { content: "/"; margin-right: .35em; color: var(--text-mute); }
.breadcrumb [aria-current="page"] { color: var(--text-mute); }

/* Tabs: <div class="tabs" role="tablist"><button role="tab" aria-selected="true" aria-controls="p1">…</button></div> then <div class="tab-panel" id="p1" role="tabpanel"> */
.tabs { display: flex; flex-wrap: wrap; gap: var(--s-1); border-bottom: var(--border-w) solid var(--border); margin-bottom: var(--s-4); }
.tabs > [role="tab"], .tabs > a { margin-bottom: -1px; padding: .6em 1em; color: var(--text-mute); font-weight: 600; font-size: var(--fs-sm); text-decoration: none; background: none; border: var(--border-w) solid transparent; border-bottom: 0; border-radius: var(--radius-ctl) var(--radius-ctl) 0 0; cursor: pointer; }
.tabs > [role="tab"]:hover, .tabs > a:hover { color: var(--text); background: var(--surface); }
.tabs > [aria-selected="true"], .tabs > a[aria-current="page"] { color: var(--brand-strong); background: var(--bg); border-color: var(--border); border-bottom: 1px solid var(--bg); }
.tab-panel[hidden] { display: none; }

/* Pagination: <nav class="pagination"><a>…</a><span aria-current="page">3</span> */
.pagination { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.pagination :where(a, span) { display: inline-grid; place-items: center; min-width: 2.2rem; height: 2.2rem; padding: 0 .6rem; border: var(--border-w) solid var(--border); border-radius: var(--radius-ctl); color: var(--text); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.pagination a:hover { background: var(--brand-soft); }
.pagination [aria-current="page"] { background: var(--btn-bg); color: var(--on-brand); border-color: transparent; }
.pagination .disabled { opacity: .45; pointer-events: none; }
}

/* ---- 34-menus.css ---- */
@layer ds.components {
/* menus: dropdown and accordion built on native <details>, so they work without JavaScript.
   ds.js adds close-on-outside-click, Escape and item click.
   <details class="dropdown"><summary class="btn btn--secondary">Menu</summary>
     <div class="dropdown__menu"><a href="…">Item</a><hr><button type="button">Action</button></div></details> */

.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; display: inline-flex; align-items: center; gap: .5em; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown > summary::after { content: ""; width: .4em; height: .4em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; rotate: 45deg; translate: 0 -.1em; }
.dropdown[open] > summary::after { rotate: 225deg; translate: 0 .1em; }
.dropdown__menu {
  position: absolute; z-index: 40; top: calc(100% + .35rem); left: 0; min-width: 12rem; max-height: 70vh; overflow-y: auto; padding: .35rem;
  background: var(--bg); border: var(--border-w) solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.dropdown--end .dropdown__menu { left: auto; right: 0; }
.dropdown__menu :where(a, button) { display: block; width: 100%; padding: .5em .75em; text-align: left; font: inherit; font-size: var(--fs-sm); font-weight: 550; color: var(--text); background: none; border: 0; border-radius: var(--radius-sm); text-decoration: none; cursor: pointer; }
.dropdown__menu :where(a, button):hover { background: var(--brand-soft); }
.dropdown__menu :where(a, button)[aria-current="true"], .dropdown__menu .active { color: var(--brand-strong); background: var(--brand-soft); }
.dropdown__menu :where(a, button).danger { color: var(--bad); }
.dropdown__menu hr { margin: .3rem 0; }
.dropdown__menu .dropdown__label { padding: .4em .75em; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--text-mute); }

/* Inside the top nav, a dropdown's summary looks like the other links */
.nav .dropdown > summary { display: inline-flex; }
@media (max-width: 48rem) {
  .nav .dropdown { display: block; }
  .nav .dropdown__menu { position: static; box-shadow: none; border: 0; padding: 0 0 0 .8rem; background: none; }
}

/* Accordion: <details class="accordion"><summary>Title</summary><div class="accordion__body">…</div></details> */
.accordion { border: var(--border-w) solid var(--border); border-radius: var(--radius-ctl); background: var(--bg); }
.accordion + .accordion { margin-top: var(--s-2); }
.accordion > summary { padding: var(--s-3) var(--s-4); font-weight: 650; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::after { content: ""; width: .5em; height: .5em; flex: none; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; rotate: 45deg; transition: rotate .2s; }
.accordion[open] > summary::after { rotate: 225deg; }
.accordion[open] > summary { border-bottom: var(--border-w) solid var(--border); }
.accordion__body { padding: var(--s-4); }
@media (prefers-reduced-motion: reduce) { .accordion > summary::after { transition: none; } }
}

/* ---- 35-feedback.css ---- */
@layer ds.components {
/* feedback: alerts, badges, status indicators, toasts, progress, spinner, empty states.
   Status modifiers everywhere: --ok  --warn  --bad  --info  --off */

/* Alert: <div class="alert alert--bad" role="alert"><strong>Title</strong> Text <button class="alert__close" data-ds-dismiss aria-label="Dismiss">×</button></div> */
.alert { --tone: var(--info); --tone-soft: var(--info-soft); position: relative; display: block; padding: var(--s-3) var(--s-4); margin-bottom: var(--s-4);
  color: var(--text); background: var(--tone-soft); border: var(--border-w) solid color-mix(in oklab, var(--tone) 35%, transparent); border-left: 4px solid var(--tone); border-radius: var(--radius-ctl); }
.alert > :last-child { margin-bottom: 0; }
.alert strong:first-child { color: var(--tone); }
.alert--ok { --tone: var(--ok); --tone-soft: var(--ok-soft); }
.alert--warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.alert--bad { --tone: var(--bad); --tone-soft: var(--bad-soft); }
.alert--off, .alert--light { --tone: var(--off); --tone-soft: var(--off-soft); }
.alert__close { position: absolute; top: .4rem; right: .6rem; padding: .1em .4em; font-size: 1.3em; line-height: 1; color: var(--text-mute); background: none; border: 0; cursor: pointer; border-radius: var(--radius-sm); }
.alert__close:hover { color: var(--text); background: color-mix(in oklch, var(--text) 8%, transparent); }
.alert:has(.alert__close) { padding-right: 2.6rem; }

/* Badge: small label. Pill: status with a dot. */
.badge { --tone: var(--brand-strong); display: inline-block; padding: .15em .6em; font-size: var(--fs-xs); font-weight: 650; line-height: 1.5; color: var(--tone);
  background: color-mix(in oklab, var(--tone) 14%, var(--bg)); border: var(--border-w) solid color-mix(in oklab, var(--tone) 30%, transparent); border-radius: 999px; white-space: nowrap; }
.badge--ok { --tone: var(--ok); } .badge--warn { --tone: var(--warn); } .badge--bad { --tone: var(--bad); } .badge--info { --tone: var(--info); } .badge--off { --tone: var(--off); }
.badge--solid { color: var(--on-brand); background: var(--tone); border-color: transparent; }

.status { --tone: var(--off); display: inline-flex; align-items: center; gap: .5em; font-weight: 600; color: var(--text); white-space: nowrap; }
.status::before { content: ""; width: .65em; height: .65em; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 .2em color-mix(in oklab, var(--tone) 22%, transparent); }
.status--ok { --tone: var(--ok); } .status--warn { --tone: var(--warn); } .status--bad { --tone: var(--bad); } .status--info { --tone: var(--info); } .status--off { --tone: var(--off); }
/* status text colour: for links/values that should read as up/down/etc. */
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-bad { color: var(--bad); } .text-info { color: var(--info); } .text-off { color: var(--off); }
.text-ok a, .text-warn a, .text-bad a, .text-info a, .text-off a { color: inherit; }

/* Toast: ds.toast("Saved", {type:"ok"}) creates these inside .toasts */
.toasts { position: fixed; z-index: 90; right: var(--s-4); bottom: var(--s-4); display: grid; gap: var(--s-2); width: min(24rem, calc(100vw - 2rem)); }
.toast { --tone: var(--info); display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--surface); color: var(--text);
  border: var(--border-w) solid var(--border); border-left: 4px solid var(--tone); border-radius: var(--radius-ctl); box-shadow: var(--shadow-lg); animation: toast-in .25s ease both; }
.toast--ok { --tone: var(--ok); } .toast--warn { --tone: var(--warn); } .toast--bad { --tone: var(--bad); }
.toast .alert__close { position: static; margin-left: auto; }
@keyframes toast-in { from { opacity: 0; translate: 0 .75rem; } to { opacity: 1; translate: 0 0; } }

/* Progress and spinner */
.progress { height: .6rem; overflow: hidden; background: var(--surface-2); border-radius: 999px; }
.progress > span, .progress > div { display: block; height: 100%; width: var(--value, 0%); background: var(--brand); border-radius: inherit; transition: width .3s; }
.spinner { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -.2em; border: .18em solid color-mix(in oklch, var(--text) 18%, transparent); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

/* Empty state */
.empty { padding: var(--s-7) var(--s-4); text-align: center; color: var(--text-mute); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty h3 { color: var(--text); }

@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .spinner { animation-duration: 2s; } .progress > span, .progress > div { transition: none; } }
}

/* ---- 36-surfaces.css ---- */
@layer ds.components {
/* surfaces: card, panel, stat tile, list group, modal dialog (native <dialog>) */

.card { position: relative; background: var(--bg); border: var(--border-w) solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; }
.card__head, .card__body, .card__foot { padding: var(--s-4) var(--s-5); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); font-weight: 650; background: var(--surface); border-bottom: var(--border-w) solid var(--border); }
.card__foot { background: var(--surface); border-top: var(--border-w) solid var(--border); }
.card__body > :last-child { margin-bottom: 0; }
.card--accent::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--brand), transparent 80%); }
.card--interactive { transition: transform .2s ease, box-shadow .2s ease; }
.card--interactive:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card--flush .card__body { padding: 0; }

/* Plain bordered block, no shadow */
.panel { padding: var(--s-4) var(--s-5); background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius); }

/* Stat tile: <div class="stat"><span class="stat__label">Uptime</span><b class="stat__value">99.9%</b><span class="stat__note">last 30 days</span></div> */
.stat { display: grid; gap: .15rem; padding: var(--s-4) var(--s-5); background: var(--bg); border: var(--border-w) solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat__label { font-size: var(--fs-xs); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-mute); }
.stat__value { font-size: 1.9em; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat__note { font-size: var(--fs-sm); color: var(--text-mute); }
.stat--ok .stat__value { color: var(--ok); } .stat--warn .stat__value { color: var(--warn); } .stat--bad .stat__value { color: var(--bad); }

/* List group: <ul class="list"><li>…</li></ul> or links */
.list { list-style: none; margin: 0 0 1em; padding: 0; border: var(--border-w) solid var(--border); border-radius: var(--radius-ctl); overflow: hidden; background: var(--bg); }
.list > li, .list > a { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); color: var(--text); text-decoration: none; }
.list > * + * { border-top: var(--border-w) solid var(--border); }
.list > a:hover { background: var(--brand-soft); }

/* Modal: <dialog class="modal" id="m1"><form method="dialog"><div class="modal__head"><h2>Title</h2><button class="alert__close" data-ds-close aria-label="Close">×</button></div>
   <div class="modal__body">…</div><div class="modal__foot"><button class="btn btn--ghost" data-ds-close>Cancel</button><button class="btn">Save</button></div></form></dialog>
   Open with <button data-ds-open="#m1">. Do not nest the dialog in the ASP.NET form's postback region if it holds server controls: put it inside <form runat="server">. */
dialog.modal { width: min(36rem, calc(100vw - 2rem)); max-height: calc(100dvh - 3rem); padding: 0; color: var(--text); background: var(--bg); border: var(--border-w) solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in .2s ease both; }
dialog.modal::backdrop { background: oklch(0.12 0.03 var(--hue) / .6); backdrop-filter: blur(2px); }
dialog.modal > form, dialog.modal > .modal__inner { display: flex; flex-direction: column; min-height: 0; margin: 0; }
.modal--lg { width: min(56rem, calc(100vw - 2rem)); }
.modal--sm { width: min(26rem, calc(100vw - 2rem)); }
.modal__head { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: var(--border-w) solid var(--border); }
.modal__head h2, .modal__head h3 { margin: 0; font-size: 1.15em; }
.modal__head .alert__close { position: static; }
.modal__body { padding: var(--s-5); overflow-y: auto; }
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-5); background: var(--surface); border-top: var(--border-w) solid var(--border); }
@keyframes modal-in { from { opacity: 0; translate: 0 1rem; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { dialog.modal[open] { animation: none; } .card--interactive { transition: none; } .card--interactive:hover { transform: none; } }
}

/* ---- 40-motion.css ---- */
@layer ds.extras {
/* motion (opt-in): scroll-triggered reveal. Scrolling a wrapper into view flips --in-view (a scroll-driven animation),
   which starts each child's timed fade-and-lift, staggered by --stagger. Runs once. Needs animation-timeline: view();
   elsewhere, and with reduced motion, content is simply shown.
     cards: <div class="reveal-item"><div class="card">…</div></div>   lists: <ul class="reveal-list"><li>…</li></ul>
   Marketing pages use this; app screens normally should not. */

.reveal-item { display: grid; }
@keyframes in-view { from { --in-view: false; } to { --in-view: true; } }
@keyframes rise-in { from { opacity: 0; translate: 0 var(--rise, 3rem); } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .reveal-item, .reveal-list { --in-view: false; animation: in-view linear both; animation-timeline: view(); animation-range: entry entry 40%; }
    .reveal-list { --rise: 1.5rem; }
    .reveal-item > *, .reveal-list > * { animation: rise-in .9s ease both paused; animation-delay: calc(var(--stagger, 0) * .15s); }
    @container style(--in-view: true) { .reveal-item > *, .reveal-list > * { animation-play-state: running; } }
  }
}
.reveal-list > :nth-child(2) { --stagger: 1; } .reveal-list > :nth-child(3) { --stagger: 2; } .reveal-list > :nth-child(4) { --stagger: 3; }
.reveal-list > :nth-child(5) { --stagger: 4; } .reveal-list > :nth-child(6) { --stagger: 5; }
}
