@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0a0c10;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --accent: #6366f1;
  --accent-glow: rgba(99,102,241,0.3);
  --critical: #ef4444;
  --critical-bg: rgba(239,68,68,0.12);
  --error: #f97316;
  --error-bg: rgba(249,115,22,0.12);
  --warning: #eab308;
  --warning-bg: rgba(234,179,8,0.12);
  --info: #3b82f6;
  --info-bg: rgba(59,130,246,0.12);
  --success: #22c55e;
  --success-bg: rgba(34,197,94,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Scrollbar ─────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Layout ────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: rgba(255,255,255,0.02);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 0;
  position: sticky; top: 0; height: 100vh;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg,#6366f1,#8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.logo-text { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.logo-sub { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; margin: 2px 8px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .2s;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: rgba(99,102,241,0.15); color: var(--accent); }
.nav-item .icon { font-size: 16px; width: 18px; text-align: center; }

.sidebar-footer { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid var(--border); }
.conn-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
.conn-dot.offline { background: var(--critical); animation: none; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.main { flex: 1; overflow-x: hidden; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10,12,16,0.85); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex; align-items: center; gap: 12px;
}
.topbar h1 { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-meta { font-size: 12px; color: var(--text-muted); }

.content { padding: 24px 28px; }

/* ── Summary Cards ─────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color .2s, transform .2s;
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.stat-card .label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: 6px; }
.stat-card .sub { font-size: 12px; color: var(--text-secondary); }
.stat-card .trend { font-size: 11px; font-weight: 500; margin-top: 4px; }
.stat-card.critical-card { border-color: rgba(239,68,68,0.25); }
.stat-card.critical-card .value { color: var(--critical); }

/* ── Filters ───────────────────────── */
.filters-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.filter-group input,
.filter-group select {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 7px 12px;
  min-width: 140px;
  outline: none;
  transition: border-color .2s;
}
.filter-group input:focus,
.filter-group select:focus { border-color: var(--accent); }
.filter-group select option { background: #1e2030; }
.filter-group input[type="date"] { min-width: 120px; color-scheme: dark; }

.filter-actions { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; padding-top: 16px; }

/* ── Search bar ────────────────────── */
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap input { width: 100%; padding-left: 36px; }
.search-wrap .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; pointer-events: none; }

/* ── Buttons ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; outline: none;
  transition: all .2s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4f52c9; box-shadow: 0 0 20px var(--accent-glow); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-card); }
.btn-danger { background: transparent; color: var(--critical); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--critical-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Table ─────────────────────────── */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-header h2 { font-size: 14px; font-weight: 600; }
.table-toolbar { display: flex; align-items: center; gap: 10px; }
.log-count { font-size: 12px; color: var(--text-muted); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer; user-select: none;
}
.data-table thead th:hover { color: var(--text-primary); }
.data-table thead th .sort-icon { margin-left: 4px; opacity: .4; }
.data-table thead th.sorted .sort-icon { opacity: 1; color: var(--accent); }

.data-table tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background .15s;
}
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr.selected { background: rgba(99,102,241,0.08); border-left: 3px solid var(--accent); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 13px 16px; font-size: 13px; vertical-align: middle; }

/* ── Severity Badges ───────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.badge-critical { background: var(--critical-bg); color: var(--critical); }
.badge-error    { background: var(--error-bg);    color: var(--error); }
.badge-warning  { background: var(--warning-bg);  color: var(--warning); }
.badge-info     { background: var(--info-bg);     color: var(--info); }

.badge::before { content: '●'; font-size: 7px; }

/* ── Detail Panel ──────────────────── */
.detail-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: flex-end;
}
.detail-overlay.open { display: flex; }

.detail-panel {
  width: 520px; height: 100vh;
  background: #12151c;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-header h3 { font-size: 15px; font-weight: 600; }
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; transition: color .2s; }
.close-btn:hover { color: var(--text-primary); }

.detail-body { flex: 1; overflow-y: auto; padding: 24px; }

.detail-section { margin-bottom: 24px; }
.detail-section h4 { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.detail-row { display: flex; gap: 12px; margin-bottom: 10px; }
.detail-label { font-size: 12px; color: var(--text-muted); width: 110px; flex-shrink: 0; padding-top: 1px; }
.detail-value { font-size: 13px; color: var(--text-primary); word-break: break-all; }

.code-block {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #a5f3fc;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.7;
}

.detail-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}

/* ── Confirm Modal ─────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #171a24;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 420px;
  animation: popIn .2s ease;
}
@keyframes popIn { from { transform: scale(.9); opacity:0; } to { transform: scale(1); opacity:1; } }
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.modal p { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal .warn-icon { font-size: 32px; margin-bottom: 16px; }

/* ── Audit Trail ───────────────────── */
.audit-badge { font-size: 11px; background: rgba(234,179,8,0.1); color: var(--warning); border: 1px solid rgba(234,179,8,0.2); border-radius: 20px; padding: 2px 8px; }

/* ── Pagination ────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid var(--border); }
.pagination-info { font-size: 12px; color: var(--text-muted); }
.page-controls { display: flex; align-items: center; gap: 8px; }
.page-btn { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ── Toast ─────────────────────────── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e2130; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  font-size: 13px; color: var(--text-primary);
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .3s ease; min-width: 260px;
  box-shadow: var(--shadow);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--critical); }
@keyframes toastIn { from { transform: translateX(120%); opacity:0; } to { transform: none; opacity:1; } }
@keyframes toastOut { to { transform: translateX(120%); opacity:0; } }
.toast.hide { animation: toastOut .3s ease forwards; }

/* ── Empty / Loading ───────────────── */
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: .3; }
.empty-state p { color: var(--text-muted); font-size: 14px; }

.loading-row td { text-align: center; padding: 48px; color: var(--text-muted); }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.1); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Config banner ─────────────────── */
.config-banner {
  background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--radius); padding: 16px 20px;
  margin-bottom: 20px; display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-secondary);
}
.config-banner.hidden { display: none; }

/* ── Responsive ────────────────────── */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-actions { margin-left: 0; }
  .detail-panel { width: 100%; }
}
@media (max-width: 500px) {
  .stat-grid { grid-template-columns: 1fr; }
  .data-table thead th:nth-child(n+4) { display: none; }
  .data-table td:nth-child(n+4) { display: none; }
}
