/* The Aarolife admin panel (AD1 stage 1). Colours from bodycheck-app/lib/theme/tokens.dart: teal #007EA3, navy #082C38,
   light background #F3F8F9; Lexend headings, Noto Sans text (self-hosted in fonts/, copied by scripts/vendor-admin.mjs;
   system fonts until then). Light and dark: the system's choice, or the person's (html[data-theme]). Laptop and tablet. */
@font-face { font-family: "Lexend"; src: url("fonts/Lexend-Variable.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url("fonts/NotoSans-Subset.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #F3F8F9; --surface: #FFFFFF; --tint: #E2F5F7; --line: #D2E2E5; --control-line: #6E8C95;
  --ink: #003D52; --muted: #4A6670; --accent-text: #005D7D; --action: #007EA3; --on-action: #FFFFFF;
  --caution: #A84E14; --danger: #B3261E; --ok: #1E7A4F; --chip: #EEF2F3;
  --side: #082C38; --side-ink: #DDEFF2; --side-muted: #8FB3BC; --side-active: #0E4A5C;
  --override: #6B3FA0;
  --radius: 10px; --heading: "Lexend", "Segoe UI", system-ui, sans-serif; --text: "Noto Sans", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #071310; --surface: #0B1D18; --tint: #12333A; --line: #22413A; --control-line: #6F9C95;
    --ink: #EEF8F8; --muted: #9DC4C8; --accent-text: #6CEAF0; --action: #1CCEDC; --on-action: #071310;
    --caution: #F2A46C; --danger: #F2B8B5; --ok: #7FD8A8; --chip: #1B332B;
    --side: #04100D; --side-ink: #DDEFF2; --side-muted: #7FA6A8; --side-active: #12333A; --override: #C9A5F2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #071310; --surface: #0B1D18; --tint: #12333A; --line: #22413A; --control-line: #6F9C95;
  --ink: #EEF8F8; --muted: #9DC4C8; --accent-text: #6CEAF0; --action: #1CCEDC; --on-action: #071310;
  --caution: #F2A46C; --danger: #F2B8B5; --ok: #7FD8A8; --chip: #1B332B;
  --side: #04100D; --side-ink: #DDEFF2; --side-muted: #7FA6A8; --side-active: #12333A; --override: #C9A5F2;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--text); }
h1, h2, h3 { font-family: var(--heading); font-weight: 600; line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; margin-top: 1.4em; }
a { color: var(--accent-text); }
code { font-family: var(--mono); font-size: .9em; }
.wrap { word-break: break-all; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 2rem; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }

/* controls */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--control-line); border-radius: 8px; padding: .45rem .6rem; min-height: 40px; }
button { background: var(--surface); border: 1px solid var(--control-line); border-radius: 8px; padding: .45rem .9rem; min-height: 40px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--action); color: var(--on-action); border-color: var(--action); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button.link { background: none; border: none; color: var(--accent-text); text-decoration: underline; padding: 0; min-height: 0; }
button.wide { width: 100%; justify-content: center; margin-top: .8rem; }
.icon-button { border-color: transparent; background: transparent; padding: .4rem; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field { display: flex; flex-direction: column; gap: .25rem; margin: .7rem 0; font-weight: 500; }
.field.inline { flex-direction: row; align-items: center; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .8rem 0; }
.msg { color: var(--danger); min-height: 1.2em; }
.note { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); }

/* sign-in */
main.narrow { max-width: 440px; margin: 8vh auto; padding: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.auth-brand { display: flex; align-items: center; gap: .6rem; font-family: var(--heading); font-weight: 600; color: var(--accent-text); margin-bottom: 1.4rem; }
.auth-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--side); color: #FFFFFF; }
.secret { font-size: 1.1rem; letter-spacing: .08em; background: var(--chip); padding: .3rem .5rem; border-radius: 6px; }

/* the shell: side menu + top bar + content */
.shell { display: grid; grid-template-columns: auto 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); width: 240px; padding: 1rem .6rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; transition: width .15s; }
.side.collapsed { width: 64px; }
.side.collapsed .menu-label, .side.collapsed .menu-group-label { display: none; }
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--heading); font-weight: 600; padding: .4rem .6rem 1.2rem; }
.menu-group { margin-bottom: 1rem; }
.menu-group-label { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; color: var(--side-muted); margin: 0 .6rem .3rem; }
.menu ul { list-style: none; margin: 0; padding: 0; }
.menu a { display: flex; align-items: center; gap: .7rem; color: var(--side-ink); text-decoration: none; padding: .55rem .6rem; border-radius: 8px; }
.menu a:hover { background: var(--side-active); }
.menu a[aria-current="page"] { background: var(--side-active); font-weight: 600; box-shadow: inset 3px 0 0 #1CCEDC; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: .6rem; padding: .5rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.top .spacer { flex: 1; }
.env.dev { background: var(--caution); color: #FFFFFF; font-weight: 700; font-size: .75rem; border-radius: 6px; padding: .1rem .45rem; }
.who { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.who .role { color: var(--muted); font-size: .85rem; }
main#content { padding: 1.4rem 1.6rem 3rem; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.crumb { margin: 0 0 .4rem; color: var(--muted); }

/* tiles, cards, notices */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin: 1rem 0; }
.tile, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.card { margin: 1rem 0; }
.tile { display: flex; flex-direction: column; gap: .2rem; }
.tile .label { color: var(--muted); font-size: .85rem; }
.tile .value { font-family: var(--heading); font-size: 1.5rem; font-weight: 600; }
.tile .note { font-size: .8rem; }
.notice { border-radius: 8px; padding: .6rem .8rem; margin: .6rem 0; background: var(--tint); }
.notice.ok { border-left: 4px solid var(--ok); }
.notice.error { border-left: 4px solid var(--danger); color: var(--ink); }
.notice.info { border-left: 4px solid var(--action); }
.badge { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .8rem; font-weight: 600; background: var(--chip); }
.badge.ok { color: var(--ok); } .badge.off { color: var(--danger); } .badge.warn { color: var(--caution); }
.badge.override { color: #FFFFFF; background: var(--override); margin-left: .4rem; }
:root[data-theme="dark"] .badge.override { color: #071310; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1.2rem; margin: 1rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.cap-key { display: block; font-family: var(--mono); font-size: .78rem; color: var(--muted); }
tr.overridden td { background: color-mix(in srgb, var(--override) 10%, transparent); }
.invite input { flex: 1; min-width: 280px; font-family: var(--mono); font-size: .85rem; }
.form-grid { max-width: 560px; }
.filters, .range { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin: 1rem 0; }
.filters label, .range label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }
.detail { font-family: var(--mono); font-size: .8rem; color: var(--muted); word-break: break-word; }

/* tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--heading); font-weight: 600; font-size: .85rem; color: var(--muted); background: var(--tint); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--tint) 50%, transparent); }
th .sort { background: none; border: none; padding: 0; min-height: 0; font: inherit; color: inherit; }
th[aria-sort="ascending"] .sort::after { content: " ▲"; } th[aria-sort="descending"] .sort::after { content: " ▼"; }
.table-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .8rem 0; }
.table-search { min-width: 240px; }
.table-pager { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; margin: .5rem 0; color: var(--muted); }
.row-link { font-weight: 600; }

/* charts (charts.js) */
svg.chart { width: 100%; max-width: 900px; height: auto; display: block; }
svg.chart .bar { fill: var(--action); }
svg.chart .grid { stroke: var(--line); }
svg.chart .axis, svg.chart .value { fill: var(--muted); font-size: 12px; font-family: var(--text); }
svg.chart .value { fill: var(--ink); }

/* dialogs */
dialog.dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); max-width: 480px; width: calc(100% - 2rem); padding: 1.4rem; }
dialog.dialog::backdrop { background: rgb(4 16 13 / .55); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* tablet: the menu collapses to icons below 1024 px */
@media (max-width: 1023px) {
  .side { width: 64px; }
  .side .menu-label, .side .menu-group-label { display: none; }
  .side:not(.collapsed) { width: 64px; }
  main#content { padding: 1rem; }
}
@media (max-width: 767px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; width: auto; }
  .who { display: none; }
}

/* AD1 stage 2: the set-up QR code (black on white in both themes, so phones read it), the sign-in hint */
.qr-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.qr-box { background: #FFFFFF; padding: .4rem; border-radius: 8px; border: 1px solid var(--line); }
svg.qr { display: block; width: 200px; height: 200px; }
.hint { font-weight: 400; font-size: .85rem; color: var(--muted); }

/* AD1 stage 3: Settings & switches */
.setting { border-top: 1px solid var(--line); padding: .8rem 0; }
.setting:first-of-type { border-top: none; }
.setting-main { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.setting-main > div:first-child { flex: 1 1 420px; min-width: 0; }
.setting-main p { margin: .2rem 0; }
.setting-meta { font-size: .8rem; color: var(--muted); }
.setting-value { text-align: right; min-width: 160px; }
.setting-value .value { font-family: var(--heading); font-weight: 600; font-size: 1.05rem; }
.setting.read-only .value { color: var(--muted); }
.setting-editor { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .6rem; padding: .6rem; background: var(--tint); border-radius: 8px; }
.chip-check { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .5rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.fixed-rules h3 { font-size: .95rem; margin-top: 1rem; }

/* AD1 stage 4: reports */
.report-tabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: .4rem 0 1rem; }
.report-tabs a { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--surface); }
.report-tabs a[aria-current="page"] { background: var(--action); color: var(--on-action); border-color: var(--action); font-weight: 600; }
.report-filters { display: contents; }
.report-table svg.chart { margin-bottom: .6rem; }
td.hidden-cell { color: var(--muted); font-style: italic; }
tr.total-row td { font-weight: 600; border-top: 2px solid var(--line); }
