/* qr.sleik.is — shares the sleik.is dark/purple palette */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:      #0e0e1a;
    --panel:   rgba(255,255,255,0.04);
    --border:  rgba(255,255,255,0.09);
    --text:    #e8e8f8;
    --muted:   #9a9ab8;
    --accent:  #634ae4;
    --accent2: #3b82f6;
    --good:    #22c55e;
    --warn:    #f59e0b;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 0 1rem 4rem;
}
body::before {
    content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99,74,228,0.13) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 70%, rgba(59,130,246,0.08) 0%, transparent 55%);
}
.wrap { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; }

/* ── header ─────────────────────────────────────────────────────────────── */
header.top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 1.5rem 0 2rem; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.brand img { height: 52px; width: auto; border-radius: 8px; display: block; }
.who { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .9rem; }
.who img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

/* ── generic bits ───────────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; letter-spacing: -0.02em; margin-bottom: .35rem; }
h2 { font-size: 1.05rem; margin-bottom: .9rem; font-weight: 600; }
.sub { color: var(--muted); font-size: .92rem; }
a { color: var(--accent2); }

.card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 14px; padding: 1.25rem;
}
.grid { display: grid; gap: 1rem; }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    background: var(--accent); color: #fff; border: none; cursor: pointer;
    padding: .6rem 1rem; border-radius: 9px; font-size: .92rem; font-weight: 600;
    text-decoration: none; font-family: inherit;
}
.btn:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: #dc2626; color: #fff; }
.btn.sm { padding: .38rem .7rem; font-size: .82rem; }

input, select, textarea {
    width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
    color: var(--text); border-radius: 9px; padding: .6rem .75rem;
    font-family: inherit; font-size: .95rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .35rem; }
.field { margin-bottom: .9rem; }

/* ── stat tiles ─────────────────────────────────────────────────────────── */
.stat {
    position: relative; background: var(--panel); border: 1px solid var(--border);
    border-radius: 14px; padding: 1.1rem 1.25rem;
    transition: border-color .15s, transform .15s;
}
.stat:hover { border-color: rgba(99,74,228,0.4); transform: translateY(-2px); }
.stat .n { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .82rem; margin-top: .3rem; display: flex; align-items: center; gap: .4rem; }
.stat .l .ic { font-size: .95rem; opacity: .85; }
/* The headline metric gets a faint accent wash so the eye lands on it first. */
.stat.primary { background: linear-gradient(180deg, rgba(99,74,228,0.15), rgba(99,74,228,0.03)); border-color: rgba(99,74,228,0.35); }
.stat.primary .n { color: #b7a8ff; }

/* ── code list ──────────────────────────────────────────────────────────── */
.codes { display: grid; gap: .75rem; }
.code-row {
    display: grid; grid-template-columns: 64px 1fr auto; gap: 1rem; align-items: center;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 14px; padding: .9rem 1.1rem; text-decoration: none; color: inherit;
    transition: border-color .15s, transform .15s, background .15s;
}
.code-row:hover { border-color: rgba(99,74,228,0.6); transform: translateY(-2px); background: rgba(99,74,228,0.05); }
.code-row img { width: 64px; height: 64px; border-radius: 8px; background: #fff; padding: 3px; }
.code-row .nm { display: flex; align-items: center; gap: .45rem; font-weight: 600; margin-bottom: .2rem; }
.code-row .tic {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem; flex-shrink: 0; border-radius: 7px;
    background: rgba(99,74,228,0.16); font-size: .9rem;
}
.code-row .dest {
    color: var(--muted); font-size: .84rem; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; max-width: 46ch;
}
.code-row .last { color: var(--muted); font-size: .76rem; margin-top: .2rem; opacity: .8; }
.code-row .cnt { text-align: right; }
.code-row .cnt b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.code-row .cnt span { display: block; color: var(--muted); font-size: .75rem; }

.pill { font-size: .7rem; padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.pill.on  { color: var(--good); border-color: rgba(34,197,94,0.4); }
.pill.off { color: var(--warn); border-color: rgba(245,158,11,0.4); }

/* ── charts ─────────────────────────────────────────────────────────────── */
/* Single series → single hue, no legend. Bars are anchored to the baseline with
   a 4px rounded data-end and a 2px surface gap between them. */
.chart { position: relative; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 170px; position: relative; z-index: 1; }
.bars .col { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bars .bar {
    width: 100%; background: var(--accent);
    border-radius: 4px 4px 0 0; min-height: 2px;
    transition: background .12s;
}
.bars .col:hover .bar { background: #7c62ff; }
.bars .col.zero .bar { background: rgba(255,255,255,0.10); }

/* Recessive gridlines behind the marks. */
.gridlines { position: absolute; inset: 0 0 auto; height: 170px; z-index: 0; }
.gridlines div { position: absolute; left: 0; right: 0; border-top: 1px solid rgba(255,255,255,0.055); }
.gridlines span { position: absolute; right: 0; top: -0.65em; font-size: .68rem; color: var(--muted); background: var(--bg); padding-left: .3rem; }

.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .72rem; margin-top: .5rem; }

.tip {
    position: absolute; z-index: 5; pointer-events: none; opacity: 0;
    background: #16162a; border: 1px solid var(--border); border-radius: 8px;
    padding: .45rem .6rem; font-size: .78rem; white-space: nowrap;
    transform: translate(-50%, -100%); transition: opacity .1s;
}
.tip.show { opacity: 1; }
.tip b { font-variant-numeric: tabular-nums; }

.rank { display: grid; gap: .55rem; }
.rank .row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; font-size: .88rem; align-items: center; }
.rank .track { grid-column: 1 / -1; height: 5px; background: rgba(255,255,255,0.07); border-radius: 3px; overflow: hidden; }
.rank .fill { height: 100%; background: var(--accent); border-radius: 3px; }
.rank .v { color: var(--muted); font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: .45rem .6rem; border-bottom: 1px solid var(--border); font-size: .78rem; }
td { padding: .5rem .6rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
tr.bot td { color: var(--muted); font-style: italic; }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* ── type picker (create modal) ─────────────────────────────────────────── */
.types { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: .5rem; }
.type-btn {
    display: flex; flex-direction: column; align-items: center; gap: .3rem;
    background: rgba(0,0,0,0.3); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; padding: .7rem .5rem; cursor: pointer;
    font-family: inherit; font-size: .82rem;
}
.type-btn:hover { border-color: rgba(99,74,228,0.6); }
.type-btn.sel   { border-color: var(--accent); background: rgba(99,74,228,0.16); }
.type-btn .ic   { font-size: 1.3rem; line-height: 1; }

/* ── toggle switch ──────────────────────────────────────────────────────── */
.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: relative; width: 40px; height: 22px; flex-shrink: 0; border-radius: 999px;
    background: rgba(255,255,255,0.15); border: 1px solid var(--border); transition: background .15s;
}
.switch .slider::before {
    content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch input:checked + .slider { background: var(--good); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-size: .85rem; color: var(--muted); }

/* ── fold-down download menu (details/summary) ──────────────────────────── */
.dl { display: inline-block; }
.dl summary { list-style: none; }
.dl summary::-webkit-details-marker { display: none; }
.dl summary::after { content: '▾'; margin-left: .35rem; opacity: .7; }
.dl[open] summary::after { content: '▴'; }
.dl-menu { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }

/* ── modal ──────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal.show { display: flex; }
.modal .box { background: #16162a; border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; width: 100%; max-width: 440px; }

@media (max-width: 620px) {
    .code-row { grid-template-columns: 48px 1fr; }
    .code-row img { width: 48px; height: 48px; }
    .code-row .cnt { grid-column: 2; text-align: left; }
    .code-row .dest { max-width: 100%; }
}
