:root {
  --bg-deep: #0a0e14;
  --bg-primary: #0f1419;
  --bg-secondary: #151b23;
  --bg-tertiary: #1a2332;
  --bg-hover: #1e2a3a;
  --bg-card: #121820;
  --border: #243044;
  --border-light: #2d3f56;
  --text-primary: #e6edf3;
  --text-secondary: #8b9cb3;
  --text-muted: #5c6b7f;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim: #1e3a5f;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --code1: #22c55e;
  --code2: #3b82f6;
  --code3: #f59e0b;
  --code4: #ef4444;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Inter', system-ui, sans-serif;
  --radius: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.15s ease;
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

#app { height: 100%; position: relative; }

/* BOOT */
.boot-screen {
  position: fixed; inset: 0;
  background: var(--bg-deep);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9999;
}
.boot-logo { text-align: center; margin-bottom: 40px; }
.badge-icon {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, #1e3a5f, #3b82f6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
  margin: 0 auto 20px;
  border: 3px solid var(--accent);
  letter-spacing: 1px;
}
.boot-logo h1 { font-size: 22px; font-weight: 600; letter-spacing: 3px; margin-bottom: 8px; }
.boot-sub { color: var(--text-secondary); font-family: var(--font-mono); font-size: 12px; }
.boot-status { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; margin-bottom: 12px; }
.boot-progress { width: 280px; height: 3px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.boot-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s ease; }

/* TERMINAL LAYOUT */
.terminal {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 48px 1fr;
  height: 100vh;
  background: var(--bg-primary);
}
.terminal.context-open { grid-template-columns: 220px 1fr 320px; }

.hidden { display: none !important; }

/* TOPBAR */
.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
}
.topbar-left, .topbar-center, .topbar-right { display: flex; align-items: center; gap: 16px; }
.dept-badge {
  background: var(--accent); color: white;
  padding: 2px 8px; border-radius: 3px;
  font-weight: 700; font-size: 11px; letter-spacing: 1px;
}
.unit-id, .badge-num { color: var(--text-secondary); }
.time-display { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.date-display, .weather-display, .shift-display { color: var(--text-secondary); }
.status-indicator { font-size: 11px; font-weight: 600; }
.status-indicator.online { color: var(--success); }
.btn-icon {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 16px; padding: 4px 6px;
  border-radius: var(--radius); transition: var(--transition);
  position: relative;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.badge-count {
  position: absolute; top: -2px; right: -2px;
  background: var(--danger); color: white;
  font-size: 9px; font-weight: 700;
  width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* SIDEBAR */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 8px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  background: none; border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans); font-size: 13px;
  cursor: pointer; border-radius: var(--radius);
  transition: var(--transition); text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--border);
}
.player-mini { text-align: center; }
.player-rank {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--accent); letter-spacing: 1px; margin-bottom: 6px;
}
.player-xp { height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.xp-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.5s ease; }

/* MAIN CONTENT */
.main-content {
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg-primary);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.panel { display: none; padding: 20px; height: 100%; }
.panel.active { display: block; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 {
  font-size: 16px; font-weight: 600; letter-spacing: 0.5px;
  font-family: var(--font-mono);
}
.panel-actions { display: flex; gap: 10px; align-items: center; }

/* BUTTONS */
.btn {
  padding: 7px 14px; border-radius: var(--radius);
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: var(--transition); display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: #000; }
.btn-large { padding: 12px 24px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 {
  font-size: 12px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--text-secondary); margin-bottom: 12px;
  font-family: var(--font-mono); text-transform: uppercase;
}
.card.wide { grid-column: span 2; }

/* DASHBOARD */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status-item { display: flex; flex-direction: column; gap: 2px; }
.status-item .label { font-size: 11px; color: var(--text-muted); }
.status-item .value { font-family: var(--font-mono); font-weight: 500; }
.profile-quick .pq-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.profile-quick .pq-row span:first-child { color: var(--text-muted); }
.stats-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.sm-val { display: block; font-size: 22px; font-weight: 700; font-family: var(--font-mono); color: var(--accent); }
.sm-lab { font-size: 11px; color: var(--text-muted); }

/* EVENT LOG */
.event-log {
  max-height: 220px; overflow-y: auto;
  font-family: var(--font-mono); font-size: 12px;
  scrollbar-width: thin;
}
.event-entry {
  padding: 4px 0; border-bottom: 1px solid var(--border);
  display: flex; gap: 10px;
}
.event-time { color: var(--text-muted); min-width: 50px; }
.event-text { color: var(--text-secondary); }
.event-text.important { color: var(--warning); }
.event-text.danger { color: var(--danger); }
.event-text.success { color: var(--success); }

/* NOTIF LIST */
.notif-list { max-height: 180px; overflow-y: auto; }
.notif-item {
  padding: 8px; border-bottom: 1px solid var(--border);
  font-size: 12px; cursor: pointer;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item .n-time { color: var(--text-muted); font-size: 11px; }
.notif-item .n-text { color: var(--text-secondary); }

/* CITY OVERVIEW */
.city-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; }
.district-chip {
  padding: 6px 8px; background: var(--bg-tertiary);
  border-radius: 4px; display: flex; justify-content: space-between;
}
.district-chip .risk-high { color: var(--danger); }
.district-chip .risk-med { color: var(--warning); }
.district-chip .risk-low { color: var(--success); }

/* SEARCH & FILTERS */
.search-input {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); padding: 7px 12px;
  border-radius: var(--radius); font-size: 13px;
  font-family: var(--font-sans); outline: none;
  transition: var(--transition); min-width: 180px;
}
.search-input:focus { border-color: var(--accent); }
.search-input.large { min-width: 400px; flex: 1; }
.filter-select {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); padding: 7px 10px;
  border-radius: var(--radius); font-size: 13px; outline: none;
}

/* EMPTY STATE */
.empty-state {
  color: var(--text-muted); text-align: center;
  padding: 40px 20px; font-size: 13px;
}

/* LIVE INDICATOR */
.live-indicator {
  color: var(--danger); font-size: 12px; font-weight: 600;
  font-family: var(--font-mono); animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* CONTEXT PANEL */
.context-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: none; flex-direction: column;
  overflow: hidden;
}
.terminal.context-open .context-panel { display: flex; }
.context-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.context-header h3 { font-size: 13px; font-family: var(--font-mono); }
.context-body { flex: 1; overflow-y: auto; padding: 16px; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%; max-width: 640px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-family: var(--font-mono); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal.large { max-width: 900px; }

/* CHAR CREATE */
.char-create {
  position: fixed; inset: 0;
  background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
.char-create-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 40px;
  width: 420px;
  text-align: center;
}
.char-create-box h1 { font-size: 14px; letter-spacing: 2px; color: var(--accent); margin-bottom: 8px; }
.char-create-box h2 { font-size: 18px; margin-bottom: 30px; }
.form-row { margin-bottom: 16px; text-align: left; }
.form-row label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.form-row input, .form-row select {
  width: 100%; padding: 10px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius);
  font-size: 14px; outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: var(--accent); }
#char-form { margin-bottom: 16px; }
#char-form .btn { width: 100%; margin-top: 10px; }

/* TOAST */
.toast-container {
  position: fixed; top: 60px; right: 20px;
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: var(--radius);
  min-width: 280px; max-width: 360px;
  font-size: 13px; box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.danger { border-left-color: var(--danger); }
.toast .toast-title { font-weight: 600; margin-bottom: 2px; }
.toast .toast-msg { color: var(--text-secondary); font-size: 12px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* RESPONSIVE */
@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .card.wide { grid-column: span 2; }
}
@media (max-width: 900px) {
  .terminal { grid-template-columns: 60px 1fr; }
  .nav-item span:not(.nav-icon):not(.nav-badge) { display: none; }
  .sidebar-footer { display: none; }
}
