/* OpenSana — "Acqua" palette (clear water: health + transparency), styled after Apple's developer documentation (HIG site): white editorial pages, large
   left-aligned titles, sections separated by space instead of boxes, soft grey tiles, gradient cover cards.
   Role-named tokens only (no raw values in components), text sizes in rem so they follow the browser's text
   size, glass only on the navigation layer, light by default with an opt-in dark theme, and support for
   reduced motion / reduced transparency / increased contrast. Text contrast ≥ 4.5:1 (WCAG AA) in both themes. */
/* Inter (SIL OFL 1.1, wwwroot/fonts/LICENSE-Inter.txt), self-hosted so no visitor request goes to a third
   party. Variable weight + optical size axis: small text uses the text cut, titles the display cut, like SF.
   Apple devices keep SF Pro (listed first in the stacks); everyone else gets Inter instead of the OS font. */
@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-var.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    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;
}

:root {
    color-scheme: light;

    /* Color roles */
    --bg: #ffffff;
    --surface: #f5f5f7;
    --surface-raised: #ffffff;
    --fill: rgba(118, 118, 128, .12);
    --fill-strong: rgba(118, 118, 128, .2);
    --label: #1d1d1f;
    --label-secondary: #6e6e73;
    --separator: rgba(0, 0, 0, .14);
    --control-border: #8e8e93;
    --tint: #0a6f73;
    --tint-pressed: #075a5d;
    --tint-soft: rgba(15, 143, 140, .1);
    --on-tint: #ffffff;
    --link: #0a6f73;
    --positive: #17794a;
    --positive-bar: #2f9e68;
    --positive-soft: rgba(23, 121, 74, .12);
    --caution: #a14b06;
    --caution-bar: #e8892b;
    --caution-soft: rgba(232, 137, 43, .12);
    --critical: #b42318;
    --critical-fill: #b42318;
    --critical-soft: rgba(180, 35, 24, .1);
    --focus: #0f8f8c;
    --glass: rgba(255, 255, 255, .78);
    --glass-rim: rgba(255, 255, 255, .65);
    --cover-rim: rgba(0, 0, 0, .04);
    --brand-1: #14a7a0;
    --brand-2: #0a6f73;
    --shadow-float: 0 8px 32px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-thumb: 0 3px 8px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .06);
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, .1);
    --scrim: rgba(0, 0, 0, .4);

    /* Type (Apple web scale; SF Pro on Apple devices, the platform UI font elsewhere) */
    --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-rounded: ui-rounded, "SF Pro Rounded", var(--font-display);
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Consolas, monospace;
    --text-hero: 700 clamp(2.25rem, 1.6rem + 2.6vw, 3.5rem)/1.07 var(--font-display);  /* up to 56/60 */
    --text-large-title: 700 2.5rem/1.1 var(--font-display);       /* 40/44 */
    --text-title1: 700 1.75rem/1.143 var(--font-display);         /* 28/32 */
    --text-title2: 700 1.375rem/1.273 var(--font-display);        /* 22/28 */
    --text-title3: 600 1.25rem/1.25 var(--font-display);          /* 20/25 */
    --text-intro: 400 clamp(1.1875rem, 1rem + .7vw, 1.5rem)/1.34 var(--font-display); /* 19→24 */
    --text-headline: 600 1.0625rem/1.294 var(--font-text);        /* 17/22 */
    --text-body: 400 1.0625rem/1.47 var(--font-text);             /* 17/25 */
    --text-callout: 400 1rem/1.3125 var(--font-text);             /* 16/21 */
    --text-subheadline: 400 .9375rem/1.4 var(--font-text);        /* 15/21 */
    --text-footnote: 400 .8125rem/1.385 var(--font-text);         /* 13/18 */
    --text-caption: 400 .75rem/1.333 var(--font-text);            /* 12/16 */
    --text-caption2: 500 .6875rem/1.2 var(--font-text);           /* 11/13 */

    /* Spacing and shape (rem, so they grow with text size) */
    --space-xs: .25rem;
    --space-s: .5rem;
    --space-m: 1rem;
    --space-l: 1.5rem;
    --space-xl: 2rem;
    --space-xxl: 3rem;
    --space-section: 3rem;
    --radius-s: 8px;
    --radius-m: 12px;
    --radius-l: 18px;
    --radius-pill: 999px;
    --tap: 44px;
    --icon: 18px;
    --content-width: 1120px;
    --gutter: 1.25rem;
    --ease-spring: cubic-bezier(.34, 1.36, .64, 1);
}

/* Dark theme: opt-in via the header toggle (data-theme on <html>); light is the default. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-raised: #2c2c2e;
    --fill: rgba(118, 118, 128, .24);
    --fill-strong: rgba(118, 118, 128, .36);
    --label: #f5f5f7;
    --label-secondary: #a1a1a6;
    --separator: rgba(255, 255, 255, .16);
    --control-border: #7c7c82;
    --tint: #5cc4bd;
    --tint-pressed: #85d6d0;
    --tint-soft: rgba(92, 196, 189, .16);
    --on-tint: #00302d;
    --link: #6fd3cb;
    --positive: #4fd18b;
    --positive-bar: #34c06f;
    --positive-soft: rgba(79, 209, 139, .16);
    --caution: #ffa53d;
    --caution-bar: #ff9f0a;
    --caution-soft: rgba(255, 159, 10, .16);
    --critical: #ff6b5e;
    --critical-soft: rgba(255, 69, 58, .18);
    --focus: #5cc4bd;
    --glass: rgba(22, 22, 23, .78);
    --glass-rim: rgba(255, 255, 255, .12);
    --cover-rim: rgba(255, 255, 255, .06);
    --shadow-float: 0 8px 32px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-thumb: 0 3px 8px rgba(0, 0, 0, .4);
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, .6);
    --scrim: rgba(0, 0, 0, .6);
}

/* Increased contrast: glass turns solid, separators and controls get real borders. */
@media (prefers-contrast: more) {
    :root {
        --glass: var(--bg);
        --glass-rim: var(--label);
        --separator: var(--label-secondary);
        --control-border: var(--label);
        --fill: transparent;
    }
    .card, .btn, .chip, .notice, .lang-picker, .theme-toggle { outline: 1px solid var(--label-secondary); outline-offset: -1px; }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--label);
    font: var(--text-body);
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
}

/* Display sizes track slightly tighter, as SF Pro Display and Inter's display cut are drawn for. */
h1, h2, h3 { margin: 0 0 var(--space-s); text-wrap: balance; letter-spacing: -.015em; }
h1 { font: var(--text-large-title); }
h2 { font: var(--text-title2); }
h3 { font: var(--text-headline); }
p { margin: 0 0 var(--space-m); }
a { color: var(--link); text-underline-offset: 3px; }
h1:focus { outline: none; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-s); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: var(--space-m); top: -3rem; z-index: 100;
    background: var(--tint); color: var(--on-tint); padding: var(--space-s) var(--space-m); border-radius: var(--radius-pill);
}
.skip-link:focus { top: .75rem; }

.boot { padding: 30vh var(--space-m); text-align: center; color: var(--label-secondary); }

/* ---------- Navigation layer: glass bar like Apple's local nav (the only glass in the app) ---------- */
.app-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--separator); }
/* Glass sits on a pseudo-element: a backdrop-filter on the header itself would become the
   containing block of the fixed mobile tab bar and trap it inside the header. */
.app-header::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
}
.app-header-inner {
    max-width: calc(var(--content-width) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter);
    min-height: 52px; display: flex; align-items: center; gap: var(--space-l);
}
.brand {
    display: flex; align-items: center; gap: .55rem;
    font: 600 1.3125rem/1 var(--font-display); color: var(--label); text-decoration: none;
}
.brand-mark {
    width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    display: grid; place-items: center; color: #fff;
}
.brand-mark svg { width: 18px; height: 18px; stroke-width: 2.4; }

.main-nav { display: flex; gap: var(--space-l); margin-left: auto; align-items: center; }
.main-nav a {
    display: flex; align-items: center; gap: .4rem; min-height: var(--tap);
    color: var(--label); text-decoration: none; font: 400 .875rem/1.2 var(--font-text);
    transition: color .2s;
}
.main-nav a:hover { color: var(--link); }
.main-nav a.active { color: var(--label-secondary); }
.main-nav svg { display: none; }

/* Segmented control */
.lang-picker { display: flex; gap: 2px; padding: 2px; background: var(--fill); border-radius: 9px; }
.lang {
    min-width: 34px; min-height: 30px; border: 0; border-radius: 7px; background: none;
    font: 600 .75rem/1 var(--font-text); color: var(--label-secondary); cursor: pointer;
    transition: background-color .2s, color .2s, box-shadow .2s;
}
.lang:hover { color: var(--label); }
.lang-on, .lang-on:hover { background: var(--surface-raised); color: var(--label); box-shadow: var(--shadow-thumb); }

.theme-toggle {
    flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--radius-pill);
    background: var(--fill); color: var(--label); cursor: pointer; transition: background-color .2s;
}
.theme-toggle:hover { background: var(--fill-strong); }
.theme-toggle svg { width: 16px; height: 16px; }

.page { max-width: calc(var(--content-width) + 2 * var(--gutter)); margin: 0 auto; padding: var(--space-xl) var(--gutter) var(--space-section); }

/* Full-bleed grey footer like apple.com, without extra markup. */
.app-footer {
    max-width: calc(var(--content-width) + 2 * var(--gutter)); margin: 0 auto; padding: var(--space-l) var(--gutter) 2.5rem;
    color: var(--label-secondary); font: var(--text-caption);
    background: var(--surface); box-shadow: 0 0 0 100vmax var(--surface); clip-path: inset(0 -100vmax);
    display: flex; flex-wrap: wrap; gap: var(--space-s) var(--space-l); justify-content: space-between;
}
.app-footer p { margin: 0; }
.app-footer a { color: var(--link); }

@media (max-width: 760px) {
    :root { --gutter: 1rem; }
    .page { padding: var(--space-l) var(--gutter) 7rem; }
    .app-header-inner { gap: var(--space-s); min-height: 48px; }
    .brand { font-size: 1.1875rem; }
    .lang-picker { margin-left: auto; }

    /* Floating glass tab bar (iOS) */
    .main-nav {
        position: fixed; z-index: 30; margin: 0; gap: var(--space-xs);
        left: calc(.75rem + env(safe-area-inset-left)); right: calc(.75rem + env(safe-area-inset-right));
        bottom: calc(.6rem + env(safe-area-inset-bottom));
        padding: var(--space-xs); border-radius: var(--radius-pill);
        background: var(--glass); border: 1px solid var(--glass-rim); box-shadow: var(--shadow-float);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
    }
    .main-nav a {
        flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px;
        min-height: 52px; padding: var(--space-xs) var(--space-s); border-radius: var(--radius-pill);
        font: var(--text-caption2); color: var(--label-secondary); text-align: center; white-space: normal;
    }
    .main-nav a:hover { color: var(--label); }
    .main-nav a.active { background: var(--fill-strong); color: var(--tint); }
    .main-nav svg { display: block; width: 22px; height: 22px; }
    .app-footer { padding-bottom: 7rem; }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root { --glass: var(--bg); }
}
@media (prefers-reduced-transparency: reduce) {
    :root { --glass: var(--bg); }
    .app-header::before, .main-nav { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- Content layer: editorial page, grey tiles, no glass ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-l); margin-bottom: var(--space-xl); }
.page-head p { color: var(--label-secondary); margin: var(--space-s) 0 0; font: var(--text-intro); max-width: 40em; }

.card { background: var(--surface); border-radius: var(--radius-l); padding: var(--space-l) 1.75rem; }
.card + .card, .stack > * + * { margin-top: var(--space-l); }
.card-head { display: flex; flex-wrap: wrap; gap: var(--space-s) var(--space-m); align-items: baseline; justify-content: space-between; margin-bottom: var(--space-m); }
.card-head p { margin: 0; color: var(--label-secondary); font: var(--text-subheadline); }
@media (max-width: 760px) { .card { padding: 1.25rem var(--space-m); } }

.grid { display: grid; gap: var(--space-l); }
.grid > .card + .card { margin-top: 0; }
.grid > * { min-width: 0; }
.two-col { grid-template-columns: 1.4fr 1fr; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* Buttons: capsules, 44px targets, tint only on the primary action. */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-s);
    min-height: var(--tap); padding: .6rem 1.35rem; border-radius: var(--radius-pill);
    border: 0; font: 400 1.0625rem/1.2 var(--font-text); cursor: pointer; text-decoration: none;
    transition: background-color .2s, color .2s, transform .35s var(--ease-spring);
}
.btn:active:not(:disabled) { transform: scale(.97); transition-duration: .1s; }
.btn svg { width: var(--icon); height: var(--icon); flex: none; }
.btn-primary { background: var(--tint); color: var(--on-tint); }
.btn-primary:hover { background: var(--tint-pressed); }
.btn-secondary { background: var(--fill); color: var(--label); }
.btn-secondary:hover { background: var(--fill-strong); }
.btn-ghost { background: transparent; color: var(--link); }
.btn-ghost:hover { background: var(--fill); }
.btn-danger { background: var(--critical-fill); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-danger-outline { background: var(--critical-soft); color: var(--critical); }
.btn-danger-outline:hover { background: var(--fill-strong); }
.btn-sm { min-height: 36px; padding: .35rem 1rem; font: 400 .9375rem/1.2 var(--font-text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.badge {
    display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
    padding: .2rem .65rem; border-radius: var(--radius-pill); font: 600 .8125rem/1.385 var(--font-text);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* Soft fill laid over an opaque base, so contrast holds on any row colour. */
.badge-demo { background: linear-gradient(var(--tint-soft), var(--tint-soft)) var(--surface-raised); color: var(--tint); }
.badge-demo::before { display: none; }
.badge-ok { background: linear-gradient(var(--positive-soft), var(--positive-soft)) var(--surface-raised); color: var(--positive); }
.badge-todo { background: linear-gradient(var(--caution-soft), var(--caution-soft)) var(--surface-raised); color: var(--caution); }

/* Notices: like the HIG's asides — soft role-coloured surface, coloured symbol, label-coloured text. */
.notice {
    display: flex; gap: .85rem; align-items: flex-start;
    padding: var(--space-m) 1.25rem; border-radius: var(--radius-m); font: var(--text-callout); color: var(--label);
}
.notice p { margin: 0; }
.notice p + p { margin-top: .35rem; }
.notice svg { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.notice-info { background: var(--surface); }
.notice-info svg { color: var(--tint); }
.notice-warn { background: var(--caution-soft); }
.notice-warn svg { color: var(--caution); }
.notice-success { background: var(--positive-soft); }
.notice-success svg { color: var(--positive); }
.notice-error { background: var(--critical-soft); }
.notice-error svg { color: var(--critical); }
.notice ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.notice .actions { margin-top: .75rem; }

.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-green { color: var(--positive); }
.money-orange { color: var(--caution); }
.muted { color: var(--label-secondary); }
.small { font: var(--text-subheadline); }

/* ---------- Forms (bordered: WCAG 1.4.11 needs a 3:1 control boundary) ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .field .label { font: 600 .875rem/1.4 var(--font-text); color: var(--label); }
.input, select.input {
    width: 100%; min-height: var(--tap); padding: .55rem .8rem;
    border: 1px solid var(--control-border); border-radius: var(--radius-m); background: var(--surface-raised);
    font: var(--text-body); color: var(--label);
}
.input:focus-visible { border-color: var(--tint); border-radius: var(--radius-m); }
.input-sm { min-height: 38px; padding: .4rem .55rem; }
.form-grid { display: grid; gap: var(--space-m); grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }

/* ---------- Tables (become inset rows on mobile) ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font: var(--text-subheadline); }
table.data th {
    text-align: left; font: 600 .8125rem/1.385 var(--font-text);
    color: var(--label-secondary); padding: .6rem .75rem; border-bottom: 1px solid var(--separator); white-space: nowrap;
}
table.data td { padding: .8rem .75rem; border-bottom: 1px solid var(--separator); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--fill); }
table.data .num { text-align: right; }
table.data tfoot td { font-weight: 700; border-top: 1px solid var(--label-secondary); border-bottom: none; }
.cell-main { font-weight: 600; color: var(--label); text-decoration: none; }
.cell-main:hover { text-decoration: underline; }
.cell-sub { display: block; color: var(--label-secondary); font: var(--text-footnote); }

@media (max-width: 760px) {
    table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td, table.responsive tfoot { display: block; width: 100%; }
    table.responsive tr { display: flex; flex-direction: column; border-radius: var(--radius-m); padding: var(--space-s) .9rem; margin-bottom: .6rem; background: var(--surface-raised); }
    table.responsive tbody tr:hover { background: var(--surface-raised); }
    table.responsive td.td-title { order: -1; }
    table.responsive td { border: none; padding: .35rem 0; display: flex; justify-content: space-between; gap: var(--space-m); text-align: right; }
    table.responsive td::before { content: attr(data-label); color: var(--label-secondary); font: 600 .8125rem/1.385 var(--font-text); text-align: left; flex: none; }
    table.responsive td.td-title { display: block; text-align: left; padding-bottom: var(--space-s); border-bottom: 1px solid var(--separator); margin-bottom: var(--space-xs); }
    table.responsive td.td-title::before { display: none; }
    table.responsive td.td-actions { justify-content: flex-end; padding-top: .6rem; }
    table.responsive td.td-actions::before { display: none; }
    table.responsive tfoot tr { background: var(--tint-soft); }
}

/* ---------- Flow steps ---------- */
.steps { list-style: none; padding: 0; margin: 0 0 var(--space-xl); display: flex; gap: var(--space-s); counter-reset: step; }
.steps li {
    flex: 1; display: flex; align-items: center; gap: .55rem;
    padding: .6rem .75rem; border-radius: var(--radius-m); background: var(--surface);
    color: var(--label-secondary); font: 500 .9375rem/1.333 var(--font-text);
}
.steps li::before {
    counter-increment: step; content: counter(step);
    flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
    background: var(--fill); color: var(--label-secondary); font: 700 .8125rem/1 var(--font-rounded);
}
.steps li.done { color: var(--positive); }
.steps li.done::before { content: "✓"; background: var(--positive-soft); color: var(--positive); }
.steps li.current { color: var(--label); font-weight: 700; box-shadow: inset 0 0 0 2px var(--tint); }
.steps li.current::before { background: var(--tint); color: var(--on-tint); }
@media (max-width: 640px) {
    .steps li { flex-direction: column; text-align: center; font: var(--text-caption2); padding: var(--space-s) var(--space-xs); gap: .3rem; }
}

/* ---------- Upload ---------- */
.dropzone {
    position: relative; border: 2px dashed var(--control-border); border-radius: var(--radius-l); background: var(--surface-raised);
    padding: 2.75rem var(--space-l); text-align: center; transition: border-color .2s, background-color .2s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--tint); background: var(--tint-soft); }
.dropzone:focus-within { border-color: var(--tint); outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-icon {
    width: 56px; height: 56px; margin: 0 auto var(--space-m); border-radius: var(--radius-m);
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; display: grid; place-items: center;
}
.dropzone-icon svg { width: 28px; height: 28px; }
.dropzone strong { font: var(--text-title3); display: block; margin-bottom: var(--space-xs); }
.dropzone .fake-btn { margin-top: var(--space-m); pointer-events: none; }

.progress-panel { text-align: center; padding: 2.5rem var(--space-l); }
.spinner {
    width: 44px; height: 44px; margin: 0 auto var(--space-m); border-radius: 50%;
    border: 4px solid var(--tint-soft); border-top-color: var(--tint); animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { height: 8px; max-width: 320px; margin: var(--space-m) auto 0; border-radius: var(--radius-pill); background: var(--fill); overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--tint); border-radius: var(--radius-pill); transition: width .3s; }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 3s; }
    * { transition: none !important; }
    .btn:active:not(:disabled), .result-card:hover, .result-card:active { transform: none; }
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: var(--space-xxl) var(--space-l); }
.empty-icon {
    width: 72px; height: 72px; margin: 0 auto 1.25rem; border-radius: var(--radius-l);
    background: var(--tint-soft); color: var(--tint); display: grid; place-items: center;
}
.empty-icon svg { width: 34px; height: 34px; }
.empty p { color: var(--label-secondary); max-width: 520px; margin-left: auto; margin-right: auto; }
.empty .actions { justify-content: center; margin-top: var(--space-l); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; gap: var(--space-m); padding: .7rem 0; border-bottom: 1px solid var(--separator); }
.list-plain li:last-child { border-bottom: none; }

/* Documentation pages read like the HIG: section titles, comfortable measure. */
.prose { max-width: 42em; }
.prose h2 { font: var(--text-title1); margin-top: var(--space-xxl); }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: .35rem; }

/* ---------- Dialog ---------- */
dialog.dialog {
    border: none; border-radius: var(--radius-l); padding: var(--space-l); width: min(440px, calc(100vw - 2rem));
    background: var(--surface-raised); color: var(--label); box-shadow: var(--shadow-float);
}
dialog.dialog[open] { animation: pop .35s var(--ease-spring); }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@media (prefers-reduced-motion: reduce) { dialog.dialog[open] { animation: none; } }
dialog.dialog::backdrop { background: var(--scrim); }
dialog.dialog p { color: var(--label-secondary); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* ---------- Blazor defaults ---------- */
#blazor-error-ui {
    background: var(--surface-raised); color: var(--label); bottom: 0; box-shadow: var(--shadow-float);
    display: none; left: 0; padding: .75rem 3rem .75rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { position: absolute; right: .75rem; top: .5rem; background: none; border: 0; color: inherit; font-size: 1.1rem; cursor: pointer; }
.blazor-error-boundary { background: var(--critical-fill); padding: var(--space-m); color: #fff; border-radius: var(--radius-m); }
.blazor-error-boundary::after { content: "Si è verificato un errore."; }

/* ---------- Search (home) ---------- */
.hero { padding: var(--space-m) 0 var(--space-xl); }
.hero h1 { font: var(--text-hero); max-width: 15em; margin: 0 0 var(--space-m); }
.hero > p { font: var(--text-intro); max-width: 32em; margin: 0 0 var(--space-xl); }
.search-box { position: relative; max-width: 640px; }
.search-box svg { position: absolute; left: 1.1rem; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--label-secondary); pointer-events: none; }
.search-input {
    width: 100%; min-height: 54px; padding: .8rem 1.25rem .8rem 3rem; font: 400 1.0625rem/1.3 var(--font-text);
    border: 1px solid var(--control-border); border-radius: var(--radius-m); background: var(--surface-raised); color: var(--label);
}
.search-input:focus-visible { border-color: var(--tint); border-radius: var(--radius-m); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-s); margin-top: var(--space-m); }
.chip {
    min-height: 36px; padding: .35rem .95rem; border-radius: var(--radius-pill); border: 0; background: var(--fill);
    font: var(--text-subheadline); color: var(--label); cursor: pointer; transition: background-color .2s, color .2s;
}
.chip:hover { background: var(--fill-strong); }
.chip-on, .chip-on:hover { background: var(--label); color: var(--bg); }

.results-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-m); margin: var(--space-section) 0 var(--space-l); }
.results-head h2 { margin: 0; font: var(--text-title1); }
.results-head .chips { margin: 0; }

/* Result cards like the HIG's: gradient cover with a symbol, text underneath, no box. */
.result-grid { list-style: none; margin: 0 0 var(--space-section); padding: 0; display: grid; gap: var(--space-xl) var(--space-l); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.result-card { display: flex; flex-direction: column; gap: .3rem; height: 100%; text-decoration: none; color: inherit; border-radius: var(--radius-l); }
.cover {
    display: grid; place-items: center; aspect-ratio: 16 / 9; margin-bottom: .75rem;
    border-radius: var(--radius-l); border: 1px solid var(--cover-rim); color: rgba(255, 255, 255, .92);
    background: linear-gradient(135deg, var(--c1), var(--c2));
    transition: transform .4s var(--ease-spring), box-shadow .3s;
}
.cover svg { width: 30%; height: auto; max-width: 84px; stroke-width: 1.5; }
.result-card:hover .cover { transform: scale(1.02); box-shadow: var(--shadow-hover); }
.result-card:active .cover { transform: scale(.98); transition-duration: .1s; }
.result-card:hover .result-name { color: var(--link); }
.cover-VisitaMedica { --c1: #0f8f8c; --c2: #3aa58a; }
.cover-Specialista  { --c1: #137f8f; --c2: #2ba3b3; }
.cover-Ospedale     { --c1: #0a6273; --c2: #2b86b3; }
.cover-Farmacia     { --c1: #2f9a7c; --c2: #63bf98; }
.cover-Laboratorio  { --c1: #2b7fb0; --c2: #59a8d0; }
.cover-Radiologia   { --c1: #1d6f9e; --c2: #2ba0bf; }
.cover-Fisioterapia { --c1: #23977f; --c2: #55c2a2; }
.cover-Odontoiatria { --c1: #2e98b8; --c2: #66c3d6; }
.cover-Psicoterapia { --c1: #4b7cb5; --c2: #6fa2d6; }
.cover-Mezzi        { --c1: #7a5fb3; --c2: #a58bd6; }
.cover-Altro        { --c1: #557880; --c2: #84a1a7; }
/* Phones: iOS list row — small square cover on the left, text beside it. */
@media (max-width: 560px) {
    .result-grid { gap: var(--space-l); }
    .result-card { display: grid; grid-template-columns: 64px 1fr; column-gap: var(--space-m); row-gap: .2rem; align-content: start; }
    .result-card > * { grid-column: 2; }
    .result-card > .cover { grid-column: 1; grid-row: 1 / span 4; aspect-ratio: 1; margin: 0; border-radius: 14px; align-self: start; }
    .cover svg { width: 55%; }
}
.result-cat { font: 600 .75rem/1.333 var(--font-text); color: var(--label-secondary); }
.result-name { font: var(--text-headline); transition: color .2s; }
.result-price { margin-top: var(--space-xs); }
.result-price .money { font: 600 1.0625rem/1.3 var(--font-text); color: var(--label); }

.cta-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-l); padding: var(--space-xl); }
.cta-card h2 { margin-bottom: var(--space-xs); }
.cta-card p { margin: 0; }

/* ---------- Service price ---------- */
.big-price { font: 700 clamp(2.5rem, 1.9rem + 2.2vw, 3.5rem)/1.05 var(--font-rounded); color: var(--label); margin: var(--space-xs) 0; }
.big-price.money { white-space: normal; }
.big-price-sub { font: var(--text-title3); margin-top: var(--space-s); }
.range-viz { position: relative; height: 28px; margin: 1.25rem 0 var(--space-s); }
.range-line { position: absolute; left: 0; right: 0; top: 13px; height: 2px; border-radius: 1px; background: var(--fill-strong); }
.range-box { position: absolute; top: 5px; height: 18px; border-radius: 6px; background: var(--tint-soft); border: 1.5px solid var(--tint); }
.range-median { position: absolute; top: 0; width: 4px; height: 28px; margin-left: -2px; border-radius: 2px; background: var(--tint); }
.range-labels { display: flex; justify-content: space-between; gap: .75rem; font: var(--text-footnote); }
.range-labels > span { display: flex; flex-direction: column; }
.range-mid { text-align: center; }
.range-labels > span:last-child { text-align: right; }
@media (max-width: 420px) { .range-labels { font: var(--text-caption); gap: .4rem; } }

.radio-group { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-xs) 1.25rem; }
.radio-group legend { width: 100%; margin-bottom: .4rem; font: 600 .9375rem/1.333 var(--font-text); padding: 0; }
.radio-group label { display: inline-flex; align-items: center; gap: .45rem; min-height: var(--tap); cursor: pointer; }
.radio-group input, .consent input { width: 20px; height: 20px; accent-color: var(--tint); }
.share { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 1.25rem 0 var(--space-m); }
.share > div { background: var(--surface-raised); border-radius: var(--radius-m); padding: .8rem var(--space-m); }
.share dt { font: 600 .8125rem/1.385 var(--font-text); color: var(--label-secondary); }
.share dd { margin: 0; font: 700 1.375rem/1.273 var(--font-rounded); }

tr.row-selected td { background: var(--tint-soft); }
.td-bar { width: 22%; }
.mini-track { height: 8px; border-radius: var(--radius-pill); background: var(--fill); overflow: hidden; }
.mini-bar { height: 100%; border-radius: var(--radius-pill); background: var(--tint); opacity: .8; }
@media (max-width: 760px) {
    table.responsive td.td-bar { display: none; }
    table.responsive tr.row-selected { background: var(--tint-soft); }
}

/* ---------- Contribute ---------- */
.share-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.25rem; margin-bottom: var(--space-m); }
.share-preview h3 { font: 600 .9375rem/1.333 var(--font-text); margin-bottom: var(--space-s); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem .75rem; margin: 0; font: var(--text-subheadline); }
.kv dt { color: var(--label-secondary); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.removed { list-style: none; margin: 0; padding: 0; font: var(--text-subheadline); }
.removed li { padding-left: 1.4rem; position: relative; margin-bottom: .3rem; color: var(--label-secondary); }
.removed li::before { content: "✕"; position: absolute; left: 0; color: var(--caution); font-weight: 700; }
.consent { display: flex; gap: .65rem; align-items: flex-start; padding: .9rem var(--space-m); border-radius: var(--radius-m); background: var(--surface-raised); cursor: pointer; font: var(--text-subheadline); }
.consent input { flex: none; margin-top: 0; }
.extracted { margin-top: 1.25rem; font: var(--text-subheadline); }
.extracted summary { cursor: pointer; color: var(--link); font-weight: 600; min-height: 32px; }

.head-filters { display: flex; flex-wrap: wrap; gap: .75rem; }
.head-filters .field { min-width: 200px; }
.point-lines { list-style: none; margin: var(--space-s) 0; padding: 0; font: var(--text-subheadline); }
.point-lines li { padding: .2rem 0; }
.sources { margin: 0 0 var(--space-s); padding-left: 1.1rem; font: var(--text-subheadline); }
.sources li { margin-bottom: var(--space-xs); overflow-wrap: anywhere; }
.code { font: .8125rem/1.385 var(--font-mono); white-space: nowrap; color: var(--label-secondary); margin-right: .35rem; }

@media (max-width: 760px) {
    h1 { font-size: 2rem; }
    .hero { padding: var(--space-m) 0 var(--space-xl); }
    .results-head { margin-top: var(--space-xxl); }
    .big-price { font-size: 2.25rem; }
    .head-filters, .head-filters .field { width: 100%; }
}

/* Charts (/andamento): two validated series colors, recessive grid, text in text tokens */
:root { --chart-1: #06a097; --chart-2: #7a5fb3; }
:root[data-theme="dark"] { --chart-1: #17a39a; --chart-2: #8a6ccc; }
.chart { margin: .75rem 0 0; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: var(--separator); stroke-width: 1; }
.chart-tick { font: 500 11px var(--font-text); fill: var(--label-secondary); text-anchor: end; }
.chart-tick-x { text-anchor: middle; }
.chart-label { font: 600 12px var(--font-text); fill: var(--label); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { stroke: var(--surface-raised); stroke-width: 2; }
.chart-line.chart-s1, .chart-swatch.chart-s1 { stroke: var(--chart-1); background: var(--chart-1); }
.chart-line.chart-s2, .chart-swatch.chart-s2 { stroke: var(--chart-2); background: var(--chart-2); }
.chart-dot.chart-s1 { fill: var(--chart-1); }
.chart-dot.chart-s2 { fill: var(--chart-2); }
.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; font: var(--text-subheadline); color: var(--label-secondary); margin-top: .5rem; }
.chart-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .4rem; vertical-align: -1px; }
.bar { display: inline-block; height: 10px; width: calc(var(--w) * 1.2); max-width: 120px; border-radius: 0 4px 4px 0; background: var(--chart-1); vertical-align: middle; margin-right: .5rem; }

/* ---------- Polish pass: one nav state, hero enters once, feedback on every control, 44px touch targets ---------- */
/* Footer stays at the bottom of the window on short pages. */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.page { flex: 1; width: 100%; }
.app-footer { width: 100%; }

/* Desktop nav: the current page is the strong one (it used to look disabled); underline draws on hover. */
@media (min-width: 761px) {
    .main-nav a { position: relative; color: var(--label-secondary); }
    .main-nav a:hover, .main-nav a.active { color: var(--label); }
    .main-nav a::after {
        content: ""; position: absolute; left: 0; right: 0; bottom: 9px; height: 2px; border-radius: 1px;
        background: var(--tint); transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
    }
    .main-nav a:hover::after, .main-nav a.active::after { transform: scaleX(1); }
}

/* Hero: tighter display tracking, intro in the secondary label like every other page head, search field as the main object. */
.hero h1 { letter-spacing: -.025em; }
.hero > p { color: var(--label-secondary); }
.search-input, .search-input:focus-visible { border-radius: var(--radius-l); }
.search-input { box-shadow: var(--shadow-thumb); }
.input, .search-input { transition: border-color .2s; }
.input:hover, .search-input:hover { border-color: var(--label); }

@media (prefers-reduced-motion: no-preference) {
    .hero > * { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
    .hero > :nth-child(2) { animation-delay: .06s; }
    .hero > :nth-child(3) { animation-delay: .12s; }
    .hero > :nth-child(n+4) { animation-delay: .18s; }
    .btn { transition: background-color .2s, color .2s, box-shadow .2s, transform .35s var(--ease-spring); }
    .btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 14px color-mix(in srgb, var(--tint) 30%, transparent); }
    .btn-primary:active:not(:disabled) { transform: scale(.97); box-shadow: none; }
    .chip { transition: background-color .2s, color .2s, transform .2s; }
    .chip:active { transform: scale(.96); }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Touch: every control reaches the 44px target. */
@media (max-width: 760px), (pointer: coarse) {
    .chip, .btn-sm, .lang { min-height: var(--tap); }
    .theme-toggle { width: var(--tap); height: var(--tap); }
    .app-header-inner { min-height: 56px; }
}
