:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --page: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --ink: #19312d;
  --muted: #657a75;
  --line: #dce7e3;
  --accent: #087f70;
  --accent-strong: #06685d;
  --accent-soft: #e3f4f0;
  --on-accent: #ffffff;
  --warning: #a85d08;
  --warning-soft: #fff3df;
  --success: #16734f;
  --success-soft: #e7f6ed;
  --danger: #b33b42;
  --danger-soft: #fff0f0;
  --shadow: 0 1px 2px rgb(28 61 54 / 6%);
  --radius: 10px;
  --info: #2b6cb0;
  --info-soft: #e6f0fb;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #111a19;
  --surface: #192523;
  --surface-soft: #202f2c;
  --ink: #e6f0ed;
  --muted: #a0b3ae;
  --line: #344843;
  --accent: #54c7b1;
  --accent-strong: #74dbc7;
  --accent-soft: #203e38;
  --on-accent: #102b25;
  --warning: #ffca78;
  --warning-soft: #45331e;
  --success: #7bd3a4;
  --success-soft: #203d2f;
  --danger: #ff9296;
  --danger-soft: #452629;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  --info: #8cbcf0;
  --info-soft: #1d3149;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #111a19;
    --surface: #192523;
    --surface-soft: #202f2c;
    --ink: #e6f0ed;
    --muted: #a0b3ae;
    --line: #344843;
    --accent: #54c7b1;
    --accent-strong: #74dbc7;
    --accent-soft: #203e38;
    --on-accent: #102b25;
    --warning: #ffca78;
    --warning-soft: #45331e;
    --success: #7bd3a4;
    --success-soft: #203d2f;
    --danger: #ff9296;
    --danger-soft: #452629;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --info: #8cbcf0;
    --info-soft: #1d3149;
  }
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: var(--page); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}

button, input, select, textarea { font: inherit; }
button, .button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-strong); }

.shell {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  min-height: 100vh;
}

aside.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 14px;
  padding: 14px 10px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px; font-size: 16px; font-weight: 750; letter-spacing: -.03em; }
.brand::before { width: 44px; height: 44px; flex: none; background: url(/static/logo.png) center / contain no-repeat; content: ""; }
nav#nav { display: grid; gap: 2px; }
.nav-item { display: flex; min-height: 36px; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); text-align: left; text-decoration: none; cursor: pointer; }
.nav-item:hover { background: var(--surface-soft); color: var(--ink); }
.nav-item.active { border-color: var(--line); background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }

.workspace { min-width: 0; }
header.topbar { position: sticky; top: 0; z-index: 10; display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 12px; padding: 8px clamp(12px, 2vw, 24px); border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar h1 { margin: 0; font-size: 18px; line-height: 1.2; letter-spacing: -.02em; }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
main#content { width: 100%; max-width: 1500px; margin-inline: auto; padding: 14px clamp(12px, 2vw, 24px) 32px; }

.mode-banner { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; font-weight: 650; }
#notice.notice { margin: 10px clamp(12px, 2vw, 24px) 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.mode-banner.mirror { border-color: color-mix(in srgb, var(--warning) 35%, var(--line)); background: var(--warning-soft); color: var(--warning); }
.mode-banner.primary { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); background: var(--success-soft); color: var(--success); }
#notice.notice { background: var(--accent-soft); color: var(--accent-strong); }
#notice.notice.error { background: var(--danger-soft); color: var(--danger); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar > input, .toolbar > select { flex: 1 1 180px; width: auto; }
.grid { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.current-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); align-items: start; }
.card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card h2, .card h3 { margin: 0 0 10px; line-height: 1.3; letter-spacing: -.02em; }
.card h2 { font-size: 15px; }
.card h3 { font-size: 14px; }
.card > :last-child { margin-bottom: 0; }
#content > .card { margin-top: 12px; }
.record { display: block; width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-align: left; text-decoration: none; overflow-wrap: anywhere; }
.record:hover { border-color: var(--accent); background: var(--surface-soft); }
.record + .record { margin-top: 6px; }
.record p { margin: 2px 0 0; }
.list { gap: 6px; }
.record + .record { margin-top: 0; }
.muted, .meta { color: var(--muted); }
.directory-code { color: color-mix(in srgb, var(--muted) 40%, var(--surface)); overflow-wrap: anywhere; }
.meta { display: flex; gap: 7px 14px; flex-wrap: wrap; font-size: 13px; }
.badge { color: var(--ink); display: inline-flex; min-height: 20px; align-items: center; padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.warning { border-color: transparent; background: var(--warning-soft); color: var(--warning); }
.badge.success { border-color: transparent; background: var(--success-soft); color: var(--success); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 10px; }
.metric { display: grid; min-height: 62px; align-content: center; gap: 1px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; background: var(--surface); }
.metric strong { font-size: 19px; line-height: 1.2; letter-spacing: -.03em; }
.metric span { color: var(--muted); font-size: 12px; }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-soft); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; font-weight: 650; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td { overflow-wrap: anywhere; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
label { display: grid; min-width: 0; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 600; }
.filter-check { display: flex; align-items: center; gap: 6px; }
.filter-check input { width: auto; min-height: 0; }
.makeup-form { display: grid; gap: 6px; min-width: 180px; }
input, select, textarea { width: 100%; min-width: 0; min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--surface); color: var(--ink); }
textarea { min-height: 72px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.span-all { grid-column: 1 / -1; }
button, .button { display: inline-flex; min-height: 34px; align-items: center; justify-content: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-weight: 650; text-decoration: none; cursor: pointer; }
button:hover, .button:hover { border-color: var(--accent); }
button:focus-visible, .button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
button:disabled, .button:disabled { cursor: not-allowed; opacity: .55; }
button.primary, .button.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
button.primary:hover, .button.primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
button.danger, .button.danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--danger-soft); color: var(--danger); }
button.quiet, .button.quiet { border-color: transparent; background: transparent; color: var(--muted); }

dialog#editor { width: min(680px, calc(100vw - 28px)); max-width: 680px; max-height: min(90vh, 900px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgb(0 0 0 / 25%); }
dialog#editor::backdrop { background: rgb(9 24 21 / 55%); backdrop-filter: blur(2px); }
dialog#editor form { padding: 16px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; font-size: 17px; }
.payment-file-name { display: inline; padding: 0; min-height: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; text-align: left; }
[data-files-entity="payments"] [data-file-list] a { overflow-wrap: anywhere; }
.payment-file-download { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; vertical-align: middle; }
#payment-file-preview { width: min(780px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
#payment-file-preview::backdrop { background: rgb(9 24 21 / 55%); }
#payment-file-preview h2 { min-width: 0; overflow-wrap: anywhere; }
#payment-file-preview img { display: block; max-width: 100%; max-height: 70dvh; margin: auto; object-fit: contain; }
#payment-file-preview iframe { display: block; width: 100%; height: 70dvh; border: 0; }
#payment-file-preview pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap; margin-top: 14px; }
#login-view.login-view { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: var(--page); }
.login-card { width: min(100%, 420px); padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.03em; }
.login-card form { display: grid; gap: 15px; margin-top: 22px; }
.hidden { display: none !important; }

dialog#lesson-detail { width: min(880px, calc(100vw - 28px)); max-width: 880px; max-height: calc(100dvh - 28px); padding: 16px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog#lesson-detail::backdrop { background: rgb(9 24 21 / 55%); backdrop-filter: blur(2px); }

/* Compact lesson editor, using the shared CRM tokens and combo controller. */
#lesson-window-form { min-width: 0; font-size: 13px; }
#lesson-window-form [hidden], #lesson-window-form .lesson-field[hidden], #edit-form [hidden] { display: none; }
#lesson-window-form .dialog-head { gap: 8px; }
#lesson-detail-title { min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lesson-window-status { flex-shrink: 0; margin-left: auto; }
.lesson-window-body { min-width: 0; padding: 0; margin: 0; border: 0; }
.lesson-roster-controls { min-width: 0; padding: 0; margin: 0; border: 0; }
.lesson-window-body:disabled :is(input, select, textarea, button) { cursor: not-allowed; }
.lesson-parameters { display: grid; grid-template-columns: 1fr 1.4fr 1.4fr; gap: 6px; margin-bottom: 6px; }
.lesson-topic { grid-template-columns: 1fr; }
.lesson-when { grid-template-columns: 142px 112px 88px 112px minmax(0, 1fr); }
#lesson-window-form :is(input, select, textarea) { min-width: 0; min-height: 30px; padding: 4px 6px; font-size: 13px; }
#lesson-window-form .combo-native { min-height: 0; padding: 0; }
#lesson-window-form .lesson-field { display: flex; align-items: center; min-width: 0; gap: 4px; padding-inline: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.lesson-field > span { flex-shrink: 0; color: var(--muted); font-size: 12px; }
#lesson-window-form .lesson-field input { border: 0; min-height: 28px; padding-inline: 0; box-shadow: none; background: transparent; }
#lesson-window-form .lesson-field .combo-inline input { min-height: 24px; padding-block: 0; }
.lesson-field:focus-within { border-color: var(--accent); }
.lesson-field .combo { flex: 1; }
#lesson-window-form .lesson-field .combo-entry input { padding-right: 24px; }
.lesson-field .combo-entry > button { width: 22px; }
.lesson-alfa-note { margin: 6px 0; color: var(--muted); font-size: 12px; }
.lesson-alfa-note:empty { display: none; }
.lesson-window-roster { margin: 12px 0; }
#lesson-window-form h3 { margin: 0; font-size: 13px; font-weight: 600; }
.lesson-window-roster .section-head { margin-bottom: 4px; }
#lesson-window-form [data-lesson-all] { min-height: 26px; padding: 0; color: var(--accent-strong); font-size: 12px; }
.lesson-student, #lesson-window-add { display: grid; grid-template-columns: 80px minmax(0, 2fr) minmax(0, 1fr) 84px minmax(0, 1fr) 22px; gap: 6px; align-items: center; }
#lesson-window-students.is-event .lesson-student, #lesson-window-add.is-event { grid-template-columns: 80px minmax(0, 2fr) 84px minmax(0, 1fr) 22px; }
/* Closed roster (planned AlfaCRM lesson before «Провести») keeps only the name and subscription. */
.lesson-student.closed { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
#lesson-window-students.is-event .lesson-student.closed { grid-template-columns: minmax(0, 1fr); }
.lesson-student { min-height: 36px; padding-block: 2px; border-top: 1px solid var(--line); }
.lesson-student > * { min-width: 0; }
.lesson-makeup, .lesson-missed { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
.lesson-student .seg button { width: 26px; min-width: 26px; min-height: 26px; padding: 0; font-size: 13px; }
.lesson-student .seg button:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: -3px; }
.lesson-student-name { display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; }
.lesson-student-name > a { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; text-decoration: none; }
.lesson-balance { flex-shrink: 0; font-size: 11px; }
.lesson-balance.danger { color: var(--danger); }
.lesson-balance.warning { color: var(--warning); }
.lesson-balance.success { color: var(--success); }
.lesson-student-subscription { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.lesson-currency { position: relative; display: block; width: 84px; }
.lesson-charge { display: flex; align-items: center; gap: 4px; }
.lesson-charge:has(:is(.lesson-makeup, .lesson-missed)) { flex-wrap: wrap; }
.lesson-charge-hint { padding: 0; min-height: 26px; color: var(--accent); text-decoration: underline; font-size: 12px; white-space: nowrap; }
#lesson-window-form .lesson-currency input { padding-right: 19px; text-align: right; font-variant-numeric: tabular-nums; appearance: textfield; }
.lesson-currency input::-webkit-inner-spin-button, .lesson-currency input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.lesson-currency > span { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.lesson-student-extra { display: flex; align-items: center; gap: 2px; }
#lesson-window-form .lesson-student-extra > * { min-width: 0; min-height: 26px; padding: 2px 4px; }
.lesson-student-extra input { flex: 1; border-color: transparent; background: transparent; }
.lesson-student-extra input:focus { border-color: var(--accent); }
.lesson-student-extra button { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-student-extra em { color: var(--muted); }
.lesson-student-remove { min-height: 26px; padding: 0; opacity: 0; }
.lesson-student:hover .lesson-student-remove, .lesson-student:focus-within .lesson-student-remove { opacity: 1; }
#lesson-window-form [data-validation-field][aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 1px; border-radius: 4px; }
.lesson-row-error { grid-column: 2 / -1; margin: 0; color: var(--danger); font-size: 12px; }
.lesson-row-error:empty, #lesson-window-error:empty { display: none; }
#lesson-window-error { flex: 0 0 100%; margin: 8px 0 0; color: var(--danger); font-size: 13px; overflow-wrap: anywhere; }
#lesson-window-add { margin-top: 4px; }
#lesson-window-add > .combo { grid-column: 2; }
#lesson-window-form textarea { overflow-y: hidden; resize: none; }
.lesson-window-files { margin-top: 8px; }
.lesson-window-files .section-head { margin: 0; }
#lesson-window-form .lesson-window-files button, .lesson-window-footer button { min-height: 30px; padding: 4px 8px; font-size: 13px; }
.lesson-window-footer { position: sticky; bottom: -16px; display: flex; justify-content: space-between; align-items: center; min-height: 44px; flex-wrap: wrap; gap: 8px; margin-top: 8px; background: var(--surface); z-index: 3; border-top: 1px solid var(--line); }
.lesson-window-footer > div { display: flex; gap: 6px; }

@media (max-width: 800px) and (min-width: 641px) {
  .lesson-when { grid-template-columns: 134px 104px 76px 104px minmax(0, 1fr); }
  .lesson-student, #lesson-window-add { grid-template-columns: 80px minmax(0, 2fr) minmax(0, 1fr) 84px minmax(0, 1fr) 16px; gap: 4px; }
  #lesson-window-students.is-event .lesson-student, #lesson-window-add.is-event { grid-template-columns: 80px minmax(0, 2fr) 84px minmax(0, 1fr) 16px; }
}
@media (max-width: 640px) {
  dialog#lesson-detail { inset: 0; width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; padding: 16px; border: 0; border-radius: 0; }
  #lesson-detail-title { font-size: 13px; }
  #lesson-window-status .badge { padding-inline: 5px; font-size: 10px; }
  #lesson-window-form .dialog-head > button { min-height: 26px; padding: 0 4px; }
  .lesson-parameters { grid-template-columns: minmax(0, 1fr); }
  .lesson-student, #lesson-window-add, #lesson-window-students.is-event .lesson-student, #lesson-window-add.is-event { grid-template-columns: 84px 80px minmax(0, 1fr) 22px; gap: 4px 6px; }
  .lesson-student { padding-block: 5px; }
  .lesson-student-name { grid-column: 2 / 4; grid-row: 1; }
  .lesson-student-mark { grid-column: 1; grid-row: 1; }
  .lesson-student-subscription { display: none; }
  .lesson-student-subscription:has(select) { display: block; grid-column: 2; grid-row: 2; }
  .lesson-charge { grid-column: 1; grid-row: 2; }
  .lesson-student-extra { grid-column: 2 / 5; grid-row: 2; }
  .lesson-student:has(select[data-row-field="subscription_id"]) .lesson-student-extra { grid-column: 3 / 5; }
  .lesson-student-remove { grid-column: -2; grid-row: 1; opacity: 1; }
  .lesson-row-error { grid-column: 1 / -1; }
  #lesson-window-add > .combo { grid-column: 2 / 4; }
}

.calendar-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.calendar-toolbar h2 { flex: 1 1 240px; margin: 0; text-align: center; font-size: 16px; }
.calendar-navigation, .calendar-views { display: flex; gap: 4px; }
.calendar-views .button { padding-inline: 10px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--muted); }
.calendar-legend span::before { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 50%; background: var(--event-color); content: ''; }
.planned { --event-color: var(--accent); }
.individual { --event-color: var(--success); }
.completed { --event-color: var(--muted); }
.overdue { --event-color: var(--danger); }
.cancelled { --event-color: var(--danger); }
.calendar-scroll { width: 100%; max-width: 100%; max-height: calc(100dvh - 190px); overflow: auto; isolation: isolate; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.calendar-scroll:focus-visible { outline: 2px solid var(--accent); }
.calendar-grid { display: grid; grid-template-columns: 60px repeat(var(--days), minmax(0, 1fr)); padding-bottom: 15px; }
.calendar-grid.week { min-width: 1000px; }
.calendar-day-head, .calendar-corner { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); background: var(--surface-soft); text-align: center; text-decoration: none; font-size: 13px; font-weight: 650; }
.calendar-day-head { position: sticky; top: 0; z-index: 5; }
.calendar-corner { position: sticky; top: 0; left: 0; z-index: 6; font-size: 11px; }
.calendar-hours { position: sticky; left: 0; z-index: 3; height: var(--grid-height); background: var(--surface); color: var(--muted); font-size: 11px; }
.calendar-hours span { position: absolute; right: 6px; transform: translateY(-50%); }
.calendar-hours span:first-child { transform: none; }
.calendar-day { position: relative; height: var(--grid-height); min-width: 0; border-left: 1px solid var(--line); background-color: var(--surface); background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 64px); }
.calendar-day::after { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(to bottom, transparent 0 32px, var(--line) 32px 33px, transparent 33px 64px); mask-image: repeating-linear-gradient(to right, #000 0 3px, transparent 3px 6px); content: ''; }
.is-today { background-color: color-mix(in srgb, var(--warning-soft) 65%, var(--surface)); }
.calendar-day-head.is-today { background-color: color-mix(in srgb, var(--warning) 9%, var(--surface-soft)); }
.calendar-slot { position: absolute; left: 0; width: 100%; height: 32px; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.calendar-slot:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.calendar-slot:focus-visible { z-index: 2; outline: 2px solid var(--accent); outline-offset: -2px; }
.calendar-lesson { display: block; min-width: 0; overflow: hidden; padding: 4px 5px; border: 1px solid var(--line); border-bottom: 4px solid var(--event-color); border-radius: 5px; background: var(--accent-soft); color: var(--ink); font-size: 11px; line-height: 1.35; text-decoration: none; overflow-wrap: anywhere; }
.calendar-lesson.timed { position: absolute; z-index: 1; }
.calendar-lesson > * { display: block; }
.calendar-lesson .lesson-time { font-variant-numeric: tabular-nums; }
.calendar-lesson strong { margin-top: 3px; font-weight: 650; }
.calendar-lesson em, .lesson-room { color: var(--muted); }
.calendar-lesson.individual { background: var(--success-soft); }
.calendar-lesson.completed { background: var(--surface-soft); }
.calendar-lesson.cancelled { background: var(--danger-soft); text-decoration: line-through; color: var(--muted); }
@keyframes calendar-overdue-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.calendar-lesson.overdue { background: linear-gradient(100deg, var(--danger-soft) 35%, color-mix(in srgb, var(--danger) 16%, var(--danger-soft)) 50%, var(--danger-soft) 65%); background-size: 200% 100%; animation: calendar-overdue-shimmer 2.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .calendar-lesson.overdue { animation: none; } }
.calendar-lesson:hover { filter: brightness(.96); box-shadow: inset 0 0 0 1px var(--event-color); }
.calendar-lesson:focus-visible { z-index: 2; outline: 2px solid var(--accent); outline-offset: -2px; }
.calendar-now { position: absolute; right: 0; left: 0; z-index: 2; height: 2px; background: var(--danger); pointer-events: none; }
.calendar-now::before { position: absolute; top: -3px; left: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); content: ''; }
.calendar-untimed { margin-top: 16px; }
.schedule-list-view > .bar { position: sticky; top: var(--topbar-h, 52px); z-index: 7; background: var(--page); padding-block: 6px; margin-bottom: 0; }
.schedule-list-view .schedule-day { position: sticky; top: calc(var(--topbar-h, 52px) + var(--schedule-bar-h, 48px)); z-index: 6; background: var(--page); }
.schedule-list { display: grid; gap: 6px; }
.schedule-day { margin: 4px 0 0; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.schedule-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) minmax(80px, .3fr) minmax(150px, .4fr); align-items: center; gap: 8px 16px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--event-color); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.schedule-row > *, .schedule-list-view, .schedule-list-view .bar > * { min-width: 0; }
.schedule-when, .schedule-description { display: grid; gap: 3px; }
.schedule-when { font-variant-numeric: tabular-nums; }
.schedule-row:hover { background: var(--surface-soft); }
.schedule-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.schedule-status .badge { white-space: normal; }
@media (max-width: 640px) {
  .calendar-scroll { max-height: calc(100dvh - 250px); }
  .schedule-row { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 8px; }
  .schedule-list-view .bar > .seg { width: 100%; }
  .schedule-list-view .bar > .seg a { flex: 1; justify-content: center; padding-inline: 4px; font-size: 12px; }
  .schedule-list-view .bar > .seg b { padding-inline: 4px; }
  .schedule-list-view .pagination { flex-wrap: wrap; }
}
.calendar-untimed .compact { display: inline-block; width: min(100%, 240px); margin: 4px; }
.calendar-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.month-weekday { padding: 8px 2px; background: var(--surface-soft); text-align: center; color: var(--muted); font-size: 12px; }
.month-day { min-width: 0; min-height: 156px; padding: 5px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
.month-day.other-month { background: var(--surface-soft); }
.month-date { display: inline-flex; min-width: 28px; min-height: 28px; align-items: center; justify-content: center; border-radius: 50%; font-weight: 650; text-decoration: none; }
.is-today .month-date { background: var(--accent); color: var(--on-accent); }
.month-lesson { margin-top: 4px; border: 0; border-left: 3px solid var(--event-color); border-radius: 3px; white-space: nowrap; text-overflow: ellipsis; }
.month-more { display: block; padding-top: 4px; font-size: 12px; }
details { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
details > summary { min-height: 34px; padding: 7px 12px; color: var(--accent-strong); font-weight: 650; cursor: pointer; }
details pre { max-width: 100%; margin: 0; padding: 14px; overflow: auto; border-top: 1px solid var(--line); color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { padding: 18px 12px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pagination > span { padding-inline: 8px; color: var(--muted); }

.list { display: grid; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.split { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.section-head h2, .section-head h3 { margin: 0; }
.contact { white-space: pre-wrap; overflow-wrap: anywhere; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Payments: bank-app style feed grouped by day. */
.pay-metrics .metric { border-left-width: 1px; border-radius: 14px; }
.pay-feed { display: grid; gap: 12px; margin-top: 12px; }
.pay-day { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.pay-day > header { display: flex; justify-content: space-between; gap: 8px; padding: 9px 14px; background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: capitalize; }
.pay-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.pay-day > header + .pay-row { border-top: 0; }
.pay-avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-size: 13px; font-weight: 700; }
.pay-avatar.in { background: var(--success-soft); color: var(--success); }
.pay-avatar.out { background: var(--danger-soft); color: var(--danger); }
.pay-main { flex: 1; min-width: 0; display: grid; gap: 1px; justify-items: start; }
.pay-main strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pay-main small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.pay-side { flex: none; display: flex; align-items: center; gap: 4px; }
.pay-sum { font-size: 15px; font-weight: 700; }
.pay-sum.in { color: var(--success); }
.pay-sum.out { color: var(--danger); }
.pay-row:has(.pay-sum.out) { background: var(--danger-soft); }
.pay-row.pending .pay-avatar { opacity: .6; }
.status-list { display: flex; gap: 7px; flex-wrap: wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 56px minmax(0, 1fr); }
  .nav-item span { display: none; }
  .brand { justify-content: center; padding: 2px 0 8px; font-size: 0; }
  .brand::before { width: 40px; height: 40px; }
  .nav-item { justify-content: center; padding: 6px; }
  aside.sidebar { padding: 14px 6px; align-items: center; }
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .shell { display: flex; flex-direction: column; min-height: 100vh; }
  aside.sidebar { position: sticky; z-index: 5; top: 0; display: block; width: 100%; height: auto; padding: 10px 12px 8px; overflow: hidden; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 3px 5px 9px; font-size: 16px; }
  .brand::before { width: 36px; height: 36px; }
  .sidebar > p { display: none; }
  nav#nav { display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 3px; scrollbar-width: thin; }
  .nav-item { flex: 0 0 auto; min-height: 44px; padding: 8px 12px; white-space: nowrap; }
  header.topbar { min-height: 82px; align-items: flex-start; padding: 17px 16px; }
  .topbar h1 { font-size: 22px; }
  .topbar p { font-size: 13px; }
  .header-actions { gap: 6px; }
  main#content { padding: 18px 14px 32px; }
  .mode-banner, #notice.notice { margin: 12px 14px 0; padding: 11px 12px; }
  .grid, .grid.two, .grid.three, .form-grid, .split { grid-template-columns: minmax(0, 1fr); }
  .span-all { grid-column: auto; }
  .card { padding: 16px; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar > button, .toolbar > .button { flex-basis: auto; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric { min-height: 92px; padding: 13px; }
  .metric strong { font-size: 22px; }
  .calendar-toolbar { gap: 10px; }
  .calendar-toolbar h2 { flex-basis: 100%; order: -1; font-size: 19px; }
  .calendar-views { flex: 1 1 100%; }
  .calendar-views .button { flex: 1; }
  .calendar-grid { grid-template-columns: 48px repeat(var(--days), minmax(0, 1fr)); }
  .calendar-grid.week { min-width: 1050px; }
  .month-day { min-height: 136px; padding: 2px; }
  .month-date { min-width: 30px; min-height: 36px; }
  .month-lesson { padding: 3px 1px; font-size: 10px; }
  .month-more { font-size: 10px; }
  .record { padding: 13px; }
  .table-wrap { margin-inline: -2px; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  td { display: grid; grid-template-columns: minmax(90px, 35%) minmax(0, 1fr); gap: 10px; overflow-wrap: anywhere; border: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  td:empty { display: none; }
  th, td { padding: 10px 11px; }
  .login-card { padding: 23px; }
  dialog#editor { width: calc(100vw - 16px); max-height: calc(100vh - 16px); border-radius: 14px; }
  dialog#editor form { padding: 17px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .dialog-actions button, .dialog-actions .button { width: 100%; }
  .row { align-items: flex-start; }
}

@media (prefers-reduced-motion: no-preference) {
  button, .button, .nav-item, .record { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
}


/* Headings receive focus programmatically for screen readers; no visible ring needed. */
h2[tabindex="-1"]:focus { outline: none; }

/* ---- T71: compact look, icons, tones, tooltip ---- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { flex: 0 0 auto; width: 18px; height: 18px; vertical-align: -3px; }
.nav-item .icon { width: 19px; height: 19px; }
.nav-item.active .icon { color: var(--accent); }
.issue-mark { margin-left: 6px; color: var(--warning, #b7791f); }
.issue-mark .icon { width: 15px; height: 15px; }
.icon-btn { width: 34px; padding: 0; }
.icon-button { width: 1.5em; height: 1.5em; min-height: 0; padding: 0; vertical-align: middle; border-color: transparent; background: transparent; color: var(--muted); }
.icon-button:hover { border-color: transparent; color: var(--accent); }
.unlink-payment-button { color: color-mix(in srgb, var(--danger) 65%, var(--muted)); font-size: 18px; line-height: 1; }
.unlink-payment-button:hover { color: var(--danger); }
.icon-button .icon { width: 15px; height: 15px; vertical-align: 0; }
.start-correction .icon-button { margin-left: 4px; }
.icon-btn:hover { color: var(--accent); }
button.primary .icon { width: 16px; height: 16px; }
.card h2 .tip, .hint .tip { margin-left: 4px; }

.tip { display: inline-flex; align-items: center; vertical-align: middle; color: var(--info); border-radius: 50%; cursor: help; }
.tip .icon { width: 15px; height: 15px; vertical-align: 0; }
.tip:hover, .tip:focus-visible { color: var(--accent-strong); }
.tip:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.tooltip { position: fixed; z-index: 60; max-width: min(280px, calc(100vw - 16px)); padding: 7px 10px; border-radius: 8px; background: var(--ink); color: var(--surface); font-size: 12px; line-height: 1.4; box-shadow: 0 6px 20px rgb(0 0 0 / 25%); pointer-events: none; white-space: pre-line; }

.mode-banner.mirror { border-color: color-mix(in srgb, var(--info) 35%, var(--line)); background: var(--info-soft); color: var(--info); }
.mode-banner .icon { width: 14px; height: 14px; }
.mode-banner .tip { color: inherit; }
p.notice { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; padding: 7px 10px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); font-size: 13px; }
.hint { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; color: var(--muted); font-size: 12px; }

.badge { gap: 4px; }
.badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { border-color: transparent; background: var(--danger-soft); color: var(--danger); }
.badge.muted { border-color: var(--line); background: transparent; color: var(--muted); }
.metric:nth-child(4n+2) { border-left-color: var(--success); }
.metric:nth-child(4n+3) { border-left-color: var(--warning); }
.metric:nth-child(4n+4) { border-left-color: var(--info); }

.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }
tbody tr:hover td { background: var(--surface-soft); }
.record strong { font-weight: 650; }
button.primary { box-shadow: 0 1px 2px rgb(0 0 0 / 12%); }
.toolbar > .button.primary { box-shadow: none; }

@media (max-width: 640px) {
  body { padding-bottom: max(calc(60px + env(safe-area-inset-bottom)), var(--sidebar-height, 0px)); }
  .shell { display: block; }
  aside.sidebar { position: fixed; z-index: 30; inset: auto 0 0; top: auto; display: block; width: 100%; height: auto; padding: 0 0 env(safe-area-inset-bottom); overflow: hidden; border-top: 1px solid var(--line); border-bottom: 0; }
  .brand { display: none; }
  nav#nav { display: flex; gap: 0; padding: 0; overflow-x: auto; }
  .nav-item { flex: 1 0 20%; flex-direction: column; justify-content: center; gap: 2px; min-height: 54px; padding: 6px 4px; border: 0; border-radius: 0; font-size: 10.5px; text-align: center; }
  .nav-item span { display: block; white-space: normal; line-height: 1.1; }
  .nav-item.active { box-shadow: inset 0 3px 0 var(--accent); }
  header.topbar { position: sticky; z-index: 10; top: 0; min-height: 48px; align-items: center; padding: 6px 12px; }
  .topbar h1 { font-size: 17px; }
  main#content { padding: 10px 12px 20px; }
  #notice.notice { margin: 8px 12px 0; }
  button, .button, input, select { min-height: 40px; }
  .nav-item { min-height: 54px; }
  .metric { min-height: 56px; padding: 8px 10px; }
  .metric strong { font-size: 17px; }
  .mode-banner .mode-text { display: none; }
  .mode-banner { padding: 4px 6px; }
  tr { padding: 6px 0; }
  th, td { padding: 4px 10px; }
  .record { padding: 9px 11px; }
  .card { padding: 12px; }
}


.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* Tasks use the CRM palette in both views. */
/* Compact bar: segmented controls, icon view switch, filters in a drop-down panel. */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; }
.bar-end { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg :is(button, a) { min-height: 32px; padding: 4px 10px; border: 0; border-radius: 0; gap: 5px; font-weight: 600; color: var(--muted); }
.seg :is(button, a) + :is(button, a) { border-left: 1px solid var(--line); }
.seg :is(button, a) b { font-weight: 650; font-size: 12px; padding: 0 6px; border-radius: 9px; background: var(--surface-soft); color: var(--ink); }
.seg :is([aria-pressed="true"], [aria-current="page"]) { background: var(--accent-soft); color: var(--accent-strong); }
.seg :is([aria-pressed="true"], [aria-current="page"]) b { background: var(--accent); color: var(--surface); }
.lesson-student-mark [data-lesson-mark="1"][aria-pressed="true"] { background: #22c55e; color: #0a3518; }
.lesson-student-mark [data-lesson-mark="0"][aria-pressed="true"] { background: #b06a6a; color: #2b0f0f; }
.lesson-student-mark [data-lesson-mark=""][aria-pressed="true"] { background: #ffd43b; color: #3d2f00; }
.task-me { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.task-me select { min-height: 32px; width: auto; max-width: 170px; padding-block: 3px; }
.filter-panel { position: relative; }
.filter-panel > summary { list-style: none; min-height: 32px; padding: 4px 10px; }
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary.active, .filter-panel[open] > summary { border-color: var(--accent); color: var(--accent-strong); }
.filter-panel .count { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--surface); font-size: 12px; text-align: center; }
.filter-panel-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; width: min(480px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 16%, transparent); }
.filter-panel-form label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.filter-panel-form .wide, .filter-panel-buttons { grid-column: 1 / -1; }
.account-prefs-form { display: flex; flex-direction: column; gap: 6px; }
.account-prefs-row, .account-prefs-legend { display: grid; grid-template-columns: minmax(90px, 1.4fr) repeat(4, minmax(0, 1fr)); align-items: center; gap: 2px; font-size: 12px; }
.account-prefs-legend { color: var(--muted); text-align: center; font-size: 11px; }
.account-prefs-row > label { position: relative; display: block; cursor: pointer; text-align: center; }
.account-prefs-row input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; cursor: pointer; }
.account-prefs-row label > span { display: block; padding: 5px 0; border: 1px solid var(--line); border-radius: 4px; color: transparent; }
.account-prefs-row input:checked + span { color: var(--accent-strong); border-color: var(--accent); background: var(--surface); }
.account-prefs-row input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.account-prefs-row input:disabled { cursor: default; }
.account-prefs-row label:has(input:disabled) { opacity: .55; cursor: default; }
.account-prefs-preview { border-top: 1px solid var(--line); padding-top: 8px; }
.account-prefs-preview > small { color: var(--muted); }
.customer-account > details[open] { flex-basis: 100%; min-width: 0; }
.customer-account-breakdown { max-width: 60ch; padding: 8px 0 4px; }
.customer-account-breakdown dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  margin: 6px 0 10px;
}
.customer-account-breakdown dd { margin: 0; text-align: right; white-space: nowrap; }
.customer-account-breakdown p { margin: 6px 0 10px; }
.customer-account-breakdown [data-account-tips]:empty { display: none; }
.filter-panel-buttons { display: flex; justify-content: flex-end; gap: 8px; }
/* The native select owns submission; the popover escapes scroll containers and modal clipping. */
.combo { position: relative; display: block; min-width: 0; width: 100%; color: var(--ink); font-weight: 400; }
.combo select.combo-native { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; opacity: 0; pointer-events: none; }
.combo-entry { position: relative; display: block; }
.combo-entry input { padding-right: 34px; }
.combo-entry > button { position: absolute; right: 1px; top: 1px; bottom: 1px; min-height: 0; width: 30px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.combo-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.combo-chips:empty { display: none; }
.combo-chip { display: inline-flex; align-items: center; min-width: 0; max-width: 100%; gap: 4px; padding-left: 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; }
.combo-chip > span { min-width: 0; overflow-wrap: anywhere; }
.combo-chip button { flex: 0 0 26px; min-height: 26px; padding: 0 5px; border: 0; background: transparent; color: inherit; }
.combo-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-height: 30px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 8px; }
.combo-inline:focus-within { border-color: var(--accent); }
.combo-inline .combo-chips { display: contents; }
.combo-inline .combo-chip { max-width: calc(100% - 43px); }
.combo-inline .combo-chip > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.combo-inline .combo-chip button { flex-basis: 20px; min-height: 20px; padding: 0 3px; }
.combo-inline .combo-entry { flex: 1 1 40px; min-width: 40px; }
.combo-inline .combo-entry input { min-height: 24px; padding-block: 0; border: 0; box-shadow: none; background: transparent; }
.lesson-field .combo-inline { min-height: 28px; border: 0; padding-inline: 0; }
.combo-list { position: fixed; inset: auto; z-index: 100; margin: 0; padding: 4px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 16%, transparent); font-size: 14px; font-weight: 400; }
.combo-list[hidden] { display: none; }
.event-schedule { padding: 8px; }
.event-schedule-bar, .event-schedule-month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.event-schedule-bar { position: sticky; top: -8px; z-index: 1; background: var(--surface); padding-block: 4px; }
.event-schedule-bar small, .event-schedule-card small { color: var(--muted); }
.event-schedule-month button { padding: 2px 12px; font-size: 20px; }
.event-schedule-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 3px; }
.event-schedule-weekday { text-align: center; color: var(--muted); }
.event-schedule-day { min-height: 58px; min-width: 0; border-top: 1px solid var(--line); padding-top: 3px; }
.event-schedule-day > small { display: block; padding-left: 3px; color: var(--muted); }
.combo-list.event-schedule .event-schedule-card { display: flex; flex-direction: column; gap: 3px; margin-block: 3px; border-left: 3px solid var(--accent); background: var(--surface-soft); white-space: normal; text-align: left; }
.event-schedule-card[aria-selected="true"] { outline: 1px solid var(--accent); background: var(--accent-soft); }
.event-schedule-grid .event-schedule-card { font-size: 11px; padding: 4px; }
.event-schedule-grid .event-schedule-card small { font-size: 10px; }
.event-schedule-grid .event-schedule-card strong { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.event-schedule-grid .event-schedule-card small:last-child:not(:first-child) { display: none; }
.event-schedule-agenda section + section { margin-top: 12px; }
.event-schedule-date { font-weight: 600; font-size: 12px; padding: 5px 8px; color: var(--muted); border-bottom: 1px solid var(--line); }
@media (max-width: 640px) {
  .event-schedule-bar { flex-wrap: wrap; }
  .event-schedule-grid { gap: 2px; }
  .event-schedule-day { min-height: 40px; }
  .event-schedule-grid .event-schedule-card { padding: 3px 2px; min-height: 44px; border-left-width: 2px; }
}
.combo-list [role="option"], .combo-empty { display: block; padding: 7px 8px; border-radius: 4px; overflow-wrap: anywhere; }
.combo-list [role="option"] { cursor: pointer; }
.combo-list [role="option"]:hover, .combo-list [role="option"].active { background: var(--accent-soft); color: var(--accent-strong); }
/* Removed/archived people: struck through everywhere they remain visible (filters, kept old values). */
select option.archived, .combo-list [role="option"].archived, .combo-chip.archived > span { text-decoration: line-through; color: var(--muted); }
.combo-list [role="option"].archived:hover, .combo-list [role="option"].archived.active { color: var(--accent-strong); }
.combo-empty { color: var(--muted); }
.combo-empty.combo-create-lead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.combo-create-lead button { flex-shrink: 0; }
.task-me .combo { width: 170px; }
@media (max-width: 640px) { .task-me .combo { width: 120px; } }
.bulk-actions { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; color: var(--muted); }
.bulk-actions button[hidden] { display: none; }
.bulk-actions .icon-text, .task-other > summary { min-height: 30px; padding: 3px 8px; font-weight: 600; }
/* Bulk buttons wake up only when something is selected. */
.bulk-actions .icon-text, .task-other { opacity: .45; pointer-events: none; }
main:has([data-task-select]:checked) .bulk-actions .icon-text, main:has([data-task-select]:checked) .task-other { opacity: 1; pointer-events: auto; }
.task-other > summary { list-style: none; }
.task-other > summary::-webkit-details-marker { display: none; }
.task-other-menu { position: absolute; z-index: 20; display: grid; gap: 4px; margin-top: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 16%, transparent); }
@media (max-width: 640px) {
  .bar .label, .bulk-actions .label { display: none; }
  .bar-end { margin-left: auto; }
  .task-me select { max-width: 120px; }
  .bar-end > .primary { width: 34px; padding: 0; font-size: 0; }
  .filter-panel-form { position: fixed; left: 16px; right: 16px; top: auto; width: auto; grid-template-columns: 1fr; }
}
.task-board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-block: 10px; align-items: start; }
.task-column { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.task-column h2 { font-size: 15px; margin: 0 0 10px; }
.task-column-overdue { border-color: var(--danger); }
.task-column-overdue h2, .task-overdue { color: var(--danger); }
.task-card { display: grid; gap: 8px; margin-block: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow-wrap: anywhere; }
.task-title { color: var(--accent-strong); background: none; border: 0; padding: 0; text-align: left; min-height: 32px; font-weight: 650; }
.task-card .task-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-card input[type="checkbox"], .bulk-actions input[type="checkbox"], [data-task-select], .task-apply input { width: 20px; height: 20px; min-height: 20px; }
.bulk-actions label, .task-apply { display: flex; align-items: center; gap: 6px; margin-right: 6px; }
.task-other { position: relative; }
.task-details { max-width: min(640px, 95vw); overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .task-board { grid-template-columns: 1fr; overflow: visible; }
  .bulk-actions { width: 100%; gap: 6px; }
}

/* Lead board shares the task board columns; width adapts to the pipeline/status count. */
.lead-board { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.lead-more { width: 100%; margin-top: 8px; }

@media (max-width: 640px) {
  .calendar-toolbar { gap: 6px; }
  .calendar-views { flex: 1 1 auto; }
  .calendar-legend { display: none; }
}

/* ---- T72 audit fixes ---- */
td > .cell { min-width: 0; }
.amount { font-variant-numeric: tabular-nums; }
.nav-more { display: none; }
.section-head button.primary { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: transparent; color: var(--accent-strong); box-shadow: none; }
.section-head button.primary:hover { background: var(--accent-soft); }
.tooltip { max-height: 50vh; overflow: auto; }
@media (max-width: 640px) {
  nav#nav { flex-wrap: wrap; overflow: visible; }
  .nav-item:nth-child(n+5):not(.nav-more) { display: none; }
  .nav-more { display: flex; }
  nav#nav.open .nav-item:nth-child(n+5) { display: flex; }
  nav#nav.open .nav-more { order: 99; }
  nav#nav:has(.nav-item:nth-child(n+5).active):not(.open) .nav-more { color: var(--accent-strong); box-shadow: inset 0 3px 0 var(--accent); }
}
.task-email { display: block; }
.nowrap { white-space: nowrap; }
td small.muted { display: block; color: var(--muted); }

/* Shared compact control bars and card action menus. */
.bar-end { flex-wrap: wrap; }
.bar-title { font-size: 15px; margin: 0; }
.seg a { text-decoration: none; }
.action-menu { position: relative; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu-items { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 4px; min-width: 200px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 16%, transparent); }
.action-menu-items button.primary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: none; }
.filter-panel-form { max-height: calc(100dvh - 160px); overflow-y: auto; }
.filter-panel-form input[type="checkbox"] { width: 18px; min-height: 18px; }
.filter-panel-form label.filter-check { display: flex; align-items: center; gap: 6px; }
.filter-panel-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
@media (max-width: 640px) {
  .bar { min-width: 0; }
  .bar .seg :is(button, a) { padding-inline: 8px; }
  .bar-title { font-size: 13px; }
  .bar-end > .primary, .section-head > button.primary { min-width: 34px; width: 34px; padding: 4px; }
  .section-head > button.primary .label { display: none; }
  .action-menu-items .label, .filter-panel-form .label { display: inline; }
  .filter-panel-form { top: 120px; bottom: auto; max-height: calc(100dvh - 136px); }
  .action-menu-items, .task-other-menu { position: fixed; left: 16px; right: 16px; top: 120px; width: auto; max-height: calc(100dvh - 136px); overflow-y: auto; }
}

/* Header quick add: plus-button styled like the neighbouring icon buttons; items are ordinary menu buttons. */
#quick-add > summary { display: inline-flex; align-items: center; justify-content: center; width: 34px; min-height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; }
#quick-add > summary:hover, #quick-add[open] > summary { border-color: var(--accent); color: var(--accent); }
#quick-add-items button { justify-content: flex-start; font-weight: 400; }

/* Header quick search: compact field, results drop down over the page. */
.quick-search { position: relative; display: flex; align-items: center; min-width: 0; color: var(--muted); }
/* Title | centred search | actions: equal side columns keep the search in the middle of the header. */
@media (min-width: 641px) {
  header.topbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 420px) minmax(0, 1fr); }
  .header-actions { justify-self: end; }
}
.quick-search > .icon { position: absolute; left: 9px; pointer-events: none; }
.quick-search input { width: 100%; min-height: 34px; padding: 4px 10px 4px 32px; }
.quick-results { position: absolute; left: 0; top: calc(100% + 4px); z-index: 30; width: max(100%, 320px); max-width: calc(100vw - 32px); max-height: 60vh; overflow-y: auto; margin: 0; padding: 4px; list-style: none; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px rgb(0 0 0 / .16); }
.quick-results li { display: grid; gap: 2px; padding: 7px 9px; border-radius: 7px; color: var(--ink); }
.quick-results li[data-id] { cursor: pointer; }
.quick-results .archived strong, .quick-results .archived small { text-decoration: line-through; }
.quick-results [aria-selected="true"], .quick-results li[data-id]:hover { background: var(--accent-soft); }
/* Mobile-only magnifier that unfolds the search row; hidden on desktop. */
#search-toggle { display: none; }
@media (max-width: 640px) {
  header.topbar { flex-wrap: wrap; row-gap: 6px; }
  #search-toggle { display: inline-flex; width: 34px; min-width: 34px; }
  /* Collapsed by default; body.search-open (the magnifier or «/») unfolds the row. */
  .quick-search { order: 3; flex: 1 0 100%; display: none; }
  body.search-open .quick-search { display: flex; }
  /* «+» pinned to the middle of the row; margins instead of transform so the fixed menu stays viewport-bound. */
  #quick-add { position: absolute; left: 50%; top: 50%; margin: -17px 0 0 -17px; }
  .quick-results { width: 100%; max-width: none; }
}

/* Group members: expandable subscriptions with visit cells. */
.members { display: grid; gap: 6px; }
details.member > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; list-style: none; color: var(--ink); font-weight: 400; }
details.member > summary::-webkit-details-marker { display: none; }
details.member > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.member[open] > summary::before { transform: rotate(90deg); }
details.member > summary .member-stats { margin-left: auto; font-size: 13px; }
details.member > summary button { min-height: 28px; padding: 2px 10px; }
details.member > summary { flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
details.member > summary > strong { min-width: 0; flex: 1 1 6em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.member > summary > .muted, details.member > summary .member-stats, details.member > summary .badge { flex: none; white-space: nowrap; font-size: 13px; }
details.member > summary .member-card, details.member > summary .icon-button { flex: none; display: inline-flex; align-items: center; justify-content: center; }
details.member > summary > strong + * { margin-left: auto; }
details.member > summary .member-stats:empty { display: none; }
.member-body { display: grid; gap: 10px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.sub-visits { display: grid; gap: 6px; }
.sub-visits + .sub-visits { padding-top: 10px; border-top: 1px dashed var(--line); }
.sub-visits.closed, .sub-visits.completed_closed { opacity: .7; }
.sub-visits .meta { margin: 0; }
.warn { color: var(--warning); }
.visits { display: flex; flex-wrap: wrap; gap: 4px; }
.visit { display: inline-flex; flex-shrink: 0; width: 58px; min-width: 58px; height: 44px; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 2px 3px; border: 1px solid transparent; border-radius: 6px; font-size: 12px; line-height: 14px; font-style: normal; font-variant-numeric: tabular-nums; cursor: default; }
.visit.att { background: var(--success-soft); color: var(--success); }
.visit.make { border-color: var(--info); background: var(--info-soft); color: var(--info); }
.visit.miss { border-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.visit.done { background: var(--surface-soft); color: var(--muted); text-decoration: line-through; }
.visit.burn { background: var(--danger-soft); color: var(--danger); }
.visit.left { border: 1px dashed var(--line); background: transparent; }
.visit-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12px; }
.visit-legend span { display: inline-flex; align-items: center; gap: 4px; }
.visit-legend .visit { width: 20px; min-width: 20px; height: 18px; padding: 0; }

.visit span { display: inline-flex; gap: 3px; }
.visit small, .dim { font-size: 10px; opacity: .65; }
.visit small { max-width: 100%; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.visits:has(.day) { align-items: flex-start; }
.day:not(.calendar-grid) { display: flex; flex-direction: column; gap: 3px; }
.day-payments { display: flex; flex-direction: column; gap: 2px; }
.visit-balance { display: block; width: 58px; min-height: 16px; padding: 0 2px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); opacity: .55; font-size: 10px; line-height: 14px; font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-payments.pays-1 { min-height: 16px; }
.day-payments.pays-2 { min-height: 34px; }
.day-payments.pays-3 { min-height: 52px; }
.day-payments.pays-4 { min-height: 70px; }
.visit-payment { display: inline-flex; align-items: center; justify-content: center; width: 58px; min-height: 16px; padding: 0 2px; border: 1px solid var(--success); border-radius: 3px; background: var(--success-soft); color: var(--success); font-size: 10px; line-height: 14px; font-style: normal; font-variant-numeric: tabular-nums; white-space: nowrap; }
.visit-payment span { overflow: hidden; text-overflow: ellipsis; }
.visit-payment.refund { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.visit-payment.correction { border-color: var(--info); color: var(--info); background: repeating-linear-gradient(135deg, var(--info-soft) 0 3px, var(--surface) 3px 5px); }
.visit-payment[data-visit] { cursor: pointer; }
.visit-payment[data-visit]:hover, .visit-payment[data-visit]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.visit-legend .visit-payment { width: 20px; min-height: 4px; height: 4px; padding: 0; }
.lane { display: flex; flex-direction: column; gap: 3px; min-height: 44px; }
.lane.extra { padding-top: 3px; border-top: 1px dashed var(--line); }

/* Events outside a subscription: white background. */
.lane.extra .visit, .sub-visits.outside .visit, .visit.out { border: 1px solid var(--line); background: #fff; }
.visit.out.att, .visit.out.make, .lane.extra .visit.att, .lane.extra .visit.make, .sub-visits.outside .visit.att, .sub-visits.outside .visit.make { color: var(--success); }
.visit.out.done, .lane.extra .visit.done, .sub-visits.outside .visit.done { color: #657a75; }
.visits .visit.out.bad { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.outside-title { text-align: center; color: var(--muted); font-size: 12px; }
.visit-warning { color: var(--danger); }
.visit[data-visit] { cursor: pointer; }
.visit[data-visit]:hover, .visit[data-visit]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
dialog#visit-info { width: min(420px, calc(100vw - 28px)); padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgb(0 0 0 / 25%); }
dialog#visit-info::backdrop { background: rgb(9 24 21 / 55%); }
dialog#visit-info h2 { margin: 0; font-size: 16px; }
dialog#visit-info dd { overflow-wrap: anywhere; white-space: pre-wrap; }
.visit small.short { opacity: .8; }
.visit small.diff { color: var(--danger); font-weight: 700; opacity: 1; }
dialog#visit-info form.visit-makeup { display: grid; gap: 8px; }
dialog#visit-info form.visit-makeup label { display: grid; gap: 3px; }

/* Older subscriptions: compact rows. */
.sub-visits.compact { gap: 3px; }
.compact-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.visits.mini { gap: 2px; }
.visits.mini .visit { min-width: 0; width: 13px; height: 13px; min-height: 0; padding: 0; border-radius: 3px; }
.visits.mini .visit span, .visits.mini .visit small { display: none; }
.visits.mini .visit.done { text-decoration: none; }
.visits.mini .day, .visits.mini .lane { gap: 2px; }
.visits.mini .lane { min-height: 0; flex-direction: row; }
.visits.mini .visit-payment { width: 13px; height: 4px; min-height: 0; padding: 0; }
.visits.mini .visit-payment span { display: none; }
.dim-text { font-size: 12px; }
.sub-wrap.collapsed > .sub-visits:not(.compact), .sub-wrap:not(.collapsed) > .sub-visits.compact { display: none; }
button.sub-title { display: inline-flex; align-items: center; gap: 6px; min-height: 0; padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
button.sub-title::before { content: "▸"; color: var(--muted); }
.sub-wrap:not(.collapsed) button.sub-title::before { content: "▾"; }
button.sub-title:hover { color: var(--accent-strong); }
button.sub-title { justify-self: start; justify-content: flex-start; width: auto; margin: 0; }
.sub-side { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.subscription-closure { font-size: 12px; padding: 4px 8px; }
.subscription-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.subscription-state small { flex-basis: 100%; }
.subscription-close-dialog.alfa-subscription { width: min(820px, calc(100vw - 32px)); }
.subscription-close-dialog .closure-form { display: grid; gap: 10px; margin-top: 16px; }
.subscription-close-dialog h3 { margin: 16px 0 8px; }
.subscription-close-dialog table { font-size: 13px; }
.subscription-close-dialog .closure-debt { border: 1px solid var(--warning); background: var(--warning-soft); color: var(--warning); }
.sub-group { color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; }

/* Subscription titles are centred like the "— вне абонемента —" dividers; group and status stay on the right. */
.sub-visits > .split { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.sub-visits > .split > :first-child { grid-column: 2; justify-self: center; text-align: center; }
.sub-visits > .split > :nth-child(2) { grid-column: 3; justify-self: end; }
@media (max-width: 640px) { .sub-visits > .split { grid-template-columns: 1fr auto; } .sub-visits > .split > :first-child { grid-column: 1; justify-self: start; } .sub-visits > .split > :nth-child(2) { grid-column: 2; } }

dialog.alfa-subscription { width: min(440px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); box-sizing: border-box; overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog.alfa-subscription::backdrop { background: rgb(9 24 21 / 55%); }
.alfa-subscription .wide { grid-column: 1 / -1; }
.alfa-subscription .dialog-actions { gap: 6px; }
.alfa-subscription .alfa-error { color: var(--danger); overflow-wrap: anywhere; }
.alfa-subscription label, .alfa-subscription input { min-width: 0; }
.start-correction { display: flex; align-items: center; gap: 6px; }
.start-correction-dialog form, .start-correction-dialog label { display: grid; gap: 6px; }
.cash-users-dialog form, .cash-users-dialog label { display: grid; gap: 6px; }
.cash-users-dialog h2 { overflow-wrap: anywhere; }
.start-correction-dialog textarea { min-width: 0; width: 100%; box-sizing: border-box; resize: vertical; }

/* Administration is independent of the mirror's domain-write mode. */
.sidebar-footer { margin-top: auto; min-width: 0; width: 100%; }
#admin-link { gap: 8px; padding-inline: 6px; font-size: 12px; }
.build-version { padding: 8px 10px 0; font-size: 10px; color: var(--muted); opacity: .6; overflow-wrap: anywhere; }
.admin-bar { min-height: 42px; margin-bottom: 12px; }
.admin-card .section-head { justify-content: flex-start; }
.admin-card .section-head h2 { margin-right: auto; }
.admin-dialog { width: min(680px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.admin-dialog::backdrop { background: rgb(9 24 21 / 55%); }
.admin-dialog .wide { grid-column: 1 / -1; min-width: 0; }
.admin-dialog ul { padding-left: 20px; }
.admin-dialog li { overflow-wrap: anywhere; }
.admin-error { color: var(--danger); white-space: pre-wrap; }
#admin-role-form { display: grid; gap: 12px; }
#admin-role-form > label { max-width: 420px; }
#admin-role-form td select { min-width: 110px; }
@media (max-width: 900px) and (min-width: 641px) {
  .build-version { padding-inline: 0; font-size: 8px; text-align: center; }
}
@media (max-width: 640px) {
  aside.sidebar { padding-right: 44px; }
  aside.sidebar:has(#admin-link.hidden) { padding-right: 0; }
  .sidebar-footer { position: absolute; right: 0; bottom: env(safe-area-inset-bottom); width: 44px; }
  #admin-link { min-height: 54px; padding-inline: 4px; }
  #admin-link span, .build-version { display: none; }
  .admin-bar { gap: 6px; flex-wrap: nowrap; }
  .admin-bar .seg { min-width: 0; }
  .admin-bar .seg :is(a,button) { font-size: 12px; padding-inline: 5px; }
  .admin-bar .primary .label { display: none; }
  .admin-dialog .form-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-card .section-head { flex-wrap: wrap; }
}

/* A dashed rule between every pair of blocks (subscriptions and "— вне абонемента —"); none inside a collapsible wrapper. */
.sub-visits + .sub-wrap, .sub-wrap + .sub-visits, .sub-wrap + .sub-wrap, .sub-visits + .sub-visits.outside, .sub-wrap + .sub-visits.outside { padding-top: 10px; border-top: 1px dashed var(--line); }
.sub-wrap > .sub-visits + .sub-visits { padding-top: 0; border-top: 0; }

/* Both timelines share the same visit facts/actions; only CSS chooses the view. */
.mobile-events, .mobile-sub-stats, .mobile-sub-brief, .mobile-future, .mobile-sub-menu { display: none; }
.timeline-desktop-actions { display: contents; }
@media (max-width: 640px) {
  .visit-legend, .sub-visits > .visits, .sub-visits > .meta,
  .sub-visits > .compact-row, .timeline-desktop-actions { display: none; }
  .sub-visits.closed, .sub-visits.completed_closed { opacity: 1; }
  .sub-visits > .split { display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
  .sub-visits > .split > .sub-side { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; width: 100%; text-align: left; gap: 6px; }
  .sub-side > :is(strong, .sub-title) { min-width: 0; overflow-wrap: anywhere; }
  .sub-visits:not(.compact) .sub-side > :is(strong, .sub-title) > .muted { display: block; font-size: 11px; font-weight: 400; }
  .sub-side > .sub-title { display: block; }
  .sub-side > .sub-title::before { display: none; }
  .mobile-sub-menu { display: block; }
  .mobile-sub-menu > summary { display: grid; place-items: center; width: 44px; padding: 0; font-size: 22px; }
  .sub-visits.compact .sub-side > .badge, .sub-visits.compact .sub-group { display: none; }
  .sub-visits.compact .sub-side { grid-template-columns: minmax(0, 1fr) auto; }
  .compact .sub-title { font-size: 12px; font-weight: 500; line-height: 1.6; }
  .mobile-sub-brief { display: inline; color: var(--muted); }
  .mobile-sub-stats { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; font-size: 12px; }
  .mobile-sub-stats label { display: grid; gap: 4px; }
  .mobile-sub-stats progress { width: 100%; height: 5px; accent-color: var(--success); }
  .mobile-sub-balance { text-align: right; overflow-wrap: anywhere; }
  .mobile-sub-balance b { display: block; font-size: 14px; }
  .mobile-sub-stats p { grid-column: 1 / -1; margin: 2px 0 0; color: var(--muted); font-size: 11px; }
  .mobile-events { display: grid; min-width: 0; }
  .mobile-visit { display: grid; grid-template-columns: 37px 22px minmax(0, 1fr) auto; gap: 6px; align-items: center; width: 100%; min-height: 52px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); box-shadow: none; font-size: 12px; font-weight: 400; line-height: 1.35; text-align: left; white-space: normal; }
  .mobile-visit:hover { background: var(--surface-soft); }
  .mobile-visit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .mobile-visit-date { font-variant-numeric: tabular-nums; }
  .mobile-visit small { display: block; color: var(--muted); font-size: 10px; }
  .mobile-visit-icon { display: grid; place-items: center; width: 22px; height: 26px; border-radius: 5px; font-size: 16px; }
  .mobile-visit.att .mobile-visit-icon, .mobile-visit.payment .mobile-visit-icon { color: var(--success); background: var(--success-soft); }
  .mobile-visit.make .mobile-visit-icon, .mobile-visit.correction .mobile-visit-icon { color: var(--info); background: var(--info-soft); }
  .mobile-visit.miss .mobile-visit-icon { color: var(--warning); background: var(--warning-soft); }
  .mobile-visit.done .mobile-visit-icon { color: var(--muted); background: var(--surface-soft); text-decoration: line-through; }
  .mobile-visit.burn .mobile-visit-icon, .mobile-visit.refund .mobile-visit-icon { color: var(--danger); background: var(--danger-soft); }
  .mobile-visit-description, .mobile-visit-name { min-width: 0; overflow-wrap: anywhere; }
  .mobile-visit-name { display: block; }
  .mobile-visit-amount { max-width: 92px; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .mobile-payment-balance { margin-top: 3px; }
  .mobile-outside { display: block; color: var(--muted); }
  .mobile-future { display: block; margin: 2px 0 6px; color: var(--muted); font-size: 12px; }
  dialog#visit-info { position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-width: 100%; max-height: 85dvh; box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
}

/* VK dialogs: a filled star marks a message copied to the AlfaCRM communication. */
.vk-star[aria-pressed="true"] .icon { fill: var(--warning); color: var(--warning); }
/* VK chat look: community chat on the left, user chats on the right, a vertical time line between them. */
#vk-dialog-card .ordered-list { background: #edeef0; border-radius: var(--radius); }
.vk-chat { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px; }
.vk-chat::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #c5cad2; }
.vk-msg { position: relative; display: flex; width: 50%; padding-right: 14px; box-sizing: border-box; }
.vk-msg.user { margin-left: 50%; padding: 0 0 0 14px; }
.vk-msg::after { content: ""; position: absolute; top: 12px; right: -5px; width: 8px; height: 8px; border-radius: 50%; background: #5181b8; border: 2px solid #edeef0; }
.vk-msg.user::after { right: auto; left: -5px; background: #4bb34b; }
.vk-bubble { min-width: 0; max-width: 100%; padding: 6px 10px 4px; border-radius: 14px; background: #fff; color: #000; overflow-wrap: anywhere; }
.vk-msg.out .vk-bubble { background: #cce4ff; }
.vk-author { font-size: 13px; font-weight: 600; color: #2a5885; }
.vk-author small { display: block; font-weight: 400; color: #818c99; font-size: 11px; }
.vk-text { white-space: pre-wrap; margin: 2px 0; }
.vk-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: #818c99; }
.vk-meta .icon-button { min-height: 0; min-width: 0; padding: 0 2px; }
.lesson-video-proposal { display:flex; align-items:center; flex-wrap:wrap; gap:4px 10px; padding:4px 16px; font-size:13px; }

.nav-item .nav-short-label { display: none; }

/* Phone layout: keep controls reachable without shrinking text or touch targets. */
@media (max-width: 640px) {
  html { scroll-padding-block: 112px calc(var(--sidebar-height, 72px) + 16px); }
  .shell { min-height: 100dvh; }
  header.topbar { padding-top: max(6px, env(safe-area-inset-top)); gap: 6px 8px; }
  .topbar h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .header-actions { flex-wrap: nowrap; gap: 2px; }
  .header-actions .mode-banner { margin: 0; padding: 4px 3px; gap: 3px; }
  .quick-search { flex-basis: 100%; }
  .quick-search input { min-height: 44px; }
  .quick-results { max-height: 45dvh; overscroll-behavior: contain; }
  .quick-results li[data-id] { min-height: 44px; }
  button, .button, input:not([type="checkbox"]):not([type="radio"]), select,
  .seg :is(button, a), .filter-panel > summary, .bulk-actions .icon-text,
  .task-other > summary { min-height: 44px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea,
  #lesson-window-form :is(input, select, textarea) { font-size: 16px; }
  .icon-btn, .bar-end > .primary, .section-head > button.primary { width: 44px; min-width: 44px; }
  .combo select.combo-native { min-height: 0; }
  .combo-entry > button { min-height: 0; width: 40px; }
  .combo-entry input { padding-right: 42px; }
  .combo-list [role="option"] { min-height: 44px; padding-block: 11px; }
  .combo-chip button { min-width: 36px; min-height: 36px; }
  .bar > *, .section-head > *, .split > *, .row > * { min-width: 0; }
  .bar > .seg { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
  .seg :is(button, a) { flex-shrink: 0; white-space: nowrap; }
  .bar-end { max-width: 100%; }
  .bulk-actions, .section-head { flex-wrap: wrap; }
  .bar-title, .dialog-head h2, .facts dd { overflow-wrap: anywhere; }
  .facts { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 8px; }
  .table-wrap { margin-inline: 0; }
  td { grid-template-columns: minmax(0, 30%) minmax(0, 1fr); gap: 8px; padding-block: 7px; }
  td:not([data-label]), td[data-label=""] { display: block; }
  td:not([data-label])::before, td[data-label=""]::before { display: none; }
  .makeup-form { min-width: 0; }
  .nowrap { white-space: normal; }
  .sub-visits > .split { grid-template-columns: minmax(0, 1fr); }
  .sub-visits > .split > :nth-child(2) { grid-column: 1; justify-self: start; }
  .sub-group { text-align: left; }
  button.sub-title { min-height: 44px; }
  .filter-panel-form, .action-menu-items, .task-other-menu {
    top: max(16px, env(safe-area-inset-top));
    max-height: calc(100dvh - var(--sidebar-height, 72px) - 32px - env(safe-area-inset-top));
    overscroll-behavior: contain;
  }
  .filter-panel-form { z-index: 40; }
  .action-menu-items, .task-other-menu { z-index: 40; }
  dialog#editor { width: calc(100vw - 32px); max-height: calc(100dvh - 32px); }
  dialog#editor form { padding: 12px; }
  .dialog-head { align-items: flex-start; }
  #lesson-window-form .dialog-head { flex-wrap: wrap; }
  .dialog-head > button { flex-shrink: 0; min-width: 44px; }
  .dialog-actions { gap: 8px; }
  #lesson-window-form :is(input, select, textarea) { min-height: 44px; }
  #lesson-window-form .dialog-head > button { min-height: 44px; padding-inline: 10px; }
  /* Multi-selects keep chips beside a short label and move under a long one. */
  #lesson-window-form .lesson-field:has(.combo-inline) { flex-wrap: wrap; column-gap: 6px; padding-block: 2px; }
  #lesson-window-form .lesson-field:has(.combo-inline) .combo { flex: 1 1 180px; }
  /* Student: name on the first line, marks + charge + comment on the second. */
  .lesson-student, #lesson-window-students.is-event .lesson-student { grid-template-columns: auto minmax(0, 1fr) 44px; gap: 4px 6px; padding-block: 8px; }
  .lesson-student-name { grid-column: 1 / 3; grid-row: 1; }
  .lesson-student-mark { grid-column: 1; grid-row: 2; }
  .lesson-student .seg button { width: 44px; min-width: 44px; min-height: 44px; }
  .lesson-student-remove { grid-column: 3; grid-row: 1; }
  .lesson-charge { grid-column: 2; grid-row: 2; }
  .lesson-charge .lesson-currency { width: 100%; max-width: 120px; min-width: 0; }
  .lesson-charge-hint { min-height: 44px; font-size: 11px; }
  .lesson-student-subscription:has(select) { grid-column: 1 / -1; grid-row: 3; }
  .lesson-student .lesson-student-extra,
  .lesson-student:has(select[data-row-field="subscription_id"]) .lesson-student-extra { grid-column: 3; grid-row: 2; justify-content: center; }
  .lesson-student .lesson-student-extra:is(:has(> :not(button):not([hidden])), :has(em)) { grid-column: 1 / -1; grid-row: 4; justify-content: flex-start; }
  #lesson-window-form .lesson-student-extra > * { min-height: 44px; }
  .lesson-window-footer { height: auto; min-height: 60px; padding-block: 8px max(8px, env(safe-area-inset-bottom)); }
  #lesson-window-form .lesson-window-files button, .lesson-window-footer button { min-height: 44px; min-width: 44px; }
  .lesson-window-footer, .lesson-window-footer > div { gap: 4px; }
  #lesson-window-add, #lesson-window-add.is-event { grid-template-columns: minmax(0, 1fr) 44px; }
  #lesson-window-add > .combo { grid-column: 1; }
  nav#nav { align-items: stretch; }
  .nav-item .nav-long-label { display: none; }
  .nav-item .nav-short-label { display: block; }
  .nav-item { min-width: 0; flex-basis: 20%; }
  .nav-item span { overflow-wrap: anywhere; }
  nav#nav.open { max-height: 60dvh; overflow-y: auto; overscroll-behavior: contain; }
}

/* Below ~375px the centred «+» would collide with the mode pill; freshness stays on the refresh screen. */
@media (max-width: 374px) {
  .header-actions .mode-banner { display: none; }
}

/* Leave room for the title and actions on small tablets. */
@media (min-width: 641px) and (max-width: 1000px) {
  header.topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .quick-search { grid-column: 1 / -1; grid-row: 2; }
  .header-actions { grid-column: 2; grid-row: 1; }
  .schedule-row { grid-template-columns: 140px minmax(0, 1fr); }
}
/* Secondary object history, loaded only on request. */
.object-history { box-sizing:border-box; width:min(460px,calc(100vw - 32px)); max-width:calc(100vw - 32px); max-height:75dvh; padding:16px; overflow:auto; }
.object-history .dialog-head h2 { font-size:1rem; }
.object-history ol { list-style:none; margin:0; padding:0; font-size:12px; }
.object-history li { padding:8px 0; border-bottom:1px solid var(--border); overflow-wrap:anywhere; }
.object-history small { display:block; font-size:11px; line-height:1.5; }
.object-history time { font-variant-numeric:tabular-nums; }
.object-history #history-more { margin-top:8px; }

/* Person card: compact expandable blocks (T271) */
.timeline-card[data-hide~="event"] .event-timeline,
.timeline-card[data-hide~="att"] :is(.visits,.mobile-events) :is(.visit.att,.mobile-visit.att),
.timeline-card[data-hide~="make"] :is(.visits,.mobile-events) :is(.visit.make,.mobile-visit.make),
.timeline-card[data-hide~="miss"] :is(.visits,.mobile-events) :is(.visit.miss,.mobile-visit.miss),
.timeline-card[data-hide~="done"] :is(.visits,.mobile-events) :is(.visit.done,.mobile-visit.done),
.timeline-card[data-hide~="burn"] :is(.visits,.mobile-events) :is(.visit.burn,.mobile-visit.burn),
.timeline-card[data-hide~="left"] :is(.visits,.mobile-events) :is(.visit.left,.mobile-visit.left),
.timeline-card[data-hide~="payment"] :is(.visits,.mobile-events) :is(.visit-payment.payment,.mobile-visit.payment),
.timeline-card[data-hide~="refund"] :is(.visits,.mobile-events) :is(.visit-payment.refund,.mobile-visit.refund),
.timeline-card[data-hide~="correction"] :is(.visits,.mobile-events) :is(.visit-payment.correction,.mobile-visit.correction) { display: none; }
.fold > details > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; cursor: pointer; list-style: none; }
.fold > details > summary::-webkit-details-marker { display: none; }
.fold > details > summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .15s; }
.fold > details[open] > summary::after { transform: rotate(180deg); }
.fold > details > summary h2 { display: flex; align-items: center; gap: 6px; margin: 0; }
.fold-sum { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 14px; }
.fold-sum > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.fold-sum .warn { color: var(--danger, #b3261e); font-weight: 600; }
.fold-body { margin-top: 10px; }
.fold-actions { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.fold-line { margin: 0 0 8px; }
.fold-inline { margin-top: 8px; }
.fold-inline > summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.row-menu > summary { display: inline-grid; place-items: center; min-width: 32px; padding: 2px 6px; }
.row-menu .action-menu-items { right: 0; }
.row-menu .makeup-form { display: grid; gap: 6px; min-width: 240px; }
.miss-state.miss { color: var(--danger, #b3261e); font-weight: 600; }
.miss-state.burn { color: var(--muted); }
.contact-list { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; }
.contact-list li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.contact-list .c-ic { color: var(--muted); flex: none; display: inline-flex; }
.contact-list .c-val { overflow-wrap: anywhere; }
.timeline-filter > .action-menu-items { min-width: 220px; }
.timeline-filter .filter-check { display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .fold > details > summary h2 { font-size: 16px; }
  .fold-sum { font-size: 13px; gap: 4px 10px; }
  .fold-body .table-wrap td { padding: 4px 0; }
  .contact-list { gap: 2px; }
  .card > .section-head h2 .muted { font-weight: 400; }
}
.card.fold > details { border: 0; background: none; }
.card.fold > details > summary { padding: 0; min-height: 0; color: var(--ink); }
.card.fold > details > summary h2 { color: var(--ink); }
/* Personal chronology applies only to VK and communication lists. */
.ordered-list.oldest-first { max-height: 420px; overflow: auto; overflow-anchor: none; }
.object-history #history-more[hidden] { display:none; }

.cat-list { display: grid; gap: 14px; margin-top: 10px; }
.cat-group header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 2px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.cat-group header strong { color: var(--ink); font-size: 15px; }
.cat-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; border-top: 1px solid var(--line); }
.cat-main { display: grid; flex: 1; min-width: 0; gap: 6px; }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.cat-bar { display: block; width: 100%; height: 4px; overflow: hidden; border-radius: 2px; background: var(--surface-soft); }
.cat-bar rect { fill: var(--accent); }
.cat-bar rect.out { fill: var(--danger); }
.cat-sum { font-size: 15px; font-weight: 600; }
.cat-sum.out { color: var(--danger); }

/* Person card: photo fetched from the linked VK profile, served by the CRM itself. */
.person-photo-link { float: right; margin: 0 0 10px 12px; }
.person-photo { display: block; max-width: 120px; max-height: 120px; border-radius: 10px; }
/* Lesson window: event poster preview, limited size; the link opens the full image. */
.lesson-window-poster { margin: 10px 0; }
.lesson-window-poster .poster-actions { display: inline-flex; gap: 10px; align-items: center; }
.lesson-window-poster .lesson-poster { display: block; max-width: 100%; max-height: 320px; margin: 8px 0 0; border-radius: 8px; }

.crm-dialog-note .vk-bubble, .crm-dialog-note {border-left:3px solid var(--accent, #b88927); background:rgba(190,150,50,.10)}
audio {display:block; max-width:100%; width:280px; margin-top:6px}

/* Shared indication for forms with explicit saving (UI.md). */
.is-unsaved { border-radius: 8px; outline: 2px solid #c58920; outline-offset: 2px; }
.has-unsaved-changes [type="submit"] { box-shadow: 0 0 0 3px #c5892060; }
[data-unsaved-status] { color: var(--ink); font-size: 12px; }
/* Unsaved-changes rule: the save button frame breathes while the form is dirty. */
button.is-unsaved { animation: unsaved-pulse 1.5s ease-in-out infinite; }
@keyframes unsaved-pulse { 0%, 100% { outline-offset: 2px; } 50% { outline-offset: 6px; } }
@media (prefers-reduced-motion: reduce) { button.is-unsaved { animation: none; } }
.setting-switch { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.setting-switch input { appearance: none; width: 38px; min-width: 38px; min-height: 22px; height: 22px; padding: 2px; border-radius: 20px; background: var(--line); cursor: pointer; }
.setting-switch input::before { content: ''; display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.setting-switch input:checked { background: var(--accent); }
.setting-switch input:checked::before { transform: translateX(14px); }
.setting-switch input:disabled { opacity: .5; cursor: wait; }

.vk-attachment-image { max-width:100%; max-height:320px; }
/* Payment table keeps columns on small screens; only its container scrolls. */
.payment-columns { position: relative; }
.payment-column-options { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: grid; gap: 8px; width: 240px; max-height: calc(100dvh - 160px); overflow-y: auto; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 16%, transparent); }
.payment-column-options label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.payment-column-options input { width: 18px; min-height: 18px; }
.payment-table { max-width: 100%; min-width: 0; }
.payment-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.payment-sort:hover { text-decoration: underline; }
.payment-sort::after { content: ' ↕'; opacity: .4; }
.payment-sort[data-direction="asc"]::after { content: ' ↑'; opacity: 1; }
.payment-sort[data-direction="desc"]::after { content: ' ↓'; opacity: 1; }
.payment-table table { display: table; width: 100%; min-width: max-content; }
.payment-table thead { display: table-header-group; position: static; width: auto; height: auto; clip-path: none; overflow: visible; }
.payment-table tbody { display: table-row-group; width: auto; }
.payment-table tr { display: table-row; width: auto; }
.payment-table .markup-sub-row[hidden] { display: none; }
.payment-table td, .payment-table th { display: table-cell; width: auto; vertical-align: top; }
.payment-table td::before { display: none; }
.payment-table .cell { display: block; max-width: 320px; white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .payment-column-options { position: fixed; left: 16px; right: 16px; top: 120px; width: auto; max-height: calc(100dvh - 136px); }
}
.payment-columns-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Purpose accounting dialogs reuse the compact CRM controls. */
.accounting-dialog { width: min(640px, calc(100vw - 32px)); max-width: calc(100vw - 32px); }
.accounting-dialog input, .accounting-dialog textarea, .accounting-dialog select { max-width: 100%; }
.accounting-dialog .form-grid > div { min-width: 0; }
.accounting-dialog .accounting-error { color: var(--danger, #b43e3e); }
.accounting-dialog .is-unsaved { outline: 1px solid var(--accent, #9470dd); outline-offset: 2px; }
.accounting-dialog .dialog-actions { flex-wrap: wrap; }

.event-payment-picker { width: min(760px, calc(100vw - 32px)); max-height: 90vh; overflow: auto; }
.event-payment-picker [data-results] { overflow-x: auto; }
.pay-main [data-payment-markup] { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.event-payment-picker fieldset { min-width: 0; margin: 12px 0; }
.event-payment-picker input[type="date"]::-webkit-calendar-picker-indicator { display: none; }

/* Own date picker of the payment-link dialog: opens on the event's month. */
.date-pop { position: fixed; z-index: 100; width: 252px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 16%, transparent); font-size: 13px; }
.date-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 4px; }
.date-pop-head button { min-width: 28px; padding: 2px 6px; }
.date-pop-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.date-pop-weekday { color: var(--muted); font-size: 11px; text-align: center; align-self: center; }
.date-pop-day { height: 28px; padding: 0; border: 0; border-radius: 6px; background: none; cursor: pointer; font: inherit; }
.date-pop-day:hover { background: var(--accent-soft); }
.date-pop-day.out { color: var(--muted); }
.date-pop-day.event { background: #ffe58a; font-weight: 600; }
.date-pop-day.value { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Event attribution occupies its own compact column in the financial feed. */
.pay-event { flex: 0 1 220px; min-width: 0; display: grid; gap: 3px; font-size: 12px; }
.pay-event a { min-width: 0; display: grid; color: var(--text); }
.pay-event a > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-event small { color: var(--muted); font-size: 11px; }
@media (max-width: 640px) {
  .pay-row { flex-wrap: wrap; gap: 8px; }
  .pay-row:has([data-payment-markup]) .pay-main { min-width: 120px; }
  .pay-event { flex: 1 1 calc(100% - 52px); margin-left: 52px; order: 3; }
}

/* Object state is preserved in lists, cards, calendars and selected values. */
.object-inactive, .schedule-row.cancelled { text-decoration: line-through; text-decoration-thickness: 1px; }

.person-balance-body { padding-top: 8px; overflow-wrap: anywhere; }
.person-balance-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.person-balance-list small { display: block; color: var(--muted); }
/* Outbound journal: long API diagnostics remain readable on phones. */
.outbound-json { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
/* Student reconciliation calendar. */
.timeline-calendar-link { margin: .35rem 0 .6rem; }
.timeline-calendar-link a { display: inline-flex; align-items: center; gap: .35rem; }
.student-cal-search { display: flex; flex: 1; gap: .3rem; min-width: 160px; }
.student-cal-search input { width: 100%; min-width: 0; }
.student-cal-search button { flex: none; }
.student-cal-month-control { display: flex; align-items: center; gap: .35rem; }
/* В обоих видах bar и навигация закреплены под фактической высотой topbar.
   Строка дней недели, заголовки дней и плавающая шапка ленты идут следом. */
:root { --student-cal-top: 0px; --student-cal-bar-h: 0px; --student-cal-nav-h: 2.75rem; }
.student-cal-controls { position: sticky; top: var(--student-cal-top); z-index: 7; background: var(--page); margin-bottom: 0; padding-bottom: 8px; }
.student-cal-navigation { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; margin: 0 0 .4rem; padding: .3rem 0 .25rem; }
.student-cal-navigation { position: sticky; top: calc(var(--student-cal-top) + var(--student-cal-bar-h)); z-index: 6; background: var(--page); border-bottom: 1px solid var(--line); }
.student-cal-navigation h2 { margin: 0; font-size: 1rem; white-space: nowrap; }
.student-cal-navigation label { display: flex; gap: .4rem; align-items: center; }
@media (max-width: 640px) {
  :root { --student-cal-top: 48px; }
  .student-cal-navigation { gap: .3rem; }
  .student-cal-navigation .button { padding-inline: 6px; min-height: 30px; }
  .student-cal-navigation h2 { font-size: .95rem; }
}
@media (max-width: 360px) {
  .student-cal-navigation { gap: .2rem; }
  .student-cal-navigation h2 { font-size: .8rem; }
  .student-cal-navigation .button { padding-inline: 4px; }
  .student-cal-navigation > a:not(.button) { font-size: .75rem; white-space: nowrap; }
}
.student-calendar { width: 100%; min-width: 0; touch-action: pan-y; }
.student-cal-weekdays, .student-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.student-cal-weekdays { position: sticky; top: calc(var(--student-cal-top) + var(--student-cal-bar-h) + var(--student-cal-nav-h)); z-index: 5; background: var(--page); border-bottom: 1px solid var(--line); }
.student-cal-weekdays span { padding: .25rem .4rem; text-align: center; font-size: .78rem; }
.student-cal-day { min-width: 0; min-height: 170px; border: 1px solid var(--line); padding: .4rem; display: flex; flex-direction: column; gap: .35rem; }
.student-cal-day h3 { margin: 0; font-size: .9rem; }
.student-cal-day.is-today h3 { text-decoration: underline; }
.student-cal-day-week { display: none; }
.student-cal-day-events { flex: 1; display: flex; flex-direction: column; gap: .4rem; }
.student-cal-balance { color: var(--muted); font-size: .72rem; }
.student-cal-balance, .student-cal-feed-float > span { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.student-cal-explain { margin: .4rem 0; }
.student-cal-explain > summary { cursor: pointer; color: var(--muted); width: fit-content; padding: .25rem 0; }
.student-cal-explain > summary:hover { color: var(--accent-strong); }
.student-cal-explain > p { margin: .35rem 0; overflow-wrap: anywhere; }
.student-cal-balance.tip { color: var(--muted); cursor: help; text-decoration: underline dotted color-mix(in srgb, var(--info) 60%, var(--muted)); text-underline-offset: 2px; }
.student-cal-off { color: var(--warning); }
.student-cal-off.unallocated { background: var(--danger); color: var(--danger-soft); padding: .05rem .3rem; border-radius: .25rem; font-weight: 600; width: fit-content; }
.cal-unalloc-link { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.student-cal-day.jump-target { animation: cal-jump-flash 1.6s ease-out; }
@keyframes cal-jump-flash { 0%,55% { background: var(--danger-soft); box-shadow: inset 0 0 0 2px var(--danger); } 100% { background: transparent; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .student-cal-day.jump-target { animation: none; box-shadow: inset 0 0 0 2px var(--danger); } }
.student-cal-payment, .student-cal-lesson { display: flex; flex-direction: column; gap: .2rem; padding: .35rem; border: 1px solid var(--line); border-radius: .3rem; overflow-wrap: anywhere; font-size: .8rem; }
.student-cal-lesson.missed { background: #f5ead8; border-color: #c94b45; }
.student-cal-lesson.attended { background: #e8f3e8; border-color: #4c9a63; }
.student-cal-lesson.cancelled { text-decoration: line-through; text-decoration-thickness: 1px; }
.student-cal-lesson.event { background: #e7eef8; border-color: #4a7fb5; }
.visit.event, .mobile-visit.event { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.student-cal-payment { border-left: 3px solid #2a9375; }
.student-cal-payment.refund { border-left-color: #bf615a; }
.student-cal-payment.correction { border-left-color: #ab8c4c; }
.student-cal-payment .mobile-visit { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; font: inherit; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.student-cal-payment small, .student-cal-lesson small { display: block; }
/* «Лента» календаря ученика: месяцы догружаются при прокрутке вокруг выбранного. */
.student-cal-feed { display: flex; flex-direction: column; gap: 1rem; margin: .75rem 0; }
.student-cal-feed-month { display: flex; flex-direction: column; gap: .4rem; }
.student-cal-feed-month-title { margin: 0; font-size: 1rem; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.student-cal-feed-month-title small { color: var(--muted); }
.student-cal-feed .student-cal-day { min-height: 0; }
.student-cal-feed-day h3 { font-size: .9rem; }
.student-cal-feed-sentinel { min-height: 8px; }
.student-cal-feed-status { margin: .2rem 0; text-align: center; color: var(--muted); font-size: .8rem; }
.student-cal-feed-undated h4 { margin: 0 0 .3rem; font-size: .9rem; }
/* Плавающая шапка ленты: дата текущего дня и его «Конец», события прокручиваются под ней. */
.student-cal-feed-float { position: sticky; top: calc(var(--student-cal-top) + var(--student-cal-bar-h) + var(--student-cal-nav-h)); z-index: 4; display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; background: var(--page); padding: .3rem 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.student-cal-feed-float.idle { visibility: hidden; }
.student-cal-feed-float [data-feed-float-close] { font-weight: 650; }
/* День ленты: события слева, деньги дня — колонкой справа, «Конец» выделен. */
.student-cal-feed-body { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .4rem .8rem; align-items: start; }
.student-cal-feed-money { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: .15rem; border-left: 1px solid var(--line); padding-left: .7rem; min-width: 9.5rem; }
.student-cal-feed-close { font-size: .95rem; }
.student-cal-feed-close b { font-size: 1.15rem; font-weight: 650; }
.student-cal-feed-close span { display: block; font-size: .72rem; color: var(--muted); }
@media (max-width: 640px) {
  .student-cal-feed-money { min-width: 0; padding-left: .5rem; }
  .student-cal-feed-close b { font-size: 1.05rem; }
}
@media (max-width: 360px) {
  .student-cal-feed-float { flex-direction: column; align-items: stretch; gap: .15rem; }
}
@media (max-width: 900px) {
  .student-cal-weekdays, .student-cal-padding { display: none; }
  .student-cal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
  .student-cal-day-week { display: inline; margin-left: .4rem; font-weight: normal; }
}
@media (max-width: 480px) {
  .student-cal-grid { grid-template-columns: minmax(0, 1fr); }
  .student-cal-day { min-height: 110px; }
  .student-cal-navigation label { width: 100%; }
  .student-cal-month-control { font-size: .8rem; }
  .student-cal-grid .student-cal-day h3 { position: sticky; top: calc(var(--student-cal-top) + var(--student-cal-bar-h) + var(--student-cal-nav-h)); z-index: 4; background: var(--page); margin: -.4rem -.4rem 0; padding: .15rem .4rem .05rem; font-size: .85rem; }
}
/* In-flight action: spinner on the trigger button, added/removed by withBusyButton. */
button.busy { opacity: .65; }
button.busy::after { content: ''; display: inline-block; width: .85em; height: .85em; margin-left: .45em; vertical-align: -.1em; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: crm-spin .8s linear infinite; }
@keyframes crm-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { button.busy::after { animation: none; } }
/* Аудит данных: поиск дублей. */
.audit-pair { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); }
.audit-pair:first-of-type { border-top: none; }
.audit-pair > div:first-child { flex: 1 1 auto; min-width: 260px; }
.audit-dialog { width: min(760px, calc(100vw - 32px)); }
.audit-dialog .grid.two { grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.audit-dialog .audit-preview { margin-top: 4px; }
@media (max-width: 640px) { .audit-dialog .grid.two { grid-template-columns: 1fr; } }

/* Event classification and participant intent share the compact lesson dialog. */
.lesson-classification { display:grid; grid-template-columns:1fr 1fr 1.3fr; gap:8px; border:0; padding:8px 0; min-width:0; }
.lesson-classification select { width:100%; min-width:0; }
.lesson-intent { display:flex; flex-wrap:wrap; align-items:center; gap:4px; max-width:100%; }
.lesson-intent-none { color:var(--muted); font-size:12px; }
.lesson-intent select,.lesson-intent input { font-size:11px; min-height:28px; padding:3px 5px; width:auto; max-width:100%; }
.lesson-intent small { font-size:11px; color:var(--muted); }
#lesson-window-add > .lesson-add-actions, #lesson-window-add > .combo { grid-column:1/-1; min-width:0; }
.lesson-add-actions { display:flex; align-items:center; gap:8px; margin:8px 0 0; }
.lesson-add-actions small { font-size:11px; white-space:nowrap; }
.lesson-add-actions [role=group] { display:grid; grid-template-columns:repeat(4,max-content); gap:4px; }
.lesson-add-actions button { display:inline-flex; align-items:center; justify-content:center; gap:4px; height:28px; min-height:28px; font-size:11px; padding:4px 7px; white-space:nowrap; color:var(--muted); background:var(--surface-soft); }
.lesson-add-actions [aria-pressed=true] { border-color:var(--accent); background:var(--accent-soft); color:var(--accent-strong); }
@media(max-width:479px) {
  .lesson-add-actions { flex-wrap:wrap; }
  .lesson-add-actions [role=group] { width:100%; grid-template-columns:repeat(2,minmax(0,1fr)); }
}
.lesson-legacy pre { white-space:pre-wrap; overflow-wrap:anywhere; max-height:180px; overflow:auto; font-size:11px; }
.event-scenarios { width:min(460px,calc(100vw - 32px)); }
.scenario-menu { display:grid; gap:4px; }
.scenario-menu button { text-align:left; display:grid; gap:2px; padding:7px 10px; }
.scenario-menu small { font-size:10px; color:var(--muted); }
.event-basis { font-size:10px; white-space:nowrap; }
#lesson-intent-summary { font-size:12px; margin:8px 0; }
@media(max-width:640px) { .lesson-classification { grid-template-columns:1fr 1fr; } .lesson-classification > :last-child { grid-column:1/-1; } }
/* Lesson editor: aligned participant columns and one secondary-section rhythm. */
#lesson-window-form .lesson-people { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
#lesson-window-form .lesson-people .lesson-field { display: grid; gap: 4px; padding: 0; border: 0; }
#lesson-window-form .lesson-people .combo-inline { border: 1px solid var(--line); padding: 2px 6px; }
#lesson-window-form .lesson-people .combo-chip button { display: none; }
#lesson-window-form .lesson-people .combo-entry { min-width: 70px; }
#lesson-window-form #lesson-window-students .lesson-student { grid-template-columns: 80px 26px minmax(0, 2fr) minmax(0, 3fr) 110px 30px; gap: 8px; min-height: 40px; padding-block: 7px; }
#lesson-window-form #lesson-window-students .lesson-student-mark { grid-column: 1; grid-row: 1; }
#lesson-window-form #lesson-window-students .lesson-student-remove { grid-column: 2; grid-row: 1; opacity: 1; color: var(--muted); border: 1px solid var(--line); background: transparent; min-height: 26px; }
#lesson-window-form #lesson-window-students .lesson-student-remove:hover { color: var(--danger); border-color: var(--danger); }
#lesson-window-form #lesson-window-students .lesson-student-remove:active { background: var(--accent-soft); }
#lesson-window-form #lesson-window-students .lesson-student-name { grid-column: 3; grid-row: 1; overflow: hidden; }
#lesson-window-form #lesson-window-students .lesson-student-basis { grid-column: 4; grid-row: 1; }
#lesson-window-form .lesson-intent { display: flex; flex-wrap: wrap; width: 100%; }
#lesson-window-form .lesson-intent > select { width: auto; min-width: 0; flex: 1 1 155px; font-size: 13px; }
.lesson-intent-extra { display: flex; flex: 0 1 auto; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
#lesson-window-form .lesson-intent-extra input { width: 100%; min-width: 0; font-size: 12px; }
#lesson-window-form .lesson-intent-extra button { min-height: 26px; padding: 2px 4px; font-size: 11px; white-space: normal; }
.lesson-intent-extra a { font-size: 11px; }
.lesson-intent .lesson-payment-status { overflow-wrap: anywhere; }
.lesson-intent .lesson-payment-status.success { color: var(--success); }
.lesson-intent .lesson-payment-status.warning { color: var(--warning); }
#lesson-window-form [data-lesson-note].has-note { color: var(--accent-strong); border-color: var(--accent); }
#lesson-window-form #lesson-window-students .lesson-student-subscription { display: block; }
#lesson-window-form #lesson-window-students .lesson-student-subscription:empty { display: none; }
#lesson-window-form .lesson-charge { grid-column: 5; grid-row: 1; flex-wrap: nowrap; }
#lesson-window-form .lesson-charge .lesson-currency { width: 110px; min-width: 0; flex: 1; }
#lesson-window-form #lesson-window-students .lesson-student .lesson-student-extra { grid-column: 6; grid-row: 1; }
#lesson-window-form #lesson-window-students .lesson-student-extra > button { width: 30px; }
#lesson-window-form #lesson-window-students .lesson-student-extra:has(input:not([hidden])) { grid-column: 3 / -1; grid-row: 2; }
#lesson-window-form #lesson-window-students .lesson-student.closed { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
#lesson-window-form #lesson-window-students .lesson-student.closed .lesson-student-name { grid-column: 1; }
#lesson-window-form #lesson-window-students .lesson-student.closed .lesson-student-basis { grid-column: 2; }
.lesson-bottom { display: grid; gap: 12px; margin-top: 12px; }
.lesson-accounting { min-width: 0; }
#lesson-window-form .lesson-accounting-toggle { justify-self: start; min-height: 26px; padding: 2px 0; font-size: 12px; font-weight: 400; }
.lesson-accounting-menu { position: fixed; z-index: 100; min-width: 210px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 16%, transparent); }
.lesson-accounting-menu[hidden] { display: none; }
.lesson-accounting-menu button { display: flex; justify-content: flex-start; width: 100%; min-height: 32px; padding: 5px 8px; border: 0; background: transparent; font-size: 13px; font-weight: 400; text-align: left; }
.lesson-accounting-menu button:hover:not(:disabled), .lesson-accounting-menu button:focus-visible { background: var(--accent-soft); }
.lesson-accounting-menu button.current { font-weight: 700; }
#lesson-window-form .lesson-bottom :is(.lesson-section, .card) { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
#lesson-window-form .lesson-files-section { margin: 0; padding: 0; border: 0; min-width: 0; }
.lesson-bottom .section-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
.lesson-bottom .section-head > h3 { flex-shrink: 0; }
.lesson-bottom .section-head > button, .lesson-bottom .section-head > .poster-actions, .lesson-section-actions { margin-left: auto; }
.lesson-section-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.lesson-bottom summary { cursor: pointer; font-weight: 600; }
.lesson-bottom #lesson-event-payments > :last-child { margin-bottom: 0; }
@media (min-width: 560px) and (max-width: 740px) {
  #lesson-window-form #lesson-window-students .lesson-student { grid-template-columns: 80px 26px minmax(0, 2fr) minmax(0, 3fr) 90px 30px; gap: 4px; }
  #lesson-window-form .lesson-charge .lesson-currency { width: 90px; }
}
@media (max-width: 559px) {
  #lesson-window-form #lesson-window-students .lesson-student { grid-template-columns: 132px 26px minmax(0, 1fr) 30px; gap: 8px; }
  #lesson-window-form #lesson-window-students .lesson-student-name { grid-column: 3; }
  #lesson-window-form #lesson-window-students .lesson-student .lesson-student-extra { grid-column: 4; grid-row: 1; }
  #lesson-window-form #lesson-window-students .lesson-student-basis { grid-column: 1 / -1; grid-row: 2; width: calc(100% - 96px); }
  #lesson-window-form .lesson-charge { grid-column: 1 / -1; grid-row: 2; justify-self: end; width: 88px; }
  #lesson-window-form .lesson-charge .lesson-currency { width: 88px; }
  #lesson-window-form #lesson-window-students .lesson-student-extra:has(input:not([hidden])) { grid-column: 1 / -1; grid-row: 3; }
  #lesson-window-form #lesson-window-students .lesson-student.closed { grid-template-columns: minmax(0, 1fr); }
  #lesson-window-form #lesson-window-students .lesson-student.closed .lesson-student-basis { grid-column: 1; grid-row: 2; width: 100%; }
  .lesson-section-actions { width: 100%; }
  .lesson-section-actions button { flex: 1 1 120px; }
}

#lesson-window-form .lesson-files-section details { border: 0; padding: 0; margin: 0; }
#lesson-window-form .lesson-files-section summary { padding: 0; min-height: 0; }

#lesson-window-form .lesson-charge-hint { flex: 0 0 20px; overflow: hidden; font-size: 0; }
#lesson-window-form .lesson-charge-hint::before { content: "↳"; font-size: 13px; }
#lesson-window-form .lesson-bottom > .lesson-legacy > summary { padding: 0; min-height: 0; }

/* «Расчёт»: шапка отчётного периода и расклад по занятиям */
.payroll-head { display: flex; justify-content: center; margin: 10px 0; }
.payroll-period { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 3px 8px; background: var(--surface); }
.payroll-period button { min-height: 28px; }
.payroll-lesson .payroll-finance { border-top: 1px solid var(--line); margin-top: 8px; padding: 8px 0 0; }
.payroll-teacher { display: inline-flex; align-items: center; gap: 6px; }
.payroll-range-error { min-height: 1em; color: var(--danger, #b06a6a); font-size: 12px; }
.payroll-basis::before { content: ''; display: inline-block; width: .62em; height: .62em; margin-inline-end: .42em; border-radius: 50%; background: var(--basis-color, #777); }
.payroll-basis.basis-subscription { --basis-color: #4789dc; }
.payroll-basis.basis-makeup { --basis-color: #dc8b23; }
.payroll-basis.basis-single { --basis-color: #29a36d; }
.payroll-basis.basis-free { --basis-color: #9b75d0; }
.payroll-lesson td:last-child small, .payroll-reward small { display: block; }
.payroll-reward { margin: 8px 0; padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; overflow-wrap: anywhere; }
