:root {
  --bg: #f6f7f9; --fg: #1b1f24; --muted: #6a737d; --card: #fff; --line: #e3e6ea;
  --accent: #2f6fed; --ok: #1f883d; --warn: #b26b00; --bad: #c62828;
  --twitch: #9146ff; --kick: #3fa416;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --fg: #e6e8eb; --muted: #8b949e; --card: #171b21; --line: #2a3038; --accent: #6b9bff; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 28px 0 10px; }
.muted { color: var(--muted); font-weight: normal; }
.nowrap { white-space: nowrap; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--fg); }
.top nav { display: flex; gap: 16px; flex: 1; }
.top nav a { color: var(--muted); padding: 4px 0; }
.top nav a.on { color: var(--fg); border-bottom: 2px solid var(--accent); }
.logout { display: flex; gap: 8px; align-items: center; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: .85rem; }
.tile .value { font-size: 2.2rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.small { font-size: .82rem; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td.av { width: 40px; padding-right: 0; }
td.av img { width: 32px; height: 32px; border-radius: 50%; display: block; }
td.title { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pf, .st { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; font-weight: 600; vertical-align: middle; }
.pf.twitch { background: color-mix(in srgb, var(--twitch) 15%, transparent); color: var(--twitch); }
.pf.kick { background: color-mix(in srgb, var(--kick) 15%, transparent); color: var(--kick); }
.st { background: var(--line); color: var(--muted); }
.st.active { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.st.paused, .st.dormant { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.st.removed { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
button, .button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; cursor: pointer; display: inline-block; }
button.link { background: none; color: var(--accent); padding: 0; }
button.danger { background: var(--bad); }
.form { display: grid; gap: 12px; align-content: start; }
.form h2 { margin: 0; }
.form label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; margin-bottom: 12px; }
.head { display: flex; justify-content: space-between; align-items: center; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.pager { display: flex; gap: 16px; justify-content: center; margin-top: 12px; }
.danger { margin-top: 12px; display: flex; gap: 12px; align-items: center; }

.login { max-width: 360px; margin: 12vh auto 0; display: grid; gap: 14px; }
.login h1 { margin: 0; }
.login label { display: grid; gap: 4px; color: var(--muted); font-size: .9rem; }
.alert { background: color-mix(in srgb, var(--bad) 12%, var(--card)); border: 1px solid var(--bad); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.ok { background: color-mix(in srgb, var(--ok) 12%, var(--card)); border: 1px solid var(--ok); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }

.profile { display: flex; gap: 16px; align-items: flex-start; }
.profile .avatar { width: 72px; height: 72px; border-radius: 50%; }
.profile h1 { margin-bottom: 4px; }
.profile p { margin: 4px 0; }
.desc { max-width: 800px; }

.session { display: grid; gap: 14px; }
.session-title { font-size: 1.05rem; font-weight: 600; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.metrics > div { display: grid; border-left: 3px solid var(--line); padding-left: 10px; }
.metrics .label { color: var(--muted); font-size: .8rem; }
.metrics .value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.session-body { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(220px, 1fr); gap: 20px; align-items: start; }
.pie { display: grid; gap: 10px; justify-items: center; }
.donut { width: 100%; max-width: 190px; height: auto; }
.legend { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; font-size: .9rem; }
.legend li { display: grid; grid-template-columns: 12px 1fr; column-gap: 8px; align-items: center; }
.legend .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .muted { grid-column: 2; font-size: .8rem; }
.swatch { width: 12px; height: 12px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; }

@media (max-width: 800px) {
  .cols, .filters, .session-body { grid-template-columns: 1fr; }
  td.title { max-width: 160px; }
}
