/* АРХИТЕКТУРА — стекло в стиле Apple, монохром логотипа + пастельные акценты */
:root {
  --font-display: 'Forum', 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Manrope', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --radius-lg: 28px;
  --radius: 18px;
  --radius-sm: 12px;
  --blur: saturate(170%) blur(26px);
  --ease: cubic-bezier(.22, .8, .24, 1);

  /* пастельные акценты */
  --sage: #bfd8c6;
  --rose: #ecbcc0;
  --sand: #ead8ae;
  --sky: #bccde9;
  --lilac: #d0c4e8;
}

[data-theme="dark"] {
  --bg: #0b0b0d;
  --bg-2: #17171b;
  --text: #f3f1ec;
  --muted: rgba(243, 241, 236, .58);
  --faint: rgba(243, 241, 236, .34);
  --glass: rgba(255, 255, 255, .055);
  --glass-strong: rgba(28, 28, 32, .72);
  --glass-hi: rgba(255, 255, 255, .09);
  --stroke: rgba(255, 255, 255, .11);
  --stroke-hi: rgba(255, 255, 255, .22);
  --shadow: 0 20px 60px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
  --primary: #f3f1ec;
  --on-primary: #0b0b0d;
  --blob-1: rgba(208, 196, 232, .16);
  --blob-2: rgba(234, 216, 174, .11);
  --blob-3: rgba(191, 216, 198, .10);
  --chip-alpha: .16;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f4f1ec;
  --bg-2: #ebe6df;
  --text: #121214;
  --muted: rgba(18, 18, 20, .58);
  --faint: rgba(18, 18, 20, .36);
  --glass: rgba(255, 255, 255, .55);
  --glass-strong: rgba(255, 255, 255, .82);
  --glass-hi: rgba(255, 255, 255, .8);
  --stroke: rgba(18, 18, 20, .08);
  --stroke-hi: rgba(18, 18, 20, .18);
  --shadow: 0 20px 50px rgba(60, 50, 40, .12), inset 0 1px 0 rgba(255, 255, 255, .7);
  --primary: #121214;
  --on-primary: #f4f1ec;
  --blob-1: rgba(208, 196, 232, .55);
  --blob-2: rgba(234, 216, 174, .55);
  --blob-3: rgba(191, 216, 198, .55);
  --chip-alpha: .55;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* фон: мягкие размытые пятна, чтобы стекло «играло» */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(120% 80% at 50% -10%, var(--bg-2), var(--bg) 60%); }
.backdrop i { position: absolute; border-radius: 50%; filter: blur(80px); }
.backdrop i:nth-child(1) { width: 52vmax; height: 52vmax; left: -14vmax; top: -12vmax; background: var(--blob-1); }
.backdrop i:nth-child(2) { width: 46vmax; height: 46vmax; right: -16vmax; top: 18vh; background: var(--blob-2); }
.backdrop i:nth-child(3) { width: 40vmax; height: 40vmax; left: 20vw; bottom: -22vmax; background: var(--blob-3); }

.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.display { font-family: var(--font-display); font-weight: 400; letter-spacing: .06em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ---------------- Шапка ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--glass-strong);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--stroke);
}
.topbar-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--stroke-hi); flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.brand-name { font-family: var(--font-display); font-size: 22px; letter-spacing: .12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 10px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); margin-top: 5px; }

.clocks { display: flex; gap: 6px; margin-left: auto; }
.clock { display: flex; flex-direction: column; align-items: flex-end; padding: 6px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--stroke); min-width: 96px; }
.clock b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.clock span { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.nav { max-width: 1240px; margin: 10px auto 0; display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--glass); border: 1px solid var(--stroke); width: max-content; }
.nav a { padding: 8px 16px; border-radius: 12px; text-decoration: none; font-weight: 600; font-size: 14px; color: var(--muted); transition: all .25s var(--ease); display: flex; gap: 8px; align-items: center; }
.nav a:hover { color: var(--text); }
.nav a.active { background: var(--primary); color: var(--on-primary); }
.nav svg { width: 17px; height: 17px; }

.tabbar { display: none; }

/* ---------------- Кнопки ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--stroke);
  background: var(--glass); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform .15s var(--ease), background .2s, border-color .2s; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--glass-hi); border-color: var(--stroke-hi); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: #ff9b9b; }
[data-theme="light"] .btn.danger { color: #b33a3a; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn.icon { width: 42px; padding: 0; }
.btn.icon.sm { width: 34px; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:disabled { opacity: .5; pointer-events: none; }

.fab { display: none; }

/* ---------------- Раскладка ---------------- */
.page { max-width: 1240px; margin: 0 auto; padding: 22px 16px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 38px; letter-spacing: .04em; line-height: 1.05; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { padding: 20px; }
.card + .card, .section + .section { margin-top: 16px; }
.card h2, .section-title { font-family: var(--font-display); font-weight: 400; font-size: 24px; letter-spacing: .04em; margin: 0 0 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .display { font-size: 24px; color: var(--text); display: block; margin-bottom: 6px; }

/* ---------------- Фильтры ---------------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px; margin-bottom: 16px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--glass); border: 1px solid var(--stroke); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; transition: all .2s var(--ease); }
.seg button.on { background: var(--primary); color: var(--on-primary); }
.seg.block { display: flex; width: 100%; }
.seg.block button { flex: 1; padding: 10px 8px; }

/* ---------------- Поля ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--muted); }
.field > span i { color: var(--rose); font-style: normal; }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--stroke);
  background: var(--glass); outline: none; transition: border-color .2s, box-shadow .2s; font-size: 16px; /* 16px — iOS не зумит */
  -webkit-appearance: none; appearance: none;
}
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
select.input option { background: var(--bg-2); color: var(--text); }
textarea.input { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--stroke-hi); box-shadow: 0 0 0 4px rgba(208, 196, 232, .18); }
.input.sm { height: 38px; font-size: 14px; border-radius: 12px; }
.input.search { padding-left: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 14px 50%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.error-text { color: var(--rose); font-size: 13px; min-height: 18px; }

/* ---------------- Чипы ---------------- */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid var(--stroke); background: var(--glass); }
.chip.sage { background: rgba(191, 216, 198, var(--chip-alpha)); border-color: rgba(191, 216, 198, .35); }
.chip.rose { background: rgba(236, 188, 192, var(--chip-alpha)); border-color: rgba(236, 188, 192, .35); }
.chip.sand { background: rgba(234, 216, 174, var(--chip-alpha)); border-color: rgba(234, 216, 174, .35); }
.chip.sky { background: rgba(188, 205, 233, var(--chip-alpha)); border-color: rgba(188, 205, 233, .35); }
.chip.lilac { background: rgba(208, 196, 232, var(--chip-alpha)); border-color: rgba(208, 196, 232, .35); }
.chip.id { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------------- KPI ---------------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; border-radius: 22px; position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi .value { font-size: 30px; font-weight: 600; letter-spacing: -.01em; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.accent { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.kpi.accent .label, .kpi.accent .sub { color: inherit; opacity: .65; }

/* ---------------- Таблицы ---------------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--stroke); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t tr:last-child td { border-bottom: 0; }
table.t .r { text-align: right; }
table.t tfoot td { font-weight: 700; border-top: 1px solid var(--stroke-hi); }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--glass); }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 14px; }
.bar-row .track { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--glass-hi); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--lilac), var(--sky)); }
.bar-row .fill.warm { background: linear-gradient(90deg, var(--sand), var(--rose)); }

/* ---------------- Визиты ---------------- */
.day-group + .day-group { margin-top: 20px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 6px 8px; }
.day-head .display { font-size: 22px; }
.visit {
  display: grid; grid-template-columns: 64px minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 18px; border-radius: 20px; cursor: pointer; transition: transform .2s var(--ease), background .2s;
}
.visit + .visit { margin-top: 8px; }
.visit:hover { background: var(--glass-hi); }
.visit:active { transform: scale(.99); }
.visit .time { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.visit .who { font-weight: 600; font-size: 16px; display: flex; gap: 8px; align-items: center; min-width: 0; }
.visit .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.visit .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.visit .svc { color: var(--muted); font-size: 14px; }
.visit .note { color: var(--muted); font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visit .amount { font-size: 18px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.visit .next { font-size: 12px; text-align: right; margin-top: 6px; }

/* ---------------- Список клиентов ---------------- */
.client-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 18px; border-radius: 20px; cursor: pointer; text-decoration: none; }
.client-row + .client-row { margin-top: 8px; }
.client-row:hover { background: var(--glass-hi); }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-size: 20px; background: var(--glass-hi); border: 1px solid var(--stroke-hi); flex-shrink: 0; }

/* ---------------- Карточка клиента (вертикальная) ---------------- */
.client-card-wrap { display: flex; justify-content: center; }
.client-card {
  width: 100%; max-width: 420px; min-height: 720px; padding: 26px 22px 22px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; border-radius: 34px;
}
.client-card::before {
  content: ''; position: absolute; width: 360px; height: 360px; right: -130px; top: -120px; border-radius: 50%;
  background: url('/logo.png') center / cover; opacity: .045; pointer-events: none; filter: grayscale(1);
}
.cc-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); }
.cc-id { font-family: var(--font-display); font-size: 15px; letter-spacing: .14em; color: var(--muted); margin-top: 26px; }
.cc-id b { font-size: 46px; display: block; color: var(--text); font-weight: 400; letter-spacing: .06em; line-height: 1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.cc-name { font-family: var(--font-display); font-size: 34px; line-height: 1.1; margin: 16px 0 6px; letter-spacing: .02em; word-break: break-word; }
.cc-phone { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; text-decoration: none; color: var(--text); }
.cc-divider { height: 1px; background: var(--stroke); margin: 20px 0; }
.cc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cc-stat { padding: 12px 14px; border-radius: 16px; background: var(--glass); border: 1px solid var(--stroke); }
.cc-stat span { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: block; }
.cc-stat b { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-next { padding: 14px 16px; border-radius: 18px; background: var(--glass-hi); border: 1px solid var(--stroke); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cc-label { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.cc-note { font-size: 14px; white-space: pre-wrap; }
.cc-history { display: flex; flex-direction: column; gap: 2px; }
.cc-h { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--stroke); font-size: 14px; cursor: pointer; }
.cc-h:last-child { border-bottom: 0; }
.cc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; padding-top: 20px; }

/* ---------------- Модальные окна ---------------- */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .25s var(--ease); }
.modal { width: 100%; max-width: 620px; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 24px; background: var(--glass-strong); animation: rise .35s var(--ease); overscroll-behavior: contain; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; letter-spacing: .04em; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.grabber { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } }

/* автодополнение клиента */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; max-height: 260px; overflow-y: auto; padding: 6px; border-radius: 18px; background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--stroke-hi); box-shadow: var(--shadow); }
.ac-item { padding: 10px 12px; border-radius: 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.ac-item:hover, .ac-item.hl { background: var(--glass-hi); }
.picked { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 14px; border: 1px solid var(--stroke-hi); background: var(--glass-hi); min-height: 46px; }

/* инструкция */
.instr { display: grid; grid-template-columns: 180px 1fr; gap: 0; }
.instr > div { padding: 12px 4px; border-bottom: 1px solid var(--stroke); }
.instr > div:nth-child(odd) { font-weight: 700; padding-right: 14px; }
.instr > div:nth-last-child(-n+2) { border-bottom: 0; }

.qr { background: #fff; padding: 12px; border-radius: 16px; width: max-content; }
.qr img, .qr canvas { display: block; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .08em; word-break: break-all; padding: 10px 14px; border-radius: 12px; background: var(--glass); border: 1px dashed var(--stroke-hi); user-select: all; }

/* тост */
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 28px); transform: translate(-50%, 20px); z-index: 200; padding: 12px 20px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: all .3s var(--ease); max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #d9767c; color: #fff; }

/* ---------------- Вход ---------------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; padding: 34px 28px 28px; text-align: center; }
.login-card img { width: 128px; height: 128px; border-radius: 50%; box-shadow: 0 0 0 1px var(--stroke-hi), 0 20px 50px rgba(0, 0, 0, .4); }
.login-card h1 { font-family: var(--font-display); font-weight: 400; font-size: 36px; letter-spacing: .14em; margin: 20px 0 0; }
.login-card .sub { font-size: 11px; font-weight: 700; letter-spacing: .4em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 26px; text-align: left; }
.login-card .btn { height: 50px; margin-top: 4px; }
.code-input { text-align: center; font-size: 26px !important; letter-spacing: .4em; font-variant-numeric: tabular-nums; height: 60px !important; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--stroke); }
.list-item:last-child { border-bottom: 0; }
.switch { position: relative; width: 46px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--glass-hi); border: 1px solid var(--stroke-hi); cursor: pointer; transition: .25s var(--ease); }
.switch span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 2px; top: 2px; border-radius: 50%; background: var(--text); transition: .25s var(--ease); }
.switch input:checked + span { background: var(--sage); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(18px); background: #0b0b0d; }

/* ================= Телефон ================= */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; }
  .topbar-inner { gap: 10px; flex-wrap: wrap; }
  .brand img { width: 38px; height: 38px; }
  .brand-name { font-size: 19px; }
  .brand-sub { font-size: 9px; }
  .clocks { order: 3; width: 100%; margin: 0; }
  .clock { flex: 1; flex-direction: row; justify-content: space-between; align-items: center; padding: 6px 12px; min-width: 0; }
  .clock b { font-size: 15px; }
  .top-actions { margin-left: auto; }
  .top-actions .btn-text { display: none; }
  .nav { display: none; }

  .tabbar {
    display: flex; position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px);
    padding: 6px; border-radius: 26px; background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--stroke-hi); box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border-radius: 20px; text-decoration: none; font-size: 10.5px; font-weight: 600; color: var(--muted); min-width: 0; }
  .tabbar a.active { background: var(--glass-hi); color: var(--text); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  .fab {
    display: grid; place-items: center; position: fixed; z-index: 41; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 92px);
    width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .4); cursor: pointer;
  }
  .fab svg { width: 26px; height: 26px; }
  .hide-mobile { display: none !important; }

  .page { padding: 16px 16px calc(env(safe-area-inset-bottom) + 120px); }
  .page-head h1 { font-size: 32px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .filters { padding: 10px; }
  .filters > * { width: 100%; }
  .filters .row > * { flex: 1; }
  .kpi { padding: 14px; border-radius: 20px; }
  .kpi .value { font-size: 24px; }
  .kpi .label { font-size: 10.5px; }
  .form-grid { grid-template-columns: 1fr; }

  .visit { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 16px; }
  .visit .time { font-size: 13px; color: var(--muted); grid-column: 1; }
  .visit .main { grid-column: 1 / -1; grid-row: 2; }
  .visit .side { grid-column: 2; grid-row: 1; }
  .visit .svc-col { grid-column: 1 / -1; grid-row: 3; }
  .visit .amount { font-size: 17px; }
  .visit .next { display: none; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 30px 30px 0 0; max-height: 94dvh; padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px); animation: sheet .4s var(--ease); }
  .grabber { display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--stroke-hi); margin: 0 auto 12px; }
  .modal-head h3 { font-size: 24px; }
  .modal-foot { position: sticky; bottom: calc(-1 * (env(safe-area-inset-bottom) + 18px)); margin: 18px -18px calc(-1 * (env(safe-area-inset-bottom) + 18px)); padding: 12px 18px calc(env(safe-area-inset-bottom) + 18px); background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-top: 1px solid var(--stroke); }
  .modal-foot .btn { flex: 1; height: 48px; }
  .instr { grid-template-columns: 1fr; }
  .instr > div:nth-child(odd) { border-bottom: 0; padding-bottom: 0; }

  .client-card { min-height: calc(100dvh - 230px); border-radius: 30px; }
  #toast { bottom: calc(env(safe-area-inset-bottom) + 100px); }
}
@keyframes sheet { from { transform: translateY(100%); } }

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