:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #6b7684;
  --line: #e4e7ec;
  --brand: #12a150;
  --brand-dark: #0d7a3c;
  --brand-soft: #e8f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf5e6;
  --err: #c0392b;
  --err-soft: #fdecea;
  --info-soft: #eef2ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
a { color: var(--brand-dark); }

/* Brand */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 18px; }
.login-card form { display: grid; gap: 10px; margin-top: 14px; }

/* Layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.sidebar nav { display: grid; gap: 4px; }
.nav-item { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-item.disabled { color: var(--muted); cursor: default; }
.nav-item.disabled:hover { background: none; }
.soon { font-size: 10px; text-transform: uppercase; background: var(--bg); padding: 2px 6px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; }
.main { padding: 28px 32px; min-width: 0; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; }
  .sidebar nav { display: flex; }
  .sidebar-foot { margin-top: 0; margin-left: auto; }
  .main { padding: 18px 16px; }
}

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; color: var(--muted); }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge.green { background: var(--brand-soft); color: var(--brand-dark); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--err-soft); color: var(--err); }
.badge.blue { background: var(--info-soft); color: #3b4cca; }

/* Forms */
label { display: grid; gap: 4px; font-weight: 500; font-size: 13px; }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 120px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }

/* Buttons */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 9px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: none; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: default; }

/* Toast */
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--text); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); z-index: 10; max-width: 420px; }
.toast.err { background: var(--err); }

/* Progress bar in table */
.bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--bg); min-width: 120px; }
.bar span { display: block; }
.bar .s-ok { background: var(--brand); }
.bar .s-wait { background: #c7cdd6; }
.bar .s-err { background: var(--err); }
.bar .s-skip { background: #e9ecf1; }

/* Ritocchi */
a.btn { text-decoration: none; display: inline-block; }
.page-head select, .toolbar select { width: auto; min-width: 180px; }
