/* LegacyWest Admin Hub — dark theme, mobile-first */
:root {
  --bg: #0a0c10;
  --surface: #12161e;
  --surface2: #1a2030;
  --border: #2a3448;
  --accent: #4a9eff;
  --accent2: #ff6b35;
  --text: #e0e6f0;
  --text-muted: #6b7a99;
  --danger: #ff4444;
  --success: #44cc88;
  --warn: #ffc844;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; }
a { color: var(--accent); }
button, input, select { font-family: inherit; }

#login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px; width: 100%; max-width: 340px;
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06101f; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; }
.error-text { color: var(--danger); font-size: 12px; margin-top: 8px; min-height: 14px; }

#app-shell { display: none; min-height: 100dvh; flex-direction: column; }
#app-shell.show { display: flex; }

#topbar {
  height: 52px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 12px; position: sticky; top: 0; z-index: 50;
}
#topbar .brand { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; white-space: nowrap; }
#topbar select#server-switcher { max-width: 160px; }
#idle-pill {
  margin-left: auto; font-size: 11px; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 9px; display: none;
}
#idle-pill.show { display: inline-block; }

#layout { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 190px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 10px 8px; display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
  padding: 10px 12px; border-radius: 8px; color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: 8px; text-decoration: none;
}
.nav-item.active { background: var(--surface2); color: var(--text); }
.nav-item:hover { color: var(--text); }

#content { flex: 1; min-width: 0; overflow-y: auto; padding: 16px; }
.page { display: none; }
.page.active { display: block; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat-tile { background: var(--surface2); border-radius: 8px; padding: 12px; }
.stat-tile .label { font-size: 11px; color: var(--text-muted); }
.stat-tile .value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; background: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
tr.bot-row { background: rgba(74,158,255,0.06); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tag.ok { background: rgba(68,204,136,0.15); color: var(--success); }
.tag.bad { background: rgba(255,68,68,0.15); color: var(--danger); }

#log-lines { font-family: ui-monospace, monospace; font-size: 12.5px; max-height: 60vh; overflow-y: auto; background: #0d1117; border-radius: 8px; padding: 10px; }
#log-lines .line { padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
#log-lines .line .chan { color: var(--accent); }
#log-lines .line .ts { color: var(--text-muted); margin-right: 6px; }
.channel-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.channel-tabs .ch { padding: 6px 12px; border-radius: 999px; background: var(--surface2); font-size: 12px; white-space: nowrap; cursor: pointer; }
.channel-tabs .ch.active { background: var(--accent); color: #06101f; font-weight: 700; }

#map-wrap { position: relative; width: 100%; height: 65vh; background: #0d1117; border-radius: var(--radius); overflow: hidden; touch-action: none; }
#map-canvas { position: absolute; top: 0; left: 0; }
.map-marker { position: absolute; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%); border: 1.5px solid #fff8; }
.map-marker.kill { background: var(--danger); }
.map-marker.hit { background: var(--warn); }
.map-marker.placed, .map-marker.packed { background: var(--accent2); }
.map-marker.connected { background: var(--success); }
.map-marker.disconnected { background: var(--text-muted); }
.map-marker.unmatched { background: var(--text-muted); opacity: 0.6; }
.map-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
#scrubber { width: 100%; }

@media (max-width: 720px) {
  #sidebar { display: none; }
  #layout { flex-direction: column; }
  #bottom-nav {
    display: flex; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 50;
  }
  #bottom-nav .nav-item { flex: 1; flex-direction: column; text-align: center; font-size: 10px; gap: 2px; padding: 6px 2px; }
  #content { padding: 10px; }
  #topbar .brand { font-size: 12px; }
  #topbar select#server-switcher { max-width: 110px; }
}
@media (min-width: 721px) {
  #bottom-nav { display: none; }
}
