:root {
  --black: #0A0A0A;
  --card: #1A1A1A;
  --card2: #2A2A2A;
  --footer: #111111;
  --line: #333333;
  --red: #EF4444;
  --red-dark: #c93333;
  --white: #FFFFFF;
  --muted: #888888;
  --light: #F5F5F5;
  --r-top: #22c55e;
  --r-good: #84cc16;
  --r-mid: #f59e0b;
  --r-low: #ef4444;
  --r-none: #444444;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--black);
  color: var(--white);
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--white); text-decoration: none; }
a:hover { color: var(--red); }
.muted { color: var(--muted); }
sup { font-size: .55em; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; border-bottom: 1px solid var(--red);
  background: var(--black); position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-badge {
  background: var(--red); color: #fff; font-weight: 800; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; padding: 6px 10px; border-radius: 3px;
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.nav { display: flex; gap: 22px; font-weight: 500; font-size: 14px; }

.container { max-width: 1180px; width: 100%; margin: 0 auto; padding: 32px; flex: 1; }
.footer {
  border-top: 1px solid var(--red); background: var(--footer);
  padding: 14px 32px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted);
}

/* Typo */
h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; line-height: 1.15; }
h1 .accent, h2 .accent { color: var(--red); }
h2 { font-size: 20px; font-weight: 800; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.badge {
  display: inline-block; background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: .15em; text-transform: uppercase; padding: 4px 9px; border-radius: 3px; margin-bottom: 12px;
}
.rule { height: 1px; background: var(--red); border: 0; margin: 18px 0 24px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.crumbs .sep { margin: 0 8px; }

/* Layout helpers */
.row { display: flex; gap: 20px; flex-wrap: wrap; }
.row > * { flex: 1 1 280px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } .container { padding: 20px 16px; } .topbar, .footer { padding: 12px 16px; } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Cards */
.card { background: var(--card); border-radius: 10px; padding: 22px; border: 1px solid #222; }
.card.tight { padding: 16px 18px; }
.card-title { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.stat { font-size: 36px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.stat.accent { color: var(--red); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Forms */
label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; background: var(--black); color: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: 11px 13px; font: inherit; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); }
select option { background: #111; }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; background: var(--red); color: #fff; border: 0; border-radius: 6px;
  padding: 11px 18px; font: inherit; font-weight: 700; cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn:hover { background: var(--red-dark); color: #fff; }
.btn.secondary { background: var(--card2); }
.btn.secondary:hover { background: #3a3a3a; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--red); background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.danger { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.danger:hover { border-color: var(--red); color: var(--red); background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid #222; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.clickable:hover td { background: #202020; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.pill-done { background: #14532d; color: #86efac; }
.pill-running, .pill-pending { background: #3b2a06; color: #fcd34d; }
.pill-error { background: #4c1515; color: #fca5a5; }
.pill-active { background: #1f2937; color: #cbd5e1; }
.pill-off { background: #222; color: #777; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; font-size: 14px; border: 1px solid; }
.flash-ok { border-color: #166534; background: #052e16; color: #bbf7d0; }
.flash-error { border-color: #7f1d1d; background: #2a0a0a; color: #fecaca; }
.flash-info { border-color: var(--line); background: var(--card); color: #ddd; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 420px; }
.login-box .card { padding: 36px; }
.login-ghost { position: fixed; right: -20px; bottom: -40px; font-size: 260px; font-weight: 800; color: #141414; line-height: 1; pointer-events: none; user-select: none; letter-spacing: -.05em; }

/* Place search */
.results { margin-top: 10px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; display: none; }
.results.show { display: block; }
.result { padding: 10px 14px; border-bottom: 1px solid #222; cursor: pointer; }
.result:last-child { border-bottom: 0; }
.result:hover, .result.selected { background: #202020; }
.result .name { font-weight: 600; }
.result .addr { font-size: 12px; color: var(--muted); }
.selected-place { background: var(--black); border: 1px solid var(--red); border-radius: 6px; padding: 12px 14px; }

/* Progress */
.progress { height: 8px; background: #222; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--red); width: 0; transition: width .3s; }

/* Grid visualisation (abstract) */
.rankgrid { display: grid; gap: 6px; }
.rankgrid .cell {
  aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff; position: relative;
}
.cell.top { background: var(--r-top); color: #052e16; }
.cell.good { background: var(--r-good); color: #1a2e05; }
.cell.mid { background: var(--r-mid); color: #2a1500; }
.cell.low { background: var(--r-low); }
.cell.none { background: var(--r-none); color: #bbb; }
.cell.center::after { content: ''; position: absolute; inset: -4px; border: 2px solid #fff; border-radius: 50%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* Map */
#map { height: 520px; border-radius: 10px; border: 1px solid #222; background: #111; }
.map-marker {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 2px 8px rgba(0,0,0,.5);
  font-family: Inter, Arial, sans-serif;
}
.map-marker.top { background: var(--r-top); color: #052e16; }
.map-marker.good { background: var(--r-good); color: #1a2e05; }
.map-marker.mid { background: var(--r-mid); color: #2a1500; }
.map-marker.low { background: var(--r-low); }
.map-marker.none { background: var(--r-none); color: #ccc; }
.map-marker.center { border-color: var(--red); border-width: 3px; }
.leaflet-container { font-family: Inter, Arial, sans-serif; background: #111; }
.leaflet-layer.dark-tiles, .dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(.8) contrast(.9) saturate(.4); }
.leaflet-control-attribution { background: rgba(0,0,0,.6) !important; color: #888 !important; font-size: 10px; }
.leaflet-control-attribution a { color: #aaa !important; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty strong { color: #fff; display: block; font-size: 18px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
