/*
 * Marotta & Cafiero - Programma editoriale
 * Design: "Font definitivo" approvato il 23/11/2026.
 * Inter come unico carattere; oro #EBC140 e nero #000000; pagine bianche.
 * Regola: sull'oro il testo e' sempre nero; l'oro non si usa mai come colore del testo su bianco.
 */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/inter-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;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("fonts/inter-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;
}

:root {
    --gold: #ebc140;
    --gold-hover: #dcb12f;
    --black: #000;
    --white: #fff;
    --ink: #111;
    --ink-soft: #3a3a3a;
    --muted: #5e5e5e;
    --line: #e4e1d8;
    --line-strong: #cfcabd;
    --surface: #f7f6f2;
    --surface-strong: #efede6;

    --ok-bg: #e5f2e9;
    --ok-ink: #1d6a39;
    --warn-bg: #fdf0d3;
    --warn-ink: #7a5200;
    --late-bg: #fbe3e3;
    --late-ink: #a11d1d;
    --info-bg: #ecebe6;
    --info-ink: #4a4a4a;

    --radius: 8px;
    --radius-small: 6px;
    --shadow: 0 1px 2px rgb(0 0 0 / 6%);
    --page-width: 1320px;
    --gutter: 24px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--white);
    color: var(--ink);
    font-family: "Inter", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
}

a {
    color: inherit;
}

h1, h2, h3 {
    margin: 0;
    color: var(--black);
    line-height: 1.2;
}

/* Titolo pagina 28px Bold */
h1, .page-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Titolo sezione 20px Semibold */
h2, .section-title {
    font-size: 20px;
    font-weight: 600;
}

h3 {
    font-size: 16px;
    font-weight: 600;
}

/* Etichette 12px Semibold maiuscolo */
.label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.muted {
    color: var(--muted);
}

.num, .tabular {
    font-variant-numeric: tabular-nums;
}

/* The page title receives focus after navigation (for screen readers): no visible frame. */
h1:focus {
    outline: none;
}

/* Duotone icons: the fill layer is a light shade of the icon colour unless a component says otherwise. */
svg .duo {
    opacity: 0.25;
}

:focus-visible {
    outline: 2px solid var(--black);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Struttura: barra laterale e barra superiore ----------
   Stessa struttura e stesse animazioni del gestionale AcerPlant: barra laterale scura con sezioni,
   voce attiva con l'indicatore a tre segmenti, barra superiore chiara con il menu utente. */

:root {
    --sidebar-width: 256px;
    --appbar-height: 60px;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    background: var(--black);
    color: #d6d6d6;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--appbar-height);
    padding: 0 20px;
    border-bottom: 1px solid rgb(255 255 255 / 7%);
    color: var(--gold);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-section {
    padding: 18px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgb(255 255 255 / 45%);
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    margin: 2px 0;
    padding: 8px 12px;
    border-radius: 8px;
    color: #cfcfcf;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: currentColor;
}

.nav-item .duo {
    fill: var(--gold);
    opacity: 0.3;
}

.nav-item:hover {
    background: rgb(255 255 255 / 6%);
    color: var(--white);
}

.nav-item:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: -2px;
}

.nav-item-active {
    background: rgb(235 193 64 / 16%);
    color: var(--white);
}

.nav-item-active .duo {
    opacity: 0.7;
}

/* Indicatore della voce attiva: tre segmenti, come in AcerPlant, nell'oro del marchio */
.nav-item-active::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -10px;
    width: 4px;
    height: 22px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(var(--gold) 0 30%, transparent 30% 37%, var(--gold) 37% 63%, transparent 63% 70%, var(--gold) 70%);
    transform: translateY(-50%);
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgb(255 255 255 / 7%);
    color: rgb(255 255 255 / 55%);
    font-size: 12px;
    font-weight: 600;
}

.main {
    min-width: 0;
    margin-left: var(--sidebar-width);
}

.appbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--appbar-height);
    padding: 0 var(--gutter);
    border-bottom: 1px solid var(--line);
    /* Solid background, no backdrop-filter: a filter would trap the fixed layers of the menus inside the bar. */
    background: var(--white);
}

.appbar-spacer {
    flex: 1;
}

.icon-button {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--black);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.icon-button svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.icon-button .duo {
    opacity: 0.25;
}

.icon-button:hover {
    background: var(--surface-strong);
}

.appbar-brand {
    display: none;
    align-items: center;
    padding: 0 4px;
}

.usermenu {
    position: relative;
}

.avatar-button {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.avatar-button:focus-visible {
    outline: 2px solid var(--black);
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--black);
    color: var(--white);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: inset 0 -3px 0 var(--gold);
}

.menu-dismiss {
    position: fixed;
    inset: 0;
    z-index: 40;
}

.menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 41;
    min-width: 240px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: 0 12px 32px rgb(0 0 0 / 14%);
    transform-origin: top right;
    animation: menu-in 0.15s ease-out;
}

.menu-user {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.menu-user-name {
    font-weight: 700;
}

.menu-user-role {
    color: var(--muted);
    font-size: 13px;
}

.logout {
    margin: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.menu-item svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.menu-item .duo {
    opacity: 0.25;
}

.menu-item:hover,
.menu-item:focus-visible {
    background: var(--surface);
    outline: none;
}

.backdrop {
    display: none;
}

/* ---------- Pagina ---------- */

.page {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 28px var(--gutter) 64px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header .eyebrow {
    margin-bottom: 6px;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.back-link:hover {
    color: var(--black);
}

/* ---------- Pulsanti 14px Semibold ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.btn, .chip, .input, .select {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gold);
    color: var(--black);
}

.btn-primary:hover:not(:disabled) {
    background: var(--gold-hover);
}

.btn-dark {
    background: var(--black);
    color: var(--white);
}

.btn-secondary {
    background: var(--white);
    border-color: var(--line-strong);
    color: var(--black);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--black);
}

.btn-danger {
    background: var(--white);
    border-color: #e3b4b4;
    color: var(--late-ink);
}

.btn-danger:hover:not(:disabled) {
    background: var(--late-bg);
}

.btn-link {
    min-height: auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--black);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn-small {
    min-height: 30px;
    padding: 4px 10px;
    font-size: 13px;
}

/* ---------- Riquadri ---------- */

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.card-note {
    margin: 4px 0 0;
}

.card-body {
    padding: 20px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    padding: 16px 18px;
}

.stat-label {
    color: var(--muted);
    font-size: 14px;
}

/* Numeri grandi 24px Bold */
.stat-value {
    margin-top: 4px;
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-late .stat-value {
    color: var(--late-ink);
}

.stat-risk .stat-value {
    color: var(--warn-ink);
}

button.stat {
    width: 100%;
    font: inherit;
    text-align: left;
    color: inherit;
    cursor: pointer;
}

button.stat {
    transition: border-color 0.15s ease, transform 0.15s ease;
}

button.stat:hover {
    border-color: var(--black);
    transform: translateY(-1px);
}

button.stat.selected {
    border-color: var(--black);
    box-shadow: inset 0 0 0 1px var(--black);
}

/* ---------- Filtri ---------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.toolbar .select {
    width: auto;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 6px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--white);
    color: var(--black);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.chip:hover {
    border-color: var(--black);
}

.chip[aria-pressed="true"] {
    background: var(--black);
    border-color: var(--black);
    color: var(--white);
}

/* ---------- Moduli ---------- */

.input, .select, textarea.input {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-small);
    background: var(--white);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
}

.input:focus, .select:focus {
    outline: 2px solid var(--black);
    outline-offset: 0;
    border-color: var(--black);
}

.input.invalid, .select.invalid {
    border-color: var(--late-ink);
}

.search {
    width: 260px;
}

.input.input-s {
    width: 90px;
}

.input.input-name {
    min-width: 260px;
}

.input.input-xs {
    width: 70px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}

.plain-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.narrow {
    max-width: 820px;
}

.form-card {
    margin-bottom: 24px;
}

.form-grid .wide {
    grid-column: 1 / -1;
}

.field label, .field .field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* A checkbox label inside a field keeps the normal text style. */
.field label.check {
    display: inline-flex;
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
    color: var(--ink);
}

.field-hint {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--black);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.validation-message {
    margin-top: 4px;
    color: var(--late-ink);
    font-size: 13px;
}

/* ---------- Tabelle 14px, numeri a larghezza fissa ---------- */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.table th {
    padding: 10px 14px;
    border-bottom: 2px solid var(--black);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table tbody tr.row-link {
    cursor: pointer;
}

.table tbody tr.row-link td {
    transition: background-color 0.15s ease;
}

.table tbody tr.row-link:hover td {
    background: var(--surface);
}

.table .month-row td {
    padding: 18px 14px 8px;
    background: var(--white);
    border-bottom: 1px solid var(--line-strong);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--black);
}

.cell-title {
    font-weight: 600;
    color: var(--black);
    text-decoration: none;
}

.cell-title:hover {
    text-decoration: underline;
}

.cell-sub {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.table .right {
    text-align: right;
}

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

/* ---------- Stati ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge-late { background: var(--late-bg); color: var(--late-ink); }
.badge-info { background: var(--info-bg); color: var(--info-ink); }
.badge-dark { background: var(--black); color: var(--white); }

.badge-outline {
    border: 1px solid var(--line-strong);
    color: var(--ink-soft);
}

.light {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.light::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--line-strong);
}

.light-green::before { background: #2e8b4f; }
.light-yellow::before { background: var(--gold); }
.light-red::before { background: #c62f2f; }
.light-off::before { background: #111; }

/* Avanzamento: un segmento per passo, come la barra della bozza */
.progress {
    display: flex;
    gap: 3px;
    width: 120px;
}

.progress span {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: var(--surface-strong);
}

.progress span.done {
    background: var(--black);
}

.progress span.current {
    background: var(--gold);
}

.phase {
    margin-top: 6px;
    font-size: 13px;
    color: var(--ink-soft);
}

/* ---------- Avvisi ---------- */

.alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-small);
    font-size: 14px;
}

/* An alert with an action button next to the text. */
.alert-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.alert-error { background: var(--late-bg); color: var(--late-ink); }
.alert-success { background: var(--ok-bg); color: var(--ok-ink); }
.alert-warn { background: var(--warn-bg); color: var(--warn-ink); }
.alert-info { background: var(--info-bg); color: var(--info-ink); }

/* ---------- Scheda libro ---------- */

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}

.detail-main {
    display: grid;
    gap: 24px;
}

.detail-side {
    position: sticky;
    top: 88px;
    display: grid;
    gap: 16px;
}

.summary-list {
    display: grid;
    gap: 14px;
    margin: 0;
}

.summary-list dt {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.summary-list dd {
    margin: 2px 0 0;
    font-size: 15px;
}

.steps {
    margin: 0;
    padding: 0;
    list-style: none;
}

.step {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.step:last-child {
    border-bottom: 0;
}

.step.done .step-name {
    color: var(--muted);
}

.step-check input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--black);
    cursor: pointer;
}

.step-dot {
    display: block;
    width: 12px;
    height: 12px;
    margin: 6px 0 0 4px;
    border: 2px solid var(--line-strong);
    border-radius: 50%;
}

.step-name {
    font-weight: 600;
    color: var(--black);
}

.step-description {
    margin-top: 2px;
    color: var(--ink-soft);
    white-space: pre-line;
}

.book-list {
    display: grid;
    gap: 14px;
    margin: 14px 0 8px;
    padding: 0;
    list-style: none;
}

.book-list .progress {
    margin-top: 6px;
}

.step-meta {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.step-side {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px 12px;
}

.step-date {
    min-width: 84px;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.step-edit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.step-edit .input {
    width: 160px;
}

.derived {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius-small);
}

.derived dt {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.derived dd {
    margin: 2px 0 0;
    font-weight: 600;
}

.votes {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

/* ---------- Finestre modali (come AcerPlant) ----------
   Sfondo scuro che compare in 0,15 s, finestra che si ingrandisce da 0,5 a 1 in 0,1 s
   (le stesse animazioni delle finestre di MudBlazor usate in AcerPlant). */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.modal-scrim {
    position: absolute;
    inset: 0;
    background: rgb(33 33 33 / 50%);
    animation: fade-in 0.15s ease;
}

.modal {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 100%;
    overflow: hidden;
    border-radius: 14px;
    background: var(--white);
    box-shadow: 0 11px 15px -7px rgb(0 0 0 / 20%), 0 24px 38px 3px rgb(0 0 0 / 14%), 0 9px 46px 8px rgb(0 0 0 / 12%);
    animation: open-dialog 0.1s cubic-bezier(0.39, 0.575, 0.565, 1) both;
}

.modal:focus {
    outline: none;
}

.modal-small { max-width: 480px; }
.modal-medium { max-width: 720px; }
.modal-large { max-width: 960px; }

.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--line);
}

.modal-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 11px;
    background: var(--black);
    color: var(--white);
}

.modal-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.modal-icon .duo {
    fill: var(--gold);
    opacity: 0.85;
}

.modal-icon-danger {
    background: var(--late-ink);
}

.modal-icon-danger .duo {
    fill: var(--white);
    opacity: 0.35;
}

.modal-heading-wrap {
    flex: 1;
    min-width: 0;
}

.modal .modal-heading {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.modal-sub {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.modal-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    align-self: flex-start;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.modal-close .duo {
    display: none;
}

.modal-close:hover {
    background: var(--surface-strong);
    color: var(--black);
}

.modal-content {
    flex: 1;
    max-height: calc(100dvh - 220px);
    overflow-y: auto;
    padding: 16px 24px 20px;
}

.modal-content > .field + .field {
    margin-top: 16px;
}

.publisher-rules {
    display: grid;
    gap: 10px;
}

.modal-text {
    margin: 0;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.modal-actions .btn {
    min-height: 42px;
}

.btn-danger-solid {
    background: var(--late-ink);
    color: var(--white);
}

.btn-danger-solid:hover:not(:disabled) {
    background: #861616;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes open-dialog {
    0% { opacity: 0; }
    1% { opacity: 1; transform: scale(0.5); }
    100% { transform: scale(1); }
}

/* ---------- Ricerca rapida (Ctrl+K), come AcerPlant ---------- */

.search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(420px, 100%);
    min-width: 0;
    min-height: 40px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.search-trigger:hover,
.search-trigger:focus-visible {
    border-color: var(--black);
    outline: none;
}

.search-trigger svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: currentColor;
}

.search-trigger .duo {
    opacity: 0.25;
}

.search-label {
    flex: 1;
    overflow: hidden;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.kbd {
    padding: 2px 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--white);
    color: var(--muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
}

.palette-overlay {
    align-items: flex-start;
    padding-top: 10vh;
}

.palette {
    max-width: 640px;
}

.palette-input {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}

.palette-input svg {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    fill: currentColor;
}

.palette-input .duo {
    opacity: 0.25;
}

.palette-input input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 17px;
}

.palette-results {
    max-height: min(420px, 60vh);
    overflow-y: auto;
    padding: 6px 8px 10px;
}

.palette-group {
    padding: 10px 10px 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 46px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.palette-item svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: currentColor;
}

.palette-item .duo {
    fill: var(--gold);
    opacity: 0.5;
}

.palette-item-active {
    background: rgb(235 193 64 / 18%);
}

.palette-item-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.palette-item-title {
    overflow: hidden;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.palette-item-detail {
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.palette-item-go {
    opacity: 0;
}

.palette-item-active .palette-item-go {
    opacity: 0.6;
}

.palette-empty {
    padding: 22px 10px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.only-phone {
    display: none;
}

/* ---------- Accesso ---------- */

.login-page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.login-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    background: var(--black);
    color: var(--white);
}

.login-brand img {
    width: 56px;
    height: 75px;
}

.login-brand h1 {
    margin-top: 28px;
    color: var(--white);
    font-size: 40px;
}

.login-brand .accent {
    display: block;
    color: var(--gold);
}

.login-brand p {
    max-width: 420px;
    color: #bdbdbd;
}

.login-form {
    display: grid;
    align-content: center;
    padding: 48px;
}

.login-form form {
    width: min(400px, 100%);
    display: grid;
    gap: 16px;
}

/* ---------- Telefono e tablet ---------- */

@media (max-width: 1100px) {
    .detail-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .detail-side {
        position: static;
        order: -1;
    }

    .detail-layout.side-last .detail-side {
        order: 0;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    :root {
        --gutter: 16px;
    }

    /* La barra laterale diventa un cassetto che entra da sinistra sopra la pagina */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .shell.nav-open .sidebar {
        transform: none;
        box-shadow: 0 0 40px rgb(0 0 0 / 35%);
    }

    .backdrop {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: block;
        background: rgb(0 0 0 / 40%);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .shell.nav-open .backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .main {
        margin-left: 0;
    }

    .icon-button {
        display: inline-grid;
    }

    .appbar-brand {
        display: inline-flex;
    }

    .page {
        padding-top: 20px;
    }

    h1, .page-title {
        font-size: 24px;
    }

    .search {
        width: 100%;
    }

    .page-actions {
        width: 100%;
    }

    .form-grid, .derived {
        grid-template-columns: minmax(0, 1fr);
    }

    .votes {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .step {
        grid-template-columns: 28px minmax(0, 1fr);
        padding: 14px 16px;
    }

    .step-side {
        grid-column: 2;
        justify-content: flex-start;
    }

    .step-date {
        min-width: 0;
        text-align: left;
    }

    .step-edit {
        justify-content: flex-start;
    }

    /* La tabella dei titoli diventa un elenco di schede */
    .table.responsive thead {
        display: none;
    }

    .table.responsive tbody tr:not(.month-row) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px 12px;
        padding: 14px 4px;
        border-bottom: 1px solid var(--line);
    }

    .table.responsive td {
        padding: 0;
        border: 0;
    }

    .table.responsive td[data-label]::before {
        content: attr(data-label) " ";
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--muted);
    }

    .table.responsive td.span-2 {
        grid-column: 1 / -1;
    }

    .login-page {
        grid-template-columns: minmax(0, 1fr);
    }

    .login-brand {
        padding: 28px 20px;
    }

    .login-brand h1 {
        font-size: 30px;
    }

    .login-form {
        padding: 28px 20px 48px;
    }
}

@media (max-width: 600px) {
    /* Finestre modali a schermo intero sul telefono, come in AcerPlant */
    .modal-overlay {
        padding: 0;
    }

    .modal-overlay:not(.palette-overlay) .modal {
        max-width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .modal-header {
        padding: 14px 16px 12px;
    }

    .modal-content {
        max-height: none;
        padding: 12px 16px 16px;
    }

    .modal-actions {
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .modal-actions .btn {
        flex: 1 1 auto;
    }

    .palette-overlay {
        padding: 8px;
    }

    .search-trigger {
        width: auto;
        flex: 1;
    }

    .search-trigger .kbd,
    .not-phone {
        display: none;
    }

    .only-phone {
        display: inline;
    }
}

@media (max-width: 520px) {
    .stats {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 10px;
    }

    .stat {
        padding: 12px 14px;
    }
}

/* ---------- Animazioni (brevi, come in AcerPlant) ---------- */

@keyframes comparsa {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes menu-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Ogni pagina entra con una comparsa leggera */
.page {
    animation: comparsa 0.2s ease-out;
}

.alert,
.form-card,
.step-edit {
    animation: comparsa 0.18s ease-out;
}

.step {
    transition: background-color 0.15s ease;
}

.step-name {
    transition: color 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------- Errore del circuito (Blazor) ---------- */

#blazor-error-ui {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 1000;
    display: none;
    padding: 14px 18px;
    background: var(--late-bg);
    border-radius: var(--radius-small);
    color: var(--late-ink);
    box-shadow: 0 4px 16px rgb(0 0 0 / 15%);
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
}

#blazor-error-ui .reload {
    margin-left: 8px;
    font-weight: 600;
}
