:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #fff;
  --surface-soft: #eef1eb;
  --text: #1d312b;
  --muted: #6c7a73;
  --line: #e3e8df;
  --accent: #27644e;
  --accent-strong: #164d38;
  --accent-soft: #e4efe6;
  --accent-text: #fff;
  --warm: #f3e7ce;
  --warm-text: #8b652c;
  --danger: #b84d4a;
  --danger-soft: #f8e7e3;
  --shadow: 0 8px 32px #203d2810;
  --radius: 22px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131d19;
  --surface: #1d2a24;
  --surface-soft: #27372e;
  --text: #edf4ec;
  --muted: #a2b1a6;
  --line: #35453a;
  --accent: #9ccdaf;
  --accent-strong: #c1e8cf;
  --accent-soft: #294735;
  --accent-text: #183724;
  --warm: #493e27;
  --warm-text: #e7c78c;
  --danger: #f0a3a0;
  --danger-soft: #4d2e2b;
  --shadow: 0 8px 32px #0002;
}
* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { margin: 0; min-width: 280px; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
button { cursor: pointer; }
button, a { -webkit-user-select: none; user-select: none; }
button { color: inherit; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px;
}
a { color: var(--accent); }
svg { width: 20px; height: 20px; flex: 0 0 auto; stroke-width: 1.7; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.16; letter-spacing: -.85px; font-weight: 750; }
h2 { font-size: 21px; line-height: 1.24; letter-spacing: -.45px; }
h3 { font-size: 16px; line-height: 1.35; font-weight: 650; }
small { font-size: 12px; }
[hidden] { display: none !important; }
.app-shell { max-width: 760px; min-height: 100vh; margin: 0 auto; padding-top: var(--safe-top); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 22px 14px; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 13px; background: var(--accent); color: var(--accent-text); font-size: 25px; font-weight: 850; letter-spacing: -2px; padding-right: 3px; }
.brand-name { font-size: 15px; font-weight: 750; letter-spacing: -.2px; }
.brand-location { margin-top: 3px; color: var(--muted); font-size: 11px; letter-spacing: .4px; }
.role-badge { font-size: 11px; color: var(--accent); background: var(--accent-soft); padding: 7px 10px; border-radius: 50px; white-space: nowrap; font-weight: 650; }
.page { padding: 14px 20px calc(110px + var(--safe-bottom)); }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 21px; }
.eyebrow { text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-size: 10px; font-weight: 750; margin-bottom: 9px; }
.subtitle { color: var(--muted); font-size: 13px; line-height: 1.55; margin-top: 8px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 25px 0 12px; }
.section-title small { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 19px; }
.card + .card { margin-top: 12px; }
.card-flat { box-shadow: none; }
.stack { display: grid; gap: 12px; }
.stack-small { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.wrap { overflow-wrap: anywhere; }
.microcopy { font-size: 12px; line-height: 1.5; color: var(--muted); }
.spacer { height: 16px; }
.button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 14px; padding: 11px 16px; font-size: 14px; line-height: 1.35; font-weight: 650; background: var(--accent); color: var(--accent-text); text-decoration: none; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button-secondary { background: var(--surface-soft); color: var(--text); }
.button-outline { border-color: var(--line); background: var(--surface); color: var(--text); }
.button-danger { background: var(--danger-soft); color: var(--danger); }
.button-small { min-height: 38px; padding: 8px 12px; font-size: 12px; border-radius: 11px; }
.button-block { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); flex: 0 0 auto; }
.text-button { min-height: 38px; padding: 5px 0; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 650; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.text-button.danger { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions > .button { flex: 1; }
.group-card { padding: 0; overflow: hidden; }
.group-card-header { display: flex; gap: 13px; padding: 19px; align-items: center; width: 100%; border: 0; text-align: left; background: transparent; }
.group-symbol { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 17px; background: var(--accent-soft); color: var(--accent); font-size: 23px; font-weight: 750; flex: 0 0 auto; }
.group-card:nth-child(even) .group-symbol { background: var(--warm); color: var(--warm-text); }
.group-card-footer { border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 10px; }
.group-card-footer .button { flex: 1; }
.group-switch { background: transparent; border: 0; color: var(--text); padding: 0; text-align: left; display: flex; align-items: center; gap: 8px; }
.group-switch h1 { font-size: 26px; }
.group-switch svg { color: var(--muted); }
.date-strip { display: flex; align-items: center; gap: 10px; margin: 17px 0; }
.date-control { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; flex: 1; min-width: 0; }
.date-control svg { color: var(--accent); }
.date-control input { color: var(--text); background: transparent; border: 0; width: 100%; min-width: 0; padding: 0; min-height: 22px; font-size: 14px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650; border-radius: 30px; padding: 6px 9px; background: var(--surface-soft); color: var(--muted); white-space: nowrap; }
.status-pill.complete { background: var(--accent-soft); color: var(--accent); }
.status-pill.draft { background: var(--warm); color: var(--warm-text); }
.status-pill.cancelled { background: var(--danger-soft); color: var(--danger); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 15px 0 19px; }
.metric { border-radius: 16px; padding: 13px 12px; background: var(--surface); border: 1px solid var(--line); }
.metric-number { font-size: 26px; font-weight: 750; line-height: 1.1; letter-spacing: -.8px; }
.metric-label { font-size: 10px; color: var(--muted); margin-top: 6px; line-height: 1.25; }
.metric.is-present { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.metric.is-present .metric-label { color: var(--accent); }
.metric.is-absent .metric-number { color: var(--danger); }
.progress-track { height: 4px; background: var(--surface-soft); border-radius: 5px; overflow: hidden; margin-top: 14px; }
.progress-fill { height: 100%; background: var(--accent); transition: width .2s; }
.search { display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 0 13px; margin: 14px 0; }
.search svg { color: var(--muted); width: 18px; }
.search input { background: transparent; color: var(--text); width: 100%; min-width: 0; min-height: 46px; border: 0; outline: none; font-size: 14px; }
.search input::placeholder { color: var(--muted); opacity: .8; }
.search:focus-within { border-color: var(--accent); }
.filter-tabs { display: flex; overflow-x: auto; gap: 7px; padding: 2px 0 12px; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab { border: 1px solid var(--line); background: transparent; color: var(--muted); white-space: nowrap; padding: 8px 13px; border-radius: 25px; font-size: 12px; min-height: 36px; }
.filter-tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.people-list { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.person-row { display: flex; align-items: center; gap: 10px; min-height: 77px; padding: 12px 13px; }
.person-row + .person-row { border-top: 1px solid var(--line); }
.person-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: 0; padding: 3px 0; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: -.3px; }
.avatar.large { width: 72px; height: 72px; font-size: 22px; color: var(--accent); background: var(--accent-soft); border-radius: 26px; }
.person-name { font-size: 14px; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
.person-detail { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; line-height: 1.35; }
.guest-label { color: var(--warm-text); }
.attendance-controls { display: flex; gap: 5px; flex: 0 0 auto; }
.attendance-button { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 13px; }
.attendance-button svg { width: 18px; height: 18px; }
.attendance-button.present[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.attendance-button.absent[aria-pressed="true"] { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.attendance-button.unmarked[aria-pressed="true"] { background: var(--surface-soft); }
.meeting-note { padding: 12px 14px; border-radius: 14px; background: var(--warm); color: var(--warm-text); font-size: 12px; line-height: 1.5; margin: 12px 0; }
.meeting-bottom { margin-top: 16px; display: grid; gap: 10px; }
.subnav { display: flex; border-bottom: 1px solid var(--line); margin: 8px 0 16px; gap: 22px; }
.subnav button { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 13px 0; border-bottom: 2px solid transparent; }
.subnav button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.bottom-nav { position: fixed; z-index: 20; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 760px); display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: var(--surface); padding: 8px 13px calc(10px + var(--safe-bottom)); box-shadow: 0 -5px 25px #203d2805; }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 51px; padding: 5px 8px; border: 0; background: none; color: var(--muted); font-size: 10px; font-weight: 600; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--accent); }
.nav-icon-wrap { display: grid; place-items: center; min-width: 46px; height: 27px; border-radius: 20px; }
.nav-item.active .nav-icon-wrap { background: var(--accent-soft); }
.back-link { margin-bottom: 14px; }
.history-row, .directory-row { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 15px; border: 0; background: transparent; }
.history-row + .history-row, .directory-row + .directory-row { border-top: 1px solid var(--line); }
.history-day { display: grid; place-items: center; width: 44px; flex: 0 0 auto; padding: 5px; background: var(--surface-soft); border-radius: 13px; }
.history-day strong { font-size: 19px; line-height: 1.2; }
.history-day small { color: var(--muted); font-size: 9px; }
.chevron { color: var(--muted); width: 16px; height: 16px; }
.profile-header { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin: 8px 0 23px; }
.profile-header h1 { font-size: 25px; max-width: 100%; overflow-wrap: anywhere; }
.profile-lines { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.profile-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 10px; background: var(--surface-soft); font-size: 12px; color: var(--muted); }
.profile-chip svg { width: 14px; height: 14px; }
.rate-card { display: flex; align-items: center; gap: 19px; }
.rate-disc { position: relative; width: 88px; height: 88px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); }
.rate-disc::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.rate-disc strong { position: relative; font-size: 23px; letter-spacing: -1px; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 13px; }
.stat-table th { font-weight: 500; color: var(--muted); text-align: right; font-size: 11px; }
.stat-table th:first-child { text-align: left; }
.stat-table td { padding: 10px 0; border-bottom: 1px solid var(--line); text-align: right; }
.stat-table td:first-child { text-align: left; }
.stat-table tr:last-child td { border: 0; }
.birthday-month { text-transform: capitalize; margin: 23px 0 11px; font-size: 13px; letter-spacing: .3px; }
.birthday-date { display: grid; place-items: center; min-width: 48px; padding: 8px; background: var(--warm); border-radius: 14px; color: var(--warm-text); font-size: 15px; font-weight: 750; }
.birthday-hero { border: 0; background: var(--accent-soft); padding: 19px; border-radius: 20px; margin-bottom: 20px; }
.birthday-hero svg { width: 27px; height: 27px; color: var(--accent); }
.settings-row { padding: 15px 0; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border: 0; }
.settings-label { font-size: 14px; font-weight: 650; }
.field { display: grid; gap: 7px; }
.field > span, .field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-width: 0; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; min-height: 46px; }
.field textarea { min-height: 90px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox-field { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.5; }
.checkbox-field input { width: 19px; height: 19px; accent-color: var(--accent); margin: 1px 0 0; flex: 0 0 auto; }
.form { display: grid; gap: 16px; }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.notice { border-left: 3px solid var(--accent); padding: 12px 14px; background: var(--accent-soft); color: var(--text); border-radius: 0 12px 12px 0; font-size: 13px; line-height: 1.5; }
.empty { padding: 36px 22px; text-align: center; }
.empty-icon { margin: 0 auto 15px; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 21px; background: var(--surface-soft); color: var(--accent); }
.empty-icon svg { width: 27px; height: 27px; }
.empty h2 { font-size: 18px; margin-bottom: 8px; }
.empty p { color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 300px; margin: auto; }
.empty .button { margin-top: 18px; }
.gate { min-height: 90vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.gate .brand-mark { width: 64px; height: 64px; font-size: 41px; border-radius: 23px; margin-bottom: 22px; }
.gate h1 { font-size: 27px; margin-bottom: 12px; }
.gate p { color: var(--muted); line-height: 1.6; font-size: 14px; max-width: 320px; }
.gate .button { margin-top: 23px; }
.gate .spinner { margin-top: 24px; }
.spinner { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-area { display: grid; justify-items: center; padding: 40px; color: var(--muted); gap: 13px; font-size: 13px; }
.skeleton { background: var(--surface-soft); border-radius: 9px; min-height: 14px; animation: pulse 1.5s ease-in-out infinite alternate; }
.skeleton-row { height: 76px; border-radius: 17px; margin-top: 10px; }
@keyframes pulse { to { opacity: .4; } }
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: #0f241b66; display: flex; align-items: flex-end; justify-content: center; padding: 12px 0 0; backdrop-filter: blur(3px); }
.sheet { max-width: 760px; width: 100%; max-height: calc(94dvh - var(--safe-top)); background: var(--bg); border-radius: 27px 27px 0 0; box-shadow: 0 -12px 45px #0002; display: flex; flex-direction: column; overflow: hidden; }
.sheet-handle { width: 32px; height: 4px; background: var(--line); border-radius: 5px; margin: 9px auto 0; flex: 0 0 auto; }
.sheet-header { display: flex; align-items: flex-start; gap: 15px; justify-content: space-between; padding: 17px 20px; flex: 0 0 auto; }
.sheet-header h2 { padding-top: 7px; }
.sheet-body { padding: 0 20px calc(24px + var(--safe-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.sheet-body .people-list { margin-bottom: 12px; }
.sheet-body .search { margin-top: 0; }
.sheet-footer { padding: 13px 20px calc(16px + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.toast-root { position: fixed; z-index: 100; bottom: calc(94px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); width: calc(100% - 36px); max-width: 480px; pointer-events: none; }
.toast { border-radius: 15px; padding: 13px 16px; margin-top: 8px; color: var(--bg); background: var(--text); box-shadow: var(--shadow); font-size: 13px; line-height: 1.5; display: flex; align-items: center; gap: 9px; }
.toast.error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.noscript { text-align: center; padding: 30px; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.pagination small { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (min-width: 600px) {
  .topbar { padding: 26px 32px 16px; }
  .page { padding: 20px 32px calc(110px + var(--safe-bottom)); }
  h1 { font-size: 32px; }
  .group-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
  .group-grid .card + .card { margin-top: 0; }
  .person-row { padding: 13px 19px; }
  .attendance-button { width: 43px; height: 43px; }
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: 27px; max-height: 90dvh; }
  .sheet-body { padding-bottom: 24px; }
  .sheet-footer { padding-bottom: 16px; }
}
@media (max-width: 350px) {
  .topbar { padding-inline: 15px; }
  .page { padding-inline: 12px; }
  .person-row { gap: 7px; padding-inline: 10px; }
  .person-main { gap: 7px; }
  .person-name { font-size: 13px; }
  .avatar { width: 29px; height: 29px; font-size: 10px; }
  .attendance-button { width: 34px; height: 38px; }
  .attendance-controls { gap: 3px; }
  .role-badge { padding: 6px 8px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

body.sheet-open { overflow: hidden; }
