/* Inoltro Chiamate – polished mobile UI */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --bg: #F5F0E8;
  --bg-accent: #EDE6DA;
  --surface: #FFFcf7;
  --primary: #4A6FA5;
  --primary-dark: #3A5780;
  --primary-soft: #E8EEF6;
  --success: #3D7A5A;
  --success-soft: #E6F2EB;
  --danger: #C45C4A;
  --danger-soft: #F8EBE8;
  --warn: #B87A2A;
  --warn-soft: #F7F0E3;
  --text: #2C2825;
  --muted: #7A736A;
  --border: #E5DDD0;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(44, 40, 37, 0.04), 0 8px 24px rgba(44, 40, 37, 0.06);
  --shadow-sm: 0 1px 3px rgba(44, 40, 37, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  min-height: 100%;
  font-size: 16px;
}

body {
  padding-bottom: calc(32px + var(--safe-bottom));
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #E8EEF6 0%, transparent 55%),
    var(--bg);
}

.app-header {
  background: transparent;
  color: var(--text);
  padding: 28px 22px 8px;
  max-width: 480px;
  margin: 0 auto;
}

.app-header h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 450;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 18px 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(229, 221, 208, 0.7);
  padding: 20px;
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .badge {
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 650;
}

.note {
  background: var(--warn-soft);
  border: 1px solid #EBD9B8;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #5C4A2E;
  margin-bottom: 14px;
  line-height: 1.45;
}

.note strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 650;
  color: var(--warn);
}

.btn-grid {
  display: grid;
  gap: 10px;
}

.btn-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.btn-grid.two {
  grid-template-columns: 1fr 1fr;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  padding: 15px 16px;
  border: none;
  border-radius: 14px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--primary);
  transition: transform 0.1s ease, opacity 0.15s, box-shadow 0.15s;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: var(--shadow-sm);
}

button:active, .btn:active { transform: scale(0.975); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-success {
  background: var(--success);
  box-shadow: 0 4px 14px rgba(61, 122, 90, 0.25);
}
.btn-danger {
  background: var(--danger);
  box-shadow: 0 4px 14px rgba(196, 92, 74, 0.22);
}
.btn-outline {
  background: var(--surface);
  color: var(--primary-dark);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
.btn-outline:active { background: var(--primary-soft); }
.btn-outline-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1.5px solid #E8C8C1;
  box-shadow: none;
  flex-direction: column;
  gap: 2px;
}
.btn-outline-danger:active { background: var(--danger-soft); }
.btn-muted {
  background: var(--bg-accent);
  color: var(--text);
  box-shadow: none;
}
.btn-sm {
  padding: 8px 12px;
  font-size: 0.78rem;
  width: auto;
  border-radius: 10px;
  box-shadow: none;
}

.quick-code {
  font-family: var(--mono);
  font-size: 0.78rem;
  opacity: 0.85;
  font-weight: 500;
  width: 100%;
  text-align: center;
}

.number-list { list-style: none; margin: 0; padding: 0; }

.number-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.number-item:last-child { border-bottom: none; }

.number-info { flex: 1; min-width: 0; }
.number-info .name {
  font-weight: 650;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.number-info .num {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 2px;
}

.number-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 20px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.form-row { margin-bottom: 14px; }

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="tel"],
input[type="number"],
select {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.18);
}

.inline-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.inline-form .form-row { flex: 1; margin-bottom: 0; }

/* CRITICAL: hidden when closed so it never steals taps */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 40, 37, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.overlay.open {
  display: flex;
}

.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 22px 22px 0 0;
  padding: 12px 18px calc(24px + var(--safe-bottom));
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(44, 40, 37, 0.12);
  animation: sheetIn 0.28s ease;
}

@keyframes sheetIn {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px auto 16px;
}

.sheet h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}

.sheet-sub {
  text-align: center;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.choice-list { display: grid; gap: 8px; margin-bottom: 14px; }

.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 14px 16px;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 14px;
  color: var(--text);
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  box-shadow: none;
}

.choice:active, .choice.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choice .sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 3px;
  font-family: var(--mono);
  word-break: break-all;
}

.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.footer-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 10px 8px 0;
  line-height: 1.4;
}

.footer-hint a {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
}

.footer-hint code {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--bg-accent);
  padding: 1px 5px;
  border-radius: 4px;
}

.toast {
  position: fixed;
  bottom: calc(28px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  background: var(--text);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.28s ease;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

.shortcut-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  background: var(--bg);
}

.shortcut-page h1 {
  font-size: 1.35rem;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.shortcut-page .code {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--danger);
  margin: 16px 0 28px;
  letter-spacing: 0.04em;
}
.shortcut-page .btn { max-width: 280px; font-size: 1.05rem; padding: 16px; }
.shortcut-page .back {
  margin-top: 32px;
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.preset {
  width: auto;
  flex: 1 1 calc(25% - 8px);
  min-width: 56px;
  padding: 11px 6px;
  font-size: 0.85rem;
  font-weight: 650;
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  box-shadow: none;
  border: 1.5px solid transparent;
}

.preset.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: var(--primary);
}

.confirm-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.confirm-row button { flex: 1; }
