/* ============================================================
   PrendiPillola PRO v3.0.0 — style.css
   Copyright (c) 2026 Lazzaro Serva - Centola
   Via Tasso, 28 – 84051 CENTOLA (SA) – Italia
   http://www.graficaesiti.it/
   Tutti i diritti riservati – All rights reserved.
   ============================================================ */

/* ═══ VARIABILI TEMA ═══ */
:root {
  --primary: #1565c0;
  --primary-l: #1e88e5;
  --primary-d: #0d47a1;
  --secondary: #00897b;
  --success: #2e7d32;
  --success-l: #43a047;
  --warning: #e65100;
  --danger: #c62828;
  --pending: #546e7a;
  --bg: #e3f2fd;
  --surface: #ffffff;
  --surface2: #f0f7ff;
  --text: #0d2137;
  --text2: #37474f;
  --border: #90caf9;
  --shadow: 0 3px 12px rgba(21,101,192,0.18);
  --shadow-l: 0 6px 24px rgba(21,101,192,0.22);
  --radius: 18px;
  --radius-s: 12px;
  --fs-body: 20px;
  --fs-label: 18px;
  --fs-small: 16px;
  --fs-big: 24px;
  --fs-title: 28px;
}
.hc {
  --primary: #003d99;
  --bg: #f5faff;
  --text: #000000;
  --text2: #111111;
  --border: #003d99;
}
.fs-xl { --fs-body:24px; --fs-label:22px; --fs-small:19px; --fs-big:30px; --fs-title:34px; }
.fs-xxl{ --fs-body:28px; --fs-label:26px; --fs-small:22px; --fs-big:36px; --fs-title:40px; }

/* ═══ RESET / BASE ═══ */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html,body{height:100%;overflow:hidden;}
body{
  font-family:'Nunito',sans-serif;
  font-size:var(--fs-body);
  background:var(--bg);
  color:var(--text);
  display:flex;flex-direction:column;
  -webkit-tap-highlight-color:transparent;
  user-select:none;
}
button{font-family:inherit;cursor:pointer;border:none;outline:none;}
input,select,textarea{font-family:inherit;font-size:var(--fs-body);outline:none;}

/* ═══ HEADER ═══ */
#header{
  background:var(--primary);
  color:#fff;
  display:flex;align-items:center;gap:10px;
  padding:10px 14px;
  box-shadow:0 3px 12px rgba(0,0,0,0.25);
  z-index:100;
  flex-shrink:0;
}
#header .logo{font-size:28px;}
#header .title{flex:1;font-weight:900;font-size:var(--fs-big);letter-spacing:-.5px;}
#header .title span{font-size:13px;opacity:.75;display:block;font-weight:600;}
.hdr-btn{
  background:rgba(255,255,255,0.18);
  border:2px solid rgba(255,255,255,0.35);
  color:#fff;border-radius:50%;
  width:52px;height:52px;
  font-size:22px;display:flex;align-items:center;justify-content:center;
  transition:background .15s;
}
.hdr-btn:active{background:rgba(255,255,255,0.35);}

/* ═══ MAIN CONTENT ═══ */
#main{flex:1;overflow-y:auto;overflow-x:hidden;padding:16px 14px 10px;}
.view{display:none;}
.view.active{display:block;}

/* ═══ BOTTOM NAV ═══ */
#bottom-nav{
  display:flex;background:var(--surface);
  border-top:2px solid var(--border);
  flex-shrink:0;z-index:100;
}
.nav-btn{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:10px 4px 8px;
  background:none;color:var(--text2);font-size:12px;font-weight:700;
  border-top:3px solid transparent;
  transition:all .15s;gap:3px;
}
.nav-btn .ni{font-size:26px;line-height:1;}
.nav-btn.active{color:var(--primary);border-top-color:var(--primary);}
.nav-btn:active{background:var(--surface2);}

/* ═══ CARDS OGGI ═══ */
.day-header{
  background:var(--primary);
  color:#fff;border-radius:var(--radius);
  padding:14px 18px;margin-bottom:16px;
  display:flex;align-items:center;gap:12px;
}
.day-header .dh-icon{font-size:36px;}
.day-header .dh-text h2{font-size:var(--fs-big);font-weight:900;}
.day-header .dh-text p{font-size:var(--fs-label);opacity:.85;font-weight:600;}

.dose-card{
  background:var(--surface);
  border-radius:var(--radius);
  border:2px solid var(--border);
  margin-bottom:14px;
  box-shadow:var(--shadow);
  overflow:hidden;
  transition:box-shadow .2s;
}
.dose-card-header{
  display:flex;align-items:center;gap:12px;
  padding:14px 16px 10px;
}
.dose-icon{font-size:36px;flex-shrink:0;}
.dose-name{flex:1;}
.dose-name strong{font-size:var(--fs-big);font-weight:900;display:block;line-height:1.1;}
.dose-name span{font-size:var(--fs-label);color:var(--text2);font-weight:600;}
.dose-time{
  font-size:var(--fs-big);font-weight:900;
  color:var(--primary);white-space:nowrap;
}
.dose-status-badge{
  font-size:var(--fs-label);font-weight:800;
  padding:5px 12px;border-radius:20px;
  margin:0 16px 10px;display:inline-block;
}
.badge-pending{background:#e3f2fd;color:var(--primary);}
.badge-now   {background:#fff3e0;color:#e65100;animation:pulse 1.5s infinite;}
.badge-taken {background:#e8f5e9;color:var(--success);}
.badge-missed{background:#ffebee;color:var(--danger);}
.badge-cancelled{background:#f3e5f5;color:#7b1fa2;}
.badge-error {background:#fff8e1;color:#f57f17;}

@keyframes pulse{0%,100%{opacity:1;}50%{opacity:.6;}}

.dose-actions{
  display:flex;gap:8px;padding:10px 16px 14px;flex-wrap:wrap;
}
.btn-preso{
  flex:1;min-width:120px;
  background:var(--success);color:#fff;
  border-radius:var(--radius-s);
  padding:14px 10px;
  font-size:var(--fs-big);font-weight:900;
  display:flex;align-items:center;justify-content:center;gap:8px;
  transition:filter .15s;
}
.btn-preso:active{filter:brightness(.85);}
.btn-small{
  background:var(--surface2);color:var(--text2);
  border:2px solid var(--border);
  border-radius:var(--radius-s);
  padding:12px 14px;
  font-size:var(--fs-label);font-weight:700;
  transition:background .15s;
}
.btn-small:active{background:var(--border);}
.btn-small.red{color:var(--danger);border-color:var(--danger);}
.btn-small.orange{color:var(--warning);border-color:var(--warning);}

/* ═══ FAB ═══ */
.fab{
  position:fixed;bottom:80px;right:18px;
  width:68px;height:68px;border-radius:50%;
  background:var(--primary);color:#fff;
  font-size:32px;display:flex;align-items:center;justify-content:center;
  box-shadow:0 4px 18px rgba(21,101,192,0.45);
  z-index:200;transition:transform .15s;
}
.fab:active{transform:scale(.92);}

/* ═══ LISTA FARMACI ═══ */
.med-card{
  background:var(--surface);border-radius:var(--radius);
  border:2px solid var(--border);margin-bottom:14px;
  box-shadow:var(--shadow);padding:16px;
  display:flex;align-items:center;gap:14px;
  transition:box-shadow .2s;
}
.med-card-info{flex:1;}
.med-card-info strong{font-size:var(--fs-big);font-weight:900;display:block;}
.med-card-info p{font-size:var(--fs-label);color:var(--text2);font-weight:600;margin-top:2px;}
.med-card-actions{display:flex;gap:8px;}
.icon-btn{
  width:50px;height:50px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;font-size:22px;
  border:2px solid var(--border);background:var(--surface2);
  transition:background .15s;
}
.icon-btn:active{background:var(--border);}
.icon-btn.danger{border-color:var(--danger);color:var(--danger);}

/* ═══ STORICO ═══ */
.history-day{
  background:var(--surface);border-radius:var(--radius);
  border:2px solid var(--border);margin-bottom:14px;
  box-shadow:var(--shadow);overflow:hidden;
}
.history-day-header{
  background:var(--primary);color:#fff;
  padding:10px 16px;font-size:var(--fs-label);font-weight:800;
}
.history-item{
  display:flex;align-items:center;gap:12px;
  padding:12px 16px;border-bottom:1px solid var(--border);
}
.history-item:last-child{border-bottom:none;}
.hi-icon{font-size:28px;}
.hi-info{flex:1;}
.hi-info strong{display:block;font-size:var(--fs-label);font-weight:900;}
.hi-info span{font-size:var(--fs-small);color:var(--text2);}
.hi-status{font-size:22px;}

/* ═══ IMPOSTAZIONI ═══ */
.settings-section{
  background:var(--surface);border-radius:var(--radius);
  border:2px solid var(--border);margin-bottom:16px;
  box-shadow:var(--shadow);overflow:hidden;
}
.settings-section h3{
  background:var(--primary-d);color:#fff;
  padding:12px 18px;font-size:var(--fs-label);font-weight:800;
}
.setting-row{
  display:flex;align-items:center;gap:12px;
  padding:14px 18px;border-bottom:1px solid var(--border);
}
.setting-row:last-child{border-bottom:none;}
.setting-label{flex:1;font-size:var(--fs-label);font-weight:700;}
.setting-label small{display:block;font-size:var(--fs-small);color:var(--text2);font-weight:600;}
.seg-control{display:flex;gap:6px;flex-wrap:wrap;}
.seg-btn{
  background:var(--surface2);border:2px solid var(--border);
  border-radius:10px;padding:8px 14px;
  font-size:var(--fs-small);font-weight:700;color:var(--text2);
  transition:all .15s;
}
.seg-btn.active{background:var(--primary);color:#fff;border-color:var(--primary);}
.seg-btn:active{opacity:.8;}
input[type=range]{
  width:120px;accent-color:var(--primary);cursor:pointer;
  height:8px;border-radius:4px;
}
.toggle{
  position:relative;width:58px;height:32px;
  background:var(--border);border-radius:16px;cursor:pointer;
  border:2px solid var(--border);transition:background .2s;
}
.toggle::after{
  content:'';position:absolute;
  width:24px;height:24px;border-radius:50%;
  background:#fff;top:2px;left:2px;
  transition:left .2s;box-shadow:0 2px 5px rgba(0,0,0,0.3);
}
.toggle.on{background:var(--success);}
.toggle.on::after{left:28px;}

/* ═══ MODALI ═══ */
.modal-backdrop{
  position:fixed;inset:0;z-index:500;
  background:rgba(0,0,0,0.60);
  display:flex;align-items:flex-end;
}
/* Bottom-sheet (aggiunta/modifica farmaco): sale dal basso, piena larghezza */
.modal{
  background:var(--surface);
  border-radius:var(--radius) var(--radius) 0 0;
  width:100%;
  max-height:92vh;
  overflow-y:auto;
  padding:20px 16px 32px;
  -webkit-overflow-scrolling:touch;
}
/* Modale centrata (help, confirm): usa absolute + transform — funziona sempre */
.modal-backdrop.center{
  display:block;           /* non flex: il figlio si posiziona con absolute */
}
.modal-backdrop.center .modal{
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  width:calc(100% - 32px);
  max-width:580px;
  max-height:88vh;
  border-radius:var(--radius);
  overflow-y:auto;
  padding:20px 18px 32px;
  -webkit-overflow-scrolling:touch;
}
.modal-header{
  display:flex;align-items:center;gap:10px;margin-bottom:20px;
}
.modal-header h2{flex:1;font-size:var(--fs-title);font-weight:900;}
.modal-close{
  width:44px;height:44px;border-radius:50%;
  background:var(--surface2);border:2px solid var(--border);
  font-size:22px;display:flex;align-items:center;justify-content:center;
}
/* ── Modale Manuale: header sticky con X sempre visibile ── */
#modalHelp .modal{
  padding:0;          /* toglie il padding globale: lo gestiamo noi */
  display:flex;
  flex-direction:column;
  overflow:hidden;    /* il contenitore non scrolla: scorre solo il body interno */
}
#modalHelp .modal-header{
  flex-shrink:0;
  position:sticky;top:0;z-index:10;
  background:var(--surface);
  padding:16px 18px 12px;
  margin-bottom:0;
  border-bottom:2px solid var(--border);
  box-shadow:0 2px 8px rgba(0,0,0,.06);
}
#modalHelp .modal-header .modal-close{
  /* X cerchiata più grande e visibile */
  width:48px;height:48px;
  border-radius:50%;
  background:var(--surface2);
  border:2px solid var(--border);
  font-size:22px;font-weight:900;
  color:var(--text);cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
  transition:background .15s, border-color .15s;
}
#modalHelp .modal-header .modal-close:hover,
#modalHelp .modal-header .modal-close:focus{
  background:var(--danger);color:#fff;border-color:var(--danger);
}
#modalHelp .modal-header .modal-close:active{
  transform:scale(.92);
}
#modalHelp .help-body{
  flex:1;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  padding:18px 18px 32px;
}

.field label{
  display:block;font-size:var(--fs-label);font-weight:800;
  margin-bottom:7px;color:var(--text);
}
.field input,.field select,.field textarea{
  width:100%;border:2px solid var(--border);
  border-radius:var(--radius-s);padding:14px 16px;
  font-size:var(--fs-body);color:var(--text);
  background:var(--surface2);
  transition:border-color .15s;
}
.field input:focus,.field select:focus{border-color:var(--primary);}
.type-grid{
  display:grid;grid-template-columns:repeat(3,1fr);gap:8px;
}
.type-btn{
  background:var(--surface2);border:2px solid var(--border);
  border-radius:var(--radius-s);padding:12px 8px;
  display:flex;flex-direction:column;align-items:center;gap:4px;
  font-size:var(--fs-small);font-weight:700;color:var(--text2);
  transition:all .15s;
}
.type-btn .ti{font-size:28px;}
.type-btn.active{background:var(--primary);color:#fff;border-color:var(--primary);}
.type-btn:active{opacity:.8;}
.times-list{display:flex;flex-direction:column;gap:8px;margin-bottom:8px;}
.time-row{display:flex;align-items:center;gap:10px;}
.time-row input[type=time]{
  flex:1;border:2px solid var(--border);border-radius:var(--radius-s);
  padding:12px 14px;font-size:var(--fs-big);font-weight:800;color:var(--primary);
  background:var(--surface2);
}
.time-row input[type=time]:focus{border-color:var(--primary);}
.btn-del-time{
  width:42px;height:42px;border-radius:50%;
  background:var(--surface2);border:2px solid var(--danger);
  color:var(--danger);font-size:20px;flex-shrink:0;
}
.btn-add-time{
  background:var(--surface2);border:2px dashed var(--primary);
  color:var(--primary);border-radius:var(--radius-s);
  padding:12px;width:100%;font-size:var(--fs-label);font-weight:800;
}
.btn-primary{
  width:100%;background:var(--primary);color:#fff;
  border-radius:var(--radius-s);padding:16px;
  font-size:var(--fs-big);font-weight:900;margin-top:10px;
  transition:filter .15s;
}
.btn-primary:active{filter:brightness(.88);}
.btn-danger{
  width:100%;background:var(--danger);color:#fff;
  border-radius:var(--radius-s);padding:14px;
  font-size:var(--fs-body);font-weight:800;margin-top:8px;
}

/* ═══ MODALE ALERT ═══ */
#alertOverlay{
  position:fixed;inset:0;z-index:900;
  background:rgba(230,81,0,0.92);
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  gap:20px;padding:30px;
  animation:flashBg 1s infinite alternate;
}
@keyframes flashBg{0%{background:rgba(230,81,0,0.9);}100%{background:rgba(198,40,40,0.92);}}
#alertOverlay .alert-icon{font-size:80px;animation:bounce 0.8s infinite alternate;}
@keyframes bounce{0%{transform:scale(1);}100%{transform:scale(1.15);}}
#alertOverlay .alert-msg{
  color:#fff;font-size:var(--fs-title);font-weight:900;
  text-align:center;line-height:1.3;text-shadow:0 2px 8px rgba(0,0,0,0.3);
}
#alertOverlay .alert-sub{
  color:rgba(255,255,255,0.85);font-size:var(--fs-big);font-weight:700;text-align:center;
}
.btn-alert-ok{
  background:#fff;color:var(--warning);
  border-radius:var(--radius);padding:20px 40px;
  font-size:var(--fs-title);font-weight:900;
  box-shadow:0 4px 20px rgba(0,0,0,0.3);
  margin-top:10px;min-width:240px;text-align:center;
  animation:pulse 1s infinite;
}
.btn-alert-ok:active{transform:scale(.96);}

/* ═══ HELP MODAL ═══ */
/* ═══ PROGRAMMAZIONE TEMPORALE ═══ */
.sched-select{
  width:100%;padding:14px 16px;font-size:var(--fs-label);font-family:inherit;
  border:2px solid var(--border);border-radius:var(--radius-s);
  background:var(--surface);color:var(--text);font-weight:700;
  appearance:none;-webkit-appearance:none;cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%231565c0' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 12px center;
}
.sched-select:focus{outline:none;border-color:var(--primary);}
.sched-extra{margin-top:12px;display:none;}
.sched-extra.visible{display:block;}
.days-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:6px;margin-top:8px;}
.day-btn{
  padding:10px 4px;font-size:var(--fs-small);font-weight:800;text-align:center;
  border:2px solid var(--border);border-radius:var(--radius-s);
  background:var(--surface2);color:var(--text2);cursor:pointer;transition:.15s;
}
.day-btn.active{background:var(--primary);color:#fff;border-color:var(--primary);}
.sched-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
.sched-num{
  width:90px;padding:12px 14px;font-size:var(--fs-label);font-family:inherit;font-weight:700;
  border:2px solid var(--border);border-radius:var(--radius-s);
  background:var(--surface);color:var(--text);text-align:center;
}
.sched-num:focus{outline:none;border-color:var(--primary);}
.sched-hint{font-size:var(--fs-small);color:var(--text2);font-weight:600;flex:1;}
.help-section{margin-bottom:20px;}
.help-section h3{
  font-size:var(--fs-big);font-weight:900;color:var(--primary);
  border-bottom:2px solid var(--border);padding-bottom:6px;margin-bottom:10px;
}
.help-section p,.help-section li{font-size:var(--fs-label);line-height:1.6;color:var(--text2);}
.help-section ul{padding-left:20px;}
.help-section li{margin-bottom:6px;}

/* ═══ STATO VUOTO ═══ */
.empty-state{
  text-align:center;padding:40px 20px;
  color:var(--text2);
}
.empty-state .es-icon{font-size:72px;margin-bottom:16px;}
.empty-state h2{font-size:var(--fs-big);font-weight:900;margin-bottom:10px;color:var(--text);}
.empty-state p{font-size:var(--fs-label);margin-bottom:20px;}
.btn-start{
  background:var(--primary);color:#fff;
  border-radius:var(--radius-s);padding:16px 28px;
  font-size:var(--fs-big);font-weight:900;display:inline-block;
}

/* ═══ VOICE BUTTON ═══ */
.voice-row{
  display:flex;align-items:center;gap:10px;
  background:var(--surface2);border:2px solid var(--border);
  border-radius:var(--radius-s);padding:12px 14px;margin-bottom:14px;
}
.voice-row span{flex:1;font-size:var(--fs-label);font-weight:700;}
.btn-voice{
  width:52px;height:52px;border-radius:50%;
  background:var(--primary);color:#fff;font-size:26px;
  display:flex;align-items:center;justify-content:center;
  border:none;transition:transform .15s;flex-shrink:0;
}
.btn-voice.listening{background:var(--danger);animation:pulse 0.7s infinite;}
.btn-voice:active{transform:scale(.92);}

/* ═══ TOAST ═══ */
#toast{
  position:fixed;bottom:85px;left:50%;transform:translateX(-50%) translateY(20px);
  background:var(--text);color:#fff;
  padding:12px 22px;border-radius:20px;
  font-size:var(--fs-label);font-weight:700;
  opacity:0;transition:opacity .3s,transform .3s;
  z-index:800;text-align:center;max-width:90%;
  pointer-events:none;white-space:normal;line-height:1.4;
}
#toast.show{opacity:1;transform:translateX(-50%) translateY(0);}

/* ═══ SCHEDA AUTORE (manuale) ═══ */
.author-card{
  background:var(--surface2);
  border:2px solid var(--primary-l);
  border-radius:var(--radius);
  padding:16px 18px 14px;
  margin-bottom:20px;
}
.author-card-top{
  display:flex;align-items:center;gap:14px;
  margin-bottom:12px;
}
.author-app-icon{
  width:56px;height:56px;border-radius:14px;
  background:var(--primary);
  display:flex;align-items:center;justify-content:center;
  font-size:30px;flex-shrink:0;
  box-shadow:0 3px 10px rgba(21,101,192,0.3);
}
.author-app-name{
  font-size:16px;font-weight:900;color:var(--text);line-height:1.1;
}
.author-ver-badge{
  display:inline-block;
  background:var(--primary);color:#fff;
  font-size:11px;font-weight:800;
  padding:2px 8px;border-radius:20px;
  vertical-align:middle;margin-left:5px;
}
.author-app-sub{
  font-size:13px;color:var(--text2);font-weight:600;margin-top:3px;
}
.author-details{
  border-top:1px solid var(--border);
  padding-top:10px;margin-bottom:10px;
  display:flex;flex-direction:column;gap:4px;
}
.author-line{font-size:14px;color:var(--text);font-weight:600;}
.author-rights{
  background:#fff3e0;
  border:1.5px solid #ffb74d;
  border-radius:10px;
  padding:9px 13px;
  font-size:13px;
  color:#7c3e00;
  line-height:1.5;
}

/* ═══ SOUND GRID ═══ */
.sound-grid{
  display:grid;grid-template-columns:repeat(5,1fr);gap:8px;
}
.sound-btn{
  background:var(--surface2);border:2px solid var(--border);
  border-radius:var(--radius-s);padding:10px 4px 8px;
  display:flex;flex-direction:column;align-items:center;gap:5px;
  font-size:26px;transition:all .15s;
}
.sound-btn span{font-size:11px;font-weight:800;color:var(--text2);line-height:1.2;text-align:center;}
.sound-btn.active{
  background:var(--primary);border-color:var(--primary);
  box-shadow:0 2px 10px rgba(21,101,192,0.35);
}
.sound-btn.active span{color:#fff;}
.sound-btn:active{opacity:.75;}

.btn-test-sound{
  background:var(--secondary);color:#fff;
  border-radius:var(--radius-s);padding:14px 28px;
  font-size:var(--fs-big);font-weight:900;
  display:flex;align-items:center;gap:10px;
  box-shadow:0 3px 12px rgba(0,137,123,0.35);
  transition:filter .15s;width:100%;justify-content:center;
}
.btn-test-sound:active{filter:brightness(.85);}
.btn-test-sound.playing{background:var(--warning);animation:pulse 0.6s infinite;}

.hidden{display:none!important;}
.section-title{
  font-size:var(--fs-big);font-weight:900;color:var(--text);
  margin-bottom:14px;padding-bottom:8px;border-bottom:2px solid var(--border);
}

/* ═══ MANUALE ═══ */
.help-section{margin-bottom:22px;}
.help-section h3{
  font-size:var(--fs-big);font-weight:900;color:var(--primary);
  border-bottom:2px solid var(--border);
  padding-bottom:6px;margin-bottom:12px;
  line-height:1.3;
}
.help-section p{
  font-size:var(--fs-label);line-height:1.65;
  color:var(--text2);margin-bottom:8px;
}
.help-section ul{
  padding-left:18px;margin-bottom:6px;
}
.help-section li{
  font-size:var(--fs-label);line-height:1.6;
  color:var(--text2);margin-bottom:8px;
}
.help-section strong{color:var(--text);}
@media(max-width:600px){
  .help-section h3{font-size:20px;}
  .help-section p,
  .help-section li{font-size:17px;line-height:1.7;}
}
/* ── Banner aggiornamento SW ── */
#updateBanner{
  display:none;
  position:fixed;bottom:72px;left:50%;transform:translateX(-50%);
  width:calc(100% - 32px);max-width:480px;
  background:#1565c0;color:#fff;
  border-radius:14px;padding:12px 16px;
  box-shadow:0 4px 20px rgba(0,0,0,.35);
  z-index:600;
  flex-direction:row;align-items:center;gap:12px;
  animation:bannerIn .35s cubic-bezier(.34,1.56,.64,1) both;
}
#updateBanner.visible{display:flex;}
#updateBanner .ub-text{flex:1;font-size:14px;font-weight:700;line-height:1.3;}
#updateBanner .ub-sub{font-size:11px;font-weight:400;opacity:.85;display:block;margin-top:2px;}
#updateBanner .ub-btn{
  background:#fff;color:#1565c0;border:none;border-radius:8px;
  padding:8px 14px;font-size:13px;font-weight:800;cursor:pointer;
  white-space:nowrap;flex-shrink:0;
}
#updateBanner .ub-btn:active{opacity:.85;}
#updateBanner .ub-close{
  background:none;border:none;color:#fff;opacity:.7;
  font-size:18px;cursor:pointer;padding:0 2px;flex-shrink:0;line-height:1;
}
#updateBanner .ub-close:hover{opacity:1;}
@keyframes bannerIn{
  from{opacity:0;transform:translateX(-50%) translateY(20px);}
  to  {opacity:1;transform:translateX(-50%) translateY(0);}
}

/* ═══ SELETTORE PROFILI ═══ */
#profileBar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
}
#profileBar::-webkit-scrollbar { display: none; }
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s;
  flex-shrink: 0;
}
.profile-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.profile-chip .pc-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.profile-chip-add {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .18s;
}
.profile-chip-add:active { background: var(--surface2); }

/* ═══ MODALE ONBOARDING (primo avvio) ═══ */
#modalOnboarding .modal {
  max-width: 420px;
}
.onboard-step {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 8px 0;
}
.onboard-step.active { display: flex; }
.onboard-icon { font-size: 56px; }
.onboard-title {
  font-size: var(--fs-big);
  font-weight: 900;
  color: var(--primary);
}
.onboard-desc {
  font-size: var(--fs-body);
  color: var(--text2);
  line-height: 1.5;
}
.onboard-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-s);
  font-size: var(--fs-body);
  font-family: inherit;
  background: var(--surface2);
  color: var(--text);
  text-align: center;
}
.onboard-input:focus {
  outline: none;
  border-color: var(--primary);
}
.onboard-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.onboard-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background .2s;
}
.onboard-dot.active { background: var(--primary); }

/* ═══ FARMACI PRN ═══ */
.prn-section-title {
  font-size: var(--fs-small);
  font-weight: 800;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 0 4px;
  margin-top: 8px;
}
.prn-card {
  background: var(--surface);
  border: 2px solid #b2dfdb;
  border-radius: var(--radius-s);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.prn-card .prn-info {
  flex: 1;
  min-width: 0;
}
.prn-card .prn-name {
  font-size: var(--fs-body);
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prn-card .prn-last {
  font-size: var(--fs-small);
  color: var(--text2);
  margin-top: 2px;
}
.btn-prn-take {
  background: var(--secondary);
  color: #fff;
  border: none;
  border-radius: var(--radius-s);
  padding: 10px 16px;
  font-size: var(--fs-small);
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}
.btn-prn-take:active { opacity: .8; }

/* Toggle PRN nel form farmaco */
.prn-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.prn-toggle-label {
  font-size: var(--fs-label);
  font-weight: 700;
  color: var(--text);
}
.prn-toggle-label small {
  display: block;
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--text2);
  margin-top: 2px;
}

/* Badge PRN nella lista farmaci */
.badge-prn {
  display: inline-block;
  background: #e0f2f1;
  color: #00695c;
  border: 1px solid #b2dfdb;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ═══ EXPORT CSV — bottone storico ═══ */
.btn-export-csv {
  background: var(--secondary);
  color: #fff;
  border: none;
  border-radius: var(--radius-s);
  padding: 12px 18px;
  font-size: var(--fs-small);
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity .15s;
}
.btn-export-csv:active { opacity: .8; }

/* ═══ MODALE GESTIONE PROFILI ═══ */
.profile-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.profile-list-item:last-child { border-bottom: none; }
.profile-color-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}
.profile-list-name {
  flex: 1;
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--text);
}
.profile-list-actions {
  display: flex;
  gap: 8px;
}
.btn-profile-edit,
.btn-profile-del {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.btn-profile-del {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff5f5;
}

/* Pallino colore in selettore profilo */
.color-picker-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.color-dot-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .15s;
}
.color-dot-btn.selected {
  border-color: var(--text);
  transform: scale(1.2);
}

/* ═══ CALLMEBOT — campi copiabili con bottone ═══ */
.copy-field-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
  margin: 4px 0;
}
.copy-field-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: monospace;
  font-weight: 700;
  background: #f0f4ff;
  color: #1565c0;
  cursor: text;
  text-align: center;
  box-sizing: border-box;
}
.copy-field-input.field-name {
  background: #fff0f4;
  color: #c62828;
}
.copy-field-input.field-prefix {
  background: #fff8e1;
  color: #e65100;
}
.copy-btn {
  flex-shrink: 0;
  padding: 8px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.copy-btn:active { opacity: .7; }
.copy-field-label {
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 3px;
}

/* ═══ Crea contatto WhatsApp Callmebot — bottone Impostazioni ═══ */
.btn-create-contact {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: var(--radius-s);
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .15s;
}
.btn-create-contact:active { opacity: .85; }
