:root {
  --bg: #08101d;
  --panel: rgba(16, 32, 66, 0.78);
  --panel-2: rgba(12, 26, 58, 0.78);
  --text: #e2e8f0;
  --muted: #9fb0ca;
  --accent: #2563eb;
  --accent-2: #1e40af;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --nav-h: 84px;
}

body[data-theme="light"] {
  --bg: #f4f6fb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-2: rgba(247, 249, 253, 0.9);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #1e40af;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(56, 189, 248, 0.2), transparent 35%),
    radial-gradient(circle at 85% 78%, rgba(168, 85, 247, 0.16), transparent 30%),
    radial-gradient(circle at top left, #0f1b2e, #08101d 62%);
  color: var(--text);
  position: relative;
}

body[data-theme="light"] {
  background: var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url('assets/chart-bg.png') center/cover no-repeat;
  opacity: 0.17;
  pointer-events: none;
  z-index: 0;
}

#loginScreen,
#app {
  position: relative;
  z-index: 2;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 36px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  background: rgba(10, 15, 25, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
}

body[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

.brand-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
}

.app-logo {
  height: 36px;
  margin-right: 12px;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.24rem; font-weight: 700; }
h2 { margin-bottom: 14px; font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 0.84rem; }

.icon-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 6px 10px;
}

body[data-theme="light"] .icon-btn {
  border-color: rgba(15, 23, 42, 0.14);
}

.hidden { display: none !important; }

.status-badge {
  border-radius: 999px;
  font-size: 0.76rem;
  padding: 7px 12px;
  font-weight: 700;
}

.status-badge.safe {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
}

.status-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.status-badge.breach {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.5);
}

body[data-theme="light"] .status-badge {
  box-shadow: none;
}

.content { padding: 18px; }

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.info-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(20, 30, 50, 0.75);
  color: var(--text);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 1rem;
}

body[data-theme="light"] .info-btn {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.1);
}

.info-panel p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.info-panel p:last-child { margin-bottom: 0; }

.screen { display: none; }
.screen.active { display: block; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 20px 40px rgba(0, 0, 0, 0.46);
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 25px 60px rgba(0, 0, 0, 0.56);
}

body[data-theme="light"] .card {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

.label {
  font-size: 0.79rem;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.metric {
  font-size: 1.36rem;
  font-weight: 700;
}

.form-grid { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 0.84rem; color: var(--muted); }

input, select {
  width: 100%;
  min-height: 42px;
  background: rgba(11, 20, 36, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
}

body[data-theme="light"] input,
body[data-theme="light"] select {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

input:focus, select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.7);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.btn {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 600;
  color: white;
  border: none;
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-3px);
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.8);
  box-shadow: none;
}

body[data-theme="light"] .btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch input { display: none; }

.slider {
  width: 48px;
  height: 24px;
  background: #334155;
  border-radius: 999px;
  position: relative;
  transition: 0.3s;
}

.slider::before {
  content: "";
  width: 20px;
  height: 20px;
  background: white;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .slider {
  background: #2563eb;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.55);
}

.switch input:checked + .slider::before {
  transform: translateX(24px);
}

.switch-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.progress-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

body[data-theme="light"] .progress-track {
  background: rgba(0, 0, 0, 0.08);
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}

.locked-list { margin: 10px 0; padding-left: 18px; color: var(--muted); }
.journal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.journal-list li {
  background: rgba(11, 20, 36, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px;
  font-size: 0.86rem;
}

/* Settings tabs styling */
.tabs {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 16px;
}

.tab {
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: none;
  padding: 10px 0;
  cursor: pointer;
  font-weight: 500;
}

.tab.active {
  color: #fff;
  border-bottom: 2px solid #3b82f6;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

body[data-theme="light"] .journal-list li {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
}

.locked-item { cursor: pointer; }

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.delete-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.delete-btn:hover { color: var(--danger); }

.fade-out {
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.bottom-nav {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  max-width: 496px;
  margin: auto;
  height: var(--nav-h);
  padding: 10px 8px;
  background: rgba(15, 23, 42, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px 24px 20px 20px;
  box-shadow: 0 -10px 26px rgba(9, 14, 26, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 30;
}

body[data-theme="light"] .bottom-nav {
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  border-left: 1px solid rgba(15, 23, 42, 0.06);
  border-right: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.12);
}

.nav-btn {
  border: none;
  background: transparent;
  color: #8a97ac;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 14px;
  transition: color 0.2s ease, transform 0.2s ease, text-shadow 0.2s ease;
}

.nav-icon { width: 22px; height: 22px; display: block; }
.nav-label { font-size: 0.74rem; letter-spacing: 0.01em; }

.nav-btn.active {
  color: var(--accent);
  transform: scale(1.05);
  text-shadow: 0 0 12px rgba(58, 132, 255, 0.35);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: rgba(20, 30, 50, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

body[data-theme="light"] .modal-card {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.modal-card.info { border-color: rgba(37, 99, 235, 0.45); }
.modal-card.warning { border-color: rgba(245, 158, 11, 0.45); }
.modal-card.danger { border-color: rgba(239, 68, 68, 0.5); }

@media (max-width: 380px) {
  .grid-two, .btn-row { grid-template-columns: 1fr; }
}

#app.locked-state {
  outline: 1px solid rgba(255, 77, 90, 0.35);
  border-radius: 14px;
}

#clearJournalBtn,
#clearAlertsBtn {
  margin-top: 10px;
}
