/* ═══════════════════════════════════════════════════════════════
   RepeatKnow — Main CSS
   Sections:
     1. CSS Variables & Base (lines ~1-70)
     2. Navbar (lines ~75-236)
     3. Page Header (lines ~237-257)
     4. Buttons (lines ~258-334)
     5. Tables (lines ~336-388)
     6. Forms (lines ~389-454)
     7. Detail Grid (lines ~456-494)
     8. Calendar (lines ~495-631)
     9. Stats (lines ~633-784)
    10. Empty State & Quick Actions (lines ~786-825)
    11. Weekly Time Grid (lines ~827-1057)
    12. Member List (lines ~1059-1080)
    13. Auth (lines ~1100-1125)
    14. Alerts (lines ~1126-1149)
    15. Contacts (lines ~1150-1417)
    16. Price Input (lines ~1419-1678)
    17. Lesson Form (lines ~1685-1895)
    18. Modal (lines ~1955-2100)
    19. Responsive (lines ~2113-2605)
    20. Inline Pills (lines ~2607-2701)
    21. Homework (lines ~2703-2928)
    22. Lesson Detail Modal (lines ~2929-2996)
    ═══════════════════════════════════════════════════════════════ */

/* ─── 1. CSS Variables & Base ──────────────────────── */
:root {
    --ink: #2D2D2D;
    --ink-light: #5A5A5A;
    --ink-muted: #8A8A8A;
    --paper: #F8F6F1;
    --paper-warm: #F3EFE8;
    --white: #FFFFFF;
    --sage: #5B8A72;
    --sage-dark: #4A7460;
    --sage-light: #E8F0EB;
    --clay: #C4956A;
    --clay-light: #F5EDE4;
    --mist: #E8E4DD;
    --mist-light: #F0EDE7;
    --danger: #C0392B;
    --danger-light: #FDECEA;
    --warning: #E67E22;
    --warning-light: #FEF3E2;
    --info: #2980B9;
    --info-light: #EBF5FB;
    --success: #27AE60;
    --success-light: #E8F8F0;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --transition: 0.2s ease;
}

.dark {
    --ink: #E8E4DD;
    --ink-light: #B8B4AD;
    --ink-muted: #8A8A8A;
    --paper: #1A1A1E;
    --paper-warm: #222226;
    --white: #2A2A2E;
    --sage: #6FAA88;
    --sage-dark: #5B8A72;
    --sage-light: #1E2E24;
    --clay: #D4A574;
    --clay-light: #2E2520;
    --mist: #3A3A3E;
    --mist-light: #333336;
    --danger: #E06050;
    --danger-light: #2E1E1C;
    --warning: #E89040;
    --warning-light: #2E2418;
    --info: #5AADE0;
    --info-light: #1A2430;
    --success: #50C878;
    --success-light: #1A2E20;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--ink);
    background: var(--paper);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ─── 2. Navbar ──────────────────────────────────── */
.navbar {
    background: var(--white);
    color: var(--ink);
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    border-bottom: 1px solid var(--mist);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand a {
    color: var(--ink);
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.navbar-brand a span {
    color: var(--sage);
}

.navbar-menu {
    display: flex;
    gap: 5px;
}

.navbar-menu a {
    color: var(--ink-light);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-size: 0.9rem;
}

.navbar-menu a:hover {
    background: var(--mist-light);
    color: var(--ink);
}

.navbar-menu a.active {
    background: var(--sage);
    color: white;
}

.navbar-auth {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name {
    color: var(--ink-light);
    font-size: 0.9rem;
}

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--mist);
    border-radius: 8px;
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
    color: var(--ink);
}

.user-menu-btn:hover {
    border-color: var(--sage);
    background: var(--sage-light);
}

.user-icon {
    color: var(--sage);
    font-size: 0.7rem;
}

.user-menu-arrow {
    font-size: 0.6rem;
    color: var(--ink-muted);
    margin-left: 2px;
}

.dark .navbar-brand img {
    filter: brightness(1.6);
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 180px;
    z-index: 200;
    overflow: hidden;
}

.user-dropdown.open {
    display: block;
}

.user-dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background var(--transition);
}

.user-dropdown-item:hover {
    background: var(--mist-light);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--mist);
    margin: 0;
}

.user-dropdown-logout {
    color: var(--danger);
}

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid var(--mist);
    background: var(--white);
    color: var(--ink-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition);
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--sage);
    color: var(--sage);
    background: var(--sage-light);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--mist);
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ink);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ─── 4. Buttons ─────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink);
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow);
}

.btn:hover {
    background: var(--mist-light);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.btn-primary {
    background: var(--sage);
    color: white;
}

.btn-primary:hover {
    background: var(--sage-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: var(--success);
}

.btn-warning {
    background: var(--warning);
    color: var(--ink);
}

.btn-warning:hover {
    background: var(--warning);
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: var(--info);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-active {
    background: var(--sage);
    color: white;
    border-color: var(--sage);
}

/* ─── 5. Tables ──────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--mist-light);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--mist-light);
}

.data-table th {
    background: var(--paper-warm);
    font-weight: 600;
    color: var(--ink-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: var(--sage-light);
}

.row-highlight {
    background: var(--clay-light);
    animation: highlightFade 2s ease-out;
}

@keyframes highlightFade {
    0% { background: var(--clay-light); }
    100% { background: transparent; }
}

.data-table a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}

.data-table a:hover {
    color: var(--sage);
}

/* ─── 6. Forms ───────────────────────────────────── */
.form {
    max-width: 800px;
}

.form-section {
    background: var(--white);
    padding: 24px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--mist-light);
}

.form-section h3 {
    margin-bottom: 16px;
    color: var(--ink);
    font-size: 1.1rem;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mist-light);
}

.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--ink-light);
    font-size: 0.9rem;
}

.form-row input,
.form-row textarea,
.form-row select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--mist);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--white);
    color: var(--ink);
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(91, 138, 114, 0.15);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ─── 7. Detail Grid ─────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.detail-section {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--mist-light);
}

.detail-section h3 {
    margin-bottom: 16px;
    color: var(--ink);
    font-size: 1.1rem;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mist-light);
}

.detail-section dl {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px;
}

.detail-section dt {
    font-weight: 500;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.detail-section dd {
    color: var(--ink);
}

/* ─── 8. Calendar ────────────────────────────────── */
.calendar-grid {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--mist-light);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--ink);
    color: var(--white);
    text-align: center;
    padding: 12px 0;
    font-weight: 600;
    font-size: 0.9rem;
}

.calendar-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    min-height: 90px;
    padding: 6px;
    border: 1px solid var(--mist-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.calendar-day.today {
    background: var(--sage-light);
}

.day-number {
    font-weight: 600;
    color: var(--ink-muted);
    font-size: 0.85rem;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.day-lessons {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
    overflow-y: auto;
    max-height: 200px;
}

.calendar-lesson {
    font-size: 0.68rem;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--mist-light);
    color: var(--ink-muted);
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1.3;
}

.calendar-lesson-time {
    font-weight: 600;
    margin-right: 2px;
    font-size: 0.62rem;
}

.calendar-lesson-name {
    font-size: 0.6rem;
    opacity: 0.85;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-lesson.status-planned.payment-paid {
    background: var(--info-light);
    color: var(--info);
}

.calendar-lesson.status-planned.payment-unpaid {
    background: var(--mist-light);
    color: var(--ink-muted);
}

.calendar-lesson.status-completed.payment-paid {
    background: var(--success-light);
    color: var(--success);
}

.calendar-lesson.status-completed.payment-unpaid {
    background: var(--danger-light);
    color: var(--danger);
}

.calendar-lesson.status-completed.payment-partial {
    background: var(--warning-light);
    color: var(--warning);
}

.calendar-lesson.status-cancelled.payment-unpaid {
    background: var(--mist-light);
    color: var(--ink-muted);
    text-decoration: line-through;
}

.calendar-lesson.status-cancelled.payment-paid {
    background: var(--mist-light);
    color: var(--danger);
}

.calendar-lesson.status-rescheduled {
    background: var(--mist-light);
    color: var(--ink-muted);
    text-decoration: line-through;
}

/* ─── 9. Stats ───────────────────────────────────── */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 28px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--mist-light);
}

.stat-value {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--sage);
}

.stat-label {
    color: var(--ink-muted);
    margin-top: 6px;
    font-size: 0.9rem;
}

.stats-filter {
    margin-bottom: 20px;
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--mist-light);
}

.stats-quick-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stats-period-label {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.stats-filter-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.stats-student-filter select {
    padding: 8px 12px;
    border: 1px solid var(--mist);
    border-radius: var(--radius-sm, 6px);
    background: var(--white);
    color: var(--ink);
    font-size: 0.9rem;
    min-width: 180px;
    cursor: pointer;
}

.stats-student-filter select:focus {
    outline: none;
    border-color: var(--sage);
}

.stat-card--paid { border-left: 4px solid #27AE60; }
.stat-card--unpaid { border-left: 4px solid #C0392B; }
.stat-card--partial { border-left: 4px solid #E67E22; }

.stat-value--paid { color: #27AE60; }
.stat-value--unpaid { color: #C0392B; }
.stat-value--partial { color: #E67E22; }

.stats-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stats-chart-card {
    background: var(--white);
    padding: 24px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--mist-light, #f0f0f0);
}

.stats-chart-card h3 {
    margin: 0 0 16px 0;
    font-size: 0.95rem;
    color: var(--ink-muted);
    font-weight: 600;
}

.data-table--monthly td {
    vertical-align: middle;
    padding: 10px 12px;
    text-align: center;
}

.data-table--monthly td:first-child {
    text-align: left;
}

.stats-cell-earned {
    font-weight: 600;
    color: var(--ink);
}

.stats-cell-detail {
    font-size: 0.78rem;
    color: var(--ink-muted);
    display: block;
    margin-top: 2px;
}

.data-table--monthly th {
    text-align: center;
}

.data-table--monthly th:first-child {
    text-align: left;
}

.stats-total-col {
    font-weight: 700;
    color: var(--sage);
    text-align: center;
}

.stats-total-row {
    background: var(--paper-warm, #faf8f5);
}

.stats-total-row td {
    font-weight: 700;
    border-top: 2px solid var(--mist);
    text-align: center;
}

.stats-total-row td:first-child {
    text-align: left;
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--ink-muted);
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.empty-state a {
    color: var(--sage);
}

.quick-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

.month-label {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0 20px;
    color: var(--ink);
}

.calendar-jump input[type="month"] {
    padding: 8px 12px;
    border: 1px solid var(--mist);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--ink);
    cursor: pointer;
}

.calendar-jump input[type="month"]:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(91, 138, 114, 0.15);
}

/* === Weekly Time Grid === */
.time-grid-wrapper {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: auto;
    max-height: calc(100vh - 160px);
}

.time-grid {
    display: flex;
    flex-direction: column;
    min-width: 700px;
}

.time-grid-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--white);
    border-bottom: 2px solid var(--mist);
}

.time-grid-corner {
    width: 60px;
    min-width: 60px;
    border-right: 1px solid var(--mist);
    position: sticky;
    left: 0;
    z-index: 20;
    background: var(--white);
}

.time-grid-day-header {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
    border-right: 1px solid var(--mist-light);
}

.time-grid-day-header:last-child {
    border-right: none;
}

.time-grid-day-header .day-name {
    font-size: 0.75rem;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-grid-day-header .day-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
}

.time-grid-day-header .day-count {
    font-size: 0.7rem;
    color: var(--ink-muted);
    margin-top: 2px;
}

.time-grid-day-header.today .day-number {
    background: var(--sage);
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.time-grid-body {
    display: flex;
    position: relative;
}

.time-grid-times {
    width: 60px;
    min-width: 60px;
    border-right: 1px solid var(--mist);
    position: sticky;
    left: 0;
    z-index: 5;
    background: var(--white);
}

.time-label {
    height: 60px;
    padding: 0 8px;
    font-size: 0.7rem;
    color: var(--ink-muted);
    text-align: right;
    border-bottom: 1px solid var(--mist-light);
    line-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-grid-day {
    flex: 1;
    position: relative;
    border-right: 1px solid var(--mist-light);
    overflow: hidden;
}

.time-grid-day:last-child {
    border-right: none;
}

.time-grid-day.today {
    background: rgba(91, 138, 114, 0.04);
}

.hour-line {
    height: 60px;
    border-bottom: 1px solid var(--mist-light);
}

.time-lesson {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 0.75rem;
    line-height: 1.3;
    overflow: hidden;
    cursor: pointer;
    border-left: 3px solid;
    transition: box-shadow 0.15s;
}

.time-lesson:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* === Lesson colors: status + payment combined === */
.time-lesson.status-planned.payment-paid {
    background: var(--info-light);
    color: var(--info);
    border-left-color: var(--info);
}

.time-lesson.status-planned.payment-unpaid {
    background: var(--mist-light);
    color: var(--ink-muted);
    border-left-color: var(--ink-muted);
}

.time-lesson.status-planned.payment-partial {
    background: var(--info-light);
    color: var(--info);
    border-left-color: var(--info);
}

.time-lesson.status-completed.payment-paid {
    background: var(--success-light);
    color: var(--success);
    border-left-color: var(--success);
}

.time-lesson.status-completed.payment-unpaid {
    background: var(--danger-light);
    color: var(--danger);
    border-left-color: var(--danger);
}

.time-lesson.status-completed.payment-partial {
    background: var(--warning-light);
    color: var(--warning);
    border-left-color: var(--warning);
}

.time-lesson.status-cancelled.payment-unpaid {
    background: var(--mist-light);
    color: var(--ink-muted);
    border-left-color: var(--ink-muted);
    text-decoration: line-through;
}

.time-lesson.status-cancelled.payment-paid {
    background: var(--mist-light);
    color: var(--danger);
    border-left-color: var(--danger);
}

.time-lesson.status-cancelled.payment-partial {
    background: var(--warning-light);
    color: var(--warning);
    border-left-color: var(--warning);
}

.time-lesson.status-rescheduled {
    background: var(--mist-light);
    color: var(--ink-muted);
    border-left-color: var(--ink-muted);
    text-decoration: line-through;
}

.time-lesson-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.time-lesson-time {
    font-size: 0.65rem;
    opacity: 0.8;
}

.time-break {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--ink-muted);
    pointer-events: none;
    background: repeating-linear-gradient(
        -45deg,
        var(--mist),
        var(--mist) 4px,
        var(--mist-light) 4px,
        var(--mist-light) 8px
    );
    border-top: 1px dashed var(--ink-muted);
    border-bottom: 1px dashed var(--ink-muted);
}

.calendar-jump input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--mist);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--ink);
    cursor: pointer;
}

.calendar-jump input[type="date"]:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(91, 138, 114, 0.15);
}

.member-list {
    list-style: none;
}

.member-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--mist-light);
}

.member-list li a {
    color: var(--info);
    text-decoration: none;
    font-weight: 500;
}

.member-list li a:hover {
    text-decoration: underline;
}


.status-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ─── Auth ────────────────────────────────────────── */
.auth-container {
    max-width: 450px;
    margin: 60px auto;
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.auth-container h1 {
    margin-bottom: 24px;
    text-align: center;
    color: var(--ink);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: var(--ink-muted);
}

.auth-link a {
    color: var(--sage);
    text-decoration: none;
    display: inline-block;
    padding: 8px 4px;
    min-height: 44px;
    line-height: 28px;
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error {
    background: var(--danger-light);
    border: 1px solid var(--danger-light);
    color: var(--danger);
}

.alert-success {
    background: var(--success-light);
    border: 1px solid var(--success-light);
    color: var(--success);
}

.alert-info {
    background: var(--sage-light);
    border: 1px solid var(--sage-light);
    color: var(--sage-dark);
}

.parent-contacts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.parent-contact-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px;
    background: var(--paper-warm);
    border-radius: 8px;
    border: 1px solid var(--mist);
}

.contact-info {
    flex: 1;
}

.contact-info strong {
    color: var(--ink);
}

.contact-notes {
    font-style: italic;
    color: var(--ink-muted);
    margin-top: 4px;
    font-size: 0.85rem;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    border: 1px solid var(--mist);
}

.checkbox-label:hover {
    background: var(--sage-light);
    border-color: var(--mist);
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: var(--sage);
}

.radio-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.2s;
    border: 1px solid var(--mist);
}

.radio-label:hover {
    background: var(--sage-light);
    border-color: var(--mist);
}

.radio-label input[type="radio"] {
    width: auto;
    accent-color: var(--sage);
}

.weekday-list {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-planned {
    background: var(--info-light);
    color: var(--info);
}

.badge-completed {
    background: var(--success-light);
    color: var(--success);
}

.badge-cancelled {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-rescheduled {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-paid {
    background: var(--success-light);
    color: var(--success);
}

.badge-unpaid {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-partial {
    background: var(--warning-light);
    color: var(--warning);
}

.lesson-card {
    background: var(--white);
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.lesson-date {
    font-weight: 600;
    color: var(--ink);
    min-width: 100px;
}

.lesson-time {
    color: var(--ink-muted);
    font-size: 0.9rem;
    min-width: 120px;
}

.lesson-title {
    flex: 1;
    font-weight: 500;
}

.lesson-students {
    display: flex;
    gap: 6px;
}

.student-tag {
    background: var(--mist-light);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--ink-light);
}

.payment-actions {
    display: flex;
    gap: 6px;
}

.contact-links {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s;
}

.contact-phone {
    background: var(--success-light);
    color: var(--success);
}

.contact-phone:hover {
    background: var(--success-light);
}

.contact-tg {
    background: var(--info-light);
    color: var(--info);
}

.contact-tg:hover {
    background: var(--info-light);
}

.contact-wa {
    background: var(--success-light);
    color: var(--success);
}

.contact-wa:hover {
    background: var(--success-light);
}

.contact-vk {
    background: var(--info-light);
    color: var(--info);
}

.contact-vk:hover {
    background: var(--info-light);
}

.contact-email {
    background: var(--clay-light);
    color: var(--clay);
}

.contact-email:hover {
    background: var(--clay-light);
}

.parent-contact-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--mist-light);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--ink-light);
}

.contact-link svg {
    width: 14px;
    height: 14px;
}

.parent-contact-pill .contact-link svg {
    width: 12px;
    height: 12px;
}

.text-muted {
    color: var(--ink-muted);
}

.price-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.price-input-group input {
    flex: 1;
}

.price-label {
    font-size: 0.85rem;
    color: var(--ink-muted);
    white-space: nowrap;
}

.price-priority-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.price-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid var(--mist);
    border-radius: 20px;
    background: var(--white);
    color: var(--ink-light);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.price-pill:hover {
    border-color: var(--sage);
    background: var(--sage-light);
}

.price-pill.active {
    border-color: var(--sage);
    background: var(--sage);
    color: var(--white);
    font-weight: 600;
}

.price-pill .pill-icon {
    font-size: 0.85rem;
}

.price-priority-hint {
    font-size: 0.8rem;
    color: var(--ink-muted);
    margin-top: 4px;
    font-style: italic;
}

.price-single-badge {
    font-size: 0.85rem;
    padding: 6px 12px;
    background: var(--mist-light);
    border-radius: 8px;
    color: var(--ink-light);
}

.group-students-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mist-light);
}

.group-students-header span {
    font-weight: 500;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.group-student-search {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--mist);
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.group-students-list {
    max-height: 300px;
    overflow-y: auto;
}

.group-student-item {
    padding: 10px 12px;
}

.student-price-tag {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--ink-muted);
    background: var(--mist-light);
    padding: 2px 8px;
    border-radius: 10px;
}

.collapsible-table-wrap {
    margin-bottom: 24px;
}

.collapsible-table {
    max-height: 420px;
    overflow: hidden;
    position: relative;
}

.collapsible-table::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--white));
    pointer-events: none;
}

.collapsible-table-wrap[data-collapsed="false"] .collapsible-table {
    max-height: none;
}

.collapsible-table-wrap[data-collapsed="false"] .collapsible-table::after {
    display: none;
}

.collapsible-toggle {
    text-align: center;
    padding: 10px;
    color: var(--sage);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0 0 8px 8px;
    border: 1px solid var(--mist-light);
    border-top: none;
    background: var(--white);
    margin-top: -1px;
}

.collapsible-toggle:hover {
    background: var(--sage-light);
}

.price-rate-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.price-rate-label {
    font-size: 0.82rem;
    color: var(--sage);
    font-weight: 500;
}

.price-input-with-toggle {
    display: flex;
    gap: 12px;
    align-items: center;
}

.price-input-with-toggle input {
    flex: 1;
}

.price-rate-toggle {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Inline price input with pills */
.price-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.price-rate-pills {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.price-pill-sm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 2px solid var(--mist);
    border-radius: 6px;
    background: var(--white);
    color: var(--ink-light);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.price-pill-sm:hover {
    border-color: var(--sage);
    background: var(--sage-light);
}

.price-pill-sm.active {
    border-color: var(--sage);
    background: var(--sage);
    color: var(--white);
}

.price-pill-sm .pill-icon {
    font-size: 0.75rem;
}

.price-rate-btn {
    padding: 6px 14px;
    font-size: 0.85rem;
    border: 2px solid var(--mist);
    background: var(--white);
    color: var(--ink-light);
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 16px;
    font-weight: 500;
}

.price-rate-btn.active {
    background: var(--sage);
    color: var(--white);
    border-color: var(--sage);
}

.price-rate-btn:not(.active):hover {
    background: var(--mist-light);
    border-color: var(--ink-muted);
}

.price-recalc-row {
    background: var(--warning-light);
    border-radius: 6px;
    padding: 4px 8px;
}

/* ─── 17. Lesson Form ────────────────────────────── */
.lesson-form-section {
    margin-bottom: 16px;
}

.lesson-form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-muted);
    margin-bottom: 8px;
}

.lesson-input,
.lesson-select,
.lesson-textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--mist);
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.lesson-input:focus,
.lesson-select:focus,
.lesson-textarea:focus {
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.lesson-textarea {
    resize: vertical;
    min-height: 80px;
}

.format-toggle {
    display: flex;
    background: var(--mist-light);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.format-toggle-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--ink-muted);
}

.format-toggle-btn.active {
    background: var(--white);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.format-toggle-btn:hover:not(.active) {
    color: var(--ink-light);
}

.lesson-form-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--sage);
    text-decoration: none;
    font-weight: 500;
}

.lesson-form-link:hover {
    text-decoration: underline;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--ink-light);
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--mist);
    border-radius: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--sage);
}

.toggle-label input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

.toggle-label input {
    display: none;
}

.weekday-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.weekday-pill {
    width: 44px;
    height: 44px;
    border: 2px solid var(--mist);
    border-radius: 12px;
    background: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.weekday-pill:hover {
    border-color: var(--sage);
    color: var(--sage);
}

.weekday-pill.active {
    background: var(--ink);
    border-color: var(--ink);
    color: white;
}

.radio-group {
    display: flex;
    gap: 8px;
}

.radio-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--mist);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--ink-muted);
    transition: all 0.2s;
}

.radio-pill:has(input:checked) {
    border-color: var(--sage);
    background: var(--sage-light);
    color: var(--sage);
}

.radio-pill input {
    display: none;
}

.lesson-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--mist-light);
}

.lesson-form-actions .btn {
    flex: 1;
    padding: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 12px;
}

.btn-group-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.status-btn {
    padding: 8px 14px;
    border: 1px solid var(--mist);
    border-radius: 8px;
    background: var(--white);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.status-btn:hover {
    border-color: var(--mist);
    color: var(--ink-light);
}

.status-btn.active {
    background: var(--ink);
    border-color: var(--ink);
    color: white;
}

.payment-btn.active[data-val="paid"] {
    background: var(--sage);
    border-color: var(--sage);
}

.payment-btn.active[data-val="partial"] {
    background: var(--warning);
    border-color: var(--warning);
}

.payment-btn.active[data-val="unpaid"] {
    background: var(--danger);
    border-color: var(--danger);
}

/* ─── 19. Responsive ─────────────────────────────── */
@media (max-width: 768px) {
    .format-toggle {
        flex-direction: column;
    }

    .weekday-pills {
        gap: 6px;
    }

    .weekday-pill {
        width: 40px;
        height: 40px;
        font-size: 0.8rem;
    }

    .radio-group {
        flex-direction: column;
    }
}

/* ─── 18. Modal ──────────────────────────────────── */
.modal-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--sage);
    background: var(--sage-light);
    border: 1px solid var(--sage);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.modal-back-btn:hover {
    background: var(--sage);
    color: var(--white);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--ink-muted);
    z-index: 1;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--ink);
}

.modal-body {
    padding: 32px;
}

.modal-body h1 {
    margin-bottom: 24px;
    color: var(--ink);
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-body .form-section {
    box-shadow: none;
    padding: 20px;
}

.modal-body .form-section:first-child {
    padding-top: 0;
}

.modal-body .form-section h3 {
    padding-top: 0;
}

.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: modalIn 0.15s ease;
}

.confirm-dialog {
    background: var(--white);
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.confirm-dialog p {
    margin-bottom: 24px;
    font-size: 1rem;
    color: var(--ink);
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.delete-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delete-option-btn {
    text-align: left;
    padding: 12px 16px;
    width: 100%;
}

.delete-option-btn:hover {
    border-color: var(--sage);
    background: var(--sage-light);
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--ink);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        padding: 0 12px;
        height: auto;
        min-height: 56px;
    }

    .navbar-brand a {
        font-size: 1.1rem;
    }

    .navbar-brand img {
        height: 24px;
        width: 24px;
    }

    /* Unauth navbar: brand + auth may not fit in one line on small screens */
    .navbar:not(:has(.navbar-toggle)) {
        gap: 8px;
    }

    .navbar:not(:has(.navbar-toggle)) .navbar-auth {
        width: 100%;
        justify-content: center;
        border-top: 1px solid var(--mist-light);
        padding-top: 8px;
    }

    .navbar-toggle {
        display: flex;
        order: 1;
        margin-left: auto;
    }

    .navbar-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        order: 3;
        padding: 8px 0 12px;
        gap: 2px;
        border-top: 1px solid var(--mist-light);
    }

    .navbar-menu.open {
        display: flex;
    }

    .navbar-menu a {
        padding: 12px 16px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .navbar-auth {
        order: 2;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .navbar-auth .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .theme-toggle {
        width: 44px;
        height: 44px;
        font-size: 0.9rem;
    }

    .container {
        padding: 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-actions .btn {
        flex: 1;
        min-width: 120px;
        justify-content: center;
        min-height: 44px;
    }

    .quick-actions {
        flex-direction: column;
        gap: 8px;
    }

    .quick-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    /* Tables → horizontal scroll с подсказкой */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .data-table {
        font-size: 0.8rem;
        min-width: 580px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
        white-space: nowrap;
    }

    .data-table th:first-child,
    .data-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--white);
    }

    .lesson-checkbox {
        width: 22px;
        height: 22px;
        cursor: pointer;
    }

    /* Фильтры → вертикальная раскладка */
    .filter-panel form {
        flex-direction: column;
        gap: 12px;
    }

    .filter-panel form > div {
        width: 100%;
    }

    .filter-panel label {
        margin-bottom: 4px;
    }

    .filter-panel input[type="text"],
    .filter-panel input[type="date"],
    .filter-panel select {
        width: 100%;
        min-height: 44px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-section dl {
        grid-template-columns: 1fr;
        gap: 4px 0;
    }

    .detail-section dt {
        margin-top: 8px;
        color: var(--ink-muted);
    }

    .lesson-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .lesson-date,
    .lesson-time {
        min-width: auto;
    }

    .lesson-students {
        flex-wrap: wrap;
    }

    .form-section {
        padding: 16px;
    }

    .form-row input,
    .form-row textarea,
    .form-row select {
        min-height: 44px;
        font-size: 16px; /* Предотвращает зум на iOS */
    }

    .modal {
        padding: 12px 8px;
    }

    .modal-body {
        padding: 20px 16px;
    }

    .modal-body h1 {
        font-size: 1.2rem;
    }

    .calendar-header {
        font-size: 0.8rem;
        padding: 10px 0;
        grid-template-columns: repeat(7, minmax(100px, 1fr));
    }

    .calendar-header div {
        padding: 4px 0;
    }

    .calendar-body {
        grid-template-columns: repeat(7, minmax(100px, 1fr));
        grid-template-rows: auto;
    }

    .calendar-day {
        min-height: 48px;
        padding: 3px 2px;
        border-radius: 6px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .calendar-day.has-lessons {
        cursor: pointer;
    }

    .calendar-day.has-lessons:active {
        background: var(--mist-light);
    }

    .day-number {
        font-size: 0.75rem;
        font-weight: 600;
        margin-bottom: 2px;
        line-height: 1;
    }

    .calendar-day.today .day-number {
        background: var(--ink);
        color: var(--white);
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .day-lessons {
        display: flex;
        flex-direction: column;
        gap: 1px;
        min-height: 0;
        overflow-y: auto;
        max-height: 120px;
    }

    .calendar-lesson {
        font-size: 0.62rem;
        padding: 1px 3px;
    }

    .calendar-lesson-time {
        font-size: 0.58rem;
    }

    .calendar-lesson-name {
        font-size: 0.55rem;
    }

    .calendar-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0;
        padding: 0;
    }

    .calendar-grid {
        min-width: 700px;
        border-radius: 12px;
        padding: 0 8px 8px;
    }

    .calendar-week-day {
        min-height: auto;
        padding: 8px;
    }

    .calendar-week-day .calendar-lesson {
        font-size: 0.75rem;
    }

    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 16px 12px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.78rem;
    }

    .stats-quick-buttons {
        flex-direction: column;
    }

    .stats-quick-buttons .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .stats-filter-row {
        flex-direction: column;
    }

    .stats-student-filter select {
        width: 100%;
    }

    .stats-charts-grid {
        grid-template-columns: 1fr;
    }

    .stats-chart-card {
        padding: 16px;
    }

    .status-actions {
        flex-direction: column;
    }

    .status-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .auth-container {
        margin: 20px auto;
        padding: 24px 16px;
    }

    .parent-contact-card {
        flex-direction: column;
        gap: 10px;
    }

    .weekday-list {
        gap: 8px;
    }

    .checkbox-label,
    .radio-label {
        padding: 10px 12px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    .stats-filter .form-inline {
        flex-direction: column;
    }

    .stats-filter label {
        margin-top: 8px;
    }

    .time-grid-wrapper {
        max-height: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .time-grid {
        min-width: 700px;
    }

    .time-grid-header {
        display: flex;
    }

    .time-grid-corner {
        width: 40px;
        min-width: 40px;
    }

    .time-grid-day-header {
        padding: 6px 2px;
    }

    .time-grid-day-header .day-name {
        font-size: 0.65rem;
    }

    .time-grid-day-header .day-number {
        font-size: 1.1rem;
    }

    .time-grid-day-header .day-count {
        font-size: 0.6rem;
    }

    .time-grid-body {
        display: flex;
    }

    .time-grid-times {
        width: 40px;
        min-width: 40px;
    }

    .time-label {
        height: 60px;
        font-size: 0.6rem;
        padding: 0 4px;
    }

    .time-grid-day {
        min-height: auto;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .page-header h1 {
        font-size: 1.2rem;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }

    .header-actions .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .time-range-picker {
        font-size: 0.75rem;
    }

    .time-range-picker input[type="number"] {
        width: 40px;
        padding: 3px 4px;
        font-size: 0.75rem;
    }

    .calendar-jump input[type="date"] {
        padding: 4px 6px;
        font-size: 0.75rem;
    }

    /* ─── Mobile Touch Target Improvements ────────────────────── */

    /* Table action buttons: bigger touch targets */
    .data-table .btn-sm {
        min-height: 40px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    /* Table cell links (student names, group names) - bigger padding */
    .data-table td a {
        display: inline-flex;
        align-items: center;
        padding: 8px 4px;
        min-height: 40px;
        line-height: 24px;
    }

    /* Home page lesson cards - bigger "Подробнее" button */
    .lesson-card .btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Home page entity links (student/group names) - bigger touch target */
    .lesson-card a {
        display: inline-block;
        padding: 4px 0;
    }

    /* Calendar lesson cells - bigger touch area */
    .calendar-lesson {
        min-height: 28px;
        padding: 3px 6px;
    }

    /* Calendar week time-lesson - bigger touch area */
    .time-lesson {
        min-height: 30px;
    }

    /* Lesson checkboxes - bigger on mobile */
    .lesson-checkbox {
        width: 28px !important;
        height: 28px !important;
    }

    /* Stats table select - bigger */
    .stats-student-filter select {
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Time range inputs - bigger */
    .time-range-picker input[type="number"] {
        width: 50px;
        min-height: 36px;
        font-size: 0.85rem;
    }

    /* Inline pills in lessons list - bigger touch area */
    .inline-pill {
        padding: 6px 14px;
        min-height: 32px;
    }

    /* Pill dropdown items - bigger */
    .pill-option {
        padding: 12px 16px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Modal actions stacking on mobile */
    .lesson-actions {
        flex-direction: column;
        gap: 8px;
    }

    .lesson-actions-left,
    .lesson-actions-right {
        width: 100%;
        justify-content: stretch;
    }

    .lesson-actions-left .btn,
    .lesson-actions-right .btn {
        flex: 1;
        min-height: 44px;
    }

    /* Group table: hide less important columns on mobile */
    #groups-table th:nth-child(2),
    #groups-table td:nth-child(2),
    #groups-table th:nth-child(3),
    #groups-table td:nth-child(3),
    #groups-table th:nth-child(4),
    #groups-table td:nth-child(4) {
        display: none;
    }

    /* Students table: hide less important columns on mobile */
    #students-table th:nth-child(3),
    #students-table td:nth-child(3),
    #students-table th:nth-child(4),
    #students-table td:nth-child(4),
    #students-table th:nth-child(5),
    #students-table td:nth-child(5),
    #students-table th:nth-child(6),
    #students-table td:nth-child(6) {
        display: none;
    }

    /* Search input - full width on mobile */
    #group-search-input,
    #student-search-input {
        max-width: 100% !important;
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Status actions in detail pages */
    .status-actions .btn {
        min-height: 44px;
        flex: 1;
    }

    /* Calendar jump controls */
    .calendar-jump {
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: wrap;
    }

    /* Filter panel inputs on mobile */
    .filter-panel select {
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Filter panel - full width on mobile */
    .filter-panel form {
        flex-direction: column;
        gap: 12px;
    }

    .filter-panel form > div {
        width: 100%;
    }

    .filter-panel input[type="text"],
    .filter-panel input[type="date"],
    .filter-panel select {
        width: 100%;
        min-height: 44px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    /* Pending/batch bars - mobile friendly */
    #pending-bar,
    #batch-bar {
        top: 56px;
        flex-direction: column;
        align-items: stretch;
    }

    #pending-bar .btn,
    #batch-bar .btn,
    #batch-bar select {
        width: 100%;
        min-height: 36px;
    }

    /* Lessons list: hide price column on mobile */
    .data-table th:nth-child(6),
    .data-table td:nth-child(6) {
        display: none;
    }

    /* Calendar week inputs - mobile friendly */
    .time-range-picker {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    .time-range-picker input[type="number"] {
        min-height: 36px;
    }
}

/* === Inline Pills (Lessons List) === */
.inline-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: all 0.15s;
}

.inline-pill:hover {
    opacity: 0.85;
}

/* Status pills */
.status-pill.status-planned {
    background: var(--info-light);
    color: var(--info);
}

.status-pill.status-completed {
    background: var(--success-light);
    color: var(--success);
}

.status-pill.status-cancelled {
    background: var(--mist-light);
    color: var(--ink-muted);
}

.status-pill.status-rescheduled {
    background: var(--mist-light);
    color: var(--ink-muted);
    text-decoration: line-through;
}

/* Payment pills */
.payment-pill.payment-paid {
    background: var(--success-light);
    color: var(--success);
}

.payment-pill.payment-unpaid {
    background: var(--mist-light);
    color: var(--ink-muted);
}

.payment-pill.payment-partial {
    background: var(--warning-light);
    color: var(--warning);
}

/* Pill changed state */
.inline-pill.changed {
    outline: 2px solid var(--sage);
    outline-offset: 1px;
}

/* Pill dropdown */
.pill-dropdown {
    position: fixed;
    min-width: 140px;
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 1000;
}

.pill-option {
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.pill-option:first-child {
    border-radius: 8px 8px 0 0;
}

.pill-option:last-child {
    border-radius: 0 0 8px 8px;
}

.pill-option:hover {
    background: var(--mist-light);
}

/* Row changed highlight */
tr.row-changed {
    background: var(--warning-light) !important;
}

/* ─── Homework List ──────────────────────────────────────── */
.homework-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.homework-item {
    padding: 14px;
    background: var(--paper-warm);
    border-radius: 8px;
    border: 1px solid var(--mist);
}

.homework-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.homework-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--ink);
}

.homework-title-link {
    color: var(--ink);
    text-decoration: none;
}

.homework-title-link:hover {
    color: var(--sage);
}

.homework-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.homework-actions .btn {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.homework-actions form {
    display: inline;
}

.homework-content {
    margin: 10px 0;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--mist-light);
    border-radius: 6px;
    font-size: 0.92rem;
    line-height: 1.6;
    overflow-x: auto;
}

.homework-file {
    margin: 8px 0;
}

.homework-file .file-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--info);
    text-decoration: none;
    transition: background 0.15s;
}

.homework-file .file-link:hover {
    background: var(--info-light);
}

.homework-meta {
    font-size: 0.8rem;
    color: var(--ink-muted);
    margin-top: 6px;
}

/* ─── Homework Form: Markdown Tabs ───────────────────────── */
.md-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--mist);
    margin-bottom: 0;
}

.md-tab {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink-muted);
    transition: color 0.15s, border-color 0.15s;
}

.md-tab:hover {
    color: var(--ink);
}

.md-tab.active {
    color: var(--sage);
    border-bottom-color: var(--sage);
}

.md-pane textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--mist);
    border-radius: 0 0 8px 8px;
    border-top: none;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

.md-pane textarea:focus {
    outline: none;
    border-color: var(--sage);
}

/* ─── Markdown / LaTeX Rendered Content ───────────────────── */
.markdown-body {
    padding: 12px;
    background: var(--paper-warm);
    border: 1px solid var(--mist);
    border-radius: 8px;
    font-size: 0.92rem;
    line-height: 1.65;
    overflow-x: auto;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin: 0.8em 0 0.4em;
    color: var(--ink);
}

.markdown-body h1 { font-size: 1.4rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1.05rem; }

.markdown-body p {
    margin: 0.5em 0;
}

.markdown-body code {
    padding: 2px 5px;
    background: var(--mist-light);
    border-radius: 4px;
    font-size: 0.88em;
}

.markdown-body pre {
    padding: 12px;
    background: var(--ink);
    color: var(--mist);
    border-radius: 8px;
    overflow-x: auto;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.markdown-body blockquote {
    margin: 0.5em 0;
    padding: 8px 14px;
    border-left: 3px solid var(--sage);
    background: var(--sage-light);
    border-radius: 0 6px 6px 0;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 24px;
    margin: 0.4em 0;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--mist);
    padding: 6px 10px;
    text-align: left;
}

.markdown-body th {
    background: var(--mist-light);
    font-weight: 600;
}

/* ─── KaTeX overflow ─────────────────────────────────────── */
.katex-block {
    overflow-x: auto;
    max-width: 100%;
    padding: 8px 0;
}

/* ─── Lesson detail modal: status grid ───────────────────── */
.lesson-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.lesson-status-col {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lesson-status-col h3 {
    margin-bottom: 12px;
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 600;
}

.lesson-status-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ─── Lesson detail modal: schedule bar ──────────────────── */
.lesson-schedule {
    background: var(--paper-warm);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.lesson-schedule dl {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 8px;
}

.lesson-schedule dt {
    font-weight: 500;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.lesson-schedule dd {
    color: var(--ink);
}

/* ─── Lesson detail modal: grouped actions ───────────────── */
.lesson-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--mist-light);
}

.lesson-actions-left,
.lesson-actions-right {
    display: flex;
    gap: 8px;
}

@media (max-width: 600px) {
    .lesson-status-grid {
        grid-template-columns: 1fr;
    }

    /* Очень маленькие экраны */
    .page-header h1 {
        font-size: 1.2rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .calendar-day {
        min-height: 48px;
        padding: 3px;
    }

    .day-number {
        font-size: 0.75rem;
    }

    .calendar-day.today .day-number {
        width: 18px;
        height: 18px;
    }

    .calendar-lesson {
        font-size: 0.58rem;
        padding: 1px 2px;
    }

    .calendar-lesson-time {
        font-size: 0.55rem;
    }

    .calendar-lesson-name {
        font-size: 0.52rem;
    }

    .btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    .btn-sm {
        min-height: 36px;
        padding: 6px 12px;
    }

    /* Touch-friendly: все интерактивные элементы min 44px */
    a, button, input[type="submit"], input[type="button"] {
        min-height: 44px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
