/* Area clienti - sistema visivo
   Pino (registro contabile) su grigio-salvia freddo. Un solo carattere, cifre tabellari per gli importi. */
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-400-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: "Schibsted Grotesk"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-ext-400-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; }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-500-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: "Schibsted Grotesk"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-ext-500-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; }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-600-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: "Schibsted Grotesk"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-ext-600-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; }
@font-face { font-family: "Schibsted Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-700-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: "Schibsted Grotesk"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-ext-700-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 {
  --canvas: #eef2ef;
  --surface: #ffffff;
  --sunken: #f6f8f6;
  --ink: #15201c;
  --muted: #5b6b64;
  --faint: #8a9892;
  --line: #d7dfda;
  --line-strong: #bccac2;
  --pine: #0f4c42;
  --pine-hover: #0b3b33;
  --pine-deep: #0c2a25;
  --mint: #dcefe7;
  --mint-ink: #0f4c42;
  --amber: #a7660b;
  --amber-bg: #fbf0dc;
  --rust: #b42318;
  --rust-bg: #fbe5e2;
  --ok: #1f7a4d;
  --ok-bg: #dff3e7;
  --info: #285b8f;
  --info-bg: #e2edf8;
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 0 rgba(21, 32, 28, .04), 0 8px 24px -16px rgba(21, 32, 28, .25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  font-feature-settings: "ss01";
}
a { color: var(--pine); text-underline-offset: 3px; }
a:hover { color: var(--pine-hover); }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 1em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, td.num, th.num { font-variant-numeric: lining-nums; text-align: right; white-space: nowrap; }
.tnum { font-variant-numeric: lining-nums; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; border-radius: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ---------- Layout comune ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack > * + * { margin-top: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-body { padding: 20px 22px; }
.panel-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-foot { padding: 12px 22px; border-top: 1px solid var(--line); background: var(--sunken); border-radius: 0 0 var(--radius) var(--radius); }
.panel.flat { box-shadow: none; }
.empty { padding: 32px 22px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .93rem; line-height: 1;
  padding: 11px 16px; border-radius: var(--radius-sm); border: 1px solid var(--pine);
  background: var(--pine); color: #fff; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--pine-hover); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); border-color: var(--muted); }
.btn-danger { background: var(--surface); color: var(--rust); border-color: #e7b9b3; }
.btn-danger:hover { background: var(--rust-bg); color: var(--rust); }
.btn-sm { padding: 7px 11px; font-size: .85rem; }
.btn-lg { padding: 14px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--pine); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn.danger { color: var(--rust); }
form.inline { display: inline; }

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: .82rem; margin-top: 5px; }
.field .opt { color: var(--faint); font-weight: 400; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=search], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 42px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px var(--mint); }
input[readonly] { background: var(--sunken); }
.is-invalid { border-color: var(--rust) !important; }
.error { color: var(--rust); font-size: .84rem; margin-top: 5px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .93rem; margin-bottom: 10px; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--pine); flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 16px; }
.form-grid > .c-12 { grid-column: span 12; } .form-grid > .c-8 { grid-column: span 8; }
.form-grid > .c-6 { grid-column: span 6; } .form-grid > .c-4 { grid-column: span 4; }
.form-grid > .c-3 { grid-column: span 3; } .form-grid > .c-2 { grid-column: span 2; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 650; font-size: 1rem; margin-bottom: 12px; padding: 0; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 9px 13px; font-size: .88rem; font-weight: 600; cursor: pointer; border-right: 1px solid var(--line); background: var(--surface); }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--pine); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--pine); outline-offset: -3px; }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--sunken); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcfb; }
.table td.min { width: 1%; white-space: nowrap; }
.table th.num { text-align: right; }
.table .title { font-weight: 600; color: var(--ink); text-decoration: none; }
.table .title:hover { text-decoration: underline; }
.table .sub { color: var(--muted); font-size: .84rem; }
.panel > .table-wrap:first-child table th:first-child { border-top-left-radius: var(--radius); }

/* ---------- Stati ---------- */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; flex: none; }
.st-paid, .st-active, .st-sent, .st-answered, .st-success { color: var(--ok); }
.st-unpaid, .st-pending, .st-queued, .st-customer_reply, .st-scheduled, .st-sending, .st-open { color: var(--amber); }
.st-overdue, .st-suspended, .st-failed, .st-urgent { color: var(--rust); }
.st-cancelled, .st-closed, .st-draft, .st-refunded, .st-expired, .st-transferred { color: var(--faint); }
.st-on_hold, .st-high { color: var(--info); }
.st-low, .st-medium { color: var(--muted); }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--sunken); border: 1px solid var(--line); color: var(--muted); }
.tag.pine { background: var(--mint); border-color: #b9dccd; color: var(--mint-ink); }

/* ---------- Avvisi ---------- */
.alert { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 18px; border: 1px solid; font-size: .94rem; }
.alert-ok { background: var(--ok-bg); border-color: #b7e0c8; color: #14532d; }
.alert-info { background: var(--info-bg); border-color: #bcd3ea; color: #1c3f63; }
.alert-warn { background: var(--amber-bg); border-color: #efd29c; color: #6b4206; }
.alert-error { background: var(--rust-bg); border-color: #efc1bb; color: #7a1a12; }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------- Importi e cifre ---------- */
.figure { font-variant-numeric: lining-nums; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; }
.figure-xl { font-size: 2.6rem; }
.figure-lg { font-size: 1.9rem; }
.figure-md { font-size: 1.35rem; }
.stat { padding: 18px 20px; }
.stat .label { color: var(--muted); font-weight: 500; font-size: .86rem; margin-bottom: 8px; }
.stat .meta { color: var(--muted); font-size: .82rem; margin-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats > .stat + .stat { border-left: 1px solid var(--line); }
.delta-up { color: var(--ok); } .delta-down { color: var(--rust); }

/* ---------- Definizioni ---------- */
dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; font-size: .93rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--pine); border-bottom-color: var(--pine); }
.tabs .count { color: var(--faint); font-weight: 500; margin-left: 4px; }

/* ---------- Filtri ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.filters input, .filters select { min-height: 38px; padding: 7px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chips a { text-decoration: none; font-size: .86rem; font-weight: 600; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted); background: var(--surface); }
.chips a[aria-current="true"] { background: var(--pine); color: #fff; border-color: var(--pine); }
.chips .count { opacity: .75; font-weight: 500; margin-left: 3px; }

/* ---------- Paginazione ---------- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 14px 18px; font-size: .88rem; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.cur { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--surface); }
.pagination span.cur { background: var(--pine); color: #fff; border-color: var(--pine); }

/* ---------- Area clienti: testata ---------- */
.c-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.c-header-in { max-width: 1180px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--pine); color: #fff; display: grid; place-items: center; font-size: .86rem; font-weight: 700; letter-spacing: 0; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; line-height: 1.1; }
.c-nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.c-nav a { padding: 21px 12px 19px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.c-nav a:hover { color: var(--ink); }
.c-nav a[aria-current="page"] { color: var(--pine); border-bottom-color: var(--pine); }
.c-nav .badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--rust); color: #fff; font-size: .72rem; line-height: 18px; text-align: center; margin-left: 4px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; padding: 6px 4px; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--mint); color: var(--mint-ink); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px -12px rgba(0,0,0,.25); min-width: 230px; padding: 6px; z-index: 30; }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; font-size: .92rem; cursor: pointer; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--sunken); }
.user-menu .menu hr { margin: 6px 0; }

/* PIN di supporto: biglietto con bordo perforato */
.pin-stub { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); overflow: hidden; text-decoration: none; color: var(--ink); }
.pin-stub .lbl { padding: 6px 10px; font-size: .74rem; line-height: 1.15; color: var(--muted); background: var(--sunken); border-right: 2px dashed var(--line-strong); font-weight: 500; }
.pin-stub .val { padding: 6px 12px; font-variant-numeric: lining-nums; font-weight: 700; letter-spacing: .12em; align-self: center; }

.impersonating { background: var(--amber-bg); border-bottom: 1px solid #efd29c; color: #6b4206; font-size: .9rem; }
.impersonating .in { max-width: 1180px; margin: 0 auto; padding: 8px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Pagine di accesso ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--pine-deep); color: #dfeee8; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .brand { color: #fff; }
.auth-side .brand small { color: #9fc2b6; }
.auth-side .brand-mark { background: #e9f5f0; color: var(--pine-deep); }
.auth-side h2 { font-size: 2.3rem; line-height: 1.08; color: #fff; font-weight: 700; max-width: 14ch; margin-bottom: 18px; }
.auth-side p { color: #b6d3c9; max-width: 42ch; }
.ledger { position: absolute; right: 44px; bottom: 96px; width: 330px; transform: rotate(-4deg); background: #f3f8f6; color: var(--ink); border-radius: 10px; padding: 18px 20px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); font-size: .88rem; }
.ledger .lrow { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed #c8d6cf; font-variant-numeric: lining-nums; }
.ledger .lrow:last-child { border-bottom: 0; font-weight: 700; }
.ledger .stamp { position: absolute; top: 14px; right: 16px; border: 2px solid var(--ok); color: var(--ok); font-weight: 700; padding: 2px 8px; border-radius: 4px; transform: rotate(8deg); font-size: .78rem; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 720px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.auth-links { margin-top: 18px; font-size: .92rem; color: var(--muted); }

/* ---------- Admin ---------- */
.admin { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--pine-deep) 236px, var(--canvas) 236px); }
.a-side { background: var(--pine-deep); color: #c9ddd6; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px 24px; }
.a-side .brand { color: #fff; padding: 4px 8px 18px; }
.a-side .brand small { color: #8fb3a7; }
.a-side .brand-mark { background: #e9f5f0; color: var(--pine-deep); }
.a-nav-group { margin-bottom: 16px; }
.a-nav-group > span { display: block; font-size: .76rem; color: #7fa397; padding: 4px 10px; font-weight: 600; }
.a-side nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 6px; color: #d5e6e0; text-decoration: none; font-size: .92rem; font-weight: 500; }
.a-side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.a-side nav a[aria-current="page"] { background: #e9f5f0; color: var(--pine-deep); font-weight: 650; }
.a-side .count { font-size: .74rem; font-weight: 700; background: #d9534a; color: #fff; padding: 0 7px; border-radius: 9px; line-height: 18px; }
.a-side nav a[aria-current="page"] .count { background: var(--rust); }
.a-top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 15; }
.a-top-in { display: flex; align-items: center; gap: 16px; padding: 10px 28px; min-height: 60px; }
.a-search { flex: 1; max-width: 520px; position: relative; }
.a-search input { padding-left: 36px; min-height: 40px; background: var(--sunken); }
.a-search svg { position: absolute; left: 11px; top: 11px; width: 18px; height: 18px; color: var(--faint); }
.a-main .page { max-width: 1280px; padding: 26px 28px 64px; }
.menu-toggle { display: none; }

/* Note admin */
.note-box { background: #fffbea; border: 1px solid #efe1a5; border-radius: var(--radius); }
.note-box textarea { background: transparent; border: 0; min-height: 90px; padding: 0; }
.note-box textarea:focus { box-shadow: none; }

/* ---------- Ticket ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.msg-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.msg-head strong { font-weight: 650; }
.msg-body { padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.staff { border-left: 3px solid var(--pine); }
.msg.staff .msg-head { background: var(--mint); }
.msg.client .msg-head { background: var(--sunken); }
.msg.internal { border-left: 3px solid #d4a72c; background: #fffbea; }
.msg.internal .msg-head { background: #fff4cc; }
.attachments { padding: 0 16px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments a { font-size: .85rem; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; text-decoration: none; background: var(--sunken); }

/* ---------- Fattura ---------- */
.invoice-sheet { padding: 34px 38px; }
.invoice-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.invoice-top h2 { font-size: 1.5rem; margin: 0; }
.paybox { border-radius: var(--radius); background: var(--pine-deep); color: #e2efea; padding: 22px; }
.paybox .figure { color: #fff; }
.paybox .muted { color: #a8c7bc; }
.paybox .btn { background: #e9f5f0; color: var(--pine-deep); border-color: #e9f5f0; }
.paybox .btn:hover { background: #fff; }
.paybox .check { color: #d3e6df; }
.paid-mark { display: inline-block; border: 2px solid var(--ok); color: var(--ok); font-weight: 700; border-radius: 6px; padding: 4px 12px; transform: rotate(-4deg); }

/* ---------- DNS ---------- */
.dns-type { display: inline-block; min-width: 54px; text-align: center; font-weight: 700; font-size: .78rem; padding: 3px 6px; border-radius: 5px; background: var(--mint); color: var(--mint-ink); }
.dns-content { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; overflow-wrap: anywhere; max-width: 420px; }
.proxy { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; }
.proxy svg { width: 18px; height: 18px; }
.proxy.on { color: #d9730d; } .proxy.off { color: var(--faint); }
details.edit-row > summary { list-style: none; cursor: pointer; }
details.edit-row > summary::-webkit-details-marker { display: none; }
tr.editing td { background: var(--sunken) !important; }
.rec-form { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1.4fr) 110px auto; gap: 10px; align-items: start; }
.rec-form > .rec-actions { padding-top: 27px; }
.rec-form .hint { margin-top: 3px; }
.rec-form .field { margin: 0; }
.rec-extra { display: none; }
.rec-form[data-type="MX"] .rec-mx, .rec-form[data-type="SRV"] .rec-srv, .rec-form[data-type="CAA"] .rec-caa { display: block; }
.rec-form[data-type="SRV"] .rec-content, .rec-form[data-type="CAA"] .rec-content { display: none; }
.rec-form .rec-proxy { display: none; }
.rec-form[data-type="A"] .rec-proxy, .rec-form[data-type="AAAA"] .rec-proxy, .rec-form[data-type="CNAME"] .rec-proxy { display: flex; }
.rec-extras { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.rec-extras .field { min-width: 120px; }

/* ---------- Grafici ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .84rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Timeline log ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 11px 22px; border-bottom: 1px solid var(--line); font-size: .9rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--faint); font-size: .82rem; white-space: nowrap; }
.feed .who { color: var(--muted); font-size: .82rem; }

/* ---------- Email preview ---------- */
.email-frame { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > .stat:nth-child(3) { border-left: 0; }
  .stats > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ledger { display: none; }
}
@media (max-width: 900px) {
  .admin { grid-template-columns: minmax(0, 1fr); background: var(--canvas); }
  .a-side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; z-index: 50; }
  .admin.nav-open .a-side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-toggle { display: inline-flex; }
  .a-top-in { padding: 10px 16px; gap: 10px; }
  .a-top-spacer { display: none; }
  .a-main .page { padding: 20px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .rec-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .page { padding: 20px 16px 48px; }
  .c-header-in { padding: 0 16px; gap: 12px; flex-wrap: wrap; }
  .c-header-in .brand small { display: none; }
  .c-nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 8px; border-top: 1px solid var(--line); }
  .c-nav a { padding: 12px 10px 10px; }
  .pin-stub .lbl { display: none; }
  .form-grid > [class*="c-"] { grid-column: span 12; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stats > .stat + .stat { border-left: 0; border-top: 1px solid var(--line); }
  .figure-xl { font-size: 2.1rem; }
  .invoice-sheet { padding: 22px 18px; }
  .panel-body { padding: 16px; }
  .panel-head { padding: 14px 16px; }
  .table th, .table td { padding: 10px 12px; }
  .table .hide-sm, .hide-sm { display: none; }
  .rec-form { grid-template-columns: minmax(0, 1fr); }
  .rec-form > .rec-actions { padding-top: 0; }
  dl.facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .c-header, .a-side, .a-top, .actions, .paybox, .no-print { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; border: 0; }
  .admin { display: block; }
}
