/* MIRO Padel — portale admin */
:root {
  --navy: #0B1020;
  --navy-2: #151c33;
  --lime: #B6FF3B;
  --lime-ink: #4d7a00;      /* lime scurito per testo su fondo chiaro */
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --line: #E3E5EA;
  --ink: #0B1020;
  --ink-2: #4a5068;
  --ink-3: #8a90a6;
  --good: #0ca30c;
  --bad: #d03b3b;
  --entrata: #2a78d6;
  --uscita: #eb6834;
  --margine: #1baf7a;
  --radius: 12px;
  --font: 'Montserrat', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--navy); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; text-decoration: none; }
.side .brand img { height: 22px; }
.side .brand span { font-weight: 800; letter-spacing: .18em; font-size: 13px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a, .side nav .soon {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  text-decoration: none; color: #c9cde0; font-weight: 500; position: relative;
}
.side nav a:hover { background: var(--navy-2); color: #fff; }
.side nav a.active { background: var(--navy-2); color: #fff; font-weight: 600; }
.side nav a.active::before {
  content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--lime);
}
.side nav svg { width: 18px; height: 18px; flex: none; }
.side nav .soon { color: #5d6482; cursor: default; }
.side nav .soon small { margin-left: auto; font-size: 10px; border: 1px solid #343b58; border-radius: 99px; padding: 1px 7px; }
.side .group { color: #5d6482; font-size: 11px; font-weight: 600; padding: 18px 12px 6px; }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid #1d2440; }
.side .me img { width: 30px; height: 30px; border-radius: 50%; }
.side .me div { min-width: 0; flex: 1; }
.side .me b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .me button { background: none; border: 0; color: #8a90a6; cursor: pointer; font-size: 12px; padding: 0; }
.side .me button:hover { color: #fff; }

.main { padding: 28px 32px 60px; min-width: 0; }
.head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head h1 { font-size: 24px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.head .sub { color: var(--ink-3); font-size: 13px; }
.head .spacer { flex: 1; }

.mobile-bar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(11,16,32,.45); }
  .mobile-bar {
    display: flex; align-items: center; gap: 12px; background: var(--navy); color: #fff; padding: 12px 16px;
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-bar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; }
  .mobile-bar img { height: 18px; }
  .main { padding: 20px 16px 60px; }
}

/* ---------- controlli ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface); padding: 9px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: #c5c9d3; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: #1b2340; }
.btn.lime { background: var(--lime); color: var(--navy); border-color: var(--lime); }
.btn.lime:hover { filter: brightness(.96); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #e9ebf0; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--entrata); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 9px 11px; outline: none;
}
.input:focus { border-color: var(--entrata); box-shadow: 0 0 0 3px rgba(42,120,214,.15); }
textarea.input { resize: vertical; min-height: 70px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.seg { display: inline-flex; background: #e9ebf0; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(11,16,32,.12); }
.seg.tipo button.on[data-v="entrata"] { background: var(--entrata); color: #fff; }
.seg.tipo button.on[data-v="uscita"] { background: var(--uscita); color: #fff; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { width: auto; }
.search { position: relative; }
.search .input { padding-left: 34px; min-width: 240px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--ink-3); }

/* ---------- card & tabelle ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card > h2, .card-h { font-size: 14px; font-weight: 700; margin: 0; padding: 16px 18px 0; }
.card-h { display: flex; align-items: center; gap: 10px; }
.card-h .muted { font-weight: 500; }
.card .body { padding: 14px 18px 18px; }
.muted { color: var(--ink-3); }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fafbfc;
}
table.t td { padding: 11px 14px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover { background: #f8f9fb; }
table.t .num, table.t th.num { text-align: right; }
table.t td.actions { text-align: right; white-space: nowrap; width: 1%; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: #eef0f4; color: var(--ink-2); white-space: nowrap; }
.pill.entrata { background: #e3eefb; color: #1c5cab; }
.pill.uscita { background: #fdebe3; color: #a8410f; }
.pill.warn { background: #fff3d6; color: #8a5a00; }
.pill.off { background: #f0f0f0; color: #999; }
.amount.entrata { color: #1c5cab; }
.amount.uscita { color: #a8410f; }

.empty { padding: 48px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; font-size: 15px; color: var(--ink); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ---------- modale ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(11,16,32,.5); z-index: 100; display: flex; align-items: flex-start;
  justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .15s;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; box-shadow: 0 30px 80px rgba(11,16,32,.35);
  animation: pop .18s ease-out;
}
.modal.wide { max-width: 820px; }
.modal-h { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; }
.modal-h button { background: none; border: 0; cursor: pointer; color: var(--ink-3); padding: 4px; }
.modal-b { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 16px 16px; }
.modal-f .left { margin-right: auto; }
.form-error { color: var(--bad); font-size: 13px; font-weight: 500; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 10px 30px rgba(11,16,32,.3); animation: pop .2s; }
.toast.error { background: var(--bad); }

/* ---------- combobox ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 14px 40px rgba(11,16,32,.16); z-index: 20; max-height: 280px; overflow-y: auto; padding: 4px;
}
.combo-list button {
  display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; border: 0; background: none; padding: 9px 10px;
  border-radius: 7px; cursor: pointer;
}
.combo-list button:hover, .combo-list button.hl { background: #f0f2f6; }
.combo-list button .r { margin-left: auto; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.combo-list button.create { color: var(--lime-ink); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; }

/* ---------- loading ---------- */
.loading { opacity: .5; transition: opacity .15s; pointer-events: none; }
