:root {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #0b0b0f);
  --surface: var(--tg-theme-secondary-bg-color, #15151c);
  --surface-strong: #1b1b24;
  --text: var(--tg-theme-text-color, #f7f5fb);
  --muted: var(--tg-theme-hint-color, #92909b);
  --accent: var(--tg-theme-button-color, #7c3aed);
  --accent-2: #a855f7;
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #ff6b78;
  --line: color-mix(in srgb, var(--text) 9%, transparent);
  --shadow: 0 18px 60px rgb(0 0 0 / 25%);
  --radius: 20px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f5f4f8);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --surface-strong: #ebe9f0;
  --text: var(--tg-theme-text-color, #17151c);
  --muted: var(--tg-theme-hint-color, #77727f);
  --shadow: 0 18px 60px rgb(51 39 75 / 14%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 85% -5%, color-mix(in srgb, var(--accent) 17%, transparent), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.app-shell { width: min(100%, 760px); min-height: 100dvh; margin: 0 auto; padding: env(safe-area-inset-top) 18px calc(104px + env(safe-area-inset-bottom)); }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow, .section-kicker { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: -.03em; }
h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 15px; display: grid; place-items: center; cursor: pointer; font-size: 28px; line-height: 1; }
.icon-button.primary { background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: var(--button-text); box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 32%, transparent); }
.icon-button.ghost { background: transparent; color: var(--muted); }
.card { background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--line); box-shadow: inset 0 1px rgb(255 255 255 / 2%); }
.screen { display: none; animation: appear .22s ease; }
.screen.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } }
.date-hero { position: relative; display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; min-height: 88px; border-radius: var(--radius); padding: 10px; }
.date-title { border: 0; background: transparent; text-align: center; display: flex; flex-direction: column; gap: 5px; cursor: pointer; }
.date-title span { color: var(--accent-2); font-size: 13px; font-weight: 700; }
.date-title strong { font-size: 20px; letter-spacing: -.02em; }
#date-picker { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 14px 0 26px; }
.day-chip { min-width: 0; padding: 10px 2px; border: 1px solid transparent; border-radius: 15px; background: transparent; color: var(--muted); cursor: pointer; }
.day-chip span, .day-chip strong { display: block; }
.day-chip span { margin-bottom: 7px; font-size: 10px; text-transform: uppercase; }
.day-chip strong { font-size: 15px; }
.day-chip.today { border-color: var(--line); }
.day-chip.selected { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); color: var(--text); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 0 2px 14px; }
.section-heading.compact { margin-top: 24px; }
.count-pill, .status-pill { padding: 6px 10px; border-radius: 999px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
.schedule-list, .contact-list { display: grid; gap: 10px; }
.appointment-card, .contact-row { width: 100%; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: inherit; text-align: left; cursor: pointer; }
.appointment-card { min-height: 76px; display: grid; grid-template-columns: 70px 1fr 24px; align-items: center; padding: 12px 14px; }
.appointment-time { font-size: 18px; font-weight: 780; letter-spacing: -.03em; }
.appointment-person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 65%, #1f2937), #24202f); color: white; font-weight: 750; }
.avatar.large { width: 58px; height: 58px; border-radius: 20px; font-size: 20px; }
.person-copy { min-width: 0; }
.person-copy strong, .person-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-copy strong { margin-bottom: 4px; font-size: 15px; }
.person-copy small { color: var(--muted); font-size: 12px; }
.chevron { color: var(--muted); font-size: 20px; }
.empty-state { min-height: 210px; padding: 34px 24px; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 18px; }
.large-action, .primary-action, .secondary-action, .danger-action { width: 100%; min-height: 52px; border-radius: 16px; border: 0; font-weight: 750; cursor: pointer; }
.link-action { display: grid; place-items: center; text-decoration: none; }
.large-action { position: sticky; bottom: 86px; margin-top: 20px; color: var(--button-text); background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 14px 36px color-mix(in srgb, var(--accent) 34%, transparent); }
.search-wrap { height: 54px; border-radius: 17px; display: flex; align-items: center; gap: 10px; padding: 0 15px; color: var(--muted); }
.search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; }
.filter-tabs { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); cursor: pointer; }
.filter-chip.active { color: var(--button-text); background: var(--accent); border-color: var(--accent); }
.contact-row { min-height: 70px; display: flex; align-items: center; gap: 12px; padding: 12px; }
.contact-row .person-copy { flex: 1; }
.status-pill { padding: 5px 8px; font-size: 10px; }
.status-pill.friend { color: #c9b8ff; background: #2e2252; }
.status-pill.active { color: #92edbf; background: #183a2d; }
.potential-card { position: relative; min-height: 200px; overflow: hidden; padding: 24px; border-radius: 26px; background: linear-gradient(145deg, #2b1951, #15131e 72%); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.potential-card span { color: #d5c8ec; font-size: 13px; }
.potential-card strong { display: block; margin-top: 18px; font-size: clamp(36px, 9vw, 54px); letter-spacing: -.05em; }
.potential-card p { color: var(--muted); }
.sparkline { position: absolute; right: 14px; bottom: 20px; width: 42%; height: 90px; display: flex; align-items: end; gap: 5px; opacity: .8; }
.sparkline i { flex: 1; border-radius: 6px 6px 2px 2px; background: linear-gradient(var(--accent-2), var(--accent)); }
.sparkline i:nth-child(1) { height: 22%; }.sparkline i:nth-child(2) { height: 43%; }.sparkline i:nth-child(3) { height: 36%; }.sparkline i:nth-child(4) { height: 62%; }.sparkline i:nth-child(5) { height: 55%; }.sparkline i:nth-child(6) { height: 88%; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.metric { min-height: 112px; padding: 18px; border-radius: 20px; color: var(--text); text-align: left; cursor: pointer; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 16px; font-size: 30px; }
.metric small { display: block; margin-top: 12px; color: var(--muted); font-size: 10px; }
.metric.accent strong { color: #a7f3d0; }
.info-card { display: flex; gap: 14px; padding: 18px; border-radius: 20px; }
.reminders-list { display: grid; gap: 10px; margin-bottom: 14px; }
.reminder-card { padding: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.reminder-card.due { border-color: color-mix(in srgb, var(--accent) 52%, transparent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.reminder-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.reminder-head strong { font-size: 16px; }.reminder-head span { color: var(--accent-2); font-size: 11px; font-weight: 750; }
.reminder-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.reminder-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reminder-actions .primary-action, .reminder-actions .secondary-action { min-height: 44px; margin: 0; font-size: 12px; }
.info-icon { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--accent-2); }
.info-card h3 { margin-bottom: 5px; }.info-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 760px); height: calc(78px + env(safe-area-inset-bottom)); padding: 8px 18px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--bg) 92%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(22px); }
.nav-item { border: 0; background: transparent; color: var(--muted); display: grid; place-content: center; gap: 5px; cursor: pointer; }
.nav-item span { font-size: 21px; }.nav-item small { font-size: 11px; font-weight: 650; }
.nav-item.active { color: var(--accent-2); }
.settings-card { display: grid; gap: 14px; padding: 18px; margin-bottom: 12px; border-radius: 20px; }
.settings-copy { display: grid; gap: 5px; }
.settings-copy span { color: var(--muted); font-size: 13px; }
.settings-action { margin: 0; }
.admin-user-list { display: grid; gap: 10px; }
.admin-section { margin-bottom: 24px; }
.admin-section:last-child { margin-bottom: 0; }
.admin-section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px; }
.admin-section-title h3 { font-size: 17px; }
.admin-section-title span { min-width: 28px; height: 28px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; background: var(--surface); color: var(--accent-2); font-size: 12px; font-weight: 750; }
.admin-empty { min-height: 74px; }
.admin-user { padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.admin-user-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.admin-user-head span { color: var(--accent-2); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.admin-user p { margin: 7px 0 12px; color: var(--muted); font-size: 13px; }
.admin-user-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.admin-user-actions button { margin: 0; min-height: 44px; }
.modal-layer { position: fixed; z-index: 100; inset: 0; display: none; align-items: end; justify-content: center; }
.modal-layer.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 62%); backdrop-filter: blur(5px); }
.sheet { position: relative; width: min(100%, 760px); max-height: 92dvh; overflow-y: auto; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--bg); box-shadow: var(--shadow); animation: sheet-up .24s ease; }
.sheet::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 2px auto 20px; }
@keyframes sheet-up { from { transform: translateY(25px); opacity: .6; } }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.sheet-header h2 { font-size: 23px; }
.close-button { width: 38px; height: 38px; border: 0; border-radius: 13px; background: var(--surface); color: var(--muted); cursor: pointer; }
.field { display: grid; gap: 8px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea { width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 15px; outline: 0; padding: 13px 14px; background: var(--surface); color: var(--text); }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field-hint, .draft-hint { color: var(--muted); font-size: 12px; line-height: 1.45; }
.draft-hint { margin: 10px 2px 14px; text-align: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.primary-action { color: var(--button-text); background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.secondary-action { margin-top: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.danger-action { margin-top: 10px; background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.detail-person { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.detail-grid { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; margin-bottom: 18px; }
.detail-row { min-height: 51px; display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.detail-row:last-child { border-bottom: 0; }.detail-row span { color: var(--muted); font-size: 13px; }.detail-row strong { font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.contact-picker { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 16px; }
.picker-search { margin-bottom: 10px; }
.picker-row { width: 100%; min-height: 54px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text); display: flex; align-items: center; justify-content: space-between; text-align: left; cursor: pointer; }
.picker-row:last-child { border-bottom: 0; }.picker-row.selected { background: color-mix(in srgb, var(--accent) 21%, var(--surface)); }
.confirmation { text-align: center; padding: 12px 0 4px; }.confirmation .danger-symbol { width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 16px; background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); font-size: 25px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); width: max-content; max-width: calc(100% - 36px); padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { min-height: 90px; border-radius: 18px; background: linear-gradient(100deg, var(--surface) 30%, var(--surface-strong) 50%, var(--surface) 70%); background-size: 240% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position-x: -240%; } }
@media (min-width: 700px) {
  .app-shell { padding-left: 30px; padding-right: 30px; }
  .schedule-list { grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .metric { min-height: 130px; }
  .large-action { max-width: 360px; margin-left: auto; margin-right: auto; display: block; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
