:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-2: #1a2234;
  --border: #243047;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-w: 240px;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.875rem; }
.error { color: #fca5a5; font-size: 0.85rem; margin-top: 0.75rem; }
.hint { color: var(--muted); font-size: 0.8rem; margin: 0 0 16px; }

.logo-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; color: white;
  flex-shrink: 0;
}
.logo-mark.sm { width: 32px; height: 32px; font-size: 0.95rem; border-radius: 8px; }
.logo-mark.logo-image {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
  padding: 6px;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}
.logo-mark.logo-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.logo-mark.logo-image.sm { padding: 5px; }

.brand-name { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99, 102, 241, 0.18), transparent),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-card h1 { font-size: 1.35rem; margin-bottom: 6px; }
.login-card form { display: grid; gap: 16px; margin-top: 24px; }
.login-card label { display: grid; gap: 6px; }
.login-card label span { font-size: 0.8rem; color: var(--muted); font-weight: 500; }

input, select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
.search-input { min-width: 220px; }
.select-input { min-width: 140px; }

button {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
button:hover { background: var(--accent-hover); }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
button.ghost:hover { border-color: var(--accent); color: var(--text); }
button.danger { background: #991b1b; }
button.danger:hover { background: var(--danger); }
button.success { background: #065f46; }
button.success:hover { background: var(--success); }
button.small { padding: 5px 10px; font-size: 0.75rem; }
button.full { width: 100%; }
button.icon-btn {
  background: transparent; border: 1px solid var(--border);
  width: 36px; height: 36px; padding: 0; border-radius: 8px;
  color: var(--muted); font-size: 1rem;
}
button.icon-btn:hover { color: var(--text); border-color: var(--accent); }

/* Shell layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 10;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: rgba(99, 102, 241, 0.15); color: var(--accent-hover); }
.nav-icon { font-size: 0.85rem; opacity: 0.7; width: 18px; text-align: center; }

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: grid; gap: 8px;
}
.admin-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.75rem;
  overflow: hidden;
}
.admin-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: var(--success); box-shadow: 0 0 6px var(--success); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-width: 0;
}
.main-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; gap: 16px;
}
.main-header h1 { font-size: 1.5rem; font-weight: 700; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.refresh-icon { display: inline-block; }

/* Cards & grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.75rem; font-weight: 700; margin-top: 4px; }
.kpi-value.accent { color: var(--accent-hover); }
.kpi-value.success { color: var(--success); }
.kpi-value.warning { color: var(--warning); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .sidebar-brand .brand-name, .sidebar-brand .brand-sub,
  .nav-item span:not(.nav-icon), .admin-email, .sidebar-foot .ghost { display: none; }
  .main { margin-left: 64px; padding: 20px 16px; }
  .sidebar-brand { justify-content: center; padding: 16px 8px; }
  .nav-item { justify-content: center; padding: 12px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.card-head h2 { font-size: 0.95rem; font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

/* Charts */
.chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 120px; padding-top: 8px;
}
.chart-bar-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 0;
}
.chart-bar {
  width: 100%; max-width: 28px;
  background: linear-gradient(to top, var(--accent), var(--accent-hover));
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}
.chart-bar.active { background: linear-gradient(to top, var(--success), #34d399); }
.chart-label { font-size: 0.6rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chart-val { font-size: 0.65rem; color: var(--muted); }

.breakdown { display: grid; gap: 10px; }
.breakdown-row {
  display: flex; align-items: center; gap: 10px;
}
.breakdown-label { font-size: 0.8rem; min-width: 80px; text-transform: capitalize; }
.breakdown-bar-bg {
  flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden;
}
.breakdown-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.breakdown-count { font-size: 0.8rem; color: var(--muted); min-width: 28px; text-align: right; }

.running-list { display: grid; gap: 8px; max-height: 200px; overflow-y: auto; }
.running-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.8rem;
}
.running-item .name { font-weight: 600; }
.running-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* Tables */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tr:hover td { background: rgba(255,255,255,0.02); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 0.75rem; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; text-transform: capitalize;
}
.badge.ok, .badge.running { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.badge.off, .badge.inactive, .badge.disabled { background: rgba(239, 68, 68, 0.12); color: #fca5a5; }
.badge.neutral { background: rgba(148, 163, 184, 0.12); color: var(--muted); }
.badge.chrome { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge.firefox { background: rgba(249, 115, 22, 0.15); color: #fdba74; }
.badge.owner { background: rgba(99, 102, 241, 0.15); color: var(--accent-hover); }
.badge.member { background: rgba(148, 163, 184, 0.12); color: var(--muted); }

.link-btn {
  background: none; border: none; color: var(--accent-hover);
  cursor: pointer; font-size: 0.82rem; font-weight: 600; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* Feed */
.feed { display: grid; gap: 8px; max-height: 400px; overflow-y: auto; }
.feed-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.82rem;
}
.feed-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(99, 102, 241, 0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; flex-shrink: 0;
}
.feed-body { flex: 1; min-width: 0; }
.feed-time { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

/* Drawer */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  display: flex; justify-content: flex-end;
}
.drawer {
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100%;
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 1.1rem; }
.drawer-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-stat { text-align: center; padding: 8px; background: var(--surface-2); border-radius: 8px; }
.drawer-stat-val { font-size: 1.2rem; font-weight: 700; }
.drawer-stat-lbl { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; }

.drawer-tabs {
  display: flex; gap: 4px; padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  padding: 6px 12px; border-radius: 8px;
  background: transparent; border: none;
  color: var(--muted); font-size: 0.8rem; font-weight: 500;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: rgba(99, 102, 241, 0.15); color: var(--accent-hover); }

.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.drawer-actions { padding: 16px 20px; border-top: 1px solid var(--border); }
.drawer-list { display: grid; gap: 8px; }
.drawer-row {
  padding: 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.82rem;
}
.drawer-row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.empty-state { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 0.85rem; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Release / config forms */
.release-form { display: flex; flex-direction: column; gap: 12px; }
.release-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.release-form label span { font-weight: 600; }
.release-form input[type="text"],
.release-form input[type="number"],
.release-form textarea,
.release-form .select-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
}
.release-form .form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.release-form .check-row { flex-direction: row; align-items: center; gap: 8px; }
.release-form button[type="submit"] {
  align-self: flex-start;
  background: var(--accent, #2563eb);
  color: #fff; border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.release-form button[type="submit"]:hover { opacity: 0.92; }
.badge.neutral { background: rgba(148,163,184,0.18); color: #64748b; }
.mini-muted { margin-top: 4px; color: var(--muted); font-size: 0.72rem; line-height: 1.25; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-warn { margin-top: 4px; color: #d97706; font-size: 0.72rem; font-weight: 700; }
.small.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-right: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.modal {
  max-width: 640px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  margin: auto;
  position: relative;
  top: 50%;
  transform: translateY(-50%);
  padding: 20px;
}
.modal .card-head { display: flex; justify-content: space-between; align-items: center; }
