:root {
  --bg: #0d0d14;
  --panel: #151520;
  --panel-high: #1b1b29;
  --line: rgba(233, 233, 237, .12);
  --text: #e9e9ed;
  --dim: rgba(233, 233, 237, .58);
  --accent: #9184d9;
  --accent-soft: rgba(145, 132, 217, .16);
  --ok: #6fd3a8;
  --warn: #f2a93b;
  --danger: #ff6b7a;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
body {
  min-height: 100vh;
  background-image: linear-gradient(rgba(145,132,217,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(145,132,217,.045) 1px, transparent 1px);
  background-size: 28px 28px;
}
[hidden] { display: none !important; }
button, input { font: inherit; }
.dim { color: var(--dim); font-size: 13px; }
.brand { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); }
h1 { font-size: 26px; font-weight: 500; margin: 4px 0 2px; }

.panel {
  position: relative;
  background: linear-gradient(180deg, var(--panel-high), var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 10px; height: 10px; border: 1.5px solid var(--accent); pointer-events: none;
}
.panel::before { top: 4px; left: 4px; border-right: 0; border-bottom: 0; border-top-left-radius: 3px; }
.panel::after { bottom: 4px; right: 4px; border-left: 0; border-top: 0; border-bottom-right-radius: 3px; }
.glow { box-shadow: 0 0 22px rgba(145,132,217,.18), inset 0 0 24px rgba(145,132,217,.06); border-color: rgba(145,132,217,.5); }

button { cursor: pointer; border-radius: 8px; padding: 10px 16px; border: 1px solid var(--accent); background: transparent; color: var(--accent); }
button.primary { background: var(--accent); color: #0d0d14; font-weight: 600; width: 100%; }
button.ghost { border-color: var(--line); color: var(--text); }
button:hover { filter: brightness(1.15); }
input[type=password], input[type=date] {
  width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
input:focus { outline: none; border-color: var(--accent); }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0; font-size: 14px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); display: grid; gap: 12px; padding: 28px; }
.login-card label { font-size: 13px; color: var(--dim); }
.check { display: flex; align-items: center; gap: 8px; }

/* App */
.app { max-width: 1280px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px 40px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.top-actions input { width: auto; margin: 0; }

.live { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); text-transform: lowercase; letter-spacing: .06em; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 1.8s infinite; }
.live.off { color: var(--dim); }
.live.off i { animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(111,211,168,.6); } 70% { box-shadow: 0 0 0 8px rgba(111,211,168,0); } 100% { box-shadow: 0 0 0 0 rgba(111,211,168,0); } }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-size: 34px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kpi.warn b { color: var(--warn); }
.kpi.danger b { color: var(--danger); }
.kpi.glow b { color: #c9c1f3; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--dim); font-size: 13px; }
.chip.on { border-color: var(--accent); color: #c9c1f3; background: var(--accent-soft); }

.grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.side { display: grid; gap: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 68vh; overflow-y: auto; }
.feed li {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.feed li:last-child { border-bottom: 0; }
.feed li.new { animation: arrive 2.4s ease-out; }
@keyframes arrive { 0% { background: rgba(145,132,217,.28); } 100% { background: transparent; } }
.time { font-family: var(--mono); font-size: 14px; }
.who b { font-weight: 500; }
.who .dim { display: block; font-size: 12px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.tag.in { border-color: var(--ok); color: var(--ok); }
.tag.out { border-color: var(--accent); color: var(--accent); }
.tag.review { border-color: var(--warn); color: var(--warn); }
.tag.refused, .tag.outside { border-color: var(--danger); color: var(--danger); }
.empty { color: var(--dim); text-align: center; padding: 24px 0; }

.site { padding: 8px 0; border-bottom: 1px solid var(--line); }
.site:last-child { border-bottom: 0; }
.site-row { display: flex; justify-content: space-between; gap: 8px; }
.bar { height: 5px; border-radius: 3px; background: rgba(233,233,237,.08); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width .6s; }

.present { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow-y: auto; }
.present li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.present li:last-child { border-bottom: 0; }

footer { margin-top: 18px; text-align: center; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:first-child { grid-column: span 2; }
}
@media (max-width: 480px) {
  .feed li { grid-template-columns: 48px 1fr; }
  .tags { grid-column: 2; justify-content: flex-start; }
  h1 { font-size: 22px; }
}
