:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --text: #1f1e1c;
  --text-2: #5f5e5a;
  --text-3: #8c8b85;
  --line: rgba(31, 30, 28, .1);
  --line-2: rgba(31, 30, 28, .18);
  --accent: #1f5fbf;
  --accent-bg: #e6eefa;
  --accent-text: #174a96;
  --ok-bg: #e8f3de; --ok: #2f6410;
  --warn-bg: #faeeda; --warn: #7a4a08;
  --err-bg: #fbe9e9; --err: #9b2b2b;
  --muted-bg: #efeee9; --muted: #5f5e5a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a19; --surface: #232322; --surface-2: #2c2c2a; --text: #ecebe6; --text-2: #b4b2a9; --text-3: #85847e;
    --line: rgba(255,255,255,.09); --line-2: rgba(255,255,255,.16);
    --accent: #6ea4ee; --accent-bg: #1d3352; --accent-text: #a9c9f5;
    --ok-bg: #233517; --ok: #a9d48a; --warn-bg: #3d2c0f; --warn: #f0c27a; --err-bg: #3e1d1d; --err: #f1a3a3;
    --muted-bg: #2c2c2a; --muted: #b4b2a9;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.icon.sm { width: 15px; height: 15px; vertical-align: -3px; }

/* layout */
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--surface-2) 227px, var(--line) 227px, var(--line) 228px, transparent 228px); }
.side { padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; align-self: start; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; padding: 2px 10px 18px; color: var(--text); }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand .mark .icon { width: 17px; height: 17px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--text-2); font-size: 14px; }
.nav:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.nav.active { background: var(--surface); color: var(--text); font-weight: 550; box-shadow: var(--shadow); }
.nav-label { font-size: 11.5px; color: var(--text-3); padding: 16px 10px 6px; text-transform: uppercase; letter-spacing: .05em; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.side-foot .who { padding: 6px 10px; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot form { margin: 0; }
.side-foot button.nav { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; text-align: left; }
.main { padding: 28px 36px 60px; max-width: 1240px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar .sub { color: var(--text-2); margin-top: 3px; font-size: 13.5px; }
.crumbs { font-size: 13px; color: var(--text-3); margin-bottom: 4px; }
.crumbs a { color: var(--text-3); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 22px; overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 7px; padding: 9px 12px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 550; }
.badge-count { background: var(--warn-bg); color: var(--warn); font-size: 11px; border-radius: 10px; padding: 0 7px; font-weight: 600; }

/* componenti */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card, .card + .grid, .grid + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.metric .label { color: var(--text-2); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.metric .value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.metric .hint { color: var(--text-3); font-size: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 550; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.pill.success { background: var(--ok-bg); color: var(--ok); }
.pill.warning { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--err-bg); color: var(--err); }
.pill.muted { background: var(--muted-bg); color: var(--muted); }
.pill.info { background: var(--accent-bg); color: var(--accent-text); }
.cat-necessary { background: var(--muted-bg); color: var(--muted); }
.cat-functional { background: #e1f5ee; color: #085041; }
.cat-analytics { background: var(--accent-bg); color: var(--accent-text); }
.cat-marketing { background: #fbeaf0; color: #72243e; }
.cat-unclassified { background: var(--warn-bg); color: var(--warn); }
@media (prefers-color-scheme: dark) {
  .cat-functional { background: #0e3a2f; color: #9fe1cb; }
  .cat-marketing { background: #4b1528; color: #f4c0d1; }
}

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12.5px; padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: var(--surface-2); }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.empty { text-align: center; padding: 36px 20px; color: var(--text-2); }
.empty .icon { width: 30px; height: 30px; color: var(--text-3); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; font-size: 15px; }

/* form */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label, .label { font-weight: 550; font-size: 13px; }
.field .help { color: var(--text-3); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 7px 10px; min-height: 36px; width: 100%;
}
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; cursor: pointer; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.check span small { display: block; color: var(--text-3); font-size: 12.5px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=text] { width: 110px; font-family: ui-monospace, Menlo, monospace; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 5px 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); }
.seg input:checked + span { background: var(--surface); color: var(--text); font-weight: 550; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
fieldset { border: 0; margin: 0; padding: 0; }
.domain-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; margin-bottom: 8px; }
.domain-block { margin-bottom: 10px; }
.domain-block .sub-list { margin: 0 0 4px; padding-left: 14px; border-left: 2px solid var(--line-2); }
.domain-block .sub-list[hidden] { display: none; }
.domain-row .check { margin: 0; white-space: nowrap; }

.alert { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert.success { background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--err-bg); color: var(--err); }
.alert.warning { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--accent-bg); color: var(--accent-text); }

.snippet { position: relative; background: var(--surface-2); border-radius: var(--radius); padding: 12px 90px 12px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; border: 1px solid var(--line); }
.snippet .btn { position: absolute; top: 7px; right: 7px; }

/* editor banner */
.editor { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 20px; align-items: start; }
.editor .panel { max-height: calc(100vh - 150px); overflow: auto; padding-right: 4px; }
.editor .preview { position: sticky; top: 20px; }
.preview-frame { width: 100%; height: calc(100vh - 190px); min-height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
details.sec { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
details.sec > summary { padding: 13px 16px; cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .15s; margin-right: 4px; }
details.sec[open] > summary::after { transform: rotate(-135deg); }
details.sec > .body { padding: 2px 16px 14px; }
.lang-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.lang-tab { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text-2); }
.lang-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lang-panel { display: none; }
.lang-panel.active { display: block; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 2px; display: flex; gap: 8px; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 380px; max-width: 100%; padding: 28px; }
.auth .brand { padding: 0 0 20px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; min-width: 140px; }
.pager { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 14px; color: var(--text-2); }
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bar-chart .b { flex: 1; display: flex; flex-direction: column-reverse; min-width: 4px; border-radius: 3px 3px 0 0; overflow: hidden; background: var(--surface-2); height: 100%; position: relative; }
.bar-chart .b span { display: block; width: 100%; }
.bar-chart .b .acc { background: var(--accent); }
.bar-chart .b .rej { background: #c9a35a; }
.bar-chart .b .cus { background: #8fb7e8; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-2); margin: 8px 0 4px; }
.split span { display: block; height: 100%; }

@media (max-width: 1000px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor .panel { max-height: none; }
  .preview-frame { height: 560px; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
  .nav { padding: 7px 9px; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .row { grid-template-columns: minmax(0, 1fr); }
  .seg span { padding: 5px 9px; }
  .snippet { padding-right: 14px; padding-bottom: 46px; }
  .snippet .btn { top: auto; bottom: 8px; }
  .topbar .actions { width: 100%; }
  .brand { padding: 4px 8px; width: 100%; }
  .nav-label, .side-foot .who { display: none; }
  .side-foot { margin: 0; border: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
  .main { padding: 18px 14px 40px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  table.list .hide-sm { display: none; }
}

/* verifica in due passaggi */
.setup-steps { margin: 0; padding-left: 22px; }
.setup-steps > li { margin-bottom: 22px; }
.setup-steps > li:last-child { margin-bottom: 0; }
.setup-steps > li::marker { font-weight: 600; color: var(--text-3); }
.setup-steps h2 { margin-bottom: 4px; }
.qr-row { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 20px; align-items: center; margin-top: 10px; }
.qr-box { width: 216px; height: 216px; padding: 8px; background: #fff; border: 1px solid var(--line-2); border-radius: 12px; }
.qr-box svg { display: block; width: 100%; height: 100%; }
.recovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.recovery-grid code { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px; font-size: 15px; letter-spacing: .05em; text-align: center; }
@media (max-width: 760px) {
  .qr-row { grid-template-columns: minmax(0, 1fr); }
  .qr-box { margin: 0 auto; }
}
.field[hidden] { display: none; }
