:root {
  --bg: #0d1b2a;
  --bg2: #12263a;
  --card: #142b3d;
  --border: #1f3a52;
  --teal: #2dd4bf;
  --teal-dim: #14b8a6;
  --text: #e6f1f7;
  --muted: #7f9db5;
  --orange: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --yellow: #eab308;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #10253a 0%, var(--bg) 55%);
  color: var(--text); min-height: 100vh;
}
.hidden { display: none !important; }
.center { text-align: center; }

/* login */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 40px; width: 360px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; letter-spacing: .5px; }
.brand-logo { font-size: 26px; }
.tagline { color: var(--muted); font-size: 13px; margin: 4px 0 24px; }
.login-card label { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 4px; }
.login-card input {
  width: 100%; padding: 10px 12px; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.login-card button[type=submit], .btn {
  margin-top: 18px; width: 100%; padding: 11px; background: linear-gradient(135deg, var(--teal), var(--teal-dim));
  border: none; border-radius: 8px; color: #06221d; font-weight: 700; font-size: 15px; cursor: pointer;
}
.error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; background: rgba(18,38,58,.85); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 14px; font-size: 13px; color: var(--teal);
}
.ghost-btn {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: var(--teal); }
.lang-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}

/* alert banner */
.alert-banner {
  display: flex; align-items: center; gap: 12px; margin: 14px 22px 0;
  padding: 12px 16px; background: rgba(245,158,11,.12); border: 1px solid var(--orange);
  border-radius: 10px; color: var(--yellow); font-size: 14px;
}
.alert-banner .btn.sm { width:auto; margin-top:0; padding:7px 14px; font-size:12px; background: var(--orange); color:#1a1206; }

/* grid */
.grid {
  display: grid; gap: 16px; padding: 18px 22px;
  grid-template-columns: repeat(12, 1fr);
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; overflow: hidden;
}
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.w-map { grid-column: span 8; }
.w-side { grid-column: span 4; }
.w-full { grid-column: 1 / -1; }
.w-half { grid-column: span 6; }
@media (max-width: 900px){ .w-map,.w-side,.w-half { grid-column: 1/-1; } }

.map-box { width: 100%; height: 340px; background: #0a1420; border-radius: 10px; position: relative; }
.map-box img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.legend {
  position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.6);
  border-radius: 8px; padding: 8px 10px; font-size: 11px;
}
.legend .bar { display:flex; gap:1px; margin-top:4px; }
.legend .bar span { width: 14px; height: 8px; border-radius: 2px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 10px; }
.tile { background: var(--bg2); border:1px solid var(--border); border-radius: 10px; padding: 12px; }
.tile .k { font-size: 11px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 700; margin-top: 2px; }

/* alerts list */
.alerts-list { display:flex; flex-direction:column; gap:8px; max-height:300px; overflow:auto; }
.alert-item {
  background: var(--bg2); border-left: 3px solid var(--yellow); border-radius: 8px;
  padding: 10px 12px; font-size: 13px;
}
.alert-item.sev-high { border-left-color: var(--red); }
.alert-item.sev-medium { border-left-color: var(--orange); }
.alert-item .sev { font-weight:700; }

/* chart bars */
.bars { display:flex; align-items:flex-end; gap:6px; height:140px; margin-top:8px; }
.bars .bar { flex:1; background: linear-gradient(180deg, var(--teal), var(--teal-dim)); border-radius: 4px 4px 0 0; min-height:4px; position:relative; }
.bars .bar span { position:absolute; bottom:-18px; left:0; right:0; text-align:center; font-size:9px; color:var(--muted); }

/* agents */
.agents { padding: 6px 22px 26px; }
.agents h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing:.6px; margin: 8px 0 12px; }
.agents-row { display:grid; grid-template-columns: repeat(auto-fit, minmax(170px,1fr)); gap: 12px; }
.agent-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; cursor: pointer; transition: transform .12s, border-color .12s;
  display:flex; flex-direction:column; gap:6px;
}
.agent-tile:hover { transform: translateY(-3px); border-color: var(--teal); }
.agent-tile .ic { font-size: 26px; }
.agent-tile .nm { font-weight:700; font-size:14px; }
.agent-tile .ds { font-size:12px; color: var(--muted); }

/* modal / chat */
.modal { position:fixed; inset:0; background: rgba(4,10,18,.7); display:flex; align-items:center; justify-content:center; z-index:50; padding:20px; }
.modal-card {
  background: var(--bg2); border:1px solid var(--border); border-radius:16px;
  width: 560px; max-width:100%; height: 70vh; display:flex; flex-direction:column; padding:16px;
}
.modal-card.narrow { width: 380px; height:auto; gap:10px; }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding-bottom:10px; border-bottom:1px solid var(--border); }
.chat-title { font-weight:700; }
.chat-notes { font-size:12px; color:var(--muted); padding:8px 0; }
.chat-log { flex:1; overflow:auto; display:flex; flex-direction:column; gap:8px; padding:10px 0; }
.msg { max-width:82%; padding:9px 13px; border-radius:12px; font-size:13px; line-height:1.45; white-space:pre-wrap; }
.msg.user { align-self:flex-end; background: var(--teal-dim); color:#04211c; }
.msg.bot { align-self:flex-start; background: var(--card); border:1px solid var(--border); }
.msg.loading { color:var(--muted); font-style:italic; }
.chat-form { display:flex; gap:8px; padding-top:10px; border-top:1px solid var(--border); }
.chat-form input { flex:1; padding:10px 12px; background:var(--card); color:var(--text); border:1px solid var(--border); border-radius:8px; }
.chat-form button { padding:10px 18px; background:var(--teal); border:none; border-radius:8px; color:#04211c; font-weight:700; cursor:pointer; }
.row.gap { display:flex; gap:8px; }
.no-data { color: var(--muted); font-size: 13px; }