:root {
  --bg: #0f1216;
  --surface: #171c22;
  --surface-2: #1e252d;
  --line: #2b343e;
  --text: #e8edf2;
  --muted: #8d9aa8;
  --accent: #ffb23f;
  --accent-2: #4cc2b0;
  --good: #5ac878;
  --bad: #ef6a5b;
  --blue: #6aa8ff;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; }
body { min-height: 100vh; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; color: var(--muted); font-weight: 600; }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: var(--text); }
button { cursor: pointer; }

#app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
#side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.brand span { color: var(--accent); }
#side label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
#side select { width: 100%; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.on { background: var(--surface-2); color: var(--accent); font-weight: 600; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); }
.side-foot button { margin-top: 6px; }

main { padding: 20px 24px 60px; min-width: 0; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 18px; }
.bar h1 { margin-right: auto; }
.bar .field { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }

select, input, textarea { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
select:focus, input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
button.small { padding: 3px 8px; font-size: 13px; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card h2 { margin-bottom: 10px; }
.card .hint { color: var(--muted); font-size: 13px; margin-top: 8px; overflow-wrap: anywhere; }

.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 13px; }
.kpi.warn .value { color: var(--bad); }
.kpi.ok .value { color: var(--good); }

/* The block "online now" at the top of the overview. */
.online { margin-bottom: 16px; }
.online-body { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; }
.online-num { flex: 0 1 300px; min-width: 0; }
.online-num .big { font-size: 48px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.online-num .word { font-size: 16px; color: var(--muted); }
.online-num .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.spark-box { flex: 1 1 280px; min-width: 0; }
svg.spark { max-height: 120px; }
/* The ladder of the battles. */
.ladder { display: grid; gap: 4px; }
.lrow { display: grid; grid-template-columns: minmax(70px, 170px) minmax(0, 1fr) 76px 66px 66px; gap: 12px; align-items: center; padding: 6px 10px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.lrow.lhead { color: var(--muted); font-size: 13px; padding-top: 0; }
.lrow.hardrow { background: rgba(239, 106, 91, .12); }
.lrow .num { text-align: right; }
.lrow .num.bad { color: var(--bad); font-weight: 700; }
.lname { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.lbar { position: relative; display: flex; align-items: center; gap: 8px; min-height: 26px; min-width: 0; }
.lbar i { position: absolute; inset: 0 auto 0 0; background: #3b82e0; border-radius: 4px; opacity: .9; }
.lbar i.hard { background: var(--bad); }
.lval { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; }
.lval b { font-weight: 600; }
.lbar em { font-style: normal; color: var(--bad); font-size: 12px; font-weight: 600; }
.lbar i.hard ~ .lval em { color: #ffe2de; }
@media (max-width: 700px) {
  .lrow { grid-template-columns: minmax(60px, 90px) minmax(0, 1fr) 56px 56px; gap: 8px; padding: 6px 4px; }
  .lrow .lat { display: none; }
  .lbar em { display: none; }
}

/* The page of problems. */
.strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.grow { flex: 1 1 auto; }
.when { color: var(--muted); font-size: 13px; }
.tabs { display: inline-flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 18px; flex-wrap: wrap; }
.tabbtn { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 8px; }
.tabbtn.on { background: var(--surface-2); color: var(--text, #e8edf2); font-weight: 600; }
.kind { margin-bottom: 22px; }
.kind-h { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.kind-h i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.cards { display: grid; gap: 12px; }
.problem { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.problem.high { border-left-color: var(--bad); }
.problem.medium { border-left-color: var(--accent); }
.problem .tag.sev { font-weight: 600; }
.problem .tag.sev.high { color: var(--bad); border-color: var(--bad); }
.problem .tag.sev.medium { color: var(--accent); border-color: var(--accent); }
.ptitle { color: inherit; font-size: 17px; margin: 8px 0 6px; overflow-wrap: anywhere; }
.pev { color: var(--muted); margin: 0 0 10px; overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; max-width: 640px; }
.fact { padding: 8px 14px; border-right: 1px solid var(--line); min-width: 120px; flex: 1 1 120px; }
.fact:last-child { border-right: 0; }
.fact .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fact .l { color: var(--muted); font-size: 13px; }
.fact .n { color: var(--muted); font-size: 12px; opacity: .8; }
.todo { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; overflow-wrap: anywhere; }
.todo-h { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 3px; }
.actions { gap: 8px; margin-bottom: 4px; }
a.btn { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; color: inherit; text-decoration: none; }
a.btn:hover { border-color: var(--accent); }
details.task { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.task summary { cursor: pointer; color: #6aa8ff; font-size: 13px; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
#nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; font-size: 12px; min-width: 22px; text-align: center; padding: 0 6px; }
.badge.new { background: var(--accent); border-color: var(--accent); color: #1a1205; font-weight: 700; }

/* The block "what to look at": the problems found by the rules of the brief. */
.problems { margin-bottom: 16px; }
.problems-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.problems-more { margin-top: 12px; }
.problems-more summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.pr { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; align-items: start; }
.pr .sev { text-align: center; }
.pr.high .sev { color: var(--bad); border-color: var(--bad); }
.pr.medium .sev { color: var(--accent); border-color: var(--accent); }
.pr .area { color: var(--muted); font-size: 13px; }
.pr .ev { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.pr .chk { font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; align-self: center; }
.live-dot.on { background: var(--good); box-shadow: 0 0 0 0 rgba(90, 200, 120, .6); animation: live-pulse 2s infinite; }
@keyframes live-pulse { 70% { box-shadow: 0 0 0 8px rgba(90, 200, 120, 0); } 100% { box-shadow: 0 0 0 0 rgba(90, 200, 120, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot.on { animation: none; } }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; word-break: break-word; min-width: 180px; }
tr:last-child td { border-bottom: 0; }

/* A bar inside a table cell or a funnel row. */
.meter { position: relative; height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; min-width: 120px; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: var(--accent-2); opacity: .75; }
.meter > b { position: relative; padding: 0 8px; line-height: 22px; font-weight: 600; font-size: 13px; text-shadow: 0 1px 2px #000; }

.funnel { display: grid; gap: 8px; }
.step { display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) 150px; gap: 12px; align-items: center; }
.step .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .bar-bg { height: 30px; background: var(--surface-2); border-radius: 6px; overflow: hidden; position: relative; }
.step .bar-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent), #e8892c); border-radius: 6px; }
.step .bar-text { position: relative; line-height: 30px; padding: 0 10px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.step .drop { font-size: 13px; color: var(--muted); text-align: right; }
.step .drop .bad { color: var(--bad); }

.hist { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 18px; }
.hist .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.hist .col .bar-v { width: 100%; background: var(--accent-2); border-radius: 5px 5px 0 0; min-height: 2px; opacity: .85; }
.hist.leave .col .bar-v { background: var(--bad); }
.hist .col .n { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.hist-x { display: flex; gap: 6px; margin-top: 6px; }
.hist-x span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); min-width: 0; }

svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.empty { color: var(--muted); padding: 24px; text-align: center; }
.error { background: #2a1512; border: 1px solid var(--bad); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
pre.code { background: #0b0e11; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.feed { max-height: 560px; overflow-y: auto; }
.feed .ev { display: grid; grid-template-columns: 74px 130px minmax(0, 1fr); gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed .ev .t { color: var(--muted); }
.feed .ev .props { color: var(--muted); word-break: break-word; }
.feed .ev .n { font-weight: 600; color: var(--accent); }

.editor .line { display: grid; grid-template-columns: 26px minmax(130px, 1.4fr) minmax(90px, 1fr) minmax(100px, 1fr) 70px minmax(100px, 1fr) auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.editor .line .no { color: var(--muted); text-align: center; }

#login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 10; padding: 16px; }
#login form { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(420px, 100%); display: grid; gap: 12px; }
#login input { width: 100%; }
#login .err { color: var(--bad); min-height: 1.4em; font-size: 14px; }

/* The cut of the players (platform, version, device ...) under the title bar. */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -8px 0 16px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters select, .filters input { padding: 5px 8px; font-size: 13px; max-width: 170px; }
.filters input[type=number] { width: 110px; }
.filters details.more { display: inline-block; }
.filters details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 6px; }
.filters details.more .row { margin-top: 6px; }

.bad { color: var(--bad); font-weight: 600; }
small.delta { font-size: 12px; margin-left: 4px; white-space: nowrap; }
small.delta.good { color: var(--good); }
small.delta.bad { color: var(--bad); }
small.delta.flat { color: var(--muted); }
td .wrap, .wrap { white-space: normal; word-break: break-word; display: inline-block; max-width: 460px; }

.note { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.note:last-child { border-bottom: 0; }
.note textarea, textarea.brief { width: 100%; resize: vertical; line-height: 1.4; }
textarea.brief { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; min-height: 360px; }

.heat-wrap { background: #0b0e11; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
canvas.heat { width: 100%; height: auto; display: block; border-radius: 4px; aspect-ratio: 16 / 9; }
.feed .ev.tapline { opacity: .75; }

@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .side-foot { margin: 0; }
  nav { flex-direction: row; flex-wrap: wrap; width: 100%; order: 5; }
  nav a { padding: 6px 10px; }
  main { padding: 14px 12px 50px; }
  .filters select, .filters input { max-width: 46vw; }
  .step { grid-template-columns: 1fr; gap: 4px; }
  .step .drop { text-align: left; }
  .editor .line { grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr); }
  .editor .line .wide { grid-column: 2 / -1; }
}
