/* =====================================================================
   Portale Ricorsi · BiSolution — design system (tema chiaro)
   Palette derivata dal logo Bi: blu #00B0E2 (accento), lime #C8D000,
   giallo #F0B000, rosso #C80808. Neutri freddi a bias blu.
   Tipografia: Titillium Web (display, font della PA italiana) + Source Sans 3 (testo).
   ===================================================================== */
@import url('/fonts/fonts.css');

:root {
  --bi-blue: #00B0E2; --bi-blue-700: #007AA3; --bi-blue-800: #00618A; --bi-blue-100: #D6F1FA; --bi-blue-50: #EDF8FC;
  --bi-navy: #0B2540; --bi-navy-700: #143A5C; --bi-navy-600: #1E4B73;
  --bi-lime: #C8D000; --bi-lime-700: #5F6B00; --bi-lime-100: #F1F5C2;
  --bi-amber: #F0B000; --bi-amber-700: #8A5B00; --bi-amber-100: #FFF0C2;
  --bi-red: #C80808; --bi-red-700: #A30606; --bi-red-100: #FBDADA;
  --violet: #6E4BB0; --violet-100: #E9E2F6; --green: #5E8E00; --green-100: #E6F0C8;
  --ink: #142433; --ink-2: #33475A; --muted: #5F7080; --muted-2: #8A9AA8;
  --line: #D9E2EB; --line-2: #E8EEF3; --bg: #F3F6F9; --surface: #FFFFFF; --surface-2: #F8FAFC; --surface-3: #EEF3F7;
  --cat-gdp: #007AA3; --cat-gdp-100: #D6F1FA; --cat-prefetto: #6E4BB0; --cat-prefetto-100: #E9E2F6; --cat-autotutela: #5E8E00; --cat-autotutela-100: #E6F0C8;
  --font-display: 'Titillium Web', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;
  --r-s: 6px; --r: 10px; --r-l: 14px;
  --sh-1: 0 1px 2px rgba(11,37,64,.06), 0 1px 3px rgba(11,37,64,.05);
  --sh-2: 0 6px 20px rgba(11,37,64,.10), 0 2px 6px rgba(11,37,64,.06);
  --sh-3: 0 20px 50px rgba(11,37,64,.22);
  --topbar-h: 56px; --sidebar-w: 256px;
  --focus: 0 0 0 3px rgba(0,176,226,.35);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--bi-navy); margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 700; } h2 { font-size: 20px; font-weight: 600; } h3 { font-size: 16px; font-weight: 600; } h4 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 .75em; } a { color: var(--bi-blue-700); text-decoration: none; } a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: .88em; }
.num, .tnum, td.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }
::selection { background: var(--bi-blue-100); }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; } .strong { font-weight: 600; }
.upper { text-transform: uppercase; letter-spacing: .06em; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.nowrap { white-space: nowrap; } .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; } .flex-wrap { flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; } .gap-2 { gap: 16px; } .between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack-s { display: flex; flex-direction: column; gap: 6px; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; } .mb-s { margin-bottom: 8px; } .hidden { display: none !important; }
.right { text-align: right; } .center { text-align: center; }

/* ---- App frame ------------------------------------------------------ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 16px; padding: 0 16px 0 12px; height: var(--topbar-h);
  background: linear-gradient(90deg, #0B2540 0%, #10395B 58%, #007AA3 100%); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 2px 10px rgba(11,37,64,.25); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--bi-blue) 0 35%, var(--bi-lime) 35% 55%, var(--bi-amber) 55% 75%, var(--bi-red) 75% 100%); opacity: .95; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: calc(var(--sidebar-w) - 12px); }
.brand:hover { text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; }
.brand .brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .01em; line-height: 1; }
.brand .brand-sub { display: block; font-size: 11px; opacity: .75; font-weight: 400; letter-spacing: .04em; text-transform: uppercase; margin-top: 3px; }
.topbar-search { flex: 1 1 420px; max-width: 560px; position: relative; }
.topbar-search input { width: 100%; height: 38px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.12); color: #fff; padding: 0 40px 0 40px; font: inherit; font-size: 14px; transition: background .15s, border-color .15s; }
.topbar-search input::placeholder { color: rgba(255,255,255,.7); }
.topbar-search input:focus { background: #fff; color: var(--ink); border-color: #fff; box-shadow: var(--focus); }
.topbar-search input:focus::placeholder { color: var(--muted-2); }
.topbar-search > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.8); pointer-events: none; }
.topbar-search input:focus + i, .topbar-search:focus-within > i { color: var(--muted); }
.topbar-search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 11px var(--font-body); color: rgba(255,255,255,.75); border: 1px solid rgba(255,255,255,.3); border-radius: 5px; padding: 1px 6px; }
.topbar-search:focus-within kbd { display: none; }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: var(--surface); color: var(--ink); border-radius: var(--r); box-shadow: var(--sh-3); border: 1px solid var(--line); overflow: hidden; max-height: 70vh; overflow-y: auto; }
.search-results .sr-group { padding: 8px 14px 4px; } .search-results a.sr-item { display: flex; gap: 10px; align-items: center; padding: 8px 14px; color: var(--ink); }
.search-results a.sr-item:hover, .search-results a.sr-item.active { background: var(--bi-blue-50); text-decoration: none; }
.search-results .sr-item i { color: var(--bi-blue-700); font-size: 16px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 999px; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 19px; transition: background .15s; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn .badge-dot { position: absolute; top: 5px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--bi-red); color: #fff; font: 700 11px/18px var(--font-body); text-align: center; box-shadow: 0 0 0 2px #10395B; }
.avatar { width: 34px; height: 34px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font: 700 13px var(--font-display); background: var(--bi-lime); color: var(--bi-navy); letter-spacing: .02em; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar.org-studio { background: var(--violet-100); color: var(--violet); } .avatar.org-ente { background: var(--bi-blue-100); color: var(--bi-blue-800); } .avatar.org-bisolution { background: var(--bi-lime); color: var(--bi-navy); }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 3px 10px 3px 3px; border-radius: 999px; background: transparent; border: 0; color: #fff; cursor: pointer; font: inherit; }
.user-btn:hover { background: rgba(255,255,255,.14); }
.user-btn .u-name { font-weight: 600; font-size: 13.5px; line-height: 1.1; text-align: left; } .user-btn .u-role { display: block; font-size: 11px; opacity: .75; font-weight: 400; }

.sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px 24px; }
.nav-group { padding: 14px 12px 6px; font-family: var(--font-display); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: 14.5px; margin-bottom: 2px; }
.nav-item i { font-size: 17px; color: var(--muted); width: 20px; text-align: center; }
.nav-item:hover { background: var(--surface-3); text-decoration: none; color: var(--bi-navy); }
.nav-item.active { background: var(--bi-blue-50); color: var(--bi-blue-800); font-weight: 600; box-shadow: inset 3px 0 0 var(--bi-blue); }
.nav-item.active i { color: var(--bi-blue-700); }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-3); border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.nav-count.warn { background: var(--bi-amber-100); color: var(--bi-amber-700); } .nav-count.danger { background: var(--bi-red-100); color: var(--bi-red-700); }
.sidebar-foot { margin: 18px 12px 0; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted-2); line-height: 1.4; }
.sidebar-toggle { display: none; }

.main { min-width: 0; padding: 22px 28px 48px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); } .crumbs i { font-size: 11px; }
.page-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Cards / surfaces --------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; } .card-head h3 i, .card-head h2 i { color: var(--bi-blue-700); }
.card-body { padding: 18px; } .card-body.tight { padding: 10px 12px; } .card-body.flush { padding: 0; }
.card-foot { padding: 10px 18px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid { display: grid; gap: 16px; } .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: inherit; text-decoration: none; transition: transform .15s, box-shadow .15s; }
a.kpi:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--sh-2); }
.kpi-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 21px; background: var(--bi-blue-50); color: var(--bi-blue-700); flex: none; }
.kpi--warn .kpi-icon { background: var(--bi-amber-100); color: var(--bi-amber-700); } .kpi--danger .kpi-icon { background: var(--bi-red-100); color: var(--bi-red-700); } .kpi--ok .kpi-icon { background: var(--green-100); color: var(--green); } .kpi--navy .kpi-icon { background: #E3EAF2; color: var(--bi-navy); } .kpi--violet .kpi-icon { background: var(--violet-100); color: var(--violet); }
.kpi-val { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1; color: var(--bi-navy); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }

/* ---- Buttons ------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; font: 600 14px var(--font-body); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; }
.btn:hover { text-decoration: none; } .btn:active { transform: translateY(1px); } .btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn i { font-size: 15px; }
.btn--primary { background: var(--bi-blue-700); color: #fff; } .btn--primary:hover { background: var(--bi-blue-800); }
.btn--secondary { background: var(--surface); color: var(--bi-navy); border-color: var(--line); box-shadow: var(--sh-1); } .btn--secondary:hover { border-color: #B9C7D4; background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--bi-blue-700); } .btn--ghost:hover { background: var(--bi-blue-50); }
.btn--danger { background: var(--bi-red); color: #fff; } .btn--danger:hover { background: var(--bi-red-700); }
.btn--warn { background: var(--bi-amber-100); color: var(--bi-amber-700); border-color: #F5D98A; } .btn--warn:hover { background: #FBE6A8; }
.btn--lime { background: var(--bi-lime); color: var(--bi-navy); } .btn--lime:hover { background: #B9C000; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; } .btn--xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn--lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn--icon { width: 36px; padding: 0; } .btn--sm.btn--icon { width: 30px; } .btn--xs.btn--icon { width: 26px; }
.btn--block { width: 100%; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.topbar .btn--upload { background: var(--bi-lime); color: var(--bi-navy); border: 0; } .topbar .btn--upload:hover { background: #d8e04d; }

/* ---- Pills, chips, tags -------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill--neutral { background: var(--surface-3); color: var(--ink-2); } .pill--info { background: var(--bi-blue-100); color: var(--bi-blue-800); } .pill--accent { background: #E3EAF2; color: var(--bi-navy); }
.pill--warn { background: var(--bi-amber-100); color: var(--bi-amber-700); } .pill--ok { background: var(--green-100); color: var(--green); } .pill--danger { background: var(--bi-red-100); color: var(--bi-red-700); } .pill--muted { background: var(--surface-3); color: var(--muted); }
.pill--sm { height: 20px; font-size: 11.5px; padding: 0 8px; }
.track { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 6px; font-size: 12.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.track--gdp { background: var(--cat-gdp-100); color: var(--cat-gdp); } .track--prefetto { background: var(--cat-prefetto-100); color: var(--cat-prefetto); } .track--autotutela { background: var(--cat-autotutela-100); color: var(--cat-autotutela); }
.track--sm { height: 20px; font-size: 11px; padding: 0 7px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 7px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; max-width: 100%; }
.chip .dot { width: 8px; height: 8px; border-radius: 2px; flex: none; } .chip i { font-size: 13px; } .chip--sm { height: 20px; font-size: 11.5px; }
.chip--tag { background: var(--bi-blue-50); color: var(--bi-blue-800); border: 1px dashed var(--bi-blue-100); }
.prio-alta { color: var(--bi-amber-700); } .prio-urgente { color: var(--bi-red-700); }
.dot-status { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---- Tables -------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-family: var(--font-display); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover { background: var(--bi-blue-50); } .table tbody tr:last-child td { border-bottom: 0; }
.table .row-link { color: var(--ink); font-weight: 600; } .table a.row-link:hover { color: var(--bi-blue-700); }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table--compact td, .table--compact th { padding: 7px 8px; font-size: 13px; }
.table tr.is-selected td { background: var(--bi-blue-50); }
.table-sub { font-size: 12.5px; color: var(--muted); display: block; margin-top: 1px; }

/* ---- Forms --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); letter-spacing: .02em; }
.field .help { font-size: 12px; color: var(--muted); }
.req::after { content: " *"; color: var(--bi-red); }
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 92px; padding: 9px 12px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--bi-blue); box-shadow: var(--focus); outline: none; }
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--muted); }
.input--sm, .select--sm { height: 32px; font-size: 13px; padding: 0 10px; border-radius: 7px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath fill='%235F7080' d='M2 5l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; } .check input { width: 17px; height: 17px; accent-color: var(--bi-blue-700); margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; } .form-grid .span-all { grid-column: 1 / -1; }
.form-section { padding: 18px; border-bottom: 1px solid var(--line-2); }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; } .form-section > h3 i { color: var(--bi-blue-700); }
.form-section > h3 .hint { font: 400 13px var(--font-body); color: var(--muted); margin-left: 6px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 18px; background: var(--surface-2); border-top: 1px solid var(--line-2); border-radius: 0 0 var(--r) var(--r); }
.filters { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; }
.filters .field { min-width: 150px; } .filters .field > label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; gap: 2px; }
.seg a, .seg button { height: 30px; padding: 0 12px; border-radius: 6px; border: 0; background: transparent; color: var(--ink-2); font: 600 13px var(--font-body); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg a:hover { text-decoration: none; color: var(--bi-navy); } .seg .on { background: var(--surface); color: var(--bi-navy); box-shadow: var(--sh-1); }

/* ---- Pills of workflow (stepper) --------------------------------- */
.stepper { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 4px 0; }
.step { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted-2); white-space: nowrap; }
.step .n { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--muted); border: 2px solid var(--line); }
.step + .step::before { content: ""; width: 14px; height: 2px; background: var(--line); margin: 0 6px; }
.step.done { color: var(--ink-2); } .step.done .n { background: var(--bi-blue-700); border-color: var(--bi-blue-700); color: #fff; }
.step.done + .step::before { background: var(--bi-blue-700); }
.step.now { color: var(--bi-navy); } .step.now .n { background: #fff; border-color: var(--bi-blue); color: var(--bi-blue-700); box-shadow: 0 0 0 4px var(--bi-blue-100); }
.step.warn .n { border-color: var(--bi-amber); color: var(--bi-amber-700); background: var(--bi-amber-100); }

/* ---- Tabs ---------------------------------------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tab:hover { color: var(--bi-navy); text-decoration: none; } .tab.active { color: var(--bi-blue-800); border-bottom-color: var(--bi-blue); }
.tab .cnt { font-size: 11.5px; background: var(--surface-3); color: var(--muted); border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums; } .tab.active .cnt { background: var(--bi-blue-100); color: var(--bi-blue-800); }
.tab .cnt.warn { background: var(--bi-amber-100); color: var(--bi-amber-700); }
.tab-pane { display: none; } .tab-pane.active { display: block; }

/* ---- File explorer (stile Nextcloud / OneDrive) -------------------- */
.explorer { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; }
.folders { display: flex; flex-direction: column; gap: 2px; }
.folder { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: 14px; cursor: pointer; border: 0; background: transparent; text-align: left; font-family: inherit; }
.folder i { color: var(--bi-amber); font-size: 16px; } .folder .nav-count { margin-left: auto; }
.folder:hover { background: var(--surface-3); } .folder.active { background: var(--bi-blue-50); color: var(--bi-blue-800); font-weight: 600; }
.folder.active i { color: var(--bi-amber); }
.explorer-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.explorer-bar .crumbs { margin: 0; font-size: 14px; } .explorer-bar .crumbs strong { color: var(--bi-navy); }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.file-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; transition: box-shadow .15s, border-color .15s, transform .15s; cursor: pointer; }
.file-card:hover { box-shadow: var(--sh-2); border-color: #B9C7D4; transform: translateY(-1px); }
.file-card.is-selected { border-color: var(--bi-blue); box-shadow: 0 0 0 2px var(--bi-blue-100); }
.file-thumb { height: 118px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--line-2); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.file-thumb.generic img { width: 56px; height: auto; object-fit: contain; }
.file-body { padding: 9px 10px 10px; }
.file-name { font-weight: 600; font-size: 13.5px; line-height: 1.25; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; min-height: 34px; }
.file-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.file-tag { position: absolute; top: 8px; left: 8px; max-width: calc(100% - 44px); }
.file-tag .chip { background: rgba(255,255,255,.94); box-shadow: var(--sh-1); }
.file-check { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 6px; background: rgba(255,255,255,.95); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .1s; }
.file-card:hover .file-check, .file-card.is-selected .file-check, .explorer.has-selection .file-check { opacity: 1; }
.file-check input { margin: 0; width: 15px; height: 15px; accent-color: var(--bi-blue-700); }
.file-badges { position: absolute; bottom: 62px; right: 8px; display: flex; gap: 4px; }
.vbadge { display: inline-flex; align-items: center; justify-content: center; height: 20px; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.95); box-shadow: var(--sh-1); }
.vbadge--ok { color: var(--green); } .vbadge--warn { color: var(--bi-amber-700); } .vbadge--sig { color: var(--violet); } .vbadge--v { color: var(--muted); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--r); padding: 22px; text-align: center; color: var(--muted); background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--bi-blue); background: var(--bi-blue-50); color: var(--bi-blue-800); }
.dropzone i { font-size: 28px; color: var(--bi-blue-700); display: block; margin-bottom: 6px; }
.dropzone strong { color: var(--bi-navy); }
.upload-queue { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.upload-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) 90px; align-items: center; gap: 10px; font-size: 13px; }
.upload-row .progress { grid-column: 2 / 4; }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; } .progress > span { display: block; height: 100%; background: var(--bi-blue-700); border-radius: 999px; transition: width .2s; }
.progress--lime > span { background: var(--bi-lime-700); }
.bulk-bar { display: none; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bi-navy); color: #fff; border-radius: var(--r); margin-bottom: 12px; }
.bulk-bar.on { display: flex; } .bulk-bar .btn--secondary { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.2); box-shadow: none; }
.bulk-bar .btn--secondary:hover { background: rgba(255,255,255,.2); }
.file-list .thumb-sm { width: 36px; height: 44px; border-radius: 4px; object-fit: cover; object-position: top; border: 1px solid var(--line-2); background: var(--surface-3); }

/* ---- Checklist / deadlines / timeline ----------------------------- */
.checklist { display: flex; flex-direction: column; gap: 6px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }
.check-row i { font-size: 17px; } .check-row.ok i { color: var(--green); } .check-row.ko i { color: var(--bi-amber-700); } .check-row.ko { background: var(--bi-amber-100); }
.deadlines { display: flex; flex-direction: column; gap: 8px; }
.deadline { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); }
.deadline .d-date { font-family: var(--font-display); font-weight: 700; line-height: 1.05; color: var(--bi-navy); text-align: center; }
.deadline .d-date .day { font-size: 22px; display: block; } .deadline .d-date .mon { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.deadline .d-title { font-weight: 600; font-size: 14px; } .deadline .d-ref { font-size: 12px; color: var(--muted); }
.deadline--urgente { border-color: #F3B8B8; background: #FFF6F6; } .deadline--urgente .d-date { color: var(--bi-red-700); }
.deadline--scaduta { border-color: #F3B8B8; background: var(--bi-red-100); } .deadline--scaduta .d-date { color: var(--bi-red-700); }
.deadline--vicina { border-color: #F5D98A; background: #FFFBEF; } .deadline--vicina .d-date { color: var(--bi-amber-700); }
.deadline--fatta { opacity: .6; } .deadline--fatta .d-title { text-decoration: line-through; }
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 8px 0; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: -8px; width: 2px; background: var(--line-2); }
.tl-item:last-child::before { display: none; }
.tl-ico { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--muted); font-size: 14px; z-index: 1; }
.tl-ico.info { background: var(--bi-blue-100); color: var(--bi-blue-800); } .tl-ico.ok { background: var(--green-100); color: var(--green); } .tl-ico.warn { background: var(--bi-amber-100); color: var(--bi-amber-700); } .tl-ico.danger { background: var(--bi-red-100); color: var(--bi-red-700); }
.tl-title { font-size: 14px; font-weight: 600; } .tl-meta { font-size: 12.5px; color: var(--muted); }
.tl-text { font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }

/* ---- Notifications ------------------------------------------------- */
.notif-panel { position: absolute; right: 0; top: 46px; width: 380px; max-height: 70vh; overflow-y: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-3); z-index: 60; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line-2); font-weight: 700; font-family: var(--font-display); }
.notif { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); color: inherit; }
.notif:hover { background: var(--bi-blue-50); text-decoration: none; } .notif.unread { background: #F5FBFE; } .notif.unread .n-title { font-weight: 700; }
.notif .n-title { font-size: 13.5px; font-weight: 600; } .notif .n-msg { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .notif .n-when { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.notif-page .notif { padding: 12px 16px; grid-template-columns: 38px minmax(0, 1fr) auto; }

/* ---- Modal / dropdown / toast ------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(11,37,64,.45); backdrop-filter: blur(2px); }
.modal.open { display: flex; }
.modal-card { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--sh-3); width: min(720px, 100%); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; animation: pop .15s ease-out; }
.modal-card.lg { width: min(1100px, 100%); } .modal-card.sm { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.modal-body { padding: 18px; overflow-y: auto; } .modal-body.flush { padding: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-3); padding: 6px; z-index: 70; display: none; }
.dropdown.open .dropdown-menu { display: block; } .dropdown-menu.left { right: auto; left: 0; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--ink); background: transparent; border: 0; font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); text-decoration: none; } .dropdown-menu i { color: var(--muted); width: 18px; text-align: center; }
.dropdown-menu .danger { color: var(--bi-red-700); } .dropdown-menu .danger i { color: var(--bi-red-700); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 6px 0; }
.dropdown-menu .dd-head { padding: 8px 10px 4px; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; background: var(--bi-navy); color: #fff; box-shadow: var(--sh-3); font-size: 14px; min-width: 260px; max-width: 420px; animation: pop .15s ease-out; }
.toast i { font-size: 18px; } .toast--ok i { color: var(--bi-lime); } .toast--errore { background: var(--bi-red-700); } .toast--warn { background: var(--bi-amber-700); }
.flash { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--r); margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash--ok { background: var(--green-100); color: #3D5C00; border-color: #CFE3A0; } .flash--errore { background: var(--bi-red-100); color: var(--bi-red-700); border-color: #F3B8B8; } .flash--warn { background: var(--bi-amber-100); color: var(--bi-amber-700); border-color: #F5D98A; } .flash--info { background: var(--bi-blue-50); color: var(--bi-blue-800); border-color: var(--bi-blue-100); }
.flash i { font-size: 18px; } .flash .close { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; font-size: 16px; }

/* ---- Misc ---------------------------------------------------------- */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty i { font-size: 36px; color: var(--muted-2); display: block; margin-bottom: 8px; } .empty strong { color: var(--ink-2); display: block; font-size: 15px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); } .legend span { display: inline-flex; align-items: center; gap: 6px; } .legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.chart-box { position: relative; height: 260px; } .chart-box.sm { height: 200px; } .chart-box.lg { height: 320px; }
.bar-h { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr) 48px; align-items: center; gap: 10px; font-size: 13.5px; padding: 5px 0; }
.bar-h .bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; } .bar-h .bar > span { display: block; height: 100%; border-radius: 999px; background: var(--bi-blue-700); }
.bar-h .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.dl { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: 6px 14px; font-size: 14px; } .dl dt { color: var(--muted); font-weight: 600; font-size: 13px; } .dl dd { margin: 0; min-width: 0; word-break: break-word; }
.dl--tight { gap: 3px 12px; font-size: 13.5px; }
.pagination { display: flex; align-items: center; gap: 4px; justify-content: flex-end; } .pagination a, .pagination span { min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.pagination a:hover { background: var(--surface-3); text-decoration: none; } .pagination .on { background: var(--bi-blue-700); color: #fff; }
.divider { border: 0; border-top: 1px solid var(--line-2); margin: 14px 0; }
.kv { display: flex; align-items: baseline; gap: 6px; font-size: 13.5px; } .kv b { font-family: var(--font-display); font-size: 18px; color: var(--bi-navy); }
.badge-num { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface-3); font-size: 12px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.color-sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: -2px; border: 1px solid rgba(0,0,0,.08); }
.preview-frame { width: 100%; height: 72vh; border: 0; background: var(--surface-3); border-radius: 8px; }
.preview-img { max-width: 100%; max-height: 72vh; display: block; margin: 0 auto; border-radius: 8px; box-shadow: var(--sh-2); }
.sheet-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 8px; } .sheet { border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sheet td, .sheet th { border: 1px solid var(--line-2); padding: 3px 8px; white-space: nowrap; } .sheet th { background: var(--surface-2); position: sticky; top: 0; font-weight: 700; } .sheet tr:first-child td { font-weight: 700; background: var(--surface-2); }
pre.text-preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 60vh; overflow: auto; font-size: 12.5px; white-space: pre-wrap; }
.side-note { border-left: 3px solid var(--bi-blue); background: var(--bi-blue-50); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 13.5px; color: var(--ink-2); }
.side-note--warn { border-color: var(--bi-amber); background: var(--bi-amber-100); } .side-note--danger { border-color: var(--bi-red); background: var(--bi-red-100); }
.lock-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r); background: #E3EAF2; color: var(--bi-navy); font-weight: 600; margin-bottom: 14px; }
.kbd { font: 600 11px var(--font-body); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; background: var(--surface-2); color: var(--muted); }
.mini-list { display: flex; flex-direction: column; gap: 0; } .mini-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; } .mini-row:last-child { border-bottom: 0; }
.mini-row .t { font-weight: 600; color: var(--ink); } .mini-row .s { font-size: 12.5px; color: var(--muted); }
.thumb-xs { width: 34px; height: 40px; border-radius: 4px; object-fit: cover; object-position: top; border: 1px solid var(--line-2); background: var(--surface-3); flex: none; }
.ico-sq { width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; flex: none; }

/* ---- Auth ---------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-brand { position: relative; overflow: hidden; background: linear-gradient(160deg, #0B2540 0%, #10395B 55%, #007AA3 100%); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-brand::before { content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%; border: 54px solid rgba(0,176,226,.18); }
.auth-brand::after { content: ""; position: absolute; right: 60px; bottom: -160px; width: 360px; height: 360px; border-radius: 50%; border: 40px solid rgba(200,208,0,.14); }
.auth-brand img { height: 46px; width: auto; position: relative; z-index: 1; }
.auth-brand h1 { color: #fff; font-size: 40px; font-weight: 700; line-height: 1.08; position: relative; z-index: 1; max-width: 12ch; }
.auth-brand .lead { font-size: 17px; opacity: .88; max-width: 44ch; position: relative; z-index: 1; margin-top: 14px; }
.auth-actors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; position: relative; z-index: 1; margin-top: 34px; }
.actor { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 14px; }
.actor i { font-size: 22px; color: var(--bi-lime); } .actor b { display: block; font-family: var(--font-display); font-size: 15px; margin-top: 8px; } .actor span { font-size: 12.5px; opacity: .8; display: block; margin-top: 2px; line-height: 1.35; }
.auth-foot { font-size: 12.5px; opacity: .75; position: relative; z-index: 1; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--sh-2); padding: 34px 34px 28px; }
.auth-card h2 { font-size: 24px; margin-bottom: 4px; } .auth-card .sub { color: var(--muted); margin-bottom: 22px; }
.auth-card .demo { margin-top: 22px; padding: 12px 14px; background: var(--surface-2); border-radius: 8px; font-size: 12.5px; color: var(--muted); border: 1px dashed var(--line); }
.auth-card .demo code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; color: var(--ink); }

/* ---- Responsive ---------------------------------------------------- */
@media (max-width: 1100px) { .grid-main { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } .explorer { grid-template-columns: 1fr; } .folders { flex-direction: row; flex-wrap: wrap; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; } .sidebar { position: fixed; left: 0; top: var(--topbar-h); width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; z-index: 45; box-shadow: var(--sh-3); }
  .sidebar.open { transform: none; } .sidebar-toggle { display: inline-flex; } .brand { min-width: 0; } .brand .brand-sub { display: none; } .topbar-search { flex-basis: 160px; } .user-btn .u-name { display: none; }
  .main { padding: 16px 14px 40px; } .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .auth { grid-template-columns: 1fr; } .auth-brand { padding: 32px 24px; } .auth-brand h1 { font-size: 30px; } .auth-actors { grid-template-columns: 1fr; }
  .notif-panel { width: min(380px, calc(100vw - 20px)); }
}
@media print { .topbar, .sidebar, .page-actions, .tabs, .btn, .dropzone, .bulk-bar { display: none !important; } .app { display: block; } .main { padding: 0; } .card { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
