/*
 * TopTrucker UP - design system condiviso (admin, console, app).
 *
 * Principi: leggibilità prima di tutto (font Ubuntu, testo 17px, contrasto AA),
 * interfaccia ariosa, pochi colori con significato preciso.
 * I colori del marchio sono variabili (--brand-*): il branding si cambia qui.
 * I colori dello Status di Guida (--status-*) sono fissi e uguali ovunque.
 */

@font-face {
    font-family: "Ubuntu";
    src: url("../fonts/ubuntu/Ubuntu-VF.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Ubuntu";
    src: url("../fonts/ubuntu/Ubuntu-Italic-VF.woff2") format("woff2");
    font-weight: 300 700;
    font-style: italic;
    font-display: swap;
}

:root {
    /* marchio: logo "B - Tachimetro" (DEC-34) */
    --brand: #14335c;
    --brand-strong: #0d2342;
    --brand-soft: #e6edf7;
    --on-brand: #ffffff;

    /* superfici e testo */
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --text: #1d2433;
    --text-muted: #5b6475;
    --border: #dde2ea;
    --focus: #2c6fd1;

    /* Status di Guida e stati */
    --status-good: #12b76a;
    --status-good-soft: #e7f8ef;
    --status-mid: #f5b83d;
    --status-mid-soft: #fef6e4;
    --status-bad: #f04438;
    --status-bad-soft: #fdecea;
    --info-soft: #eaf2ff;

    /* forma e ritmo */
    --font: "Ubuntu", "Noto Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --text-base: 17px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-3); font-weight: 700; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--space-4); }
a { color: #1f5fbf; text-decoration: none; }
a:hover { text-decoration: underline; }
small, .muted { color: var(--text-muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Marchio ---------- */
.brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--text); font-size: 1.25rem; letter-spacing: -.2px; }
.brand:hover { text-decoration: none; }
.brand__mark { width: 36px; height: 36px; border-radius: 10px; flex: none; }
.brand__mark--text { display: inline-grid; place-items: center; background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: .95rem; }
.brand__name b { font-weight: 700; }
.brand__name span { font-weight: 400; }

/* ---------- Pulsanti ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 48px; padding: 0 var(--space-5);
    border: 1px solid transparent; border-radius: var(--radius);
    font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
    transition: background-color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-strong); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--surface-alt); }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { color: var(--text); background: var(--surface-alt); }
.btn--block { width: 100%; }
.btn--small { min-height: 36px; padding: 0 var(--space-3); font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Form ---------- */
.field { margin-bottom: var(--space-4); }
.field label { display: block; font-weight: 500; margin-bottom: var(--space-2); }
.field__hint { font-size: .9rem; color: var(--text-muted); margin-top: var(--space-1); }
.input {
    width: 100%; min-height: 50px; padding: 0 var(--space-4);
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px rgba(44, 111, 209, .18); }
.input--code { font-size: 1.5rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.input[aria-invalid="true"] { border-color: var(--status-bad); }
select.input { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 22px) 22px, calc(100% - 16px) 22px; background-size: 6px 6px; background-repeat: no-repeat; }

/* ---------- Messaggi ---------- */
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius); margin-bottom: var(--space-4); border: 1px solid transparent; }
.alert--error { background: var(--status-bad-soft); border-color: #f8c4bf; color: #8a1c13; }
.alert--success { background: var(--status-good-soft); border-color: #b6ebcf; color: #0b6b3e; }
.alert--info { background: var(--info-soft); border-color: #c7dafd; color: #17407f; }
.alert--warning { background: var(--status-mid-soft); border-color: #f6dfa6; color: #7a5208; }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow); }
.card__title { font-size: 1.1rem; margin: 0 0 var(--space-3); }
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat__label { color: var(--text-muted); font-size: .95rem; }
.stat__value { font-size: 2rem; font-weight: 700; line-height: 1.2; }

/* ---------- Badge ---------- */
.badge { display: inline-block; max-width: 100%; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.badge--good { background: var(--status-good-soft); color: #0b6b3e; }
.badge--mid { background: var(--status-mid-soft); color: #7a5208; }
.badge--bad { background: var(--status-bad-soft); color: #8a1c13; }
.badge--neutral { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Pagine di accesso ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-5) var(--space-4); }
.auth__card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow-lg); }
.auth__brand { display: flex; justify-content: center; margin-bottom: var(--space-5); }
.auth__title { text-align: center; font-size: 1.45rem; margin-bottom: var(--space-2); }
.auth__subtitle { text-align: center; color: var(--text-muted); margin-bottom: var(--space-5); }
.auth__footer { margin-top: var(--space-5); text-align: center; font-size: .95rem; }
.auth__links { text-align: center; margin-top: var(--space-4); }
.lang-switch { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1); margin-top: var(--space-5); }
.lang-switch a { padding: 4px 10px; border-radius: 999px; color: var(--text-muted); font-size: .9rem; }
.lang-switch a[aria-current="true"] { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.qr { display: flex; justify-content: center; margin: var(--space-4) 0; }
.qr svg { width: 200px; height: 200px; }
.secret { font-family: ui-monospace, monospace; font-size: .95rem; word-break: break-all; text-align: center; background: var(--surface-alt); padding: var(--space-2); border-radius: var(--radius-sm); }

/* ---------- Struttura applicativa (admin, console) ---------- */
.shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); grid-template-rows: 64px 1fr; grid-template-areas: "top top" "nav main"; }
.topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 0 var(--space-5); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar__user { display: flex; align-items: center; gap: var(--space-3); color: var(--text-muted); }
.sidenav { grid-area: nav; background: var(--surface); border-right: 1px solid var(--border); padding: var(--space-4) var(--space-3); }
.sidenav a { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border-radius: var(--radius); color: var(--text); font-weight: 500; }
.sidenav a:hover { background: var(--surface-alt); text-decoration: none; }
.sidenav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }
.main { grid-area: main; padding: var(--space-6); max-width: none; width: 100%; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.page-header h1 { margin: 0; }
@media (max-width: 860px) {
    /* minmax(0, 1fr): la colonna non si allarga oltre lo schermo per una tabella o un grafico larghi */
    .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: 64px auto 1fr; grid-template-areas: "top" "nav" "main"; }
    .topbar__user > span:not(.badge), .topbar .brand__name { display: none; }
    fieldset { min-width: 0; }
    .topbar__user .badge { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .sidenav { border-right: 0; border-bottom: 1px solid var(--border); display: flex; overflow-x: auto; gap: var(--space-1); padding: var(--space-2); }
    .sidenav a { white-space: nowrap; }
    .main { padding: var(--space-4); }
    .topbar { padding: 0 var(--space-4); }
}

/* ---------- App autista (mobile) ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; background: var(--bg); }
.app__bar { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); background: var(--brand); color: var(--on-brand); }
.app__bar .brand { color: var(--on-brand); font-size: 1.05rem; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-4); background: var(--status-mid-soft); color: #7a5208; border-bottom: 1px solid #f6dfa6; font-size: .9rem; }
.preview-bar form { margin: 0; }
.app__bar .btn--ghost { color: var(--on-brand); }
.app__content { flex: 1; padding: var(--space-4); }

/* ---------- Tabelle ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.table th { font-size: .9rem; color: var(--text-muted); font-weight: 500; background: var(--surface-alt); }
.table tr:last-child td { border-bottom: 0; }

/* ---------- Utilità ---------- */
.stack > * + * { margin-top: var(--space-4); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.inline-form { display: inline; margin: 0; }

/* ---------- Pagine essenziali (errori, diagnostica) ---------- */
.minimal { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.minimal__box { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow); }
.minimal__brand { margin-bottom: var(--space-4); }
.minimal__title { margin: 0 0 var(--space-2); font-size: 1.6rem; }
.minimal__text { color: var(--text-muted); }
.minimal__note { font-size: .9rem; color: var(--text-muted); }
.status-table { width: 100%; border-collapse: collapse; }
.status-table th, .status-table td { text-align: left; padding: 10px 4px; border-top: 1px solid var(--border); }
.status-table th { font-weight: 500; color: var(--text-muted); width: 45%; }
.badge--ok { background: var(--status-good-soft); color: #0b6b3e; }
.badge--ko { background: var(--status-bad-soft); color: #8a1c13; }

/* ---------- Form amministrativi ---------- */
.form-card { max-width: 900px; }
.form-section { border: 0; padding: 0; margin: 0 0 var(--space-5); }
.form-section legend { font-size: 1.1rem; font-weight: 700; margin-bottom: var(--space-3); padding: 0; }
.form-grid { display: grid; gap: 0 var(--space-4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); padding-top: var(--space-2); }
.field__error { color: #b42318; font-size: .9rem; margin: var(--space-1) 0 0; }
.checkbox { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; cursor: pointer; }
.checkbox input[type=checkbox] { width: 20px; height: 20px; }
.textarea { min-height: 110px; padding: var(--space-3) var(--space-4); line-height: 1.45; resize: vertical; }
.textarea--code { font-family: ui-monospace, monospace; font-size: .95rem; }
.translations { display: grid; gap: var(--space-2); }
.translations__row { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: var(--space-2); }
.translations__lang { font-weight: 700; color: var(--text-muted); font-size: .9rem; }
.input:disabled { background: var(--surface-alt); color: var(--text-muted); }
.btn--danger { color: #b42318; border-color: #f3c3be; }
.btn--danger:hover { background: var(--status-bad-soft); }
.danger-zone { margin-top: var(--space-5); }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tabs a { padding: var(--space-3) var(--space-4); color: var(--text-muted); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2) var(--space-5); margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: break-word; }
@media (max-width: 560px) {
    /* telefono: etichetta sopra, valore sotto */
    .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .kv dd { margin-bottom: var(--space-2); }
}
.actions-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.input-affix { position: relative; max-width: 240px; }
.input-affix .input { padding-right: 40px; }
.input-affix__suffix { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-weight: 500; }
.section-title { font-size: 1.2rem; margin: var(--space-6) 0 var(--space-3); }
.pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, monospace; font-size: .85rem; }
.grid--main-side { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
@media (max-width: 1000px) { .grid--main-side { grid-template-columns: 1fr; } }
.card--link { color: inherit; transition: box-shadow .15s, border-color .15s; }
.card--link:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow-lg); }
code { font-family: ui-monospace, monospace; font-size: .9em; background: var(--surface-alt); padding: 1px 6px; border-radius: 6px; }
.table--form td { vertical-align: top; padding: var(--space-2); }
.table--form .input { min-height: 40px; font-size: .95rem; padding: 0 var(--space-2); }
.table--form .input + .input { margin-top: var(--space-1); }
.input--mono { font-family: ui-monospace, monospace; min-width: 280px; }
.input--num { width: 90px; }
.table--form td:first-child .input { min-width: 150px; }
.table--form td:nth-child(2) .input { min-width: 220px; }
.labels-more summary { cursor: pointer; font-size: .85rem; color: var(--text-muted); margin-top: var(--space-1); }
.labels-more .input { margin-top: var(--space-1); }

/* ---------- Console azienda ---------- */
.grid--two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: var(--space-4); }
.chart-card { margin-top: var(--space-4); }
.chart-box { position: relative; height: 320px; }
.delta { font-weight: 700; font-size: .9rem; white-space: nowrap; }
.delta--up { color: #0b7a44; }
.delta--down { color: #b42318; }
.delta--flat, .delta--none { color: var(--text-muted); }
.scorebar { position: relative; display: inline-block; width: 160px; height: 26px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); overflow: hidden; vertical-align: middle; }
.scorebar__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; }
.scorebar--high .scorebar__fill { background: var(--status-good); }
.scorebar--mid .scorebar__fill { background: var(--status-mid); }
.scorebar--low .scorebar__fill { background: var(--status-bad); }
.scorebar__value { position: relative; display: block; text-align: center; line-height: 24px; font-weight: 700; font-size: .9rem; color: var(--text); text-shadow: 0 0 3px rgba(255,255,255,.9); }
.rank { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 700; background: var(--surface-alt); }
.rank--1 { background: #fde68a; }
.rank--2 { background: #e5e7eb; }
.rank--3 { background: #fed7aa; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4); align-items: flex-end; padding: var(--space-4); }
.filters .field { margin: 0; min-width: 160px; }
.filters__submit { min-width: auto; }
.period-label { margin: var(--space-3) 0 var(--space-4); }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.people li:last-child { border-bottom: 0; }
.people__hint { flex-basis: 100%; }
.pin-box__code { font-size: 1.5rem; font-weight: 700; letter-spacing: .15em; font-variant-numeric: tabular-nums; }

/* ---- Premialità (fase 12) ---- */
.nowrap { white-space: nowrap; }
.bands { line-height: 1.8; }
.table--bands .input { max-width: 140px; }
.table tfoot th { border-top: 2px solid var(--border); text-align: left; font-size: 1rem; color: var(--text); }
.table tfoot th.num { text-align: right; }

/* pagina da stampare / salvare in PDF */
.print-page { background: #fff; padding: var(--space-5); max-width: 1100px; margin: 0 auto; }
.print-brand { margin-bottom: var(--space-4); }
.print-actions { display: flex; justify-content: flex-end; margin-bottom: var(--space-3); }
.print-meta { border-collapse: collapse; margin-bottom: var(--space-4); }
.print-page .table-wrap, .print-page .table { width: 100%; }
.print-meta th { text-align: left; padding: var(--space-1) var(--space-4) var(--space-1) 0; color: var(--text-muted); font-weight: 500; vertical-align: top; }
.print-meta td { padding: var(--space-1) 0; }
@media print {
    .no-print { display: none !important; }
    .print-page { padding: 0; max-width: none; }
    .print-page .table-wrap { overflow: visible; border: 0; box-shadow: none; }
    .print-page .table { font-size: 10pt; }
    .print-page .table th, .print-page .table td { padding: 4px 6px; }
    .print-page tr { break-inside: avoid; }
    @page { size: A4; margin: 14mm; }
}

/* ---- Story (fase 13) ---- */
.lang-picker { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.lang-picker a { padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--text-muted); }
.lang-picker a.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.story-element { margin-bottom: var(--space-4); }
.story-element__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.story-element__tools { margin-left: auto; display: flex; gap: var(--space-1); }
.story-textarea { min-height: 180px; font-family: inherit; line-height: 1.5; }
.story-source pre { white-space: pre-wrap; background: var(--surface-alt); padding: var(--space-3); border-radius: var(--radius); font-family: inherit; font-size: .9rem; }
.story-media-preview { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-2); }
.story-media-preview img, .story-media-preview video { max-width: 320px; max-height: 220px; border-radius: var(--radius); border: 1px solid var(--border); }
.story-add { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.story-add .input { width: auto; }
.inline-fields { display: flex; align-items: center; gap: var(--space-2); }
.inline-fields .input { width: 90px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-1) var(--space-4); }
.story-rule { margin-bottom: var(--space-4); }
.story-preview { max-width: 480px; margin: 0 auto; border: 8px solid #1d2939; border-radius: 28px; padding: var(--space-4); background: var(--bg); }

/* lettore (app e anteprima) */
.story__title { margin: 0 0 var(--space-2); font-size: 1.5rem; }
.story__desc { color: var(--text-muted); margin: 0 0 var(--space-3); }
.story__progress { height: 6px; background: var(--surface-alt); border-radius: 999px; overflow: hidden; display: none; }
.story__progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s; }
.story__counter { display: none; font-size: .9rem; margin: var(--space-1) 0 0; text-align: right; }
.story--paged .story__progress, .story--paged .story__counter { display: block; }
.story__step { padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.story--paged .story__step { border-bottom: 0; min-height: 40vh; }
.story__nav { display: flex; gap: var(--space-3); justify-content: space-between; position: sticky; bottom: 0; padding: var(--space-3) 0; background: var(--bg); }
.story__nav .btn { flex: 1; }
.story-text { font-size: 1.15rem; line-height: 1.6; }
.story-text h3 { font-size: 1.3rem; margin: 0 0 var(--space-3); color: var(--brand); }
.story-text ul { padding-left: 1.2em; }
.story-text li { margin-bottom: var(--space-2); }
.story-figure { margin: 0; }
.story-figure img, .story-figure video { width: 100%; height: auto; border-radius: var(--radius-lg); background: #000; }
.story-figure figcaption { color: var(--text-muted); margin-top: var(--space-2); }
.story-embed { position: relative; padding-top: 56.25%; }
.story-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius-lg); }
.story-audio { width: 100%; margin-bottom: var(--space-3); }

/* elenco Story nell'app */
.app-section { font-size: 1.15rem; margin: var(--space-5) 0 var(--space-2); }
.story-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: var(--space-3); color: var(--text); overflow: hidden; }
.story-card:hover { text-decoration: none; border-color: var(--brand); }
.story-card--highlight { border-left: 5px solid var(--status-mid, #f2b134); }
.story-card__body { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); }
.story-card__title { font-size: 1.1rem; }
.story-card__desc { color: var(--text-muted); }
.story-card__meta { display: flex; gap: var(--space-3); align-items: center; margin-top: var(--space-1); }
.story-card__progress { display: block; height: 4px; background: var(--surface-alt); }
.story-card__progress span { display: block; height: 100%; background: var(--brand); }
.back-link { font-weight: 600; }

[hidden] { display: none !important; }

/* ---- Home app autista (fase 14) ---- */
.app { padding-bottom: 72px; }
.app-hello { font-size: 1.3rem; font-weight: 700; margin: 0 0 var(--space-3); }
.status-card { padding-top: var(--space-4); }
.status-card__period { color: var(--text-muted); margin: 0 0 var(--space-3); }
.status-card__label { margin: var(--space-2) 0 0; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .85rem; }
.status-card__score { font-size: 4rem; font-weight: 700; line-height: 1; margin: var(--space-1) 0 var(--space-3); }
.status-card__score span { font-size: 2rem; }
.status-card__insufficient { font-size: 1.1rem; }
.face { display: block; margin: 0 auto; filter: drop-shadow(0 4px 10px rgba(16, 24, 40, .15)); }
.status-change { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: 1.05rem; margin: 0; padding: var(--space-2) var(--space-4); border-radius: 999px; background: var(--surface-alt); }
.status-change__icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--text-muted); color: #fff; font-weight: 700; }
.status-change--up { background: var(--status-good-soft); color: #0b6b3e; }
.status-change--up .status-change__icon { background: #12b76a; font-size: 1.1rem; }
.status-change--down { background: var(--status-bad-soft); color: #8a1c13; }
.status-change--down .status-change__icon { background: #d92d20; }
.rank-exact { font-size: 1.6rem; margin: 0; }
.band-meter { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: var(--space-3); }
.band-meter__step { text-align: center; padding: var(--space-2) 0; border-radius: var(--radius); background: var(--surface-alt); color: var(--text-muted); font-weight: 600; font-size: .95rem; }
.band-meter__step.is-current { color: #fff; transform: scale(1.06); box-shadow: 0 2px 8px rgba(16, 24, 40, .2); }
.band-meter__step--low.is-current { background: #d92d20; }
.band-meter__step--mid.is-current { background: #f79009; }
.band-meter__step--high.is-current { background: #12b76a; }
.tip-card__weak { margin: 0 0 var(--space-3); }
.btn--big { min-height: 56px; font-size: 1.15rem; }
.sparkline { width: 100%; height: auto; }
.sparkline__grid { stroke: var(--border); stroke-dasharray: 4 4; }
.sparkline__line { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linejoin: round; }
.sparkline__dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.sparkline__dot.is-last { fill: var(--brand); }
.sparkline__label { font-size: 11px; fill: var(--text-muted); }
.story__speak { margin-top: var(--space-3); }

/* barra in basso dell'app */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabbar__item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-2) 0; color: var(--text-muted); font-size: .85rem; font-weight: 600; min-height: 56px; justify-content: center; }
.tabbar__item span { font-size: 1.2rem; line-height: 1; }
.tabbar__item:hover { text-decoration: none; }
.tabbar__item.is-active { color: var(--brand); }
.story__nav { bottom: 64px; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
/* editor dei modelli di scoring: colonne Parametro | Codice | Nome | Espressione | ... */
/* editor dei modelli di scoring: Parametro (combo, codice, formula) | Nome | Buono | Scarso | Peso | Attivo */
#parameters > tbody > tr > td:nth-child(1) { width: 34%; min-width: 300px; }
#parameters > tbody > tr > td:nth-child(2) { width: 26%; min-width: 200px; }
#parameters > tbody > tr > td:nth-child(2) .input { min-width: 0; width: 100%; }
#parameters > tbody > tr > td:nth-child(n+3) > .input--num { width: 80px; min-width: 0; }
.param-formula { display: grid; grid-template-columns: 1fr; gap: var(--space-1); margin-top: var(--space-2); }
.param-formula label { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: var(--space-2); font-size: .85rem; color: var(--text-muted); }
.param-formula .input { min-width: 0; width: 100%; }
.param-formula .input[readonly] { background: var(--surface-alt); color: var(--text-muted); }
#parameters .indicator-cell .field__hint { max-width: none; margin: var(--space-1) 0 0; }
.evaluation-cell { min-width: 230px; }
.evaluation-linear { display: grid; gap: var(--space-1); margin-top: var(--space-2); }
.evaluation-linear label { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: var(--space-2); font-size: .85rem; color: var(--text-muted); }
.score-bands { margin: var(--space-2) 0 var(--space-1); width: auto; min-width: 0; }
.score-bands th, .score-bands td { padding: 2px 4px; }
.score-bands .input, .table--form .score-bands td .input { min-height: 32px; width: 68px; min-width: 0; }
.evaluation-cell .field__hint { max-width: 260px; }

/* ---------- Report Status dell'autista (DEC-75) ---------- */
.small-link { font-size: .8rem; }
.status-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-4); margin: var(--space-4) 0; }
.status-header h2 { margin: 0 0 var(--space-2); }
.status-header__score { text-align: right; }
.status-header__badge { font-size: 1.6rem; padding: 4px 16px; }
.status-group { font-size: 1.15rem; margin: var(--space-5) 0 var(--space-3); }
.status-grid { margin-top: 0; }
.status-section__title { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); font-size: 1rem; margin: 0 0 var(--space-2); }
.status-section__table { width: 100%; }
.status-section__table th { text-align: left; font-weight: 500; color: var(--text-muted); }
.status-section__note th { color: var(--text); font-weight: 700; }
.status-section .field__hint { margin: var(--space-2) 0 0; }
@media print {
    .status-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .status-section { break-inside: avoid; padding: 8px; box-shadow: none; }
    .status-group { margin: 12px 0 6px; }
}

/* dati di accesso dell'autista (console) */
.access-kv dd { font-size: 1.1rem; }
.access-message { font-family: inherit; line-height: 1.5; }
.print-only { display: none; }
@media print {
    .topbar, .sidenav, .no-print { display: none !important; }
    .print-only { display: block; }
    .shell { display: block; }
    .main { padding: 0; max-width: none; }
}
.record-payment { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.record-payment .input { width: auto; min-height: 36px; }
.pay-methods { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.pay-methods form { margin: 0; }
.stat__value--sm { font-size: 1.5rem; }
.text-bad { color: #b42318; font-weight: 600; }

/* copia di cortesia delle fatture (fase 18) */
.invoice-head { display: flex; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; margin: var(--space-4) 0; line-height: 1.5; }
.invoice-customer { min-width: 280px; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); }
.invoice-lines { margin: var(--space-4) 0; }
.invoice-test { background: #fde8e7; color: #8a1c13; font-weight: 700; text-align: center; padding: var(--space-2); border-radius: var(--radius); }
.inline-details { display: inline-block; }
.inline-details[open] form { position: absolute; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); min-width: 260px; box-shadow: 0 6px 20px rgba(16,24,40,.12); }
.inline-details summary { list-style: none; cursor: pointer; }
.table--compact th, .table--compact td { padding: 4px 8px; font-size: .85rem; }
details > .table--compact { margin-top: var(--space-2); }
label.check { display: flex; align-items: center; gap: var(--space-2); margin: 4px 0; font-weight: 400; }
fieldset.field { border: 0; padding: 0; margin: 0 0 var(--space-3); }
fieldset.field legend { font-weight: 600; margin-bottom: var(--space-1); }
.toolbar-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3); margin-bottom: var(--space-4); }
.toolbar-form .field { margin: 0; min-width: 200px; }

/* testo lungo (informativa privacy nell'app) */
.prose h2 { font-size: 1.05rem; margin: 1.2em 0 .4em; }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 1.2em; margin: .4em 0; }
.prose li { margin: .2em 0; }

/* tabella che può scorrere in orizzontale senza la cornice di .table-wrap (es. righe della fattura) */
.scroll-x { overflow-x: auto; }
