:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafb; --text: #17212b; --muted: #5d6b78; --border: #dde3e8;
  --primary: #0f766e; --primary-ink: #ffffff; --primary-soft: #e3f4f2;
  --danger: #b42318; --danger-soft: #fdecea; --warn: #9a6700; --warn-soft: #fff4d6; --ok: #1a7f37; --ok-soft: #e6f4ea;
  --info: #1d4ed8; --info-soft: #e7eefd; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418; --surface: #182026; --surface-2: #1d262d; --text: #e6ebef; --muted: #9aa8b3; --border: #2b3740;
    --primary: #2bb3a5; --primary-ink: #04201d; --primary-soft: #133a36;
    --danger: #f97066; --danger-soft: #3b1a18; --warn: #f5c451; --warn-soft: #3a2e10; --ok: #57c27a; --ok-soft: #15301e;
    --info: #7ea6ff; --info-soft: #1a2747; --shadow: none;
  }
}
* { 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: var(--primary); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); } .small { font-size: .86rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1150px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); text-decoration: none; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand svg { flex: none; }
.nav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.nav a { padding: .4rem .7rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.badge-dot { display: inline-block; min-width: 1.2rem; padding: 0 .3rem; margin-left: .25rem; border-radius: 99px; background: var(--danger); color: #fff; font-size: .72rem; text-align: center; }
.btn.menu-btn { display: none; margin-left: auto; }
main { max-width: 1150px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
@media (max-width: 1040px) {
  .btn.menu-btn { display: inline-flex; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; padding: .5rem 16px 1rem; }
  .nav.open { display: flex; }
  .topbar-inner { position: relative; }
}

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 400px) { .grid.cols-2 { grid-template-columns: 1fr; } }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head p { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: .25rem .6rem; font-size: .85rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .6; cursor: default; }

form .field { display: flex; flex-direction: column; gap: .3rem; }
form .fields { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
form .full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .88rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: .5rem .75rem; border-radius: 8px; display: none; }
.form-error.show { display: block; }

.tag { display: inline-block; padding: .08rem .5rem; border-radius: 99px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

.list-item { padding: .85rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.member-card { display: flex; gap: .85rem; align-items: flex-start; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.member-card .info { min-width: 0; flex: 1; }
.member-card .name { font-weight: 700; }
.phone { font-weight: 600; text-decoration: none; }

.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar > span { display: block; height: 100%; background: var(--primary); }

.vote { display: flex; flex-direction: column; align-items: center; min-width: 54px; padding: .35rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; color: var(--text); }
.vote.voted { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.vote b { font-size: 1.1rem; }

.comment { background: var(--surface-2); border-radius: 8px; padding: .6rem .75rem; }
.comment.system { background: transparent; padding: .2rem .75rem; font-style: italic; color: var(--muted); }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 2rem 16px; }
.auth-card { width: 100%; max-width: 560px; }
.auth-card.narrow { max-width: 400px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { background: none; border: none; padding: .55rem .8rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(620px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
dialog .dlg-body { padding: 1rem 1.1rem 1.2rem; max-height: 75vh; overflow-y: auto; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
.notice-body { white-space: pre-wrap; }
.storage-warning { background: var(--danger-soft); color: var(--danger); border-bottom: 1px solid var(--danger); padding: .7rem 16px; text-align: center; font-size: .92rem; }
.storage-warning code { background: var(--surface); padding: 0 .3rem; border-radius: 4px; }
