* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --text: #e2e8f0;
  --muted: #64748b;
  --radius: 12px;
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

/* Sidebar */
.sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--border); padding: 24px 0; display: flex; flex-direction: column; flex-shrink: 0; }
.logo { padding: 0 24px 28px; display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 36px; height: 36px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.logo-text { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.logo-badge { font-size: 10px; background: var(--accent); color: #fff; padding: 2px 6px; border-radius: 4px; margin-left: 4px; font-weight: 600; }
nav a { display: flex; align-items: center; gap: 10px; padding: 10px 24px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; border-left: 3px solid transparent; transition: all 0.15s; }
nav a:hover { color: var(--text); background: var(--surface2); }
nav a.active { color: var(--accent2); border-left-color: var(--accent); background: rgba(108,99,255,0.08); }
nav .section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 16px 24px 6px; display: block; }
.sidebar-footer { margin-top: auto; padding: 16px 24px; border-top: 1px solid var(--border); }
.admin-chip { display: flex; align-items: center; gap: 10px; }
.admin-avatar { width: 32px; height: 32px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.admin-name { font-size: 13px; font-weight: 600; }
.admin-role { font-size: 11px; color: var(--muted); }
.logout-link { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); text-decoration: none; }
.logout-link:hover { color: var(--red); }

/* Main */
.main { flex: 1; overflow-y: auto; padding: 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.btn { padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: opacity 0.15s; text-decoration: none; display: inline-flex; align-items: center; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn:hover { opacity: 0.85; }
.search-box { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; color: var(--text); font-size: 13px; width: 220px; outline: none; }
.search-box::placeholder { color: var(--muted); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 30px; font-weight: 800; margin: 6px 0 4px; letter-spacing: -1px; }
.stat-change { font-size: 12px; font-weight: 600; }
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }
.stat-icon { float: right; font-size: 28px; opacity: 0.5; margin-top: -4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Table */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 28px; }
.table-head-row { display: flex; padding: 12px 22px; background: var(--surface2); border-bottom: 1px solid var(--border); }
.table-head-row span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.table-row { display: flex; padding: 14px 22px; border-bottom: 1px solid var(--border); align-items: center; transition: background 0.1s; }
.table-row:last-child { border-bottom: none; }
.table-row:hover { background: var(--surface2); }
.col-site { flex: 2.2; }
.col-plan { flex: 1; }
.col-status { flex: 1; }
.col-queries { flex: 1; }
.col-expiry { flex: 1.2; }
.col-heartbeat { flex: 1.2; }
.col-action { flex: 1.2; text-align: right; }
.site-name { font-size: 13px; font-weight: 600; }
.site-key { font-size: 11px; color: var(--muted); font-family: monospace; margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-active { background: rgba(34,197,94,0.12); color: var(--green); }
.badge-active::before { background: var(--green); }
.badge-suspended { background: rgba(239,68,68,0.12); color: var(--red); }
.badge-suspended::before { background: var(--red); }
.badge-trial { background: rgba(245,158,11,0.12); color: var(--yellow); }
.badge-trial::before { background: var(--yellow); }
.badge-expired { background: rgba(100,116,139,0.15); color: var(--muted); }
.badge-expired::before { background: var(--muted); }
.plan-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: rgba(108,99,255,0.15); color: var(--accent2); }
.plan-chip.starter { background: rgba(59,130,246,0.12); color: var(--blue); }
.plan-chip.pro { background: rgba(108,99,255,0.15); color: var(--accent2); }
.plan-chip.enterprise { background: rgba(34,197,94,0.12); color: var(--green); }
.action-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; font-size: 11px; font-weight: 600; cursor: pointer; color: var(--text); transition: all 0.15s; text-decoration: none; display: inline-block; }
.action-btn:hover { border-color: var(--accent); color: var(--accent2); }
.action-btn.danger:hover { border-color: var(--red); color: var(--red); }
.action-btn.success { border-color: var(--green); color: var(--green); }
.action-btn.info { border-color: var(--blue); color: var(--blue); }
.query-bar { height: 4px; background: var(--surface2); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.query-fill { height: 100%; border-radius: 2px; background: var(--accent); }
.font-mono { font-family: monospace; font-size: 12px; }
.text-muted { color: var(--muted); }
.heartbeat-ok { color: var(--green); font-size: 12px; }
.heartbeat-warn { color: var(--yellow); font-size: 12px; }
.heartbeat-dead { color: var(--red); font-size: 12px; }

.bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.activity-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Forms / modal */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; color: var(--text); font-size: 13px; outline: none; font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 18px; }
.alert-error { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: rgba(34,197,94,0.12); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.highlight-key { background: var(--surface2); border-radius: 8px; padding: 10px 14px; font-family: monospace; font-size: 14px; letter-spacing: 1px; }

/* Login page */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 36px; width: 380px; }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; text-align: center; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .bottom-row { grid-template-columns: 1fr; }
}
