@font-face { font-family: "Inter"; src: url("../fonts/Inter-Regular.ttf"); font-weight: 400; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-Medium.ttf"); font-weight: 500; }
@font-face { font-family: "Inter"; src: url("../fonts/Inter-SemiBold.ttf"); font-weight: 600; }
@font-face { font-family: "Outfit"; src: url("../fonts/Outfit-SemiBold.ttf"); font-weight: 600; }
@font-face { font-family: "Outfit"; src: url("../fonts/Outfit-Bold.ttf"); font-weight: 700; }

/* Colori dell'app iOS (Theme.swift) */
:root {
  --lime: #C8F31D; --lime-dark: #9BBD12; --on-lime: #10120D;
  --bg: #0B0C0A; --surface: #151713; --raised: #22251E; --stroke: rgba(255,255,255,.08);
  --text: #F4F5F0; --muted: #A2A699; --red: #FF6B5E; --amber: #F5B83D; --blue: #7CC4FF;
  --r-lg: 20px; --r: 14px; --r-sm: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brand { font-family: "Outfit", "Inter", sans-serif; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--lime); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--stroke); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 6px; padding: 0 8px 18px; }
.brand .pin { width: 12px; height: 16px; background: var(--lime); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: inline-block; margin-left: 2px; }
.brand small { font-family: "Inter"; font-size: 11px; font-weight: 500; color: var(--muted); margin-left: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--raised); color: var(--text); }
.nav a.active { background: rgba(200,243,29,.12); color: var(--lime); }
.nav .badge { margin-left: auto; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--stroke); }
.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }
.topbar { display: none; }
.layout > * { min-width: 0; }
.ownerbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--stroke); background: var(--surface); }
.ownerbar .brand { padding: 0; font-size: 20px; }

/* Elementi */
.btn { border: 1px solid var(--stroke); background: var(--raised); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: rgba(255,255,255,.2); }
.btn.primary { background: var(--lime); color: var(--on-lime); border-color: var(--lime); font-weight: 600; }
.btn.primary:hover { background: #d6fb45; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--raised); color: var(--muted); white-space: nowrap; }
.badge.lime { background: rgba(200,243,29,.14); color: var(--lime); }
.badge.red { background: rgba(255,107,94,.14); color: var(--red); }
.badge.amber { background: rgba(245,184,61,.14); color: var(--amber); }
.badge.blue { background: rgba(124,196,255,.14); color: var(--blue); }
.card { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-lg); padding: 18px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.stat .n { font-family: "Outfit"; font-size: 30px; font-weight: 700; }
.stat .l { color: var(--muted); }
.two { grid-template-columns: 1fr 1fr; }
.todo { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--stroke); }
.todo:first-of-type { border-top: 0; }
.todo .grow { flex: 1; min-width: 0; }

/* Filtri */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.input, select.input, textarea.input { background: var(--raised); border: 1px solid var(--stroke); border-radius: var(--r-sm); padding: 8px 12px; outline: none; min-width: 0; }
.input:focus { border-color: var(--lime); }
.search { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--stroke); background: transparent; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Tabella */
.table-wrap { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--r-lg); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(255,255,255,.025); }
td .sub { color: var(--muted); font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.count { color: var(--muted); font-size: 12px; margin: 8px 4px; }

/* Pannello laterale */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--stroke); z-index: 21; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--stroke); }
.drawer-head h2 { flex: 1; }
.drawer-body { padding: 20px 22px; overflow: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--stroke); display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-foot .spacer { flex: 1; }
.x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 4px; }

/* Moduli */
.form { display: grid; gap: 14px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label.f { display: grid; gap: 5px; font-weight: 500; font-size: 13px; }
label.f .input { width: 100%; font-weight: 400; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; background: var(--raised); border: 1px solid var(--stroke); border-radius: 999px; position: relative; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: .15s; }
.switch input:checked { background: var(--lime); border-color: var(--lime); }
.switch input:checked::after { left: 18px; background: var(--on-lime); }
details.more { border: 1px solid var(--stroke); border-radius: var(--r); padding: 10px 14px; }
details.more summary { cursor: pointer; font-weight: 500; color: var(--muted); }
details.more[open] summary { margin-bottom: 12px; }
.hours { display: grid; gap: 6px; }
.chip-check { cursor: pointer; }
.chip-check input { display: none; }
.chip-check span { display: inline-block; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--stroke); background: var(--raised); color: var(--muted); font-size: 13px; font-weight: 500; }
.chip-check input:checked + span { background: rgba(200,243,29,.14); border-color: rgba(200,243,29,.4); color: var(--lime); }
.chip-check input:disabled + span { opacity: .6; cursor: default; }
.votes { display: grid; gap: 4px; }
.vote { display: grid; grid-template-columns: 150px 1fr 32px; gap: 10px; align-items: center; font-size: 13px; }
.vote b { text-align: right; font-weight: 600; }
input[type=range] { accent-color: var(--lime); }
.hours .day { display: grid; grid-template-columns: 90px auto 1fr 1fr; gap: 8px; align-items: center; }
.section { margin-top: 20px; }
.section > h3 { margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.stars { color: var(--lime); letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: #3a3e33; }
.crit { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.quote { background: var(--raised); border-radius: var(--r); padding: 12px 14px; }
.diff { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 6px 10px; font-size: 13px; }
.diff .old { color: var(--muted); text-decoration: line-through; }
.diff .new { color: var(--lime); }
.note { background: rgba(245,184,61,.08); border: 1px solid rgba(245,184,61,.25); color: #f3d79a; border-radius: var(--r); padding: 10px 14px; font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 28px; }
.login .brand { justify-content: center; font-size: 30px; padding: 0 0 4px; }
.demo { display: grid; gap: 6px; margin-top: 14px; }
.error { color: var(--red); font-size: 13px; min-height: 18px; }

/* Avvisi */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; z-index: 40; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.dialog { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; background: rgba(0,0,0,.6); padding: 16px; }
.dialog .card { width: min(420px, 100%); }
.dialog .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Telefono */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 25; width: 250px; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--stroke); background: var(--surface); position: sticky; top: 0; z-index: 10; }
  .topbar .brand { padding: 0; font-size: 20px; }
  .main { padding: 18px 16px 50px; }
  .two, .form .row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .toolbar select.input { flex: 1 1 140px; }
  .ownerbar { padding: 12px 16px; }
  .hours .day { grid-template-columns: 70px auto 1fr 1fr; }
}
