/* ==========================================================================
   Kapocs Hub — modern minimal stylesheet
   ========================================================================== */

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --border: #e5e8ef;
    --text: #1a1f2e;
    --text-muted: #6b7280;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success: #16a34a;
    --success-soft: #f0fdf4;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

h1 { font-size: 1.75rem; font-weight: 700; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 1rem; }
.muted { color: var(--text-muted); }

/* ----- Auth shell (login page) ------------------------------------------ */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #eef2ff 0%, #f4f6fb 50%, #ecfeff 100%);
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    border: 1px solid var(--border);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.auth-heading {
    font-size: 1.5rem;
    margin: 0 0 0.25rem;
}

.auth-sub {
    color: var(--text-muted);
    margin: 0 0 1.75rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-language {
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-language select {
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    color: var(--text);
}

/* ----- Brand mark -------------------------------------------------------- */

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand-name {
    font-weight: 600;
    font-size: 1.05rem;
}

/* ----- App shell (authenticated layout) --------------------------------- */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 auto;
}

.nav-form {
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 500;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background: var(--surface-2);
}

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

.nav-item--button {
    color: var(--text);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-language {
    margin-bottom: 0.75rem;
}

.sidebar-language select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface, #fff);
    color: var(--text);
    font: inherit;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name { font-weight: 600; font-size: 0.9rem; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

/* ----- Content ---------------------------------------------------------- */

.content {
    padding: 2.5rem clamp(1.5rem, 4vw, 3rem);
    max-width: 1100px;
    width: 100%;
}

.page-header {
    margin-bottom: 1.75rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 1.25rem; }

.card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Responsive dashboard grid (Home): a row of cards that collapses to a single
   column on phones. */
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
    align-items: start;
}

.home-grid > .card {
    margin-top: 0;
}

/* Card header with an inline search field to its right. */
.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.85rem;
}

.card-header-row h2 {
    margin: 0;
}

/* Home dashboard chip-list search field. */
.home-search {
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
}

.card-header-row .home-search {
    flex: 1 1 140px;
    min-width: 0;
    max-width: 220px;
}

/* Home dashboard item rows. */
.home-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.home-list-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.home-list-item:hover {
    background: var(--surface);
}

.home-list-name {
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-list-meta {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ----- Forms ------------------------------------------------------------ */

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.field-hint {
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-muted);
}

.recur-days {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
}

.recur-days-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.35rem 0;
}

.recur-monthdays-grid {
    gap: 0.3rem;
}

.recur-day-check {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    justify-content: center;
}

.recur-day-check input {
    width: auto;
    margin: 0;
}

.recur-monthdays-grid .recur-day-check {
    min-width: 2.75rem;
    padding: 0.25rem 0.4rem;
}

.field input,
.settings-form input {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.settings-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 420px;
}

/* ----- Buttons ---------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-block {
    width: 100%;
}

/* ----- Alerts ----------------------------------------------------------- */

.alert {
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #fecaca;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: #bbf7d0;
}

/* ----- Badges ----------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-admin {
    background: var(--primary-soft);
    color: var(--primary);
}

.badge-user {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ----- Tables ----------------------------------------------------------- */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table thead th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table-actions {
    text-align: right;
    white-space: nowrap;
}

/* ----- Log viewer (admin tail page) ------------------------------------ */

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.log-level {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    background: var(--surface-2);
    color: var(--text);
}

.log-level-warning {
    background: #fff3cd;
    color: #7a5b00;
}

.log-level-error,
.log-level-critical {
    background: #f8d7da;
    color: #842029;
}

.log-level-information {
    background: #cfe2ff;
    color: #084298;
}

.link {
    color: var(--primary);
    font-weight: 500;
}

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

/* ----- Page header w/ actions ------------------------------------------ */

.page-header--actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ----- Form actions row -------------------------------------------------- */

.form-actions {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.5rem;
}

.btn {
    /* default (non-primary) button — surface look */
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    text-decoration: none;
}

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

/* ----- Checkboxes / chips ----------------------------------------------- */

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem 1rem;
    margin-top: 0.25rem;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.92rem;
    cursor: pointer;
}

.checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    margin: 0 0.2rem 0.2rem 0;
    text-transform: capitalize;
}

.role-chip--administrator {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: transparent;
}

.role-chip--teacher {
    background: #ecfeff;
    color: #0e7490;
    border-color: transparent;
}

.role-chip--billing {
    background: #fef3c7;
    color: #92400e;
    border-color: transparent;
}

.role-chip--assistant {
    background: #f3e8ff;
    color: #6b21a8;
    border-color: transparent;
}

.role-chip--user {
    background: var(--surface-2);
    color: var(--text-muted);
}

/* ----- Description / detail lists --------------------------------------- */

.detail-list {
    display: grid;
    grid-template-columns: minmax(160px, max-content) 1fr;
    gap: 0.5rem 1.25rem;
    margin: 0;
}

.detail-list dt {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.detail-list dd {
    margin: 0;
}

/* ----- Generic chip lists (tools, lessons, series links) --------------- */

.chip-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    text-decoration: none;
}

.chip:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: transparent;
}

/* ----- Contacts list --------------------------------------------------- */

.contact-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.contact-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ----- Filter bar (small inline form above tables) --------------------- */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* ----- Button groups (calendar navigation) ----------------------------- */

.btn-group {
    display: inline-flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* ----- Small text helpers ---------------------------------------------- */

.small {
    font-size: 0.8rem;
}

.cell-wrap {
    white-space: pre-wrap;
    word-break: break-word;
}

/* ----- Horizontally scrollable tables (mobile safety) ------------------ */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----- Calendar (week view) -------------------------------------------- */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.calendar-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 160px;
    display: flex;
    flex-direction: column;
}

.calendar-day-header {
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.calendar-day-name {
    font-weight: 600;
    font-size: 0.85rem;
}

.calendar-day-date {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.calendar-day-list {
    list-style: none;
    margin: 0;
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1 1 auto;
}

.calendar-empty {
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0.25rem 0.35rem;
}

.calendar-entry a {
    display: block;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border);
    font-size: 0.82rem;
    line-height: 1.25;
}

.calendar-entry a:hover {
    background: var(--primary-soft);
    border-color: transparent;
    color: var(--primary);
}

.calendar-entry-time {
    font-weight: 600;
    display: inline-block;
    margin-right: 0.4rem;
}

.calendar-entry-title {
    display: block;
}

.calendar-entry-meta {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-top: 0.15rem;
}

.calendar-entry--consultation a { border-left: 3px solid #0e7490; }
.calendar-entry--statuscheck a { border-left: 3px solid #92400e; }
.calendar-entry--other a { border-left: 3px solid #6b21a8; }
.calendar-entry--class a { border-left: 3px solid var(--primary); }

.calendar-entry--status-cancelled a {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ----- Calendar (view switcher + day / month / agenda) ----------------- */

.calendar-views {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.calendar-views .btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.calendar-grid--day {
    grid-template-columns: minmax(0, 1fr);
}

.calendar-grid--month {
    gap: 0.35rem;
}

.calendar-grid--month .calendar-day {
    min-height: 110px;
}

.calendar-day--muted {
    opacity: 0.55;
}

.calendar-new {
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--primary);
    padding: 0 0.25rem;
    white-space: nowrap;
}

.calendar-new:hover {
    text-decoration: underline;
}

.calendar-agenda {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.calendar-agenda-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.calendar-agenda-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border);
}

.calendar-agenda .calendar-day-list {
    padding: 0.5rem;
}

/* ----- My lessons list ------------------------------------------------- */

.lesson-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.lesson-list-item a {
    display: block;
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
}

.lesson-list-item a:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.lesson-list-item--consultation a { border-left-color: #0e7490; }
.lesson-list-item--statuscheck a { border-left-color: #92400e; }
.lesson-list-item--other a { border-left-color: #6b21a8; }

.lesson-list-item--status-cancelled a {
    text-decoration: line-through;
    color: var(--text-muted);
}

.lesson-list-when {
    font-weight: 600;
    margin-right: 0.5rem;
}

.lesson-list-title {
    font-weight: 500;
}

.lesson-list-meta {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

/* ----- Admin landing tiles --------------------------------------------- */

.admin-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.admin-tile {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.admin-tile:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.admin-tile h2 {
    margin-top: 0;
}

/* ----- Attendance editor (lesson details) ------------------------------ */

.attendance-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.attendance-row {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.7rem;
}

.attendance-name {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.attendance-form {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.attendance-field {
    margin: 0;
}

.attendance-field--grow {
    flex: 1 1 14rem;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.attendance-remove-form {
    margin-top: 0.5rem;
}

.roster-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.roster-edit-form {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
    flex: 1 1 18rem;
}

.roster-edit-field--grow {
    margin: 0;
    flex: 1 1 12rem;
}

/* ----- Planning (FullCalendar + SortableJS) ---------------------------- */

.planning-shell {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    gap: 1rem;
    margin-top: 1rem;
    align-items: start;
}

.planning-side,
.planning-detail,
.planning-main {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
}

.planning-side h2,
.planning-detail h2 {
    font-size: 1rem;
    margin: 0 0 0.65rem;
}

.planning-panel {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}
.planning-panel:first-of-type {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}
.planning-panel > summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.25rem 0;
}

.planning-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 240px;
    overflow-y: auto;
}

.planning-filter-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.planning-filter-input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.45rem;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.planning-filter-row .planning-filter-input {
    margin-bottom: 0;
}

.planning-list-item {
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.85rem;
}

.planning-list-item:hover {
    background: var(--primary-soft);
    border-color: transparent;
}

.planning-week-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.planning-calendar {
    min-height: 540px;
}

.planning-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.planning-task-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.planning-task-row {
    display: grid;
    grid-template-columns: auto 1fr 70px auto 28px;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    font-size: 0.85rem;
}

.planning-task-handle {
    cursor: grab;
    user-select: none;
    color: var(--text-muted);
    text-align: center;
}

.planning-task-name {
    word-break: break-word;
}

.planning-task-duration {
    width: 60px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.3rem;
    background: var(--surface);
    font: inherit;
}

.planning-task-ghost {
    opacity: 0.4;
    background: var(--primary-soft);
}

.planning-status {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 60;
    max-width: min(90vw, 30rem);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    font-size: 0.9rem;
    color: var(--text);
}

.planning-status:empty { display: none; }
.planning-status--ok { border-color: var(--success); color: var(--success); }
.planning-status--error { border-color: var(--danger); color: var(--danger); }

.btn-ghost {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
}
.btn-ghost:hover { color: var(--text); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* FullCalendar event tinting per Lesson.Kind. */
.planning-event { border-color: transparent !important; }
.planning-event--class { background: var(--primary) !important; }
.planning-event--consultation { background: #0e7490 !important; }
.planning-event--statuscheck { background: #92400e !important; }
.planning-event--other { background: #6b21a8 !important; }

/* Toolbar: navigation + view toggle + (mobile) library button. */
.planning-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.planning-view-toggle .btn[aria-pressed="true"] {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* The "Library" sheet opener and per-sheet close buttons are mobile-only. */
.planning-library-toggle,
.planning-sheet-close {
    display: none;
}

.planning-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0 0 0.65rem;
}

.planning-sheet-header h2 {
    margin: 0;
}

/* Per-kind colour legend in the calendar header. */
.planning-legend {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.planning-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.planning-legend-swatch {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    display: inline-block;
}

/* Shared dimmer behind any open mobile bottom sheet. */
.planning-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.45);
    border: 0;
}
.planning-backdrop[hidden] { display: none; }

/* Per-task up/down reorder buttons (touch fallback for drag). */
.planning-task-reorder {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
}

.planning-task-move {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.1rem 0.3rem;
    font-size: 0.75rem;
}
.planning-task-move:hover { color: var(--text); }
.planning-task-move:disabled { opacity: 0.35; cursor: default; }

.planning-week-header {
    flex-wrap: wrap;
}

/* ----- Responsive ------------------------------------------------------- */

@media (max-width: 980px) {
    .calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .sidebar-footer {
        border-top: 0;
        padding-top: 0;
        margin-left: auto;
    }

    .content {
        padding: 1.25rem 1rem;
    }

    .detail-list {
        grid-template-columns: 1fr;
        gap: 0.15rem 0;
    }

    .detail-list dt {
        margin-top: 0.5rem;
    }

    .page-header--actions {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .calendar-day {
        min-height: auto;
    }

    /* Calendar stays the primary surface; the library and the lesson
       detail become bottom sheets that slide up over it. */
    .planning-shell {
        grid-template-columns: 1fr;
        position: relative;
    }

    /* Keep the toolbar (and the Library button) visible while the calendar
       is scrolled into view. */
    #planning-toolbar {
        position: sticky;
        top: 0;
        z-index: 45;
        background: var(--bg);
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }

    .planning-library-toggle {
        display: inline-flex;
    }

    .planning-sheet-close {
        display: inline-flex;
    }

    .planning-side,
    .planning-detail {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 55;
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.25);
        transform: translateY(100%);
        transition: transform 0.2s ease;
    }

    .planning-side {
        /* The library sheet is collapsed until the toolbar button opens it. */
        display: block;
    }

    .planning-side.is-open,
    .planning-detail.is-open {
        transform: translateY(0);
    }

    /* On desktop the detail uses [hidden]; on mobile the sheet transform
       controls visibility, so keep it rendered for the slide animation. */
    .planning-detail[hidden] {
        display: block;
        transform: translateY(100%);
    }

    .planning-list {
        max-height: 40vh;
    }

    /* Comfortable touch targets for the per-task controls. */
    .planning-task-move,
    .planning-task-remove,
    .planning-task-handle {
        min-width: 2.25rem;
        min-height: 2.25rem;
    }

    .planning-task-row {
        grid-template-columns: auto 1fr 56px;
        grid-template-areas:
            "reorder name remove"
            "type    type duration";
        gap: 0.5rem;
    }
    .planning-task-reorder { grid-area: reorder; }
    .planning-task-name { grid-area: name; }
    .planning-task-type { grid-area: type; }
    .planning-task-duration { grid-area: duration; justify-self: end; }
    .planning-task-remove { grid-area: remove; }
}


/* ----- Template slot editor --------------------------------------------- */

.template-slots {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0.5rem 0;
}

.template-slot {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem 1rem;
    align-items: center;
    padding: 0.5rem 0.65rem;
    background: var(--surface-2);
    border-radius: 6px;
}

.template-slot-name {
    font-weight: 500;
}

.template-slot-duration {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
}

.template-slot-duration input[type=number] {
    width: 5.5rem;
}

.template-slot-actions {
    display: inline-flex;
    gap: 0.25rem;
}

.template-add {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.25rem;
}

.template-add select {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 600px) {
    .template-slot {
        grid-template-columns: 1fr;
    }
    .template-slot-actions {
        justify-content: flex-end;
    }
}


/* ----- Member / contact / owner lists ----------------------------------- */

.member-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.member-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: var(--surface-2);
    border-radius: 6px;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
}

.inline-form select,
.inline-form input[type=text],
.inline-form input[type=number] {
    min-width: 0;
    flex: 1 1 12rem;
}

.btn-small {
    padding: 0.2rem 0.55rem;
    font-size: 0.85rem;
    line-height: 1.1;
}

/* ----- Check-in / attendance screen (Phase 11) ------------------------- */

.checkin-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkin-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.checkin-card-name {
    font-weight: 600;
    flex: 1 1 100%;
    margin-bottom: 0.1rem;
}

.checkin-form {
    display: contents;
}

.checkin-form--note {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1 1 14rem;
}

.checkin-note-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    font: inherit;
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
}

.checkin-checkin-label {
    white-space: nowrap;
}

/* Status cycle button — coloured by current status */
.btn-status {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
    white-space: nowrap;
}

.btn-status--scheduled  { background: var(--surface-2);   color: var(--text-muted);  border-color: var(--border); }
.btn-status--attended   { background: var(--success-soft); color: var(--success);     border-color: #bbf7d0; }
.btn-status--absent     { background: var(--danger-soft);  color: var(--danger);      border-color: #fecaca; }
.btn-status--excused    { background: #fef3c7;             color: #92400e;            border-color: #fde68a; }
.btn-status--cancelled  { background: var(--surface-2);   color: var(--text-muted);  border-color: var(--border); text-decoration: line-through; }

.btn-status:hover { opacity: 0.8; }

/* ----- Attendance matrix (course details) ------------------------------ */

.attendance-matrix-section > summary {
    cursor: pointer;
    list-style: none;
}

.attendance-matrix-section > summary::-webkit-details-marker {
    display: none;
}

.attendance-matrix-section > summary h2 {
    display: inline-block;
    margin: 0;
}

.attendance-matrix-section > summary::before {
    content: "\25B8"; /* ▸ */
    display: inline-block;
    margin-right: 0.5rem;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.attendance-matrix-section[open] > summary::before {
    transform: rotate(90deg);
}

.attendance-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    font-size: 0.85rem;
}

.attendance-legend li {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.attendance-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.78rem;
}

.attendance-cell--scheduled { background: var(--surface-2);    color: var(--text-muted); border-color: var(--border); }
.attendance-cell--attended  { background: var(--success-soft); color: var(--success);    border-color: #bbf7d0; }
.attendance-cell--absent    { background: var(--danger-soft);  color: var(--danger);     border-color: #fecaca; }
.attendance-cell--excused   { background: #fef3c7;             color: #92400e;           border-color: #fde68a; }
.attendance-cell--cancelled { background: var(--surface-2);    color: var(--text-muted); border-color: var(--border); text-decoration: line-through; }

.attendance-matrix th,
.attendance-matrix td {
    text-align: center;
    white-space: nowrap;
}

.attendance-matrix .attendance-matrix-name,
.attendance-matrix .attendance-matrix-corner {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
    text-align: left;
}

.attendance-matrix thead .attendance-matrix-corner {
    z-index: 2;
}

.attendance-matrix-total {
    font-weight: 600;
}

