:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --ink: #0E1014;
  --ink-2: #2A2E36;
  --muted: #6B7280;
  --line: #E6E8EC;
  --yes: #0FA968;
  --yes-ink: #067A4A;
  --yes-soft: #E3F7EC;
  --no: #E5484D;
  --no-ink: #B4232A;
  --no-soft: #FDECEC;
  --none: #EEF0F3;
  --accent: #0E1014;
  --accent-ink: #FFFFFF;
  --gold: #F5B83D;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 60px rgba(16, 24, 40, .18);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A0B0E;
    --surface: #15171C;
    --surface-2: #1B1E24;
    --ink: #F3F4F6;
    --ink-2: #D9DCE1;
    --muted: #9AA1AC;
    --line: #262A31;
    --yes: #22C17E;
    --yes-ink: #5BE0A4;
    --yes-soft: rgba(34, 193, 126, .15);
    --no: #F06167;
    --no-ink: #FF8C90;
    --no-soft: rgba(240, 97, 103, .15);
    --none: #20232A;
    --accent: #F3F4F6;
    --accent-ink: #0E1014;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------ layout */
.shell { max-width: 1040px; margin: 0 auto; padding: 0 16px calc(110px + var(--safe-b)); }
.shell.no-nav { padding-bottom: calc(40px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px; margin: 0 -16px 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 10px; background: var(--ink);
  position: relative; flex: none;
}
.logo-mark::before {
  content: ""; position: absolute; left: 7px; right: 7px; top: 9px; bottom: 7px;
  border: 2px solid var(--bg); border-radius: 4px;
}
.logo-mark::after {
  content: ""; position: absolute; width: 9px; height: 9px; right: -3px; bottom: -3px;
  border-radius: 50%; background: var(--yes); border: 2.5px solid var(--bg);
}
.logo-mark.big { width: 56px; height: 56px; border-radius: 17px; }
.logo-mark.big::before { left: 13px; right: 13px; top: 16px; bottom: 13px; border-width: 3px; border-radius: 6px; }
.logo-mark.big::after { width: 15px; height: 15px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yes); }
.pill.sync .dot { background: var(--gold); animation: pulse 1s infinite; }
.pill.offline .dot, .pill.error .dot { background: var(--no); }
@keyframes pulse { 50% { opacity: .35; } }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 4px 0 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--no-soft); color: var(--no-ink); font-size: 13.5px; font-weight: 500;
  animation: rise .3s ease;
}
.banner.info { background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow); }

.view { animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin: 6px 2px 2px; }
.page-sub { color: var(--muted); margin: 0 2px 18px; font-size: 14px; }
.section-title {
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 26px 4px 10px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .shell { padding-left: 28px; padding-right: 28px; }
  .topbar { margin: 0 -28px 8px; padding-left: 28px; padding-right: 28px; }
}

/* ------------------------------------------------------------- cards */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 12px; }
.card h3 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; }
.card .hint { color: var(--muted); font-size: 13.5px; }

.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.stat .label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat .value { font-size: 24px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.hero {
  grid-column: 1 / -1; background: var(--ink); color: var(--bg);
  padding: 20px; position: relative; overflow: hidden;
}
.stat.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--yes) 55%, transparent), transparent 70%);
}
.stat.hero .label, .stat.hero .sub { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.stat.hero .value { font-size: 34px; }
.icon-chip {
  width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 12px;
  background: var(--surface-2);
}
.icon-chip.yes { background: var(--yes-soft); }
.icon-chip.no { background: var(--no-soft); }

/* --------------------------------------------------------- calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; text-transform: capitalize; display: flex; align-items: center; gap: 8px; }
.cal-title .lock { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-transform: none; letter-spacing: 0; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center;
  background: var(--surface-2); color: var(--ink); transition: transform .15s, background .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 18px; height: 18px; }
.cal-nav { display: flex; gap: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding-bottom: 4px; }
.cal-day {
  position: relative; aspect-ratio: 1 / 1.08; border-radius: 14px; background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-weight: 700; font-size: 14.5px; transition: transform .15s ease, background .2s ease;
  border: 1.5px solid transparent;
}
.cal-day:active { transform: scale(.92); }
.cal-day .emo { font-size: 13px; line-height: 1; height: 14px; }
.cal-day.yes { background: var(--yes-soft); color: var(--yes-ink); }
.cal-day.no { background: var(--no-soft); color: var(--no-ink); }
.cal-day.today { border-color: var(--ink); }
.cal-day.future:not(.yes):not(.no) { color: var(--muted); }
.cal-day.empty { visibility: hidden; }
.cal-day.pending::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold);
}
.cal-day.by-admin::before {
  content: ""; position: absolute; top: 6px; left: 6px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink); opacity: .55;
}
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; background: var(--none); }
.legend i.yes { background: var(--yes-soft); border: 1.5px solid var(--yes); }
.legend i.no { background: var(--no-soft); border: 1.5px solid var(--no); }
.legend i.adm { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); opacity: .55; }
.legend i.pend { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }

/* --------------------------------------------------- answer buttons */
.answer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.answer.three { grid-template-columns: 1fr 1fr; }
.ans {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 96px; border-radius: 18px; font-weight: 700; font-size: 15px;
  background: var(--surface-2); border: 2px solid var(--line);
  transition: transform .15s ease, background .2s, border-color .2s, box-shadow .2s;
}
.ans .big { font-size: 34px; line-height: 1; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.ans:active { transform: scale(.96); }
.ans.yes.on { background: var(--yes); border-color: var(--yes); color: #fff; box-shadow: 0 10px 24px color-mix(in srgb, var(--yes) 35%, transparent); }
.ans.no.on { background: var(--no); border-color: var(--no); color: #fff; box-shadow: 0 10px 24px color-mix(in srgb, var(--no) 35%, transparent); }
.ans.on .big { transform: scale(1.12); }
.ans.clear { grid-column: 1 / -1; min-height: 50px; flex-direction: row; font-size: 14px; color: var(--muted); }

.today-card .when { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.today-card .q { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.today-card .note { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* ------------------------------------------------------------ lists */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; font-size: 14.5px; }
.row .s { color: var(--muted); font-size: 12.5px; }
.row .amt { font-weight: 700; white-space: nowrap; }
.row.tap { cursor: pointer; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--none); color: var(--muted);
}
.badge.yes { background: var(--yes-soft); color: var(--yes-ink); }
.badge.no { background: var(--no-soft); color: var(--no-ink); }
.badge.dark { background: var(--ink); color: var(--bg); }
.empty-state { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 14px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 0 6px 8px; }
.tbl td { padding: 11px 6px; border-top: 1px solid var(--line); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr.total td { font-weight: 800; }

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .m { color: var(--muted); font-weight: 600; text-transform: capitalize; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--yes); border-radius: 99px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar-row.cur .m { color: var(--ink); }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface-2); font-size: 16px; outline: none; transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--ink); background: var(--surface); }
textarea.input { resize: vertical; min-height: 70px; }
.input-money { position: relative; }
.input-money span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); }
.input-money .input { padding-left: 44px; font-weight: 700; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; border-radius: 15px; font-weight: 700; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--no-soft); color: var(--no-ink); }
.btn.green { background: var(--yes); color: #fff; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn { flex: 1 1 140px; }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: flex; padding: 4px; border-radius: 14px; background: var(--surface-2); gap: 4px; }
.seg button { flex: 1; min-height: 40px; border-radius: 11px; font-weight: 600; font-size: 13.5px; color: var(--muted); transition: background .2s, color .2s; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.toggle { width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .25s cubic-bezier(.3, 1.4, .5, 1); }
.toggle.on { background: var(--ink); }
.toggle.on::after { transform: translateX(20px); }

.link-box {
  margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2);
  font-size: 12.5px; color: var(--muted); word-break: break-all; max-height: 74px; overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* -------------------------------------------------------- bottom nav */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); z-index: 30;
  display: flex; gap: 4px; padding: 6px; border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg); width: min(440px, calc(100% - 24px));
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: 16px; font-size: 11.5px; font-weight: 600; color: var(--muted);
  transition: background .2s, color .2s;
}
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button.on { background: var(--ink); color: var(--bg); }

/* ------------------------------------------------------------- sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 14, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px 20px calc(24px + var(--safe-b));
  animation: up .32s cubic-bezier(.2, .9, .25, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; text-transform: capitalize; }
.sheet .meta { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
@keyframes up { from { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 26px; padding-bottom: 24px; animation: pop .25s ease; }
  @keyframes pop { from { transform: scale(.96); opacity: 0; } }
}

/* ------------------------------------------------------------- toast */
#toast-root { position: fixed; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: min(460px, calc(100% - 24px));
  padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); animation: drop .3s cubic-bezier(.2, .9, .25, 1);
}
.toast.err { background: var(--no); color: #fff; }
.toast.ok { background: var(--yes); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: .25s; }
@keyframes drop { from { opacity: 0; transform: translateY(-12px); } }

/* -------------------------------------------------------- auth pages */
.boot, .auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 18px; gap: 16px; text-align: center; color: var(--muted); }
.auth .card { width: 100%; max-width: 420px; text-align: left; padding: 24px; }
.auth h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: var(--ink); }
.auth .lead { color: var(--muted); margin-top: 6px; font-size: 14.5px; }
.auth .steps { margin: 14px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 13.5px; }
.auth .steps li { margin-bottom: 6px; }
.err-text { color: var(--no-ink); font-size: 13.5px; font-weight: 600; margin-top: 12px; min-height: 1px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.small { font-size: 12.5px; }

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