:root {
  --bg: #0e1014;
  --panel: #161a21;
  --panel-2: #1c212a;
  --line: #2a303b;
  --text: #e8eaee;
  --muted: #8d95a3;
  --accent: #d63a40;
  --accent-2: #f05a60;
  --ok: #3fb67a;
  --warn: #e0b341;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-2: #f6f7fa;
  --line: #dfe2e8;
  --text: #1b1f27;
  --muted: #667085;
  --accent: #c82b32;
  --accent-2: #a9222a;
  --shadow: 0 6px 18px rgba(20, 25, 35, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; text-decoration: none; }

.shell { display: flex; min-height: 100vh; }
.side {
  width: 250px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .5px;
}
.brand b { font-size: 13px; letter-spacing: .6px; line-height: 1.2; }
.nav a, .nav summary {
  display: block; padding: 10px 12px; border-radius: 8px; color: var(--muted); cursor: pointer;
  list-style: none; font-weight: 500;
}
.nav a:hover, .nav summary:hover { background: var(--panel-2); color: var(--text); }
.nav a.on, .nav details.on summary { background: var(--accent); color: #fff; }
.nav details a { margin-left: 12px; }
.side .spacer { flex: 1; }
.side .me { font-size: 13px; color: var(--muted); padding: 8px; border-top: 1px solid var(--line); }
.side .me b { color: var(--text); display: block; }

.main { flex: 1; min-width: 0; padding: 22px clamp(14px, 3vw, 34px); }
.topbar { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; }
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.profile { display: flex; gap: 14px; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--panel-2); border: 2px solid var(--accent); }
.avatar.sm { width: 34px; height: 34px; border-width: 1px; }
.big { font-size: 38px; font-weight: 700; line-height: 1.1; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; }

.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input {
  flex: 1; max-width: 420px; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font: inherit;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
.cell-user { display: flex; align-items: center; gap: 10px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.banner { background: #3a1f22; border: 1px solid var(--accent); color: #ffd7da; padding: 8px 12px; border-radius: 8px; margin-bottom: 14px; }
:root[data-theme="light"] .banner { background: #fde8ea; color: #7a1820; }
.testbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.testbar select { background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 7px; border-radius: 8px; max-width: 260px; }

.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.logincard { max-width: 420px; width: 100%; text-align: center; padding: 34px 26px; }
.logincard .mark { width: 74px; height: 74px; margin: 0 auto 14px; font-size: 22px; }
.err { color: #ff9aa0; margin: 12px 0 0; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 0 8px 0 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav details a { margin-left: 0; }
  .side .spacer, .side .me { display: none; }
}

/* ---- Step 3: messages, forms, actions, dialogs */
.note { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--panel); }
.note.good { border-color: var(--ok); }
.note.warn { border-color: var(--warn); }
.note.bad { border-color: var(--accent); background: #3a1f22; color: #ffd7da; }
:root[data-theme="light"] .note.bad { background: #fde8ea; color: #7a1820; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { border-color: var(--accent); color: var(--accent-2); }
.btn.danger:hover { background: var(--accent); color: #fff; }
.btn.ok { border-color: var(--ok); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; }
.tag.red { border-color: var(--accent); color: var(--accent-2); }
.tag.green { border-color: var(--ok); color: var(--ok); }
.sub { font-size: 12px; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 10px; }
.switch .state { font-weight: 700; }
.switch .state.on { color: var(--ok); }
.switch .state.off { color: var(--muted); }

.form { max-width: 640px; display: grid; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input[type=text], .field select, .field textarea, .inline select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font: inherit;
}
.inline select { width: auto; padding: 6px 8px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input[readonly] { opacity: .7; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.row2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.section-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin: 8px 0 0; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(440px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { margin: 0 0 8px; }
@media (max-width: 600px) { .row2 { grid-template-columns: 1fr; } }

/* ---- Dashboard */
.hero { position: relative; height: clamp(220px, 34vw, 340px); border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 18px; background: #0b0d11; }
.slides, .slide { position: absolute; inset: 0; }
.slide { background-size: cover; background-position: center 40%; opacity: 0; transition: opacity 1.4s ease; transform: scale(1.02); }
.slide.on { opacity: 1; animation: kenburns 9s ease-out forwards; }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.12); } }
.hero-shade { position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(8,10,14,.82) 0%, rgba(8,10,14,.45) 45%, rgba(8,10,14,.05) 100%),
              linear-gradient(0deg, rgba(8,10,14,.7) 0%, rgba(8,10,14,0) 45%); }
.hero-text { position: absolute; left: clamp(16px, 3vw, 34px); bottom: clamp(16px, 3vw, 30px); right: 16px; color: #fff; }
.hero-kicker { font-size: 12px; letter-spacing: 2px; color: #ff8a8f; font-weight: 700; }
.hero-title { font-size: clamp(22px, 4vw, 36px); margin: 4px 0 2px; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.hero-sub { color: #e6e8ec; font-size: 15px; }
.dots { position: absolute; right: 14px; bottom: 12px; display: flex; gap: 6px; }
.dots button { width: 9px; height: 9px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: rgba(255,255,255,.4); }
.dots button.on { background: var(--accent-2); width: 22px; border-radius: 6px; }

.dash-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.dash-grid .wide { grid-column: 1 / -1; }
.card { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.dash-grid .card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(214, 58, 64, .18); }
.big-av { width: 84px; height: 84px; border-width: 3px; }
.p-name { font-size: 20px; font-weight: 700; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tags .tag { margin-left: 0; }
.stat-card .big { font-size: 56px; color: var(--accent-2); }
.stat-card .mini { margin-top: 10px; color: var(--muted); font-size: 13px; }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 16px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-weight: 600; font-size: 14px; }
.tile:hover { border-color: var(--accent); background: var(--accent); color: #fff; }
.tile svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 34px; gap: 10px; align-items: center; font-size: 14px; }
.bar-track { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 1s cubic-bezier(.2,.8,.2,1); }
.bar-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.dept .big { font-size: 44px; }
.leaders { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.leaders .tag { margin-left: 0; }
@media (max-width: 600px) { .bar-row { grid-template-columns: 110px 1fr 28px; } }
@media (prefers-reduced-motion: reduce) { .slide.on { animation: none; } .slide, .bar-fill, .card { transition: none; } }

/* ---- Pontaj */
.avg.red { color: #ff6b70; } .avg.yellow { color: var(--warn); } .avg.green { color: var(--ok); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; }
.wday { text-align: center; }
.wbar { height: 140px; background: var(--panel-2); border-radius: 10px; display: flex; align-items: flex-end; overflow: hidden; }
.wbar span { display: block; width: 100%; background: linear-gradient(0deg, var(--accent), var(--accent-2)); border-radius: 10px 10px 0 0; min-height: 2px; }
.wtime { font-weight: 700; margin-top: 6px; font-size: 14px; }
.wname { color: var(--muted); font-size: 12px; }
.pgrid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 1000px) { .pgrid { grid-template-columns: 1fr; } }
.tablewrap.flat { border: 0; background: transparent; border-radius: 0; }
table.slim { min-width: 0; }
table.slim th, table.slim td { padding: 8px 10px; }
.live { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 8px; box-shadow: 0 0 0 0 rgba(63,182,122,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(63,182,122,0); } 100% { box-shadow: 0 0 0 0 rgba(63,182,122,0); } }
.dt { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 8px 10px; border-radius: 8px; font: inherit; color-scheme: dark; }
.running-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.running-list .tag { margin-left: 0; display: inline-flex; align-items: center; }
@media (max-width: 600px) { .week { gap: 4px; } .wtime { font-size: 11px; } .wname { font-size: 10px; } .wbar { height: 100px; } }
@media (prefers-reduced-motion: reduce) { .live { animation: none; } }
@media (max-width: 600px) {
  table.slim th, table.slim td { padding: 7px 6px; white-space: normal; font-size: 13px; }
  table.slim .btn.sm { padding: 4px 7px; font-size: 12px; }
  .pgrid .card { padding: 12px; }
}
.pgrid > *, .dash-grid > * { min-width: 0; }

/* ---- Loguri */
.selectf { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; }
table.logs td.wrap { white-space: normal; min-width: 280px; }
table.logs td.nowrap { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
table.logs td { white-space: normal; vertical-align: top; }
table.logs .tag { margin-left: 0; white-space: nowrap; }

/* ===================== UI round 2 ===================== */
/* logo + menu icons */
.brand .logo { width: 44px; height: 44px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.nav a, .nav summary { display: flex; align-items: center; gap: 10px; }
.nav .ic { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.nav details a.sub { margin-left: 29px; padding-top: 7px; padding-bottom: 7px; font-size: 14px; }
.nav summary::-webkit-details-marker { display: none; }

/* toasts */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px;
  width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px;
  border-radius: 12px; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-left: 4px solid var(--ok); box-shadow: 0 12px 30px rgba(0,0,0,.35);
  transform: translateX(24px); opacity: 0; transition: transform .25s ease, opacity .25s ease; }
.toast.in { transform: none; opacity: 1; }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--accent); }
.toast span { flex: 1; line-height: 1.4; }
.toast button { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.toast button:hover { color: var(--text); }

/* login */
.login-body { position: relative; }
.login-bg { position: fixed; inset: 0; background: url("/static/banner/halloween.jpg") center / cover no-repeat;
  filter: brightness(.35) blur(2px); transform: scale(1.04); }
.login-body .loginwrap { position: relative; }
.logincard { background: rgba(22, 26, 33, .86); backdrop-filter: blur(6px); }
:root[data-theme="light"] .logincard { background: rgba(255,255,255,.9); }
.login-logo { width: 110px; height: 110px; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(0,0,0,.5)); }
.discord-btn { display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; font-weight: 600; }
.discord-btn svg { width: 22px; height: 22px; fill: currentColor; }

/* rank tags */
.rk { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.rk.gen { color: #f2c94c; border-color: rgba(242,201,76,.5); background: rgba(242,201,76,.08); }
.rk.con { color: #ff7a7f; border-color: rgba(214,58,64,.55); background: rgba(214,58,64,.08); }
.rk.sub { color: var(--muted); }
.rk.rez { color: #8fb8ff; border-color: rgba(143,184,255,.45); background: rgba(143,184,255,.08); }
:root[data-theme="light"] .rk.gen { color: #8a6a00; }
:root[data-theme="light"] .rk.con { color: #b0242b; }
:root[data-theme="light"] .rk.rez { color: #2b5bb5; }

/* quick filters */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 99px; padding: 6px 13px;
  font: inherit; font-size: 14px; cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { opacity: .75; margin-left: 4px; font-size: 12px; }

/* copy Discord ID */
.copy { background: none; border: 0; padding: 2px 4px; margin: -2px -4px; color: inherit; font: inherit; cursor: pointer; border-radius: 6px; font-variant-numeric: tabular-nums; }
.copy:hover { background: var(--panel-2); color: var(--accent-2); }

/* members table becomes cards on phones */
@media (max-width: 760px) {
  #tbl { min-width: 0; }
  #tbl thead { display: none; }
  #tbl, #tbl tbody { display: block; }
  #tbl tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 14px; border-bottom: 1px solid var(--line); }
  #tbl td { display: block; border: 0; padding: 0; white-space: normal; font-size: 14px; }
  #tbl td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
  #tbl td.c-user { grid-column: 1 / -1; font-size: 16px; font-weight: 600; }
  #tbl td.c-act { grid-column: 1 / -1; margin-top: 4px; }
  #tbl td:empty, #tbl td.blank { display: none; }
  .tablewrap:has(#tbl) { background: var(--panel); }
}

/* live previews in the member form */
.preview { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel-2); display: grid; gap: 8px; }
.preview .nick { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 15px; word-break: break-all; }
.preview .count { font-size: 12px; color: var(--muted); }
.preview .count.warn { color: var(--warn); }
.preview .count.bad { color: #ff7a7f; }
.preview .roles { font-size: 13px; line-height: 1.6; }
.preview .plus { color: var(--ok); }
.preview .minus { color: #ff7a7f; }
.preview .roles .tag { margin: 0 4px 4px 0; }

/* pontaj: goal ring, sessions, top 5 */
.goal { display: flex; align-items: center; gap: 18px; }
.ring { width: 110px; height: 110px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: var(--panel-2); }
.ring .fg { stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring .fg.red { stroke: #ff6b70; } .ring .fg.yellow { stroke: var(--warn); } .ring .fg.green { stroke: var(--ok); }
.goal .pct { font-size: 26px; font-weight: 700; }
.top5 { display: grid; gap: 8px; }
.top5 .row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.top5 .pos { font-weight: 800; text-align: center; color: var(--muted); }
.top5 .row:nth-child(1) .pos { color: #f2c94c; } .top5 .row:nth-child(2) .pos { color: #c9d1d9; } .top5 .row:nth-child(3) .pos { color: #d08a4a; }
.st-cancel { color: #ff7a7f; } .st-active { color: var(--ok); }
.search input { min-width: 0; }
@media (max-width: 600px) { .search { flex-wrap: wrap; } .search input { flex-basis: 100%; max-width: none; } }
.brand b { letter-spacing: .3px; }
