*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Surfaces */
  --bg: #FBF9F6;
  --surface: #FFFFFF;
  --surface-sunken: #F4F1EC;
  --surface-raised: #FFFFFF;
  /* Ink */
  --ink: #16140F;
  --ink-2: #3A362E;
  --ink-3: #6B665B;
  --ink-4: #9A9388;
  --ink-5: #C7C0B3;
  /* Lines */
  --line: #E8E3D8;
  --line-strong: #D7D1C2;
  /* Accent */
  --accent: oklch(0.58 0.20 25);
  --accent-ink: oklch(0.46 0.19 25);
  --accent-soft: oklch(0.95 0.04 25);
  --accent-contrast: #FFFFFF;
  --red: var(--accent);
  --red-dark: var(--accent-ink);
  --red-soft: var(--accent);
  /* Semantic */
  --success: oklch(0.60 0.13 150);
  --success-soft: oklch(0.95 0.04 150);
  --warning: oklch(0.72 0.15 65);
  --warning-soft: oklch(0.96 0.05 75);

  /* Danger: rosso semantico fisso (alert, spese, errori). NON segue il primary. */
  --danger: oklch(0.58 0.20 25);
  --danger-soft: oklch(0.95 0.04 25);
  --danger-ink: oklch(0.46 0.19 25);
  --danger: oklch(0.58 0.20 25);
  /* Fonts */
  --font-display: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font: var(--font-body);
  --f-serif: "Instrument Serif", serif;
  --f-mono: var(--font-mono);
  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  /* Density compact default */
  --row-py: 9px;
  --row-px: 14px;
  --card-p: 16px;
  --section-gap: 24px;
  /* Compat */
  --black: var(--ink); --white: var(--surface);
  --gray-50: var(--surface-sunken); --gray-100: var(--line);
  --gray-200: var(--line-strong); --gray-400: var(--ink-3); --gray-600: var(--ink-2);
  --ink-70: var(--ink-2); --ink-55: var(--ink-3); --ink-40: var(--ink-4); --ink-20: var(--ink-5); --ink-10: var(--line);
}
body { font-family: var(--font-body); background: var(--bg); color: var(--ink); display: flex; min-height: 100vh; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11"; }
aside { width: 240px; background: var(--ink); color: var(--ink-5); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 20px 14px 16px; gap: 4px; border-right: 1px solid var(--line-strong); }
.sidebar-header { padding: 0; }
.sidebar-logo-wrap { background: var(--accent); color: var(--accent-contrast); border-radius: var(--r-md); padding: 14px 14px 12px; margin-bottom: 10px; position: relative; overflow: hidden; flex: none; }
.sidebar-logo-wrap::after { content: ""; position: absolute; right: -10px; bottom: -10px; width: 48px; height: 48px; background: radial-gradient(circle, rgba(255,255,255,.18) 0%, transparent 70%); pointer-events: none; }
.sidebar-logo { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -0.03em; line-height: 1; color: white; }
.sidebar-info { padding: 0; margin-top: 4px; }
.sidebar-tema { font-family: var(--font-mono); font-weight: 500; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255,255,255,.75); }
.sidebar-data { display: flex; align-items: center; gap: 8px; color: var(--ink-4); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; padding: 10px 10px 14px; border-bottom: 1px solid rgba(255,255,255,.06); flex: none; text-transform: uppercase; }
nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 0 0; flex: 1; }
nav button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-5); font-size: 13px; width: 100%; text-align: left; transition: background .12s, color .12s; position: relative; background: transparent; border: none; cursor: pointer; font-family: var(--font-body); font-weight: 500; letter-spacing: 0; }
nav button:hover { background: rgba(255,255,255,.04); color: #fff; }
nav button.active { background: rgba(255,255,255,.06); color: #fff; }
nav button.active::before { content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; background: var(--accent); border-radius: 0 2px 2px 0; }
.nav-icon { width: 18px; display: flex; justify-content: center; opacity: .85; flex-shrink: 0; }
.nav-divider { height: 1px; background: rgba(255,255,255,.06); margin: 10px 4px; }
.sidebar-footer { margin-top: 10px; padding: 12px 10px; border: 1px dashed rgba(255,255,255,.12); border-radius: var(--r-md); display: flex; flex-direction: column; gap: 8px; flex: none; }
main { flex: 1; background: var(--bg); min-height: 100vh; }
.main-header { background: transparent; border-bottom: 1px solid var(--line); padding: 20px 28px; display: flex; align-items: center; justify-content: space-between; }
.main-title { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
.main-body { padding: 20px 28px 40px; max-width: 1480px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: var(--section-gap); }
.card-title { font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.metric { border-right: 1px solid var(--line); padding: 14px 18px; background: transparent; border-radius: 0; border-top: none; border-bottom: none; border-left: none; }
.metric:last-child { border-right: none; }
.metric-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); margin-bottom: 6px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500; }
.metric-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; margin: 4px 0 6px; }
.metric-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--section-gap); }
.row-item { display: flex; justify-content: space-between; align-items: center; padding: var(--row-py) 0; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: none; padding-bottom: 0; }
.row-item:first-child { padding-top: 0; }
.item-name { font-size: 13.5px; font-weight: 500; letter-spacing: -0.005em; color: var(--ink); }
.item-sub { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-top: 3px; letter-spacing: 0.02em; }
.badge { font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-gray  { background: var(--surface-sunken); color: var(--ink-3); border: 1px solid var(--line-strong); }
.badge-blue  { background: oklch(0.95 0.04 250); color: oklch(0.4 0.18 250); }
.badge-red   { background: var(--danger); color: #fff; }
.badge-pronto { background: oklch(0.96 0.05 75); color: oklch(0.4 0.15 65); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; letter-spacing: -0.01em; flex-shrink: 0; font-family: var(--font-mono); }
.avatar-red   { background: var(--accent); color: white; }
.avatar-black { background: var(--ink); color: var(--bg); }
.btn { padding: 6px 11px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-size: 12px; font-weight: 500; cursor: pointer; font-family: var(--font-body); letter-spacing: -0.005em; transition: all 0.12s; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface-sunken); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-ink); border-color: var(--danger-ink); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: white; }
hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
input, select, textarea { padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; font-family: var(--font-body); width: 100%; transition: border-color 0.12s, box-shadow 0.12s; letter-spacing: -0.005em; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); display: block; margin-bottom: 6px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.overlay { position: fixed; inset: 0; background: rgba(22,20,15,0.20); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px) saturate(1.05); -webkit-backdrop-filter: blur(2px) saturate(1.05); }
.modal { background: var(--bg); border-radius: var(--r-lg); padding: 28px 32px; width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(22,20,15,0.15); }
.modal-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin-bottom: 20px; letter-spacing: -0.02em; color: var(--ink); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.modal:not(.modal-side) .modal-footer { background: var(--surface); margin: 20px -32px -28px -32px; padding: 16px 32px; border-bottom-left-radius: var(--r-lg); border-bottom-right-radius: var(--r-lg); }
.overlay.overlay-side { background: rgba(22,20,15,0.20); backdrop-filter: blur(2px) saturate(1.05); -webkit-backdrop-filter: blur(2px) saturate(1.05); align-items: stretch; justify-content: flex-end; }
.modal.modal-side { background: var(--bg); width: 520px; max-width: 100vw; max-height: none; height: 100vh; padding: 0; border-radius: var(--r-lg) 0 0 var(--r-lg); border: 1px solid var(--line); border-right: none; box-shadow: -16px 0 48px rgba(22,20,15,0.10); position: relative; display: flex; flex-direction: column; animation: modalSideIn 240ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.modal-side .modal-body { flex: 1; overflow-y: auto; padding: 36px 40px 24px; }
.modal-side .modal-footer { flex-shrink: 0; margin: 0; padding: 20px 40px; background: var(--surface); border-top: 1px solid var(--line); }
@keyframes modalSideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.modal-close { position: absolute; top: 18px; right: 20px; width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background 0.12s, color 0.12s, border-color 0.12s; padding: 0; z-index: 1; }
.modal-close:hover { background: var(--surface-sunken); color: var(--ink); border-color: var(--line-strong); }
.loading { text-align: center; padding: 60px; color: var(--ink-3); font-family: var(--font-mono); font-size: 12px; }
.empty { padding: 24px 0; color: var(--ink-3); font-family: var(--f-serif); font-style: italic; font-size: 15px; }
#toast { position: fixed; bottom: 28px; right: 28px; background: var(--ink); color: white; padding: 10px 16px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 500; letter-spacing: -0.005em; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; z-index: 200; transform: translateY(10px); box-shadow: 0 10px 30px rgba(22,20,15,0.2); }
#toast.show { opacity: 1; transform: translateY(0); }
.drag-handle { cursor: grab; color: var(--ink-5); font-size: 16px; padding: 0 8px 0 0; user-select: none; flex-shrink: 0; display: inline-flex; align-items: center; }
.drag-handle:hover { color: var(--ink-3); }
.dragging { opacity: 0.4; }
.drag-over { border-top: 2px solid var(--accent) !important; }
.link-preview { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.link-preview a { color: var(--accent); text-decoration: none; }
.link-preview a:hover { text-decoration: underline; }
.note-box { font-family: var(--f-serif); font-size: 14px; color: var(--ink-2); margin-top: 6px; font-style: italic; padding: 8px 12px; background: var(--surface-sunken); border-radius: var(--r-sm); line-height: 1.5; }
.tab-btn { padding: 10px 18px; background: transparent; border: none; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer; font-family: var(--font-body); margin-bottom: -1px; transition: color 0.12s; letter-spacing: -0.005em; }
.tab-btn.active { border-bottom-color: var(--accent); color: var(--ink); }
.note-editor { min-height: 260px; max-height: 420px; overflow-y: auto; padding: 14px 16px; font-size: 14px; line-height: 1.7; outline: none; color: var(--ink); font-family: var(--font-body); }
.note-editor a { color: var(--accent); }
.note-editor ul, .note-editor ol { padding-left: 20px; margin: 6px 0; }
.note-editor li { margin-bottom: 2px; }
label:hover .avatar-upload-overlay { opacity: 1 !important; }
/* HERO */
.hero { margin-bottom: 24px; display: grid; grid-template-columns: 1.3fr 2fr; gap: 32px; align-items: end; }
.hero-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; margin-bottom: 10px; }
.hero-title { font-family: var(--font-display); font-size: 40px; line-height: 1.05; margin: 0; font-weight: 600; max-width: 22ch; letter-spacing: -0.03em; color: var(--ink); }
.hero-title em { font-family: var(--f-serif); font-style: italic; font-weight: 400; color: var(--ink-2); }
.hero-accent { color: var(--accent); font-weight: 700; font-size: 54px; font-family: var(--font-display); }
.hero-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.hero-kpis .kpi { border-right: 1px solid var(--line); padding: 14px 18px; }
.hero-kpis .kpi:last-child { border-right: none; }
.kpi-num { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin: 4px 0 6px; letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-success { color: var(--success); }
.kpi-warning { color: var(--warning); }
.kpi-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }
/* DASHBOARD 2-COLUMN LAYOUT */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--section-gap); align-items: start; }
.dash-grid .stack { display: flex; flex-direction: column; gap: var(--section-gap); }
/* BUDGET CARD */
.budget-card .label-mono { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.budget-net { padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.budget-net-num { font-family: var(--font-display); font-size: 36px; font-weight: 600; letter-spacing: -0.02em; margin: 4px 0 2px; color: var(--success); font-variant-numeric: tabular-nums; }
.budget-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.budget-sub-num { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.budget-bar { height: 6px; background: var(--success); border-radius: 999px; position: relative; overflow: hidden; margin-top: 4px; }
.budget-bar-fill { position: absolute; top: 0; left: 0; bottom: 0; background: var(--danger); transition: width .4s; }
.budget-bar-labels { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); }
.budget-breakdown { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.budget-line { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 0; color: var(--ink-2); }
.budget-line span:last-child { color: var(--accent); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ghost-cta { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 9px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); font-size: 12px; color: var(--ink-3); margin-top: 14px; background: transparent; cursor: pointer; font-family: var(--font-body); transition: all 0.12s; }
.ghost-cta:hover { border-color: var(--accent); color: var(--accent); }
/* NOTE CARD */
.notes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.note-item { text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); display: flex; flex-direction: column; gap: 6px; transition: all .12s; cursor: pointer; }
.note-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.note-item-head { display: flex; align-items: center; gap: 8px; }
.note-item-title { font-size: 13px; font-weight: 600; color: var(--ink); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.01em; }
.note-item-body { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }
/* CARD HEADER with link + label */
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.linkbtn { background: transparent; border: none; display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-body); font-size: 12px; color: var(--ink-2); font-weight: 500; cursor: pointer; padding: 0; letter-spacing: -0.005em; }
.linkbtn:hover { color: var(--accent); }
.btn-icon { background: transparent; border: none; padding: 5px; border-radius: 6px; color: var(--ink-4); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.12s; flex-shrink: 0; }
.btn-icon:hover { background: var(--surface-sunken); color: var(--ink); }
.btn-icon svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon.btn-icon-danger:hover { background: var(--danger-soft); color: var(--danger); }
/* SEGMENTED CONTROL (tabs con contatori) */
.seg { display: inline-flex; background: var(--surface-sunken); border-radius: var(--r-sm); padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg-btn { padding: 5px 10px; border-radius: 6px; font-size: 11.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; background: transparent; border: none; cursor: pointer; font-family: var(--font-body); font-weight: 500; letter-spacing: -0.005em; transition: all 0.12s; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }
.seg-count { font-family: var(--font-mono); font-size: 10px; color: var(--ink-4); background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.seg-btn.active .seg-count { background: var(--surface-sunken); color: var(--ink-3); }
.dash-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dash-list-title { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.dash-list-title .sub { display: block; color: var(--ink-4); margin-top: 4px; text-transform: none; letter-spacing: 0.02em; font-size: 11px; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } .hero { grid-template-columns: 1fr; gap: 16px; } .hero-kpis { grid-template-columns: repeat(2, 1fr); } .hero-kpis .kpi:nth-child(2) { border-right: none; } }
@media (max-width: 768px) {
  aside { position: fixed; left: -240px; top: 0; height: 100vh; z-index: 50; transition: left 0.25s ease; }
  aside.open { left: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .main-body { padding: 16px; }
  .main-header { padding: 14px 16px; }
  #sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(22,20,15,0.5); z-index: 49; }
  #sidebar-overlay.open { display: block; }
  #hamburger { display: flex; }
  .hero-title { font-size: 28px; }
  .hero-accent { font-size: 40px; }
  .hero-kpis { grid-template-columns: 1fr 1fr; }
  .hero-kpis .kpi:nth-child(2) { border-right: none; }
}
@media (min-width: 769px) {
  #hamburger { display: none; }
  #sidebar-overlay { display: none !important; }
}
#hamburger { align-items: center; justify-content: center; width: 36px; height: 36px; background: transparent; border: 1px solid var(--line-strong); border-radius: var(--r-sm); cursor: pointer; flex-direction: column; gap: 4px; padding: 8px; flex-shrink: 0; }
#hamburger span { display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 1px; }
/* LOGIN */
#login-screen { position: fixed; inset: 0; width: 100vw; height: 100vh; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 1000; }
.login-card { display: flex; width: 100%; max-width: 1100px; min-height: 620px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 24px 60px rgba(22,20,15,0.08); overflow: hidden; }
.login-left { flex: 0 0 48%; padding: 72px 64px; display: flex; flex-direction: column; justify-content: center; }
.login-right { flex: 1; background: var(--surface-sunken); background-size: cover; background-position: center; background-repeat: no-repeat; position: relative; display: flex; align-items: center; justify-content: center; }
.login-right.has-image .login-right-placeholder { display: none; }
.login-right-placeholder { display: flex; flex-direction: column; align-items: center; gap: 14px; font-family: var(--f-serif); font-style: italic; font-size: 14px; color: var(--ink-4); text-align: center; line-height: 1.45; padding: 24px; }
.login-right-placeholder svg { width: 36px; height: 36px; opacity: 0.5; stroke: currentColor; }
.login-logo { display: flex; align-items: center; gap: 0; margin-bottom: 64px; min-height: 60px; }
.login-logo .ted { font-family: var(--font-display); font-weight: 800; font-size: 52px; letter-spacing: -0.04em; color: var(--accent); line-height: 1; }
.login-logo .x { font-family: var(--font-display); font-weight: 800; font-size: 52px; letter-spacing: -0.04em; color: var(--ink); line-height: 1; }
.login-logo-img { max-width: 200px; max-height: 80px; width: auto; height: auto; object-fit: contain; display: block; }
.login-form { display: flex; flex-direction: column; }
.login-btn { width: 100%; padding: 14px 20px; background: var(--ink); color: var(--bg); border: none; border-radius: var(--r-sm); font-family: var(--font-display); font-weight: 500; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; transition: background 0.15s; margin-top: 6px; }
.login-btn:hover { background: var(--ink-2); }
.login-error { display: none; margin-top: 12px; color: var(--danger); font-family: var(--f-serif); font-style: italic; font-size: 13.5px; line-height: 1.4; }
@media (max-width: 768px) {
  #login-screen { padding: 0; }
  .login-card { flex-direction: column; min-height: 100vh; max-width: 100%; border-radius: 0; border: none; box-shadow: none; }
  .login-right { display: none; }
  .login-left { flex: 1; padding: 48px 28px; }
  .login-logo { margin-bottom: 40px; }
  .login-logo .ted, .login-logo .x { font-size: 44px; }
}
.cal-cell-event { background: var(--accent-soft) !important; position: relative; }
.cal-cell-event::after { content: ''; position: absolute; top: 6px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.dash-grid .stack > .card { margin-bottom: 0; }
.dash-speaker-card { display: flex; flex-direction: column; max-height: 640px; }
.dash-speaker-head { flex-shrink: 0; background: var(--surface); }
.dash-speaker-list { flex: 1 1 auto; overflow-y: auto; min-height: 0; }

/* Spese */
.spese-kpis { padding: 22px 20px; margin-bottom: 18px; }
.spese-kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.spese-kpi { display: flex; flex-direction: column; gap: 4px; }
.spese-kpi-num { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.025em; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.spese-kpi-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px; }
.spese-progress { position: relative; height: 8px; background: var(--surface-sunken); border-radius: 999px; overflow: hidden; margin: 18px 0 14px; }
.spese-progress-fill { height: 100%; background: var(--success); transition: width .4s; }
.spese-progress-label { position: absolute; right: 0; top: -18px; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.spese-cats-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-sunken); }
.spese-cats-seg { min-width: 6px; border-right: 2px solid var(--bg); background: var(--surface-sunken); cursor: help; transition: filter 0.12s; }
.spese-cats-seg:hover { filter: brightness(1.08); }
.spese-cats-seg:last-child { border-right: none; }
.spese-cats-empty { flex: 1; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.spese-cats-tip { position: fixed; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: var(--r-sm); font-family: var(--font-display); font-weight: 500; font-size: 13px; letter-spacing: -0.005em; pointer-events: none; transform: translate(-50%, calc(-100% - 8px)); opacity: 0; transition: opacity 0.1s; z-index: 9999; white-space: nowrap; }
.spese-cats-tip.is-visible { opacity: 1; transition: opacity 0.15s; }
.spese-cats-tip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink); }
.spesa-color-picker { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.spesa-color-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; transition: transform 0.12s, border-color 0.12s; box-shadow: 0 0 0 1px var(--line) inset; }
.spesa-color-swatch:hover { transform: scale(1.1); }
.spesa-color-swatch.is-selected { border-color: var(--ink); transform: scale(1.1); box-shadow: none; }
.spesa-chip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; flex-shrink: 0; }

.spese-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0; margin-bottom: 12px; }
.spese-search { position: relative; flex: 0 0 280px; max-width: 320px; }
.spese-search input { padding-left: 32px; padding-right: 28px; }
.spese-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; display: inline-flex; }
.spese-search-icon svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.spese-search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.spese-cat-row { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; min-width: 0; padding-top: 4px; }
.spese-cat-row > .filter-icon { color: var(--ink-3); display: inline-flex; flex-shrink: 0; }
.spese-cat-row > .filter-icon svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.spese-table-card { overflow: hidden; padding: 0; }
.spese-table { display: flex; flex-direction: column; }
.spese-row { display: grid; grid-template-columns: minmax(220px, 2.4fr) 140px 80px 130px 110px 130px 110px; align-items: center; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--line); transition: background .1s; font-size: 13px; }
.spese-row:first-child { border-top: none; }
.spese-row:hover:not(.spese-row-head):not(.spese-row-detail) { background: var(--surface-sunken); }
.spese-row-head { background: var(--surface-sunken); padding-top: 10px; padding-bottom: 10px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.spese-row-paid .spese-c-name .item-name { color: var(--ink-3); }
.spese-row-paid .spese-c-amount { color: var(--ink-4); text-decoration: line-through; text-decoration-color: var(--ink-5); }
.sort-head { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; text-align: left; letter-spacing: 0.1em; background: transparent; border: none; padding: 0; cursor: pointer; }
.sort-head:hover { color: var(--ink); }
.sort-head[data-active="true"] { color: var(--ink); }
.sort-head-right { justify-content: flex-end; text-align: right; width: 100%; }
.sort-head svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 2; fill: none; }

.spese-c-name { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.spese-expand { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-4); border-radius: 4px; flex: none; background: transparent; border: none; cursor: pointer; padding: 0; margin-top: 1px; }
.spese-expand:hover { background: var(--surface); color: var(--ink); }
.spese-expand svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 2; fill: none; }
.spese-note-preview { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }
.spese-cat-tag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--ink); padding: 3px 8px; border-radius: 999px; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.spese-cat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); flex-shrink: 0; }
.spese-c-date { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.spese-c-vendor { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spese-c-amount { font-family: var(--font-mono); font-weight: 600; text-align: right; font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.spese-c-actions { display: flex; justify-content: flex-end; gap: 2px; }

.pay-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--warning-soft); color: oklch(0.5 0.15 65); border: 1px solid transparent; cursor: pointer; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; transition: all .18s; }
.pay-toggle:hover { border-color: var(--warning); }
.pay-toggle-thumb { width: 18px; height: 18px; border-radius: 999px; background: var(--surface); border: 1px solid currentColor; display: inline-flex; align-items: center; justify-content: center; flex: none; transition: all .18s; }
.pay-toggle-thumb svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pay-toggle-on { background: var(--success-soft); color: var(--success); }
.pay-toggle-on .pay-toggle-thumb { background: var(--success); color: #fff; border-color: var(--success); transform: scale(1.05); }

.spese-row-detail { display: block; background: var(--surface-sunken); padding: 14px 20px 16px; border-top: 1px solid var(--line); }
.spese-detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.spese-detail-note { font-family: var(--f-serif); font-size: 13.5px; color: var(--ink-2); margin: 6px 0 0; font-style: italic; line-height: 1.55; }
.spese-att { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--ink-2); }

.spese-foot { padding: 12px 20px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; background: var(--surface-sunken); }
.spese-empty { padding: 60px 20px; text-align: center; color: var(--ink-3); font-family: var(--f-serif); font-style: italic; }

@media (max-width: 1100px) {
  .spese-row { grid-template-columns: minmax(160px, 1.6fr) 120px 70px 100px 110px 110px 90px; gap: 8px; }
  .spese-c-vendor { display: none; }
  .spese-row-head .col-vendor { display: none; }
}
@media (max-width: 820px) {
  .spese-row { grid-template-columns: 1fr auto auto; }
  .spese-row > .spese-c-cat, .spese-row > .spese-c-date, .spese-row > .spese-c-vendor { display: none; }
  .spese-row-head .col-cat, .spese-row-head .col-date, .spese-row-head .col-vendor { display: none; }
}

/* ── Moodboard ── */

.mb-empty-state { padding: 80px 20px; text-align: center; }

.mb-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.mb-filter-chip { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: all 0.12s; }
.mb-filter-chip:hover { border-color: var(--ink-4); }
.mb-filter-chip.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.mb-filter-clear { font-family: var(--font-mono); font-size: 11px; padding: 5px 10px; background: transparent; border: none; color: var(--ink-3); cursor: pointer; text-decoration: underline; margin-left: 4px; }

.mb-grid { column-count: 4; column-gap: 14px; }
@media (max-width: 1280px) { .mb-grid { column-count: 3; } }
@media (max-width: 900px)  { .mb-grid { column-count: 2; } }
@media (max-width: 560px)  { .mb-grid { column-count: 1; } }

.mb-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; margin: 0 0 14px; overflow: hidden; break-inside: avoid; cursor: pointer; position: relative; transition: border-color 0.12s, box-shadow 0.12s; }
.mb-card:hover { border-color: var(--ink-4); box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.mb-card-actions { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity 0.12s; z-index: 2; display: flex; gap: 4px; }
.mb-card:hover .mb-card-actions { opacity: 1; }
.mb-card-actions .btn-icon { background: var(--surface); border: 1px solid var(--line); }

.mb-card-img img { width: 100%; height: auto; display: block; }
.mb-card-fallback { padding: 30px 14px; text-align: center; font-size: 12px; color: var(--ink-4); background: var(--surface-sunken); }

.mb-card-quote .mb-card-body { padding: 18px 16px 14px; }
.mb-quote-text { font-family: var(--f-serif, serif); font-size: 17px; line-height: 1.45; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.mb-quote-text::before { content: "\201C"; font-size: 28px; line-height: 0; vertical-align: -8px; color: var(--ink-4); margin-right: 2px; }
.mb-quote-text::after  { content: "\201D"; font-size: 28px; line-height: 0; vertical-align: -8px; color: var(--ink-4); margin-left: 2px; }
.mb-quote-author { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-top: 8px; letter-spacing: 0.04em; }

.mb-link-thumb { width: 100%; height: auto; display: block; }
.mb-card-link .mb-card-body { padding: 14px 16px; }
.mb-link-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 4px; line-height: 1.3; }
.mb-link-url { font-family: var(--font-mono); font-size: 11px; color: var(--accent); text-decoration: none; word-break: break-all; }
.mb-link-url:hover { text-decoration: underline; }

.mb-card-img .mb-card-body { padding: 10px 12px 12px; }
.mb-card-title { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.mb-card-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.04em; margin-bottom: 6px; }
.mb-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mb-card-tag { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; background: var(--surface-sunken); border-radius: 999px; color: var(--ink-3); letter-spacing: 0.04em; }
.mb-card-date { font-family: var(--font-mono); font-size: 10px; color: var(--ink-4); margin-top: 8px; letter-spacing: 0.04em; text-transform: uppercase; }

/* Modale moodboard: tag chips input */
.mb-tag-chips-input { display: flex; flex-wrap: wrap; gap: 4px; min-height: 8px; }
.mb-tag-chip { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 11px; padding: 3px 4px 3px 8px; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); letter-spacing: 0.04em; }
.mb-tag-chip button { background: transparent; border: none; color: var(--ink-4); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.mb-tag-chip button:hover { color: var(--accent); }
