/* Font serviti dall'app, senza richieste a Google Fonts */
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400 900; font-display: swap; src: url(/fonts/figtree-latin.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(/fonts/jetbrains-mono-latin.woff2) format('woff2'); }
:root {
  --bg: #f3f0ec;
  --shell: #faf8f5;
  --panel: #f5f2ee;
  --card: #ffffff;
  --ink: #16191a;
  --ink-2: #4a4744;
  --muted: #857f79;
  --line: #ebe6e0;
  --line-2: #e0dad3;
  --brand: #2353d8;
  --logo-orange: #2f62f0;
  --logo-ink: #16191a;
  --brand-2: #1a3fae;
  --teal: #2f62f0;
  --teal-soft: #a9bffa;
  --teal-bg: #ecf1ff;
  --red: #d12f2f;
  --red-bg: #fdecec;
  --amber: #c7780a;
  --amber-bg: #fff4e2;
  --blue: #2a63c9;
  --blue-bg: #e8f0fd;
  --green: #18855a;
  --green-bg: #e3f5ec;
  --gray-bg: #f2eee9;
  --radius: 22px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(22, 25, 26, .04);
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; gap: 12px; min-height: 100vh; padding: 12px; }
.sidebar { background: var(--shell); border-radius: var(--radius); padding: 26px 14px 14px; display: flex; flex-direction: column; position: sticky; top: 12px; height: calc(100vh - 24px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 28px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 24px; letter-spacing: -0.04em; color: var(--logo-ink); }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--logo-orange); display: grid; place-items: center; }
.logo-mark svg { width: 18px; height: 18px; color: #fff; stroke-width: 2.2; }
.logo b { color: var(--logo-orange); font-weight: 800; }
.brand-tag { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--brand); background: var(--teal-bg); padding: 4px 8px; border-radius: 999px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; color: var(--muted); padding: 0 12px; margin: 6px 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--ink-2); font-size: 15px; }
.nav a:hover { background: #eceeed; }
.nav a svg { width: 19px; height: 19px; color: var(--muted); }
.nav a.active { color: var(--ink); font-weight: 600; }
.nav a.active svg { color: var(--teal); }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav .count { margin-left: auto; min-width: 24px; height: 20px; padding: 0 7px; border-radius: 7px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.nav .count.red { background: var(--red); }
.side-promo { margin-top: auto; position: relative; overflow: hidden; background: var(--brand-2); color: #fff; border-radius: 18px; padding: 18px; }
.side-promo::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-18deg, transparent 0 14px, rgba(255,255,255,.035) 14px 15px); pointer-events: none; }
.side-promo .ic { width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--brand-2); display: grid; place-items: center; margin-bottom: 16px; }
.side-promo .ic svg { width: 17px; height: 17px; }
.side-promo h4 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.side-promo p { margin: 0 0 16px; font-size: 12.5px; opacity: .75; line-height: 1.45; }
.side-promo .btn { position: relative; z-index: 1; width: 100%; background: #fff; color: var(--brand-2); justify-content: center; }

.main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.topbar { background: var(--shell); border-radius: var(--radius); padding: 12px 20px 12px 20px; display: flex; align-items: center; gap: 12px; }
.search { flex: 0 1 420px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; color: var(--muted); }
.search input { border: 0; outline: 0; flex: 1; background: transparent; color: var(--ink); min-width: 0; }
.search svg { width: 17px; height: 17px; }
.kbd { font-size: 11px; font-weight: 600; background: var(--gray-bg); border-radius: 6px; padding: 2px 6px; color: var(--ink-2); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--shell); }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 6px; cursor: pointer; position: relative; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--teal-bg); color: var(--brand); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.user-chip .who b { display: block; font-size: 14px; font-weight: 600; }
.user-chip .who span { font-size: 12px; color: var(--muted); }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.08); padding: 6px; min-width: 200px; z-index: 50; }
.menu a, .menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 12px; border: 0; background: none; border-radius: 9px; cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--panel); }
.menu svg { width: 16px; height: 16px; color: var(--muted); }

.content { background: var(--panel); border-radius: var(--radius); padding: 28px 26px 30px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 32px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.crumb { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.crumb:hover { color: var(--ink); }
.crumb svg { width: 15px; height: 15px; }

/* ---------- buttons, chips ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent; font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-outline { background: transparent; border-color: var(--brand); color: var(--brand); }
.btn-outline:hover { background: #fff; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--line-2); }
.btn-danger { background: #fff; border-color: #f2c8c8; color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { height: 32px; padding: 0 13px; font-size: 13px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 25px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.chip.red { background: var(--red-bg); color: var(--red); border-color: #f6d3d3; }
.chip.amber { background: var(--amber-bg); color: var(--amber); border-color: #f6e0bc; }
.chip.teal { background: var(--teal-bg); color: var(--brand); border-color: #cbd8fb; }
.chip.blue { background: var(--blue-bg); color: var(--blue); border-color: #d2e0fa; }
.chip.green { background: var(--green-bg); color: var(--green); border-color: #c9ead9; }
.chip.gray { background: var(--gray-bg); color: var(--ink-2); border-color: var(--line); }
.chip .spin { width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tag { font-family: var(--mono); font-size: 11.5px; background: var(--gray-bg); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; color: var(--ink-2); }

/* ---------- cards ---------- */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.card-head h3 { font-size: 17px; font-weight: 600; }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.kpi { position: relative; display: block; padding: 22px 22px 20px; transition: transform .15s; }
.kpi:hover { transform: translateY(-1px); }
.kpi .t { font-weight: 600; font-size: 15px; }
.kpi .v { font-size: 44px; font-weight: 600; letter-spacing: -0.03em; margin: 20px 0 8px; line-height: 1; }
.kpi .s { font-size: 12.5px; color: var(--teal); display: flex; gap: 6px; align-items: center; }
.kpi .s svg { width: 15px; height: 15px; }
.kpi .go { position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; }
.kpi .go svg { width: 15px; height: 15px; }
.kpi.dark { background: var(--brand); color: #fff; }
.kpi.dark .s { color: #d6e1ff; }
.kpi.dark .go { background: #fff; color: var(--brand); border-color: #fff; }
.kpi .s.warn { color: var(--red); }

.dash-row-1 { grid-template-columns: 1.55fr 1fr 1.25fr; margin-bottom: 14px; }
.dash-row-2 { grid-template-columns: 1.55fr 1.1fr 1.15fr; }

.bars { display: flex; align-items: flex-end; justify-content: space-around; height: 180px; gap: 10px; padding-top: 26px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; height: 100%; justify-content: flex-end; position: relative; }
.bar { width: 100%; max-width: 46px; border-radius: 999px; background: var(--teal-soft); min-height: 46px; position: relative; }
.bar.peak { background: var(--teal); }
.bar.today { background: var(--brand); }
.bar.empty { background: repeating-linear-gradient(-45deg, #cfeee9 0 5px, #fff 5px 9px); border: 1px solid #bfe4de; }
.bar-col .lbl { font-size: 12px; color: var(--muted); }
.bar-col .val { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 600; border: 1px solid var(--line-2); border-radius: 7px; padding: 1px 6px; background: #fff; }

.focus-title { font-size: 22px; color: var(--brand); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; margin-bottom: 8px; }
.focus-meta { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.badge-n { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 7px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

.actions-list { display: flex; flex-direction: column; gap: 16px; }
.action { display: flex; gap: 14px; align-items: flex-start; }
.action .ai { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.action .ai svg { width: 16px; height: 16px; }
.action .ai.amber { background: var(--amber-bg); color: var(--amber); }
.action .ai.teal { background: var(--teal-bg); color: var(--teal); }
.action .ai.red { background: var(--red-bg); color: var(--red); }
.action b { display: block; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.action small { font-size: 12.5px; color: var(--muted); }
.action small.red { color: var(--red); }

.people { display: flex; flex-direction: column; }
.person { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person .info { flex: 1; min-width: 0; }
.person .info b { display: block; font-weight: 600; font-size: 14.5px; }
.person .info span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.person .info span em { font-style: normal; color: var(--ink); font-weight: 500; }

.gauge-wrap { display: flex; flex-direction: column; align-items: center; }
.gauge-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.gauge-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.dark-card { background: var(--brand-2); color: #fff; position: relative; overflow: hidden; display: flex; flex-direction: column; }
.dark-card::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-18deg, transparent 0 22px, rgba(255,255,255,.03) 22px 23px); pointer-events: none; }
.big-num { font-size: 56px; font-weight: 600; letter-spacing: -0.04em; margin: 14px 0 0; }
.big-num small { font-size: 18px; font-weight: 400; opacity: .8; margin-left: 6px; letter-spacing: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: auto; position: relative; z-index: 1; }
.mini-stats div { background: rgba(255,255,255,.08); border-radius: 12px; padding: 10px 12px; }
.mini-stats span { display: block; font-size: 11.5px; opacity: .7; }
.mini-stats b { font-size: 17px; font-weight: 600; }

/* ---------- tables & filters ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { height: 36px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-size: 14px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }
.tab .n { font-size: 11.5px; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.tab.active .n { color: #d6e1ff; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.field-box { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line-2); border-radius: 14px; padding: 0 14px; height: 46px; }
.field-box svg { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.field-box input, .field-box select { border: 0; outline: 0; background: transparent; flex: 1; height: 100%; min-width: 0; font-size: 14.5px; }
select.input, .field-box 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 24 24' fill='none' stroke='%2344514f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 2px center; padding-right: 22px; cursor: pointer; }
select.input { background-position: right 12px center; padding-right: 34px; }

.table-card { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: #fafbfb; }
.tbl tr.flag td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.tbl tr.warn td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.tbl .doc-cell b { display: block; font-size: 15px; font-weight: 600; margin: 5px 0 2px; }
.tbl .doc-cell small { color: var(--muted); font-size: 12.5px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .chk { width: 44px; padding-right: 0; }
.tbl input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.who-cell { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.when { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.when svg { width: 14px; height: 14px; }
.when.red { color: var(--red); }
.when.amber { color: var(--amber); }
.conf { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.conf .track { flex: 1; height: 6px; border-radius: 3px; background: var(--gray-bg); overflow: hidden; }
.conf .fill { height: 100%; border-radius: 3px; background: var(--teal); }
.conf.mid .fill { background: var(--amber); }
.conf.low .fill { background: var(--red); }
.conf span { font-size: 12.5px; font-weight: 600; width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.bulkbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--teal-bg); border-bottom: 1px solid #cbd8fb; }
.bulkbar b { margin-right: auto; color: var(--brand); }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--line-2); margin-bottom: 10px; }
.empty h4 { margin: 0 0 6px; color: var(--ink); font-size: 16px; font-weight: 600; }

/* ---------- document detail ---------- */
.doc-layout { display: grid; grid-template-columns: minmax(340px, 0.9fr) 1.4fr; gap: 14px; align-items: start; }
.doc-layout > *, .two-col > * { min-width: 0; }
.preview { position: sticky; top: 12px; padding: 12px; }
.preview-frame { background: var(--panel); border-radius: 14px; height: calc(100vh - 150px); min-height: 420px; overflow: auto; display: flex; align-items: flex-start; justify-content: center; }
.preview-frame img { max-width: 100%; display: block; transform-origin: top center; }
.preview-frame iframe { width: 100%; height: 100%; border: 0; border-radius: 14px; }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 4px 6px 12px; }
.preview-bar .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.no-file { margin: auto; text-align: center; color: var(--muted); padding: 30px; }
.no-file svg { width: 44px; height: 44px; color: var(--line-2); }

.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-4 { grid-column: 1 / -1; }
.fld label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; height: 42px; border: 1px solid var(--line-2); border-radius: 11px; padding: 0 12px; background: #fff; outline: 0; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47,98,240,.16); }
.input.low { border-color: #f0c47c; background: #fffbf3; }
.lowdot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }

.lines-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.lines { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1080px; }
.lines th { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 0 4px 8px; white-space: nowrap; }
.lines td { padding: 3px 3px; vertical-align: middle; }
.lines input { width: 100%; height: 36px; border: 1px solid transparent; border-radius: 8px; padding: 0 8px; background: var(--panel); outline: 0; font-size: 13.5px; }
.lines input:focus { border-color: var(--teal); background: #fff; }
.lines input.r { text-align: right; font-variant-numeric: tabular-nums; }
.lines tr.low input { background: #fff6e6; }
.lines .no { color: var(--muted); font-size: 12px; text-align: center; width: 28px; }
.lines .del { width: 30px; height: 30px; border: 0; background: none; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.lines .del:hover { background: var(--red-bg); color: var(--red); }
.lines .del svg { width: 15px; height: 15px; }
.lines-foot { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.lines-foot .tot { margin-left: auto; font-size: 13px; color: var(--muted); }
.lines-foot .tot b { font-size: 18px; color: var(--ink); margin-left: 8px; }

.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; margin-bottom: 14px; }
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.notice.red { background: var(--red-bg); color: #8f1f1f; }
.notice.amber { background: var(--amber-bg); color: #7a4a06; }
.notice.teal { background: var(--teal-bg); color: var(--brand); }
.notice b { display: block; margin-bottom: 2px; }
.sticky-actions { position: sticky; bottom: 12px; z-index: 5; display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 999px; padding: 8px 8px 8px 20px; margin-top: 14px; box-shadow: 0 8px 24px rgba(15,29,28,.08); }
.sticky-actions .info { margin-right: auto; font-size: 13px; color: var(--muted); }

/* ---------- upload ---------- */
.drop { display: block; border: 2px dashed var(--line-2); border-radius: var(--radius); background: #fff; padding: 56px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--teal); background: #f5f8ff; }
.drop .ic { width: 64px; height: 64px; border-radius: 20px; background: var(--teal-bg); color: var(--teal); display: grid; place-items: center; margin: 0 auto 18px; }
.drop .ic svg { width: 28px; height: 28px; }
.drop h3 { font-size: 20px; margin-bottom: 6px; }
.drop p { margin: 0 0 18px; color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.step { display: flex; gap: 12px; }
.step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; font-size: 13px; }
.step b { display: block; margin-bottom: 3px; }
.step p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.queue-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.queue-item:last-child { border-bottom: 0; }
.file-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--panel); display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0; font-size: 10px; font-weight: 700; }
.queue-item .info { flex: 1; min-width: 0; }
.queue-item .info b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .info small { color: var(--muted); }

/* ---------- profiles ---------- */
.profiles { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.profile-card { cursor: pointer; display: flex; flex-direction: column; gap: 14px; border: 1px solid transparent; transition: border-color .15s; }
.profile-card:hover { border-color: var(--line-2); }
.profile-card .top { display: flex; gap: 12px; align-items: center; }
.sw-ic { width: 44px; height: 44px; border-radius: 13px; background: var(--teal-bg); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.profile-card h3 { font-size: 16px; }
.profile-card .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.profile-card .foot { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; }
.cols-editor { display: flex; flex-direction: column; gap: 6px; }
.col-row { display: grid; grid-template-columns: 24px 1fr 1.3fr 1fr 96px; gap: 8px; align-items: center; }
.col-row .idx { font-size: 12px; color: var(--muted); text-align: center; }
.col-row .btns { display: flex; gap: 2px; justify-content: flex-end; }
.col-row .btns button { width: 30px; height: 30px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.col-row .btns button:hover { background: var(--panel); color: var(--ink); }
.col-row .btns svg { width: 15px; height: 15px; }
.col-row .input { height: 38px; }
.preview-table { overflow: auto; max-height: 340px; border: 1px solid var(--line); border-radius: 12px; }
.preview-table table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.preview-table th, .preview-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
.preview-table th { background: var(--panel); position: sticky; top: 0; font-family: var(--mono); font-weight: 600; font-size: 11.5px; }
.preview-table td { font-family: var(--mono); font-size: 12px; }

.two-col { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; align-items: start; }
.export-sum { display: flex; gap: 22px; margin: 4px 0 18px; }
.export-sum div span { display: block; font-size: 12px; color: var(--muted); }
.export-sum div b { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 14px; cursor: pointer; background: #fff; }
.radio-item.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,98,240,.10); }
.radio-item input { accent-color: var(--brand); width: 17px; height: 17px; }
.radio-item b { display: block; font-weight: 600; }
.radio-item small { color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

.plan-meter { height: 10px; border-radius: 5px; background: var(--gray-bg); overflow: hidden; margin: 10px 0 6px; }
.plan-meter div { height: 100%; background: var(--teal); border-radius: 5px; }
.plans { grid-template-columns: repeat(3, 1fr); }
.plan { border: 1px solid var(--line-2); border-radius: 18px; padding: 18px; }
.plan.current { border-color: var(--brand); background: #f7fbfa; }
.plan h4 { margin: 0 0 4px; font-size: 16px; }
.plan .price { font-size: 26px; font-weight: 600; margin: 8px 0; }
.plan .price small { font-size: 13px; color: var(--muted); font-weight: 400; }
.plan ul { padding-left: 18px; margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.7; }

/* ---------- modal, toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 25, 24, .35); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .15s; }
.modal { background: #fff; border-radius: 24px; padding: 26px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { width: min(980px, 100%); }
.modal h3 { font-size: 20px; margin-bottom: 6px; }
.modal .sub { color: var(--muted); margin: 0 0 20px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: fade .2s; display: flex; gap: 8px; align-items: center; }
.toast.err { background: var(--red); }
.toast svg { width: 16px; height: 16px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; padding: 12px; gap: 12px; }
.auth-side { background: var(--logo-orange); border-radius: var(--radius); color: #fff; padding: 44px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-side::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(-18deg, transparent 0 26px, rgba(255,255,255,.05) 26px 27px); }
.auth-side .logo { color: #fff; position: relative; z-index: 1; }
.auth-side .logo-mark { background: #fff; }
.auth-side .logo-mark svg { color: var(--logo-orange); }
.auth-side .logo b { color: var(--logo-ink); }
.auth-side h2 { font-size: 52px; font-weight: 800; line-height: 1.02; letter-spacing: -0.045em; margin: auto 0 22px; max-width: 520px; position: relative; z-index: 1; }
.auth-side h2 mark { display: inline-block; margin-top: 10px; background: #fff; color: #c94f0f; padding: 0 14px 2px; border-radius: 12px; font-size: .78em; }
.auth-side p { opacity: .9; max-width: 440px; line-height: 1.55; font-size: 15px; position: relative; z-index: 1; }
.auth-feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 30px; position: relative; z-index: 1; }
.auth-feats div { background: rgba(255,255,255,.16); border-radius: 14px; padding: 14px; font-size: 13px; }
.auth-feats b { display: block; font-size: 22px; margin-bottom: 2px; }
.auth-main { background: var(--shell); border-radius: var(--radius); display: grid; place-items: center; padding: 30px; }
.auth-form { width: min(400px, 100%); }
.auth-form h1 { font-size: 30px; margin-bottom: 6px; }
.auth-form > p { color: var(--muted); margin: 0 0 26px; }
.auth-form .switch { text-align: center; margin-top: 18px; color: var(--muted); }
.auth-form .switch a { color: var(--brand); font-weight: 600; cursor: pointer; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--ink-2); cursor: pointer; }
.consent input { width: 17px; height: 17px; margin: 1px 0 0; flex: none; accent-color: var(--brand); cursor: pointer; }
.consent a, .legal-links a { color: var(--brand); font-weight: 600; }
.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 22px; font-size: 12px; color: var(--muted); }
.legal-links a { color: var(--muted); font-weight: 500; }
.legal-links a:hover { color: var(--brand); }
.err-msg { color: var(--red); font-size: 13.5px; min-height: 18px; }

/* ---------- monete ---------- */
.coin-chip { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.coin-chip i { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe08a, #e0a91a); box-shadow: inset 0 0 0 2px #d39b10; }
.coin-chip span { font-weight: 500; color: var(--muted); }
.coin-chip.low { border-color: #f2c8c8; color: var(--red); background: var(--red-bg); }
.tbl-compact td, .tbl-compact th { padding: 10px 12px; }

/* ---------- shell mobile ---------- */
.menu-btn, .mobile-logo, .scrim { display: none; }

@media (max-width: 1280px) {
  .dash-row-1, .dash-row-2 { grid-template-columns: 1fr 1fr; }
  .dash-row-1 > :first-child, .dash-row-2 > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .doc-layout, .two-col { grid-template-columns: 1fr; }
  .preview { position: static; }
  .preview-frame { height: 480px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; padding: 8px; gap: 8px; }
  .sidebar { position: fixed; z-index: 90; top: 0; left: 0; bottom: 0; height: 100vh; height: 100dvh; width: 280px; max-width: 86vw; border-radius: 0 22px 22px 0;
    transform: translateX(-105%); transition: transform .25s ease; overflow-y: auto; box-shadow: 0 0 40px rgba(0,0,0,.18); }
  .nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(10,25,24,.35); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: grid; flex-shrink: 0; }
  .mobile-logo { display: flex; font-size: 20px; }
  .mobile-logo .logo-mark { width: 26px; height: 26px; }
  .topbar { flex-wrap: wrap; padding: 10px 12px; border-radius: 18px; position: sticky; top: 8px; z-index: 40; }
  .topbar .search { order: 10; flex: 1 1 100%; padding: 8px 14px; }
  .topbar .kbd { display: none; }
  .user-chip .who { display: none; }
  .content { padding: 20px 14px 26px; border-radius: 18px; }
  .preview-frame { height: 60vh; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .page-head { margin-bottom: 16px; gap: 12px; }
  .page-head h1 { font-size: 26px; }
  .page-head p { font-size: 14px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; justify-content: center; }
  .hide-sm { display: none !important; }
  .coin-chip { height: 36px; padding: 0 11px; }
  .coin-chip span { display: none; }
  .icon-btn, .avatar { width: 36px; height: 36px; }
  .top-actions { gap: 6px; }
  .card { padding: 18px; border-radius: 18px; }
  .kpis { gap: 10px; }
  .kpi { padding: 16px; }
  .kpi .t { font-size: 13.5px; padding-right: 34px; }
  .kpi .v { font-size: 32px; margin: 14px 0 6px; }
  .kpi .s { font-size: 11.5px; }
  .kpi .go { width: 28px; height: 28px; top: 14px; right: 14px; }
  .dash-row-1, .dash-row-2, .steps, .plans, .export-sum { grid-template-columns: 1fr; }
  .dash-row-1 > *, .dash-row-2 > * { grid-column: auto !important; }
  .export-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .bars { height: 150px; gap: 6px; }
  .big-num { font-size: 44px; }
  .mini-stats { grid-template-columns: 1fr 1fr 1fr; }
  .mini-stats div { padding: 8px; }
  .mini-stats b { font-size: 15px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin-left: -14px; margin-right: -14px; padding: 0 14px 4px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; }
  .filters { grid-template-columns: 1fr 1fr; gap: 8px; }
  .field-box { height: 42px; padding: 0 12px; }
  .form-grid { grid-template-columns: 1fr 1fr !important; }
  .form-grid > * { grid-column: auto !important; }
  .form-grid .span-2, .form-grid .span-4, .form-grid [style*="span 3"] { grid-column: 1 / -1 !important; }
  .drop { padding: 34px 16px; }
  .drop h3 { font-size: 17px; }
  .queue-item { flex-wrap: wrap; }
  .queue-item .info { flex-basis: calc(100% - 52px); }
  .queue-item > div[style] { width: auto !important; flex: 1; margin-left: 52px; }
  .lines-wrap { margin: 0 -18px; padding: 0 18px; }
  .lines-foot { flex-wrap: wrap; }
  .sticky-actions { bottom: 8px; border-radius: 999px; padding: 6px; gap: 6px; }
  .sticky-actions .info { display: none; }
  .sticky-actions .btn { flex: 1; justify-content: center; padding: 0 12px; }
  .col-row { grid-template-columns: 22px 1fr 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .col-row:first-child { display: none; }
  .col-row > :nth-child(4) { grid-column: 2 / 3; }
  .col-row .btns { grid-column: 3 / 4; }
  .radio-item { padding: 10px 12px; }
  .bulkbar { flex-wrap: wrap; }
  .bulkbar b { width: 100%; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal, .modal.wide { width: 100%; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); max-height: 92vh; }
  .modal .foot .btn { flex: 1; justify-content: center; }
  .toasts { left: 12px; right: 12px; transform: none; bottom: 12px; }
  .toast { border-radius: 16px; }
  .auth { grid-template-columns: 1fr; padding: 8px; }
  .auth-side { display: none; }
  .auth-main { padding: 26px 18px; min-height: calc(100vh - 16px); }
  .profiles { grid-template-columns: 1fr; }

  /* tabelle come schede */
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tbody tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .tbl tbody tr:last-child { border-bottom: 0; }
  .tbl td { display: block; padding: 0; border: 0; min-width: 0; }
  .tbl td[data-label]:not(.doc-cell):not(.chk):not(:empty)::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
  .tbl td.doc-cell { grid-column: 1 / -1; padding-right: 30px; }
  .tbl td.doc-cell b { margin-top: 4px; }
  .tbl td.chk { position: absolute; top: 14px; right: 16px; width: auto; }
  .tbl td.chk:empty, .tbl td:empty { display: none; }
  .tbl .num { text-align: left; }
  .tbl tr.flag td:first-child, .tbl tr.warn td:first-child { box-shadow: none; }
  .tbl tr.flag { box-shadow: inset 3px 0 0 var(--red); }
  .tbl tr.warn { box-shadow: inset 3px 0 0 var(--amber); }
  .tbl td .input { width: 100% !important; }
  .tbl-compact tbody tr { grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; }
  .tbl-compact td::before { display: none !important; }
  .tbl-compact td:nth-child(2) { grid-row: 2; font-size: 12.5px; color: var(--muted); }
  .tbl-compact td:nth-child(3) { grid-row: 1 / 3; grid-column: 2; align-self: center; }
  .table-scroll { overflow: visible; max-height: none !important; }
}
@media (max-width: 420px) {
  .filters { grid-template-columns: 1fr; }
  .kpi .v { font-size: 28px; }
  .mobile-logo { font-size: 18px; }
}

/* ---------- area admin ---------- */
.support-bar { position: sticky; top: 0; z-index: 95; display: flex; align-items: center; gap: 10px; padding: 9px 16px; background: var(--amber); color: #fff; font-size: 14px; }
.support-bar svg { width: 17px; height: 17px; flex-shrink: 0; }
.support-bar span { flex: 1; min-width: 0; }
.support-bar .btn { background: #fff; color: #7a4a06; height: 32px; }
.mobile-only { display: none !important; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin: 6px 0 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row b { display: block; font-weight: 600; margin-bottom: 2px; }
.switch-row small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.toggle { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); cursor: pointer; transition: background .15s; }
.toggle span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--brand); }
.toggle input:checked + span::after { transform: translateX(20px); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat { background: #fff; border-radius: 18px; padding: 18px; }
.stat span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.stat b { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.stat small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.stat.good b { color: var(--green); }
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-top: 10px; }
.chart-bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; min-width: 0; }
.chart-bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart-bars .pair i { display: block; width: 42%; max-width: 18px; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.chart-bars .lbl { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.key-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--panel); margin-bottom: 14px; }
.key-box b { font-family: var(--mono); font-size: 13px; }
.admin-tabs { margin-bottom: 18px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .mobile-only { display: flex !important; }
  .support-bar { font-size: 12.5px; padding: 8px 12px; flex-wrap: wrap; }
  .support-bar .btn { width: 100%; justify-content: center; }
  .stat-grid { gap: 10px; }
  .stat { padding: 14px; }
  .stat b { font-size: 20px; }
  .chart-bars { height: 160px; gap: 4px; }
  .chart-bars .lbl { font-size: 9.5px; }
}
@media (max-width: 420px) { .filters[style] { grid-template-columns: 1fr !important; } }
.mail-preview { width: 100%; height: min(65vh, 620px); border: 1px solid var(--line); border-radius: var(--radius-sm); background: #eef0ef; }

/* ---------- ClickFattura ---------- */
.lines select { width: 100%; height: 36px; border: 1px solid transparent; border-radius: 8px; padding: 0 4px; background: var(--panel); outline: 0; font-size: 13px; }
.lines select:focus { border-color: var(--teal); background: #fff; }
.lines tr.low select { background: #fff6e6; }
.preview-bar .icon-btn.active { background: var(--brand); color: #fff; }
.radio-item small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tot-cell { font-size: 13.5px; white-space: nowrap; }
.promo-bar { display: flex; align-items: center; gap: 12px; background: var(--teal-bg); color: var(--brand); border-radius: 14px; padding: 10px 10px 10px 16px; margin: 0 0 12px; font-size: 13.5px; line-height: 1.45; }
.promo-bar > svg { width: 18px; height: 18px; flex-shrink: 0; }
.promo-bar span { flex: 1; }
.promo-bar .icon-btn { width: 30px; height: 30px; flex-shrink: 0; }
