﻿:root {
  color-scheme: light;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --bg: #f6f8fc;
  --paper: #fff;
  --ink: #172b43;
  --muted: #4c6078;
  --line: #d4dfe9;
  --soft: #edf3fa;
  --nav: #eaf0f7;
  --nav-selected: #dce9f8;
  --lift: 0 1px 2px #1025400b, 0 8px 28px #10254008;
  --blue: #1765ad;
  --action: #1765ad;
  --action-hover: #11538f;
  --success: #176044;
  --danger: #a52f36;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101b2b;
  --paper: #17283d;
  --ink: #eff5ff;
  --muted: #b5c6db;
  --line: #3b516a;
  --soft: #203750;
  --nav: #15263c;
  --nav-selected: #24456a;
  --lift: 0 1px 2px #0003, 0 8px 28px #0002;
  --blue: #90c5ff;
  --action: #2065a7;
  --action-hover: #17538e;
  --success: #a4e2c7;
  --danger: #ffb4bf;
}

html[data-theme="sand"] {
  color-scheme: light;
  --bg: #f7f3ec;
  --paper: #fffdf8;
  --ink: #382d26;
  --muted: #655449;
  --line: #e2d5c5;
  --soft: #f2e9dd;
  --nav: #efe5d8;
  --nav-selected: #ead6c0;
  --lift: 0 1px 2px #51351c0b, 0 8px 28px #51351c08;
  --blue: #854922;
  --action: #874721;
  --action-hover: #6d391b;
  --success: #30623f;
  --danger: #932b37;
}
html[data-theme="slate"] {
  color-scheme: dark;
  --bg: #17191e;
  --paper: #222630;
  --ink: #f0f1f5;
  --muted: #bbbfcf;
  --line: #484e60;
  --soft: #2d3342;
  --nav: #20242c;
  --nav-selected: #38404f;
  --lift: 0 1px 2px #0004, 0 8px 28px #0002;
  --blue: #b8c6ff;
  --action: #555eac;
  --action-hover: #484f94;
  --success: #a9dec4;
  --danger: #ffb4bf;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--blue); text-underline-offset: .18em; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(1.65rem, 1.2rem + 1.7vw, 2.65rem); line-height: 1.15; letter-spacing: -.025em; }
h2 { margin: 0 0 .85rem; font-size: 1.15rem; line-height: 1.3; }
p { margin: 0 0 1rem; }
small { color: var(--muted); }
button, .linkbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: .48rem .85rem; border: 1px solid transparent;
  border-radius: 9px; font-weight: 650; cursor: pointer; text-decoration: none;
}
.primary { background: var(--action); color: #fff; }
.primary:hover { background: var(--action-hover); }
.secondary, .danger { background: var(--paper); color: var(--ink); border-color: var(--line); }
.secondary:hover { background: var(--soft); }
.danger { color: var(--danger); }
.skip { position: absolute; left: -10000px; }
.skip:focus { left: 1rem; top: .5rem; z-index: 10; background: var(--paper); padding: .5rem; }

.top {
  min-height: 68px; display: flex; align-items: center; gap: .75rem;
  padding: .45rem clamp(.65rem, 2.7vw, 2rem); background: var(--paper);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand-link { display: block; min-width: 0; }
.brand { display: block; width: 180px; max-width: 100%; height: 52px; object-fit: contain; object-position: left center; }
.brand-compact, .dark, html:is([data-theme="dark"], [data-theme="slate"]) .light { display: none; }
html:is([data-theme="dark"], [data-theme="slate"]) .dark { display: block; }
.topright { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.theme-anchor { position: relative; }
.theme-picker {
  position: absolute; z-index: 6; inset-inline-end: 0; top: calc(100% + .55rem);
  width: min(245px, calc(100vw - 1.3rem)); padding: .85rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--lift);
}
.theme-picker fieldset { margin: 0; border: 0; padding: 0; }
.theme-picker legend { padding: 0; margin-bottom: .35rem; }
.theme-option {
  display: flex; align-items: center; gap: .6rem; padding: .35rem .45rem;
  min-height: 37px; margin: 0; border-radius: 7px;
}
.theme-option:has(input:checked), .theme-option:hover { background: var(--soft); }
.theme-option input { width: 1rem; height: 1rem; min-height: 0; accent-color: var(--action); padding: 0; margin: 0; }
.theme-swatch { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); }
.theme-swatch.swatch-system { background: linear-gradient(135deg, #eaf0f7 50%, #17283d 50%); }
.theme-swatch.swatch-light { background: #eaf0f7; }
.theme-swatch.swatch-sand { background: #ead6c0; }
.theme-swatch.swatch-dark { background: #24456a; }
.theme-swatch.swatch-slate { background: #38404f; }
.theme-error { color: var(--danger); font-size: .85rem; margin: .5rem 0 0; }
.account { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.account-link { text-decoration: none; }
.account-panels { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,310px),1fr)); gap: 1rem; align-items: start; }
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.shell.collapsed { grid-template-columns: minmax(0, 1fr); }
.shell.collapsed aside { display: none; }
#sidebar {
  position: sticky; top: 81px; align-self: start;
  max-height: calc(100dvh - 94px); overflow-y: auto; overscroll-behavior: contain;
  margin: .85rem 0 .85rem .85rem; padding: .85rem .65rem;
  background: var(--nav); color: var(--ink); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--lift);
}
#sidebar { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 42%, var(--nav)) transparent; }
#sidebar:hover, #sidebar:focus-within { scrollbar-color: var(--muted) transparent; }
@media (forced-colors: active) {
  #sidebar, #sidebar:hover, #sidebar:focus-within { scrollbar-color: auto; }
}
.sidebar-backdrop { display: none; }
.association-label { display: grid; gap: .2rem; overflow-wrap: anywhere; }
.association-label span { color: var(--muted); font-size: .76rem; }
.association-label strong { font-size: .94rem; }
.nav-group { min-width: 0; margin: .25rem 0 0; }
.nav-group-links { display: grid; gap: .15rem; }
.nav-caption {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  min-height: 38px; padding: .4rem .65rem; border-radius: 7px;
  color: var(--ink); font-size: .83rem; font-weight: 700; overflow-wrap: anywhere;
}
.nav-caption::-webkit-details-marker { display: none; }
.nav-caption:hover { background: var(--soft); }
.nav-caption::after {
  content: ""; flex: none; width: 6px; height: 6px;
  border-inline-end: 2px solid var(--muted); border-block-end: 2px solid var(--muted);
  transform: rotate(-45deg);
}
.nav-group[open] > .nav-caption::after { transform: rotate(45deg); }
.nav-group .navitem { margin-inline-start: .3rem; }


aside :focus-visible { outline-color: var(--blue); }
.association { padding: .3rem .35rem 1rem; border-bottom: 1px solid var(--line); }
.association label { color: var(--muted); }
.association .secondary { min-height: 34px; }
aside nav { display: grid; gap: .25rem; margin-top: .9rem; }
.navitem {
  display: flex; min-width: 0; align-items: center; gap: .65rem; padding: .63rem .75rem;
  border-radius: 7px; border-inline-start: 3px solid transparent; color: var(--ink); text-decoration: none;
}
.navitem img { width: 20px; height: 20px; }
.navitem:hover { background: var(--soft); }
.navitem.selected { background: var(--nav-selected); border-inline-start-color: var(--blue); font-weight: 700; }
.edition { margin: 1.25rem .75rem; color: var(--muted); font-size: .82rem; }

.content, .auth { min-width: 0; width: 100%; max-width: 1420px; margin-inline: auto; }
.content { padding: clamp(1rem, 3vw, 2.5rem); }
.auth { max-width: 590px; padding: clamp(1rem, 5vw, 3rem); }
.crumb, .page-intro, footer { color: var(--muted); }
.crumb { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; font-size: .85rem; margin-bottom: .65rem; }
.page-heading { margin-bottom: 1.25rem; }
.page-intro { margin-top: -.55rem; margin-bottom: 1.25rem; }
footer { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: .9rem; font-size: .8rem; }
.panel, .module-card, .metric { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.panel { margin-bottom: 1rem; box-shadow: var(--lift); padding: clamp(.85rem, 2vw, 1.35rem); }
.metrics, .cards { display: grid; gap: .85rem; margin-bottom: 1.45rem; }
.metrics { grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); }
.cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 238px), 1fr)); }
.metric { background: var(--paper); padding: 1rem 1.15rem; color: var(--muted); font-weight: 600; text-decoration: none; box-shadow: var(--lift); }
.metric:hover { border-color: var(--blue); }
.metric strong { display: block; margin-block: .15rem .2rem; color: var(--ink); font-size: 1.95rem; line-height: 1.2; font-variant-numeric: tabular-nums; }

.module-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .55rem;
  padding: .9rem 1rem; border-top: 3px solid var(--accent);
}
.module-heading { display: flex; align-items: center; gap: .6rem; }
.module-icon { width: 36px; height: 36px; object-fit: contain; flex: none; }
.module-card h2, .module-card p { margin: 0; }
.module-card p { color: var(--muted); }
.module-card > form, .module-card > a { margin-top: auto; }
.module-card > form { width: 100%; padding-top: .4rem; }
.status { border-radius: 999px; background: var(--soft); color: var(--muted); font-size: .77rem; font-weight: 700; padding: .18rem .55rem; }
.status.active, .status.required { color: var(--success); }
.status.readonly { color: var(--blue); }
.status.missing_dependency { color: var(--danger); }
.notice, .empty-state { border: 1px solid var(--line); border-inline-start: 3px solid var(--blue); background: var(--soft); padding: .75rem 1rem; border-radius: 7px; }

form { margin: 0; }
form.stack, .fields, .grant-grid, .checkgrid { display: grid; gap: .75rem; }
form.stack > button { justify-self: start; }
.fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr)); margin-bottom: .85rem; }
label { display: grid; align-content: start; gap: .3rem; margin: 0 0 .65rem; font-weight: 600; font-size: .9rem; }
.fields label, form.stack label, .toolbar label { margin-bottom: 0; }
input, select, textarea { min-width: 0; width: 100%; min-height: 40px; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); }
input[type="checkbox"] { width: 1.05rem; min-height: auto; accent-color: var(--action); }
.check { display: flex; align-items: baseline; gap: .5rem; font-weight: 400; }
.grant-grid, .checkgrid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 6px; }
legend { font-weight: 650; }
.toolbar, .toolbar form { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.toolbar { margin-bottom: 1rem; }
.toolbar a:not(.linkbtn) { align-self: center; }
.module-filters { padding: .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: start; padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--soft); font-size: .82rem; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover, tbody tr:focus-within { background: var(--soft); }
td { overflow-wrap: anywhere; }
td form { min-width: 120px; }
td details, td a, td form { margin-block: .25rem; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; }
details { margin: .35rem 0; }
summary { cursor: pointer; font-weight: 650; padding-block: .3rem; }

.hub-workspace { display: grid; gap: 1rem; margin-bottom: 1.45rem; }
.hub-workspace > .panel { margin: 0; }
@media (min-width: 1120px) {
  .hub-workspace:has(> :nth-child(2)) { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; }
}
.hub-actions .toolbar { margin-bottom: 0; }
.hub-events { list-style: none; padding: 0; margin: 0; }
.hub-events li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; border-top: 1px solid var(--line); padding: .7rem 0; }
.hub-events li:last-child { padding-bottom: 0; }
.hub-events a { font-weight: 650; }
.hub-empty { margin-bottom: 0; color: var(--muted); }
.app-shortcuts { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,245px),1fr)); gap: .65rem; }
.app-shortcut { display: flex; align-items: center; gap: .65rem; min-height: 64px; padding: .65rem .85rem;
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--paper); text-decoration: none; }
.app-shortcut:hover { border-color: var(--blue); }
.app-shortcut strong, .app-shortcut small { display: block; }
.app-arrow { margin-inline-start: auto; font-size: 1.4rem; color: var(--blue); }

@media (max-width: 760px) {
  .top { gap: .4rem; }
  .brand { width: 135px; height: 42px; }
  .topright { gap: .3rem; }
  .theme-picker { position: fixed; top: 65px; inset-inline-end: .65rem; }
  .top button, .top .linkbtn { padding-inline: .45rem; font-size: .84rem; }
  .account { display: none; }
  .shell, .shell.collapsed { display: block; }
  #sidebar { position: static; margin-inline: .65rem; }
  .sidebar-ready #sidebar {
    position: fixed; top: 76px; bottom: .65rem; inset-inline-start: .65rem;
    width: min(290px, calc(100% - 1.3rem)); max-height: none; margin: 0; z-index: 4;
  }
  .sidebar-ready:not(.collapsed) .sidebar-backdrop {
    display: block; position: fixed; inset: 68px 0 0; background: #101b2b70; z-index: 3;
  }
  body.sidebar-open { overflow: hidden; }
}
@media (max-width: 370px) {
  .top .brand, html:is([data-theme="dark"], [data-theme="slate"]) .top .brand { display: none; }
  .brand-compact { display: block; width: 34px; height: 34px; object-fit: contain; }
  .toolbar form { width: 100%; }
  .module-filters label { width: 100%; }
}

.list-filters {
  display: grid;
  grid-template-columns: minmax(140px, 1.6fr) repeat(3, minmax(110px, 1fr)) auto;
  align-items: end;
  gap: .65rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.list-filters label { margin: 0; }
.stock-tabs {
  display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .85rem;
  border-bottom: 1px solid var(--line); padding-bottom: .45rem;
}
.stock-tabs a { padding: .4rem .65rem; border-radius: 7px; color: var(--muted); text-decoration: none; }
.stock-tabs a:hover { background: var(--soft); color: var(--ink); }
.stock-tabs a[aria-current] { background: var(--nav-selected); color: var(--ink); font-weight: 700; }
.list-filters button { justify-self: start; }
.list-actions, .list-count, .list-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem 1rem;
}
.list-actions:not(:empty) { margin-bottom: .9rem; }
.list-count, .list-pagination { padding-block: .75rem; color: var(--muted); font-size: .9rem; }
.list-pagination { padding-bottom: 0; }
.record-link { min-height: 34px; padding: .25rem .7rem; white-space: nowrap; }
.record-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.record-toolbar:last-child { margin-bottom: 0; }
.record-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.record-sections > .panel { margin: 0; }
.record-sections + .panel { margin-top: 1rem; }
.record-data { display: grid; gap: .8rem; margin: 0; }
.record-data > div { display: grid; gap: .15rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.record-data dt { color: var(--muted); font-size: .85rem; }
.attendance-form { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.attendance-form label { margin: 0; }
.record-text { white-space: pre-wrap; }
.pos-total { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.pos-total p, .pos-total label { margin: 0; }
.pos-total output { font-weight: 750; font-size: 1.2rem; }
.pos-quantity { width: 6rem; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ticket-output { max-width: 620px; }
.draft-output { max-width: 850px; }
.draft-line-actions { margin: 0; }
.ticket-code { overflow-wrap: anywhere; display: block; padding: .75rem; background: var(--soft); border-radius: 6px; }
.scan-result.scan-error { border-inline-start-color: var(--danger); }
.scan-result.scan-success { border-inline-start-color: var(--success); }
@media print {
  body:has(.ticket-output) :is(.top,#sidebar,.crumb,.page-heading,.record-toolbar,footer,.skip) { display: none; }
  body:has(.ticket-output) .shell { display: block; min-height: 0; }
  body:has(.ticket-output) .content, .ticket-output { color: #000; background: #fff; box-shadow: none; }
  .ticket-output .ticket-code { color: #000; background: #fff; }
  .draft-output.draft-editable :is(th:last-child,td:last-child) { display: none; }
  .draft-output :is(th,.notice) { background: #fff; color: #000; }
}
.site-public {
  background: #f6f8fc; color: #172b43; min-height: 100vh;
}
.site-public > header { padding: 1.2rem max(1rem, calc((100% - 920px) / 2)); background: #102540; }
.site-public > header a { color: #fff; font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.site-public > main { max-width: 920px; padding: clamp(1rem,5vw,2.5rem); margin-inline: auto; }
.site-nav { display: flex; flex-wrap: wrap; gap: .7rem 1.25rem; margin-block: 1rem 2rem; }
.site-nav a { overflow-wrap: anywhere; }
.site-copy { max-width: 75ch; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; }
.record-data dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.record-editor { max-width: 780px; }
.record-context { background: var(--soft); border-radius: 7px; padding: .65rem .85rem; }
.record-context strong { margin-inline-start: .35rem; }
.field-wide { grid-column: 1 / -1; }
.history-back { margin-bottom: 1rem; }
@media (max-width: 700px) {
  .record-sections { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 975px) {
  .list-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 390px) {
  .list-filters { grid-template-columns: minmax(0, 1fr); }
}
