:root {
  --brand: #1f4e79;
  --brand-2: #2f6ea5;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #677585;
  --line: #e1e6ec;
  --ok: #1e8e5a;
  --ok-bg: #e6f5ee;
  --warn: #b26a00;
  --warn-bg: #fff4e0;
  --err: #c0392b;
  --err-bg: #fdecea;
  --radius: 10px;
  --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: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); background: var(--bg);
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
small, .muted { color: var(--muted); }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ---------- layout staff ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: #fff; border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; color: var(--text); }
.brand img { height: 34px; width: auto; }
.brand .logo-box {
  width: 34px; height: 34px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800;
}
.side h6 { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 8px 6px; }
.side a.nav { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.side a.nav:hover { background: var(--bg); text-decoration: none; }
.side a.nav.on { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); font-weight: 600; }
.side .who { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .85rem; }
.main { padding: 26px 32px 60px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

/* ---------- layout corsista ---------- */
.header {
  background: #fff; border-bottom: 1px solid var(--line); padding: 10px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.header nav { display: flex; gap: 16px; align-items: center; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* ---------- componenti ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card > h2:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; color: var(--brand); }
.stat span { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand);
  color: #fff; padding: 8px 14px; border-radius: 8px; font: inherit; font-size: .9rem; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.sec { background: #fff; color: var(--brand); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.danger { background: #fff; color: var(--err); border-color: #f0c2bc; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.sm { padding: 4px 9px; font-size: .8rem; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef2f6; color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.brand { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); }

.bar { height: 8px; background: #e9edf2; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.bar.ok > i { background: var(--ok); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: #145c3b; }
.flash.error { background: var(--err-bg); color: #8e2a1f; }
.note { background: #f6f8fb; border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; font-size: .88rem; color: var(--muted); }

label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 4px; color: #3b4754; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd7e0; border-radius: 8px; font: inherit; font-size: .92rem; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.field { margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
details > summary { cursor: pointer; font-weight: 600; color: var(--brand); }
details[open] > summary { margin-bottom: 10px; }

/* moduli e lezioni */
.mod { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; background: #fff; }
.mod-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.mod-h b { font-size: .98rem; }
.lez { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.lez:last-child { border-bottom: 0; }
.lez .t { flex: 1; min-width: 0; }
.lez .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; background: #eef2f6; color: var(--muted); flex: none; }
.lez .ico.ok { background: var(--ok-bg); color: var(--ok); }
.locked { opacity: .55; }

/* lettore lezione */
.player { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.player .contenuto { padding: 24px 28px; font-size: 1rem; line-height: 1.7; }
.player .contenuto img { max-width: 100%; }
.player video, .player iframe { width: 100%; display: block; background: #000; border: 0; }
.player iframe.doc { height: 75vh; background: #fff; }
.tracker {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 14px; align-items: center; justify-content: space-between;
  background: #fff; border-bottom: 1px solid var(--line); padding: 10px 18px; font-size: .88rem; flex-wrap: wrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c2c9d1; display: inline-block; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.pause { background: var(--warn); }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 33, .55); display: none; place-items: center; z-index: 50; padding: 16px; }
.modal.open { display: grid; }
.modal .box { background: #fff; border-radius: 14px; padding: 26px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .box h3 { margin-top: 0; font-size: 1.2rem; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 90%, black) 0%, var(--brand-2) 100%); }
.auth .card { width: 100%; max-width: 420px; padding: 30px; }
.auth .card.wide { max-width: 760px; }
.auth h1 { margin-bottom: 4px; }

/* live */
.live-wrap { height: calc(100vh - 120px); min-height: 480px; background: #111; border-radius: var(--radius); overflow: hidden; }

/* quiz */
.q { padding: 14px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q label.opt { font-weight: 400; display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: .95rem; color: var(--text); }
.q label.opt:hover { background: var(--bg); }
.q label.opt input { width: auto; margin-top: 4px; }

.cal-day { font-weight: 700; color: var(--brand); font-size: .85rem; padding-top: 14px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat b { font-size: 1.3rem; }
  .main { padding: 18px 16px 50px; }
  .wrap { padding: 16px; }
  .header { padding: 10px 16px; }
}
@media print {
  .side, .header, .btn, .actions { display: none !important; }
  .shell { display: block; }
}

.split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
