:root {
  --bg: #070d1a;
  --bg-elev: #111c33;
  --bg-card: rgba(17, 28, 51, 0.85);
  --border: #223455;
  --text: #e6edf7;
  --muted: #8fa3c4;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --accent: #6366f1;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 15% 0%, #10203d 0%, var(--bg) 55%);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
h2 { margin: 0 0 6px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: #f1f5f9; }
label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* Login */
.login-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #172b52, #060b16 70%);
}
.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.brand-big { font-size: 28px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; }

/* Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px;
  background: rgba(8, 14, 28, 0.96);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid #172540; margin-bottom: 14px; }
.brand-icon { font-size: 24px; background: linear-gradient(135deg, #0ea5e9, #6366f1); width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.brand-name { font-size: 18px; font-weight: 800; color: #fff; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 5px; flex: 1; overflow-y: auto; }
.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.nav-btn:hover { background: rgba(56, 189, 248, 0.08); color: #fff; }
.nav-btn.active {
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.22), rgba(99, 102, 241, 0.14));
  border-color: rgba(56, 189, 248, 0.45);
  color: #fff;
  font-weight: 600;
}
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.user-badge { font-size: 12px; color: var(--muted); padding: 0 4px; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(11, 19, 36, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.project-picker { display: flex; align-items: center; gap: 10px; }
.project-picker select { min-width: 320px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.pill-count { background: var(--primary-dark); color: #fff; padding: 1px 7px; border-radius: 99px; font-size: 11px; }

.content { padding: 22px; display: flex; flex-direction: column; gap: 18px; max-width: 1520px; }
.tab-panel { display: none; flex-direction: column; gap: 16px; }
.tab-panel.active { display: flex; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.accent-card { border-color: rgba(56, 189, 248, 0.4); background: linear-gradient(180deg, rgba(14, 165, 233, 0.08), var(--bg-card)); }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; }
.kpi-card {
  background: linear-gradient(145deg, rgba(22, 36, 65, 0.92), rgba(11, 19, 36, 0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-val { font-size: 28px; font-weight: 800; color: var(--primary); }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.table-wrap { overflow-x: auto; }

/* Inputs & Buttons */
input, select, textarea {
  background: #091121;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18); }
.form-grid { display: flex; flex-direction: column; gap: 9px; }
.inline-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }

.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--bg-elev);
  transition: all 0.15s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: linear-gradient(135deg, #0284c7, #2563eb); border-color: #38bdf8; }
.btn.warning { background: linear-gradient(135deg, #b45309, #d97706); border-color: var(--warning); }
.btn.danger { background: #991b1b; border-color: var(--danger); }
.btn.ghost { background: rgba(15, 23, 42, 0.5); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #1d2c48; vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.table tr:hover td { background: rgba(56, 189, 248, 0.04); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok, .badge.HEALTHY, .badge.STABLE, .badge.IMPROVED, .badge.completed, .badge.SUCCESS { background: rgba(34, 197, 94, 0.16); color: #4ade80; }
.badge.warn, .badge.WARNING, .badge.FAIR, .badge.running, .badge.queued { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge.bad, .badge.CRITICAL, .badge.DEGRADED, .badge.failed, .badge.ERROR { background: rgba(239, 68, 68, 0.22); color: #f87171; }
.badge.info, .badge.NEW, .badge.INFO, .badge.UNKNOWN, .badge.cancelled { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.badge.internal { background: rgba(139, 92, 246, 0.22); color: #c4b5fd; }

.progress-wrap { width: 110px; height: 8px; background: #070d1a; border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #0ea5e9, #6366f1); }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.photo-tile { background: #091121; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.photo-tile img { width: 100%; height: 130px; object-fit: cover; display: block; background: #020617; }
.photo-meta { padding: 9px 10px; font-size: 12px; }

/* AI Chat */
.chat-card { display: flex; flex-direction: column; min-height: 520px; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: 460px; padding: 6px; }
.chat-bubble { max-width: 82%; padding: 11px 14px; border-radius: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-bubble.user { align-self: flex-end; background: linear-gradient(135deg, #0284c7, #2563eb); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: #0c172b; border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.chat-meta { font-size: 11px; opacity: 0.72; margin-bottom: 4px; }

/* Checklist */
.checklist { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; padding: 4px 0; }
.check-item { display: flex; align-items: center; gap: 10px; background: #091121; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }

/* Explorer & Terminal */
.pill-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill { background: #091121; border: 1px solid var(--border); color: var(--primary); border-radius: 999px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.path-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.path-bar input { flex: 1; }
.terminal-box, .code-box {
  background: #040811;
  border: 1px solid #1d2c48;
  border-radius: 9px;
  padding: 12px;
  font-family: "JetBrains Mono", "DejaVu Sans Mono", monospace;
  font-size: 12px;
  color: #86efac;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}
.terminal-box.tall { height: 240px; max-height: 360px; }
.alert-box { background: #091121; border-left: 4px solid var(--primary); padding: 12px; border-radius: 8px; margin-bottom: 12px; }

/* Drawer & Toast */
.drawer {
  position: fixed; right: 16px; top: 58px; width: 370px; max-height: 75vh;
  background: #0d172b; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55); z-index: 30; display: flex; flex-direction: column;
}
.drawer-header { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.drawer-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.notif-item { background: #091121; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: #0284c7; color: #fff;
  padding: 11px 18px; border-radius: 10px; font-weight: 600; z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

/* Right-click Drive Context Menu */
.context-menu {
  position: fixed;
  z-index: 90;
  min-width: 270px;
  background: #0b1426;
  border: 1px solid #2b446f;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ctx-header {
  font-size: 11.5px;
  font-weight: 700;
  color: #38bdf8;
  padding: 6px 10px;
  border-bottom: 1px solid #1d2e4c;
  margin-bottom: 4px;
}
.context-menu button {
  background: transparent;
  border: none;
  color: #e6edf7;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.context-menu button:hover { background: rgba(56, 189, 248, 0.16); }
.context-menu button.ctx-danger { color: #fca5a5; }
.context-menu button.ctx-danger:hover { background: rgba(239, 68, 68, 0.22); }
.ctx-sep { height: 1px; background: #1d2e4c; margin: 4px 0; }
