/* DR SOLUTION · DR System Code */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --border: #dfe5e2;
  --ink: #16211c;
  --ink-2: #4a5a53;
  --ink-3: #7a8a83;
  --brand: #0f6b45;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ea;
  --pos: #0f7a4a;
  --pos-soft: #e2f4ea;
  --neg: #c0392b;
  --neg-soft: #fbe9e7;
  --warn: #b26a00;
  --warn-soft: #fff3dc;
  --info: #1f5fa8;
  --info-soft: #e5eefa;
  --bar: #2f8f63;
  --grid: #e6ebe8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 33, 26, .06), 0 4px 16px rgba(16, 33, 26, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1e2723;
    --border: #2a3530;
    --ink: #e8efeb;
    --ink-2: #aebdb6;
    --ink-3: #7f8f88;
    --brand: #34b27b;
    --brand-ink: #06130d;
    --brand-soft: #173026;
    --pos: #4cc991;
    --pos-soft: #16302a;
    --neg: #f07b6c;
    --neg-soft: #3a1e1b;
    --warn: #f0b24a;
    --warn-soft: #3a2c12;
    --info: #7fb1ec;
    --info-soft: #182a40;
    --bar: #46b886;
    --grid: #26302c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--brand); }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 36px 28px; width: min(380px, 100%); text-align: center;
}
.login-card img { border-radius: 18px; }
.login-card h1 { margin: 12px 0 4px; font-size: 1.8rem; letter-spacing: .02em; }
.login-card p { color: var(--ink-2); margin: 0 0 24px; }
.login-card small { color: var(--ink-3); display: block; margin-top: 20px; }
.lock-form { display: flex; gap: 8px; margin-top: 14px; }
.lock-form input { flex: 1; }
#btnBio svg { flex: none; }
.err { color: var(--neg); min-height: 1.2em; margin-top: 12px !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; padding: 4px 8px 18px; letter-spacing: .03em; }
.brand img { border-radius: 8px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
#nav a .ico { width: 22px; text-align: center; font-size: 1.05rem; }
#nav a:hover { background: var(--surface-2); color: var(--ink); }
#nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.user { margin-top: auto; font-size: .85rem; color: var(--ink-2); padding: 8px; border-top: 1px solid var(--border); }
.user button { margin-top: 6px; }
main { flex: 1; min-width: 0; padding: 24px clamp(16px, 3vw, 36px) 40px; max-width: 1200px; }
.banner {
  background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px;
  margin-bottom: 16px; font-size: .9rem;
}

@media (max-width: 820px) {
  .app { display: block; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: 100%; height: auto; z-index: 20;
    flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
  }
  .brand, .user { display: none; }
  #nav { flex-direction: row; width: 100%; justify-content: space-around; }
  #nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .68rem; flex: 1; text-align: center; }
  #nav a .ico { font-size: 1.2rem; width: auto; }
  main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
}

/* ---------- Header di pagina ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font: inherit; color: var(--ink-2);
  cursor: pointer; white-space: nowrap; font-weight: 500;
}
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 650; }

/* ---------- Pulsanti e campi ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 550;
  cursor: pointer; text-decoration: none; min-height: 38px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--neg); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn.big { padding: 12px 20px; font-size: 1rem; width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--ink-2); font-size: 1rem; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--ink-2); font-weight: 550; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 11px; width: 100%; min-height: 40px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
label.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
label.check input { width: auto; min-height: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.full { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters label.check input { min-width: 0; flex: none; }
.filters input:not([type=checkbox]), .filters select { width: auto; min-width: 140px; flex: 1 1 140px; max-width: 260px; }

/* ---------- Card e KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .lbl { font-size: .8rem; color: var(--ink-2); font-weight: 550; }
.kpi .val { font-size: 1.45rem; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--ink-3); margin-top: 2px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols > .card + .card { margin-top: 0; }
.cols.cols-wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 960px) { .cols, .cols.cols-wide { grid-template-columns: 1fr; } .cols > .card + .card { margin-top: 0; } }

/* ---------- Liste ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: .82rem; color: var(--ink-3); }
.row .amt { text-align: right; font-weight: 650; }
.row .amt .meta { font-weight: 400; }
.row .acts { display: flex; gap: 2px; }
.row.click { cursor: pointer; border-radius: 8px; }
.row.click:hover { background: var(--surface-2); }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-3); }

.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 650; padding: 2px 8px;
  border-radius: 99px; white-space: nowrap; background: var(--surface-2); color: var(--ink-2);
}
.pill.pos { background: var(--pos-soft); color: var(--pos); }
.pill.neg { background: var(--neg-soft); color: var(--neg); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }

.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }

table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .78rem; color: var(--ink-2); font-weight: 650; padding: 8px 8px; border-bottom: 1px solid var(--border); }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
table.t td.r, table.t th.r { text-align: right; }
table.t tfoot td { font-weight: 700; border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- Clienti (Dare/Avere) ---------- */
.clients { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.client { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; text-align: left; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.client:hover { border-color: var(--brand); }
.client-top { display: flex; gap: 10px; align-items: center; }
.client-top .main { min-width: 0; }
.client-top .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-top .meta { font-size: .8rem; color: var(--ink-3); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 750; flex: none; }
.client-bal { font-size: .9rem; font-weight: 600; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; color: var(--ink-2); }
.client-bal.pos { background: var(--pos-soft); color: var(--pos); }
.client-bal.neg { background: var(--neg-soft); color: var(--neg); }
.client-bal b { font-size: 1.15rem; margin-left: 4px; }
.client-bal.big { font-size: 1rem; padding: 12px 14px; }
.client-bal.big b { font-size: 1.5rem; }
.client-grid { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.client-grid .num { text-align: right; }
.io-card { margin-bottom: 16px; }
.io { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.io .lbl { font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.io .val { font-size: 1.4rem; font-weight: 750; }
.io .sub { font-size: .8rem; color: var(--ink-3); }
@media (max-width: 560px) { .io { grid-template-columns: 1fr 1fr; } .io > div:last-child { grid-column: 1 / -1; } }

/* ---------- Veicoli ---------- */
.vehicles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.vehicle {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  box-shadow: var(--shadow); text-align: left; font: inherit; color: inherit;
}
.vehicle.active { outline: 2px solid var(--brand); border-color: transparent; }
.vehicle .plate { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.vehicle .name { font-weight: 700; font-size: 1.05rem; margin: 4px 0; }

/* ---------- Grafici ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--bar); }
.chart .bar.sel { fill: var(--brand); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.hover { filter: brightness(1.12); }
.chart .vlabel { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar .top { display: flex; justify-content: space-between; gap: 8px; font-size: .88rem; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 99px; margin-top: 4px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--bar); border-radius: 99px; }
.tip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--bg); padding: 6px 10px;
  border-radius: 8px; font-size: .82rem; box-shadow: 0 4px 14px rgba(0,0,0,.2); white-space: nowrap;
}

/* ---------- Ricevute ---------- */
.ric-img { width: 100%; border: 1px solid var(--border); border-radius: 12px; display: block; background: #fff; }
.ric-txt { white-space: pre-wrap; font: .85rem/1.45 system-ui, sans-serif; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: 8px 0 0; }
.client:focus-visible { outline: 2px solid var(--brand); }
.client-top .icon-btn { margin-left: auto; }

/* ---------- Scanner bolletta ---------- */
.scan-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18% 22%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
.qr-box { display: flex; flex-direction: column; }
.qr-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; word-break: break-all; }

/* ---------- Modale ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10, 20, 15, .45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
dialog header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; }
dialog .x { border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; color: var(--ink-2); padding: 6px; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
dialog footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
dialog footer .spacer { flex: 1; }
.hint { font-size: .82rem; color: var(--ink-3); }
.box { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 200; pointer-events: none; font-size: .9rem;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
@media (max-width: 820px) { .toast { bottom: 90px; } }

/* ---------- Stampa report ---------- */
@media print {
  .sidebar, .page-head .actions, .tabs, .filters, .banner, .icon-btn, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}

/* ---------- Telefono: righe su due livelli ---------- */
@media (max-width: 560px) {
  .row { flex-wrap: wrap; gap: 6px 10px; }
  .row .main { flex: 1 1 100%; }
  .row .amt { text-align: left; margin-right: auto; }
  .filters input:not([type=checkbox]), .filters select { max-width: none; }
  .card { padding: 14px; }
  .kpi .val { font-size: 1.25rem; }
}

/* ======================================================================
   TEMA COLORATO "SCADENZIARIO" — colori per sezione
   ====================================================================== */
:root {
  --bg: #eef3f1;
  --accent: #0f7a52; --accent-2: #14a36b; --accent-soft: #e0f3ea;
  --side-1: #083b2a; --side-2: #0f6b45;
  --u-late: #e5484d; --u-soon: #f08c00; --u-month: #e9b200; --u-later: #22a06b;
}
body[data-view="dare-avere"] { --accent: #0e7c86; --accent-2: #13a8a0; --accent-soft: #dff4f3; }
body[data-view="auto"]       { --accent: #d9480f; --accent-2: #f76707; --accent-soft: #fff0e6; }
body[data-view="spese"]      { --accent: #1c64d8; --accent-2: #3b8cf5; --accent-soft: #e5efff; }
body[data-view="scadenze"]   { --accent: #c92a2a; --accent-2: #f0543c; --accent-soft: #ffe9e6; }
body[data-view="report"]     { --accent: #6741d9; --accent-2: #8f67f0; --accent-soft: #efe9ff; }
body[data-view="impostazioni"] { --accent: #495057; --accent-2: #74808c; --accent-soft: #eef0f2; }
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c1210; --accent-soft: #16261f; --side-1: #06201a; --side-2: #0b3d2b; }
  body[data-view] { --accent-soft: color-mix(in srgb, var(--accent) 22%, #10171a); }
}

/* Barra laterale scura con sfumatura */
.sidebar { background: linear-gradient(180deg, var(--side-1), var(--side-2)); border-right: 0; color: #fff; }
.brand { color: #fff; }
#nav a { color: rgba(255, 255, 255, .78); position: relative; }
#nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
#nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
#nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: #ffd65a; }
.user { color: rgba(255, 255, 255, .8); border-top-color: rgba(255, 255, 255, .15); }
.user .muted { color: rgba(255, 255, 255, .6); }
@media (max-width: 820px) {
  .sidebar { background: var(--surface); color: var(--ink); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
  #nav a { color: var(--ink-3); font-size: .62rem; padding: 6px 2px; }
  #nav a:hover { background: transparent; color: var(--ink); }
  #nav a.active { background: var(--accent-soft); color: var(--accent); }
  #nav a.active::before { display: none; }
}

/* Intestazione di pagina colorata */
.page-head {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-radius: 18px; padding: 20px 22px; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 28%, transparent);
  position: relative; overflow: hidden;
}
.page-head::after { content: ""; position: absolute; right: -40px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .1); pointer-events: none; }
.page-head h1 { color: #fff; }
.page-head .muted, .page-head .sub-h { color: rgba(255, 255, 255, .85); font-size: .9rem; }
.page-head .btn { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .35); position: relative; z-index: 1; }
.page-head .btn:hover { background: rgba(255, 255, 255, .26); }
.page-head .btn.primary { background: #fff; color: var(--accent); border-color: #fff; }

/* Card e indicatori con accento */
.kpi { position: relative; overflow: hidden; border-top: 0; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); }
.kpi { padding-left: 20px; }
.tabs button.active { color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline-color: var(--accent); }
.card-head h2 { position: relative; }
.chart .bar { fill: var(--accent-2); }
.chart .bar.sel { fill: var(--accent); }
.hbar .track i, .progress > i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.vehicle.active { outline-color: var(--accent); }
.client:hover { border-color: var(--accent); }
.avatar { background: var(--accent-soft); color: var(--accent); }
dialog header h2 { color: var(--accent); }

/* ---------- Scadenziario ---------- */
.sc-cols { grid-template-columns: minmax(280px, 360px) 1fr; align-items: start; }
@media (max-width: 960px) { .sc-cols { grid-template-columns: 1fr; } }
.cal-card .card-head { justify-content: space-between; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h { text-align: center; font-size: .72rem; font-weight: 700; color: var(--ink-3); padding: 2px 0 4px; }
.cal-d { position: relative; aspect-ratio: 1; border: 0; background: var(--surface-2); border-radius: 10px; font: inherit; font-size: .85rem; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.cal-d:hover { filter: brightness(.96); }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--accent); color: var(--ink); font-weight: 700; }
.cal-d.sel { outline: 3px solid var(--ink); }
.cal-d.has { color: #fff; font-weight: 700; }
.cal-d.has.u-late { background: var(--u-late); } .cal-d.has.u-soon { background: var(--u-soon); }
.cal-d.has.u-month { background: var(--u-month); color: #3a2d00; } .cal-d.has.u-later { background: var(--u-later); }
.cal-d i { position: absolute; top: 2px; right: 4px; font-size: .62rem; font-style: normal; }
.cal-leg { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; color: var(--ink-2); }
.cal-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.cal-leg i.u-late { background: var(--u-late); } .cal-leg i.u-soon { background: var(--u-soon); } .cal-leg i.u-month { background: var(--u-month); } .cal-leg i.u-later { background: var(--u-later); }
.sc-group + .sc-group { margin-top: 18px; }
.sc-group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 6px; }
.sc-group h3.neg { color: var(--u-late); }
.sc-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; border-left: 5px solid var(--u-later); background: var(--surface-2); margin-bottom: 8px; }
.sc-row.u-late { border-left-color: var(--u-late); background: color-mix(in srgb, var(--u-late) 9%, var(--surface)); }
.sc-row.u-soon { border-left-color: var(--u-soon); background: color-mix(in srgb, var(--u-soon) 9%, var(--surface)); }
.sc-row.u-month { border-left-color: var(--u-month); }
.sc-row .main { flex: 1; min-width: 0; }
.sc-row .title { font-weight: 650; }
.sc-row .meta { font-size: .8rem; color: var(--ink-3); }
.sc-date { width: 50px; flex: none; text-align: center; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; line-height: 1.1; }
.sc-date b { display: block; font-size: 1.25rem; padding: 4px 0 2px; }
.sc-date span { display: block; font-size: .66rem; font-weight: 700; text-transform: uppercase; color: #fff; background: var(--u-later); padding: 2px 0; }
.u-late .sc-date span { background: var(--u-late); } .u-soon .sc-date span { background: var(--u-soon); } .u-month .sc-date span { background: var(--u-month); color: #3a2d00; }
.u-late .sc-when { color: var(--u-late); font-weight: 700; } .u-soon .sc-when { color: var(--u-soon); font-weight: 700; }
@media (max-width: 560px) { .sc-row { flex-wrap: wrap; } .sc-row .main { flex: 1 1 calc(100% - 64px); } .sc-row .amt { margin-left: 62px; margin-right: auto; } }
@media print { .page-head { background: none; color: #000; box-shadow: none; } .page-head h1 { color: #000; } }

.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
body.drop main::after { content: "Rilascia qui la bolletta (PDF o immagine)"; position: fixed; inset: 16px; border: 3px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--accent) 10%, transparent); display: grid; place-items: center; font-size: 1.3rem; font-weight: 700; color: var(--accent); z-index: 50; pointer-events: none; }

.drop-hint { margin: -4px 0 12px; }
@media (max-width: 820px) { .drop-hint { display: none; } }

/* ---------- Impegni ---------- */
body[data-view="impegni"] { --accent: #c2255c; --accent-2: #e64980; --accent-soft: #ffe8f0; }
.quick-add { display: flex; gap: 8px; padding: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.quick-add input { flex: 1 1 260px; }
.quick-add select { width: auto; }
.imp-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; background: var(--surface-2); margin-bottom: 8px; border-left: 4px solid transparent; }
.imp-row.prio-alta { border-left-color: var(--u-late); }
.imp-row.prio-bassa { opacity: .92; }
.imp-row .main { flex: 1; min-width: 0; }
.imp-row .title { font-weight: 600; }
.imp-row .meta { font-size: .8rem; color: var(--ink-3); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.imp-row.done .title { text-decoration: line-through; color: var(--ink-3); }
.imp-check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface); color: #fff; font-weight: 800; cursor: pointer; flex: none; display: grid; place-items: center; transition: .15s; }
.imp-check:hover { background: var(--accent-soft); }
.imp-row.done .imp-check { background: var(--u-later); border-color: var(--u-later); }
.warn-t { color: var(--warn); font-weight: 600; }
.only-mobile { display: none !important; }
@media (max-width: 820px) { .hide-mobile { display: none !important; } .only-mobile { display: inline-flex !important; } }

/* ---------- Notifiche / installazione ---------- */
.steps { margin: 8px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.steps li.ok { color: var(--pos); }
.steps .btn { margin-left: 6px; }
.notif-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--info-soft); color: var(--info); }
.notif-banner .btn { margin-left: 6px; }

/* ---------- Eventi ---------- */
.add-event { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-2); border-style: dashed; text-align: center; min-height: 170px; }
.client.event .avatar { font-size: 1.2rem; }
.chip { display: inline-flex; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span { font-size: 1.4rem; padding: 4px 8px; border-radius: 10px; border: 2px solid transparent; background: var(--surface-2); }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); }

.btn.wa { background: #25d366; border-color: #25d366; color: #fff; }

/* ---------- Barra in alto: installa + campanella ---------- */
.topbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: -8px 0 14px; }
.topbar-brand { display: none; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .03em; margin-right: auto; }
.topbar-brand img { border-radius: 8px; }
.install-btn { display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 16px; border-radius: 99px; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.install-btn:hover { filter: brightness(1.08); }
.install-btn[hidden] { display: none !important; }
.bell { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); flex: none;
  background: var(--surface); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.1); transition: .15s; }
.bell:hover { color: var(--accent); transform: scale(1.05); }
.bell.has { color: var(--accent); }
.bell.urgent svg { animation: ring 2.4s ease-in-out infinite; transform-origin: 50% 10%; color: var(--u-late); }
.bell-badge { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--u-late); color: #fff;
  font-size: .72rem; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface); }
@keyframes ring { 0%, 80%, 100% { transform: rotate(0); } 84% { transform: rotate(14deg); } 88% { transform: rotate(-12deg); } 92% { transform: rotate(8deg); } 96% { transform: rotate(-4deg); } }
.bell-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--u-later); }
.bell-dot.neg { background: var(--u-late); } .bell-dot.warn { background: var(--u-soon); } .bell-dot.info { background: var(--info); }
@media (max-width: 820px) {
  .topbar { margin: -4px 0 12px; }
  .topbar-brand { display: flex; }
  .install-btn { height: 38px; padding: 0 12px; font-size: .85rem; }
  .bell { width: 40px; height: 40px; }
}
@media (max-width: 380px) { .install-btn span { display: none; } }
@media print { .topbar { display: none !important; } }

/* ---------- Logo ricevute ---------- */
.logo-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; font: inherit; font-size: .85rem; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: var(--shadow); }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.logo-prev { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.logo-prev img { max-height: 64px; max-width: 160px; border-radius: 8px; border: 1px solid var(--border); background: #fff; padding: 4px; }

/* ---------- Categorie Dare/Avere ---------- */
.pill.cat { background: hsl(var(--h) 70% 92%); color: hsl(var(--h) 55% 32%); }
@media (prefers-color-scheme: dark) { .pill.cat { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 70% 78%); } }
.cat-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 6px; }
.cat-chip { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); font: inherit; color: var(--ink); cursor: pointer; box-shadow: var(--shadow); text-align: left; }
.cat-chip.on { border-color: var(--accent); background: var(--accent-soft); outline: 2px solid var(--accent); }
.cat-chip.add { justify-content: center; align-items: center; color: var(--ink-3); }

/* ---------- Utenze / Spese quotidiane / menu ---------- */
body[data-view="utenze"] { --accent: #1c64d8; --accent-2: #3b8cf5; --accent-soft: #e5efff; }
body[data-view="spese"] { --accent: #e67700; --accent-2: #fab005; --accent-soft: #fff4e0; }
.quick-spesa .q-imp { flex: 0 1 130px; font-size: 1.15rem; font-weight: 700; }
.quick-spesa input:not(.q-imp) { flex: 1 1 200px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; text-transform: capitalize !important; }
.day-h b { color: var(--ink); font-size: .9rem; }
.only-mobile-flex { display: none !important; }
@media (max-width: 820px) { .only-mobile-flex { display: flex !important; } }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 6px; border-radius: 14px; background: var(--surface-2); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; }
.menu-tile span { font-size: 1.6rem; }
.menu-tile.on { background: var(--accent-soft); color: var(--accent); outline: 2px solid var(--accent); }

body[data-view="future"] { --accent: #5f3dc4; --accent-2: #9775fa; --accent-soft: #f0ebff; }
.fut-row { border-left: 4px solid transparent; padding-left: 10px; }
.fut-row.prio-urgente { border-left-color: var(--u-late); }
.fut-row.prio-importante { border-left-color: var(--u-soon); }
.fut-row.prio-puo-aspettare { border-left-color: var(--u-later); }

body[data-view="entrate"] { --accent: #2b8a3e; --accent-2: #51cf66; --accent-soft: #e6f7ea; }

.vehicle { position: relative; }
.veh-edit { position: absolute; top: 8px; right: 8px; }
.veh-top { display: flex; align-items: center; gap: 8px; }
.veh-ico { font-size: 1.5rem; }
.chip small { font-size: .72rem; }
.chip { position: relative; } .chip input { min-height: 0 !important; padding: 0 !important; border: 0 !important; pointer-events: none; }

.wallet-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 18px 20px; border-radius: 18px;
  background: linear-gradient(135deg, #1b4332, #2b8a3e); color: #fff; box-shadow: 0 8px 22px rgba(43,138,62,.3); }
.wallet-card .lbl { font-size: .85rem; opacity: .85; font-weight: 600; }
.wallet-card .val { font-size: 2rem; font-weight: 800; }
.wallet-card .sub { font-size: .8rem; opacity: .8; }
.wallet-card .btn { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.35); }

table.t tr.sel-row td { background: var(--accent-soft); }
body[data-view="report"] .tabs { flex-wrap: nowrap; }
.install-btn.installed { background: #e2f4ea; color: #0f6b45; box-shadow: none; }
.install-btn.installed span::after { content: " ✓"; }

/* ======================================================================
   TELEFONI GRANDI (Samsung Galaxy S26 Ultra ~412×915, Android con gesti)
   ====================================================================== */
@media (max-width: 560px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overscroll-behavior-y: contain; }
  main { padding: calc(10px + env(safe-area-inset-top)) 12px calc(92px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px; }
  /* barra in basso più comoda per il pollice */
  .sidebar { padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); }
  #nav a { min-height: 56px; justify-content: center; font-size: .66rem; border-radius: 14px; }
  #nav a .ico { font-size: 1.35rem; line-height: 1.1; }
  /* intestazione di pagina più compatta */
  .page-head { padding: 16px 18px !important; margin-bottom: 12px; border-radius: 18px; }
  .page-head h1 { font-size: 1.45rem; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; justify-content: center; }
  /* righe: titolo a sinistra, importo a destra, pulsanti sotto */
  .row { flex-wrap: wrap; justify-content: flex-end; gap: 6px 10px; padding-top: 10px; padding-bottom: 10px; }
  .row .main { flex: 1 1 0; min-width: 58%; }
  .row .amt { text-align: right; margin-right: 0; white-space: nowrap; align-self: flex-start; padding-top: 1px; }
  .row .title { white-space: normal; }
  /* KPI su due colonne ben proporzionate */
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .val { font-size: 1.2rem; }
  /* inserimento veloce (Spese / Portafoglio) */
  .quick-add.quick-spesa { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 12px; }
  .quick-add.quick-spesa > .q-imp { grid-column: span 2; }
  .quick-add.quick-spesa > input:not(.q-imp) { grid-column: span 4; }
  .quick-add.quick-spesa > select { grid-column: span 3; }
  .quick-add.quick-spesa .q-imp, .quick-add.quick-spesa input, .quick-add.quick-spesa select { width: 100%; min-width: 0; }
  .quick-add.quick-spesa button[type=submit] { grid-column: 1 / -1; height: 46px; }
  .quick-add.quick-spesa datalist { display: none; }
  /* veicoli a scorrimento orizzontale */
  .vehicles { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; padding-bottom: 4px; margin: 0 -12px 14px; padding-left: 12px; padding-right: 12px; scrollbar-width: none; }
  .vehicles::-webkit-scrollbar { display: none; }
  .vehicles > * { flex: 0 0 78%; scroll-snap-align: start; }
  /* schede e filtri */
  .tabs { scrollbar-width: none; margin-left: -2px; margin-right: -2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; }
  .filters { gap: 8px; }
  .filters > input[type=search] { flex: 1 1 100%; }
  .filters label { flex-wrap: wrap; max-width: 100%; }
  .filters select { max-width: 100%; min-width: 0; }
  .filters label select { flex: 1 1 100%; }
  /* finestre: foglio che sale dal basso */
  dialog { width: 100%; max-width: 100%; max-height: calc(100dvh - 24px); margin: auto 0 0; border-radius: 22px 22px 0 0; }
  dialog form { max-height: calc(100dvh - 24px - env(safe-area-inset-top)); }
  dialog footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  dialog footer .btn { flex: 1 1 auto; justify-content: center; }
  dialog footer .spacer { display: none; }
  .ric-img { max-height: 55dvh; object-fit: contain; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
/* S26 Ultra e simili: i campi brevi restano affiancati */
@media (min-width: 380px) and (max-width: 560px) {
  .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .grid2 .field, .grid2 .field input, .grid2 .field select, .grid2 .field textarea { min-width: 0; max-width: 100%; }
  .grid2 > .full, .grid2 > .field.full, .grid2 > label.check, .grid2 > details, .grid2 > p, .grid2 > .grid2 { grid-column: 1 / -1; }
  .grid3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Dare/Avere veloce */
.da-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; margin-bottom: 16px; }
.da-quick .da-dir { grid-column: 1 / -1; display: flex; }
.da-quick .da-dir button { flex: 1; }
.da-quick #daQNota { grid-column: 1 / -1; }
.da-quick .q-imp { font-size: 1.15rem; font-weight: 700; }
.da-quick button[type=submit] { height: 46px; justify-content: center; }
.da-quick .da-qinfo { grid-column: 1 / -1; margin: 0; }
.da-quick input { min-width: 0; width: 100%; }
@media (min-width: 900px) { .da-quick { grid-template-columns: 2fr 1fr 2fr auto auto; } .da-quick #daQNota { grid-column: auto; } }
.client-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.client-quick .btn { justify-content: center; }
.big-imp { width: 100%; font-size: 1.8rem; font-weight: 800; text-align: center; padding: 14px; margin-top: 12px; border-radius: 14px; }

/* ======================================================================
   DARE/AVERE — rubrica clienti compatta
   ====================================================================== */
.da-top { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.da-top h1 { font-size: 1.35rem; margin: 0; }
.da-top .spacer { flex: 1; }
.da-catsel { width: auto; font-weight: 800; border-radius: 99px; padding: 6px 30px 6px 14px; background-color: var(--accent-soft); color: var(--accent); border-color: transparent; }
.da-ic { width: 42px; height: 42px; font-size: 1.25rem; border-radius: 50%; }
.da-search { width: 100%; margin-bottom: 10px; }
.da-seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1.5px solid var(--border); border-radius: 99px; padding: 4px; margin-bottom: 12px; background: var(--surface); }
.da-seg button { border: 0; background: transparent; font: inherit; font-weight: 700; font-size: .92rem; padding: 10px 4px; border-radius: 99px; color: var(--ink-2); cursor: pointer; position: relative; }
.da-seg button + button::before { content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 1px; background: var(--border); }
.da-seg button.on { color: var(--accent); background: var(--accent-soft); }
.da-seg button.on::before, .da-seg button.on + button::before { display: none; }
.da-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 150px; }
.da-row { display: grid; grid-template-columns: 50px 1fr auto 34px; align-items: center; gap: 12px; padding: 12px 6px 12px 12px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06)); cursor: pointer; }
.da-row:active { transform: scale(.99); }
.da-av { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.35rem;
  background: hsl(var(--h) 70% 93%); color: hsl(var(--h) 60% 38%); }
.da-mid { min-width: 0; }
.da-name { font-weight: 750; font-size: 1.08rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.da-sub { display: flex; gap: 14px; font-size: .84rem; color: var(--ink-3); margin-top: 4px; }
.da-sub span:first-child { font-weight: 650; color: var(--ink-2); }
.da-amt { text-align: right; line-height: 1.15; }
.da-amt b { display: block; font-size: 1.08rem; }
.da-amt small { font-size: .75rem; font-weight: 700; text-transform: lowercase; }
.da-amt.pos { color: var(--pos, #0f7a4a); } .da-amt.neg { color: var(--neg, #c0392b); } .da-amt.zero { color: var(--ink-3); }
.da-more { width: 34px; height: 40px; font-size: 1.3rem; color: var(--ink-3); }
.da-dock { position: sticky; bottom: 0; z-index: 5; margin: 0 -4px; padding: 10px 4px 4px; background: linear-gradient(transparent, var(--bg) 18%); }
.da-dock-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.da-dock-btns .btn { height: 52px; font-size: 1.02rem; justify-content: center; border-radius: 12px; }
.da-trans { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.da-tot { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; }
.da-tot > div { text-align: center; padding: 8px 4px; display: flex; flex-direction: column; }
.da-tot > div + div { border-left: 1.5px solid var(--border); }
.da-tot span { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.da-tot b { font-size: 1.05rem; margin-top: 2px; }
.da-tot small { font-size: .68rem; color: var(--ink-3); }
.da-back { margin-bottom: 10px; }
.azioni { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.azioni .btn { justify-content: flex-start; }
.chip-seg { flex: 1; position: relative; }
.chip-seg input { position: absolute; opacity: 0; pointer-events: none; }
.chip-seg span { display: block; text-align: center; padding: 10px; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.chip-seg input:checked + span { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
@media (max-width: 820px) {
  .da-dock { bottom: calc(68px + env(safe-area-inset-bottom)); }
}
@media (min-width: 821px) { .da-list { max-width: 900px; } .da-dock { max-width: 900px; } }
@media (prefers-color-scheme: dark) { .da-av { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 80% 72%); } }
.da-top h1 { white-space: nowrap; font-size: 1.25rem; }
.da-catsel { max-width: 42%; }
.da-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.2; }
.da-top { min-width: 0; }
.da-top .da-catsel { flex: 0 1 auto; min-width: 0; width: auto; }
.da-top .icon-btn { flex: none; }

/* Auto: conto alla rovescia scadenze */
.veh-count { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 14px; --c: #0f7a4a; --bgc: #e2f4ea; background: var(--bgc); }
.veh-count.warn { --c: #b35c00; --bgc: #fff1dc; }
.veh-count.urg { --c: #c0392b; --bgc: #fde6e3; animation: vcPulse 1.8s ease-in-out infinite; }
@keyframes vcPulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); } }
.vc-num { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 58px; height: 58px; border-radius: 50%; background: var(--c); color: #fff; line-height: 1; }
.vc-num b { font-size: 1.45rem; font-weight: 800; }
.vc-num span { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin-top: 2px; }
.vc-txt { min-width: 0; }
.vc-tipo { font-weight: 800; color: var(--c); }
.vc-q { font-size: .82rem; color: var(--ink-2); margin-top: 1px; }
.vc-bar { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--c) 18%, transparent); margin-top: 6px; overflow: hidden; }
.vc-bar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }
.vc-pay { background: var(--surface); border-color: transparent; color: var(--c); font-weight: 700; }
.veh-altre { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.veh-mini { font-size: .78rem; padding: 3px 9px; border-radius: 99px; background: #e2f4ea; color: #0f7a4a; }
.veh-mini.warn { background: #fff1dc; color: #b35c00; } .veh-mini.urg { background: #fde6e3; color: #c0392b; }
@media (prefers-color-scheme: dark) {
  .veh-count { --bgc: color-mix(in srgb, var(--c) 20%, #16211c); }
  .veh-count { --c: #3ec486; } .veh-count.warn { --c: #f0a040; } .veh-count.urg { --c: #ff6b5e; }
  .veh-mini { background: #1d3a2c; color: #7fe0b0; } .veh-mini.warn { background: #3d2d14; color: #f5b865; } .veh-mini.urg { background: #3f1c1a; color: #ff8a80; }
}
.veh-count { grid-template-columns: auto 1fr; }
.vc-tipo { display: flex; align-items: center; gap: 4px; }
.vc-pay { grid-column: 1 / -1; justify-self: stretch; justify-content: center; margin-top: 2px; }
.vc-tipo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ======================================================================
   VIAGGI E SPESE DI GRUPPO
   ====================================================================== */
body[data-view="viaggi"] { --accent: #0b7285; --accent-2: #15aabf; --accent-soft: #e3f7fa; }
.vi-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.vi-card { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 12px; padding: 14px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06)); cursor: pointer; }
.vi-card.chiuso { opacity: .7; }
.vi-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.8rem; background: var(--accent-soft); }
.vi-main { min-width: 0; }
.vi-nome { font-weight: 800; font-size: 1.08rem; }
.vi-sub { font-size: .82rem; color: var(--ink-3); margin-top: 2px; }
.vi-right { text-align: right; line-height: 1.2; }
.vi-right b { display: block; font-size: 1.08rem; }
.vi-right small { font-size: .78rem; font-weight: 700; }
.vi-quick { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 10px; align-items: end; padding: 14px; margin-bottom: 16px; }
.vi-quick .q-imp { font-size: 1.15rem; font-weight: 700; }
.vi-quick input, .vi-quick select { width: 100%; min-width: 0; }
.vi-lbl { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.vi-tra { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.vi-tra > .vi-lbl { margin-right: 4px; }
.vi-quick button[type=submit] { grid-column: 1 / -1; height: 48px; justify-content: center; }
.vi-chip { position: relative; }
.vi-chip input { position: absolute; opacity: 0; pointer-events: none; }
.vi-chip span { display: inline-block; padding: 7px 14px; border-radius: 99px; border: 1.5px solid var(--border); font-weight: 700; font-size: .9rem; cursor: pointer; background: var(--surface); color: var(--ink-3); }
.vi-chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.vi-icone { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.vi-icone .vi-chip span { font-size: 1.3rem; padding: 4px 10px; }
.vi-trasf .title b { color: var(--accent); }
@media (max-width: 560px) {
  .vi-cards { grid-template-columns: 1fr; }
  .vi-quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vi-quick #viQDesc { grid-column: 1 / -1; order: 2; }
  .vi-quick .vi-lbl:has(#viQChi) { order: 1; }
  .vi-quick .vi-tra { order: 3; } .vi-quick button[type=submit] { order: 4; }
}
.scheda-azioni { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.scheda-azioni .btn { flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 12px 8px; text-align: center; }
.scheda-azioni .btn small { font-size: .74rem; font-weight: 500; opacity: .8; }
@media (max-width: 380px) { .scheda-azioni { grid-template-columns: 1fr; } }

/* Aggiorna app */
.upd-btn { font-size: 1.1rem; display: grid; place-items: center; background: var(--surface); cursor: pointer; }
[data-act=aggiorna-app].nuova { position: relative; }
.upd-btn.nuova { background: var(--accent); color: #fff; border-color: transparent; animation: updPulse 1.6s ease-in-out infinite; }
.upd-btn.nuova::after { content: ""; position: absolute; top: 0; right: 0; width: 11px; height: 11px; border-radius: 50%; background: #ffd65a; border: 2px solid var(--surface); }
@keyframes updPulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); } }
.lock-tools, .menu-tools { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.menu-tools .btn { flex: 1 1 140px; justify-content: center; }
.ver-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.ver-btns { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .ver-btns { width: 100%; } .ver-btns .btn { flex: 1; justify-content: center; } .topbar { gap: 8px; } }
.topbar-brand span { white-space: nowrap; }
@media (max-width: 560px) {
  .topbar .install-btn { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 50%; font-size: 1.1rem; }
  .topbar .install-btn span { display: none; }
  .topbar .bell { width: 40px; height: 40px; }
}

/* ======================================================================
   MANUTENZIONE CASA
   ====================================================================== */
body[data-view="casa"] { --accent: #5f3dc4; --accent-2: #845ef7; --accent-soft: #efeaff; }
.casa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.casa-card { background: var(--surface); border-radius: 16px; padding: 14px; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06)); cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.casa-top { display: flex; gap: 12px; align-items: center; }
.casa-ico { width: 50px; height: 50px; flex: none; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; background: var(--accent-soft); }
.casa-main { min-width: 0; }
.casa-nome { font-weight: 800; font-size: 1.05rem; }
.casa-sub { font-size: .82rem; color: var(--ink-3); }
.casa-card .veh-count { margin-top: 0; }
.casa-nodate { font-size: .85rem; color: var(--ink-3); background: var(--surface-2); border-radius: 12px; padding: 12px; text-align: center; }
.casa-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.casa-preset { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.casa-pre { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; font: inherit; text-align: left; color: var(--ink); }
.casa-pre:hover { border-color: var(--accent); }
.casa-pre span { font-size: 1.5rem; }
.casa-pre small { color: var(--ink-3); font-size: .76rem; }
.casa-preset.mini { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin: 0 0 12px; gap: 6px; }
.casa-preset.mini .casa-pre { padding: 8px; flex-direction: row; align-items: center; gap: 6px; }
.casa-preset.mini .casa-pre span { font-size: 1.1rem; }
.casa-preset.mini .casa-pre b { font-size: .78rem; }
@media (max-width: 560px) { .casa-grid { grid-template-columns: 1fr; } .casa-preset { grid-template-columns: 1fr 1fr; } }
.casa-foot .btn { white-space: nowrap; flex: none; }
.scheda-azioni .md-pay { grid-column: 1 / -1; flex-direction: row; gap: 6px; }
.btn.md-pos { border-color: color-mix(in srgb, var(--pos) 45%, transparent); color: var(--pos); background: color-mix(in srgb, var(--pos) 9%, var(--surface)); }
.btn.md-neg { border-color: color-mix(in srgb, var(--neg) 45%, transparent); color: var(--neg); background: color-mix(in srgb, var(--neg) 9%, var(--surface)); }
.scheda-azioni .btn.md-pos small, .scheda-azioni .btn.md-neg small { color: var(--ink-2); }
@media (max-width: 380px) { .scheda-azioni { grid-template-columns: 1fr 1fr; } }

/* ======================================================================
   SCHEDA CLIENTE semplice (conto con movimenti)
   ====================================================================== */
#modal.sc-modal header h2:empty { display: none; }
#modal.sc-modal header { padding-bottom: 0; }
.sc-head { display: flex; align-items: center; gap: 14px; margin-top: -6px; }
.da-av.big { width: 60px; height: 60px; font-size: 1.6rem; flex: none; }
.sc-nome { font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.sc-tel { font-size: .88rem; margin-top: 2px; }
.sc-tel a { color: var(--accent); text-decoration: none; font-weight: 600; }
.sc-saldo { margin: 14px 0 12px; padding: 16px 18px; border-radius: 18px; text-align: center; background: var(--surface-2); }
.sc-saldo span { display: block; font-weight: 700; font-size: .95rem; }
.sc-saldo > b { display: block; font-size: 2.3rem; font-weight: 800; line-height: 1.15; margin-top: 2px; }
.sc-saldo small { display: block; font-size: .8rem; color: var(--ink-2); margin-top: 4px; }
.sc-saldo.pos { background: color-mix(in srgb, var(--pos) 12%, var(--surface)); color: var(--pos); }
.sc-saldo.neg { background: color-mix(in srgb, var(--neg) 12%, var(--surface)); color: var(--neg); }
.sc-saldo.zero { color: var(--ink-2); }
.sc-prog { height: 7px; border-radius: 99px; background: color-mix(in srgb, currentColor 18%, transparent); margin: 10px auto 0; max-width: 320px; overflow: hidden; }
.sc-prog i { display: block; height: 100%; background: currentColor; border-radius: 99px; }
.sc-azioni { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.sc-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 14px 6px; border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface); font: inherit; font-weight: 800; font-size: .98rem; cursor: pointer; color: var(--ink); }
.sc-btn span { font-size: 1.45rem; line-height: 1; }
.sc-btn.pos { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 40%, transparent); background: color-mix(in srgb, var(--pos) 8%, var(--surface)); }
.sc-btn.neg { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, transparent); background: color-mix(in srgb, var(--neg) 8%, var(--surface)); }
.sc-btn.acc { color: #fff; background: var(--accent); border-color: transparent; }
.sc-btn:disabled { opacity: .4; cursor: default; }
.sc-btn:active:not(:disabled) { transform: scale(.97); }
.sc-mov-h { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 2px 6px; }
.sc-mov { display: flex; flex-direction: column; }
.sc-r { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.sc-r:last-child { border-bottom: 0; }
.sc-r:hover { background: var(--surface-2); }
.sc-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 1.15rem; }
.sc-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sc-txt b { font-size: .98rem; }
.sc-txt span { font-size: .86rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-txt small { font-size: .76rem; color: var(--ink-3); }
.sc-val { text-align: right; line-height: 1.2; }
.sc-val b { display: block; font-size: 1.02rem; }
.sc-val small { font-size: .74rem; color: var(--ink-3); white-space: nowrap; }
.acc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; justify-content: center; }
.acc-resta { text-align: center; margin: 8px 0 0; }
@media (max-width: 560px) { .sc-saldo > b { font-size: 2rem; } .sc-btn { font-size: .9rem; padding: 12px 4px; } }
.chiudi-opz { display: flex; flex-direction: column; gap: 8px; }
.chiudi-o { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--border); border-radius: 14px; cursor: pointer; }
.chiudi-o input { margin-top: 4px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.chiudi-o span { display: flex; flex-direction: column; gap: 2px; }
.chiudi-o small { color: var(--ink-3); font-size: .8rem; }
.chiudi-o:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chiudi-o.danger:has(input:checked) { border-color: var(--neg); background: color-mix(in srgb, var(--neg) 10%, var(--surface)); }
.chiudi-o.danger b { color: var(--neg); }

/* Dettagli bolletta e ricevuta di pagamento */
.det-box summary { cursor: pointer; padding: 4px 0; }
.det-cons { display: flex; gap: 6px; }
.det-cons input { flex: 1; min-width: 0; }
.det-cons select { width: auto; flex: none; }
.ric-pag { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.vc-btns { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 2px; }
.vc-btns .btn { justify-content: center; }
.vc-edit { background: transparent; border-color: color-mix(in srgb, var(--c) 40%, transparent); color: var(--c); font-weight: 700; }
.sca-sposta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vc-btns .vc-pay { grid-column: auto; margin-top: 0; }

/* Lavori (sito web, gestionale…) */
.sc-azioni { grid-template-columns: repeat(4, 1fr); }
.sc-btn.lav { color: #5f3dc4; border-color: color-mix(in srgb, #5f3dc4 40%, transparent); background: color-mix(in srgb, #5f3dc4 8%, var(--surface)); }
.lav-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.lav-card { border: 1.5px solid color-mix(in srgb, #5f3dc4 30%, var(--border)); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.lav-card.chiuso { opacity: .65; }
.lav-top { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; }
.lav-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; background: color-mix(in srgb, #5f3dc4 12%, var(--surface)); }
.lav-main { display: flex; flex-direction: column; min-width: 0; }
.lav-main small, .lav-val small { color: var(--ink-3); font-size: .78rem; }
.lav-val { text-align: right; display: flex; flex-direction: column; }
.lav-val b { font-size: 1.05rem; }
.lav-prog { margin: 4px 0 0; max-width: none; color: #5f3dc4; }
.lav-piano { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.lav-rata { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; font-size: .85rem; padding: 4px 6px; border-radius: 8px; }
.lav-rata.ok { color: var(--pos); } .lav-rata.late { color: var(--neg); background: color-mix(in srgb, var(--neg) 8%, transparent); }
.lav-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.lav-modi { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.lab-sm { font-weight: 700; font-size: .85rem; margin: 12px 0 6px; color: var(--ink-2); }
.lav-link { width: 100%; justify-content: center; margin-bottom: 12px; border-style: dashed; }
.da-lav { font-size: .78rem; color: #5f3dc4; font-weight: 700; }
@media (max-width: 560px) { .sc-btn { font-size: .82rem; } .sc-btn span { font-size: 1.25rem; } }
@media (prefers-color-scheme: dark) { .sc-btn.lav, .da-lav { color: #b197fc; } .lav-prog { color: #b197fc; } }
.sc-r { grid-template-columns: 40px 1fr auto 34px; }
.sc-edit { width: 34px; height: 34px; font-size: 1rem; color: var(--ink-3); border-radius: 50%; }
.sc-edit:hover { color: var(--accent); background: var(--accent-soft); }
