:root {
  --bg: #0e1420;
  --bg-2: #151d2e;
  --panel: #1a2436;
  --panel-2: #202c42;
  --border: #2a3852;
  --text: #e6edf7;
  --muted: #8b9bb5;
  --accent: #2f6df6;
  --accent-2: #4b86ff;
  --green: #2ecc71;
  --amber: #f5a623;
  --red: #ff5964;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { display:grid; place-items:center; height:100vh; color: var(--muted); }

/* Layout */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.brand { display:flex; align-items:center; gap:10px; padding: 8px 10px 16px; font-weight: 700; font-size: 16px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg,var(--accent),#7aa2ff); display:grid; place-items:center; color:#fff; font-weight:800; }
.brand small { display:block; color: var(--muted); font-weight: 500; font-size: 11px; }
.nav a { display:flex; align-items:center; gap:10px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .ico { width: 18px; text-align:center; opacity:.9; }
.nav .sep { height:1px; background: var(--border); margin: 10px 6px; }
.sidebar .spacer { flex: 1; }
.userchip { padding: 10px 12px; border-radius: 9px; background: var(--panel); font-size: 13px; }
.userchip b { display:block; }
.userchip .role { color: var(--muted); font-size: 11px; text-transform: capitalize; }

.main { display:flex; flex-direction: column; min-width: 0; }
.topbar { display:flex; align-items:center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--bg-2); position: sticky; top:0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .grow { flex: 1; }
.content { padding: 24px; max-width: 1400px; width: 100%; }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.cards { display:grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .n { font-size: 30px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat .n.green { color: var(--green); } .stat .n.amber { color: var(--amber); } .stat .n.red { color: var(--red); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
tbody tr:hover { background: var(--panel-2); }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }

/* Badges */
.badge { display:inline-flex; align-items:center; gap:6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge .dot { width:8px; height:8px; border-radius:50%; }
.badge.online { background: rgba(46,204,113,.15); color: var(--green); }
.badge.online .dot { background: var(--green); }
.badge.offline { background: rgba(255,89,100,.14); color: var(--red); }
.badge.offline .dot { background: var(--red); }
.badge.pending { background: rgba(245,166,35,.15); color: var(--amber); }
.badge.pending .dot { background: var(--amber); }
.badge.disabled { background: rgba(139,155,181,.15); color: var(--muted); }
.badge.disabled .dot { background: var(--muted); }
.badge.info { background: rgba(75,134,255,.15); color: var(--accent-2); }
.badge.warning { background: rgba(245,166,35,.15); color: var(--amber); }
.badge.critical { background: rgba(255,89,100,.16); color: var(--red); }

/* Buttons & inputs */
.btn { display:inline-flex; align-items:center; gap:8px; padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: rgba(255,89,100,.14); border-color: rgba(255,89,100,.4); color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 9px 12px; font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display:block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field { margin-bottom: 14px; }
.row { display:flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.filters { display:flex; gap:10px; flex-wrap: wrap; align-items:center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 160px; }

/* Login */
.login { display:grid; place-items:center; min-height: 100vh; padding: 24px; }
.login .box { width: 380px; max-width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.login h2 { margin: 0 0 4px; }
.login p.sub { color: var(--muted); margin: 0 0 24px; }
.err { background: rgba(255,89,100,.12); border: 1px solid rgba(255,89,100,.3); color: var(--red); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }
.ok { background: rgba(46,204,113,.12); border: 1px solid rgba(46,204,113,.3); color: var(--green); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }

/* Screenshot grid */
.shots { display:grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 14px; }
.shot { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; }
.shot .thumb { aspect-ratio: 16/10; background: var(--bg-2); display:grid; place-items:center; color: var(--muted); font-size: 12px; overflow:hidden; }
.shot .thumb img { width: 100%; height: 100%; object-fit: cover; }
.shot .meta { padding: 8px 10px; font-size: 12px; }
.shot .meta .app { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shot .meta .t { color: var(--muted); }

/* Modal / lightbox */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.7); display:grid; place-items:center; z-index: 50; padding: 24px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; max-width: 640px; width: 100%; max-height: 90vh; overflow:auto; box-shadow: var(--shadow); }
.modal .head { display:flex; align-items:center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal .head h3 { margin: 0; }
.modal .body { padding: 20px; }
.modal .foot { padding: 16px 20px; border-top: 1px solid var(--border); display:flex; gap: 10px; justify-content:flex-end; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 8px; }
.lightbox .cap { color:#cfd8e6; text-align:center; margin-top: 10px; font-size: 13px; }

/* Timeline */
.timeline { position: relative; }
.tl-item { display:grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.tl-item .time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.tl-item .app { font-weight: 600; }
.tl-item .sub { color: var(--muted); font-size: 12px; }

/* Bars (reports) */
.bar-row { display:grid; grid-template-columns: 180px 1fr 70px; gap: 10px; align-items:center; margin-bottom: 8px; font-size: 13px; }
.bar-track { background: var(--bg-2); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg,var(--accent),#7aa2ff); }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.tag { font-family: ui-monospace, monospace; font-size: 12px; background: var(--bg-2); padding: 2px 6px; border-radius: 5px; }
.empty { padding: 40px; text-align:center; color: var(--muted); }
.pills { display:flex; gap:8px; flex-wrap:wrap; }
.pill { padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border:1px solid var(--border); font-size:12px; cursor:pointer; }
.pill.active { background: var(--accent); border-color: var(--accent); color:#fff; }
.section-title { font-size: 15px; font-weight: 700; margin: 24px 0 12px; }
.kv { display:grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 13px; }
.kv .k { color: var(--muted); }
/* Policy cards: tidy key/value rows so values don't wrap awkwardly */
.cards .kv { grid-template-columns: 1fr auto; gap: 7px 14px; align-items: baseline; }
.cards .kv > div:nth-child(even) { text-align: right; font-weight: 600; white-space: nowrap; }
.cards .card h3 { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }
.checkline { display:flex; align-items:center; gap: 8px; margin-bottom: 8px; }
.checkline input { width:auto; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x:auto; }
  .sidebar .spacer, .userchip { display:none; }
}
