/* JSPBX Phone — Light VoIP Theme */
:root {
  --bg-primary: #F4F6F9;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #E8EDF4;
  --accent: #00897B;
  --accent-hover: #00695C;
  --danger: #D9534F;
  --danger-hover: #C9302C;
  --text-primary: #1A2332;
  --text-secondary: #5A6B82;
  --text-muted: #5E6C80;
  --border: #DCE3EC;
  --ring: #00897B;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100vh; position: relative; }

/* Screens */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.active { display: flex; }

.hidden { display: none !important; }

/* Login */
#screen-login {
  justify-content: center; align-items: center;
  background: var(--bg-primary);
  padding: 24px;
  overflow-y: auto;
}
.login-container { width: 100%; max-width: 360px; margin: auto; }
.logo { text-align: center; margin-bottom: 32px; }
.logo-img { width: 240px; max-width: 75%; height: auto; }
.logo h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }

/* Modalità tastiera aperta: iOS non ridimensiona la WebView, quindi
   compattiamo la login per tenere password e Connetti sopra la tastiera */
#screen-login.kb-open { justify-content: flex-start; }
#screen-login.kb-open .login-container { transform: translateY(-70px); }
#screen-login.kb-open .logo { margin-bottom: 12px; }
#screen-login.kb-open .logo-img { width: 110px; }
#screen-login.kb-open .subtitle { display: none; }
#screen-login.kb-open .login-form { gap: 8px; }
#screen-login.kb-open .input-group { gap: 4px; }
#screen-login.kb-open .input-group input[type="text"],
#screen-login.kb-open .input-group input[type="password"] { padding: 9px 14px; }
#screen-login.kb-open .btn-large { padding: 12px; }
#screen-login.kb-open .build-tag { display: none; }

.login-form { display: flex; flex-direction: column; gap: 16px; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.input-group input[type="text"],
.input-group input[type="password"] {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color .2s;
}
.input-group input:focus { border-color: var(--accent); }
.input-group input::placeholder { color: var(--text-muted); }
.input-group input[type="checkbox"] { accent-color: var(--accent); }

.btn {
  border: none; border-radius: 12px;
  padding: 14px 24px; font-size: 16px;
  font-weight: 600; cursor: pointer;
  transition: all .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover, .btn-primary:active { background: var(--accent-hover); transform: scale(0.98); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-large { width: 100%; padding: 16px; font-size: 17px; border-radius: 14px; }

.error-message {
  background: rgba(217,83,79,.10);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-top: 12px;
}

/* Status Bar */
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
/* Marchio + stato in un unico blocco: la barra resta a tre zone (questo,
   il tasto Rubrica, le azioni), altrimenti il logo sposterebbe le altre due */
.status-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Il marchio è il wordmark «jspbx» (720×220): 26px di altezza ≈ 85px di
   larghezza. L'elemento più alto della barra è l'ingranaggio (36px), quindi
   26px non fa crescere la barra: riempie lo spazio che c'era. */
.brand-mark { height: 26px; width: auto; display: block; flex-shrink: 0; }
/* Su schermi molto stretti (iPhone SE e simili) il marchio a 26px ruberebbe
   spazio allo stato: si riduce invece di mandare la barra a capo. */
@media (max-width: 360px) { .brand-mark { height: 20px; } }
/* Le azioni della barra non avevano regola: build-tag e ingranaggio si
   impilavano in verticale e la barra veniva alta 80px invece di ~60. Con
   flex stanno in riga, come sono stati pensati. */
.status-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status.disconnected .status-dot { background: #3b82f6; }
.status.connecting .status-dot { background: #F39C12; animation: pulse 1s infinite; }
.status.connected .status-dot { background: #22c55e; }
.status.calling .status-dot, .status.ringing .status-dot { background: #F39C12; animation: pulse .6s infinite; }
.status.incall .status-dot { background: var(--accent); animation: pulse 1.5s infinite; }
/* Il testo segue il colore dello stato; qui servono tinte più scure di quelle
   dei pallini perché su fondo bianco le tinte accese non si leggono. */
.status.disconnected .status-text { color: #1d4ed8; }
.status.connecting .status-text { color: #9a6708; }
.status.connected .status-text { color: #15803d; }
/* Il numero dell'interno in barra è l'informazione che si guarda, le etichette
   di stato sono contorno: quindi più grande e in grassetto. Il colore resta
   quello dello stato, definito dalle regole qui sopra (qui non si tocca). */
.status-text.ext { font-size: 17px; font-weight: 700; letter-spacing: .3px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.btn-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-tertiary); border: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer;
}
.btn-icon svg { width: 18px; height: 18px; }

/* Tasto Rubrica centrale nella status bar (webapp: 3 zone sinistra/centro/destra) */
.btn-rubrica {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 10px;
  background: var(--bg-tertiary); border: none;
  color: var(--text-primary); font-size: 13px; cursor: pointer;
}
.btn-rubrica svg { width: 16px; height: 16px; }

/* Indicatore presenza interno (stato da /api/phonebook: attivo/occupato/non registrato) */
.presence-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin: 0 4px 1px 6px; vertical-align: middle;
}
.presence-dot.attivo { background: #22c55e; }
.presence-dot.occupato { background: #ef4444; }
.presence-dot.non_registrato { background: #3b82f6; }
.presence-label {
  font-size: 11px; color: var(--text-muted); vertical-align: middle;
}
/* Lo stato dell'interno si legge anche dal cerchio delle iniziali: il pallino
   da 8px da solo non si nota. Testo scuro perché il tema è chiaro. */
.list-item-avatar.p-attivo { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.5); color: #15803d; }
.list-item-avatar.p-occupato { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.5); color: #b91c1c; }
.list-item-avatar.p-non_registrato { background: rgba(59,130,246,.15); border: 1px solid rgba(59,130,246,.5); color: #1d4ed8; }

/* Dialpad */
.dialpad-display {
  position: relative;
  padding: 24px 16px 12px;
}
.dialpad-display input {
  width: 100%; box-sizing: border-box;
  padding: 0 56px;
  background: transparent; border: none;
  color: var(--text-primary); font-size: 28px;
  text-align: center; outline: none;
}
/* Backspace: cerchio ben delimitato vicino al numero */
.dialpad-display .backspace {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--bg-secondary); border: 1.5px solid var(--border);
  color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
}
.dialpad-display .backspace svg { width: 24px; height: 24px; }

/* Etichetta versione build (per riconoscere l'APK installata) */
.build-tag {
  margin-top: 18px; text-align: center;
  font-size: 11px; color: var(--text-muted);
}
.build-tag-inline {
  font-size: 10px; color: var(--text-muted);
  align-self: center; margin-right: 2px; user-select: none;
}

/* Riga diagnostica tecnica nella schermata chiamata */
.call-tech-text {
  margin: 6px 0 0; min-height: 16px;
  font-size: 12px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.dialpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 24px;
  /* Tastierino compatto: non occupare tutta la larghezza/altezza del telefono */
  flex: 0 0 auto;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  box-sizing: border-box;
}
.dial-btn {
  aspect-ratio: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-primary); cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
}
.dial-btn:active { background: var(--bg-tertiary); transform: scale(0.92); }
.dial-btn .digit { font-size: 26px; font-weight: 600; line-height: 1; }
.dial-btn .letters { font-size: 10px; color: var(--text-muted); margin-top: 2px; letter-spacing: 1px; }

.dialpad-actions {
  display: flex; justify-content: center;
  padding: 8px 24px 10px;
}

/* Pannello unico sotto il tastierino: Interni | Recenti */
.quick-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.quick-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.quick-tab {
  flex: 1;
  background: none; border: none;
  padding: 10px 8px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.quick-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.quick-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.quick-list .list-item { padding: 8px 16px; }
.quick-list .list-item-avatar { width: 34px; height: 34px; font-size: 13px; }
.btn-call {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  display: flex; align-items: center; justify-content: center;
  color: #000; cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 20px rgba(0,137,123,.3);
}
.btn-call:disabled { background: var(--bg-tertiary); color: var(--text-muted); box-shadow: none; }
.btn-call svg { width: 28px; height: 28px; }
.btn-call:active { transform: scale(0.92); }

/* Bottom Nav */
.bottom-nav {
  display: flex; justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none;
  color: var(--text-muted); font-size: 11px; cursor: pointer;
  padding: 6px;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--accent); }

/* Call Screen */
#screen-call {
  background: var(--bg-primary);
  justify-content: space-between;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.call-header {
  text-align: center; padding: 48px 24px 24px;
}
.call-header h2 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.call-header .caller-number { color: var(--text-secondary); font-size: 15px; }
.call-timer { font-size: 16px; color: var(--accent); margin-top: 12px; font-variant-numeric: tabular-nums; }
.call-status-text { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.call-actions-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding: 0 32px;
}
.call-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px 8px;
  color: var(--text-primary); font-size: 12px; cursor: pointer;
  transition: all .2s;
}
.call-btn svg { width: 22px; height: 22px; }
.call-btn:active { background: var(--bg-tertiary); }
.call-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

.call-main-actions {
  display: flex; justify-content: center;
  padding: 24px;
}
.btn-end-call {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--danger);
  border: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 20px rgba(217,83,79,.3);
}
.btn-end-call:active { transform: scale(0.92); }
.btn-end-call svg { width: 28px; height: 28px; }

/* Overlays */
.overlay {
  position: absolute; inset: 0;
  background: var(--bg-primary);
  z-index: 100;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
}
.incoming-content { text-align: center; width: 100%; max-width: 320px; }
.caller-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: var(--text-secondary);
}
.caller-avatar svg { width: 48px; height: 48px; }
.caller-info h2 { font-size: 22px; margin-bottom: 4px; }
.caller-number { color: var(--text-secondary); font-size: 16px; }
.incoming-actions {
  display: flex; justify-content: center; gap: 32px;
  margin-top: 48px;
}
.btn-action {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  color: var(--text-primary); font-size: 13px;
}
.btn-action > *:first-child {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.btn-decline > *:first-child { background: var(--danger); }
.btn-answer > *:first-child { background: var(--accent); color: #000; }
.btn-action svg { width: 26px; height: 26px; }

/* Dialog */
.dialog {
  position: absolute; inset: 0;
  background: rgba(26,35,50,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.dialog-content {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 24px;
  width: 100%; max-width: 360px;
}
.dialog-content h3 { margin-bottom: 16px; font-size: 18px; }
.dialog-content input {
  width: 100%; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; color: var(--text-primary); font-size: 16px;
  margin-bottom: 16px; outline: none;
}
.dialog-actions { display: flex; flex-direction: column; gap: 8px; }

/* DTMF */
.dtmf-content { width: 100%; max-width: 340px; }
.dtmf-display {
  text-align: center; font-size: 24px; min-height: 40px;
  color: var(--accent); margin-bottom: 16px;
  letter-spacing: 4px;
}
.dtmf-btn {
  aspect-ratio: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-primary); font-size: 22px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.dtmf-btn:active { background: var(--bg-tertiary); transform: scale(0.92); }
#btn-close-dtmf { margin-top: 16px; }

.compact { padding: 0; gap: 6px; }
.compact .dtmf-btn { width: auto; height: auto; }

/* ===== TAB SCREENS (Contacts + History) — merge 2026-09-07 ===== */

/* ===== TAB SCREENS (Contacts + History) ===== */

/* Bottom Nav — fixed at bottom */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex; justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

/* Main tab screens need bottom padding for nav */
#screen-dialpad,
#screen-contacts,
#screen-history {
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* Tab Header */
.tab-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-header h2 {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.3px;
}

/* Tab Search */
.tab-search {
  padding: 12px 16px;
  flex-shrink: 0;
}
.tab-search input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}
.tab-search input:focus { border-color: var(--accent); }
.tab-search input::placeholder { color: var(--text-muted); }

/* Tab List */
.tab-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}

/* List Item (Contact / History) */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.list-item:active { opacity: 0.7; }

.list-item-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.list-item-info {
  flex: 1;
  min-width: 0;
}
.list-item-info .name {
  font-size: 16px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-item-info .subtitle {
  font-size: 13px; color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Rubrica: righe più ariose e testo più grande delle altre liste (interni e
   recenti restano compatti perché stanno in colonna stretta) */
#screen-contacts .list-item { padding: 16px 0; gap: 14px; }
#screen-contacts .list-item-avatar { width: 52px; height: 52px; font-size: 19px; }
#screen-contacts .list-item-info .name { font-size: 19px; }
#screen-contacts .list-item-info .subtitle { font-size: 15px; }

.list-item-actions {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.list-item-actions .btn-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
}
.list-item-actions .btn-icon.call {
  background: var(--accent); color: #000;
}

/* History specific */
.history-item .badge {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.badge.incoming { background: #3b82f6; }
.badge.outgoing { background: #22c55e; }
.badge.missed { background: var(--danger); }

.history-item .time {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap;
}

/* Empty State */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state p {
  font-size: 15px;
}

/* Contact dialog extra */
#contact-dialog .dialog-content input {
  margin-bottom: 12px;
}

/* Settings overlay */
.settings-content { text-align: left; }
.settings-info { margin-bottom: 16px; font-size: 13px; color: var(--text-secondary); }
.settings-info p { margin: 10px 0; }
.settings-info strong { color: var(--text-primary); font-size: 16px; font-weight: 600; word-break: break-all; }

/* Messaggio informativo (non errore) nella schermata di login */
.error-message.info {
  background: rgba(0, 137, 123, 0.10);
  color: var(--accent);
  border-color: rgba(0, 137, 123, 0.35);
}

/* Toast (avvisi transienti, es. "Hai già una chiamata in corso") */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 1000;
  pointer-events: none;
  max-width: 85vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Log diagnostici in Impostazioni */
.settings-log-wrap { margin-bottom: 16px; }
.settings-log-wrap summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}
#settings-log {
  max-height: 220px;
  overflow: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin: 10px 0;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Colonne Interni/Recenti: su mobile si alternano con le linguette,
   su desktop restano affiancate */
.quick-cols { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.quick-col { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.quick-col-title {
  display: none;
  padding: 12px 16px 4px;
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
}
/* La freccia Indietro serve anche sul telefono: era nascosta perché il ritorno
   dalla Rubrica lo faceva la barra in basso, che ora non c'è più. */
.btn-contacts-back { display: inline-flex; }

/* La barra in basso (Telefono / Rubrica) non serve: il Telefono è la schermata
   in cui si è già, e la Rubrica si apre dal tasto in alto e si chiude con la
   freccia. Restavano due caselle ridondanti. */
.bottom-nav { display: none !important; }

/* ===== Layout desktop webapp (schermi larghi): tastierino | interni | recenti ===== */
@media (min-width: 901px) {
  /* Schermata Telefono in riga: il contenitore mantiene la status-bar a tutta
     larghezza grazie al wrap, poi tastierino a sinistra e colonne a destra */
  /* Griglia a due righe: status-bar a tutta larghezza, poi tastierino e colonne.
     Con flex + wrap la seconda riga prendeva l'altezza dal contenuto, quindi le
     liste non avevano un'altezza limite e non potevano scorrere: il contenuto in
     eccesso finiva fuori dallo schermo senza modo di raggiungerlo. La riga
     `minmax(0, 1fr)` dà invece alla seconda riga tutto lo spazio che resta. */
  #screen-dialpad.active {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
  }
  #screen-dialpad.active .status-bar { grid-column: 1 / -1; grid-row: 1; }
  .dialpad-main {
    display: flex;
    flex-direction: column;
    grid-column: 1; grid-row: 2;
    border-right: 1px solid var(--border);
    padding-bottom: 16px;
    overflow-y: auto;
  }
  .dialpad-display { padding-top: 40px; }
  .dialpad-grid { max-width: 280px; }
  .quick-panel {
    flex-direction: row;
    grid-column: 2; grid-row: 2;
    min-width: 0;
    border-top: none;
    background: transparent;
  }
  .quick-tabs { display: none; }
  .quick-cols { flex-direction: row; gap: 12px; padding: 12px; }
  .quick-col-title { display: block; }
  /* Entrambe le colonne sempre visibili, anche se una ha la classe .hidden
     impostata dalla logica mobile (id+class batte la regola di .hidden) */
  #qcol-interni.hidden, #qcol-recenti.hidden { display: flex !important; }
  .quick-col .quick-list {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 4px 0 0;
    flex: 1;
  }
  /* Tutto e' visibile in una pagina: la barra in basso non serve piu' */
  .bottom-nav { display: none !important; }
  /* Rubrica raggiungibile solo dal tasto in alto: serve il tasto Indietro */
  .btn-contacts-back { display: inline-flex; }
}
