/* Emergency Help — app shell (local web client) */
:root {
  --bg: #f4f2ef;
  --bg-card: #ffffff;
  --text: #1a1614;
  --text-muted: #6b6560;
  --border: #e8e4df;
  --primary: #c53030;
  --primary-hover: #a82828;
  --primary-soft: rgba(197, 48, 48, 0.1);
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --success: #15803d;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(26, 22, 20, 0.08);
  --shadow-sm: 0 2px 12px rgba(26, 22, 20, 0.06);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 18px;
  --space-lg: 26px;
  --space-xl: 36px;
  --space-2xl: 48px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-wrap {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-md) 22px var(--space-2xl);
}

/* Header */
.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.brand-lockup {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.brand-logo {
  flex-shrink: 0;
  width: auto;
  height: 52px;
  max-width: min(160px, 42vw);
  object-fit: contain;
  display: block;
}

.menu-tagline {
  margin: 10px 0 0;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.45;
  color: var(--primary);
  text-transform: uppercase;
  max-width: 12.5rem;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.app-name {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
}

.app-tagline {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 260px;
}

.progress-dots {
  display: flex;
  gap: 7px;
  flex-shrink: 0;
  padding-top: 4px;
}

.progress-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s, transform 0.2s;
}

.progress-dots span.active {
  background: var(--primary);
  transform: scale(1.15);
}

.progress-dots span.done {
  background: var(--accent);
}

/* Views */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fadeIn 0.35s ease;
}

.view.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  text-align: center;
  margin-bottom: var(--space-xl);
  padding: 0 var(--space-xs);
}

.hero-ready .ready-illustration {
  margin-top: 0;
}

.hero-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 var(--space-sm);
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.22;
  margin: 0 0 var(--space-md);
  letter-spacing: -0.03em;
}

.hero-lead {
  margin: 0 auto;
  max-width: 34ch;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
  font-weight: 500;
}

.hero-lead strong {
  color: var(--text);
  font-weight: 700;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.card-tight {
  padding: var(--space-lg) var(--space-lg);
}

.card-list {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.card + .card {
  margin-top: var(--space-md);
}

.list-card-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.list-card-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}

.list-card-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-finish {
  margin-top: var(--space-lg);
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="number"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: #fdfcfa;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field {
  margin-bottom: var(--space-md);
}

.field-hint {
  margin: 8px 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-muted);
  font-weight: 500;
}

.field-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.field-row .field {
  margin-bottom: 0;
}

.field-row .field--cc {
  flex: 0 0 88px;
  min-width: 0;
}

.field-row .field--mobile {
  flex: 1;
  min-width: 0;
}

.field-row + .field-hint {
  margin-top: 10px;
  margin-bottom: var(--space-md);
}

.card-tight .field:last-of-type {
  margin-bottom: var(--space-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(197, 48, 48, 0.35);
  margin-top: var(--space-xs);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: var(--space-sm);
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px;
  margin-top: 8px;
}

.btn-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  width: 100%;
}

.btn-row .btn {
  flex: 1;
  margin-top: 0;
  margin-top: var(--space-xs);
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-lg);
  line-height: 1.55;
  padding: 0 var(--space-sm);
  max-width: 32ch;
  margin-left: auto;
  margin-right: auto;
}

/* Permission checklist */
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.checklist li:last-child {
  border-bottom: none;
}

.checklist input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

.checklist .item-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.checklist .item-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Contacts */
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.contact-list li {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border);
}

.contact-list li:last-child {
  border-bottom: none;
}

.priority-badge {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-body {
  flex: 1;
  min-width: 0;
}

.contact-body strong {
  display: block;
  font-size: 0.95rem;
}

.contact-body span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.contact-body .contact-wa {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.contact-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: var(--accent-soft);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--accent);
  transform: scale(1.05);
}

.btn-icon.btn-delete {
  background: rgba(239, 68, 68, 0.1);
}

.btn-icon.btn-delete:hover {
  background: rgba(239, 68, 68, 0.2);
}

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--text-muted);
}

.empty-state[hidden] {
  display: none !important;
}

.empty-icon {
  font-size: 2.25rem;
  margin-bottom: var(--space-sm);
  opacity: 0.85;
}

.empty-title {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  margin: 0 0 var(--space-xs);
}

.empty-desc {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: 26ch;
  margin-left: auto;
  margin-right: auto;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  max-width: min(400px, calc(100% - 32px));
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.toast.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.toast.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Ready screen */
.ready-illustration {
  width: 112px;
  height: 112px;
  margin: 0 auto var(--space-lg);
  border-radius: 50%;
  background: linear-gradient(160deg, var(--accent-soft), var(--primary-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.75rem;
  border: 3px solid rgba(15, 118, 110, 0.25);
}

.footer-dev {
  margin-top: auto;
  padding-top: var(--space-xl);
  text-align: center;
}

.footer-dev[hidden] {
  display: none !important;
}

.footer-dev button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
}

.dev-panel {
  margin-top: 12px;
  padding: 12px;
  background: #f1efeb;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  text-align: left;
  display: none;
}

.dev-panel.open {
  display: block;
}

.dev-panel pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.segment {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
}

.segment-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 12px 10px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
}

.segment-btn--on {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* HELP Button & Emergency Escalation */
.card-help {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  background: linear-gradient(135deg, rgba(197, 48, 48, 0.05) 0%, rgba(197, 48, 48, 0.02) 100%);
  border: 2px solid var(--primary-soft);
  margin-bottom: var(--space-lg);
}

.help-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-md);
  animation: pulse 2s infinite;
}

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

.help-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 var(--space-lg) 0;
}

.btn-danger {
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 700;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1.1rem;
}

.btn-danger:hover {
  background: var(--primary-hover);
  transform: scale(1.02);
  box-shadow: var(--shadow);
}

.btn-danger:active {
  transform: scale(0.98);
}

.btn-lg {
  padding: var(--space-lg) var(--space-2xl);
  font-size: 1.25rem;
  min-height: 60px;
}

.help-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: var(--space-md) 0 0 0;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: var(--space-lg);
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-content h2 {
  margin: 0 0 var(--space-md) 0;
  font-size: 1.5rem;
  color: var(--text);
}

.modal-content p {
  margin: 0 0 var(--space-lg) 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

.modal-buttons .btn {
  flex: 1;
  max-width: 150px;
}

/* Escalation Status */
.card-escalation {
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, var(--accent-soft) 0%, transparent 100%);
}

.escalation-status-label {
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 var(--space-md) 0;
  font-size: 1rem;
}

.escalation-progress {
  width: 100%;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
  width: 0%;
  transition: width 0.6s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
}

.escalation-current-contact {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  margin: 0 0 var(--space-sm) 0;
}

.escalation-attempts {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 var(--space-lg) 0;
}

/* Success State */
.card-success {
  border-left: 4px solid var(--success);
  background: linear-gradient(135deg, rgba(21, 128, 61, 0.05) 0%, transparent 100%);
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}

.success-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  animation: checkmark 0.6s ease;
}

@keyframes checkmark {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.card-success h3 {
  margin: 0 0 var(--space-sm) 0;
  font-size: 1.3rem;
  color: var(--success);
}

.card-success p {
  margin: 0 0 var(--space-lg) 0;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Menu Button */
.menu-button {
  position: relative;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  transition: opacity 0.2s;
}

.menu-button:hover {
  opacity: 0.7;
}

/* Menu Overlay */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 998;
  animation: fadeIn 0.3s ease;
}

.menu-overlay.active {
  display: block;
}

/* Menu Modal */
.menu-modal {
  position: fixed;
  top: 0;
  right: 0;
  width: 85%;
  max-width: 340px;
  height: 100vh;
  background: var(--bg-card);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  z-index: 999;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.menu-modal.active {
  transform: translateX(0);
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border);
}

.menu-header-text {
  min-width: 0;
  flex: 1;
  padding-right: 4px;
}

.menu-header h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
  color: var(--text);
}

.menu-practice-box {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.menu-practice-note {
  margin-top: 16px !important;
  font-size: 0.85rem !important;
  color: var(--text-muted);
}

.menu-close {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: opacity 0.2s;
}

.menu-close:hover {
  opacity: 0.7;
}

/* Menu Tabs */
.menu-tabs {
  display: flex;
  gap: 0;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}

.menu-tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: var(--space-sm) var(--space-md);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  position: relative;
  bottom: -1px;
}

.menu-tab-btn:hover {
  color: var(--text);
}

.menu-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Menu Content */
.menu-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.menu-tab {
  display: none;
  padding: var(--space-lg) var(--space-md);
}

.menu-tab.active {
  display: block;
}

.menu-section {
  margin-bottom: var(--space-xl);
}

.menu-section h3 {
  margin: 0 0 var(--space-md) 0;
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
}

.menu-section h4 {
  margin: 0 0 var(--space-sm) 0;
  font-size: 0.95rem;
  color: var(--text);
}

.menu-section p {
  margin: 0 0 var(--space-md) 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.menu-steps {
  margin: 0;
  padding-left: var(--space-lg);
  list-style: decimal;
}

.menu-steps li {
  margin-bottom: var(--space-md);
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.menu-steps strong {
  color: var(--text);
}

.menu-features {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.menu-features li {
  margin-bottom: var(--space-sm);
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  padding-left: var(--space-md);
}

/* Menu Footer */
.menu-footer {
  padding: var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border);
}

.menu-footer[hidden] {
  display: none !important;
}

.btn-full {
  width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
