/* ============================================================
   Gestione Incassi Assistenze - Stili
   ============================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #faf8f3;
    --surface: #ffffff;
    --ink: #1a1a1a;
    --muted: #6b6760;
    --line: #e8e4d8;
    --line-strong: #d4d0c4;
    --accent: #1a1a1a;

    --green: #0f7b5e;
    --green-bg: #d4f0e3;
    --yellow: #a16207;
    --yellow-bg: #fef3c7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --orange: #9a3412;
    --orange-bg: #fed7aa;
    --blue: #1e40af;
    --blue-bg: #dbeafe;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.serif {
    font-family: 'Georgia', 'Times New Roman', serif;
}

.mono {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-variant-numeric: tabular-nums;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 32px;
    width: 100%;
}

/* ============= TOPBAR ============= */
.topbar {
    border-bottom: 1px solid var(--ink);
    background: var(--bg);
    padding: 20px 0;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.brand-title {
    font-family: 'Georgia', serif;
    font-size: 24px;
    font-weight: 400;
    letter-spacing: -0.5px;
}

.brand-sub {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    margin-top: 2px;
}

.mainnav {
    display: flex;
    gap: 4px;
}

.mainnav a {
    padding: 8px 14px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.mainnav a:hover {
    color: var(--ink);
}

.mainnav a.active {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
}

.username {
    font-weight: 600;
    color: var(--ink);
}

.btn-link {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 1px;
    transition: color 0.2s;
}

.btn-link:hover {
    color: var(--ink);
}

/* ============= MAIN ============= */
.main-content {
    padding: 32px;
    flex: 1;
}

/* ============= TIPOGRAFIA ============= */
h1.page-title {
    font-family: 'Georgia', serif;
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.page-sub {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 24px;
}

h2.section-title {
    font-family: 'Georgia', serif;
    font-size: 20px;
    font-weight: 400;
    margin-bottom: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

/* ============= FLASH ============= */
.flash {
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    border-left: 3px solid;
}

.flash-success { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.flash-error { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.flash-info { background: var(--blue-bg); border-color: var(--blue); color: var(--blue); }
.flash-warning { background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow); }

/* ============= BOTTONI ============= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: var(--bg);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn:hover { background: #3a3a3a; }

.btn-ghost {
    background: transparent;
    color: var(--ink);
}

.btn-ghost:hover {
    background: var(--ink);
    color: var(--bg);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

.btn-danger {
    border-color: var(--red);
    background: var(--red);
    color: white;
}

.btn-danger:hover {
    background: #991717;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}

.btn-icon-danger:hover {
    background: var(--red);
    border-color: var(--red);
    color: white;
}

/* ============= FORM ============= */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

label.label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    border: 1px solid var(--line-strong);
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--ink);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line-strong);
    background: white;
    max-height: 200px;
    overflow-y: auto;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    padding: 4px;
}

.checkbox-list input[type="checkbox"] {
    cursor: pointer;
}

/* ============= CARDS / PANNELLI ============= */
.card {
    background: white;
    border: 1px solid var(--line);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-body {
    padding: 20px;
}

.card-no-padding {
    background: white;
    border: 1px solid var(--line);
    margin-bottom: 24px;
}

/* ============= STATS ============= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    padding: 20px;
    border: 1px solid var(--line);
}

.stat-card.accent-green { border-left: 3px solid var(--green); }
.stat-card.accent-yellow { border-left: 3px solid var(--yellow); }
.stat-card.accent-red { border-left: 3px solid var(--red); }
.stat-card.accent-orange { border-left: 3px solid var(--orange); }

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-value {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
}

.stat-value.green { color: var(--green); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.red { color: var(--red); }
.stat-value.orange { color: var(--orange); }

.stat-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

/* ============= TABELLE ============= */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    border-bottom: 2px solid var(--ink);
    font-weight: 600;
    white-space: nowrap;
}

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

table tbody tr:hover {
    background: #f4f1e8;
}

table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table .actions {
    text-align: right;
    white-space: nowrap;
}

table .actions .btn-icon {
    margin-left: 4px;
}

table tr.totals {
    background: var(--ink);
    color: var(--bg);
    font-weight: 700;
}

table tr.totals td {
    border-bottom: none;
}

/* ============= BADGE ============= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-pagato { background: var(--green-bg); color: var(--green); }
.badge-parziale { background: var(--blue-bg); color: var(--blue); }
.badge-da_pagare { background: var(--yellow-bg); color: var(--yellow); }
.badge-scaduto { background: var(--red-bg); color: var(--red); }

/* ============= FILTRI ============= */
.filters {
    background: white;
    border: 1px solid var(--line);
    padding: 20px;
    margin-bottom: 24px;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.filters-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    font-weight: 600;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

/* ============= PROGRESS BAR ============= */
.progress {
    background: var(--line);
    height: 8px;
    overflow: hidden;
    margin: 6px 0;
}

.progress-bar {
    height: 100%;
    background: var(--green);
    transition: width 0.3s;
}

.progress-bar.partial { background: var(--blue); }

/* ============= LOGIN ============= */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    background: white;
    border: 1px solid var(--ink);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-family: 'Georgia', serif;
    font-size: 28px;
    margin-bottom: 4px;
}

.login-sub {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    margin-bottom: 32px;
}

/* ============= EMPTY STATE ============= */
.empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.empty-title {
    font-family: 'Georgia', serif;
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 8px;
}

/* ============= FOOTER ============= */
.footer {
    border-top: 1px solid var(--line);
    padding: 20px 0;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============= UTILITIES ============= */
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* ============= RESPONSIVE ============= */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .main-content { padding: 20px 16px; }
    .topbar-inner { flex-direction: column; align-items: flex-start; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    h1.page-title { font-size: 22px; }
    .stat-value { font-size: 22px; }
    .mainnav { flex-wrap: wrap; }
}

/* ============= PRINT ============= */
@media print {
    .topbar, .footer, .btn, .filters, .actions { display: none; }
    .main-content { padding: 0; }
    .card-no-padding { border: none; }
}
