:root {
  --bg: #f4f6f9;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-soft: #e0f2fe;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --err: #991b1b;
  --err-bg: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 256px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand-box {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 2px;
}

.nav-scroll { padding: 12px 10px; flex: 1; overflow-y: auto; }

.nav-search {
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 10px;
  font-size: 0.84rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
}
.nav-search:focus { outline: none; border-color: var(--accent); background: #fff; }

.nav-group {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 16px 10px 6px;
}

.nav-group:first-child { margin-top: 4px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 2px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.15s ease;
}

.nav a:hover {
  background: #f1f5f9;
  color: var(--text);
}

.nav a:hover svg {
  color: var(--text-secondary);
}

.nav a.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.nav a.active svg {
  color: var(--accent-hover);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
}

/* Main Content & Topbar */
.content-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-info { display: flex; align-items: center; gap: 10px; font-size: 0.84rem; color: var(--muted); }

.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 600;
}

.pill-accent {
  border-color: #bae6fd;
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.main { flex: 1; padding: 24px 28px; max-width: 1320px; width: 100%; }

h1 {
  margin: 0 0 18px;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

h2 {
  margin: 0 0 14px;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
}

/* Grid & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.tile-icon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tile-title { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.tile-sub { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.metric-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.metric-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}

.bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.4;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--accent-soft); color: #075985; }

/* Buttons & Forms */
.btn {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--accent-hover); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

.btn-danger { background: #dc2626; color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: #94a3b8;
  color: var(--text);
}

.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 150px; flex: 1; }

label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; }

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 11px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

/* Alerts */
.alert {
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--ok); }
.alert-err { background: #fef2f2; border: 1px solid #fecaca; color: var(--err); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.login-box { width: 100%; max-width: 400px; }

/* Code & Pre */
code, pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #1e293b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code { padding: 2px 6px; font-size: 0.82rem; }

pre {
  padding: 14px;
  overflow-x: auto;
  font-size: 0.82rem;
  color: #1e293b;
  max-height: 420px;
  line-height: 1.55;
  margin: 0;
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .topbar { padding: 0 16px; }
  .main { padding: 18px 16px; }
}

/* Accordion Sidebar & Submenus (WHM / CyberPanel Style) */
.nav-top-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 7px;
  color: #1e293b;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.nav-top-link:hover { background: #f1f5f9; }
.nav-top-link.active { background: #e0f2fe; color: #0369a1; }

.nav-accordion {
  margin-bottom: 4px;
  border-radius: 7px;
}
.nav-accordion > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  user-select: none;
}
.nav-accordion > summary::-webkit-details-marker { display: none; }
.nav-accordion > summary:hover { background: #f1f5f9; color: #0f172a; }
.nav-accordion[open] > summary { color: #0f172a; background: #f8fafc; }
.summary-label { display: flex; align-items: center; gap: 8px; }
.chevron { font-size: 1rem; color: #94a3b8; transition: transform 0.15s ease; }
.nav-accordion[open] .chevron { transform: rotate(90deg); color: #0284c7; }

.submenu {
  display: flex;
  flex-direction: column;
  padding: 4px 0 6px 14px;
  margin-left: 14px;
  border-left: 1px solid #e2e8f0;
  gap: 2px;
}
.submenu a {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.83rem;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
}
.submenu a:hover { background: #f1f5f9; color: #0f172a; }
.submenu a.active { background: #e0f2fe; color: #0369a1; font-weight: 600; }

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  color: #64748b;
}
.breadcrumbs a { color: #0284c7; text-decoration: none; font-weight: 600; }
.breadcrumbs a:hover { text-decoration: underline; }
.crumb-sep { color: #cbd5e1; }
.crumb-item:last-child { color: #0f172a; font-weight: 600; }
