:root {
  color-scheme: dark;
  --bg: #07101f;
  --bg-deep: #040b17;
  --sidebar: rgba(8, 17, 33, 0.97);
  --surface: #0d192b;
  --surface-2: #122139;
  --surface-3: #172944;
  --card: rgba(15, 28, 48, 0.92);
  --line: rgba(164, 188, 221, 0.16);
  --line-strong: rgba(164, 188, 221, 0.28);
  --text: #f6f9ff;
  --muted: #9caec7;
  --primary: #5da8ff;
  --primary-strong: #2e8df7;
  --primary-soft: rgba(70, 151, 255, 0.14);
  --success: #5fd2a5;
  --warning: #f3bd58;
  --danger: #ff7d86;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #edf2f8;
  --bg-deep: #e6edf5;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #e9f1fa;
  --card: rgba(255, 255, 255, 0.96);
  --line: rgba(28, 53, 82, 0.12);
  --line-strong: rgba(28, 53, 82, 0.23);
  --text: #172338;
  --muted: #61718a;
  --primary-soft: rgba(46, 141, 247, 0.10);
  --shadow: 0 20px 48px rgba(30, 55, 84, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(41, 119, 215, 0.24), transparent 30rem),
    linear-gradient(135deg, var(--bg-deep), var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button, input, select { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px 18px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  box-shadow: 16px 0 45px rgba(0, 0, 0, 0.14);
  z-index: 5;
}

.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-image-wrap { width: 52px; height: 52px; border-radius: 14px; padding: 5px; background: #fff; overflow: hidden; flex: 0 0 auto; }
.brand-image-wrap img { width: 100%; height: 100%; object-fit: contain; }
.brand-lockup strong { display: block; font-size: 1.05rem; letter-spacing: -0.01em; }
.eyebrow, .page-kicker { color: var(--primary); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; }

.nav-list { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 11px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); transform: translateX(2px); }
.nav-item.active { color: var(--text); background: var(--primary-soft); border-color: rgba(93, 168, 255, 0.25); }
.nav-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; color: var(--primary); background: rgba(93, 168, 255, 0.10); font-weight: 800; }
.nav-count { min-width: 23px; padding: 2px 6px; border-radius: 999px; background: rgba(255,125,134,.15); color: var(--danger); font-size: .75rem; text-align: center; }
.nav-divider { height: 1px; margin: 8px 8px; background: var(--line); }

.sidebar-footer { margin-top: auto; display: grid; grid-template-columns: 38px 1fr 35px; align-items: center; gap: 9px; padding: 12px 8px 2px; border-top: 1px solid var(--line); }
.sidebar-footer strong, .sidebar-footer span { display: block; }
.sidebar-footer strong { font-size: .88rem; }
.sidebar-footer span { color: var(--muted); font-size: .74rem; }
.profile-dot { position: relative; width: 36px; height: 36px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: #07101f; background: linear-gradient(135deg, #97c9ff, #4f9ef7); font-size: .75rem; font-weight: 800; }
.profile-dot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.main-content { min-width: 0; padding: 28px 36px 56px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; max-width: 1500px; margin: 0 auto 24px; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(1.6rem, 2.7vw, 2.45rem); letter-spacing: -0.035em; }
.page-kicker { margin: 0; }
.topbar-actions, .control-row, .date-controls, .section-toolbar { display: flex; align-items: center; gap: 10px; }
.topbar-right, .toolbar-actions { display: flex; align-items: center; gap: 10px; }
.mobile-logout { display: none; }

.button, .icon-button {
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 42px;
  padding: 9px 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.button:hover, .icon-button:hover { transform: translateY(-1px); border-color: rgba(93, 168, 255, .55); }
.button.primary { background: linear-gradient(135deg, var(--primary-strong), #58afff); border-color: transparent; color: white; box-shadow: 0 10px 22px rgba(46,141,247,.22); }
.button.ghost { background: transparent; }
.button.quiet { min-height: 38px; background: var(--surface); }
.button.full { width: 100%; }
.icon-button { width: 40px; min-height: 38px; padding: 6px; display: grid; place-items: center; }

.workspace { display: none; max-width: 1500px; margin: 0 auto; }
.workspace.active { display: block; }
.control-row { flex-wrap: wrap; margin-bottom: 18px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(12,24,42,.68); backdrop-filter: blur(12px); }
html[data-theme="light"] .control-row { background: rgba(255,255,255,.78); }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.segmented button { border: 0; border-radius: 7px; padding: 7px 13px; background: transparent; color: var(--muted); cursor: pointer; }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 3px 10px rgba(0,0,0,.12); }

.select-field { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: .82rem; font-weight: 700; }
.select-field + .select-field { margin-left: 0; }
select, input {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
select:focus, input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(93,168,255,.13); }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card { position: relative; overflow: hidden; padding: 16px 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); box-shadow: 0 10px 25px rgba(0,0,0,.08); }
.summary-card::after { content: ""; position: absolute; width: 60px; height: 60px; right: -18px; top: -18px; border-radius: 50%; background: var(--line); }
.summary-card span, .summary-card small { display: block; color: var(--muted); }
.summary-card span { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.summary-card strong { display: block; margin: 3px 0 0; font-size: 1.75rem; letter-spacing: -.04em; }
.summary-card small { font-size: .76rem; }
.summary-card.accent strong { color: var(--primary); }
.summary-card.warning strong { color: var(--warning); }

.notice { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 11px 13px; border: 1px solid rgba(93,168,255,.22); border-radius: 12px; background: var(--primary-soft); color: var(--muted); font-size: .86rem; }
.notice strong { color: var(--text); }
.notice-icon { flex: 0 0 auto; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: #06101f; font-weight: 900; }

.lesson-list { display: grid; gap: 15px; }
.lesson-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.lesson-header { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(93,168,255,.08), transparent 42%); }
.lesson-time strong { display: block; font-size: 1.35rem; letter-spacing: -.03em; }
.lesson-time span { color: var(--muted); font-size: .75rem; }
.lesson-title h2 { margin: 0; font-size: 1.05rem; }
.lesson-title p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.lesson-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.meta-chip, .status-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .74rem; font-weight: 700; }
.status-chip { color: var(--primary); }
.status-chip.warning { color: var(--warning); background: rgba(243,189,88,.10); border-color: rgba(243,189,88,.22); }
.status-chip.danger { color: var(--danger); background: rgba(255,125,134,.10); border-color: rgba(255,125,134,.22); }

.participant-table { width: 100%; border-collapse: collapse; }
.participant-table th, .participant-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.participant-table th { color: var(--muted); background: rgba(7,16,31,.18); font-size: .73rem; letter-spacing: .06em; text-transform: uppercase; }
.participant-table tr:last-child td { border-bottom: 0; }
.participant-table .student-cell { font-weight: 700; }
.participant-table select { width: 100%; min-width: 145px; }
.number-badge { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 900; }
.number-badge.empty { color: var(--muted); background: var(--surface-2); }
.row-cancelled .student-cell { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
.row-cancelled { background: rgba(255,125,134,.035); }
.row-conflict { background: rgba(243,189,88,.07); }
.status-select.cancelled { color: var(--danger); }
.status-select.present { color: var(--success); }
.lesson-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); background: rgba(0,0,0,.04); }
.participant-add { display: flex; align-items: center; gap: 8px; min-width: 0; }
.participant-add select { min-width: 250px; max-width: 360px; }
.participant-add .text-button:disabled { cursor: not-allowed; opacity: .45; }
.text-button { border: 0; background: transparent; color: var(--primary); padding: 4px; font-weight: 750; cursor: pointer; }
.lesson-hint { color: var(--muted); font-size: .78rem; }

.print-heading { display: none; }
.section-toolbar { justify-content: space-between; margin-bottom: 16px; }
.section-toolbar > div { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.master-toolbar { min-height: 46px; }
.search-field { flex: 1 1 320px; max-width: 520px; }
.search-field input { width: 100%; min-height: 43px; padding-left: 14px; }
.muted { color: var(--muted); font-size: .85rem; }
.data-card, .request-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 850px; }
.data-table th, .data-table td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; }
.data-table th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.data-table td { font-size: .9rem; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .money { font-weight: 800; color: var(--text); }
.master-table td:last-child, .master-table th:last-child { width: 112px; text-align: right; }
.table-actions { display: inline-flex; justify-content: flex-end; gap: 5px; }
.mini-button { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 750; cursor: pointer; }
.mini-button:hover { border-color: rgba(93,168,255,.55); color: var(--text); }
.mini-button.danger:hover { border-color: rgba(255,125,134,.45); color: var(--danger); }
.contact-stack strong, .contact-stack span { display: block; }
.contact-stack span { color: var(--muted); font-size: .77rem; }
.person-name-cell { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.person-name-cell > div > span { display: block; color: var(--muted); font-size: .74rem; }
.person-child-row { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.person-child-row td:first-child { padding-left: 34px; }
.family-horse-copy { display: flex !important; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--primary-soft); }
.family-horse-copy input { width: 20px; height: 20px; flex: 0 0 auto; }
.family-horse-copy span, .family-horse-copy small { display: block; }
.horse-link-field { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.horse-link-field legend { padding: 0 6px; color: var(--muted); font-weight: 700; }
.horse-link-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; max-height: 210px; overflow: auto; }
.horse-link-choice { display: flex !important; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.horse-link-choice input { width: 18px; height: 18px; flex: 0 0 auto; }
.horse-link-choice span, .horse-link-choice small { display: block; }
.profile-photo { position: relative; width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: .7rem; font-weight: 800; }
.profile-photo.large { width: 86px; height: 86px; font-size: .9rem; }
.profile-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.master-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-bottom: 14px; }
.master-stat { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(13,25,43,.64); }
html[data-theme="light"] .master-stat { background: rgba(255,255,255,.72); }
.master-stat span { color: var(--muted); font-size: .79rem; font-weight: 700; }
.master-stat strong { color: var(--primary); font-size: 1.25rem; }
.empty-row td { padding: 34px 16px; color: var(--muted); text-align: center !important; }

.request-list { display: grid; gap: 12px; }
.request-card { display: grid; grid-template-columns: 62px minmax(125px, .7fr) minmax(160px, 1fr) minmax(165px, .8fr) auto; align-items: center; gap: 12px; padding: 16px; }
.request-date { width: 62px; padding: 8px 5px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.request-date strong, .request-date span { display: block; }
.request-date strong { color: var(--primary); font-size: 1.15rem; }
.request-date span { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.request-card h3 { margin: 0; font-size: .98rem; }
.request-card p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.decision-select { min-width: 210px; }
.request-card .button { white-space: nowrap; }

.billing-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); gap: 16px; }
.billing-card, .export-card { padding: 20px; }
.card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.card-heading h2, .export-card h2 { margin: 2px 0 0; }
.billing-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.select-field.wide { display: grid; gap: 6px; margin: 0; }
.billing-lines { display: grid; border-top: 1px solid var(--line); }
.billing-line { display: grid; grid-template-columns: auto minmax(180px, 1fr) minmax(290px, auto); align-items: center; gap: 10px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.billing-line > input { min-height: auto; }
.billing-position-controls { display: grid; grid-template-columns: minmax(180px, 1fr) 100px; align-items: end; gap: 8px; }
.billing-amount-field { display: grid; gap: 3px; color: var(--muted); font-size: .68rem; font-weight: 750; }
.billing-amount-field .billing-amount { width: 100%; min-height: 40px; }
.billing-cancellation { color: var(--warning) !important; }
.billing-total { display: flex; justify-content: space-between; padding-top: 18px; font-size: 1.1rem; }
.billing-total strong { font-size: 1.4rem; }
.export-card p { color: var(--muted); }
.export-card dl { display: grid; gap: 10px; margin: 18px 0 22px; }
.export-card dl div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.export-card dt { color: var(--muted); }
.export-card dd { margin: 0; font-weight: 750; }

.empty-state { display: grid; place-items: center; min-height: 58vh; padding: 36px; border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; background: rgba(13,25,43,.42); }
.empty-state h2 { margin: 10px 0 4px; }
.empty-state p { max-width: 520px; margin: 0; color: var(--muted); }
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--primary-soft); color: var(--primary); font-size: 1.8rem; }

.modal { width: min(780px, calc(100% - 28px)); border: 1px solid var(--line-strong); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 36px 90px rgba(0,0,0,.5); }
.modal::backdrop { background: rgba(2,8,18,.72); backdrop-filter: blur(5px); }
.modal form { padding: 22px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.modal-header h2 { margin: 3px 0 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.form-grid .full-field { grid-column: 1 / -1; }
.form-grid textarea { min-height: 88px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 10px; background: var(--surface); color: var(--text); font: inherit; outline: none; }
.form-grid textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(93,168,255,.13); }
.field-help { color: var(--muted); font-size: .72rem; font-weight: 500; line-height: 1.4; }
.inline-create-card { margin: 4px 0 0; padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.inline-create-toggle { display: flex !important; grid-template-columns: none !important; align-items: flex-start; gap: 11px !important; padding: 15px 16px; color: var(--text) !important; cursor: pointer; }
.inline-create-toggle input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); }
.inline-create-toggle span { display: grid; gap: 3px; }
.inline-create-toggle strong { font-size: .9rem; }
.inline-create-toggle small { color: var(--muted); font-size: .74rem; font-weight: 500; line-height: 1.4; }
.inline-create-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px; border-top: 1px solid var(--line); background: var(--surface); }
.inline-create-fields label { display: grid; gap: 6px; }
.inline-create-fields .full-field { grid-column: 1 / -1; }
.inline-create-heading { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-create-heading span { padding: 4px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.master-modal { width: min(1180px, calc(100% - 32px)); max-height: calc(100vh - 24px); overflow-y: auto; }
.master-modal .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.master-modal .form-grid .full-field { grid-column: 1 / -1; }
.profile-image-field { display: flex; align-items: center; gap: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.profile-image-field > div:last-child { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-image-field p { flex-basis: 100%; margin: 2px 0; }
.file-button { display: inline-flex !important; color: var(--text) !important; cursor: pointer; }
.mail-modal { width: min(900px, calc(100% - 28px)); }
.wysiwyg-toolbar { display: flex; gap: 6px; padding: 7px; border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--surface-2); }
.wysiwyg-toolbar button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); cursor: pointer; }
.wysiwyg-editor { min-height: 270px; max-height: 48vh; overflow-y: auto; padding: 14px; border: 1px solid var(--line-strong); border-radius: 0 0 10px 10px; background: var(--surface); color: var(--text); font: inherit; outline: none; }
.wysiwyg-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(93,168,255,.13); }
.portal-share-preview { display: grid; place-items: center; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.portal-share-preview img { width: 220px; height: 220px; }
.portal-share-preview a { color: #135dab; font-weight: 750; overflow-wrap: anywhere; }
.dashboard-care-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 18px; }
.dashboard-care-card { padding: 20px; }
.dashboard-module-card { margin-top: 18px; padding: 20px; }
.dashboard-module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; }
.dashboard-module-grid button { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; }
.dashboard-module-grid button:hover { border-color: rgba(93,168,255,.5); background: var(--primary-soft); transform: translateY(-1px); }
.dashboard-module-grid button span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: rgba(93,168,255,.12); color: var(--primary); font-size: 1.05rem; }
.role-preview-grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.role-preview-grid button { display: grid; grid-template-columns: 34px 1fr; align-items: center; }
.role-preview-grid button span { grid-row: span 2; }
.role-preview-grid button strong, .role-preview-grid button small { display: block; }
.role-preview-grid button small { margin-top: 2px; color: var(--muted); font-size: .74rem; font-weight: 500; line-height: 1.35; }
.role-preview-banner { position: sticky; top: 12px; z-index: 12; max-width: 1500px; margin: -8px auto 20px; padding: 13px 15px; border: 1px solid rgba(243,189,88,.48); border-radius: 15px; background: var(--surface); background: color-mix(in srgb, var(--surface) 92%, #f3bd58 8%); box-shadow: var(--shadow); }
.role-preview-banner, .role-preview-banner > div, .role-preview-controls, .role-preview-controls label { display: flex; align-items: center; gap: 11px; }
.role-preview-banner { justify-content: space-between; }
.role-preview-banner > div:first-child > div { display: grid; gap: 1px; }
.role-preview-banner strong { font-size: .91rem; }
.role-preview-banner span { color: var(--muted); font-size: .76rem; }
.preview-lock { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: rgba(243,189,88,.15); color: var(--warning) !important; }
.role-preview-controls { flex-wrap: wrap; justify-content: flex-end; }
.role-preview-controls label { gap: 6px; font-weight: 750; }
.role-preview-controls select { min-height: 36px; max-width: 230px; padding-block: 5px; }
.role-preview-active [data-preview-disabled="true"] { cursor: not-allowed !important; opacity: .5; }
.role-preview-active .sidebar-footer { border-color: rgba(243,189,88,.45); }
.customer-welcome { border-color: rgba(93,168,255,.35); }
.waitlist-guest-fields { grid-column: 1 / -1; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.waitlist-guest-fields[hidden] { display: none; }
.request-status-actions { display: grid; gap: 8px; min-width: 190px; }
.button-group { display: flex; flex-wrap: wrap; gap: 10px; }
.care-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-top: 1px solid var(--line); }
.care-row span { display: block; color: var(--muted); font-size: .78rem; }
.appointment-fields { display: grid; grid-template-columns: 140px 100px minmax(130px,1fr) auto; gap: 6px; min-width: 510px; }
.appointment-fields input { min-height: 36px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 360px; padding: 13px 16px; border: 1px solid rgba(95,210,165,.35); border-radius: 12px; background: #102a25; color: #dffdf1; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

[hidden] { display: none !important; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 25% 10%, rgba(93,168,255,.14), transparent 34%), var(--bg); }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid var(--line-strong); border-radius: 24px; background: var(--card); box-shadow: 0 30px 80px rgba(0,0,0,.38); }
.login-card > img { width: 150px; height: 92px; object-fit: contain; border-radius: 12px; margin-bottom: 22px; background: #fff; }
.login-card h1 { margin: 5px 0 8px; font-size: 1.8rem; }
.login-form { display: grid; gap: 14px; margin-top: 24px; }
.portal-link { display:block; color:var(--primary); text-align:center; text-decoration:none; font-size:.85rem; font-weight:750; }
.portal-link:hover { text-decoration:underline; }
.login-form label, .dialog-field { display: grid; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: .84rem; }
.form-message { margin: 14px 0 0; color: var(--success); font-size: .84rem; line-height: 1.45; }

.dashboard-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(120deg, var(--primary-soft), var(--card)); }
.dashboard-hero h2 { margin: 4px 0; font-size: 1.6rem; }
.dashboard-hero p { margin: 0; color: var(--muted); }
.dashboard-badge { min-width: 105px; padding: 16px; border-radius: 16px; background: var(--surface-2); text-align: center; }
.dashboard-badge strong, .dashboard-badge span { display: block; }
.dashboard-badge strong { color: var(--primary); font-size: 2rem; }
.dashboard-badge span { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.dashboard-lessons { display: grid; gap: 10px; }
.dashboard-lesson { display: grid; grid-template-columns: 85px 1fr auto; align-items: center; gap: 16px; width: 100%; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); color: var(--text); text-align: left; cursor: pointer; }
.dashboard-lesson:hover { border-color: rgba(93,168,255,.5); transform: translateY(-1px); }
.dashboard-lesson small { display: block; margin-top: 4px; color: var(--muted); }
.dashboard-time { color: var(--primary); font-size: 1.25rem; font-weight: 800; }
.empty-state.compact { min-height: 240px; }

.calendar-plan { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(145px, 1fr)); overflow-x: auto; }
.calendar-day { min-height: 480px; border-right: 1px solid var(--line); }
.calendar-day:last-child { border-right: 0; }
.calendar-day > header { display: flex; justify-content: space-between; align-items: center; padding: 13px; border-bottom: 1px solid var(--line); background: var(--surface-2); text-transform: uppercase; }
.calendar-day > header span { color: var(--muted); font-size: .72rem; font-weight: 800; }
.calendar-day > header strong { color: var(--primary); }
.calendar-day > div { display: grid; gap: 8px; padding: 9px; }
.calendar-lesson { display: grid; gap: 4px; width: 100%; padding: 9px; border: 1px solid rgba(93,168,255,.24); border-radius: 9px; background: var(--primary-soft); color: var(--text); text-align: left; cursor: pointer; }
.calendar-lesson strong { font-size: .76rem; }
.calendar-lesson span { color: var(--muted); font-size: .68rem; }
.calendar-empty { padding: 14px 4px; color: var(--muted); font-size: .73rem; }
.calendar-weekdays, .month-days { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); }
.calendar-weekdays span { padding: 10px; border-right: 1px solid var(--line); background: var(--surface-2); color: var(--muted); text-align: center; font-size: .72rem; font-weight: 800; }
.month-days { min-width: 850px; }
.month-day { min-height: 145px; padding: 8px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
.month-day header { margin-bottom: 7px; color: var(--primary); font-weight: 800; }
.month-day .calendar-lesson { margin-bottom: 5px; }
.month-day.outside { opacity: .35; }

.row-actions { display: flex; gap: 5px; min-width: 175px; }
.lesson-meta .mini-button { white-space: nowrap; }
.billing-person { border-bottom: 1px solid var(--line); }
.billing-person > header { display: flex; justify-content: space-between; gap: 12px; padding: 14px 2px 5px; }
.billing-person > header span, .billing-person small { display: block; color: var(--muted); font-size: .75rem; }
.billing-person .billing-price { max-width: 310px; }
.health-toolbar { margin-top: 28px; }
.horse-filter { margin-left: 0; }
.list-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 24px 2px 10px; }
.list-heading:first-of-type { margin-top: 18px; }
.list-heading h2 { margin: 3px 0 0; font-size: 1.05rem; }
.record-list { display: grid; gap: 10px; max-height: 280px; overflow-y: auto; margin-bottom: 20px; }
.record-list article { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); }
.record-list article > div { display: flex; justify-content: space-between; gap: 12px; }
.record-list h3 { margin: 9px 0 3px; font-size: .95rem; }
.record-list p { margin: 0; color: var(--muted); font-size: .82rem; white-space: pre-wrap; }
.dialog-field { margin-top: 13px; }
.dialog-field textarea { width: 100%; padding: 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); resize: vertical; }
.modal-actions a.button { display: inline-flex; align-items: center; text-decoration: none; }
.boarder-welcome { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:18px; padding:25px; border:1px solid var(--line-strong); border-radius:var(--radius); background:linear-gradient(135deg,rgba(125,183,255,.08),rgba(214,180,108,.08)); }
.boarder-welcome h2 { margin:4px 0; font-size:1.6rem; }
.boarder-welcome p:last-child { margin:0; color:var(--muted); }
.boarder-welcome .button { text-decoration:none; white-space:nowrap; }
.boarder-module-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.boarder-module { padding:18px; border:1px solid var(--line); border-radius:var(--radius); background:var(--card); }
.boarder-module.wide { grid-column:span 3; }
.boarder-module>header { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.boarder-module h3 { margin:2px 0 0; }
.profile-data { display:grid; gap:8px; margin:0; }
.profile-data div { display:grid; gap:2px; padding-bottom:8px; border-bottom:1px solid var(--line); }
.profile-data dt { color:var(--muted); font-size:.72rem; }
.profile-data dd { margin:0; font-weight:700; overflow-wrap:anywhere; }
.boarder-list-row { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:11px 0; border-bottom:1px solid var(--line); }
.boarder-list-row:last-child { border-bottom:0; }
.boarder-list-row span { display:block; margin-top:3px; color:var(--muted); font-size:.78rem; line-height:1.45; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 82px minmax(0,1fr); }
  .sidebar { padding-inline: 12px; }
  .brand-lockup > div:last-child, .nav-item span:not(.nav-icon):not(.nav-count), .sidebar-footer > div:not(.profile-dot), .nav-count { display: none; }
  .brand-lockup { justify-content: center; }
  .nav-item { grid-template-columns: 1fr; padding: 9px; }
  .nav-icon { margin: auto; }
  .sidebar-footer { grid-template-columns: 1fr; justify-items: center; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .request-card { grid-template-columns: 70px 1fr; }
  .request-card .decision-select, .request-card .button { grid-column: 2; }
}

@media (max-width: 720px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .lesson-footer { align-items: stretch; flex-direction: column; }
  .participant-add { align-items: stretch; flex-direction: column; }
  .participant-add select { max-width: none; min-width: 0; width: 100%; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: auto 0 0; height: auto; flex-direction: row; padding: 8px; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .brand-lockup, .sidebar-footer, .nav-divider { display: none; }
  .nav-list { width: 100%; flex-direction: row; justify-content: space-around; }
  .nav-item { min-width: 54px; width: auto; }
  .nav-item:nth-of-type(n+5) { display: none; }
  .main-content { padding: 20px 14px 92px; }
  .topbar { align-items: center; }
  .topbar-actions .ghost { display: none; }
  .control-row { align-items: stretch; }
  .select-field { width: 100%; margin: 0; justify-content: space-between; }
  .select-field select { flex: 1; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .lesson-header { grid-template-columns: 74px 1fr; }
  .lesson-meta { grid-column: 1 / -1; justify-content: flex-start; }
  .participant-table th:nth-child(4), .participant-table td:nth-child(4) { display: none; }
  .participant-table th, .participant-table td { padding-inline: 9px; }
  .billing-layout, .billing-controls { grid-template-columns: 1fr; }
  .billing-line { grid-template-columns: auto 1fr; }
  .billing-position-controls { grid-column: 2; grid-template-columns: 1fr 100px; width: 100%; }
  .master-summary { grid-template-columns: 1fr; }
  #studentsView .data-card { min-width: 0; overflow: hidden; }
  #studentsView .table-scroll { width: 100%; max-width: 100%; overflow: visible; }
  #studentsView .master-table { display: block; width: 100%; min-width: 0; }
  #studentsView .master-table thead { display: none; }
  #studentsView .master-table tbody { display: grid; width: 100%; }
  #studentsView .master-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, auto); gap: 7px 12px; width: 100%; padding: 14px; border-bottom: 1px solid var(--line); }
  #studentsView .master-table tr:last-child { border-bottom: 0; }
  #studentsView .master-table td { min-width: 0; padding: 0; border: 0; }
  #studentsView .master-table td:nth-child(1) { grid-column: 1; }
  #studentsView .master-table td:nth-child(2) { grid-column: 2; overflow-wrap: anywhere; text-align: right; }
  #studentsView .master-table td:nth-child(n+3):nth-child(-n+6) { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding-top: 7px; border-top: 1px solid var(--line); }
  #studentsView .master-table td:nth-child(n+3):nth-child(-n+6)::before { flex: 0 0 94px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  #studentsView .master-table td:nth-child(3)::before { content: "Kontakt"; }
  #studentsView .master-table td:nth-child(4)::before { content: "Kenntnisstufe"; }
  #studentsView .master-table td:nth-child(5)::before { content: "Abrechnung"; }
  #studentsView .master-table td:nth-child(6)::before { content: "Status"; }
  #studentsView .master-table td:nth-child(3) .contact-stack,
  #studentsView .master-table td:nth-child(5) .contact-stack { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  #studentsView .master-table td:last-child { grid-column: 1 / -1; width: auto; padding-top: 4px; text-align: right; }
  #studentsView .master-table .person-name-cell { min-width: 0; }
  #studentsView .master-table .person-child-row { margin-left: 18px; width: calc(100% - 18px); border-left: 3px solid var(--primary); background: color-mix(in srgb, var(--primary-soft) 65%, transparent); }
  #studentsView .master-table .person-child-row td:first-child { padding-left: 0; }
  .request-card { grid-template-columns: 58px 1fr; gap: 10px; }
  .form-grid, .inline-create-fields { grid-template-columns: 1fr; }
  .master-modal { width: calc(100% - 20px); max-height: calc(100vh - 20px); }
  .master-modal .form-grid { grid-template-columns: 1fr; }
  .master-modal .form-grid .full-field { grid-column: auto; }
  .form-grid .full-field { grid-column: auto; }
  .inline-create-fields .full-field, .inline-create-heading { grid-column: auto; }
  .boarder-welcome { align-items:stretch; flex-direction:column; }
  .boarder-module-grid { grid-template-columns:1fr; }
  .boarder-module.wide { grid-column:auto; }
  .dashboard-care-grid { grid-template-columns: 1fr; }
  .dashboard-module-grid { grid-template-columns: 1fr 1fr; }
  .role-preview-banner { position: static; align-items: stretch; flex-direction: column; }
  .role-preview-controls { justify-content: flex-start; }
  .role-preview-controls label { align-items: stretch; flex-direction: column; }
  .topbar-right { align-items: flex-end; flex-direction: column; }
  .theme-toggle { min-height: 36px; padding: 6px 10px; }
  .mobile-logout { display: inline-flex; min-height: 36px; padding: 6px 10px; }
}

@media (max-width: 560px) {
  .dashboard-module-grid, .role-preview-grid { grid-template-columns: 1fr; }
  .role-preview-controls, .role-preview-controls label, .role-preview-controls select, .role-preview-controls .button { width: 100%; max-width: none; }
}

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  :root { color-scheme: light; }
  body { background: #fff; color: #111; font-family: Arial, sans-serif; font-size: 10.5pt; }
  .sidebar, .topbar, .no-print, .lesson-footer, .toast { display: none !important; }
  .app-shell, .main-content { display: block; padding: 0; }
  .workspace { display: none !important; max-width: none; }
  #planningView.active { display: block !important; }
  .print-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 8mm; padding-bottom: 4mm; border-bottom: 2px solid #111; }
  .print-heading img { width: 30mm; height: 22mm; object-fit: contain; }
  .print-heading div { text-align: right; }
  .print-heading span, .print-heading strong { display: block; }
  .print-heading span { font-size: 10pt; }
  .print-heading strong { font-size: 16pt; }
  .lesson-list { display: block; }
  .lesson-card { break-inside: avoid; margin-bottom: 6mm; border: 1.4px solid #222; border-radius: 0; background: #fff; box-shadow: none; }
  .lesson-header { grid-template-columns: 27mm 1fr auto; padding: 3mm; border-bottom: 1.4px solid #222; background: #f0f0f0; }
  .lesson-time strong { font-size: 14pt; }
  .lesson-title h2 { font-size: 11pt; }
  .lesson-title p, .lesson-time span { color: #333; font-size: 8pt; }
  .meta-chip { border-color: #777; background: transparent; color: #222; }
  .participant-table th, .participant-table td { padding: 2mm 2.4mm; border-color: #444; color: #111; }
  .participant-table th { background: #f5f5f5; color: #111; }
  .participant-table select { appearance: none; border: 0; min-height: 0; padding: 0; background: transparent; color: #111; }
  .number-badge { width: auto; height: auto; display: block; background: transparent; color: #111; }
  .row-cancelled .student-cell { color: #333; }
}
