/* ============================================================
   CONCILIA - Estilos Principais
   Design System: Modo Emergência
   ============================================================ */

/* ---- Importar fontes ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ---- Variáveis CSS (tema editável via config.js) ---- */
:root {
  --primary: #E63946;
  --primary-dark: #C1121F;
  --primary-light: #FF6B6B;
  --secondary: #1D3557;
  --secondary-light: #457B9D;
  --accent: #A8DADC;
  --success: #2DC653;
  --success-dark: #1B9E3E;
  --warning: #F4A261;
  --danger: #E63946;
  --white: #FFFFFF;
  --light: #F8F9FA;
  --light-gray: #E9ECEF;
  --mid-gray: #ADB5BD;
  --dark-gray: #495057;
  --dark: #212529;
  --bg: #F0F2F5;

  --font: 'Inter', 'Segoe UI', sans-serif;
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.16);
  --shadow-primary: 0 8px 32px rgba(230, 57, 70, 0.35);
  --shadow-secondary: 0 8px 32px rgba(29, 53, 87, 0.35);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;

  /* Dark mode variables */
  --dm-bg: #0D1117;
  --dm-surface: #161B22;
  --dm-surface2: #21262D;
  --dm-border: #30363D;
  --dm-text: #E6EDF3;
  --dm-text-muted: #8B949E;
}

/* ---- Dark Mode ---- */
[data-theme="dark"] {
  --bg: var(--dm-bg);
  --light: var(--dm-surface);
  --light-gray: var(--dm-surface2);
  --dark: var(--dm-text);
  --dark-gray: var(--dm-text-muted);
  --mid-gray: #6E7681;
  --white: var(--dm-surface);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* ============================================================
   LAYOUT - Mobile First
   ============================================================ */
.app-wrapper {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

/* ============================================================
   TELA / VIEWS
   ============================================================ */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; }

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

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes ripple {
  0% { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(4); opacity: 0; }
}

/* ============================================================
   TELA INICIAL - MODO EMERGÊNCIA
   ============================================================ */
#screen-home {
  background: linear-gradient(160deg, var(--secondary) 0%, #0A1628 60%, #1A0A0A 100%);
  position: relative;
  overflow: hidden;
}

#screen-home::before {
  content: '';
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(230,57,70,0.15) 0%, transparent 70%);
  pointer-events: none;
}

#screen-home::after {
  content: '';
  position: absolute;
  bottom: -80px; left: -80px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(69,123,157,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.home-header {
  padding: 60px 24px 20px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.emergency-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(230,57,70,0.15);
  border: 1px solid rgba(230,57,70,0.4);
  color: #FF6B6B;
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 24px;
  animation: pulse 2s infinite;
}

.emergency-badge .dot {
  width: 8px; height: 8px;
  background: #FF6B6B;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

.home-logo {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--white);
  line-height: 1;
  margin-bottom: 8px;
}

.home-logo span { color: var(--primary); }

.home-tagline {
  font-size: 15px;
  color: rgba(255,255,255,0.7);
  font-weight: 400;
  line-height: 1.5;
  max-width: 280px;
  margin: 0 auto;
}

.home-buttons {
  padding: 32px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 2;
}

.btn-main {
  width: 100%;
  padding: 24px 20px;
  border-radius: var(--radius-xl);
  border: none;
  cursor: pointer;
  text-align: left;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-main:active { transform: scale(0.97); }

.btn-main .btn-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.btn-main .btn-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.btn-main .btn-text { flex: 1; }
.btn-main .btn-label {
  display: block;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}
.btn-main .btn-sub {
  display: block;
  font-size: 13px;
  font-weight: 400;
  opacity: 0.8;
}
.btn-main .btn-arrow {
  font-size: 22px;
  opacity: 0.7;
}

/* Botão Causador */
.btn-causador {
  background: linear-gradient(135deg, #E63946, #C1121F);
  color: white;
  box-shadow: var(--shadow-primary);
}
.btn-causador .btn-icon { background: rgba(255,255,255,0.15); }

/* Botão Vítima */
.btn-vitima {
  background: linear-gradient(135deg, var(--secondary), #0A1628);
  color: white;
  box-shadow: var(--shadow-secondary);
  border: 1px solid rgba(69,123,157,0.3);
}
.btn-vitima .btn-icon { background: rgba(255,255,255,0.1); }

/* Botão Tensão Zero */
.btn-tensao {
  background: linear-gradient(135deg, #F4A261, #E76F51);
  color: white;
}
.btn-tensao .btn-icon { background: rgba(255,255,255,0.2); }

/* Botão Emergência */
.btn-emergency-sos {
  width: 100%;
  padding: 16px;
  background: transparent;
  border: 2px solid rgba(230,57,70,0.4);
  border-radius: var(--radius-lg);
  color: #FF6B6B;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  letter-spacing: 0.02em;
}

.btn-emergency-sos:hover {
  background: rgba(230,57,70,0.1);
  border-color: var(--primary);
}

.home-footer {
  padding: 16px 24px 32px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.home-footer a {
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  text-decoration: none;
  transition: var(--transition-fast);
}
.home-footer a:hover { color: rgba(255,255,255,0.6); }

/* ============================================================
   HEADERS DAS TELAS INTERNAS
   ============================================================ */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 52px 20px 16px;
  background: var(--light);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--light-gray);
}

.btn-back {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--light-gray);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition-fast);
  flex-shrink: 0;
  color: var(--dark);
}
.btn-back:hover { background: var(--mid-gray); }

.screen-header-text { flex: 1; }
.screen-header-text h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
}
.screen-header-text p {
  font-size: 12px;
  color: var(--dark-gray);
  margin-top: 2px;
}

.screen-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--light);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--light-gray);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--dark-gray);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--light-gray);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  color: var(--dark);
  background: var(--bg);
  transition: var(--transition-fast);
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--light);
  box-shadow: 0 0 0 4px rgba(230,57,70,0.1);
}

.form-control::placeholder { color: var(--mid-gray); }

.form-control.plate {
  text-transform: uppercase;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

/* ============================================================
   BOTÕES DE AÇÃO
   ============================================================ */
.btn {
  width: 100%;
  padding: 18px 24px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { box-shadow: 0 12px 40px rgba(230,57,70,0.45); }

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), #0A1628);
  color: white;
  box-shadow: var(--shadow-secondary);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
  box-shadow: 0 8px 32px rgba(45,198,83,0.35);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: rgba(230,57,70,0.05); }

.btn-ghost {
  background: var(--light-gray);
  color: var(--dark-gray);
  box-shadow: none;
}

.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  width: auto;
}

.btn-lg {
  padding: 22px 24px;
  font-size: 18px;
  border-radius: var(--radius-xl);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Ripple Effect */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  width: 60px; height: 60px;
  margin-left: -30px; margin-top: -30px;
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}

/* ============================================================
   GPS / LOCATION BUTTON
   ============================================================ */
.btn-gps {
  padding: 14px 16px;
  background: linear-gradient(135deg, #1D3557, #457B9D);
  color: white;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  transition: var(--transition);
}

.btn-gps.captured {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
}

.btn-gps span { flex: 1; text-align: left; }
.btn-gps .gps-status {
  font-size: 11px;
  opacity: 0.8;
  text-align: right;
  font-weight: 400;
}

/* ============================================================
   STEP PROGRESS
   ============================================================ */
.step-progress {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 8px;
  background: var(--light);
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  transition: var(--transition);
}

.step.pending .step-circle { background: var(--light-gray); color: var(--mid-gray); }
.step.active .step-circle { background: var(--primary); color: white; box-shadow: 0 0 0 4px rgba(230,57,70,0.2); }
.step.done .step-circle { background: var(--success); color: white; }

.step-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.step.pending .step-label { color: var(--mid-gray); }
.step.active .step-label { color: var(--primary); }
.step.done .step-label { color: var(--success); }

.step-line {
  flex: 0 0 20px;
  height: 2px;
  background: var(--light-gray);
  border-radius: 1px;
  transition: var(--transition);
}
.step-line.done { background: var(--success); }

/* ============================================================
   VOUCHER DIGITAL
   ============================================================ */
.voucher {
  background: linear-gradient(135deg, var(--secondary), #0A1628);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: white;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.voucher::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 150px; height: 150px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.voucher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.voucher-badge {
  background: var(--success);
  color: white;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
}

.voucher-brand { font-size: 18px; font-weight: 900; letter-spacing: -0.5px; }
.voucher-brand span { color: var(--primary); }

.voucher-protocol {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  text-align: center;
  margin: 16px 0;
  font-variant-numeric: tabular-nums;
}

.voucher-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.voucher-field label {
  display: block;
  font-size: 10px;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.voucher-field value {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.voucher-qr {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  color: var(--dark);
}

.voucher-qr canvas { display: block; margin: 0 auto; }
.voucher-qr p { font-size: 10px; color: var(--dark-gray); margin-top: 6px; font-weight: 600; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-success { background: rgba(45,198,83,0.15); color: var(--success); }
.badge-primary { background: rgba(230,57,70,0.12); color: var(--primary); }
.badge-secondary { background: rgba(29,53,87,0.12); color: var(--secondary); }
.badge-warning { background: rgba(244,162,97,0.15); color: #D4701A; }
.badge-info { background: rgba(69,123,157,0.15); color: var(--secondary-light); }

/* ============================================================
   TIMELINE DE STATUS
   ============================================================ */
.timeline {
  padding-left: 8px;
}

.timeline-item {
  display: flex;
  gap: 16px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--light-gray);
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-item.done .timeline-dot { background: var(--success); }
.timeline-item.active .timeline-dot { background: var(--primary); animation: pulse 2s infinite; }
.timeline-item.pending .timeline-dot { background: var(--light-gray); }

.timeline-content h4 { font-size: 14px; font-weight: 600; color: var(--dark); }
.timeline-content p { font-size: 12px; color: var(--dark-gray); margin-top: 2px; }
.timeline-content time { font-size: 11px; color: var(--mid-gray); }

/* ============================================================
   CHAT / IA ASSISTENTE
   ============================================================ */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 85%;
  animation: slideUp 0.3s ease;
}

.chat-message.bot {
  align-self: flex-start;
}
.chat-message.user {
  align-self: flex-end;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-message.bot .chat-bubble {
  background: var(--light);
  color: var(--dark);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--light-gray);
}

.chat-message.user .chat-bubble {
  background: var(--secondary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chat-option-btn {
  padding: 8px 14px;
  border: 2px solid var(--secondary);
  border-radius: 50px;
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.chat-option-btn:hover {
  background: var(--secondary);
  color: white;
}

.chat-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-bottom: 4px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--light);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-indicator span {
  width: 8px; height: 8px;
  background: var(--mid-gray);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ============================================================
   UPLOAD DE FOTOS
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--light-gray);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-fast);
  background: var(--bg);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(230,57,70,0.04);
}

.upload-zone .upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-zone h4 { font-size: 14px; font-weight: 600; color: var(--dark); margin-bottom: 4px; }
.upload-zone p { font-size: 12px; color: var(--dark-gray); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.photo-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--light-gray);
}

.photo-item img { width: 100%; height: 100%; object-fit: cover; }

.photo-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

/* ============================================================
   ASSINATURA DIGITAL
   ============================================================ */
.signature-pad-wrapper {
  border: 2px solid var(--light-gray);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--light);
  position: relative;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 160px;
  cursor: crosshair;
  touch-action: none;
}

.signature-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--mid-gray);
  pointer-events: none;
  white-space: nowrap;
}

.signature-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ============================================================
   LOADING / SPINNERS
   ============================================================ */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loader-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.loader-card {
  background: var(--light);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  max-width: 280px;
  width: 90%;
  animation: slideUp 0.3s ease;
}

.loader-spinner {
  width: 56px; height: 56px;
  border: 4px solid var(--light-gray);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.loader-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.loader-card p { font-size: 13px; color: var(--dark-gray); }

/* ============================================================
   MODAL / POPUP
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal-sheet {
  background: var(--light);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px 20px 40px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-overlay.visible .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 40px; height: 4px;
  background: var(--light-gray);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
  text-align: center;
}

/* ============================================================
   ADMIN PANEL
   ============================================================ */
#screen-admin {
  background: var(--bg);
}

.admin-header {
  background: linear-gradient(135deg, var(--secondary), #0A1628);
  padding: 52px 20px 20px;
  color: white;
}

.admin-header h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.admin-header p { font-size: 13px; opacity: 0.7; }

.admin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.stat-card {
  background: var(--light);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--light-gray);
}

.stat-number {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--dark-gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.admin-nav {
  display: flex;
  overflow-x: auto;
  padding: 0 16px;
  gap: 8px;
  scrollbar-width: none;
  border-bottom: 1px solid var(--light-gray);
  background: var(--light);
}

.admin-nav::-webkit-scrollbar { display: none; }

.admin-nav-btn {
  padding: 12px 16px;
  white-space: nowrap;
  border: none;
  background: none;
  color: var(--dark-gray);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.admin-nav-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.admin-section {
  display: none;
  padding: 16px;
}
.admin-section.active { display: block; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--light-gray);
}

.admin-table th {
  font-weight: 700;
  color: var(--dark-gray);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
}

.admin-table tr:hover td { background: var(--bg); }

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--light-gray);
  gap: 16px;
}

.config-row:last-child { border-bottom: none; }

.config-info { flex: 1; }
.config-info h4 { font-size: 14px; font-weight: 600; color: var(--dark); }
.config-info p { font-size: 12px; color: var(--dark-gray); margin-top: 2px; }

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--light-gray);
  border-radius: 26px;
  transition: var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition-fast);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* Color Picker */
.color-chip {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 2px solid var(--light-gray);
  cursor: pointer;
  transition: var(--transition-fast);
}

/* ============================================================
   OFFLINE INDICATOR
   ============================================================ */
.offline-banner {
  background: var(--warning);
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9998;
  max-width: 480px;
  margin: 0 auto;
}

.offline-banner.visible { display: block; }

/* ============================================================
   SUCCESS / ERROR STATES
   ============================================================ */
.success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  text-align: center;
}

.success-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(45,198,83,0.4);
  animation: slideUp 0.5s ease;
}

.success-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.success-sub { font-size: 14px; color: var(--dark-gray); line-height: 1.6; margin-bottom: 24px; }

/* ============================================================
   MODO TENSÃO ZERO
   ============================================================ */
#screen-tensao {
  background: linear-gradient(160deg, #0D1117 0%, #1D1030 100%);
  color: white;
}

.tensao-header {
  padding: 52px 24px 20px;
  text-align: center;
}

.tensao-badge {
  display: inline-block;
  background: rgba(244,162,97,0.2);
  color: var(--warning);
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  border: 1px solid rgba(244,162,97,0.3);
}

.tensao-title { font-size: 26px; font-weight: 900; margin-bottom: 8px; }
.tensao-sub { font-size: 14px; opacity: 0.7; }

.question-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin: 20px;
  text-align: center;
  animation: slideUp 0.3s ease;
}

.question-number {
  font-size: 12px;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.question-text {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 28px;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.question-btn {
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.question-btn:hover {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
}

.question-btn.yes-btn {
  border-color: rgba(45,198,83,0.4);
  color: #2DC653;
}
.question-btn.yes-btn:hover { background: rgba(45,198,83,0.1); }

.question-btn.no-btn {
  border-color: rgba(230,57,70,0.4);
  color: #FF6B6B;
}
.question-btn.no-btn:hover { background: rgba(230,57,70,0.1); }

.progress-bar-wrapper {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin: 16px 24px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--warning);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ============================================================
   EMERGENCY MODAL
   ============================================================ */
.emergency-modal {
  background: linear-gradient(135deg, #C1121F, #E63946);
  color: white;
  text-align: center;
  padding: 32px 24px 48px;
}

.emergency-modal h2 { font-size: 24px; font-weight: 900; margin-bottom: 8px; }
.emergency-modal p { font-size: 14px; opacity: 0.9; margin-bottom: 28px; line-height: 1.6; }

.emergency-numbers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.emergency-number-btn {
  padding: 18px 12px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.emergency-number-btn:hover { background: rgba(255,255,255,0.25); }
.emergency-number-btn .en-number { font-size: 28px; font-weight: 900; }
.emergency-number-btn .en-label { font-size: 11px; opacity: 0.8; font-weight: 600; }

/* ============================================================
   UTILS
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--dark-gray); }
.text-sm { font-size: 13px; }
.fw-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

.divider {
  height: 1px;
  background: var(--light-gray);
  margin: 16px 0;
}

.info-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.info-box.blue { background: rgba(29,53,87,0.08); color: var(--secondary); border-left: 3px solid var(--secondary); }
.info-box.green { background: rgba(45,198,83,0.08); color: var(--success-dark); border-left: 3px solid var(--success); }
.info-box.yellow { background: rgba(244,162,97,0.12); color: #B5621A; border-left: 3px solid var(--warning); }
.info-box.red { background: rgba(230,57,70,0.08); color: var(--primary-dark); border-left: 3px solid var(--primary); }

.section-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mid-gray);
  margin-bottom: 12px;
  margin-top: 8px;
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  z-index: 200;
  transition: var(--transition-fast);
  backdrop-filter: blur(10px);
}

.theme-toggle:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
   SCROLLBAR PERSONALIZADA
   ============================================================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--light-gray); border-radius: 2px; }

/* ============================================================
   RESPONSIVO DESKTOP
   ============================================================ */
@media (min-width: 481px) {
  .app-wrapper {
    border-left: 1px solid var(--light-gray);
    border-right: 1px solid var(--light-gray);
    box-shadow: var(--shadow-lg);
  }

  body {
    background: #1a1a2e;
  }

  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: -1;
  }
}

/* ============================================================
   ACESSIBILIDADE
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Alta Contraste */
@media (prefers-contrast: high) {
  .btn-main { border: 2px solid white; }
  .form-control { border-width: 3px; }
}
