:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #16202e;
  --muted: #62708a;
  --line: #e3e8f2;
  --brand: #2f6df0;
  --brand-ink: #1f4fc0;
  --danger: #d64545;
  --ok: #1f9d67;
  --shadow: 0 10px 30px rgba(20, 40, 80, .08);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --panel: #161e2c;
    --ink: #e8edf6;
    --muted: #93a1b8;
    --line: #26314a;
    --brand: #5b8bff;
    --brand-ink: #7ea3ff;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand);
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 18px;
}
.brand-name { font-weight: 700; letter-spacing: -.2px; }
.brand-name span { color: var(--brand); }
.topnav { display: flex; align-items: center; gap: 14px; }
.navlink { color: var(--brand-ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.navlink:hover { text-decoration: underline; }
.who { color: var(--muted); font-size: .9rem; }
.inline { display: inline; margin: 0; }

/* Layout */
.wrap { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 34px 20px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 30px;
}
.card.narrow { max-width: 460px; margin: 20px auto; }
h1 { margin: 0 0 8px; font-size: 1.6rem; letter-spacing: -.4px; }
.lead { color: var(--ink); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* Form generico */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { font-weight: 600; font-size: .95rem; }
input[type=email], input[type=text], input[type=number] {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font-size: 1rem;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0;
  padding: 12px 18px; border-radius: 10px; font-size: 1rem; font-weight: 700;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--brand-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.danger { background: var(--danger); }
.btn-ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 9px; cursor: pointer; font-size: .9rem; font-weight: 600;
}
.btn-ghost:hover { color: var(--ink); }
.btn-ghost.danger { color: var(--danger); border-color: transparent; }

.alert {
  background: rgba(214, 69, 69, .1); border: 1px solid rgba(214, 69, 69, .35);
  color: var(--danger); padding: 11px 14px; border-radius: 10px; margin-bottom: 16px;
  font-weight: 600; font-size: .95rem;
}

/* Drop area */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 2px dashed var(--line); border-radius: 12px; padding: 30px 20px;
  text-align: center; cursor: pointer; background: var(--bg); transition: border-color .15s;
}
.drop.over, .drop:hover { border-color: var(--brand); }
.drop input[type=file] { display: none; }
.drop-title { font-weight: 700; }
.drop-hint { color: var(--muted); font-size: .85rem; }
.drop-list { color: var(--brand-ink); font-size: .85rem; margin-top: 6px; word-break: break-word; }

/* Modalità */
.modes { border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px 14px; }
.modes legend { padding: 0 8px; font-weight: 700; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.mode { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 10px; cursor: pointer; }
.mode:hover { background: var(--bg); }
.mode.active { background: rgba(47, 109, 240, .08); }
.mode input[type=radio] { margin-top: 4px; }
.mode-body { display: flex; flex-direction: column; gap: 2px; }
.mode-title { font-weight: 700; }
.mode-desc { color: var(--muted); font-size: .9rem; }
.mode-desc code, .mode-extra code { background: var(--bg); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); }
.mode-extra { margin-top: 6px; font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.num { width: 74px !important; }
.txt { width: 200px !important; max-width: 100%; }

/* Admin */
.row-form { display: flex; gap: 10px; align-items: center; margin: 16px 0 22px; flex-wrap: wrap; }
.row-form .grow { flex: 1; min-width: 200px; width: auto; }
.chk { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.tbl th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbl .right { text-align: right; }
.tag { font-size: .72rem; background: var(--line); color: var(--muted); padding: 1px 7px; border-radius: 20px; font-weight: 700; }
.tag.admin { background: rgba(47, 109, 240, .15); color: var(--brand-ink); }

/* Footer */
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 20px; display: flex; gap: 8px; justify-content: center; }
.foot .dot { opacity: .5; }

/* Modale interna */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 18, 30, .55);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 24px; max-width: 400px; width: 100%;
}
.modal-msg { margin: 0 0 18px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
