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

:root {
  --bg:      #0D1117;
  --surface: #161B22;
  --surface2:#21262D;
  --border:  #30363D;
  --text:    #E6EDF3;
  --muted:   #8B949E;
  --teal:    #1D9E75;
  --teal-l:  #9FE1CB;
  --red:     #EF4444;
  --orange:  #F97316;
  --amber:   #FBBF24;
  --purple:  #7F77DD;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* ── App container ──────────────────────────── */
#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
}

/* ── Header ─────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

#header h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal-l);
  letter-spacing: 0.8px;
  white-space: nowrap;
}

#header .subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.high   { background: var(--red); }
.dot.warn   { background: var(--orange); }
.dot.normal { background: var(--muted); }

#adaptive-bar {
  font-size: 12px;
  color: var(--teal);
  background: #052E26;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--teal);
  white-space: nowrap;
  flex-shrink: 0;
}

#simulate-btn {
  background: var(--teal);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

#simulate-btn.running { background: var(--red); color: white; }

/* ── Main layout ────────────────────────────── */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Left sidebar — Priority + Chat ─────────── */
#left-panel {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

#leaderboard {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 0;
}

#leaderboard h4 {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.zone-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.zone-row:hover { border-color: var(--teal); }
.zone-row.selected { border-color: var(--teal); background: #052E26; }

.zone-rank { font-size: 11px; color: var(--muted); width: 16px; text-align: center; }
.zone-name-label { flex: 1; font-size: 12px; color: var(--text); }
.zone-score { font-size: 11px; font-weight: 700; }
.score-HIGH   { color: var(--red); }
.score-WARN   { color: var(--orange); }
.score-NORMAL { color: var(--muted); }

/* ── Chat ───────────────────────────────────── */
#chat-section {
  padding: 12px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#chat-section h4 {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

#chat-messages {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  height: 250px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.6;
  margin-bottom: 8px;
  color: var(--text);
}

.chat-row { display: flex; gap: 6px; }

#chat-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 11px;
  outline: none;
}

#chat-input:focus { border-color: var(--teal); }

#chat-send {
  background: var(--teal);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

/* ── Map ────────────────────────────────────── */
#map { flex: 1; height: 100%; min-width: 0; }

/* ── Right sidebar — Zone detail + Footer ───── */
#right-panel {
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

/* ── Zone detail ────────────────────────────── */
#zone-detail {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  min-height: 0;
}

#zone-detail h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.alert-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 6px;
}

.alert-badge.HIGH   { background: var(--red);    color: white; }
.alert-badge.WARN   { background: var(--orange);  color: white; }
.alert-badge.NORMAL { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

.chain-bar { display: flex; gap: 3px; margin: 6px 0; }

.chain-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--border);
  border: 1px solid var(--border);
}

.chain-dot.active  { background: var(--teal); border-color: var(--teal); }
.chain-dot.current { background: var(--red);  border-color: var(--red); box-shadow: 0 0 5px var(--red); }

.chain-desc {
  font-size: 11px;
  color: var(--teal-l);
  margin-bottom: 6px;
  line-height: 1.4;
}

.conf-bar-wrap {
  background: var(--surface2);
  border-radius: 3px;
  height: 5px;
  margin-bottom: 4px;
  overflow: hidden;
}

.conf-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 8px;
}

.metric-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
}

.metric-box .label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.metric-box .value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.feedback-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.btn-confirm { background: var(--teal); color: #000; }
.btn-fp      { background: #3D1F1F; color: var(--red); border: 1px solid var(--red); }

/* ── Right footer ───────────────────────────── */
#right-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.footer-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.footer-val {
  font-size: 10px;
  color: var(--text);
  margin-top: 1px;
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Login screen ───────────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#login-box {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 36px 32px;
}

#login-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--teal-l);
  letter-spacing: 2px;
  margin-bottom: 4px;
}

#login-subtitle {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
}

#login-tagline {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.login-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.login-field input:focus { border-color: var(--teal); }

#login-btn {
  width: 100%;
  background: var(--teal);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  margin-bottom: 12px;
}

#login-btn:hover { opacity: 0.9; }

#login-error {
  font-size: 11px;
  color: var(--red);
  text-align: center;
  min-height: 16px;
  margin-bottom: 8px;
}

#login-hint {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.hint-title {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.hint-row {
  font-size: 11px;
  color: var(--muted);
  padding: 5px 6px;
  border-radius: 3px;
  cursor: pointer;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint-row:hover { background: var(--surface2); color: var(--text); }

.hint-role {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 2px;
  flex-shrink: 0;
}

.hint-role.admin    { background: #052E26; color: var(--teal); }
.hint-role.operator { background: #1C1A00; color: var(--amber); }
.hint-role.observer { background: #1A1528; color: var(--purple); }

/* ── Agency badge + logout ──────────────────── */
#agency-badge {
  font-size: 11px;
  color: var(--teal-l);
  background: #052E26;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--teal);
  white-space: nowrap;
  flex-shrink: 0;
}

#logout-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

#logout-btn:hover { border-color: var(--red); color: var(--red); }