/*
 * Control Center — design system (token e componenti) per le pagine PHP.
 * Valori dal design system "Control Center": tema scuro di default, il chiaro con data-theme="light".
 */

:root {
  color-scheme: dark;
  --bg: #16181D;
  --sidebar: #1B1E24;
  --surface: #1F2228;
  --surface-sunken: #1A1D22;
  --surface-raised: #262A31;
  --line: #2C2F36;
  --ink: #F4F1EA;
  --ink-soft: #C9C7C0;
  --ink-muted: #9A9DA4;
  --on-accent: #16181D;
  --veicolo: #E8A33D;
  --veicolo-soft: #F2C57C;
  --veicolo-text: #E8A33D;
  --finanza: #4DB6A2;
  --finanza-text: #4DB6A2;
  --critico: #E5735F;
  --critico-text: #F08F7D;
  --critico-surface: #2B1F1D;
  --critico-line: #5A302A;
  --focus: #F2C57C;
  --mark-graphite-1: #5C5F66;
  --mark-graphite-2: #3A3D44;
  --mark-graphite-3: #8A8D93;

  --font-display: "Unbounded", "Sora", system-ui, sans-serif;
  --font-sans: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --sidebar-width: 248px;
  --control-height: 44px;
  --icon-well: 36px;
  --bottom-nav-height: 76px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F5F4F0;
  --sidebar: #FBFAF7;
  --surface: #FFFFFF;
  --surface-sunken: #EFEDE8;
  --surface-raised: #E9E7E1;
  --line: #DEDBD3;
  --ink: #16181D;
  --ink-soft: #3A3D44;
  --ink-muted: #62656C;
  --veicolo-soft: #F6D9A6;
  --veicolo-text: #8F5C0E;
  --finanza-text: #1D7363;
  --critico-text: #B23B27;
  --critico-surface: #FBE9E5;
  --critico-line: #F0C2B8;
  --focus: #8F5C0E;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body.cc-body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
.cc-body a { color: var(--veicolo-text); }
.cc-body button { font-family: inherit; }
.cc-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cc-num { font-variant-numeric: tabular-nums; }
.cc-missing { color: var(--ink-muted); font-weight: inherit; }

.cc-icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.cc-caption { font-family: var(--font-mono); font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); }
.cc-bg-veicolo { background: var(--veicolo); color: var(--on-accent); }
.cc-bg-finanza { background: var(--finanza); color: var(--on-accent); }
.cc-bg-critico { background: var(--critico); color: var(--on-accent); }
.cc-bg-neutro { background: var(--ink); color: var(--bg); }
.cc-bg-grafite { background: var(--mark-graphite-1); color: var(--on-accent); }
.cc-tx-veicolo { color: var(--veicolo-text); }
.cc-tx-finanza { color: var(--finanza-text); }
.cc-tx-critico { color: var(--critico-text); }
.cc-tx-neutro { color: var(--ink-soft); }

:where(.cc-body) a:focus-visible,
:where(.cc-body) button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Logo */
.cc-mark { display: block; flex-shrink: 0; }
.cc-mark .m-a { fill: var(--veicolo); }
.cc-mark .m-g1 { fill: var(--mark-graphite-1); }
.cc-mark .m-g2 { fill: var(--mark-graphite-2); }
.cc-mark .m-g3 { fill: var(--mark-graphite-3); }
.cc-lockup { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.cc-wordmark { font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.1; color: var(--ink); white-space: nowrap; }

/* Button */
.cc-btn { height: var(--control-height); min-width: var(--control-height); padding: 0 16px; border-radius: var(--radius-md); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-sans); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.cc-body .cc-btn-primary { background: var(--veicolo); color: var(--on-accent); }
.cc-body .cc-btn-primary:hover { background: var(--veicolo-soft); }
.cc-body .cc-btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.cc-btn-secondary .cc-icon { color: var(--finanza-text); }
.cc-btn-secondary:hover { background: var(--surface-raised); }
.cc-body .cc-btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.cc-btn-ghost:hover { color: var(--ink); background: var(--surface-raised); }
.cc-btn-block { display: flex; width: 100%; }

/* Avatar */
.cc-avatar { width: var(--control-height); height: var(--control-height); border-radius: var(--radius-full); background: var(--mark-graphite-2); color: #F4F1EA; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; overflow: hidden; flex-shrink: 0; text-decoration: none; }
.cc-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Card */
.cc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.cc-card-head { display: flex; align-items: center; gap: 12px; }
.cc-card-badge { width: 32px; height: 32px; flex-shrink: 0; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.cc-card-title { flex: 1 1 0; min-width: 0; margin: 0; font-size: 16px; line-height: 22px; font-weight: 600; color: var(--ink); }
.cc-card-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; text-decoration: none; white-space: nowrap; }
.cc-body .cc-card-link.is-veicolo { color: var(--veicolo-text); }
.cc-body .cc-card-link.is-finanza { color: var(--finanza-text); }
.cc-card-link:hover { text-decoration: underline; }
.cc-empty { margin: 0; padding: 16px 0 4px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-muted); }

/* KPI */
.cc-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: var(--space-5); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cc-kpi-label { display: flex; align-items: center; gap: 8px; }
.cc-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.cc-kpi-value { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.cc-kpi-unit { font-size: 14px; font-weight: 400; color: var(--ink-muted); }
.cc-kpi-note { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.cc-kpi-note .cc-icon { margin: -2px 4px 0 0; }
.cc-trend-good { color: var(--finanza-text); }
.cc-trend-bad { color: var(--critico-text); }

/* Stat tile */
.cc-stat { background: var(--surface-sunken); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cc-stat-value { font-size: 18px; line-height: 24px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* List row */
.cc-list { display: flex; flex-direction: column; }
.cc-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.cc-row[hidden] { display: none; }
.cc-well { width: var(--icon-well); height: var(--icon-well); flex-shrink: 0; border-radius: 10px; background: var(--surface-raised); display: flex; align-items: center; justify-content: center; }
.cc-row-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cc-row-title { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-row-meta { font-size: 12px; line-height: 16px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-row-value { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cc-row-value.cc-row-amount { font-size: 14px; }
.cc-body .cc-action-row .cc-row-value { color: var(--ink); }
.cc-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.cc-tone-neutral { color: var(--ink); }
.cc-tone-muted { color: var(--ink-muted); }
.cc-tone-soft { color: var(--ink-soft); }
.cc-tone-critico { color: var(--critico-text); }
.cc-tone-ok { color: var(--finanza-text); }

/* Progress / category bars */
.cc-progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-raised); overflow: hidden; }
.cc-progress-fill { display: block; height: 100%; border-radius: var(--radius-full); background: var(--mark-graphite-1); }
.cc-progress-fill.is-veicolo { background: var(--veicolo); }
.cc-progress-fill.cc-bg-critico { background: var(--critico); }
.cc-progress-fill.cc-bg-finanza { background: var(--finanza); }
.cc-cat-list { display: flex; flex-direction: column; gap: 16px; }
.cc-cat { display: flex; flex-direction: column; gap: 8px; }
.cc-cat-head { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.cc-cat-head .cc-icon { color: var(--ink-muted); }
.cc-cat-name { flex-grow: 1; color: var(--ink-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-cat.is-veicolo .cc-cat-name { color: var(--ink); }
.cc-cat.is-veicolo .cc-icon { color: var(--veicolo-text); }
.cc-cat-amount { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Alert */
.cc-alert { border-radius: 16px; background: var(--critico-surface); border: 1px solid var(--critico-line); padding: 14px 18px; display: flex; align-items: center; gap: 14px; }
.cc-alert-main { display: flex; align-items: center; gap: 14px; flex-grow: 1; min-width: 0; }
.cc-alert-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; background: var(--critico); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.cc-alert-title { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink); }
.cc-alert-detail { font-size: 12px; line-height: 16px; color: var(--ink-soft); }
.cc-body .cc-alert-btn { height: var(--control-height); padding: 0 16px; border-radius: var(--radius-md); border: 1px solid var(--critico-line); background: transparent; color: var(--ink); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; flex-shrink: 0; }
.cc-alert-btn:hover { background: var(--critico-line); }

/* Segmented control */
.cc-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-sunken); border: 1px solid var(--line); }
.cc-seg-btn { height: 30px; padding: 0 12px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-muted); font-size: 12px; cursor: pointer; }
.cc-seg-btn.is-on { background: var(--surface-raised); color: var(--ink); font-weight: 600; }

/* Sidebar nav */
.cc-nav { height: var(--control-height); padding: 0 14px; border-radius: var(--radius-md); display: flex; align-items: center; gap: 12px; text-decoration: none; font-size: 14px; }
.cc-body .cc-nav { color: var(--ink-soft); }
.cc-nav .cc-icon { color: var(--ink-muted); }
.cc-nav:hover { background: var(--surface-raised); }
.cc-body .cc-nav.is-active { background: var(--surface-raised); color: var(--ink); font-weight: 600; }
.cc-nav.is-active .cc-icon { color: var(--ink); }
.cc-nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--critico); color: var(--on-accent); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* ——— Shell ——— */
.cc-shell { min-height: 100vh; display: flex; }
.cc-sidebar { width: var(--sidebar-width); flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 32px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.cc-sidebar .cc-lockup { padding: 0 6px; }
.cc-nav-list { display: flex; flex-direction: column; gap: 4px; }
.cc-nav-group-label { padding: 0 0 6px; }
.cc-sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.cc-main { flex-grow: 1; min-width: 0; padding: var(--space-8) var(--space-10); display: flex; flex-direction: column; gap: var(--space-6); }

.cc-topbar-actions { display: flex; align-items: center; gap: 8px; }

/* Header */
.cc-head { display: flex; align-items: flex-end; gap: 12px; }
.cc-head-text { flex-grow: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cc-greeting { margin: 0; font-size: 32px; line-height: 40px; font-weight: 400; letter-spacing: -.01em; }
.cc-greeting strong { font-weight: 700; }
.cc-head-actions { display: flex; gap: 12px; }
.cc-weather { display: flex; align-items: center; gap: 10px; height: var(--control-height); padding: 0 14px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); color: var(--ink); cursor: pointer; font: inherit; }
.cc-weather:hover { background: var(--surface-raised); }
.cc-weather .cc-icon { color: var(--ink-soft); }
.cc-weather-temp { font-size: 15px; font-weight: 600; }
.cc-weather-meta { font-size: 12px; color: var(--ink-muted); white-space: nowrap; }

/* Grids */
.cc-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-5); }
.cc-kpis.cc-kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cc-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-5); align-items: stretch; }
.cc-span-7 { grid-column: span 7; }
.cc-span-5 { grid-column: span 5; }
.cc-span-12 { grid-column: span 12; }

/* Mobile chrome */
.cc-topbar { display: none; }
.cc-bottomnav { display: none; }

/* Sheets and dialogs */
.cc-sheet[hidden] { display: none; }
.cc-sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.cc-sheet-backdrop { position: absolute; inset: 0; border: 0; padding: 0; background: rgba(10, 11, 14, .6); cursor: pointer; }
.cc-sheet-panel { position: relative; width: min(560px, 100%); max-height: 86vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.cc-sheet-head { display: flex; align-items: center; gap: 12px; }
.cc-sheet-head h2 { margin: 0; flex-grow: 1; font-size: 16px; line-height: 22px; font-weight: 600; }
.cc-icon-btn { width: var(--control-height); height: var(--control-height); border-radius: var(--radius-md); border: 1px solid var(--line); background: transparent; color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.cc-icon-btn:hover { background: var(--surface-raised); color: var(--ink); }
.cc-action-row { text-decoration: none; }
.cc-action-row:hover .cc-row-title { text-decoration: underline; }
.cc-forecast { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cc-day { border: 1px solid var(--line); background: var(--surface-sunken); border-radius: 14px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink); cursor: pointer; font: inherit; }
.cc-day .cc-icon { color: var(--ink-soft); }
.cc-day.is-on { background: var(--surface-raised); border-color: var(--ink-muted); }
.cc-day-temp { font-weight: 700; font-variant-numeric: tabular-nums; }
.cc-hours { display: flex; flex-direction: column; }
.cc-hour { display: grid; grid-template-columns: 56px 24px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.cc-hour .cc-icon { color: var(--ink-soft); }
.cc-hour-rain { color: var(--ink-muted); text-align: right; font-variant-numeric: tabular-nums; }

@media (min-width: 1024px) {
  .cc-sheet { align-items: center; }
  .cc-sheet-panel { border-radius: var(--radius-lg); }
}

@media (min-width: 1024px) and (max-width: 1365px) {
  .cc-weather-meta { display: none; }
}

@media (max-width: 1279px) {
  .cc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cc-span-7, .cc-span-5 { grid-column: span 12; }
}

@media (max-width: 1023px) {
  /* iOS Safari zooma la pagina quando un campo va a fuoco con font-size sotto i 16px:
     è quello che sembra uno zoom "da solo" (e lo scroll orizzontale che ne segue). */
  .cc-input, .cc-select, .cc-textarea { font-size: 16px; }
  .cc-shell { display: block; }
  .cc-sidebar { display: none; }
  .cc-topbar { display: flex; position: sticky; top: 0; z-index: 40; height: 64px; padding: 0 var(--space-5); align-items: center; justify-content: space-between; background: var(--sidebar); border-bottom: 1px solid var(--line); }
  .cc-main { padding: var(--space-5) var(--space-5) calc(var(--bottom-nav-height) + var(--space-6) + env(safe-area-inset-bottom)); gap: var(--space-4); }
  .cc-head { flex-wrap: wrap; align-items: flex-start; }
  .cc-head-text { flex-basis: 100%; }
  .cc-greeting { font-size: 24px; line-height: 30px; }
  .cc-head-actions, .cc-head .cc-avatar { display: none; }
  .cc-weather { width: 100%; }
  .cc-weather-meta { overflow: hidden; text-overflow: ellipsis; }
  .cc-kpis { gap: var(--space-3); }
  .cc-kpi { padding: var(--space-4); gap: 8px; }
  .cc-kpi-value { font-size: 22px; line-height: 28px; }
  .cc-grid { gap: var(--space-4); }
  .cc-card { padding: 18px; }
  .cc-alert { flex-direction: column; align-items: stretch; padding: 16px; }
  .cc-bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom)); padding: 0 8px calc(12px + env(safe-area-inset-bottom)); background: var(--sidebar); border-top: 1px solid var(--line); align-items: center; }
  .cc-tab { flex: 1 1 0; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; font-size: 11px; }
  .cc-body .cc-tab { color: var(--ink-muted); }
  .cc-body .cc-tab.is-active { color: var(--ink); font-weight: 600; }
  .cc-tab.is-active .cc-icon { color: var(--veicolo-text); }
  .cc-fab { width: 52px; height: 52px; flex-shrink: 0; margin: 0 6px; border-radius: 16px; border: 0; background: var(--veicolo); color: var(--on-accent); display: flex; align-items: center; justify-content: center; cursor: pointer; }
}

@media (max-width: 420px) {
  .cc-card-head-filter { flex-wrap: wrap; }
  .cc-card-head-filter .cc-seg { width: 100%; }
  .cc-card-head-filter .cc-seg-btn { flex: 1 1 0; }
  .cc-forecast { gap: 4px; }
  .cc-day { padding: 8px 2px; font-size: 12px; }
}


/* ——— Pagine interne ——— */
body.cc-locked { overflow: hidden; }
.cc-page-title { margin: 0; font-size: 32px; line-height: 40px; font-weight: 700; letter-spacing: -.01em; }
.cc-page-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.cc-stack { display: flex; flex-direction: column; gap: var(--space-6); }
.cc-cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); align-items: start; }
.cc-cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-5); }
.cc-muted { color: var(--ink-muted); }
.cc-soft { color: var(--ink-soft); }
.cc-text-sm { font-size: 13px; line-height: 18px; }
.cc-section-title { margin: 0; font-size: 16px; line-height: 22px; font-weight: 600; }

/* Chip e targa */
.cc-chip { height: 26px; padding: 0 10px; border-radius: var(--radius-full); border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; background: transparent; }
.cc-chip-veicolo { color: var(--veicolo-text); border-color: var(--veicolo-text); }
.cc-chip-finanza, .cc-chip-ok { color: var(--finanza-text); border-color: var(--finanza-text); }
.cc-chip-critico { color: var(--critico-text); border-color: var(--critico-line); }
.cc-body a.cc-chip { text-decoration: none; color: var(--ink-soft); }
.cc-body a.cc-chip.is-on { color: var(--ink); }
a.cc-chip:hover { background: var(--surface-raised); color: var(--ink); }
.cc-chip.is-on { background: var(--surface-raised); color: var(--ink); border-color: var(--ink-muted); font-weight: 600; }
.cc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-plate { height: 30px; display: inline-flex; border-radius: 5px; overflow: hidden; border: 1px solid #C9CCD2; background: #FFFFFF; flex-shrink: 0; }
.cc-plate-band { width: 14px; background: #1D4FB5; }
.cc-plate-text { padding: 0 10px; display: flex; align-items: center; font-family: var(--font-mono); font-size: 14px; font-weight: 500; letter-spacing: .08em; color: #16181D; text-transform: uppercase; }

/* Tabs a link (sottosezioni di pagina) */
.cc-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-sunken); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.cc-tabs::-webkit-scrollbar { display: none; }
.cc-body .cc-tabs a, .cc-tabs button { height: 36px; padding: 0 14px; border-radius: 10px; border: 0; background: transparent; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); text-decoration: none; white-space: nowrap; cursor: pointer; }
.cc-body .cc-tabs .is-on { background: var(--surface-raised); color: var(--ink); font-weight: 600; }
.cc-tabs a:hover, .cc-tabs button:hover { color: var(--ink); }

/* Righe espandibili (dettaglio di un record) */
.cc-entry { border-top: 1px solid var(--line); }
.cc-entry > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.cc-entry > summary::-webkit-details-marker { display: none; }
.cc-entry > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.cc-entry-chevron { color: var(--ink-muted); transition: transform .15s ease; flex-shrink: 0; }
.cc-entry[open] .cc-entry-chevron { transform: rotate(180deg); }
.cc-entry-body { padding: 0 0 16px 48px; display: flex; flex-direction: column; gap: 12px; }
.cc-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cc-fact { background: var(--surface-sunken); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cc-fact-value { font-size: 13px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.cc-entry-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.cc-entry-actions form { margin: 0; }
.cc-btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.cc-body .cc-btn-danger { background: transparent; border-color: var(--critico-line); color: var(--critico-text); }
.cc-btn-danger:hover { background: var(--critico-surface); }
.cc-btn[disabled], .cc-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* Paginazione */
.cc-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); }
.cc-pager-links { display: flex; flex-wrap: wrap; gap: 6px; }
.cc-body .cc-pager-link { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft); text-decoration: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.cc-pager-link:hover { background: var(--surface-raised); }
.cc-body .cc-pager-link.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* Form */
.cc-form { display: flex; flex-direction: column; gap: var(--space-4); }
.cc-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.cc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cc-field-wide { grid-column: 1 / -1; }
fieldset.cc-field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.cc-field > legend { padding: 0; margin-bottom: 6px; }
.cc-label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--ink-soft); }
.cc-hint { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.cc-input, .cc-select, .cc-textarea { width: 100%; min-height: var(--control-height); padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface-sunken); color: var(--ink); font: inherit; font-size: 14px; }
.cc-textarea { min-height: 88px; resize: vertical; }
.cc-select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239A9DA4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.cc-input::placeholder, .cc-textarea::placeholder { color: var(--ink-muted); }
.cc-input:focus, .cc-select:focus, .cc-textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
.cc-input[type="date"], .cc-input[type="datetime-local"], .cc-input[type="month"] { color-scheme: dark; }
:root[data-theme="light"] .cc-input[type="date"], :root[data-theme="light"] .cc-input[type="datetime-local"] { color-scheme: light; }
.cc-check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--control-height); font-size: 14px; color: var(--ink); cursor: pointer; }
.cc-check input { width: 20px; height: 20px; accent-color: var(--veicolo); }
.refuel-hint { margin: 0; }
.refuel-auto { display: inline-flex; align-items: center; gap: 4px; color: var(--veicolo-text); }
.refuel-auto[hidden] { display: none !important; }
.cc-form-foot { display: flex; gap: 12px; justify-content: flex-end; padding-top: var(--space-2); }
.cc-form-foot .cc-btn { min-width: 140px; }

/* Form: errore in cima, importo in evidenza, sezioni facoltative richiudibili */
.cc-form-error { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--critico-surface); border: 1px solid var(--critico-line); color: var(--ink); font-size: 13px; line-height: 18px; }
.cc-form-error .cc-icon { color: var(--critico-text); flex-shrink: 0; margin-top: 1px; }
.cc-input-strong { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cc-input-strong::placeholder { font-weight: 400; }
.cc-more { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-sunken); }
.cc-more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.cc-more > summary::-webkit-details-marker { display: none; }
.cc-more > summary > span { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-more > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 14px; }
.cc-more[open] .cc-entry-chevron { transform: rotate(180deg); }
.cc-more-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.cc-more > .cc-form-grid, .cc-more > .cc-textarea, .cc-more > .cc-more-body { margin: 0 14px 14px; width: auto; }
.cc-more .cc-input, .cc-more .cc-select, .cc-more .cc-textarea { background: var(--surface); }
/* Pastiglie di scelta: radio o checkbox nascosti dentro .cc-chip */
.cc-choice .cc-chip { height: 34px; padding: 0 12px; cursor: pointer; font-size: 13px; }
.cc-choice .cc-chip:hover { background: var(--surface-raised); color: var(--ink); }
.cc-choice .cc-chip:has(input:checked) { background: var(--surface-raised); color: var(--ink); border-color: var(--ink-muted); font-weight: 600; }
.cc-choice .cc-chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.cc-choice .cc-chip.is-dashed { border-style: dashed; }
/* Zona di caricamento file: il campo copre il riquadro, così si può trascinare il file */
.cc-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 16px; border: 1px dashed var(--line); border-radius: 14px; background: var(--surface-sunken); text-align: center; color: var(--ink-muted); cursor: pointer; }
.cc-drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.cc-drop:hover, .cc-drop.is-over { border-color: var(--ink-muted); background: var(--surface-raised); }
.cc-drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.cc-drop.has-file { border-style: solid; border-color: var(--finanza-text); }
.cc-drop.has-file .cc-icon { color: var(--finanza-text); }
.cc-drop-text { font-size: 13px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
[data-panel][hidden] { display: none !important; }
/* Importo in evidenza in cima ai form (movimento, rifornimento, spesa) */
.cc-amount { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 14px 16px; border-radius: 16px; background: var(--surface-sunken); border: 1px solid var(--line); cursor: text; }
.cc-amount:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
.cc-amount-sign, .cc-amount-currency { font-size: 26px; font-weight: 700; color: var(--ink-muted); }
.cc-amount.is-income .cc-amount-sign { color: var(--finanza-text); }
.cc-amount-input { width: 7ch; min-width: 0; flex: 0 1 auto; border: 0; padding: 0; background: transparent; color: var(--ink); font: inherit; font-size: 38px; line-height: 46px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; text-align: left; }
.cc-amount-input:focus { outline: none; }
.cc-amount-input::placeholder { color: var(--mark-graphite-1); }
.cc-amount-input::-webkit-outer-spin-button, .cc-amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cc-amount-input[type="number"] { -moz-appearance: textfield; }
.cc-amount-hint { margin: -8px 0 0; text-align: center; }
.cc-seg-full { display: flex; width: 100%; }
.cc-seg-full .cc-seg-btn { flex: 1 1 0; height: 36px; font-size: 13px; }
/* Interruttore (checkbox) su una riga: testo a sinistra, levetta a destra */
.cc-switch { display: flex; align-items: center; gap: 12px; min-height: var(--control-height); cursor: pointer; font-size: 14px; color: var(--ink); }
.cc-switch > span:first-of-type { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; }
.cc-switch input { appearance: none; -webkit-appearance: none; flex-shrink: 0; width: 42px; height: 24px; margin: 0; border-radius: var(--radius-full); background: var(--surface-raised); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background-color .15s ease; }
.cc-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-muted); transition: transform .15s ease, background-color .15s ease; }
.cc-switch input:checked { background: var(--veicolo); border-color: var(--veicolo); }
.cc-switch input:checked::after { transform: translateX(18px); background: var(--on-accent); }
.cc-switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Nota informativa dentro un form (es. "Chiude Inversione gomme") */
.cc-form-note { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-raised); font-size: 13px; line-height: 18px; color: var(--ink-soft); }
.cc-form-note .cc-icon { flex-shrink: 0; margin-top: 1px; color: var(--veicolo-text); }
.cc-form-note strong { color: var(--ink); font-weight: 600; }
.cc-form-note[hidden] { display: none; }
.cc-picks .cc-chip { height: 32px; cursor: pointer; font-size: 13px; }
.cc-picks .cc-chip:hover { background: var(--surface-raised); color: var(--ink); }
.cc-field > .cc-picks { margin-bottom: 2px; }
.cc-more-body { display: flex; flex-direction: column; gap: 12px; }
.cc-suffix { position: relative; display: flex; }
.cc-suffix .cc-input { padding-right: 56px; }
.cc-suffix > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--ink-muted); pointer-events: none; }
/* Form di Veicolo */
.vehicle-sheet-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.vehicle-amount .refuel-auto { justify-content: center; }
.vehicle-due { margin-top: 10px; }
@media (max-width: 1023px) {
  .vehicle-head-extra { display: none; }
}
/* Modale grande (form) */
.cc-sheet-panel.is-wide { width: min(640px, 100%); }
.cc-sheet-sub { margin: -8px 0 0; font-size: 13px; color: var(--ink-muted); }

/* Messaggio di esito */
.cc-toast { position: fixed; bottom: 24px; right: 24px; z-index: 95; max-width: min(420px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 14px; background: var(--surface-raised); border: 1px solid var(--finanza-text); color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: 0 16px 40px rgba(0, 0, 0, .35); }
.cc-toast .cc-icon { color: var(--finanza-text); }
.cc-toast.is-error { border-color: var(--critico-line); background: var(--critico-surface); }
.cc-toast.is-error .cc-icon { color: var(--critico-text); }
.cc-toast span { flex-grow: 1; }
.cc-toast-close { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.cc-toast .cc-toast-close .cc-icon { color: inherit; }

/* Scheda veicolo */
.cc-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 46%); overflow: hidden; padding: 0; gap: 0; }
.cc-hero-main { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.cc-hero-title { margin: 0; font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -.01em; }
.cc-hero-media { position: relative; min-height: 220px; background: var(--surface-sunken); display: flex; align-items: center; justify-content: center; color: var(--ink-muted); }
.cc-hero-media:not(.is-empty) { background: transparent; }
/* La foto resta intera: si adatta al riquadro senza essere tagliata. */
.cc-hero-media img { position: absolute; inset: 16px; width: calc(100% - 32px); height: calc(100% - 32px); object-fit: contain; object-position: center; }
.cc-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cc-hero-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

/* Veicolo: scheda, diario e colonna laterale */
.vehicle-next { display: flex; flex-direction: column; gap: 8px; }
.vehicle-next-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.vehicle-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.vehicle-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.vehicle-side { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.vehicle-journal-head { flex-wrap: wrap; }
.vehicle-journal-head .cc-chips { margin-left: auto; }
.vehicle-month { padding: 14px 0 6px; }
.vehicle-month:first-child { padding-top: 0; }
.vehicle-spark { width: 100%; height: 60px; color: var(--veicolo); }
.cc-entry > summary .cc-row-value + .cc-entry-chevron { margin-left: 0; }

@media (max-width: 1279px) {
  .vehicle-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cc-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .cc-page-title { font-size: 24px; line-height: 30px; }
  .cc-page-actions { width: 100%; }
  .cc-page-actions .cc-btn { flex: 1 1 0; }
  .cc-cols-2, .cc-cols-3 { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .cc-hero { grid-template-columns: minmax(0, 1fr); }
  .vehicle-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .vehicle-side { display: contents; }
  .vehicle-side #scadenze { order: -1; }
  .vehicle-journal-head .cc-chips { margin-left: 0; width: 100%; }
  .cc-hero-media { min-height: 0; aspect-ratio: 16 / 9; order: -1; }
  .cc-hero-media.is-empty { display: none; }
  .cc-hero-main { padding: 18px; }
  .cc-toast { left: 16px; right: 16px; top: 76px; bottom: auto; max-width: none; }
}
@media (max-width: 560px) {
  .cc-form-grid { grid-template-columns: minmax(0, 1fr); }
  .cc-entry-body { padding-left: 0; }
  .cc-form-foot .cc-btn { flex: 1 1 0; min-width: 0; }
  .cc-sheet-panel { padding: 18px; }
}


/* Login */
.cc-login { min-height: 100vh; min-height: 100dvh; width: min(440px, 100%); margin: 0 auto; padding: var(--space-10) var(--space-4); display: flex; flex-direction: column; justify-content: center; gap: var(--space-6); }
.cc-login-brand { display: flex; align-items: center; justify-content: center; gap: 14px; }
.cc-login-wordmark { font-size: 22px; }
.cc-login-card { gap: var(--space-5); padding: var(--space-8) var(--space-6); }
.cc-login-intro { display: flex; flex-direction: column; gap: 8px; }
.cc-login-title { margin: 0; font-size: 32px; line-height: 40px; font-weight: 400; letter-spacing: -.01em; }
.cc-login-text { margin: 0; color: var(--ink-soft); }
.cc-login-actions { display: flex; flex-direction: column; gap: var(--space-3); }
.cc-login-actions form { margin: 0; }
.cc-login-btn { height: 52px; font-size: 15px; }
.cc-login-error { margin: 0; font-size: 13px; color: var(--critico-text); }
.cc-login-note { display: flex; align-items: center; justify-content: center; gap: 8px; padding-top: var(--space-4); border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); }
.cc-login-footer { text-align: center; font-size: 12px; color: var(--ink-muted); }
.cc-login .cc-alert { align-items: flex-start; }

@media (prefers-reduced-motion: no-preference) {
  .cc-btn, .cc-nav, .cc-weather, .cc-icon-btn, .cc-seg-btn { transition: background-color .15s ease, color .15s ease; }
}
