:root {
    --ink: #0a2540;
    --ink-soft: #425466;
    --muted: #6b7c93;
    --line: #e6ebf1;
    --surface: #ffffff;
    --surface-soft: #f6f9fc;
    --primary: #635bff;
    --primary-dark: #4b45d6;
    --cyan: #00d4ff;
    --success: #0e9f6e;
    --danger: #df1b41;
    --shadow: 0 16px 40px rgba(50, 50, 93, .09), 0 4px 12px rgba(0, 0, 0, .04);
    --radius: 18px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--surface-soft);
    color: var(--ink);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Manrope, Inter, sans-serif; letter-spacing: -.035em; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.08; }
h2 { margin-bottom: 0; font-size: 1.35rem; }

.ambient { position: fixed; z-index: -1; border-radius: 999px; filter: blur(1px); pointer-events: none; }
.ambient-one { width: 460px; height: 460px; top: -300px; right: -80px; background: radial-gradient(circle, rgba(99,91,255,.17), rgba(99,91,255,0) 70%); }
.ambient-two { width: 360px; height: 360px; top: 420px; left: -260px; background: radial-gradient(circle, rgba(0,212,255,.11), rgba(0,212,255,0) 70%); }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 24px 0;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--primary), #7a73ff 60%, var(--cyan)); color: white; box-shadow: 0 8px 18px rgba(99,91,255,.25); font-family: Manrope, sans-serif; font-weight: 800; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-family: Manrope, sans-serif; letter-spacing: -.025em; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.brand-light { color: white; }
.brand-light .brand-copy small { color: rgba(255,255,255,.65); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions form { margin: 0; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 18px auto 80px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin: 38px 0 34px; }
.hero-subtitle { max-width: 620px; margin-bottom: 0; color: var(--muted); font-size: 1.03rem; }
.eyebrow { margin-bottom: 9px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow-light { color: #7fe8ff; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: linear-gradient(135deg, var(--primary), #766cff); color: white; box-shadow: 0 8px 18px rgba(99,91,255,.23); }
.button-primary:hover { box-shadow: 0 11px 24px rgba(99,91,255,.3); }
.button-secondary { border: 1px solid #d8e0e9; background: white; color: var(--ink); }
.button-secondary:hover, .button-ghost:hover { background: #eef3f8; }
.button-ghost { background: transparent; color: var(--ink-soft); }
.button-link { min-height: 38px; padding: 0 8px; color: var(--primary); }
.button-compact { min-height: 38px; padding: 0 14px; font-size: 13px; }
.button-wide { width: 100%; margin-top: 5px; }

.grand-total-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 34px; }
.grand-total-card { position: relative; overflow: hidden; padding: 26px; border: 1px solid rgba(255,255,255,.7); border-radius: var(--radius); color: white; box-shadow: var(--shadow); }
.grand-total-card::after { position: absolute; width: 200px; height: 200px; top: -125px; right: -70px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; box-shadow: 0 0 0 28px rgba(255,255,255,.05), 0 0 0 58px rgba(255,255,255,.03); content: ""; }
.total-monthly { background: linear-gradient(125deg, #0a2540, #263e84 75%, #536dfe); }
.total-onetime { background: linear-gradient(125deg, #4b45d6, #635bff 65%, #8a84ff); }
.total-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.metric-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.14); }
.metric-label { color: rgba(255,255,255,.8); font-size: 13px; font-weight: 600; }
.grand-total-card > strong { display: block; margin-bottom: 7px; font-family: Manrope, sans-serif; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -.04em; }
.metric-caption { color: rgba(255,255,255,.6); font-size: 12px; }

.status-section { margin-bottom: 34px; }
.section-heading, .list-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.section-heading .eyebrow, .list-header .eyebrow { margin-bottom: 5px; }
.section-hint, .result-count { color: var(--muted); font-size: 12px; }
.status-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.status-card { padding: 18px; border: 1px solid var(--line); border-top: 3px solid var(--status-color); border-radius: 14px; background: rgba(255,255,255,.9); box-shadow: 0 6px 18px rgba(50,50,93,.045); }
.status-card-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.status-card-heading strong { font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-color); }
.status-count { display: grid; place-items: center; min-width: 22px; height: 22px; margin-left: auto; padding: 0 6px; border-radius: 99px; background: var(--status-bg); color: var(--status-color); font-size: 11px; font-weight: 700; }
.status-amount { display: flex; justify-content: space-between; gap: 6px; padding-top: 9px; border-top: 1px solid #edf1f5; }
.status-amount + .status-amount { margin-top: 9px; }
.status-amount span { color: var(--muted); font-size: 10px; }
.status-amount strong { font-size: 11px; white-space: nowrap; }
.status-pagato { --status-color: #0e9f6e; --status-bg: #e7f8f1; }
.status-confermato { --status-color: #635bff; --status-bg: #eeedff; }
.status-forse { --status-color: #d97706; --status-bg: #fff5dc; }
.status-rimandato { --status-color: #66758a; --status-bg: #edf1f5; }
.status-rifiutato { --status-color: #df1b41; --status-bg: #fff0f3; }

.list-card, .form-card { border: 1px solid rgba(230,235,241,.9); border-radius: var(--radius); background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.list-header { margin: 0; padding: 24px 26px 18px; }
.filters { display: flex; align-items: center; gap: 10px; padding: 0 26px 20px; border-bottom: 1px solid var(--line); }
.filters select { width: auto; min-width: 175px; }
.search-field { position: relative; flex: 1; }
.search-field > span { position: absolute; top: 50%; left: 14px; color: var(--muted); font-size: 20px; transform: translateY(-53%); pointer-events: none; }
.search-field input { padding-left: 41px; }
input, select, textarea { width: 100%; border: 1px solid #d8e0e9; border-radius: 10px; outline: none; background: white; color: var(--ink); transition: border .16s ease, box-shadow .16s ease; }
input, select { height: 44px; padding: 0 13px; }
textarea { min-height: 110px; padding: 12px 13px; line-height: 1.55; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9aa8b6; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,91,255,.12); }
.is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(223,27,65,.08) !important; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 18px; background: #fbfcfe; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #fbfcff; }
.text-right { text-align: right; }
.collaboration-name { display: block; margin-bottom: 3px; color: var(--ink); font-weight: 650; text-decoration: none; }
.collaboration-name:hover { color: var(--primary); }
.collaboration-description { display: block; max-width: 320px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.money-cell { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 99px; background: var(--status-bg); color: var(--status-color); font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-pill > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.deadline { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; white-space: nowrap; }
.deadline small { margin-top: 1px; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.deadline-overdue { color: var(--danger); }
.deadline-today { color: #d97706; }
.deadline-upcoming { color: var(--primary); }
.deadline-neutral { color: var(--muted); }
.actions-cell { display: flex; justify-content: flex-end; gap: 4px; }
.actions-cell form { margin: 0; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.icon-button:hover { background: #edf1f5; color: var(--ink); }
.icon-button-danger:hover { background: #fff0f3; color: var(--danger); }

.empty-state { padding: 65px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 16px; background: #eeedff; color: var(--primary); font-size: 25px; }
.empty-state h3 { margin-bottom: 7px; }
.empty-state p { margin-bottom: 20px; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-top: 1px solid var(--line); }
.pagination-link { color: var(--primary); font-size: 12px; font-weight: 600; text-decoration: none; }
.pagination-link.is-disabled { color: #aab5c0; }
.pagination-info { color: var(--muted); font-size: 11px; }

.flash { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; padding: 13px 16px; border: 1px solid; border-radius: 12px; font-size: 13px; }
.flash-success { border-color: #bdebd9; background: #effbf7; color: #087653; }
.flash-error { border-color: #ffd2dc; background: #fff5f7; color: #b31536; }
.flash-icon { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; background: currentColor; color: white; font-weight: 700; }

.form-page-heading { max-width: 760px; margin: 38px auto 26px; }
.form-page-heading > p:last-child { margin-bottom: 0; color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--primary); }
.form-card { max-width: 760px; margin: 0 auto; padding: 32px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 23px 18px; }
.field-wide { grid-column: 1 / -1; }
.field label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; font-size: 12px; font-weight: 650; }
.field label > span { color: var(--danger); }
.field label small { color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.field-error { margin: 6px 0 0; color: var(--danger); font-size: 11px; }
.money-input { position: relative; }
.money-input > span { position: absolute; z-index: 1; top: 50%; left: 13px; color: var(--muted); transform: translateY(-50%); }
.money-input input { padding-left: 32px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin: 30px -32px -32px; padding: 20px 32px; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); background: #fbfcfe; }

.access-page { overflow-x: hidden; background: #061b2f; }
.access-gradient { position: fixed; inset: 0; background: radial-gradient(circle at 18% 18%, rgba(99,91,255,.38), transparent 36%), radial-gradient(circle at 82% 82%, rgba(0,212,255,.16), transparent 31%), linear-gradient(135deg, #071d33, #0a2540 55%, #172d65); }
.access-gradient::after { position: absolute; inset: 0; opacity: .12; background-image: linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px); background-size: 54px 54px; content: ""; mask-image: linear-gradient(to bottom, black, transparent 80%); }
.access-shell { position: relative; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 450px); align-items: center; gap: clamp(55px, 10vw, 150px); width: min(1100px, calc(100% - 48px)); min-height: 100vh; margin: auto; padding: 50px 0; }
.access-intro { color: white; }
.access-intro .brand { margin-bottom: 100px; }
.access-intro h1 { max-width: 620px; margin-bottom: 22px; font-size: clamp(2.5rem, 5.5vw, 4.4rem); }
.access-intro > p:last-child { max-width: 510px; color: rgba(255,255,255,.63); font-size: 1.05rem; }
.access-card { position: relative; padding: 38px; border: 1px solid rgba(255,255,255,.55); border-radius: 22px; background: rgba(255,255,255,.97); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.access-card-icon { display: grid; place-items: center; width: 45px; height: 45px; margin-bottom: 28px; border-radius: 13px; background: linear-gradient(135deg, var(--primary), #8b86ff); color: white; font-size: 20px; box-shadow: 0 10px 22px rgba(99,91,255,.25); }
.access-card h2 { margin-bottom: 8px; font-size: 1.8rem; }
.muted { color: var(--muted); }
.access-card > .muted { margin-bottom: 27px; font-size: 13px; }
.access-form label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 650; }
.access-form input { height: 50px; font-size: 20px; letter-spacing: .28em; }
.access-footnote { margin: 23px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.access-footnote span { margin-right: 4px; color: var(--success); font-size: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; margin: -1px; padding: 0; border: 0; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 980px) {
    .status-grid { grid-template-columns: repeat(3, 1fr); }
    .access-shell { grid-template-columns: 1fr 400px; gap: 55px; }
    .access-intro .brand { margin-bottom: 70px; }
}

@media (max-width: 760px) {
    .site-header, .page-shell { width: min(100% - 28px, 1180px); }
    .site-header { padding: 17px 0; }
    .brand-copy { display: none; }
    .hero-row { align-items: flex-start; margin-top: 27px; }
    .hero-button { display: none; }
    .grand-total-grid { grid-template-columns: 1fr; }
    .status-grid { display: flex; overflow-x: auto; margin-right: -14px; padding: 2px 14px 12px 1px; scroll-snap-type: x mandatory; }
    .status-card { flex: 0 0 180px; scroll-snap-align: start; }
    .filters { display: grid; grid-template-columns: 1fr 1fr; padding: 0 16px 17px; }
    .search-field { grid-column: 1 / -1; }
    .filters select { width: 100%; min-width: 0; }
    .filters .button-secondary { grid-column: 1 / -1; }
    .list-header { padding: 20px 16px 15px; }
    .table-wrap { overflow: visible; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { display: none; }
    tbody tr { position: relative; padding: 16px; border-top: 1px solid var(--line); }
    td { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 7px 0; border: 0; text-align: right !important; }
    td::before { color: var(--muted); content: attr(data-label); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
    td:first-child { display: block; padding: 0 75px 12px 0; text-align: left !important; }
    td:first-child::before { display: none; }
    .collaboration-description { white-space: normal; }
    .actions-cell { position: absolute; top: 12px; right: 12px; }
    .actions-cell::before { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .form-card { padding: 22px 18px; }
    .form-actions { margin: 28px -18px -22px; padding: 17px 18px; }
    .form-actions .button { flex: 1; padding: 0 10px; }
    .access-shell { display: flex; flex-direction: column; justify-content: center; width: min(100% - 32px, 460px); padding: 32px 0; }
    .access-intro { width: 100%; }
    .access-intro .brand { margin-bottom: 38px; }
    .access-intro .brand-copy { display: flex; }
    .access-intro h1 { margin-bottom: 10px; font-size: 2.25rem; }
    .access-intro > p:last-child { display: none; }
    .access-card { width: 100%; padding: 28px 23px; }
}

@media (max-width: 430px) {
    .header-actions .button-primary { width: 38px; padding: 0; font-size: 0; }
    .header-actions .button-primary span { font-size: 18px; }
    .grand-total-card { padding: 22px; }
    .filters { grid-template-columns: 1fr; }
    .search-field, .filters .button-secondary { grid-column: auto; }
    .pagination-info { display: none; }
}
