/* Gestionale Palestra — stile di base (struttura dalla Cartella Nutrizionale,
   tavolozza e caratteri della palestra). Caratteri inclusi nel programma
   (licenza SIL OFL, vedi fonts/): nessuna richiesta a server esterni. */
@font-face{font-family:'Archivo'; src:url('../fonts/archivo-latin.woff2') format('woff2'); font-weight:100 900; font-stretch:62% 125%; font-style:normal; font-display:swap; unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}
@font-face{font-family:'Archivo'; src:url('../fonts/archivo-latin-ext.woff2') format('woff2'); font-weight:100 900; font-stretch:62% 125%; font-style:normal; font-display:swap; unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;}
@font-face{font-family:'IBM Plex Mono'; src:url('../fonts/ibm-plex-mono-400.woff2') format('woff2'); font-weight:400; font-display:swap;}
@font-face{font-family:'IBM Plex Mono'; src:url('../fonts/ibm-plex-mono-500.woff2') format('woff2'); font-weight:500; font-display:swap;}
@font-face{font-family:'IBM Plex Mono'; src:url('../fonts/ibm-plex-mono-600.woff2') format('woff2'); font-weight:600; font-display:swap;}

  /* Tavolozza: notte (barra laterale), cobalto (azioni), carta (fondo). */
  :root{
    color-scheme: light;
    --bg:#F3F5F9; --bg-elev:#FFFFFF; --surface:#FFFFFF; --surface-2:#EEF1F7; --surface-hover:#E7EBF3;
    --border:#DDE2EC; --border-strong:#C5CCDA;
    --text:#0E1B3D; --text-2:#4A5675; --text-muted:#6B7590;
    --accent:#2448E0; --accent-strong:#1A36B4; --accent-soft:#E6ECFD; --accent-contrast:#FFFFFF;
    --danger:#C9372C; --danger-soft:#FBE9E7; --danger-strong:#952319;
    --good:#0E8A5F; --good-soft:#E2F4EC; --warn:#A86A00; --warn-soft:#FFF3D9;
    --notte:#0E1B3D; --notte-2:#17285A; --notte-testo:#C9D2EC;
    --shadow: 0 1px 2px rgba(14,27,61,0.06), 0 10px 28px -16px rgba(14,27,61,0.22);
    --velo:rgba(36,72,224,0.10); --velo-2:rgba(36,72,224,0.06);
    --font-display:'Archivo', -apple-system, "Segoe UI", sans-serif;
    --font-body:'Archivo', -apple-system, "Segoe UI", sans-serif;
    --font-mono:'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  }
  @media (prefers-color-scheme: dark){
    :root:not([data-theme="light"]){
      color-scheme: dark;
      --bg:#0A1022; --bg-elev:#111A33; --surface:#111A33; --surface-2:#18233F; --surface-hover:#1E2A4A;
      --border:#25314F; --border-strong:#34426A;
      --text:#E8ECF6; --text-2:#B4BED6; --text-muted:#8590AD;
      --accent:#7B96FF; --accent-strong:#A3B5FF; --accent-soft:rgba(123,150,255,0.16); --accent-contrast:#0A1022;
      --danger:#FF8A7E; --danger-soft:#3A1A18; --danger-strong:#FFB4AB;
      --good:#4FC490; --good-soft:#10301F; --warn:#F2B94B; --warn-soft:#33280D;
      --notte:#070C1A; --notte-2:#111A33; --notte-testo:#B4BED6;
      --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 10px 28px -14px rgba(0,0,0,0.55);
      --velo:rgba(123,150,255,0.14); --velo-2:rgba(123,150,255,0.08);
    }
  }
  :root[data-theme="dark"]{
    color-scheme: dark;
    --bg:#0A1022; --bg-elev:#111A33; --surface:#111A33; --surface-2:#18233F; --surface-hover:#1E2A4A;
    --border:#25314F; --border-strong:#34426A;
    --text:#E8ECF6; --text-2:#B4BED6; --text-muted:#8590AD;
    --accent:#7B96FF; --accent-strong:#A3B5FF; --accent-soft:rgba(123,150,255,0.16); --accent-contrast:#0A1022;
    --danger:#FF8A7E; --danger-soft:#3A1A18; --danger-strong:#FFB4AB;
    --good:#4FC490; --good-soft:#10301F; --warn:#F2B94B; --warn-soft:#33280D;
    --notte:#070C1A; --notte-2:#111A33; --notte-testo:#B4BED6;
    --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 10px 28px -14px rgba(0,0,0,0.55);
    --velo:rgba(123,150,255,0.14); --velo-2:rgba(123,150,255,0.08);
  }

  *{box-sizing:border-box;}
  html,body{margin:0;padding:0;}
  body{
    background:var(--bg); color:var(--text); font-family:var(--font-body);
    font-size:14px; line-height:1.5; -webkit-font-smoothing:antialiased;
  }
  h1,h2,h3,h4{font-family:var(--font-display); font-weight:600; margin:0; text-wrap:balance; color:var(--text);}
  a{color:var(--accent);}
  button{font-family:inherit;}
  input,select,textarea{font-family:inherit; font-size:14px;}
  ::selection{background:var(--accent-soft);}
  .num{font-family:var(--font-mono); font-variant-numeric:tabular-nums;}

  [hidden]{display:none !important;}

  /* ---------- Gate ---------- */
  #gate{
    min-height:100vh; display:flex; align-items:center; justify-content:center;
    padding:32px 16px; background:
      radial-gradient(860px 460px at 10% -8%, var(--velo), transparent 62%),
      radial-gradient(700px 400px at 105% 106%, var(--velo-2), transparent 60%),
      var(--bg-elev);
  }
  .gate-card{
    width:100%; max-width:394px; background:var(--surface);
    border:1px solid var(--border); border-top:4px solid var(--accent);
    border-radius:18px; padding:30px 30px 28px;
    box-shadow:0 1px 2px rgba(20,30,22,.06), 0 26px 64px -30px rgba(20,30,22,.42);
  }
  .gate-mark{
    width:44px;height:44px;border-radius:12px;background:var(--accent);color:var(--accent-contrast);
    display:flex;align-items:center;justify-content:center;font-size:20px;margin-bottom:16px;
  }
  .gate-card h1{font-family:var(--font-body); font-size:11px; font-weight:700; letter-spacing:.13em;
    text-transform:uppercase; color:var(--accent-strong); margin-bottom:6px; text-align:center;}
  .gate-sub{color:var(--text-2); font-size:13px; line-height:1.5; margin:0 0 20px; text-align:center;}
  #gate-body{border-top:1px solid var(--border); padding-top:20px;}
  .gate-note{margin-top:18px; font-size:11.5px; color:var(--text-muted); line-height:1.55; text-align:center;}
  .gate-error{color:var(--danger); font-size:13px; margin-top:10px; min-height:16px; text-align:center;}

  /* ---------- Form basics ---------- */
  .field{display:flex; flex-direction:column; gap:6px; margin-bottom:14px;}
  .field label{font-size:12px; font-weight:600; color:var(--text-2); letter-spacing:.01em;}
  .field .hint{font-size:11.5px; color:var(--text-muted);}
  input:not([type]),input[type=text],input[type=date],input[type=time],input[type=search],input[type=number],input[type=password],input[type=email],input[type=tel],select,textarea{
    width:100%; padding:9px 11px; border-radius:9px; border:1px solid var(--border-strong);
    background:var(--bg-elev); color:var(--text); outline:none; transition:border-color .12s, box-shadow .12s;
  }
  textarea{resize:vertical; min-height:64px; font-family:inherit;}
  input:focus,select:focus,textarea:focus{border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft);}
  input::placeholder,textarea::placeholder{color:var(--text-muted);}
  .row{display:flex; gap:12px; flex-wrap:wrap;}
  .row > .field{flex:1 1 160px; min-width:0;}
  .grid-2{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
  .grid-3{display:grid; grid-template-columns:repeat(3,1fr); gap:12px;}
  @media (max-width:640px){ .grid-2,.grid-3{grid-template-columns:1fr;} }

  button{cursor:pointer;}
  .btn{
    display:inline-flex; align-items:center; gap:6px; padding:9px 15px; border-radius:9px;
    border:1px solid var(--border-strong); background:var(--bg-elev); color:var(--text);
    font-size:13.5px; font-weight:600; transition:background .12s,border-color .12s,transform .05s;
  }
  .btn:hover{background:var(--surface-hover);}
  .btn:active{transform:translateY(1px);}
  .btn-primary{background:var(--accent); border-color:var(--accent); color:var(--accent-contrast);}
  .btn-primary:hover{background:var(--accent-strong); border-color:var(--accent-strong);}
  .btn-danger{background:transparent; border-color:var(--danger); color:var(--danger);}
  .btn-danger:hover{background:var(--danger-soft);}
  .btn-ghost{background:transparent; border-color:transparent;}
  .btn-ghost:hover{background:var(--surface-hover);}
  .btn-sm{padding:6px 10px; font-size:12.5px; border-radius:7px;}
  .btn-block{width:100%; justify-content:center;}
  .btn[disabled]{opacity:.5; cursor:not-allowed;}
  .icon-btn{width:30px;height:30px;padding:0;justify-content:center;border-radius:7px;}

  /* ---------- Shell ---------- */
  .shell{display:flex; min-height:100vh;}
  .sidebar{
    width:228px; flex-shrink:0; background:var(--bg-elev); border-right:1px solid var(--border);
    display:flex; flex-direction:column; padding:18px 14px; gap:4px; position:sticky; top:0; height:100vh;
  }
  .brand{display:flex; flex-direction:column; align-items:flex-start; gap:4px; padding:4px 8px 16px;}
  .brand-logo{display:block; width:100%; height:auto;}
  /* La base chiara sotto al logo: nel tema chiaro si confonde con la pagina,
     nel tema scuro diventa un riquadro di carta su cui il logo resta nitido. */
  .logo-base{background:#FFFFFF; border-radius:12px; padding:2px;}
  .brand-base{width:100%; max-width:180px; padding:8px 10px;}
  .gate-base{max-width:246px; margin:2px auto 22px; padding:10px 14px;}
  .brand-sotto{font-size:9.5px; font-weight:600; letter-spacing:.09em; text-transform:uppercase; color:var(--text-muted); padding-left:2px;}
  .gate-logo{display:block; width:100%; height:auto;}
  @media (prefers-color-scheme: dark){
    :root:not([data-theme="light"]) .logo-base{box-shadow:0 1px 3px rgba(0,0,0,.35);}
  }
  :root[data-theme="dark"] .logo-base{box-shadow:0 1px 3px rgba(0,0,0,.35);}
  @media (max-width:860px){
    .brand{flex-direction:row; align-items:center; gap:9px;}
    .brand-base{max-width:132px; padding:6px 8px;}
    .brand-sotto{display:none;}
  }
  .brand-mark{width:32px;height:32px;border-radius:9px;background:var(--accent);color:var(--accent-contrast);
    display:flex;align-items:center;justify-content:center;font-size:16px; flex-shrink:0;}
  .brand-text{font-family:var(--font-display); font-weight:600; font-size:16.5px; line-height:1.15;}
  .brand-text span{display:block; font-family:var(--font-body); font-weight:500; font-size:10.5px; color:var(--text-muted); text-transform:uppercase; letter-spacing:.06em;}
  .nav-btn{
    display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:9px; border:none;
    background:transparent; color:var(--text-2); font-size:13.5px; font-weight:600; text-align:left; width:100%;
  }
  .nav-btn .ic{font-size:15px; width:18px; text-align:center;}
  .nav-btn:hover{background:var(--surface-hover); color:var(--text);}
  .nav-btn.active{background:var(--accent-soft); color:var(--accent-strong);}
  .sidebar-spacer{flex:1;}
  .sidebar-foot{border-top:1px solid var(--border); padding-top:10px; display:flex; flex-direction:column; gap:2px;}
  .sidebar-foot .nav-btn{color:var(--text-muted); font-size:12.5px;}

  .main{flex:1; min-width:0; display:flex; flex-direction:column;}
  .topbar{
    display:flex; align-items:center; justify-content:space-between; gap:12px;
    padding:16px 28px; border-bottom:1px solid var(--border); background:var(--bg-elev);
    position:sticky; top:0; z-index:5;
  }
  .topbar-left{display:flex; align-items:center; gap:12px; min-width:0;}
  .topbar h2{font-size:19px;}
  .topbar .crumb{font-size:12px; color:var(--text-muted); display:flex; align-items:center; gap:6px;}
  .content{padding:24px 28px 60px; max-width:980px; width:100%; margin:0 auto;}
  @media (max-width:860px){
    .shell{flex-direction:column;}
    .sidebar{position:static; width:100%; height:auto; flex-direction:row; align-items:center; overflow-x:auto; padding:10px 12px; border-right:none; border-bottom:1px solid var(--border);}
    .brand{padding:2px 10px 2px 2px;}
    .sidebar-spacer{display:none;}
    .sidebar-foot{border-top:none; border-left:1px solid var(--border); padding-left:10px; flex-direction:row;}
    .content{padding:18px 16px 48px;}
    .topbar{padding:14px 16px;}
  }

  /* ---------- Cards / lists ---------- */
  .card{background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:20px; box-shadow:var(--shadow); margin-bottom:18px;}
  .card-head{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px;}
  .card-head h3{font-size:15.5px;}
  .card-head .hint{font-size:12px; color:var(--text-muted); font-weight:400;}
  .search-row{display:flex; gap:10px; margin-bottom:16px; flex-wrap:wrap;}
  .search-row input[type=text]{flex:1; min-width:200px;}

  .plist{display:flex; flex-direction:column; gap:8px;}
  .prow{
    display:flex; align-items:center; gap:14px; padding:13px 14px; border:1px solid var(--border);
    border-radius:11px; background:var(--bg-elev); text-align:left; width:100%;
  }
  .prow:hover{border-color:var(--border-strong); background:var(--surface-hover);}
  .avatar{width:38px;height:38px;border-radius:50%; background:var(--accent-soft); color:var(--accent-strong);
    display:flex; align-items:center; justify-content:center; font-weight:700; font-size:14px; flex-shrink:0; font-family:var(--font-display);}
  .prow-main{flex:1; min-width:0;}
  .prow-name{font-weight:600; font-size:14.5px;}
  .prow-sub{font-size:12px; color:var(--text-muted); margin-top:1px;}
  .prow-chev{color:var(--text-muted); font-size:16px;}
  .empty-state{padding:40px 20px; text-align:center; color:var(--text-muted);}
  .empty-state .ic{font-size:30px; margin-bottom:10px;}

  /* ---------- Tabs ---------- */
  .tabs{display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:20px; overflow-x:auto;}
  .tab-btn{padding:10px 14px; border:none; background:none; color:var(--text-muted); font-weight:600; font-size:13px;
    border-bottom:2px solid transparent; white-space:nowrap;}
  .tab-btn:hover{color:var(--text);}
  .tab-btn.active{color:var(--accent-strong); border-bottom-color:var(--accent);}

  /* ---------- Tags / pills / badges ---------- */
  .pill{display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:99px; font-size:11.5px; font-weight:600;}
  .pill-accent{background:var(--accent-soft); color:var(--accent-strong);}
  .pill-warn{background:var(--warn-soft); color:var(--warn);}
  .pill-muted{background:var(--surface-2); color:var(--text-2);}

  /* ---------- Stat tiles ---------- */
  .stat-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px; margin-bottom:6px;}
  .stat-tile{background:var(--surface-2); border-radius:11px; padding:13px 14px;}
  .stat-tile .lbl{font-size:11px; color:var(--text-muted); font-weight:600; text-transform:uppercase; letter-spacing:.03em;}
  .stat-tile .val{font-family:var(--font-mono); font-size:20px; font-weight:600; margin-top:3px; font-variant-numeric:tabular-nums;}
  .stat-tile .val small{font-size:12px; font-weight:500; color:var(--text-2);}

  /* ---------- Table ---------- */
  .tbl-wrap{overflow-x:auto;}
  table.data{width:100%; border-collapse:collapse; font-size:13px;}
  table.data th{text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--text-muted);
    font-weight:600; padding:8px 10px; border-bottom:1px solid var(--border); white-space:nowrap;}
  table.data td{padding:9px 10px; border-bottom:1px solid var(--border); vertical-align:middle;}
  table.data td.num,table.data th.num{font-family:var(--font-mono); font-variant-numeric:tabular-nums; text-align:right;}
  table.data tr:last-child td{border-bottom:none;}
  table.data tr:hover td{background:var(--surface-2);}
  .row-actions{display:flex; gap:4px; justify-content:flex-end;}


  /* ---------- Il menu dei tre puntini ---------- */
  .menu-wrap{position:relative; display:inline-flex; flex:none;}
  .menu-btn{font-size:16px; line-height:1; color:var(--text-muted);}
  .menu-btn:hover, .menu-btn.attivo{color:var(--text); background:var(--surface-hover);}
  .menu-pop{position:absolute; right:0; top:calc(100% + 4px); z-index:30; min-width:232px;
    background:var(--surface); border:1px solid var(--border-strong); border-radius:10px;
    box-shadow:0 2px 6px rgba(20,30,22,.10), 0 18px 40px -18px rgba(20,30,22,.45); padding:5px; }
  .menu-voce{display:flex; align-items:center; gap:9px; width:100%; text-align:left; border:none; background:none;
    padding:7px 9px; border-radius:7px; font-size:13px; color:var(--text); font-family:inherit;}
  .menu-voce:hover{background:var(--surface-hover);}
  .menu-voce .ic{width:16px; text-align:center; font-size:12.5px; opacity:.8; flex:none;}
  .menu-voce.pericolo{color:var(--danger);}
  .menu-sep{height:1px; background:var(--border); margin:4px 2px;}


  /* ---------- Modal ---------- */
  .modal-overlay{position:fixed; inset:0; background:rgba(7,12,26,0.5); display:flex; align-items:center; justify-content:center;
    padding:20px; z-index:50; backdrop-filter:blur(1px);}
  .modal{background:var(--surface); border-radius:16px; border:1px solid var(--border); box-shadow:var(--shadow);
    width:100%; max-width:460px; max-height:88vh; overflow-y:auto; padding:24px;}
  .modal h3{font-size:17px; margin-bottom:16px;}
  .modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:18px;}

  /* ---------- Toast ---------- */
  #toast-root{position:fixed; bottom:20px; left:50%; transform:translateX(-50%); z-index:80; display:flex; flex-direction:column; gap:8px; align-items:center;}
  .toast{background:var(--text); color:var(--bg); padding:10px 18px; border-radius:99px; font-size:13px; font-weight:600;
    box-shadow:var(--shadow); animation:toast-in .15s ease-out;}
  .toast.err{background:var(--danger);}
  @keyframes toast-in{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);}}

  .save-bar{display:flex; align-items:center; gap:12px; justify-content:flex-end; margin-top:4px;}
  .save-bar .saved-note{font-size:12px; color:var(--text-muted);}
  .sum-warn{color:var(--danger); font-weight:600;}
  .sum-ok{color:var(--good); font-weight:600;}
  .subtle{color:var(--text-muted); font-size:12.5px;}
  .section-divider{border:none; border-top:1px solid var(--border); margin:22px 0;}

