:root {
    --oliva: #4D5033;
    --oliva-scuro: #3E422B;
    --tortora: #8B725A;
    --sabbia: #C7AE94;
    --crema: #DDD0BE;
    --avorio: #F5F0E8;
    --marrone: #514537;
    --bianco: #ffffff;
    --font-testi: Montserrat, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    --font-titoli: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--avorio);
    color: var(--marrone);
    font-family: var(--font-testi);
    font-size: 15px;
    line-height: 1.5;
}

h1 { font-family: var(--font-titoli); font-weight: 600; color: var(--oliva-scuro); margin: 0; font-size: 28px; line-height: 1.15; }
a { color: var(--oliva); }
.muted { color: var(--tortora); margin: 0; font-size: 13px; }

.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 16px;
    padding: 18px 24px; background: var(--bianco); border-bottom: 1px solid var(--crema);
}
.logout { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 20px; }
.brand img { display: block; height: 50px; width: auto; }
.brand h1 { font-size: 24px; }
.login-logo { display: block; width: 180px; height: auto; margin: 0 auto 20px; }
.login-box { text-align: center; }
.login-box form, .login-box label { text-align: left; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 48px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--bianco); border: 1px solid var(--crema); padding: 16px 18px; display: flex; flex-direction: column; }
.tile-n { font-family: var(--font-titoli); font-size: 38px; font-weight: 600; color: var(--oliva-scuro); line-height: 1; }
.tile-l { font-size: 12px; color: var(--tortora); margin-top: 6px; letter-spacing: 0.04em; text-transform: uppercase; }

.filters {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    background: var(--bianco); border: 1px solid var(--crema); padding: 16px; margin-bottom: 16px;
}
.filters > div { display: flex; flex-direction: column; min-width: 150px; }
.filters .grow { flex: 1 1 220px; }
.filters .actions { flex-direction: row; gap: 8px; align-items: center; min-width: 0; }

label { font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--oliva-scuro); }
input, select {
    height: 42px; padding: 0 12px; font: inherit; color: var(--marrone);
    background: var(--bianco); border: 1px solid var(--sabbia); border-radius: 2px; width: 100%;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--oliva); outline-offset: 2px; }

button, .btn, .btn-ghost, .btn-small {
    font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
    border-radius: 2px; border: 1px solid var(--oliva-scuro); display: inline-flex; align-items: center; justify-content: center;
}
button, .btn { height: 42px; padding: 0 18px; background: var(--oliva-scuro); color: var(--avorio); }
button:hover, .btn:hover { background: var(--oliva); }
.btn-ghost { height: 42px; padding: 0 16px; background: transparent; color: var(--oliva-scuro); }
.btn-ghost:hover { background: var(--crema); }
.btn-small { height: 34px; padding: 0 12px; font-size: 13px; background: var(--bianco); color: var(--oliva-scuro); }
.btn-small:hover { background: var(--crema); }
.btn-wa { background: var(--oliva-scuro); color: var(--avorio); }
.btn-wa:hover { background: var(--oliva); }

.listhead { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 12px; }
.listhead p { margin: 0; }

.table-wrap { background: var(--bianco); border: 1px solid var(--crema); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--tortora); padding: 12px 14px; border-bottom: 1px solid var(--crema); background: var(--avorio); }
td { padding: 12px 14px; border-bottom: 1px solid var(--crema); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.sub { display: block; font-size: 12px; color: var(--tortora); }
.contact { white-space: nowrap; }
.contact .phone { display: block; font-size: 13px; margin-bottom: 6px; }
.contact .btn-small + .btn-small { margin-left: 6px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 18px; }
.empty { background: var(--bianco); border: 1px solid var(--crema); padding: 28px; text-align: center; color: var(--tortora); }

.alert { background: #f3e1d8; border: 1px solid #c98f78; color: #6b2f1c; padding: 10px 14px; margin: 0 0 16px; }

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-box { background: var(--bianco); border: 1px solid var(--crema); padding: 32px 28px; width: 100%; max-width: 400px; }
.login-box h1 { margin-bottom: 4px; }
.login-box .muted { margin-bottom: 20px; }
.login-box label { display: block; margin-top: 14px; }
.login-box button { width: 100%; margin-top: 20px; }

@media (max-width: 860px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .topbar { padding: 14px 16px; }
    h1 { font-size: 24px; }
    .brand { gap: 12px; }
    .brand img { height: 38px; }
    .brand h1 { font-size: 19px; }
    .brand .muted { display: none; }
    .logout .muted { display: none; }

    .table-wrap { background: transparent; border: 0; overflow: visible; }
    thead { display: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    tr { background: var(--bianco); border: 1px solid var(--crema); margin-bottom: 12px; padding: 6px 0; }
    td { display: flex; justify-content: space-between; gap: 16px; padding: 8px 14px; border: 0; text-align: right; }
    td::before { content: attr(data-label); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--tortora); text-align: left; flex: 0 0 auto; }
    td .sub { text-align: right; }
    .contact { white-space: normal; flex-wrap: wrap; justify-content: flex-end; }
    .contact .phone { width: 100%; margin-bottom: 8px; }
    .btn-small { height: 44px; padding: 0 16px; }
}

@media (max-width: 480px) {
    .filters > div { min-width: 100%; }
    .filters .actions { width: 100%; }
    .filters .actions button { flex: 1; }
    .listhead { flex-direction: column; align-items: stretch; gap: 10px; }
}
