:root {
  --primary: #0077B6;
  --primary-light: #90E0EF;
  --secondary: #00B4D8;
  --accent: #E0A96D; /* Dourado */
  --bg-color: #f4f7f6;
  --card-bg: rgba(255, 255, 255, 0.75);
  --text-main: #1a1a24;
  --text-muted: #555566;
  --border: rgba(255, 255, 255, 0.5);
  --nav-bg: rgba(255, 255, 255, 0.85);
  --danger: #e63946;
  --success: #2a9d8f;
  --glass-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 8px 32px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0A192F;
    --card-bg: rgba(17, 34, 64, 0.65);
    --text-main: #ccd6f6;
    --text-muted: #8892b0;
    --border: rgba(255, 255, 255, 0.1);
    --nav-bg: rgba(10, 25, 47, 0.85);
    --primary: #00B4D8;
    --glass-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 32px rgba(0, 0, 0, 0.3);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #050b14;
  background-image: radial-gradient(circle at 50% 0%, #10243d 0%, #050b14 70%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

#app-content {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  background-color: var(--bg-color);
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
  position: relative;
  transition: max-width 0.3s ease;
}

.hidden { display: none !important; }

/* -------------------
   PIN SCREEN
-------------------- */
#pin-screen {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background-color: var(--bg-color);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s;
}
#pin-screen:not(.active) {
  opacity: 0;
  pointer-events: none;
}
.pin-container { text-align: center; }
.pin-container h2 { font-size: 24px; margin-bottom: 8px; color: var(--primary); }
.pin-container p { color: var(--text-muted); margin-bottom: 32px; }
.pin-dots {
  display: flex; gap: 16px; justify-content: center; margin-bottom: 48px;
}
.dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  transition: background-color 0.2s;
}
.dot.filled { background-color: var(--primary); }
.pin-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 300px;
  margin: 0 auto;
}
.num-key {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: none;
  background-color: var(--card-bg);
  color: var(--text-main);
  font-size: 28px;
  font-weight: 300;
  display: flex; justify-content: center; align-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  cursor: pointer;
}
.num-key:active { background-color: var(--border); }
.action-key { font-size: 20px; font-weight: normal; background: transparent; box-shadow: none; }
#pin-error { color: var(--danger); margin-top: 24px; font-weight: 600; }
.shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
  40%, 60% { transform: translate3d(8px, 0, 0); }
}

/* -------------------
   APP HERO & LAYOUT
-------------------- */
.app-hero {
  position: relative;
  width: 100%;
  height: 280px;
  background-image: url('assets/img/panama_hero.jpg');
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  margin-bottom: 0;
  transition: background-image 0.5s ease-in-out;
}
.hero-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to top, rgba(10, 25, 47, 0.9) 0%, rgba(10, 25, 47, 0.2) 60%, transparent 100%);
}
.hero-content {
  position: relative;
  z-index: 10;
  padding: 24px;
  color: #fff;
}
.hero-content h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.hero-content p {
  font-size: 16px;
  color: var(--primary-light);
  font-weight: 500;
}

.app-main { padding: 20px 16px; }

.tab-pane { display: none; animation: fadeIn 0.3s; }
.tab-pane.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Cards & Buttons (Liquid Glass) */
.card {
  background-color: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.card h3 { font-size: 18px; margin-bottom: 8px; color: var(--primary); }
.card p { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  border: none;
  cursor: pointer;
}
.btn.primary { background-color: var(--primary); color: #fff; }
.btn.outline { border: 1px solid var(--primary); color: var(--primary); background: transparent; }
.list-btn { display: block; width: 100%; margin-bottom: 8px; }

/* Filter Bar (Roteiro - Segmented Control) */
.filter-bar {
  display: flex;
  background-color: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px;
  gap: 6px;
  margin-bottom: 24px;
  box-shadow: var(--glass-shadow);
}
.filter-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.filter-btn:hover {
  color: var(--text-main);
}
.filter-btn.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 180, 216, 0.4);
}

/* Timeline */
.timeline-day { margin-bottom: 24px; position: relative; padding-left: 20px; border-left: 2px solid var(--border); }
.timeline-day::before {
  content: ''; position: absolute; left: -7px; top: 0;
  width: 12px; height: 12px; border-radius: 50%;
  background-color: var(--accent);
}
.timeline-date { font-weight: 700; font-size: 16px; margin-bottom: 12px; color: var(--text-main); }
.timeline-event {
  background-color: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; margin-bottom: 12px;
}
.event-time { font-size: 12px; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.event-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.event-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.event-actions { display: flex; gap: 6px; }
.event-actions a { font-size: 12px; padding: 6px 10px; }

/* Orçamento */
.budget-summary { display: flex; justify-content: space-around; flex-wrap: wrap; text-align: center; }
.budget-summary h3 { width: 100%; margin-bottom: 16px; }
.budget-item { display: flex; flex-direction: column; align-items: center; margin-bottom: 12px; }
.currency { font-size: 12px; color: var(--text-muted); }
.value { font-size: 18px; font-weight: 700; color: var(--primary); }

.converter-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.converter-group label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.converter-group input {
  padding: 12px; border-radius: 8px; border: 1px solid var(--border);
  background-color: var(--bg-color); color: var(--text-main);
  font-size: 16px; font-weight: 600; width: 100%;
}
.converter-note { font-size: 11px; color: var(--text-muted); margin-top: 12px; }

/* Checklist */
.progress-container { margin-bottom: 24px; }
.progress-text { font-size: 14px; font-weight: 600; margin-bottom: 8px; text-align: right; color: var(--primary); }
.progress-bar-bg { width: 100%; height: 8px; background-color: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background-color: var(--success); width: 0%; transition: width 0.3s ease; }

.checklist-group { margin-bottom: 24px; }
.checklist-group h4 { font-size: 15px; margin-bottom: 12px; color: var(--accent); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.check-item { display: flex; align-items: center; margin-bottom: 12px; }
.check-item input[type="checkbox"] {
  width: 20px; height: 20px; margin-right: 12px;
  accent-color: var(--success);
}
.check-item label { font-size: 15px; color: var(--text-main); }
.check-item.done label { text-decoration: line-through; color: var(--text-muted); }

/* Bottom Nav (Floating Pill Style) */
.bottom-nav {
  position: fixed; 
  bottom: calc(16px + env(safe-area-inset-bottom)); 
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  background-color: var(--nav-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 30px;
  display: flex; 
  justify-content: space-around;
  padding: 8px 12px;
  z-index: 1000;
  box-shadow: var(--glass-shadow);
}
.nav-item {
  background: transparent; border: none;
  display: flex; flex-direction: column; align-items: center;
  color: var(--text-muted); font-size: 11px;
  cursor: pointer; padding: 4px 8px;
}
.nav-item .icon { font-size: 20px; margin-bottom: 4px; filter: grayscale(100%); opacity: 0.7; }
.nav-item.active { color: var(--primary); }
.nav-item.active .icon { filter: none; opacity: 1; }

.alert-card { border-left: 4px solid var(--danger); }
.alert-card h3 { color: var(--danger); }
.alert-card ul { margin-left: 16px; margin-top: 8px; font-size: 14px; }
.alert-card li { margin-bottom: 6px; }

/* -------------------
   RESPONSIVIDADE (iPAD & DESKTOP)
-------------------- */
@media (min-width: 768px) {
  body {
    padding: 32px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }

  #app-content {
    max-width: 780px;
    margin: 0 auto;
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border);
    overflow: hidden;
  }

  .app-hero {
    height: 320px;
    border-bottom-left-radius: 28px;
    border-bottom-right-radius: 28px;
  }

  .hero-content {
    padding: 32px;
  }

  .hero-content h1 {
    font-size: 38px;
  }

  .hero-content p {
    font-size: 18px;
  }

  .app-main {
    padding: 32px 28px;
  }

  /* Grid nos Vouchers no iPad e Desktop */
  #tab-vouchers.active {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  #tab-vouchers .card {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* Grid no Orçamento no iPad e Desktop */
  #tab-orcamento.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  #tab-orcamento .card {
    margin-bottom: 0;
  }

  /* Grid na Emergência no iPad e Desktop */
  #tab-emergencia.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  #tab-emergencia .card {
    margin-bottom: 0;
  }

  .bottom-nav {
    max-width: 540px;
    padding: 10px 20px;
  }

  .nav-item {
    font-size: 12px;
    padding: 6px 14px;
  }

  .nav-item .icon {
    font-size: 22px;
  }

  .pin-container {
    padding: 40px;
    border-radius: 28px;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: var(--glass-shadow);
  }
}
