@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
    --green: #2f7d5b;
    --green-dark: #245f46;
    --mint-50: #e4efe8;
    --surface-2: #f7faf6;
    --bg: #eff3ee;
    --card: #ffffff;
    --ink: #1e2a23;
    --muted: #69786e;
    --faint: #9aa69d;
    --border: #e0e7df;
    --warn-bg: #f6ebd6;
    --err: #ac4636;
    --ok: #2f7d5b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}
* { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
body {
    margin: 0;
    font-family: "Manrope", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--green-dark); }

/* App shell */
.app-shell { display: flex; align-items: flex-start; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; align-self: stretch; flex: 0 0 238px; width: 238px;
    min-height: 100vh; display: flex; flex-direction: column; gap: 5px;
    background: var(--card); border-right: 1px solid var(--border); padding: 18px 14px;
    z-index: 60;
}
.brand {
    display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px;
    text-decoration: none; color: var(--ink);
}
.brand-mark {
    width: 30px; height: 30px; border-radius: 10px; display: inline-flex;
    align-items: center; justify-content: center; background: var(--green);
    color: #fff; font-weight: 700; font-size: 16px;
}
.brand-name { display: block; font-weight: 700; font-size: 20px; line-height: 1; }
.brand-sub { display: block; margin-top: 3px; color: var(--faint); font-size: 11px; }
.brand.big { font-size: 26px; color: var(--green); }
.sidenav { display: flex; flex-direction: column; gap: 4px; }
.nav-section {
    padding: 12px 8px 3px; color: var(--faint); font-size: 10.5px;
    font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border: none; border-radius: var(--radius-md);
    background: transparent; color: var(--ink); text-align: left; text-decoration: none;
    font: inherit; font-size: 14px; line-height: 1.2; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--mint-50); color: var(--green-dark); font-weight: 700; }
.nav-dropdown { position: relative; }
.nav-parent { padding-right: 8px; }
.nav-caret { margin-left: auto; color: var(--faint); font-weight: 700; }
.nav-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    z-index: 80;
    min-width: 190px;
    display: none;
    padding: 6px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 36px rgba(30, 42, 35, .14);
}
.nav-dropdown:hover .nav-submenu,
.nav-dropdown:focus-within .nav-submenu { display: grid; gap: 3px; }
.nav-subitem {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.2;
}
.nav-subitem:hover { background: var(--surface-2); }
.nav-subitem.active { background: var(--mint-50); color: var(--green-dark); font-weight: 700; }
.nav-icon {
    width: 22px; height: 22px; flex: 0 0 22px; display: inline-flex;
    align-items: center; justify-content: center; color: var(--muted);
    font-size: 15px; font-weight: 700;
}
.nav-item.active .nav-icon { color: var(--green-dark); }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.userbox { display: flex; align-items: center; gap: 9px; padding: 0 6px 9px; min-width: 0; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; display: inline-flex;
    align-items: center; justify-content: center; background: var(--green); color: #fff;
    font-size: 13px; font-weight: 700;
}
.username { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.userbox .role { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.logout { margin-top: 2px; }
.main-shell { flex: 1; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
    padding: 15px 26px; background: rgba(247,250,246,.92);
    backdrop-filter: blur(6px); border-bottom: 1px solid var(--border);
}
.topbar-kicker { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.topbar-title { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-chips { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card); color: var(--ink); font-size: 12.5px; font-weight: 600;
}
.datetime-chip { min-width: 230px; justify-content: center; color: var(--green-dark); }
.chip.dark { background: var(--ink); border-color: var(--ink); color: #fff; }

.container { max-width: 1100px; margin: 22px auto; padding: 0 18px; }
.container.wide { max-width: 1360px; }
.app-shell .container { max-width: 1280px; margin: 0 auto; padding: 24px 26px 52px; }
.app-shell .container.wide { max-width: 1500px; }
.app-shell .container.expenses-container { max-width: none; width: 100%; }
.app-shell .container.leads-container,
.app-shell .container.communications-container,
.app-shell .container.tasks-container { max-width: none; width: 100%; margin: 0; padding-left: 18px; padding-right: 18px; }
.app-shell .container.clients-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 18px;
    padding-right: 18px;
}
.app-shell .container.staff-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 18px;
    padding-right: 18px;
}
.app-shell .container.passes-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 18px;
    padding-right: 18px;
}
.app-shell .container.catalog-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 18px;
    padding-right: 18px;
}
.app-shell .container.classes-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 10px 12px 44px;
}
.app-shell .container.teacher-payroll-container {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 18px;
    padding-right: 18px;
}
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); }
.muted { color: var(--muted); }
code { background: #eef2ee; padding: 1px 5px; border-radius: 4px; }
.page-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.page-header h1 { margin: 0; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.dashboard-cards { grid-template-columns: repeat(3, minmax(320px, 1fr)); align-items: start; }
.dashboard-title-form {
    margin: 0 0 16px;
}
.dashboard-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0;
}
.dashboard-month-link {
    padding: 2px 0;
    border-bottom: 1px dashed var(--green);
    color: var(--green-dark);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}
.dashboard-month-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.dashboard-month-picker:hover .dashboard-month-link { color: var(--green); }
.dashboard-month-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}
.dashboard-month-input::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}
.dashboard-month-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card);
    color: var(--green-dark);
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}
.dashboard-month-arrow:hover {
    background: var(--mint-50);
    border-color: #c7d8c5;
}
.dashboard-month-arrow.is-disabled {
    background: var(--surface-2);
    color: var(--faint);
    pointer-events: none;
}
.dashboard-card-revenue { order: 1; }
.dashboard-card-expenses { order: 2; }
.dashboard-card-profit { order: 3; }
.dashboard-card-passes { order: 4; }
.dashboard-card-average { order: 5; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; }
.card-label { color: var(--muted); font-size: 13px; }
.card-value { font-size: 26px; font-weight: 700; margin: 6px 0; }
.card-sub { font-size: 13px; color: var(--muted); }
.revenue-forecast { margin-top: -2px; font-weight: 600; }
.card-value-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0; }
.card-value-row .card-value { margin: 0; }
.revenue-total-row { justify-content: space-between; }
.revenue-total-row .metric-deltas { justify-content: flex-end; }
.metric-deltas { display: flex; gap: 6px; flex-wrap: wrap; }
.metric-delta {
    display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #f7faf6; color: var(--muted); font-size: 12px; font-weight: 600;
}
.metric-delta.up { color: #207449; border-color: #b7ddc4; background: #edf8f0; }
.metric-delta.down { color: #a13e34; border-color: #efc2bd; background: #fff1ef; }
.card-breakdown { margin-top: 10px; display: grid; gap: 6px; }
.revenue-breakdown { padding-top: 8px; border-top: 1px solid var(--border); }
.branch-breakdown-row {
    display: grid; gap: 5px; font-size: 13px; color: var(--muted);
}
.branch-breakdown-row + .branch-breakdown-row { padding-top: 8px; border-top: 1px solid #edf2ec; }
.branch-breakdown-metrics { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.branch-deltas { justify-content: flex-end; flex-wrap: nowrap; }
.branch-deltas .metric-delta { min-height: 22px; padding: 2px 7px; font-size: 11.5px; white-space: nowrap; }
.breakdown-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-size: 13px; color: var(--muted);
}
.breakdown-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-value { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
    .dashboard-cards { grid-template-columns: repeat(2, minmax(300px, 1fr)); }
}

@media (max-width: 640px) {
    .dashboard-cards { grid-template-columns: 1fr; }
}

/* Forms */
.form-card, .filterbar {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 16px; margin-bottom: 18px;
}
.filterbar { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.filter-actions {
    flex: 1 0 100%;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.form-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.form-row.wrap label { flex: 0 0 auto; min-width: 150px; }
.shift-form-section {
    padding: 12px;
    border: 1px solid #d7e6d5;
    border-radius: var(--radius-sm);
    background: #f7fbf6;
}
.shift-card-break { flex-basis: 100%; height: 0; }
label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
label.wide { flex: 1 1 100%; }
label.checkline { flex-direction: row; align-items: center; color: var(--ink); min-width: auto; }
input, select, textarea {
    font-size: 15px; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: #fff; color: var(--ink); min-width: 120px;
    font-family: inherit;
}
textarea { min-width: 100%; resize: vertical; line-height: 1.45; }
input:disabled, select:disabled, textarea:disabled { background: #f7faf6; color: var(--muted); }
label.checkline input[type="checkbox"] { min-width: auto; width: auto; padding: 0; }
.shift-open-checks,
.shift-close-checks {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 0 0 12px;
}
.shift-open-checks .checkline,
.shift-close-checks .checkline {
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.shift-alert-modal { width: min(520px, calc(100vw - 36px)); }
.shift-alert-message { margin: 0 0 14px; color: var(--ink); font-weight: 600; }
.shift-alert-modal .actions[hidden] { display: none !important; }
.shift-alert-modal .modal-header { margin-bottom: 10px; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.plain-fieldset:disabled { opacity: 1; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.modal {
    width: min(980px, calc(100vw - 36px)); max-height: calc(100vh - 48px);
    padding: 0; border: 0; border-radius: var(--radius-md);
    background: var(--card); color: var(--ink);
    box-shadow: 0 24px 70px rgba(30, 42, 35, .22);
}
.modal::backdrop { background: rgba(30, 42, 35, .38); backdrop-filter: blur(2px); }
.modal .form-card { margin: 0; border: 0; border-radius: 0; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 14px;
}
.modal-header h2 { margin: 0; color: var(--ink); }
.modal-close {
    width: 34px; height: 34px; padding: 0; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: #fff; color: var(--muted);
    font-size: 24px; line-height: 1; display: inline-flex; align-items: center;
    justify-content: center;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-form, .expense-modal-form { max-height: calc(100vh - 48px); overflow: auto; }

button { cursor: pointer; font-size: 15px; }
button.primary, .primary {
    background: var(--green); color: #fff; border: none; padding: 10px 18px;
    border-radius: var(--radius-sm); font-weight: 700;
}
button.primary:hover { background: var(--green-dark); }
.primary.small { padding: 4px 10px; font-size: 13px; }
.btn {
    display: inline-block; background: #fff; border: 1px solid var(--border);
    padding: 8px 14px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink);
}
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.disabled {
    color: var(--faint);
    background: #f7faf6;
    cursor: default;
    pointer-events: none;
}
.btn.danger { border-color: #efc2bd; color: var(--err); background: #fff; }
.btn.danger:hover { background: #fff1ef; }
button.link { background: none; border: none; color: var(--green-dark); padding: 0; text-decoration: underline; }
.inline { display: inline; }

/* Tables */
.table-scroll { width: 100%; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
table.grid th { background: var(--surface-2); font-size: 11px; color: var(--faint); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid .strong { font-weight: 700; }
table.grid tr.warn { background: var(--warn-bg); }
table.grid tfoot td { font-weight: 600; background: #f0f4f0; }

.teacher-payroll-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 18px;
}
.teacher-payroll-summary .stat-card {
    display: inline-flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    flex: 1 1 190px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
}
.teacher-payroll-summary .stat-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.teacher-payroll-summary .stat-card strong {
    font-size: 18px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.teacher-payroll-lines-wrap {
    margin-bottom: 24px;
}
.teacher-payroll-lines {
    min-width: 1180px;
}
.teacher-payroll-lines th:nth-child(1),
.teacher-payroll-lines td:nth-child(1),
.teacher-payroll-lines th:nth-child(2),
.teacher-payroll-lines td:nth-child(2),
.teacher-payroll-lines th:nth-child(6),
.teacher-payroll-lines td:nth-child(6),
.teacher-payroll-lines th:nth-child(10),
.teacher-payroll-lines td:nth-child(10) {
    white-space: nowrap;
}
.teacher-payroll-header-actions {
    margin-top: 0;
    margin-left: auto;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.teacher-payroll-finalize-form {
    margin: 0;
}
.teacher-payroll-finalize-form .primary {
    white-space: nowrap;
}
.teacher-payroll-adjustment-modal {
    width: min(1080px, calc(100vw - 36px));
}
.teacher-payroll-adjustment-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}
.teacher-payroll-adjustment-form label {
    min-width: 0;
}
.teacher-payroll-adjustment-form input,
.teacher-payroll-adjustment-form select {
    width: 100%;
    min-width: 0;
}
.teacher-payroll-adjustment-form .btn {
    width: 100%;
    text-align: center;
    white-space: normal;
}
.teacher-payroll-adjustment-modal h3 {
    margin: 0 0 10px;
    color: var(--muted);
}

@media (max-width: 1180px) {
    .teacher-payroll-header-actions {
        flex-basis: 100%;
    }
}

@media (max-width: 680px) {
    .teacher-payroll-summary .stat-card {
        flex-basis: 100%;
    }
    .teacher-payroll-header-actions .btn,
    .teacher-payroll-finalize-form,
    .teacher-payroll-finalize-form .primary {
        width: 100%;
    }
    .teacher-payroll-adjustment-form {
        grid-template-columns: 1fr;
    }
}

/* Weekly schedule grid: fixed layout so columns line up across every day. */
.schedule-grid { table-layout: fixed; }
.schedule-grid th:nth-child(1), .schedule-grid td:nth-child(1) { width: 84px; white-space: nowrap; }
.schedule-grid th:nth-child(2), .schedule-grid td:nth-child(2) { width: 30%; }
.schedule-grid th:nth-child(3), .schedule-grid td:nth-child(3) { width: 24%; }
.schedule-grid th:nth-child(4), .schedule-grid td:nth-child(4) { width: 24%; }
.schedule-grid th:nth-child(5), .schedule-grid td:nth-child(5) { width: 120px; }
.schedule-grid td { overflow-wrap: anywhere; }
.schedule-grid tr.daysep td {
    background: var(--surface-2);
    font-weight: 700;
    color: var(--ink);
    text-transform: none;
    letter-spacing: 0;
}

/* CRM schedule board */
.crm-schedule-shell {
    min-height: calc(100vh - 96px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.crm-schedule-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 58px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}
.crm-schedule-period {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 265px;
}
.crm-schedule-arrow {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: #356ea1;
    text-decoration: none;
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
}
.crm-schedule-arrow:hover { background: #eef5fb; }
.crm-schedule-caption {
    min-width: 190px;
    color: #356ea1;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0;
}
.crm-schedule-control {
    min-width: 185px;
    gap: 2px;
    font-size: 11px;
}
.crm-schedule-control input,
.crm-schedule-control select {
    min-width: 0;
    width: 100%;
    height: 34px;
    padding: 5px 9px;
    border-radius: 3px;
    font-size: 14px;
}
.crm-schedule-new {
    height: 34px;
    padding: 7px 14px;
    white-space: nowrap;
}
.crm-schedule-modes {
    display: flex;
    align-items: stretch;
    gap: 18px;
    margin-left: auto;
    align-self: stretch;
}
.crm-schedule-modes a {
    display: inline-flex;
    align-items: center;
    padding: 0 2px;
    border-bottom: 4px solid transparent;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
}
.crm-schedule-modes a.active {
    border-color: #ef5363;
    color: var(--ink);
}
.crm-schedule-board {
    width: 100%;
    overflow: auto;
    background: #fff;
}
.crm-schedule-day-head,
.crm-schedule-day-row {
    display: grid;
    grid-template-columns: 92px minmax(720px, 1fr);
}
.crm-schedule-day-head {
    position: sticky;
    top: 0;
    z-index: 1;
    min-width: 880px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}
.crm-schedule-day-head > div {
    padding: 8px 12px;
    text-align: center;
}
.crm-schedule-day-row {
    min-width: 880px;
    min-height: 126px;
    border-bottom: 1px solid var(--border);
}
.crm-schedule-time-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    border-right: 1px solid var(--border);
    color: var(--ink);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: #fff;
}
.crm-schedule-day-events {
    display: grid;
    gap: 2px;
    padding: 0;
    background: #fff;
}
.crm-schedule-week-grid { min-width: 1260px; }
.crm-schedule-week-head,
.crm-schedule-week-row {
    display: grid;
    grid-template-columns: 92px repeat(7, minmax(160px, 1fr));
}
.crm-schedule-week-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.crm-schedule-week-time-head,
.crm-schedule-week-day {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-right: 1px solid var(--border);
    font-size: 13px;
    font-weight: 800;
}
.crm-schedule-week-day.selected { color: #356ea1; }
.crm-schedule-week-row {
    min-height: 118px;
    border-bottom: 1px solid var(--border);
}
.crm-schedule-week-cell {
    display: grid;
    gap: 2px;
    min-height: 118px;
    padding: 0;
    border-right: 1px solid var(--border);
    background: #fff;
}
.crm-schedule-week-cell.empty {
    background-image: repeating-linear-gradient(
        45deg,
        #ffffff 0,
        #ffffff 2px,
        #f2f4f1 2px,
        #f2f4f1 4px
    );
}
.crm-schedule-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 124px;
    color: #1f2a26;
    text-decoration: none;
    overflow: hidden;
}
.crm-schedule-card.compact { min-height: 116px; }
.crm-schedule-card:hover {
    filter: brightness(.98);
    outline: 2px solid rgba(47, 125, 91, .25);
    outline-offset: -2px;
}
.crm-schedule-room {
    min-height: 20px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, .08);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.crm-schedule-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 8px;
    text-align: center;
}
.crm-schedule-time {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
    font-size: 28px;
    line-height: 1;
    font-weight: 500;
    white-space: nowrap;
}
.crm-schedule-card.compact .crm-schedule-time {
    font-size: 20px;
    line-height: 1;
}
.crm-schedule-time-separator {
    font-size: .72em;
    font-weight: 600;
}
.crm-schedule-name {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 800;
    overflow-wrap: anywhere;
}
.crm-schedule-card.compact .crm-schedule-name { font-size: 13px; }
.crm-schedule-meta {
    font-size: 11px;
    line-height: 1.15;
    font-weight: 700;
}
.crm-schedule-teacher {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.15;
    font-weight: 800;
}
.crm-schedule-card.is-cancelled {
    opacity: .58;
    text-decoration: line-through;
}
.crm-schedule-card.is-full::before {
    content: "НЕТ МЕСТ";
    position: absolute;
    top: 22px;
    left: 0;
    right: 0;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}
.crm-schedule-color-1 { background: #b94259; }
.crm-schedule-color-2 { background: #ecd4eb; }
.crm-schedule-color-3 { background: #7da8a2; }
.crm-schedule-color-4 { background: #536e70; }
.crm-schedule-color-5 { background: #68c7b0; }
.crm-schedule-color-6 { background: #c9b83e; }
.crm-schedule-color-7 { background: #bfe7df; }
.crm-schedule-color-8 { background: #a9adbd; }
.crm-schedule-card.has-custom-color {
    background: var(--schedule-color);
    color: var(--schedule-text);
}
.crm-schedule-color-1,
.crm-schedule-color-4 { color: #fff; }
.crm-schedule-empty {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-weight: 700;
}
.row-actions { display: flex; gap: 12px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
.row-actions .btn { flex: 0 0 auto; }
table.grid td.row-actions { display: table-cell; vertical-align: middle; }
table.grid td.row-actions > * + * { margin-left: 8px; }
table.grid td.row-actions > .inline { display: inline-block; vertical-align: middle; }
table.grid td.row-actions > .btn { vertical-align: middle; }
.expenses-container .form-card, .expenses-container .table-scroll { box-sizing: border-box; width: 100%; }
.expense-table { min-width: 1320px; }
.expense-table .accrual-col { min-width: 190px; white-space: nowrap; }
.expense-table .amount-col { min-width: 130px; white-space: nowrap; }
.expense-table .actions-col { width: 170px; min-width: 170px; white-space: nowrap; }
.leads-container .table-scroll { width: 100%; }
.leads-table { min-width: 1500px; table-layout: fixed; }
.leads-table th:nth-child(1), .leads-table td:nth-child(1) { width: 190px; }
.leads-table th:nth-child(2), .leads-table td:nth-child(2) { width: 180px; }
.leads-table th:nth-child(3), .leads-table td:nth-child(3) { width: 190px; }
.leads-table th:nth-child(4), .leads-table td:nth-child(4) { width: 140px; }
.leads-table th:nth-child(5), .leads-table td:nth-child(5) { width: 170px; }
.leads-table th:nth-child(6), .leads-table td:nth-child(6) { width: 210px; }
.leads-table th:nth-child(7), .leads-table td:nth-child(7) { width: 160px; white-space: nowrap; }
.leads-table th:nth-child(8), .leads-table td.message-col { width: 230px; white-space: normal; }
.leads-table th:nth-child(9), .leads-table td:nth-child(9) { width: 150px; }
.leads-table th:nth-child(10), .leads-table td:nth-child(10) { width: 190px; }
.lead-funnel { display: flex; flex-wrap: wrap; gap: 5px; }
.lead-funnel span {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: 12px;
    color: var(--muted);
    background: #fff;
}
.lead-funnel span.done { background: #e3f3e9; border-color: #b9dfc4; color: var(--ok); font-weight: 700; }
.tasks-table { min-width: 1320px; table-layout: fixed; }
.tasks-table th:nth-child(1), .tasks-table td:nth-child(1) { width: 300px; }
.tasks-table th:nth-child(2), .tasks-table td:nth-child(2) { width: 190px; }
.tasks-table th:nth-child(3), .tasks-table td:nth-child(3) { width: 170px; }
.tasks-table th:nth-child(4), .tasks-table td:nth-child(4) { width: 150px; }
.tasks-table th:nth-child(5), .tasks-table td:nth-child(5) { width: 155px; white-space: nowrap; }
.tasks-table th:nth-child(6), .tasks-table td:nth-child(6) { width: 150px; }
.tasks-table th:nth-child(7), .tasks-table td:nth-child(7) { width: 120px; }
.tasks-table th:nth-child(8), .tasks-table td:nth-child(8) { width: 230px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-title-row h2 { margin: 0; }
.empty-state { padding: 18px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); }
.freeze-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    margin: 8px 0 14px;
}
.freeze-summary-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.two-column-sections { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.communications-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; margin-bottom: 22px; }
.conversation-list, .conversation-detail {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
}
.conversation-list { max-height: 760px; overflow: auto; }
.conversation-card {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
    background: #fff;
    margin-bottom: 8px;
}
.conversation-card.active { border-color: var(--green); background: #f1faf3; }
.conversation-title { font-weight: 700; }
.conversation-meta, .conversation-preview, .conversation-time { color: var(--muted); font-size: 13px; }
.conversation-preview { line-height: 1.35; }
.conversation-header { display: flex; justify-content: space-between; gap: 14px; align-items: start; margin-bottom: 14px; }
.conversation-header h2 { margin: 0 0 4px; }
.conversation-links { display: flex; gap: 10px; margin-top: 6px; }
.message-thread { display: grid; gap: 10px; margin-bottom: 14px; }
.message-bubble { max-width: 78%; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; background: #fff; }
.message-bubble.outbound { margin-left: auto; background: #f1faf3; border-color: #cfe8d4; }
.message-bubble.inbound { margin-right: auto; background: #f7faf6; }
.message-bubble.system, .message-bubble.internal { max-width: 100%; background: #fff9e8; border-color: #f0dfaa; }
.message-meta { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.message-body { white-space: pre-wrap; line-height: 1.45; }
.pager.compact { margin-top: 10px; }
@media (max-width: 1080px) {
    .communications-layout, .two-column-sections { grid-template-columns: 1fr; }
    .conversation-list { max-height: none; }
}
.clients-filterbar .clients-search { flex: 1 1 320px; }
.clients-filterbar .clients-search input { width: 100%; }
.clients-stat-cards { margin-bottom: 18px; grid-template-columns: repeat(4, minmax(180px, 1fr)); }
.clients-container .clients-stat-cards {
    gap: 10px;
    margin-bottom: 12px;
}
.clients-container .clients-stat-cards .card {
    padding: 10px 12px;
}
.clients-container .clients-stat-cards .card-label,
.clients-container .clients-stat-cards .card-sub {
    font-size: 12px;
}
.clients-container .clients-stat-cards .card-value {
    margin: 2px 0;
    font-size: 22px;
    line-height: 1.15;
}
.clients-page-header { margin-bottom: 12px; }
.clients-container .clients-table-wrap { width: 100%; }
.clients-table { min-width: 100%; table-layout: fixed; }
.clients-table th:nth-child(1), .clients-table td:nth-child(1) { width: 250px; }
.clients-table th:nth-child(2), .clients-table td.contact-col { width: 245px; }
.clients-table th:nth-child(3), .clients-table td:nth-child(3) { width: 150px; }
.clients-table th:nth-child(4), .clients-table td:nth-child(4) { width: 190px; }
.clients-table th:nth-child(5), .clients-table td:nth-child(5) { width: 120px; white-space: nowrap; }
.clients-table th:nth-child(6), .clients-table td:nth-child(6) { width: 130px; white-space: nowrap; }
.clients-table th:nth-child(7), .clients-table td:nth-child(7) { width: 150px; white-space: nowrap; }
.clients-table th:nth-child(8), .clients-table td:nth-child(8) { width: 180px; white-space: nowrap; }
.staff-table { min-width: 1180px; table-layout: fixed; }
.staff-table th:nth-child(1), .staff-table td:nth-child(1) { width: 230px; }
.staff-table th:nth-child(2), .staff-table td:nth-child(2) { width: 170px; }
.staff-table th:nth-child(3), .staff-table td:nth-child(3) { width: 170px; }
.staff-table th:nth-child(4), .staff-table td:nth-child(4) { width: 220px; }
.staff-table th:nth-child(5), .staff-table td:nth-child(5) { width: 135px; white-space: nowrap; }
.staff-table th:nth-child(6), .staff-table td:nth-child(6) { width: 160px; }
.staff-table th:nth-child(7), .staff-table td:nth-child(7) { width: 110px; white-space: nowrap; }
.staff-table th:nth-child(8), .staff-table td:nth-child(8) { width: 145px; white-space: nowrap; }
.staff-table th:nth-child(9), .staff-table td:nth-child(9) { width: 180px; white-space: nowrap; }
.groups-table { min-width: 1380px; }
.group-color-palette {
    display: grid;
    grid-template-columns: repeat(6, 18px);
    gap: 4px;
    align-items: center;
}
.color-swatch {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid rgba(31, 42, 38, .18);
    border-radius: 999px;
    background: var(--swatch-color);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}
.color-swatch.selected {
    outline: 2px solid var(--green-dark);
    outline-offset: 2px;
}
.color-swatch.readonly {
    display: inline-block;
    cursor: default;
}
.passes-container .table-scroll { width: 100%; }
.passes-container .clients-stat-cards { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
.passes-table { width: 100%; min-width: 1360px; table-layout: fixed; }
.passes-table th:nth-child(1), .passes-table td:nth-child(1) { width: 230px; }
.passes-table th:nth-child(2), .passes-table td:nth-child(2) { width: 140px; }
.passes-table th:nth-child(3), .passes-table td:nth-child(3) { width: 115px; }
.passes-table th:nth-child(4), .passes-table td:nth-child(4) { width: 115px; }
.passes-table th:nth-child(5), .passes-table td:nth-child(5) { width: 105px; }
.passes-table th:nth-child(6), .passes-table td:nth-child(6) { width: 125px; }
.passes-table th:nth-child(7), .passes-table td:nth-child(7) { width: 145px; }
.passes-table th:nth-child(8), .passes-table td:nth-child(8) { width: 185px; }
.passes-table th:nth-child(9), .passes-table td:nth-child(9) { width: 105px; }
.passes-table th:nth-child(10), .passes-table td:nth-child(10) { width: 135px; }
.passes-table th:nth-child(11), .passes-table td:nth-child(11) { width: 160px; }
.passes-table td { overflow-wrap: anywhere; }
.pass-types-table { width: 100%; min-width: 980px; }
.promo-codes-table { width: 100%; min-width: 1280px; }
.certificates-table { width: 100%; min-width: 100%; }
.class-bookings-table { min-width: 1320px; }
.class-queue-table { min-width: 1180px; }
.sales-table { min-width: 1280px; }
.payments-table { min-width: 1180px; }
.locations-table { min-width: 1120px; }
.locations-table input,
.locations-table select { width: 100%; min-width: 120px; }
.field-hint {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}
.client-drawer {
    position: fixed;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(1120px, calc(100vw - 48px));
    max-width: none;
    height: auto;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    margin: 0;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.client-drawer::backdrop { background: rgba(30, 42, 35, .42); backdrop-filter: blur(2px); }
.client-drawer-body {
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow: auto;
    background: var(--bg);
}
.drawer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    color: var(--muted);
    font-weight: 700;
}
.client-panel { padding: 18px 20px 30px; }
.client-panel-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: -18px -20px 18px;
    padding: 18px 20px 14px;
    background: rgba(247, 250, 246, .96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(6px);
}
.client-panel-header h1 { margin: 4px 0 8px; }
.client-panel-kicker { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.client-drawer-close { flex: 0 0 auto; }
.client-edit-form { margin-bottom: 18px; }
.client-edit-form h2 { margin-top: 0; }
.client-edit-form .form-row label { flex: 1 1 190px; }
.client-edit-form .checkline { flex: 0 0 auto; }
.class-attendance-panel {
    margin-bottom: 18px;
    display: grid;
    gap: 18px;
}
.class-attendance-add {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.class-attendance-add input { width: 100%; }
.class-attendance-section h2 {
    margin: 0 0 10px;
    font-size: 16px;
}
.class-attendance-table {
    width: 100%;
    min-width: 760px;
}
.class-attendance-table td:first-child {
    min-width: 240px;
    white-space: normal;
}
.class-attendance-table td:nth-child(2) {
    width: 170px;
    white-space: nowrap;
}
.class-attendance-table td.row-actions {
    width: 280px;
    white-space: nowrap;
}
.class-attendance-empty {
    padding: 12px 0;
    font-weight: 600;
}
.client-full-page .client-panel { padding: 16px 0 0; }
.client-page-header { align-items: flex-start; }
.client-page-header h1 { margin: 12px 0 8px; }
.client-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.client-summary-cards { margin-bottom: 20px; grid-template-columns: repeat(4, minmax(210px, 1fr)); }
.client-panel > .client-summary-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.client-panel > .client-summary-cards .card {
    min-width: 0;
    padding: 12px;
}
.client-panel > .client-summary-cards .card-value {
    font-size: 20px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}
.client-panel > .client-summary-cards .card-label,
.client-panel > .client-summary-cards .card-sub {
    font-size: 12px;
}
.client-metrics-cards {
    margin-top: -8px;
}
.client-sticky-note {
    margin-bottom: 18px;
    background: #fffaf0;
    border-color: #efdca8;
}
.client-sticky-note h2 {
    margin-top: 0;
}
.client-sticky-note .note-text {
    color: var(--text);
    line-height: 1.5;
    white-space: pre-wrap;
}
.client-delete-form {
    clear: both;
    margin-top: 34px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
.client-activity {
    display: block;
    margin-top: 18px;
    margin-bottom: 30px;
}
.client-activity-content {
    display: flow-root;
}
.client-activity .drawer-loading { min-height: 120px; }
.client-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}
.client-history-grid { margin-top: 8px; }
.client-history-section {
    margin-top: 22px;
}
.client-history-section h2 {
    margin-top: 0;
}
.client-history-table {
    min-width: 860px;
}
.client-history-table td {
    vertical-align: top;
}
.kv-list { margin: 0; display: grid; gap: 8px; }
.kv-list div {
    display: grid;
    grid-template-columns: minmax(130px, 0.42fr) 1fr;
    gap: 12px;
    align-items: start;
    padding: 7px 0;
    border-bottom: 1px solid #edf2ec;
}
.kv-list.compact div { grid-template-columns: 100px 1fr; }
.kv-list dt { color: var(--muted); font-size: 13px; }
.kv-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.channel-grid { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.compact-grid th, .compact-grid td { padding: 7px 9px; }
.external-ids-table { min-width: 820px; }
.external-ids-table code { white-space: nowrap; }
.contact-col { overflow-wrap: anywhere; }
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 12px;
    flex-wrap: wrap;
}
.pager.bottom { margin: 14px 0 0; }
.pager-summary { color: var(--muted); font-size: 13px; font-weight: 600; }
.pager-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager-jump {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.pager-jump label {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}
.pager-jump input {
    width: 78px;
    min-width: 0;
    padding: 4px 8px;
    font-size: 13px;
}
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #eef2ee; }
.tag.ok { background: #e3f3e9; color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: #9a6b00; }
.tag.err { background: #fde8e6; color: var(--err); }
.hint { cursor: help; color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
@media (max-width: 980px) {
    .clients-stat-cards,
    .client-summary-cards { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .client-panel > .client-summary-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .passes-container .clients-stat-cards { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .client-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .two-col { grid-template-columns: 1fr; }
    .clients-stat-cards,
    .client-summary-cards { grid-template-columns: 1fr; }
    .client-panel > .client-summary-cards { grid-template-columns: 1fr; }
    .passes-container .clients-stat-cards { grid-template-columns: 1fr; }
    .kv-list div { grid-template-columns: 1fr; gap: 2px; }
    .client-drawer {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }
    .client-drawer-body {
        max-height: calc(100vh - 16px);
        max-height: calc(100dvh - 16px);
    }
    .client-panel { padding: 16px 14px 26px; }
    .client-panel-header { margin: -16px -14px 16px; padding: 16px 14px 12px; }
}

/* Flash */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.flash.ok { background: #e3f3e9; color: var(--ok); }
.flash.err { background: #fde8e6; color: var(--err); }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
    background: #fff; border: 1px solid var(--border); border-radius: 16px;
    padding: 32px; width: 340px; display: flex; flex-direction: column; gap: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.06);
}
.login-card-wide { width: min(420px, calc(100vw - 32px)); }
.login-card label { color: var(--ink); }
.small-center { text-align: center; font-size: 13px; margin: 0; }

.error-page {
    display: flex;
    justify-content: center;
    padding: 42px 0;
}
.error-card {
    width: min(820px, 100%);
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--card);
    box-shadow: 0 16px 40px rgba(30, 42, 35, .08);
}
.error-code {
    display: inline-flex;
    margin-bottom: 10px;
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    background: #fde8e6;
    color: var(--err);
    font-size: 12px;
    font-weight: 700;
}
.error-page h1 {
    margin-bottom: 8px;
    color: var(--ink);
}
.error-page p {
    max-width: 720px;
    margin: 0 0 18px;
    color: var(--muted);
}
.error-actions {
    margin-top: 18px;
}
.error-actions h2 {
    margin: 0 0 8px;
}
.error-actions ul {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
}
.error-details {
    margin-top: 18px;
}
.error-details summary {
    cursor: pointer;
    color: var(--green-dark);
    font-weight: 700;
}
.error-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Embedded BI */
/* The embed fills the whole content column: the main shell becomes a flex
   column pinned to the viewport height, the topbar keeps its natural size and
   the dashboard container grows into the rest. No magic header offset, so the
   iframe always reaches the bottom edge regardless of the topbar height. */
.main-shell:has(.datalens-container) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}
.app-shell .container.datalens-container {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
    /* Fallback for browsers without :has() — keeps the embed near full height. */
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
    overflow: hidden;
}
.datalens-shell {
    height: 100%;
    overflow: hidden;
}
.datalens-frame {
    display: block;
    width: calc(100% / var(--datalens-scale));
    height: calc(100% / var(--datalens-scale));
    border: 0;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
    transform: scale(var(--datalens-scale));
    transform-origin: top left;
}
.code-block {
    overflow-x: auto;
    margin: 10px 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f7faf6;
}
.section-block {
    margin-top: 24px;
}
.page-header.compact {
    margin-bottom: 12px;
}
.json-pre {
    max-width: 520px;
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 10px 0 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f7faf6;
    font-size: 12px;
    line-height: 1.45;
}

@media (max-width: 880px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        position: static; width: 100%; min-height: 0; flex: none; flex-direction: row;
        flex-wrap: wrap; align-items: center; gap: 4px; padding: 12px 14px;
    }
    .brand { width: 100%; padding: 4px 6px 8px; }
    .sidenav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .nav-section, .sidebar-footer { display: none; }
    .nav-item { width: auto; padding: 8px 10px; }
    .nav-icon { width: auto; flex-basis: auto; }
    .main-shell { width: 100%; }
    .topbar { position: static; padding: 14px 18px; }
    .topbar-chips { margin-left: 0; }
    .app-shell .container { padding: 20px 18px 42px; }
    /* On narrow screens the sidebar stacks on top, so the embed can't own the
       full viewport height — fall back to a fixed share of the screen. */
    .main-shell:has(.datalens-container) {
        display: block;
        height: auto;
        overflow: visible;
    }
    .app-shell .container.datalens-container {
        flex: none;
        height: 78vh;
        height: 78dvh;
        min-height: 520px;
        padding: 0;
    }
}
