/* FactorIA de Apps 5.2 — visual base, with the 262Travel brand applied (docs/BRAND.md is the source of truth).
   Copy it to the app (e.g. public/base.css) and keep the two files identical; what is particular to the app goes in another file.
   Brand: Lexend (self-hosted, see fonts/), Aguamarina #66F1C2, Deep Navy-Black #0D171C, Slate Charcoal #1F292E,
   Icy Off-White #F4F7F8, Pure White #FFFFFF, Sunset Coral #FF7A6A.
   Light and dark (Block 56): every colour is a token with a day value and a night value. The night values are in NIGHT below, written
   twice with the same lines (once for "Same as my device", once for a chosen "Dark"); tests/night-mode.test.js holds them equal and
   checks every pair of text on background at 4.5:1 in both. No rule below the tokens names a colour. */

/* ---------- Lexend, self-hosted (SIL Open Font License, fonts/OFL.txt). Never loaded from another server. ---------- */
@font-face {
  font-family: "Lexend"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/lexend-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Lexend"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/lexend-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;
  /* The brand's six colours */
  --background: #f4f7f8;      /* Icy Off-White: the canvas behind everything */
  --surface: #ffffff;         /* Pure White: cards, fields, panels */
  --text: #0d171c;            /* Deep Navy-Black: headings, data, borders */
  --text-2: #1f292e;          /* Slate Charcoal: body text */
  --accent: #66f1c2;          /* Aguamarina: backgrounds, indicators and focus rings only, never small text on white */
  --danger: #ff7a6a;          /* Sunset Coral: backgrounds, borders and icons, never small text on white */
  /* Derived from them, quiet on purpose */
  --surface-2: #ebf1f3;
  --border: #d3dcdf;          /* edges of cards and dividers */
  --border-strong: #0d171c;   /* edges of fields and buttons */
  --text-3: #4d5c62;          /* secondary notes and placeholders (at least 4.5:1 on white and on the canvas) */
  --accent-strong: #4adcab;   /* aguamarina when pressed or hovered */
  --accent-ink: #0b6e55;      /* the brand's colour as text, links and icons: deep teal by day (6.2:1 on white), aguamarina by night */
  --accent-soft: #dffaf0;
  --on-accent: #0d171c;       /* the text on aguamarina is always dark */
  --danger-strong: #f45f4d;
  --danger-soft: #ffe3df;
  --on-danger: #0d171c;
  --ok: var(--accent);        --ok-soft: #dffaf0;
  --warning: var(--text);     --warning-soft: #e6edf0;
  --info: var(--text);        --info-soft: #ebf1f3;
  --highlight: #b8f8e2;
  /* Design refresh (2026-11-12): a second level of colour, so colour can carry meaning. Ratios in PLAN.md → "Design refresh decisions".
     Deep teal is the brand's colour for text, links, icons and active marks on white (6.2:1 on white, 5.8:1 on the canvas);
     aguamarina and every tint below are backgrounds only, never text. */
  --teal: var(--accent-ink); --teal-strong: #085a46;
  --accent-50: #effdf8; --accent-100: #d9f9ec; --accent-200: #b4f5dd;
  --navy: #0d171c; --navy-2: #16262e; --navy-3: #22343d; /* navy surfaces: the trip header, heroes (aguamarina on navy-2 is 11:1) */
  --coral-50: #fff4f2; --coral-100: #ffe6e1;
  --sun: #ffd166; --sun-100: #fff2c7; --sun-200: #ffe08a; /* the warm accent: backgrounds with navy text, or on navy */
  /* One colour per kind of plan entry: a tint behind a deep icon (each ink is 5.4:1 or more on its tint). */
  --kind-flight-bg: #e4f0fb; --kind-flight: #1d5d99;
  --kind-stay-bg: #d9f9ec; --kind-stay: #0b6e55;
  --kind-transport-bg: #fff2c7; --kind-transport: #7a5200;
  --kind-tour-bg: #d8f1f8; --kind-tour: #0e5c73; /* Review 24 (E8): petrol, not the coral of "To book" and errors (6.4:1) */
  --coral-ink: #a63a2b; /* a deep coral for an icon on its tint (5.4:1 on coral-100): something urgent */
  --danger-ink: var(--coral-ink); /* coral as text: deep by day, light by night */
  --kind-meal-bg: #f1e7f8; --kind-meal: #6a3d8a;
  --kind-other-bg: #e9eef0; --kind-other: #3c4a50;
  /* The dark navigation (sidebar) */
  --nav-bg: #0d171c; --nav-text: #f4f7f8; --nav-text-2: #c5d0d4; --nav-text-3: #9fb0b6; --nav-hover: #1a2a32; --nav-line: #2b3c44; --nav-edge: #5d727b;
  /* Block 56: the pieces that are not a plain colour of the page */
  --island-glow: #0b6e55;     /* the deep teal glow inside a navy band */
  --shade: #0d171c;           /* the colour of every shadow; none by night, where depth is the surface and its edge */
  --scrim: rgb(13 23 28 / .45); /* behind a dialog or an open menu */
  --paper: #ffffff; --on-paper: #0d171c; --on-paper-2: #1f292e; --on-paper-3: #4d5c62; /* the mat around a painting: paper in both modes, with its own ink */
  --tile: #ffffff; --on-tile: #0d171c; /* behind a logo or a square code, which stay as they were made: white in both modes */
  --marker: #66f1c2;          /* the stroke of a highlighter under a headline's words: aguamarina by day, deeper by night so light words read on it */
  --map-dim: none;            /* the map's tiles: as they come by day, dimmed by night (never inverted) */
  --icon-select: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%230d171c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%230d171c' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E");

  --font: "Lexend", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Nothing for reading is under 14px (.875rem); --t-xs (13px) is only for small secondary labels such as counts, group names and the initials in a logo or avatar. */
  --t-xs: .8125rem; --t-s: .875rem; --t-m: .9375rem; --t-l: 1.125rem; --t-xl: 1.375rem; --t-2xl: 1.75rem;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius: 10px; --radius-s: 6px; --radius-l: 14px;
  /* Depth comes from white cards on the off-white canvas, not from shadows. Only things that float get one. */
  --shadow: none;
  --shadow-l: 0 8px 24px color-mix(in srgb, var(--shade) 14%, transparent);
  --ring: 0 0 0 1px var(--text), 0 0 0 4px var(--accent);
  --sidebar: 232px;
}

/* ---------- Night (Block 56). On a screen only: paper is always light. ---------- */
/* "Same as my device": no script and no attribute, the device decides. A chosen "Light" keeps the day values. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
/* NIGHT */
    --background: #0d171c; --surface: #16232a; --surface-2: #1e2e36;
    --text: #f4f7f8; --text-2: #c5d0d4; --text-3: #9fb0b6;
    --border: #2b3d45; --border-strong: #8a9ba1;
    --accent-strong: #8af5d2; --accent-ink: #66f1c2; --teal-strong: #8af5d2;
    --accent-soft: #123b32; --ok-soft: #123b32; --accent-50: #0f2a25; --accent-100: #123b32; --accent-200: #1b5646;
    --danger-strong: #ff8f80; --danger-soft: #3a1c18; --coral-50: #2a1614; --coral-100: #3a1c18; --coral-ink: #ff8f80;
    --warning-soft: #22323a; --info-soft: #1e2e36; --highlight: #17493c;
    --sun-100: #33290f; --sun-200: #5a4716;
    --navy: #0a2a28; --navy-2: #0f3532; --navy-3: #164440;
    --nav-bg: #0a2a28; --nav-hover: #123a37; --nav-line: #245651; --nav-edge: #4f8580;
    --kind-flight-bg: #15283a; --kind-flight: #8cc2f5;
    --kind-stay-bg: #123b32; --kind-stay: #66f1c2;
    --kind-transport-bg: #33290f; --kind-transport: #ffd166;
    --kind-tour-bg: #10303a; --kind-tour: #7fd3ea;
    --kind-meal-bg: #2a1f35; --kind-meal: #d3a8f0;
    --kind-other-bg: #22323a; --kind-other: #c5d0d4;
    --shade: transparent; --scrim: rgb(0 0 0 / .6);
    --shadow-l: 0 0 0 1px var(--border);
    --paper: #efebe2; --marker: #1b7a62;
    --map-dim: brightness(.72) saturate(.85) contrast(1.05);
    --icon-select: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23f4f7f8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23f4f7f8' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E");
/* /NIGHT */
  }
}
/* A chosen "Dark" (public/theme.js sets the attribute before the page paints), whatever the device says. */
@media screen {
  :root[data-theme="dark"] {
/* NIGHT */
    --background: #0d171c; --surface: #16232a; --surface-2: #1e2e36;
    --text: #f4f7f8; --text-2: #c5d0d4; --text-3: #9fb0b6;
    --border: #2b3d45; --border-strong: #8a9ba1;
    --accent-strong: #8af5d2; --accent-ink: #66f1c2; --teal-strong: #8af5d2;
    --accent-soft: #123b32; --ok-soft: #123b32; --accent-50: #0f2a25; --accent-100: #123b32; --accent-200: #1b5646;
    --danger-strong: #ff8f80; --danger-soft: #3a1c18; --coral-50: #2a1614; --coral-100: #3a1c18; --coral-ink: #ff8f80;
    --warning-soft: #22323a; --info-soft: #1e2e36; --highlight: #17493c;
    --sun-100: #33290f; --sun-200: #5a4716;
    --navy: #0a2a28; --navy-2: #0f3532; --navy-3: #164440;
    --nav-bg: #0a2a28; --nav-hover: #123a37; --nav-line: #245651; --nav-edge: #4f8580;
    --kind-flight-bg: #15283a; --kind-flight: #8cc2f5;
    --kind-stay-bg: #123b32; --kind-stay: #66f1c2;
    --kind-transport-bg: #33290f; --kind-transport: #ffd166;
    --kind-tour-bg: #10303a; --kind-tour: #7fd3ea;
    --kind-meal-bg: #2a1f35; --kind-meal: #d3a8f0;
    --kind-other-bg: #22323a; --kind-other: #c5d0d4;
    --shade: transparent; --scrim: rgb(0 0 0 / .6);
    --shadow-l: 0 0 0 1px var(--border);
    --paper: #efebe2; --marker: #1b7a62;
    --map-dim: brightness(.72) saturate(.85) contrast(1.05);
    --icon-select: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23f4f7f8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23f4f7f8' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E");
/* /NIGHT */
  }
}
/* The browser's own parts (date pickers, scroll bars, lists of options) follow the same choice. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media print { :root, :root[data-theme] { color-scheme: light; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--text-2);
  font: 400 var(--t-m)/1.5 var(--font); -webkit-font-smoothing: antialiased;
  /* A phone on its side, with the app on its home screen (viewport-fit=cover): nothing under the notch. env() is 0 elsewhere. */
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
h1, h2 { text-align: left; }
h1 { font-size: var(--t-2xl); } h2 { font-size: var(--t-xl); } h3 { font-size: var(--t-l); } h4 { font-size: var(--t-m); }
strong, b { font-weight: 600; color: var(--text); }
p { margin: 0; }
a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-s); }
::selection { background: var(--accent); color: var(--on-accent); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.small { font-size: var(--t-s); } .mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- App structure ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(to right, var(--nav-bg) var(--sidebar), transparent 0); }
/* The sidebar is dark: inside it the colour tokens are the inverted ones, so everything placed in it reads on navy. */
.sidebar {
  --text: var(--nav-text); --text-2: var(--nav-text-2); --text-3: var(--nav-text-3);
  --surface-2: var(--nav-hover); --border: var(--nav-line); --border-strong: var(--nav-edge);
  --ring: 0 0 0 2px var(--nav-bg), 0 0 0 4px var(--accent);
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; padding: var(--space-4) var(--space-3);
  padding-top: calc(var(--space-4) + env(safe-area-inset-top, 0px)); padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}
.brand { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-4); font-weight: 600; font-size: var(--t-l); color: var(--text); }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--on-accent); box-shadow: inset 0 0 0 1.5px var(--on-accent); display: grid; place-items: center; font-size: var(--t-xs); font-weight: 600; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--space-3); padding: 9px var(--space-3); border-radius: var(--radius-s);
  color: var(--text-2); font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { margin-left: auto; font-size: var(--t-xs); color: var(--text-3); }
.nav-title { margin: var(--space-5) var(--space-3) var(--space-2); font-size: var(--t-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.sidebar-footer { margin-top: auto; padding-top: var(--space-4); border-top: 1px solid var(--border); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-6); padding-top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .search { flex: 1; max-width: 520px; }
.content { padding: var(--space-6); width: 100%; max-width: 1240px; }
.content.wide { max-width: none; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.page-header p { color: var(--text-2); margin-top: var(--space-1); }
.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.breadcrumbs { font-size: var(--t-s); color: var(--text-3); margin-bottom: var(--space-2); }
.breadcrumbs a { color: var(--text-2); }


@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(82vw, 300px); z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-l);
  }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open::after { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
  .app { background: none; }
  .button.menu-button { display: inline-flex; }
  .topbar .key, .hide-mobile { display: none; }
  .topbar .search { min-width: 0; }
  .topbar { padding: var(--space-3) var(--space-4); }
  .content { padding: var(--space-4); }
  .page-header { align-items: flex-start; }
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 38px; padding: 0 var(--space-4); border-radius: var(--radius-s); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 500 var(--t-m)/1 var(--font);
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s;
}
.button:hover { background: var(--surface-2); text-decoration: none; }
.button:disabled, .button[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
/* The main action: aguamarina with dark text and a dark edge, so it does not vanish on white. */
.button.primary { background: var(--accent); border-color: var(--on-accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-strong); border-color: var(--on-accent); }
/* Destructive: coral with dark text. */
.button.danger, .button.danger.filled { background: var(--danger); border-color: var(--on-danger); color: var(--on-danger); }
.button.danger:hover, .button.danger.filled:hover { background: var(--danger-strong); }
.button.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.button.ghost:hover { background: var(--surface-2); color: var(--text); }
.button.small { min-height: 30px; padding: 0 var(--space-3); font-size: var(--t-s); }
.button.icon { width: 38px; padding: 0; }
.button.icon.small { width: 30px; }
@media (min-width: 861px) { .button.menu-button { display: none; } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.field > label, .label { font-size: var(--t-s); font-weight: 500; color: var(--text); }
.field .help { font-size: var(--t-s); color: var(--text-3); }
/* An error: dark text, with a coral icon (coral is never the colour of small text). */
.field .error { font-size: var(--t-s); color: var(--text); display: flex; align-items: flex-start; gap: 8px; }
.field .error::before { content: "!"; flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 1px var(--on-danger); color: var(--on-danger); font-size: .75rem; font-weight: 600; line-height: 18px; text-align: center; }
.required::after { content: " *"; color: var(--text); }
.input, input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"]), select, textarea {
  width: 100%; min-height: 38px; padding: 8px var(--space-3); border-radius: var(--radius-s);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 400 var(--t-m)/1.4 var(--font); transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 96px; resize: vertical; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: var(--icon-select);
  background-repeat: no-repeat; background-position: right 12px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); box-shadow: var(--ring); }
/* An invalid field keeps its dark edge and gets a coral halo. */
[aria-invalid="true"], [aria-invalid="true"]:focus { border-color: var(--text); box-shadow: 0 0 0 1px var(--text), 0 0 0 4px var(--danger); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.checkbox { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
input[type="checkbox"], input[type="radio"] {
  appearance: none; flex: none; width: 18px; height: 18px; margin: 0; cursor: pointer;
  border: 1.5px solid var(--text); background: var(--surface); display: inline-grid; place-items: center;
}
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:checked { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.5l2.5 2.5 4.5-5.5' fill='none' stroke='%230d171c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat; }
input[type="radio"]:checked { background: radial-gradient(circle, var(--on-accent) 0 34%, var(--accent) 40%); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { box-shadow: var(--ring); }
progress { appearance: none; border: 1px solid var(--text); border-radius: 999px; background: var(--surface); overflow: hidden; height: 12px; }
progress::-webkit-progress-bar { background: var(--surface); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

.search { position: relative; }
.search input { padding-left: 36px; background: var(--surface); }
.search::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); opacity: .75;
  background: var(--icon-search) center/16px no-repeat;
}
.key { font: 500 var(--t-xs)/1 var(--font-mono); padding: 3px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--text-3); }
.filters { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-4); }
.filters > * { width: auto; }
.filters .search { flex: 1; min-width: 200px; }

/* ---------- Cards and front page ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.card-body { padding: var(--space-5); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: var(--t-m); }
.grid { display: grid; gap: var(--space-4); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1024px) { .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.three, .grid.side { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid.two { grid-template-columns: 1fr; } .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); } .stat { padding: var(--space-3) var(--space-4); } .stat .value { font-size: var(--t-xl); } }

.stat { padding: var(--space-4) var(--space-5); }
.stat .value { font-size: var(--t-2xl); font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: var(--space-1); color: var(--text); }
.stat .caption { font-size: var(--t-s); color: var(--text-2); font-weight: 500; }
.stat .note { font-size: var(--t-s); color: var(--text-3); margin-top: var(--space-1); }
.greeting h1 { font-size: var(--t-2xl); }
.greeting p { color: var(--text-2); margin-top: var(--space-1); }

/* ---------- Lists and tables ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); min-width: 0; }
.list > li:first-child { border-top: 0; }
.list > li.link { cursor: pointer; } .list > li.link:hover { background: var(--surface-2); }
.list .list-main { flex: 1; min-width: 0; }
.list .list-title { font-weight: 500; color: var(--text); }
.list .list-detail { font-size: var(--t-s); color: var(--text-3); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--t-m); }
.table th { text-align: left; font-size: var(--t-s); font-weight: 500; color: var(--text); background: var(--surface-2); padding: 10px var(--space-4); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td:first-child { white-space: nowrap; }
.table .row-actions { display: flex; gap: var(--space-1); justify-content: flex-end; }
/* Stacked table: on mobile each row becomes a record. Each <td> carries data-label="Column". */
@media (max-width: 640px) {
  .table.stacked thead { display: none; }
  .table.stacked, .table.stacked tbody, .table.stacked tr, .table.stacked td { display: block; width: 100%; }
  .table.stacked tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
  .table.stacked tr:last-child { border-bottom: 0; }
  .table.stacked td { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: 3px 0; border: 0; white-space: normal; text-align: right; }
  .table.stacked td::before { content: attr(data-label); color: var(--text-3); font-size: var(--t-s); text-align: left; flex: none; }
  .table.stacked td:first-child { display: block; text-align: left; font-weight: 500; padding-bottom: var(--space-1); }
  .table.stacked td:first-child::before { display: none; }
  .table.stacked td.num { text-align: right; }
  .table.stacked .row-actions { justify-content: flex-end; }
}
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); font-size: var(--t-s); color: var(--text-2); }

/* ---------- Tags, avatars ---------- */
/* Every tag has dark text; the colour only sits in the background, the edge and the dot. */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: var(--t-s); font-weight: 500; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.tag.no-dot::before { display: none; }
.tag.accent, .tag.ok { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tag.accent::before, .tag.ok::before { background: var(--accent); box-shadow: 0 0 0 1px var(--on-accent); }
.tag.warning { background: var(--warning-soft); box-shadow: inset 0 0 0 1px var(--text-3); }
.tag.danger { background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger); }
.tag.warning::before { background: var(--text-3); }
.tag.danger::before { background: var(--danger); box-shadow: 0 0 0 1px var(--on-danger); }
.tag.info { background: var(--info-soft); box-shadow: inset 0 0 0 1px var(--border); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-size: var(--t-xs); font-weight: 600; background: var(--accent); color: var(--on-accent); }
.avatar.large { width: 40px; height: 40px; font-size: var(--t-s); }
.person { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tabs a, .tabs button { padding: 10px var(--space-3) 13px; border: 0; background: none; color: var(--text-2); font: 500 var(--t-m)/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; }
/* The chosen tab: an aguamarina bar with a dark edge under it. */
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--text); box-shadow: inset 0 -1px 0 var(--text), inset 0 -4px 0 var(--accent); }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs :focus-visible { box-shadow: var(--ring); }
.tabs .count { color: var(--text-3); font-size: var(--t-s); margin-left: 4px; }

/* ---------- Board by columns ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-3); align-items: start; }
.column { background: var(--surface-2); border-radius: var(--radius-l); padding: var(--space-3); min-height: 200px; }
.column-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-1) var(--space-2) var(--space-3); font-weight: 500; font-size: var(--t-s); color: var(--text); }
.column-header .count { color: var(--text-3); font-weight: 500; }
.column.over { outline: 2px dashed var(--text); outline-offset: -4px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-2); box-shadow: var(--shadow); cursor: grab; }
.board-card:hover { border-color: var(--text); }
.board-card.dragging { opacity: .5; }
.board-card .card-title { font-weight: 500; color: var(--text); margin-bottom: var(--space-1); }
.board-card .card-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); font-size: var(--t-s); color: var(--text-3); }

/* ---------- History ---------- */
.history { list-style: none; margin: 0; padding: 0; position: relative; }
.history li { position: relative; padding: 0 0 var(--space-4) 28px; }
.history li::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: -4px; width: 2px; background: var(--border); }
.history li:last-child::before { display: none; }
.history li::after { content: ""; position: absolute; left: 2px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--text); }
.history .what { font-size: var(--t-m); }
.history .when { font-size: var(--t-s); color: var(--text-3); }
.history .change { font-size: var(--t-s); color: var(--text-2); }
.history del { color: var(--text-3); }
.history ins { text-decoration: none; font-weight: 500; }

/* ---------- Files ---------- */
.file { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.file-icon { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font: 500 var(--t-xs)/1 var(--font); background: var(--surface-2); color: var(--text); flex: none; text-transform: uppercase; }
.upload-zone { border: 2px dashed var(--text-3); border-radius: var(--radius-l); padding: var(--space-5); text-align: center; color: var(--text-2); cursor: pointer; }
.upload-zone.over { border-color: var(--text); background: var(--accent-soft); }

/* ---------- Empty states, notices, loading ---------- */
.empty { text-align: center; padding: var(--space-7) var(--space-5); color: var(--text-2); }
.empty .empty-icon { width: 52px; height: 52px; margin: 0 auto var(--space-4); border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); font-size: 22px; }
.empty h3 { color: var(--text); margin-bottom: var(--space-2); }
.empty p { max-width: 420px; margin: 0 auto var(--space-4); }
.notice-box { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--info-soft); color: var(--text-2); border: 1px solid var(--border); border-left: 4px solid var(--text-3); }
.notice-box.ok { background: var(--ok-soft); border-color: var(--accent); border-left-color: var(--accent); }
.notice-box.warning { background: var(--warning-soft); border-color: var(--border); border-left-color: var(--text); color: var(--text); }
.notice-box.danger { background: var(--danger-soft); border-color: var(--danger); border-left-color: var(--danger); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 50%, var(--surface)), var(--surface-2)); background-size: 200% 100%; animation: skeleton 1.2s infinite linear; border-radius: var(--radius-s); min-height: 14px; }
@keyframes skeleton { to { background-position: -200% 0; } }

.notices { position: fixed; right: var(--space-5); bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: var(--space-2); z-index: 100; }
.notice-floating { display: flex; align-items: center; gap: var(--space-3); min-width: 260px; max-width: 380px; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--nav-bg); color: var(--nav-text); box-shadow: var(--shadow-l); font-size: var(--t-m); animation: enter .18s ease-out; }
.notice-floating.error { background: var(--danger); color: var(--on-danger); box-shadow: var(--shadow-l), 0 0 0 1px var(--on-danger); }
@keyframes enter { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 640px) { .notices { left: var(--space-4); right: var(--space-4); bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); } .notice-floating { max-width: none; } }

/* ---------- Dialogs and menus ---------- */
dialog.dialog { border: 1px solid var(--border); padding: 0; border-radius: var(--radius-l); background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-l); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px); }
dialog.dialog::backdrop { background: var(--scrim); }
.dialog-header { padding: var(--space-5) var(--space-5) var(--space-2); }
.dialog-header p { color: var(--text-2); margin-top: var(--space-1); }
.dialog-body { padding: var(--space-3) var(--space-5); overflow-y: auto; }
.dialog-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5) var(--space-5); }
.menu { position: absolute; z-index: 60; min-width: 200px; padding: var(--space-1); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-l); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: var(--space-2); padding: 8px var(--space-3); border: 0; border-radius: var(--radius-s); background: none; color: var(--text); font: 400 var(--t-m)/1.2 var(--font); text-align: left; cursor: pointer; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .danger:hover { background: var(--danger-soft); }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); box-shadow: var(--shadow-l); max-height: 60vh; overflow-y: auto; }
.results .group { font-size: var(--t-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: var(--space-2) var(--space-3) var(--space-1); }
.results a { display: block; padding: 8px var(--space-3); border-radius: var(--radius-s); color: var(--text); text-decoration: none; }
.results a:hover, .results a[aria-selected="true"] { background: var(--surface-2); }
mark { background: var(--highlight); color: var(--text); border-radius: 3px; padding: 0 2px; }

/* ---------- Sign-in page ---------- */
.signin { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5); }
.signin .card { width: min(400px, 100%); }
.signin .brand { padding: 0 0 var(--space-4); }
.signin h1 { font-size: var(--t-xl); }
.signin .sub { color: var(--text-2); margin: var(--space-1) 0 var(--space-5); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { .sidebar, .topbar, .actions, .notices { display: none !important; } .app { display: block; } body { background: var(--surface); } }
