/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:         #020816;
  --surface:    #0a1628;
  --surface-2:  #0f1f38;
  --surface-3:  #152842;
  --text:       #e8f4f0;
  --muted:      #7a9bb0;
  --brand:      #4ff0b7;
  --brand-dark: #2bc99a;
  --danger:     #ff5f5f;
  --warn:       #f0c94f;
  --success:    #4ff0b7;
  --border:     #1a2d4a;
  --shadow:     0 8px 24px rgba(0,0,0,0.5);
  --radius:     8px;
  --sidebar-w:  220px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--brand); text-decoration: none; }
button { cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  overflow-y: auto;
}
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 20px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--brand);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand-dot {
  width: 8px; height: 8px;
  background: var(--brand);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--brand);
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}
.nav-btn:hover { background: var(--surface-3); color: var(--text); }
.nav-btn.active { background: rgba(79,240,183,0.1); color: var(--brand); }
.nav-icon { font-size: 12px; width: 14px; text-align: center; }
.nav-divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.logout-btn {
  margin: 16px 10px 0;
  padding: 9px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  transition: border-color 0.15s, color 0.15s;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ── Sections ──────────────────────────────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.section-header h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.section-header h2 { font-size: 16px; font-weight: 600; color: var(--text); }

/* ── Stat Cards ────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-card.loading { color: var(--muted); font-style: italic; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-value.brand { color: var(--brand); }
.stat-value.danger { color: var(--danger); }
.stat-value.warn { color: var(--warn); }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Panels ────────────────────────────────────────────────────────────────── */
.hw-chart { display: block; width: 100%; height: 140px; cursor: default; border-radius: 6px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  overflow-x: auto;
}
.panel-log { padding: 0; }
.panel-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px; }
.row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .row-2col { grid-template-columns: 1fr; } }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(26,45,74,0.5);
  font-size: 13px;
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(79,240,183,0.03); }
.data-table th[data-sort] { user-select: none; }
.data-table th.sort-asc::after { content: ' ↑'; color: var(--brand); }
.data-table th.sort-desc::after { content: ' ↓'; color: var(--brand); }
.mono { font-family: 'Consolas', 'Fira Code', monospace; font-size: 12px; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: rgba(79,240,183,0.15); color: var(--brand); }
.badge-red    { background: rgba(255,95,95,0.15);  color: var(--danger); }
.badge-yellow { background: rgba(240,201,79,0.15); color: var(--warn); }
.badge-gray   { background: rgba(122,155,176,0.15); color: var(--muted); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-sm {
  padding: 6px 14px;
  background: var(--brand);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s;
}
.btn-sm:hover { background: var(--brand-dark); }
.btn-sm.btn-ghost {
  background: none;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-sm.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
}
.btn-sm.btn-secondary:hover { background: var(--surface-2); }
.btn-sm.btn-ghost:hover { border-color: var(--muted); color: var(--text); }
.btn-sm.btn-danger { background: var(--danger); color: #fff; }
.btn-sm.btn-danger:hover { background: #e04444; }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Filters ───────────────────────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-select, .filter-input {
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.filter-select:focus, .filter-input:focus { border-color: var(--brand); }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 14px; align-items: center; }
.pagination .page-info { font-size: 12px; color: var(--muted); margin: 0 6px; }

/* ── Resource bars ─────────────────────────────────────────────────────────── */
.resource-bar-wrap { margin-bottom: 14px; }
.resource-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.resource-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
}
.resource-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--brand);
  transition: width 0.4s ease;
}
.resource-bar-fill.warn  { background: var(--warn); }
.resource-bar-fill.danger { background: var(--danger); }

.tier-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.tier-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tier-card-name { font-weight: 700; font-size: 14px; }
.tier-card-count { font-size: 22px; font-weight: 700; color: var(--brand); }
.tier-card-meta { display: flex; gap: 20px; font-size: 12px; color: var(--muted); }
.tier-can-fit { font-size: 13px; color: var(--brand); font-weight: 600; margin-top: 6px; }

/* ── Service grid ──────────────────────────────────────────────────────────── */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.service-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.service-name { font-weight: 700; font-size: 14px; }
.service-desc { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.service-actions { display: flex; gap: 6px; }

/* ── Log viewer ────────────────────────────────────────────────────────────── */
.log-output {
  width: 100%;
  min-height: 480px;
  max-height: 65vh;
  overflow-y: auto;
  padding: 16px;
  background: #010811;
  color: #c8e0d4;
  font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: var(--radius);
}

/* ── Toggle ────────────────────────────────────────────────────────────────── */
.toggle-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.toggle-label input { accent-color: var(--brand); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 400px;
  max-width: 95vw;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; margin-top: 12px; }
.modal-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  resize: vertical;
}
.modal-input:focus { border-color: var(--brand); }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }

/* ── Warning box ───────────────────────────────────────────────────────────── */
.warning-box {
  background: rgba(240,201,79,0.1);
  border: 1px solid rgba(240,201,79,0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 12px;
  color: var(--warn);
  margin-bottom: 16px;
}
.warning-box.hidden { display: none; }

/* ── Login Page ────────────────────────────────────────────────────────────── */
.admin-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg);
}
.admin-login .content {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 320px;
}
.admin-login input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.admin-login input:focus { border-color: var(--brand); }
.admin-login button {
  width: 100%;
  padding: 0.65rem;
  background: var(--brand);
  border: none;
  border-radius: 6px;
  color: var(--bg);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.admin-login button:hover { background: var(--brand-dark); }
.error-message {
  display: none;
  background: rgba(255,95,95,0.1);
  border: 1px solid rgba(255,95,95,0.3);
  color: var(--danger);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 1rem;
  text-align: center;
}
.error-message.show { display: block; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.empty-state { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; }
