@font-face { font-family: Marhey; src: url(fonts/Marhey.ttf); font-display: swap; }
@font-face { font-family: Readex; src: url(fonts/ReadexPro.ttf); font-display: swap; }

:root {
  --paper: #FBF7EE; --paper2: #F1E9D8; --ink: #1F2433; --ink2: #6B7080;
  --rule: #C9D6F2; --margin: #F29BA0; --note: #FFE36E; --hl: #FFE36E;
  --p0: #2F6BFF; --p1: #E5484D; --p2: #22A861; --p3: #FF8A3D;
  --win: #22A861; --lose: #E5484D; --gem: #19B5D6; --card: #FFFDF7;
  --shadow: 0 6px 18px -8px rgba(31, 36, 51, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1B1F2E; --paper2: #242A3D; --ink: #EDEFF6; --ink2: #9AA1B8;
    --rule: #2D3550; --margin: #8E3B47; --note: #E2BE3C; --hl: #8A2D5A;
    --card: #222839; --shadow: 0 6px 18px -8px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  --paper: #1B1F2E; --paper2: #242A3D; --ink: #EDEFF6; --ink2: #9AA1B8;
  --rule: #2D3550; --margin: #8E3B47; --note: #E2BE3C; --hl: #8A2D5A;
  --card: #222839; --shadow: 0 6px 18px -8px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Readex, system-ui, sans-serif; color: var(--ink);
  background: var(--paper)
    repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  min-height: 100vh;
}
h1, h2, h3, .brand { font-family: Marhey, Readex, sans-serif; margin: 0 0 .4em; }
a { color: var(--p0); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; font-size: 48px; }

/* layout */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--paper2); padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  border-inline-end: 3px solid var(--margin); display: flex; flex-direction: column; gap: 4px;
}
.brand { font-size: 28px; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.nav a {
  display: block; padding: 9px 12px; border-radius: 10px; text-decoration: none;
  color: var(--ink); font-weight: 500;
}
.nav a:hover { background: var(--card); }
.nav a.on { background: var(--hl); }
.side .spacer { flex: 1; }
.main { padding: 22px clamp(14px, 3vw, 34px) 60px; max-width: 1200px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.top h1 { font-size: 30px; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border: 0; border-bottom: 3px solid var(--margin); }
  .side .spacer { display: none; }
  .brand { width: 100%; }
  .nav a { padding: 6px 10px; }
}

/* cards */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.card {
  background: var(--card); border-radius: 6px; padding: 16px; box-shadow: var(--shadow);
  border: 2px solid var(--ink); position: relative;
}
.card.tape::before {
  content: ""; position: absolute; top: -10px; inset-inline-start: 50%; width: 70px; height: 20px;
  transform: translateX(50%) rotate(-3deg); background: rgba(143, 196, 220, .55);
}
.stat .n { font-family: Marhey, sans-serif; font-size: 34px; line-height: 1.1; }
.stat .l { color: var(--ink2); font-size: 14px; }
.stat.live .n::before { content: "● "; color: var(--win); font-size: 18px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.section { margin-top: 26px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--ink2); }
.pill { display: inline-block; padding: 1px 10px; border-radius: 99px; background: var(--paper2); font-size: 13px; }
.pill.ok { background: color-mix(in srgb, var(--win) 25%, transparent); }
.pill.bad { background: color-mix(in srgb, var(--lose) 25%, transparent); }

/* forms */
label { display: block; font-size: 14px; color: var(--ink2); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 2px solid var(--ink);
  background: var(--paper); outline: none;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px var(--hl); }
textarea { min-height: 80px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .two { grid-template-columns: 1fr; } }
.btn {
  border: 2px solid var(--ink); background: var(--card); padding: 9px 18px; border-radius: 10px;
  cursor: pointer; font-weight: 600; box-shadow: 3px 3px 0 var(--ink);
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--note); color: #1F2433; }
.btn.danger { background: var(--lose); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
th, td { padding: 9px 10px; text-align: start; border-bottom: 1px solid var(--rule); font-size: 14px; }
th { background: var(--paper2); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--paper2); }
.scroll { overflow-x: auto; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bars .bar { width: 100%; background: var(--p0); border-radius: 5px 5px 0 0; min-height: 2px; opacity: .85; }
.bars .bar.alt { background: var(--p2); }
.bars .t { font-size: 11px; color: var(--ink2); }
.bars .v { font-size: 12px; }

/* login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(420px, 100%); }
.login .note { background: var(--note); color: #1F2433; padding: 12px 14px; border-radius: 4px; transform: rotate(-1deg); margin: 12px 0; }
.secret { font-family: monospace; font-size: 18px; letter-spacing: 2px; word-break: break-all; background: var(--paper2); padding: 10px; border-radius: 8px; direction: ltr; text-align: center; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: monospace; font-size: 18px; direction: ltr; }
.err { color: var(--lose); min-height: 1.4em; margin-top: 8px; }

/* phone preview */
.phone { background: #111; color: #fff; border-radius: 26px; padding: 14px; width: 280px; }
.phone .notif { background: #2a2d36; border-radius: 16px; padding: 10px 12px; display: flex; gap: 10px; }
.phone .notif img { width: 34px; height: 34px; border-radius: 8px; }
.phone .notif b { display: block; }

.toast {
  position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 10px; z-index: 9;
}
.theme { background: none; border: 0; cursor: pointer; font-size: 20px; }
