:root {
  --bg: #12151b;
  --panel: #1a1e26;
  --panel-2: #1d222b;
  --raise: #252a34;
  --line: #262b34;
  --line-2: #2a2f39;
  --line-3: #323845;
  --row-line: #252a33;
  --text: #e9eaee;
  --text-2: #c9ccd3;
  --text-3: #aab0bb;
  --muted: #8b919d;
  --dim: #7d838f;
  --green: #4ade80;
  --green-bg: #183022;
  --green-line: #2f5c40;
  --amber: #e0a13a;
  --amber-hi: #f0b75a;
  --amber-bg: #2a2217;
  --amber-line: #4a3a1f;
  --red: #f08a6c;
  --red-bg: #30201a;
  --red-line: #5c3a2f;
  --head: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --body: "Manrope", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
svg { display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--panel);
  font-weight: 700; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--raise); }
a.btn { color: var(--text); text-decoration: none; }
.btn.amber { border-color: var(--amber-line); background: var(--amber-bg); color: var(--amber); }
.btn.primary { border: 0; background: var(--amber); color: var(--bg); font-weight: 800; }
.btn.primary:hover { background: var(--amber-hi); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.icon-btn { width: 44px; padding: 0; }

/* ------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; gap: 16px;
}
.card h1 { font-family: var(--head); font-size: 22px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; font-weight: 600; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-3); font-weight: 700; }
.field input, .field select {
  height: 46px; border-radius: 10px; border: 1px solid var(--line-3); background: #14171d;
  padding: 0 14px; font-size: 15px; font-weight: 600; color: var(--text);
}
.err { color: var(--red); font-size: 13px; font-weight: 600; min-height: 18px; }

/* ------------------------------------------------ header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(18, 21, 27, 0.96); backdrop-filter: blur(8px);
  padding: 18px 32px 14px;
  display: grid; gap: 14px 28px;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand stats actions" "controls controls controls" "banner banner banner";
}
.brand { grid-area: brand; display: flex; align-items: center; gap: 12px; }
.brand > div { display: flex; flex-direction: column; gap: 2px; }
.brand-logo { width: 54px; height: 54px; flex-shrink: 0; }
.brand b { font-family: var(--head); font-size: 20px; letter-spacing: -0.01em; }
.brand small { font-size: 12px; color: var(--muted); font-weight: 600; }
.login-logo { width: 150px; height: 150px; align-self: center; margin-bottom: 4px; }

.stats { grid-area: stats; display: flex; align-items: center; justify-content: flex-end; gap: 28px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.stat small { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat b { font-family: var(--head); font-weight: 600; font-size: 20px; }
.stat .green { color: var(--green); }
.stat .plain { color: var(--text-2); }
.vsep { width: 1px; height: 44px; background: var(--line-2); }
.balance-box { display: flex; align-items: center; gap: 10px; }
.balance-btn {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  background: none; border: 0; padding: 4px 6px; border-radius: 8px;
}
.balance-btn:hover { background: var(--panel); }
.balance-btn small { font-size: 12px; color: var(--muted); font-weight: 600; }
.balance-btn b { font-family: var(--head); font-size: 30px; line-height: 1; font-weight: 700; }
.balance-btn b .unit { font-size: 14px; color: var(--muted); font-weight: 600; }
.balance-sub { display: none; }
.pm { display: flex; flex-direction: column-reverse; gap: 4px; }
.pm button {
  width: 34px; height: 26px; border-radius: 7px; font-weight: 800; font-size: 16px; line-height: 1;
}
.pm .plus { border: 1px solid var(--green-line); background: var(--green-bg); color: var(--green); }
.pm .minus { border: 1px solid var(--red-line); background: var(--red-bg); color: var(--red); }

.actions { grid-area: actions; display: flex; align-items: center; gap: 8px; }
.user-wrap { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px 0 6px;
  border-radius: 22px; border: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font-weight: 700; font-size: 13px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--line-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--head); font-size: 13px; color: var(--text);
}
.menu {
  position: absolute; right: 0; top: 50px; min-width: 180px; z-index: 30;
  background: var(--panel-2); border: 1px solid var(--line-3); border-radius: 10px;
  padding: 6px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 7px;
  background: none; border: 0; color: var(--text); text-decoration: none; font-weight: 700; font-size: 13px;
}
.menu a:hover, .menu button:hover { background: var(--raise); }

.controls {
  grid-area: controls; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 8px 12px 8px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.switch {
  display: flex; align-items: center; gap: 0; background: none; border: 0;
  font-weight: 700; font-size: 13px; padding: 0 4px; min-height: 44px;
}
.switch .track { margin-right: 10px; }
.switch .track {
  width: 38px; height: 22px; border-radius: 11px; background: #3a3f4a; position: relative; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: left .15s;
}
.switch[aria-pressed="true"] .track { background: #43b672; }
.switch[aria-pressed="true"] .track::after { left: 19px; }
.mult {
  padding: 6px 10px; border-radius: 7px; background: var(--raise); color: var(--text-3);
  font-family: var(--head); font-weight: 600; font-size: 12px;
}
.mult.on { background: rgba(224, 161, 58, 0.16); color: var(--amber-hi); }
.online {
  margin-left: auto; display: flex; align-items: center; gap: 12px;
  padding: 0 18px; border-left: 1px solid var(--line-2); border-right: 1px solid var(--line-2);
}
.online-title { font-weight: 700; font-size: 13px; }
.online-ctl { display: flex; align-items: center; gap: 6px; }
.sq {
  width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--amber-line);
  background: var(--amber-bg); color: var(--amber); font-weight: 800; font-size: 16px;
}
.segs { display: flex; gap: 3px; padding: 0 6px; }
.segs i { width: 22px; height: 8px; border-radius: 3px; background: #2f343e; }
.segs i.on { background: var(--amber); }
.segs.full i { background: var(--green); }
.online-hours { min-width: 36px; text-align: center; font-weight: 700; font-size: 13px; color: var(--text-2); }
.online-bp { min-width: 56px; text-align: right; font-weight: 800; font-size: 13px; color: var(--muted); }
.online-bp.got { color: var(--green); }
.ctl-btn {
  height: 40px; border-radius: 9px; border: 1px solid var(--line-2); background: #1f242d;
  color: var(--text-2); display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 12px; font-weight: 700; font-size: 13px;
}
.ctl-btn.sound { width: 40px; padding: 0; }
.ctl-btn.sound[aria-pressed="false"] { color: var(--dim); }
.ctl-btn[aria-pressed="true"].edit { border-color: var(--amber); background: var(--amber-bg); color: var(--amber); }

.banner {
  grid-area: banner; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 10px 10px 16px; background: var(--amber-bg); border: 1px solid var(--amber-line); border-radius: 12px;
}
.banner p { margin: 0; font-size: 13px; font-weight: 600; color: #f0cf95; flex: 1 1 300px; }
.banner .btns { display: flex; gap: 8px; margin-left: auto; }

/* ------------------------------------------------ tabs (mobile) */
.tabs { display: none; }

/* ------------------------------------------------ board */
.board {
  padding: 4px 32px 40px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start;
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cat {
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-radius: 12px; overflow: hidden;
}
.cat-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 14px 16px; min-height: 48px;
  background: color-mix(in srgb, var(--c) 10%, var(--panel)); border: 0; text-align: left;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.cat-title { font-family: var(--head); font-weight: 600; font-size: 14px; }
.cat-count { font-size: 12px; color: var(--muted); font-weight: 700; }
.cat-earned { margin-left: auto; font-weight: 800; font-size: 13px; color: var(--c); }
.cat-earned.zero { color: var(--dim); }
.chev { color: var(--muted); transition: transform .15s; }
.cat.collapsed .chev { transform: rotate(-90deg); }
.cat.collapsed .task-list { display: none; }
.task-list { min-height: 8px; }
.editing .task-list { min-height: 44px; }

.task {
  display: flex; align-items: center; gap: 6px; min-height: 46px;
  padding: 6px 10px 6px 16px; border-top: 1px solid var(--row-line);
  transition: background .2s;
}
.task.done { background: rgba(74, 222, 128, 0.07); }
.task .name { flex: 1; font-weight: 600; font-size: 13px; line-height: 1.35; padding: 4px 0; cursor: pointer; min-width: 0; }
.task.done .name { color: var(--dim); text-decoration: line-through; }
.task input[type=checkbox] {
  width: 18px; height: 18px; margin: 0 4px; accent-color: var(--green); cursor: pointer; flex-shrink: 0;
}
.task .bp { width: 44px; white-space: nowrap; text-align: right; font-weight: 800; font-size: 13px; color: var(--text-3); flex-shrink: 0; }
.task.done .bp { color: var(--green); }
.handle, .hide-btn, .move { display: none; }
.editing .handle { display: flex; color: var(--amber); cursor: grab; padding: 6px 2px; margin-left: -6px; touch-action: none; }
.editing .hide-btn {
  display: flex; width: 32px; height: 32px; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--raise); border: 1px solid var(--line-3); color: var(--text-2); border-radius: 7px;
}
.editing .task { padding-left: 10px; }
.sortable-ghost { opacity: 0.35; }
.sortable-chosen { background: var(--raise); }

.clock {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; min-width: 32px; padding: 0; border-radius: 8px; flex-shrink: 0;
  border: 1px solid var(--line-3); background: var(--raise); color: var(--text-3);
  font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums;
}
.clock.amber { border-color: var(--amber-line); background: var(--amber-bg); color: var(--amber); padding: 0 7px; min-width: 46px; }
.clock.green { border-color: var(--green-line); background: var(--green-bg); color: var(--green); }
.stepper {
  display: flex; align-items: center; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: var(--raise); border: 1px solid var(--line-3);
}
.stepper.full { border-color: var(--green-line); }
.stepper button {
  width: 24px; height: 100%; background: none; border: 0; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.stepper span { min-width: 34px; text-align: center; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.stepper.full span { color: var(--green); }

.hidden-box { border: 1px dashed var(--amber-line); border-radius: 12px; overflow: hidden; }
.hidden-box h3 {
  margin: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  font-size: 13px; font-weight: 700; color: var(--amber);
}
.hidden-box h3 span { color: var(--muted); font-size: 12px; }
.hidden-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-top: 1px dashed #3a3222; }
.hidden-row div { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.hidden-row b { font-weight: 600; font-size: 13px; color: var(--text-3); }
.hidden-row small { font-size: 11px; color: var(--dim); font-weight: 600; }
.hidden-empty { padding: 4px 16px 14px; font-size: 12px; color: var(--muted); font-weight: 600; }

/* ------------------------------------------------ overlays */
.backdrop { position: fixed; inset: 0; background: rgba(8, 10, 14, 0.6); z-index: 40; border: 0; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); z-index: 41;
  background: #171b22; border-left: 1px solid var(--line-2); display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; gap: 12px; padding: 20px 16px 16px 24px; border-bottom: 1px solid var(--line-2);
}
.drawer-head h2 { font-family: var(--head); font-weight: 600; font-size: 16px; margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding-bottom: 16px; }
.close-x { width: 40px; height: 40px; background: none; border: 0; color: var(--muted); font-size: 24px; line-height: 1; }
.log-day { display: flex; align-items: center; gap: 12px; padding: 14px 24px 6px; font-size: 12px; font-weight: 800; color: var(--amber); }
.log-day::after { content: ""; flex: 1; height: 1px; background: #3a3222; }
.log-row {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) 52px 52px; align-items: center; gap: 10px;
  padding: 9px 24px; border-bottom: 1px solid #20242c;
}
.log-row time { font-size: 12px; color: var(--dim); font-weight: 700; }
.log-row .t { font-size: 13px; font-weight: 600; }
.log-row .t.undone { color: var(--dim); text-decoration: line-through; }
.log-row .undo { display: block; padding: 0; background: none; border: 0; color: var(--amber); font-weight: 700; font-size: 12px; margin-top: 2px; }
.log-row .amt { text-align: right; font-weight: 800; font-size: 13px; }
.log-row .amt.pos { color: var(--green); }
.log-row .amt.neg { color: var(--red); }
.log-row .after { text-align: right; font-size: 12px; color: var(--muted); font-weight: 700; }
.log-more { display: flex; justify-content: center; padding: 16px; }

.modal {
  position: fixed; z-index: 41; left: 50%; top: 110px; transform: translateX(-50%);
  width: min(340px, calc(100% - 32px)); background: var(--panel-2); border: 1px solid var(--line-3);
  border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.modal-head { display: flex; align-items: center; }
.modal-head h2 { font-family: var(--head); font-weight: 600; font-size: 15px; margin: 0; }
.modal-head h2.plus { color: var(--green); }
.modal-head h2.minus { color: var(--red); }
.modal-head .close-x { margin-left: auto; }
.quick { display: flex; gap: 6px; }
.quick button {
  flex: 1; height: 38px; border-radius: 8px; border: 1px solid var(--line-3); background: var(--raise);
  font-weight: 800; font-size: 13px;
}
.warn { font-size: 12px; color: var(--amber-hi); font-weight: 600; }
.modal .go { height: 46px; border-radius: 10px; border: 0; color: var(--bg); font-weight: 800; font-size: 14px; }
.go.plus { background: var(--green); }
.go.minus { background: var(--red); }
.go.fix { background: var(--amber); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 16px; padding: 10px 10px 10px 18px; max-width: calc(100% - 32px);
  background: #262b35; border: 1px solid #353b48; border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  font-weight: 700; font-size: 14px; min-height: 54px;
}
.toast .btn { height: 34px; }

/* ------------------------------------------------ admin */
.admin { max-width: 1100px; margin: 0 auto; padding: 24px 24px 60px; }
.admin-top { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-top h1 { font-family: var(--head); font-size: 20px; margin: 0; }
.admin-tabs { display: flex; gap: 6px; margin-left: auto; }
.admin-tabs button {
  height: 40px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font-weight: 700;
}
.admin-tabs button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.panel h2 { font-family: var(--head); font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row .field { flex: 1 1 160px; }
.form-row .field.sm { flex: 0 1 120px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; height: 46px; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
td { padding: 10px; border-bottom: 1px solid var(--row-line); font-weight: 600; vertical-align: middle; }
td .btns { display: flex; gap: 6px; justify-content: flex-end; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; background: var(--raise); color: var(--text-3); }
.badge.admin { background: var(--amber-bg); color: var(--amber); }
.cat-label { display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------------------------ mobile */
@media (max-width: 860px) {
  .top {
    padding: 14px 16px 12px; gap: 12px;
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand actions" "stats stats" "controls controls" "banner banner";
  }
  .brand b { font-size: 16px; }
  .brand { gap: 10px; }
  .brand-logo { width: 40px; height: 40px; }
  .brand small { display: none; }
  .actions .lbl { display: none; }
  .actions .btn { width: 44px; padding: 0; }
  .user-btn { padding: 0 6px; }
  .user-btn .lbl { display: none; }

  .stats {
    justify-content: flex-start; gap: 12px;
    padding: 12px 12px 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  }
  .stats .stat, .stats .vsep { display: none; }
  .balance-box { width: 100%; }
  .balance-btn { align-items: flex-start; padding: 0; }
  .balance-btn b { font-size: 28px; }
  .balance-sub { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
  .balance-sub span { color: var(--green); }
  .pm { flex-direction: row; gap: 8px; margin-left: auto; }
  .balance-btn b { color: var(--text); }
  .pm button { width: 44px; height: 44px; border-radius: 10px; font-size: 20px; }

  .controls { background: none; border: 0; padding: 0; gap: 8px; }
  .switch { height: 40px; min-height: 0; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line-2); gap: 0; color: var(--muted); }
  .switch .track { display: none; }
  .switch[aria-pressed="true"] { background: var(--green-bg); border-color: var(--green-line); color: var(--green); }
  .switch .long { display: none; }
  .mult { font-size: 11px; padding: 6px 8px; }
  .online { order: 10; width: 100%; margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
  .online-bp { margin-left: auto; }
  .ctl-btn.edit .lbl { display: none; }
  .ctl-btn.edit { width: 40px; padding: 0; }
  .ctl-btn.sound { margin-left: auto; }

  .tabs { display: flex; gap: 6px; padding: 4px 16px 10px; overflow-x: auto; scrollbar-width: none; }
  .tabs button {
    flex-shrink: 0; display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
    border-radius: 18px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
    font-weight: 800; font-size: 12px;
  }
  .tabs button span { opacity: 0.8; font-weight: 700; }
  .tabs button[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: var(--bg); }

  .board { display: block; padding: 0 16px 32px; }
  .col { display: contents; }
  .cat { display: none; }
  .cat.tab-active { display: block; margin-bottom: 12px; }
  .cat.collapsed .task-list { display: block; }
  .cat-head .chev { display: none; }
  .task { min-height: 52px; padding-left: 14px; }
  .task .name { font-size: 14px; }
  .task input[type=checkbox] { width: 22px; height: 22px; }
  .clock, .stepper, .editing .hide-btn { height: 38px; }
  .clock { min-width: 38px; }
  .stepper button { width: 30px; }
  .editing .move {
    display: block; height: 38px; max-width: 44px; border-radius: 8px; border: 1px solid var(--line-3);
    background: var(--raise); padding: 0 4px; font-size: 12px;
  }
  .editing .hide-btn { width: 38px; }
  .hidden-box { margin-top: 12px; }

  .drawer { top: auto; height: 80vh; width: 100%; border-left: 0; border-top: 1px solid var(--line-2); border-radius: 18px 18px 0 0; }
  .log-row { grid-template-columns: minmax(0, 1fr) 48px; padding: 10px 18px; }
  .log-row time { grid-column: 1; grid-row: 2; font-size: 11px; }
  .log-row .after { display: none; }
  .log-row .amt { grid-column: 2; grid-row: 1 / span 2; font-size: 14px; }
  .log-day { padding: 12px 18px 4px; }
  .modal { top: auto; bottom: 0; transform: none; left: 0; width: 100%; border-radius: 18px 18px 0 0; padding: 18px 18px 28px; }
  .quick button { height: 44px; }
  .toast { bottom: 16px; width: calc(100% - 32px); justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
