@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Russo+One&display=swap");

:root {
  --background-color: #0d0821;
  --background-gradient: linear-gradient(135deg, #0d0821 0%, #1a1230 100%);
  --primary-color: #ff51f9;
  --accent-color-1: #a348ff;
  --accent-color-2: #3978ff;
  --highlight-color: #f093ff;
  --text-primary: #ffffff;
  --text-secondary: #cfc9dd;
  --success-color: #32fba2;
  --warning-color: #ffcc00;
  --error-color: #ff4d6d;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 32px rgba(255, 81, 249, 0.12);
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --warn-info: #7ec8ff;
  --warn-minor: #ffd166;
  --warn-moderate: #ff9f43;
  --warn-severe: #ff6b6b;
  --warn-extreme: #c9184a;
}

html[data-theme="light"] {
  --background-color: #f4f0ff;
  --background-gradient: linear-gradient(135deg, #f4f0ff 0%, #ebe4ff 100%);
  --text-primary: #1b1238;
  --text-secondary: #5f5380;
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(20, 10, 60, 0.1);
  --glass-shadow: 0 8px 32px rgba(57, 120, 255, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--background-gradient);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-color); text-decoration: none; }
a:hover { color: var(--highlight-color); }

.container {
  width: min(1200px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  backdrop-filter: blur(16px);
  background: rgba(13, 8, 33, 0.72);
  border-bottom: 1px solid var(--glass-border);
}
html[data-theme="light"] .site-header { background: rgba(244, 240, 255, 0.88); }

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: "Russo One", sans-serif;
  font-size: 22px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color-2));
  box-shadow: 0 10px 30px rgba(255, 81, 249, 0.28);
}

.brand-title {
  font-family: "Russo One", sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.brand-sub {
  color: var(--text-secondary);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.status-pill.bad { border-color: rgba(255, 77, 109, 0.45); color: #ffb4c2; }

.app-main { padding: var(--space-4) 0 var(--space-5); }

.hero-copy { margin-bottom: var(--space-3); }
.hero-copy h1 {
  font-family: "Russo One", sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.1;
  margin: 0.4rem 0 0.8rem;
}
.hero-copy p { color: var(--text-secondary); max-width: 760px; }

.glass-card,
.panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.muted, .text-secondary { color: var(--text-secondary); }
.no-margin { margin: 0; }
.block { display: block; margin-top: 0.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: 0.72rem 1rem;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.92rem;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }

.btn-primary {
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color-1));
}
.btn-secondary {
  color: var(--text-primary);
  background: var(--glass-bg);
  border-color: var(--glass-border);
}
.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
  border-color: var(--glass-border);
}
.icon-btn { min-width: 44px; padding-inline: 0.7rem; }
.full-width { width: 100%; }

label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-bottom: 0.45rem;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text-primary);
  padding: 0.72rem 0.85rem;
  font-size: 0.95rem;
}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea { background: rgba(255,255,255,0.92); }

.controls {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.search-wrap { position: relative; }
.search-results {
  position: absolute;
  z-index: 50;
  left: 0; right: 0;
  top: calc(100% + 6px);
  list-style: none;
  border-radius: var(--radius-lg);
  background: rgba(20, 12, 40, 0.96);
  border: 1px solid var(--glass-border);
  max-height: 280px;
  overflow: auto;
  box-shadow: var(--glass-shadow);
}
html[data-theme="light"] .search-results { background: #fff; }
.search-results.hidden { display: none; }
.search-results li { padding: 0.7rem 0.85rem; cursor: pointer; }
.search-results li:hover { background: rgba(255,255,255,0.06); }
.search-results li strong { display: block; }
.search-results li span { color: var(--text-secondary); font-size: 0.78rem; }

.control-actions { display: flex; gap: 8px; align-items: end; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-3);
}
.tab {
  border-radius: var(--radius-lg);
  padding: 0.62rem 0.95rem;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 600;
}
.tab.active {
  background: linear-gradient(135deg, rgba(255,81,249,0.95), rgba(57,120,255,0.95));
  border-color: transparent;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
}
.card { min-height: 140px; }
.card h2 { font-size: 0.95rem; color: var(--text-secondary); font-weight: 600; }
.big {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 0.35rem 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.metric, .day, .hour-card, .source-item, .source-status, .warning-card, .admin-stat {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 14px;
  background: rgba(0,0,0,0.14);
}
.metric span { display: block; color: var(--text-secondary); font-size: 0.78rem; margin-bottom: 6px; }
.metric strong { font-size: 1.35rem; }

.hour-strip, .days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.hour-card span { display: block; font-size: 1.35rem; font-weight: 800; margin: 0.4rem 0; }
.bar { height: 6px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,0.12); margin: 0.7rem 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-color-2), var(--primary-color)); }

#map {
  min-height: 520px;
  height: min(68vh, 720px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}
.map-actions, .timeline-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.timeline-controls {
  display: grid;
  grid-template-columns: repeat(5, auto) 1fr;
  gap: 8px;
  align-items: center;
}
.panel-inner {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.12);
}
.inline-check { display: inline-flex; gap: 8px; align-items: center; font-size: 0.85rem; color: var(--text-secondary); }
.inline-check input { width: auto; }

.warnings-list { display: grid; gap: 14px; }
.warning-card { border-left: 4px solid var(--warn-info); }
.warning-card.warn-minor { border-left-color: var(--warn-minor); }
.warning-card.warn-moderate { border-left-color: var(--warn-moderate); }
.warning-card.warn-severe { border-left-color: var(--warn-severe); }
.warning-card.warn-extreme { border-left-color: var(--warn-extreme); }
.warning-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.warn-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.instruction {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.warncell-info {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  background: rgba(57,120,255,0.08);
  font-size: 0.85rem;
}

.source-status-grid, .admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.source-status.ok { border-color: rgba(50, 251, 162, 0.35); }
.source-status.error { border-color: rgba(255, 77, 109, 0.4); }
.source-status strong { display: block; text-transform: capitalize; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  cursor: pointer;
}
.favorites-panel.hidden { display: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--glass-border); }
th { color: var(--text-secondary); font-size: 0.8rem; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.rendered-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.rendered-frame { border: 1px solid var(--glass-border); border-radius: var(--radius-lg); overflow: hidden; }
.rendered-frame img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.rendered-frame figcaption { padding: 8px 10px; font-size: 0.78rem; color: var(--text-secondary); }

.site-footer {
  border-top: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.22);
  padding: var(--space-4) 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-3);
}
.footer-grid ul { list-style: none; }
.footer-grid li { margin-bottom: 0.35rem; }
.footer-grid a { color: var(--text-secondary); }
.footer-grid a:hover { color: var(--primary-color); }

.leaflet-control-layers, .leaflet-popup-content-wrapper { color: #1b1238; }

/* Admin */
.admin-page { min-height: 100vh; }
.admin-login-wrap {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
  padding: var(--space-4) 0;
}
.admin-login-card { width: min(420px, 100%); }
.admin-login-card h1 {
  font-family: "Russo One", sans-serif;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}
.admin-error {
  color: var(--error-color);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.admin-hidden { display: none !important; }
.hidden { display: none !important; }
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.admin-stat strong { display: block; font-size: 1.2rem; }
.admin-stat span { color: var(--text-secondary); font-size: 0.82rem; }
.config-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}

.legal-page { max-width: 760px; margin: 40px auto; padding: 0 20px; }
.legal-page h1 { font-family: "Russo One", sans-serif; }

@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls { grid-template-columns: 1fr 1fr; }
  .search-wrap, .control-actions { grid-column: 1 / -1; }
  .footer-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .grid, .metrics, .controls { grid-template-columns: 1fr; }
  #map { min-height: 380px; height: 52vh; }
  .timeline-controls { grid-template-columns: repeat(5, auto); }
  .timeline-controls input[type=range] { grid-column: 1 / -1; }
}
