:root {
  --bg: #f6f8f3; --card: #ffffff; --ink: #1b2118; --muted: #687062; --line: #e6eadf;
  --soft: #f0f4ea; --accent: #2e7d32; --accent-ink: #ffffff; --accent-soft: #e6f3de;
  --ok: #1f7a46; --ok-bg: #e2f3e8; --warn: #96600a; --warn-bg: #fcf1d9; --bad: #b3312f; --bad-bg: #fbe7e6;
  --info-bg: #e8f0fa; --info: #265f9e;
  --mk-kinguin: #2a78d6; --mk-eneba: #e8742a; --mk-g2a: #8a63d2;
  --radius: 14px; --shadow: 0 1px 2px rgba(25, 40, 15, .05), 0 4px 14px rgba(25, 40, 15, .03);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11140f; --card: #1a1e17; --ink: #eef2e9; --muted: #9aa393; --line: #2a3026;
    --soft: #222820; --accent: #6cc467; --accent-ink: #0d1a0c; --accent-soft: #223a20;
    --ok: #55c88a; --ok-bg: #173a29; --warn: #efb84a; --warn-bg: #3d3010;
    --bad: #f0807e; --bad-bg: #44201f; --info-bg: #14304f; --info: #8cbcf2;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: flex; min-height: 100vh; }

/* barra laterale */
.side { width: 220px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--ink); font-weight: 650; font-size: 16px; line-height: 1.15; }
.brand:hover { text-decoration: none; }
.brand img { display: block; width: 36px; height: auto; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.navlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 12px 4px; }
.side a.nav { display: block; padding: 8px 12px; border-radius: 9px; color: var(--ink); margin-bottom: 1px; }
.side a.nav:hover { background: var(--soft); text-decoration: none; }
.side a.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 12px 12px 2px; }
.main { flex: 1; min-width: 0; padding: 30px 38px 70px; max-width: 1160px; }

h1 { font-size: 26px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 620; margin: 30px 0 12px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card > h2:first-child { margin-top: 0; }

/* numeri principali */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 29px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .n { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* tabelle */
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .r, table.t th.r { text-align: right; }
table.t td.r { white-space: nowrap; }
table.t tfoot td { border-top: 2px solid var(--line); background: var(--soft); font-size: 13.5px; }
.scroll { overflow-x: auto; }

/* etichette, avvisi, barre */
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.alert { padding: 11px 15px; border-radius: 11px; margin-bottom: 10px; background: var(--info-bg); color: var(--info); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.danger { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.bar { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar > i.low { background: #e0a21a; }
.bar.thin { height: 6px; }
.bar.big { height: 14px; }

/* moduli */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.btn { display: inline-block; font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 15px; border-radius: 9px; cursor: pointer; width: auto; text-align: center; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 550; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { padding: 4px 11px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.big { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.sim input.d { width: 78px; text-align: right; padding: 5px 8px; }
.rowform { display: contents; }

/* grafici disegnati dal server (SVG) */
svg.ch { width: 100%; height: auto; display: block; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-ax { fill: var(--muted); font-size: 11px; font-family: inherit; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* marketplace */
.mkdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.mkdot.kinguin { background: var(--mk-kinguin); } .mkdot.eneba { background: var(--mk-eneba); } .mkdot.g2a { background: var(--mk-g2a); }
.chip { display: inline-flex; align-items: center; gap: 0; font-size: 12.5px; background: var(--soft); border-radius: 99px; padding: 2px 9px; margin: 2px 4px 2px 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
td.cell { min-width: 150px; line-height: 1.35; }
.note { font-size: 12.5px; margin: 2px 0; line-height: 1.4; }
.note.bad { color: var(--bad); } .note.warn { color: var(--warn); } .note.info { color: var(--info); }

/* "da fare" nel cruscotto */
.todo { display: flex; flex-direction: column; gap: 2px; }
.todo .item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.todo .item:last-child { border-bottom: 0; }
.todo .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.todo .dot.bad { background: var(--bad); } .todo .dot.warn { background: #e0a21a; } .todo .dot.info { background: var(--info); }
.todo .txt { flex: 1; }
.allgood { color: var(--ok); font-weight: 550; }

/* schede bundle del cruscotto */
.bcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 14px; }
.bcard { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); color: var(--ink); }
.bcard:hover { text-decoration: none; border-color: var(--accent); }
.bcard .top { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 12px; }
.bcard .nums { display: flex; justify-content: space-between; margin-top: 12px; font-size: 13px; color: var(--muted); }
.bcard .nums b { display: block; font-size: 17px; color: var(--ink); font-weight: 620; }

/* schede (tab) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 18px; overflow-x: auto; }
.tabs a, .tabs button { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 14px; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs a.on, .tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .cnt { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; font-size: 11.5px; border-radius: 99px; background: var(--soft); color: var(--muted); text-align: center; }
.tabs .cnt.hot { background: var(--bad-bg); color: var(--bad); }
.js-tabs .pane { display: none; } .js-tabs .pane.on { display: block; }
details.fold > summary { cursor: pointer; font-weight: 600; list-style: none; padding: 2px 0; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "›"; display: inline-block; width: 16px; color: var(--muted); transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }

.waterfall td:last-child, .waterfall th:last-child { text-align: right; }
.waterfall tr.sum td { font-weight: 600; background: var(--soft); }
.waterfall tr.sub td { color: var(--muted); font-size: 13px; }
.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login img { width: 230px; height: auto; margin: 0 auto 6px; display: block; }
.login form { text-align: left; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .brand { padding: 2px 10px; width: 100%; }
  .brand small, .side .foot, .navlabel { display: none; }
  .side a.nav { padding: 6px 10px; }
  .main { padding: 18px 14px 50px; }
  .cols { grid-template-columns: 1fr; }
  .kpi .v { font-size: 24px; }
}
.tabbar { display: none; }
.js-tabs .tabbar { display: flex; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
