/*
 * ica-hub admin design system.
 * Direction: a calm household tool, phone first. Sage-tinted paper, white surfaces with hairline borders, one basil-green
 * accent reserved for the brand mark, the active tab and primary actions. Flat by default; only floating layers
 * (dialog, toast, bottom bar) get a shadow. System fonts only.
 */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --color-bg: #f3f6f1;
  --color-surface: #ffffff;
  --color-surface-2: #e8ede5;
  --color-border: #d2dacd;
  --color-border-strong: #7f8c84;
  --color-text: #17231d;
  --color-text-muted: #55635b;
  --color-accent: #1f5c46;
  --color-accent-contrast: #ffffff;
  --color-accent-soft: #dcebe2;
  --color-ok: #1d6b3a;
  --color-ok-surface: #e1f1e5;
  --color-warn: #7d5200;
  --color-warn-surface: #fbf0d4;
  --color-bad: #a3241d;
  --color-bad-surface: #fbe5e2;
  --color-focus: #2b5fd9;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.875rem;
  --leading: 1.5;

  --shadow-1: 0 1px 2px rgb(23 35 29 / 0.06), 0 2px 8px rgb(23 35 29 / 0.06);
  --shadow-2: 0 8px 28px rgb(23 35 29 / 0.16), 0 2px 6px rgb(23 35 29 / 0.08);

  --tap: 44px;
  --shell-max: 46rem;
  --sidebar-w: 0px;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-bg: #121915;
    --color-surface: #1a231e;
    --color-surface-2: #232e28;
    --color-border: #33423a;
    --color-border-strong: #6a7b71;
    --color-text: #e5ece7;
    --color-text-muted: #a3b1a9;
    --color-accent: #7cc9a3;
    --color-accent-contrast: #0e2519;
    --color-accent-soft: #1f3a2d;
    --color-ok: #86d09c;
    --color-ok-surface: #173222;
    --color-warn: #e8bf62;
    --color-warn-surface: #372b10;
    --color-bad: #f29a90;
    --color-bad-surface: #3d1b18;
    --color-focus: #8fb2ff;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 10px 30px rgb(0 0 0 / 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #121915;
  --color-surface: #1a231e;
  --color-surface-2: #232e28;
  --color-border: #33423a;
  --color-border-strong: #6a7b71;
  --color-text: #e5ece7;
  --color-text-muted: #a3b1a9;
  --color-accent: #7cc9a3;
  --color-accent-contrast: #0e2519;
  --color-accent-soft: #1f3a2d;
  --color-ok: #86d09c;
  --color-ok-surface: #173222;
  --color-warn: #e8bf62;
  --color-warn-surface: #372b10;
  --color-bad: #f29a90;
  --color-bad-surface: #3d1b18;
  --color-focus: #8fb2ff;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 10px 30px rgb(0 0 0 / 0.55);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h2 { font-size: var(--text-lg); font-weight: 650; }
h3 { font-size: var(--text-base); font-weight: 650; }
p, ul, ol, dl, pre { margin: 0; }
ul, ol { padding-left: 1.25rem; }
li + li { margin-top: var(--space-1); }
a { color: var(--color-accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
strong { font-weight: 650; }
code, pre { font-family: var(--font-mono); font-size: 0.85em; }
code { overflow-wrap: anywhere; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-xs); color: var(--color-text-muted); }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.icon { width: 22px; height: 22px; flex: none; }

/* ---------- Utilities ---------- */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack > * { margin: 0; }
/* An empty live region (the password strength line before typing) takes no gap; it stays rendered so it is announced. */
.stack > .field-hint:empty { margin-top: calc(-1 * var(--space-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.muted { color: var(--color-text-muted); }
.wrap-anywhere { overflow-wrap: anywhere; min-width: 0; }
/* A text link that stands on its own line (not inside a sentence): a full 44 px tap target. */
.tap-link { display: inline-flex; align-items: center; min-height: var(--tap); }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.visually-hidden:not(:focus):not(:focus-within) {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip:focus {
  position: fixed; z-index: 100; top: var(--space-2); left: var(--space-2);
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-4);
  background: var(--color-surface); color: var(--color-text); border-radius: var(--radius-md); box-shadow: var(--shadow-2);
}

/* ---------- App shell (phone first) ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 56px;
  padding: env(safe-area-inset-top) max(var(--space-4), env(safe-area-inset-right)) 0 max(var(--space-4), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--tap);
  color: var(--color-text); text-decoration: none;
  font-weight: 700; font-size: var(--text-lg); letter-spacing: -0.015em;
  white-space: nowrap; flex: none; /* the user menu truncates instead, however long the name */
}
.brand-mark { width: 28px; height: 28px; flex: none; }

.usermenu {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: var(--tap); max-width: min(55vw, 18rem);
  padding: 0 var(--space-3) 0 var(--space-2);
  border-radius: var(--radius-pill);
  color: var(--color-text); text-decoration: none; font-size: var(--text-sm); font-weight: 550;
}
.usermenu:hover, .usermenu[aria-current="page"] { background: var(--color-surface-2); }
.topbar-end { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
/* Admins' Settings: in the top bar on phones (six bottom tabs are too tight), a nav item from 768 px. */
.topbar-settings {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--tap); height: var(--tap); border-radius: var(--radius-pill); color: var(--color-text-muted);
}
.topbar-settings:hover, .topbar-settings[aria-current="page"] { background: var(--color-surface-2); color: var(--color-text); }
.topbar-settings[aria-current="page"] { color: var(--color-accent); }
.topbar-settings .icon { width: 22px; height: 22px; }
.nav-item--settings { display: none; }

/* Bottom tab bar below 768 px */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 12px rgb(23 35 29 / 0.05);
}
.nav-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabbar-h); min-width: var(--tap);
  padding: var(--space-1) var(--space-1) var(--space-2);
  color: var(--color-text-muted); text-decoration: none;
  font-size: var(--text-xs); font-weight: 550; line-height: 1.1;
}
.nav-item::before {
  content: ""; position: absolute; top: 0; left: 50%;
  width: 28px; height: 3px; margin-left: -14px;
  border-radius: 0 0 3px 3px; background: transparent;
}
.nav-item:hover { color: var(--color-text); }
.nav-item[aria-current="page"] { color: var(--color-accent); font-weight: 650; }
.nav-item[aria-current="page"]::before { background: var(--color-accent); }
.nav-item .icon { width: 24px; height: 24px; }

.main {
  width: 100%; max-width: var(--shell-max); min-width: 0;
  margin: 0 auto;
  padding: var(--space-6) max(var(--space-4), env(safe-area-inset-right)) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-8)) max(var(--space-4), env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: var(--space-5);
  flex: 1 0 auto; /* fills the shell's height, so the footer's margin-top: auto pins it to the bottom of short pages */
}
.main--wide { max-width: 72rem; }

.page-title { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }

/* Icon rail from 768 px, full sidebar from 960 px */
@media (min-width: 768px) {
  :root { --sidebar-w: 92px; }
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .topbar { grid-column: 1 / -1; }
  .nav {
    position: sticky; top: 57px; inset: auto;
    grid-row: 2; align-self: start;
    grid-auto-flow: row; grid-auto-columns: auto; align-content: start; gap: var(--space-1);
    height: calc(100dvh - 57px);
    padding: var(--space-4) var(--space-2);
    background: transparent; border-top: 0; border-right: 1px solid var(--color-border); box-shadow: none;
  }
  .nav-item { min-height: 64px; border-radius: var(--radius-md); }
  .nav-item::before { display: none; }
  .nav-item[aria-current="page"] { background: var(--color-accent-soft); }
  .main { grid-row: 2; grid-column: 2; padding-bottom: var(--space-8); padding-top: var(--space-7); }
  .nav-item--settings { display: flex; }
  .topbar-settings { display: none; }
}

@media (min-width: 960px) {
  :root { --sidebar-w: 232px; }
  .nav { padding: var(--space-5) var(--space-3); }
  .nav-item {
    flex-direction: row; justify-content: flex-start; gap: var(--space-3);
    min-height: var(--tap); padding: 0 var(--space-3);
    font-size: var(--text-sm);
  }
  .nav-item .icon { width: 22px; height: 22px; }
  .main { padding-left: var(--space-8); padding-right: var(--space-8); margin: 0; }
}

/* ---------- Bare layout (sign-in, consent, invite, errors) ---------- */
.bare {
  min-height: 100dvh;
  display: grid; place-items: center; grid-template-rows: 1fr auto; gap: var(--space-5);
  padding: max(var(--space-6), env(safe-area-inset-top)) var(--space-4) max(var(--space-6), env(safe-area-inset-bottom));
}
.bare-card { width: min(100%, 27rem); padding: var(--space-6); gap: var(--space-5); }
.bare-card > .brand { font-size: var(--text-base); min-height: 0; }
.bare-card .page-title { font-size: var(--text-xl); }
.bare-card form .btn { width: 100%; }
.bare-card form.cluster .btn { width: auto; flex: 1 1 8rem; }
.divider {
  display: flex; align-items: center; gap: var(--space-3);
  color: var(--color-text-muted); font-size: var(--text-sm); text-align: center;
}
.divider::before, .divider::after { content: ""; flex: 1 1 0; border-top: 1px solid var(--color-border); }

/* ---------- Cards ---------- */
.grid-cards { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
.card {
  display: flex; flex-direction: column; gap: var(--space-4);
  min-width: 0;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.card-footer { display: flex; flex-wrap: wrap; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.card--warn { background: var(--color-warn-surface); border-color: color-mix(in srgb, var(--color-warn) 35%, transparent); }
.card--bad { background: var(--color-bad-surface); border-color: color-mix(in srgb, var(--color-bad) 35%, transparent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: var(--space-2) var(--space-5); /* block padding only shows when a long label wraps */
  border: 1px solid transparent; border-radius: var(--radius-md); text-align: center;
  font: inherit; font-size: var(--text-base); font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn-primary { background: var(--color-accent); color: var(--color-accent-contrast); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 88%, var(--color-text)); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-2); }
.btn-danger { background: var(--color-bad-surface); color: var(--color-bad); border-color: color-mix(in srgb, var(--color-bad) 45%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--color-bad-surface) 80%, var(--color-bad)); }
.btn-link { background: none; border-color: transparent; color: var(--color-accent); padding: 0 var(--space-2); text-decoration: underline; text-underline-offset: 0.18em; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* copy buttons exist only once app.js runs */
[data-copy] { display: none; }
.js [data-copy] { display: inline-flex; }
[data-copy][data-copied]::after { content: "✓"; color: var(--color-ok); font-weight: 700; }
.js [data-nojs] { display: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 650; line-height: 1.5; white-space: nowrap;
}
.badge--ok { background: var(--color-ok-surface); color: var(--color-ok); }
.badge--warn { background: var(--color-warn-surface); color: var(--color-warn); }
.badge--bad { background: var(--color-bad-surface); color: var(--color-bad); }
.badge--neutral { background: var(--color-surface-2); color: var(--color-text-muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge--neutral::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.badge[title] { cursor: help; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field > label, legend { font-size: var(--text-sm); font-weight: 600; }
input:not([type="hidden"], [type="radio"], [type="checkbox"]), select, textarea {
  width: 100%; min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  font: inherit; font-size: max(16px, var(--text-base));
}
input:not([type="hidden"], [type="radio"], [type="checkbox"]):hover, select:hover, textarea:hover { border-color: var(--color-text); }
input[aria-invalid="true"] { border-color: var(--color-bad); }
.field-hint { font-size: var(--text-sm); color: var(--color-text-muted); overflow-wrap: anywhere; }
.field-error, .err { color: var(--color-bad); }
.field-error { font-size: var(--text-sm); font-weight: 550; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
/* A checkbox with its label: the whole row is a 44 px tap target. */
.check { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); }
.check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--color-accent); }
.check label { font-weight: 550; cursor: pointer; }

/* Segmented radio group (theme) */
.segmented { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.segmented legend { width: 100%; margin-bottom: var(--space-2); }
.segment {
  position: relative; flex: 1 1 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 var(--space-3);
  background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 550; cursor: pointer;
}
.segment input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segment:has(input:checked) { background: var(--color-accent-soft); border-color: var(--color-accent); color: var(--color-text); }
.segment:has(input:focus-visible) { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.theme-form { display: flex; flex-direction: column; gap: var(--space-3); }

/* ---------- Toasts (flash after POST) ---------- */
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); border: 1px solid var(--color-border);
  background: var(--color-surface); box-shadow: var(--shadow-1);
  font-weight: 550;
}
.toast--success { background: var(--color-ok-surface); color: var(--color-ok); border-color: color-mix(in srgb, var(--color-ok) 30%, transparent); }
.toast--error { background: var(--color-bad-surface); color: var(--color-bad); border-color: color-mix(in srgb, var(--color-bad) 30%, transparent); }
.toast--info { background: var(--color-surface-2); color: var(--color-text); }

/* ---------- Empty states ---------- */
.empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-6);
  border: 1px dashed var(--color-border); border-radius: var(--radius-lg);
  color: var(--color-text-muted);
}
.empty h2 { color: var(--color-text); }

/* ---------- Tables (stacked cards below 640 px) ---------- */
.table-wrap { min-width: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table caption { text-align: left; padding-bottom: var(--space-2); color: var(--color-text-muted); font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 600; color: var(--color-text-muted); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); }
.table td { padding: var(--space-3); vertical-align: top; border-bottom: 1px solid var(--color-border); overflow-wrap: break-word; }
.table td.wrap-anywhere { overflow-wrap: anywhere; }
.table time { white-space: nowrap; }

@media (max-width: 639.98px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    margin-bottom: var(--space-3); padding: var(--space-2) var(--space-4);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  }
  .table td { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: var(--space-3); padding: var(--space-2) 0; }
  .table tr td:last-child { border-bottom: 0; }
  .table td::before { content: attr(data-label); font-weight: 600; color: var(--color-text-muted); }
}

/* ---------- Page-specific pieces ---------- */
.qr { display: flex; justify-content: flex-start; }
.qr img {
  width: 16rem; max-width: 100%; height: auto; aspect-ratio: 1;
  padding: var(--space-3); background: #ffffff; border: 1px solid var(--color-border); border-radius: var(--radius-lg);
}
.qr img:not([src]) { background: var(--color-surface-2); }
/* The invite QR: an inline SVG (black on white whatever the theme, so every camera reads it), framed like a till receipt. */
figure.qr { margin: 0; }
figure.qr svg {
  display: block; width: 15rem; max-width: 100%; height: auto; aspect-ratio: 1;
  padding: var(--space-3); background: #ffffff; border: 2px solid var(--color-accent); border-radius: var(--radius-lg);
}
.invite-link { font-family: var(--font-mono); font-size: var(--text-sm); }
.invite-email { font-size: var(--text-lg); }
.invite-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.invite-form .field:first-of-type { flex: 1 1 14rem; }
.invite-form select { min-height: var(--tap); }
.invite-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--color-border); }
.invite-row:first-child { border-top: 0; }

.dest {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2); border: 2px solid var(--color-border); border-radius: var(--radius-md);
  font-size: var(--text-lg);
}

.checklist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.checklist li { display: flex; align-items: flex-start; gap: var(--space-3); margin: 0; }
.checklist .icon { color: var(--color-border-strong); margin-top: 1px; }
.checklist [data-done] { color: var(--color-text-muted); }
.checklist [data-done] .icon { color: var(--color-ok); }
.checklist a { font-weight: 600; }
.check-results .checklist .badge { flex: none; min-width: 5.5rem; }

/* Home: the MCP URL to paste into Claude */
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.copy-row code {
  flex: 1 1 14rem; min-width: 0; padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2); border-radius: var(--radius-sm); font-size: var(--text-sm);
}
.device { padding-top: var(--space-5); border-top: 1px solid var(--color-border); }
.theme-form { max-width: 28rem; }

/* Consent */
.consent-who { display: flex; flex-direction: column; gap: var(--space-1); }
.consent-client { font-size: var(--text-xl); letter-spacing: -0.015em; }
.scopes-label { font-weight: 600; }
.scopes { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.scopes li { display: flex; align-items: flex-start; gap: var(--space-3); margin: 0; }
.scopes .icon { color: var(--color-ok); margin-top: 1px; }
.scopes li:has(code) .icon { color: var(--color-warn); }
.actions .btn { min-height: var(--tap); }
.small { font-size: var(--text-sm); }

/* A warning/problem banner: icon beside the text */
.callout { flex-direction: row; align-items: flex-start; gap: var(--space-3); padding: var(--space-4); }
.card--warn.callout .icon { color: var(--color-warn); }
.card--bad.callout .icon { color: var(--color-bad); }

/* ICA connect */
.status-line { font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); }
.filters .field { flex: 1 1 10rem; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }

.kv { display: grid; grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr); gap: var(--space-2) var(--space-4); margin: 0; }
.kv dt { color: var(--color-text-muted); font-size: var(--text-sm); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- ICA-MCP branding: mascot, playful lines, disclaimer footer ----------
 * The mascot is the one loud element; everything around it stays in the calm palette. Its SVG carries its own
 * fixed colours (light body, dark outline), readable on both themes. Playful lines are Swedish and set lang="sv".
 */
.mascot { display: block; flex: none; width: auto; height: 96px; }
.mascot--sm { height: 64px; }
.mascot--lg { height: 120px; }

.quip { font-size: var(--text-lg); font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; color: var(--color-text); text-wrap: balance; }

.hero { display: flex; align-items: center; gap: var(--space-4); }
.hero-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.hero .brand { font-size: var(--text-xl); min-height: 0; }
.tagline { color: var(--color-text-muted); font-size: var(--text-sm); }

.error-art { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }

.empty--art { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-5); border-style: solid; background: var(--color-surface); }
.empty-text { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); flex: 1 1 14rem; min-width: 0; }
.empty--art h2 { font-size: var(--text-xl); letter-spacing: -0.015em; }

.mascot-note { display: flex; align-items: center; gap: var(--space-3); }
.mascot-note .quip { font-size: var(--text-base); }

.page-head { display: flex; flex-direction: column; gap: var(--space-1); }
.page-subtitle { color: var(--color-text-muted); font-size: var(--text-lg); font-weight: 550; }

.site-footer { color: var(--color-text-muted); font-size: var(--text-xs); line-height: 1.5; }
.site-footer a { color: inherit; white-space: nowrap; }
.main > .site-footer { margin-top: auto; padding-top: var(--space-5); border-top: 1px solid var(--color-border); }
.bare > .site-footer { width: min(100%, 27rem); text-align: center; }

/* ---------- Confirm dialog ---------- */
dialog {
  width: min(calc(100% - 2 * var(--space-4)), 24rem);
  padding: var(--space-6);
  color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
}
dialog:not([open]) { display: none; }
dialog::backdrop { background: rgb(10 18 14 / 0.45); }
dialog .cluster { justify-content: flex-end; }

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

/* ---------- Users: one card per household member ---------- */
.user-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.user-list > li { margin: 0; }
.user h2 { font-size: var(--text-lg); }
.user-controls { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.role-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.role-form label { font-weight: 600; }
.role-form select { flex: 1 1 8rem; min-width: 0; max-width: 14rem; min-height: var(--tap); }
.user-actions .btn { min-height: var(--tap); }
.plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.plain-list li { margin: 0; }
@media (min-width: 960px) {
  .user-list { grid-template-columns: repeat(auto-fill, minmax(24rem, 1fr)); }
}

/* ---------- Profile & security ---------- */
.profile-id h2 { font-size: var(--text-xl); letter-spacing: -0.015em; }
.session-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.session-list > li { margin: 0; display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4) 0; border-top: 1px solid var(--color-border); }
.session-list > li:first-child { border-top: 0; padding-top: 0; }
.session-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.session-head h3 { font-size: var(--text-base); font-weight: 650; min-width: 0; }
.session .btn, .card-footer .btn { min-height: var(--tap); }
