*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #060b14;
  --surface:  #0d1526;
  --surface2: #111d35;
  --border:   #1a2d50;
  --accent:   #00c9a7;
  --accent2:  #3b82f6;
  --text:     #cdd5e0;
  --muted:    #4a6080;
  --info:     #38bdf8;
  --warning:  #fbbf24;
  --critical: #f87171;
  --success:  #34d399;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 0%, #00c9a710 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, #3b82f608 0%, transparent 50%);
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.header-title {
  display: flex;
  flex-direction: column;
}

.header-title h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.header-title span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--critical);
}

.live-dot.active {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

#ws-status {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid;
}

.badge-connected    { background: #00c9a712; color: var(--success); border-color: #34d39930; }
.badge-disconnected { background: #f8717112; color: var(--critical); border-color: #f8717130; }

#clock {
  font-size: 12px;
  color: #7a96b8;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
}

/* ── MAIN ── */
main { padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; max-width: 1600px; margin: 0 auto; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  border-left: 3px solid;
}


.stat-card.total   { border-left-color: var(--accent); }
.stat-card.info    { border-left-color: var(--info); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.critical{ border-left-color: var(--critical); }

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 38px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-card.total   .stat-value { color: var(--accent); }
.stat-card.info    .stat-value { color: var(--info); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.critical .stat-value{ color: var(--critical); }

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── CHARTS ── */
.charts-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
.charts-grid canvas { max-height: 200px; }

/* ── LOG SOURCE ── */
.input-row { display: flex; gap: 8px; }

.input-row input {
  flex: 1;
  padding: 9px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Courier New', monospace;
  transition: border-color 0.2s;
}

.input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-row input::placeholder { color: var(--muted); }

#log-path-msg { font-family: 'Courier New', monospace; }

/* ── FILTER ── */
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }

select {
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
}

button {
  padding: 7px 16px;
  background: var(--accent);
  color: #060b14;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover { color: var(--text); border-color: var(--text); opacity: 1; }

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; max-height: 420px; overflow-y: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #1a2d5060;
  transition: background 0.1s;
}

tbody tr:hover { background: var(--surface2); }

tbody td {
  padding: 9px 14px;
  font-size: 12px;
  white-space: nowrap;
  font-family: 'Courier New', monospace;
}

td.td-source {
  font-family: 'Segoe UI', sans-serif;
  font-size: 11px;
}

.source-badge {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.source-auth   { background: #3b82f615; color: #60a5fa; border: 1px solid #3b82f630; }
.source-access { background: #00c9a715; color: var(--accent); border: 1px solid #00c9a730; }

.sev-info     { color: var(--info);     font-weight: 700; }
.sev-warning  { color: var(--warning);  font-weight: 700; }
.sev-critical { color: var(--critical); font-weight: 700; }

.rule-badge {
  background: #a855f715;
  color: #c084fc;
  border: 1px solid #a855f730;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  header { padding: 12px 16px; }
  main   { padding: 16px; }
}
