:root {
    --bg: #f2f5f6;
    --surface: #ffffff;
    --surface-soft: #f7f9fa;
    --ink: #17242d;
    --muted: #687780;
    --line: #dfe6e9;
    --brand: #17242d;
    --accent: #33b98b;
    --accent-dark: #168264;
    --danger: #d84d5c;
    --warning: #d9a52e;
    --shadow: 0 10px 30px rgba(23, 36, 45, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px max(16px, env(safe-area-inset-left));
    background: rgba(23, 36, 45, .96);
    color: white;
    backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-size: 1.1rem; font-weight: 900; letter-spacing: .08em; }
.brand-subtitle { font-size: .75rem; opacity: .62; text-transform: uppercase; letter-spacing: .12em; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-copy { text-align: right; font-size: .82rem; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
    width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.16); border-radius: 12px;
    background: rgba(255,255,255,.08); color: white; cursor: pointer; font-size: 1.1rem;
}
.main-content { width: min(1120px, 100%); margin: 0 auto; padding: 24px 16px 40px; }
.main-content.with-nav { padding-bottom: 104px; }

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px rgba(23, 36, 45, .08);
    scrollbar-width: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-item {
    flex: 1 0 68px;
    min-width: 68px;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 13px;
    color: #5f6f78;
    font-size: .68rem;
    font-weight: 700;
}
.nav-item:active { background: #eaf2f0; color: var(--accent-dark); }
.nav-symbol { font-size: 1.16rem; line-height: 1; }

.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 22px; }
.page-head.compact { margin-bottom: 14px; }
.eyebrow { margin: 0 0 5px; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .13em; font-weight: 800; font-size: .72rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(1.85rem, 6vw, 3rem); line-height: 1; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -.025em; }
h3 { margin-bottom: 0; }
.page-subtitle, .muted-line { color: var(--muted); }
.page-subtitle { margin-bottom: 0; }
.muted-line { margin: 5px 0 0; font-size: .84rem; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.summary-card {
    position: relative;
    min-height: 118px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.summary-card::after {
    content: "";
    position: absolute;
    width: 70px; height: 70px;
    right: -22px; bottom: -30px;
    border-radius: 50%;
    background: rgba(51,185,139,.16);
}
.summary-card strong { font-size: 2rem; line-height: 1; letter-spacing: -.04em; }
.summary-label { color: var(--muted); font-size: .84rem; font-weight: 700; }

.section-block { margin-top: 24px; }
.section-title-row { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 12px; }
.text-link { color: var(--accent-dark); font-size: .86rem; font-weight: 800; }
.card-list { display: grid; gap: 12px; }
.card-list.list-page { margin-top: 14px; }
.practice-card, .client-card {
    display: block;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 5px 20px rgba(23,36,45,.055);
    transition: transform .15s ease, border-color .15s ease;
}
.practice-card:active, .client-card:active { transform: scale(.992); border-color: #b9ccc5; }
.practice-card-top, .client-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.practice-card h3, .client-card h3 { margin-top: 4px; font-size: 1.07rem; line-height: 1.25; }
.practice-code { color: var(--accent-dark); font-size: .74rem; font-weight: 900; letter-spacing: .08em; }
.status-badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.status-badge.large { min-height: 32px; padding-inline: 12px; }
.status-order { color: #0f7157; background: #dcf6ed; }
.status-proposal { color: #725512; background: #fff0c7; }
.status-withdrawal { color: #365d89; background: #e1edfb; }
.status-archived { color: #6c7377; background: #e9edef; }
.status-neutral { color: #5d6670; background: #edf0f2; }
.practice-meta-grid, .client-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    margin-top: 14px;
    color: var(--ink);
    font-size: .86rem;
}
.practice-meta-grid span, .client-meta span { min-width: 0; overflow-wrap: anywhere; }
.practice-meta-grid small, .client-meta small { display: block; margin-bottom: 3px; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
.readiness-line { display: flex; align-items: center; gap: 7px; margin-top: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c5cdd1; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 4px rgba(51,185,139,.12); }
.dot.ko { background: var(--danger); }
.dot.warn { background: var(--warning); }
.tag-row, .hero-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.mini-tag, .count-pill {
    display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px;
    background: #edf2f3; color: #50616a; font-size: .69rem; font-weight: 800;
}
.mini-tag.accent { background: #ddf6ed; color: var(--accent-dark); }
.mini-tag.sold { background: #e4f7e9; color: #28733e; }

.type-tabs, .status-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.type-tabs::-webkit-scrollbar, .status-tabs::-webkit-scrollbar { display: none; }
.type-tabs { margin-bottom: 12px; }
.status-tabs { margin: 12px 0; }
.type-tabs a, .status-tabs a {
    flex: 0 0 auto;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: .8rem;
    font-weight: 800;
}
.type-tabs a.active, .status-tabs a.active { background: var(--brand); color: white; border-color: var(--brand); }
.filter-panel {
    display: grid;
    gap: 10px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.search-box {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 13px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 13px;
}
.search-box span { color: var(--muted); font-size: 1.15rem; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.filter-panel select, .form-stack select, .form-stack input {
    width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink); outline: 0;
}
.filter-panel select:focus, .form-stack select:focus, .form-stack input:focus, .search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(51,185,139,.13); }
.primary-button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border: 0;
    border-radius: 13px;
    background: var(--brand);
    color: white;
    font-weight: 850;
    cursor: pointer;
}
.full-width { width: 100%; }

.detail-hero {
    padding: 18px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #17242d, #2c414d);
    color: white;
    border-radius: 22px;
    box-shadow: var(--shadow);
}
.back-link { display: inline-block; margin-bottom: 18px; color: rgba(255,255,255,.72); font-size: .8rem; font-weight: 750; }
.detail-hero-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-hero h1 { margin-bottom: 6px; font-size: clamp(1.75rem, 7vw, 2.7rem); }
.detail-title { margin-bottom: 0; color: rgba(255,255,255,.78); font-size: 1rem; }
.detail-hero .eyebrow { color: #7de0bd; }
.detail-hero .mini-tag { background: rgba(255,255,255,.1); color: white; border: 1px solid rgba(255,255,255,.12); }
.readiness-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.readiness-item { display: grid; grid-template-columns: 10px 1fr; gap: 1px 9px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.readiness-item > span { grid-row: 1 / 3; width: 9px; height: 9px; border-radius: 50%; }
.readiness-item strong { font-size: .78rem; }
.readiness-item small { color: var(--muted); font-size: .65rem; }
.readiness-item.complete > span { background: var(--accent); }
.readiness-item.incomplete > span { background: var(--danger); }
.readiness-item.warning > span { background: var(--warning); }
.detail-section {
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.detail-section summary {
    list-style: none;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    font-weight: 900;
    cursor: pointer;
}
.detail-section summary::-webkit-details-marker { display: none; }
.detail-section summary::after { content: "+"; color: var(--muted); font-size: 1.25rem; font-weight: 500; }
.detail-section[open] summary::after { content: "−"; }
.detail-section[open] summary { border-bottom: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; padding: 4px 16px 12px; }
.detail-grid > div { padding: 11px 0; border-bottom: 1px solid #edf1f2; }
.detail-grid > div:last-child { border-bottom: 0; }
.detail-grid dt { margin-bottom: 4px; color: var(--muted); font-size: .69rem; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.detail-grid dd { margin: 0; line-height: 1.45; overflow-wrap: anywhere; }
.detail-grid a { color: var(--accent-dark); font-weight: 800; }
.pre-line { white-space: pre-line; }
.check-list, .file-list, .timeline { padding: 10px 14px 14px; }
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid #edf1f2; }
.check-item:last-child { border-bottom: 0; }
.check-item span { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: white; font-weight: 900; }
.check-item.checked span { background: var(--accent); }
.check-item.unchecked span { background: var(--danger); }
.check-item p { margin: 2px 0 0; }
.file-row { min-height: 58px; display: grid; grid-template-columns: 36px 1fr 20px; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid #edf1f2; }
.file-row:last-child { border-bottom: 0; }
.file-row strong { display: block; overflow-wrap: anywhere; }
.file-row small { display: block; margin-top: 3px; color: var(--muted); }
.file-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: #edf5f2; color: var(--accent-dark); }
.timeline-item { position: relative; padding: 12px 0 12px 16px; border-left: 2px solid #dce7e3; }
.timeline-item::before { content: ""; position: absolute; left: -6px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.timeline-head time { color: var(--muted); font-size: .72rem; }
.timeline-item p { margin-bottom: 7px; line-height: 1.45; }
.empty-inline { padding: 4px 16px 16px; color: var(--muted); }
.record-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 4px 2px 14px; color: var(--muted); font-size: .7rem; }

.client-card > p { margin: 7px 0 0; color: var(--muted); }
.client-meta span:last-child { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty-card, .empty-state {
    padding: 28px 18px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
}
.empty-state { min-height: 45vh; display: grid; place-items: center; align-content: center; gap: 8px; }
.empty-state.small { min-height: 240px; margin-top: 16px; }
.empty-state h1, .empty-state h2 { color: var(--ink); margin-bottom: 0; }
.empty-state p { margin-bottom: 8px; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 18px 0 4px; font-size: .76rem; }
.pagination a { padding: 10px 8px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); font-weight: 800; }
.pagination a:last-child { text-align: right; }
.pagination span { color: var(--muted); text-align: center; }

.login-body { min-height: 100vh; background: radial-gradient(circle at 20% 10%, #35515e, #17242d 58%, #10191f); }
.login-body .main-content { min-height: 100vh; padding: 18px; display: grid; place-items: center; }
.login-shell { width: min(430px, 100%); }
.login-card { padding: 28px 22px; background: rgba(255,255,255,.97); border-radius: 24px; box-shadow: 0 25px 70px rgba(0,0,0,.28); }
.login-logo { width: 68px; height: 68px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 20px; background: var(--brand); color: white; font-size: 1.25rem; font-weight: 950; letter-spacing: .07em; }
.login-card h1 { margin-bottom: 8px; }
.login-card > p { color: var(--muted); margin-bottom: 22px; }
.form-stack { display: grid; gap: 9px; }
.form-stack label { font-size: .79rem; font-weight: 800; }
.checkbox-line { display: flex; align-items: center; gap: 9px; margin: 5px 0 8px; }
.checkbox-line input { width: 18px; min-height: 18px; }
.validation-summary, .field-error { color: var(--danger); font-size: .78rem; }
.validation-summary:empty, .field-error:empty { display: none; }

@media (min-width: 680px) {
    .main-content { padding-inline: 24px; }
    .summary-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .summary-card { min-height: 128px; }
    .filter-panel { grid-template-columns: minmax(260px, 1fr) auto auto; align-items: center; }
    .filter-panel.single-line { grid-template-columns: 1fr auto; }
    .practice-meta-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
    .detail-grid > div.wide { grid-column: 1 / -1; }
    .readiness-panel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .card-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bottom-nav { left: 50%; right: auto; transform: translateX(-50%); width: min(760px, calc(100% - 24px)); bottom: 12px; border: 1px solid var(--line); border-radius: 18px; padding-bottom: 8px; }
    .main-content.with-nav { padding-bottom: 110px; }
}

@media (min-width: 980px) {
    .card-list.list-page { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .detail-section, .detail-hero, .readiness-panel, .record-meta { max-width: 920px; margin-left: auto; margin-right: auto; }
}

/* =========================================================
   PALETTE CMU
   Nero principale, azzurro e rosso ripresi dal logo
   ========================================================= */

:root {
    --brand: #111417;
    --brand-soft: #20262b;
    --accent: #32a7df;
    --accent-dark: #126d9c;
    --accent-soft: #e1f4fc;
    --secondary: #e44f64;
    --secondary-dark: #a9293c;
    --secondary-soft: #fde8ec;
    /* Il verde rimane solo dove significa "completato/OK" */
    --success: #29a36a;
}

/* Barra superiore */

.topbar {
    min-height: 68px;
    background: rgba(17, 20, 23, .97);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.brand-logo-box {
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    background: #ffffff;
    border-radius: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}

.brand-logo {
    display: block;
    width: clamp(125px, 34vw, 168px);
    max-width: 100%;
    max-height: 35px;
    object-fit: contain;
}

.brand-subtitle {
    color: rgba(255, 255, 255, .65);
}

/* Colori generali */

.eyebrow,
.text-link,
.practice-code,
.detail-grid a {
    color: var(--accent-dark);
}

.nav-item:active {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.filter-panel select:focus,
.form-stack select:focus,
.form-stack input:focus,
.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(50, 167, 223, .15);
}

/* Nuvolette delle card dashboard */

.summary-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 18px;
    right: 18px;
    height: 3px;
    border-radius: 0 0 5px 5px;
    background: var(--accent);
}

.summary-card::after {
    background: rgba(50, 167, 223, .18);
}

.summary-card:nth-child(even)::before {
    background: var(--secondary);
}

.summary-card:nth-child(even)::after {
    background: rgba(228, 79, 100, .17);
}

/* Badge azzurri e rossi */

.status-order,
.status-withdrawal {
    color: #0d658f;
    background: var(--accent-soft);
}

.status-proposal {
    color: var(--secondary-dark);
    background: var(--secondary-soft);
}

.mini-tag.accent,
.count-pill {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.mini-tag.sold {
    color: var(--secondary-dark);
    background: var(--secondary-soft);
}

.file-icon {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

/* Timeline */

.timeline-item {
    border-left-color: #d7ebf4;
}

    .timeline-item::before {
        background: var(--accent);
    }

/* Semafori: verde lasciato soltanto per stato positivo */

.dot.ok {
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(41, 163, 106, .13);
}

.readiness-item.complete > span,
.check-item.checked span {
    background: var(--success);
}

/* Dettaglio pratica */

.detail-hero {
    background: linear-gradient(135deg, #111417, #26323a);
}

    .detail-hero .eyebrow {
        color: #8edbfa;
    }

/* Login */

.login-body {
    background: radial-gradient(circle at 15% 12%, rgba(50, 167, 223, .38), transparent 34%), radial-gradient(circle at 88% 88%, rgba(228, 79, 100, .28), transparent 34%), #111417;
}

.login-logo {
    width: 100%;
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 20px;
    padding: 5px 0;
    background: transparent;
    border-radius: 0;
}

    .login-logo img {
        display: block;
        width: min(260px, 86%);
        max-height: 72px;
        object-fit: contain;
        object-position: left center;
    }

.primary-button {
    background: var(--brand);
}

    .primary-button:active {
        background: var(--brand-soft);
    }

@media (max-width: 430px) {
    .brand-subtitle {
        display: none;
    }

    .brand-logo-box {
        height: 43px;
        padding-inline: 8px;
    }

    .brand-logo {
        width: 132px;
        max-height: 32px;
    }
}