:root {
  --background: #111827;
  --panel: #1c293a;
  --secondary: #263244;
  --separator: #344154;
  --text: #f2f5fa;
  --muted: #9baec8;
  --accent: #82afff;
  --row-odd: #1c293a;
  --row-even: #243449;
  --row-hover: #30445e;
  --table-heading: #34547a;
  --header-mark-height: 56px;
  --action-blue: #2459a6;
  --action-green: #217044;
  --action-red: #ac3543;
  --discipline-1: #b49aff;
  --discipline-2: #63cdb7;
  --discipline-3: #f28fa3;
  --discipline-4: #efbb68;
  --discipline-5: #82afff;
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--background);
}
.login-page { align-items: center; justify-content: center; overflow: auto; padding: 24px; }
.login-card { width: min(100%, 350px); padding: 28px; flex-shrink: 0; }
.login-card h1 { margin-bottom: 4px; font-size: 22px; }
.login-card .company-logo { height: 48px; }
.login-card label { display: block; margin: 16px 0; color: var(--muted); }
.login-card input:not([type="hidden"]) { display: block; width: 100%; margin-top: 6px; height: 36px; padding: 6px 10px; border: 1px solid var(--separator); border-radius: 4px; background: var(--secondary); color: var(--text); font: inherit; }
.login-card button, .session-control button { background: var(--secondary); color: var(--text); border: 1px solid var(--separator); border-radius: 4px; padding: 8px 10px; font: inherit; cursor: pointer; }
.login-card button { width: 100%; margin-top: 6px; }
.session-control { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.session-control form { margin: 0; }
.session-control span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="light"] {
  color-scheme: light;
  --background: #e9eef5;
  --panel: #ffffff;
  --secondary: #e5ecf5;
  --separator: #bbc9da;
  --text: #18283d;
  --muted: #4b617c;
  --accent: #2459a6;
  --row-odd: #ffffff;
  --row-even: #edf3fa;
  --row-hover: #d8e6f7;
  --table-heading: #c4d7ef;
  --discipline-1: #7851c2;
  --discipline-2: #16856d;
  --discipline-3: #c44365;
  --discipline-4: #b57614;
  --discipline-5: #2459a6;
}
:root[data-theme="light"] .company-logo { filter: brightness(0) saturate(100%); }
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; }
button:focus-visible, .table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app-header { height: 120px; flex-shrink: 0; padding: 24px 28px; display: flex; align-items: center; gap: 40px; border-bottom: 1px solid var(--separator); background: var(--panel); }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 1.6px; }
.identity { flex-shrink: 0; }
.company-logo { display: block; width: auto; height: var(--header-mark-height); object-fit: contain; }
.future-actions { display: flex; gap: 8px; flex: 1; }
.future-actions button, .future-actions a { min-width: 92px; height: 34px; border: 1px solid var(--separator); border-radius: 4px; color: var(--muted); background: var(--secondary); font-size: 11px; font-weight: 600; letter-spacing: .7px; }
.future-actions .action-new { background: var(--action-blue); border-color: #82afff; color: #f2f5fa; }
.future-actions .action-fichas { background: #a94e13; border-color: #efaa65; color: #fff; }
.future-actions .action-wait { background: var(--action-green); border-color: #63c58c; color: #f2f5fa; }
.future-actions .action-inactive { background: var(--action-red); border-color: #ef8a96; color: #f2f5fa; }
button:disabled { cursor: default; }
.milestone { color: var(--muted); font-size: 10px; letter-spacing: 1px; white-space: nowrap; }
.header-course { position: relative; display: flex; align-items: center; flex-shrink: 0; height: var(--header-mark-height); }
.header-course .milestone { position: absolute; right: 0; bottom: calc(100% + 5px); line-height: 1; }
.course-year { margin: 0; font-size: calc(var(--header-mark-height) * 1.0); line-height: var(--header-mark-height); font-weight: 650; letter-spacing: -1.2px; }
.course-year span { color: var(--accent); }
.badge { display: inline-block; padding: 3px 6px; color: var(--accent); background: var(--secondary); border: 1px solid var(--separator); border-radius: 3px; font-size: 9px; letter-spacing: 1px; vertical-align: middle; }
.milestone .badge { margin-left: 8px; }
.panel-controls { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; }
.panel-controls button { background: transparent; border: 1px solid var(--separator); border-radius: 4px; padding: 6px 10px; color: var(--muted); cursor: pointer; font-size: 11px; }
.panel-controls button:hover { color: var(--text); background: var(--secondary); }
.workspace-label { font-size: 9px; letter-spacing: 1.7px; color: var(--muted); }
.workspace { display: grid; grid-template-columns: 150px minmax(0, 1fr) 170px; gap: 10px; padding: 10px; flex: 1; min-height: 0; }
.workspace.menu-hidden { grid-template-columns: 46px minmax(0, 1fr) 170px; }
.workspace.disciplines-hidden { grid-template-columns: 150px minmax(0, 1fr) 46px; }
.workspace.menu-hidden.disciplines-hidden { grid-template-columns: 46px minmax(0, 1fr) 46px; }
[hidden] { display: none !important; }
.panel { background: var(--panel); border: 1px solid var(--separator); border-radius: 5px; min-width: 0; min-height: 0; }
.sidebar { padding: 18px 12px; overflow-y: auto; }
.sidebar h2 { margin: 0 0 18px; font-size: 10px; letter-spacing: 1.4px; color: var(--muted); font-weight: 600; }
#menu-panel { padding: 18px 8px; display: flex; flex-direction: column; }
#menu-panel .menu-heading { flex-shrink: 0; }
#menu-content { flex: 1 0 auto; }
.theme-control { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--separator); display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#theme-toggle { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; flex: 0 0 28px; border: 0; background: transparent; cursor: pointer; }
.theme-track { display: block; width: 28px; height: 16px; border-radius: 10px; background: var(--separator); border: 1px solid var(--muted); position: relative; }
.theme-track::after { content: ''; position: absolute; width: 10px; height: 10px; top: 2px; left: 2px; border-radius: 50%; background: var(--text); }
#theme-toggle[aria-checked="true"] .theme-track { background: var(--accent); border-color: var(--accent); }
#theme-toggle[aria-checked="true"] .theme-track::after { left: 14px; background: #ffffff; }
#theme-label { font-size: 11px; white-space: nowrap; color: var(--muted); }
.menu-hidden #theme-label { display: none; }
.menu-heading { display: flex; align-items: center; margin-bottom: 18px; }
.menu-heading button { width: 28px; height: 26px; flex-shrink: 0; background: transparent; border: 1px solid var(--separator); border-radius: 4px; padding: 0; color: var(--muted); cursor: pointer; font-size: 11px; }
.menu-heading button:hover { color: var(--text); background: var(--secondary); }
.menu-icon { width: 28px; height: 20px; flex: 0 0 28px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#menu-content .side-list button { display: flex; align-items: center; gap: 4px; height: 40px; font-size: 12px; white-space: nowrap; }
.menu-hidden .menu-label, .menu-hidden #menu-content .panel-note { display: none; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list button { border: 0; color: var(--text); background: transparent; padding: 10px 0; width: 100%; text-align: left; }
.panel-note { border-top: 1px solid var(--separator); padding-top: 14px; margin-top: 22px; font-size: 11px; line-height: 1.7; color: var(--muted); }
#disciplines-panel { padding: 18px 8px; }
.disciplines-heading { justify-content: flex-end; }
.discipline-entry { font-size: 12px; line-height: 1.4; }
.discipline-entry summary, .discipline-single { min-height: 42px; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.discipline-entry summary { cursor: pointer; list-style: none; }
.discipline-entry summary::-webkit-details-marker { display: none; }
.discipline-entry summary::before { content: '▸'; color: var(--muted); }
.discipline-entry details[open] summary::before { content: '▾'; }
.discipline-entry summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.discipline-members { list-style: none; margin: 0 8px 8px 0; padding: 0 8px 0 0; border-right: 2px solid var(--discipline-color); text-align: right; color: var(--muted); }
.discipline-members li { padding: 4px 0; overflow-wrap: anywhere; }
.discipline-label { text-align: right; }
.discipline-dot { width: 14px; height: 14px; flex: 0 0 14px; margin: 0 7px; border-radius: 50%; background: var(--discipline-color); }
.discipline-color-1 { --discipline-color: var(--discipline-1); }
.discipline-color-2 { --discipline-color: var(--discipline-2); }
.discipline-color-3 { --discipline-color: var(--discipline-3); }
.discipline-color-4 { --discipline-color: var(--discipline-4); }
.discipline-color-5 { --discipline-color: var(--discipline-5); }
.disciplines-hidden .discipline-label, .disciplines-hidden #disciplines-content .panel-note { display: none; }
.disciplines-hidden .discipline-members, .disciplines-hidden summary::before { display: none; }
.students-panel { display: flex; flex-direction: column; overflow: hidden; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 22px 24px 18px; flex-shrink: 0; }
h1 { margin: 6px 0 0; font-size: 23px; font-weight: 600; letter-spacing: -.5px; }
.count { color: var(--muted); font-size: 11px; white-space: nowrap; }
.count .badge { margin-left: 8px; }
.listing-filters { display: flex; flex-direction: column; gap: 8px; margin: 0 24px 18px; flex-shrink: 0; }
.search-control { display: block; width: 100%; min-width: 0; }
.search-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.search-row .search-control { flex: 1; }
#toggle-filters { flex-shrink: 0; }
#toggle-filters[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.filter-bar { display: flex; align-items: center; gap: 8px; width: 100%; flex-wrap: nowrap; }
.filter-control { min-width: 0; flex: 0 1 155px; }
.city-control { flex-basis: 190px; }
.payment-control { flex-basis: 210px; }
#clear-filters { margin-left: auto; flex-shrink: 0; }
@media (max-width: 1100px) {
  .filter-bar { flex-wrap: wrap; }
}
.listing-filters input, .listing-filters select, .listing-filters button, .back-link { height: 34px; border: 1px solid var(--separator); border-radius: 4px; background: var(--secondary); color: var(--text); font: inherit; font-size: 12px; padding: 0 10px; }
.listing-filters input, .listing-filters select { width: 100%; }
.listing-filters input::placeholder { color: var(--muted); }
.listing-filters button { cursor: pointer; }
.listing-filters button:disabled { color: var(--muted); cursor: default; }
.listing-filters :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.sort-button { display: flex; align-items: center; justify-content: space-between; gap: 3px; width: 100%; height: 32px; padding: 0; color: inherit; background: transparent; border: 0; font: inherit; text-align: left; cursor: pointer; white-space: nowrap; }
.sort-arrow { display: inline-block; flex: 0 0 12px; width: 12px; text-align: center; }
.dynamic-heading { display: flex; align-items: center; gap: 4px; }
.dynamic-heading #dynamic-field { flex: 1; width: 0; }
.dynamic-sort { flex: 0 0 20px; width: 20px; justify-content: center; }
#empty-results td { color: var(--muted); text-align: center; height: 64px; }
.table-scroll { overflow: auto; flex: 1; min-height: 0; }
table { table-layout: fixed; border-collapse: separate; border-spacing: 0; width: 100%; min-width: 760px; text-align: left; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; background: var(--table-heading); color: var(--text); font-size: 11px; font-weight: 600; height: 39px; }
th, td { padding: 0 12px; border-bottom: 1px solid var(--separator); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td { height: 40px; }
td:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
#dynamic-field { width: 100%; min-width: 0; padding: 5px 4px; font: inherit; font-weight: 600; color: var(--text); background: var(--table-heading); border: 1px solid var(--separator); border-radius: 3px; }
#dynamic-field:focus-visible { outline: 2px solid var(--accent); }
.listing-error { margin: 0; padding: 12px 24px; color: var(--text); background: var(--secondary); border-top: 1px solid var(--separator); }
.students-panel tbody tr:nth-child(odd) { background: var(--row-odd); }
.students-panel tbody tr:nth-child(even) { background: var(--row-even); }
.students-panel tbody tr:hover { background: var(--row-hover); }
.table-footer { padding: 10px 24px; border-top: 1px solid var(--separator); color: var(--muted); font-size: 10px; flex-shrink: 0; }
@media (max-width: 800px) {
  .app-header { padding: 16px; gap: 20px; }
  .workspace-label { display: none; }
  .future-actions { justify-content: flex-end; gap: 5px; }
  .future-actions button, .future-actions a { min-width: 60px; }
  .section-heading { padding: 16px; flex-wrap: wrap; }
  .listing-filters { margin: 0 16px 16px; }
  th, td { padding: 0 14px; }
}

/* Hito 3A: read-only student detail, sharing the application shell. */
.open-student { color: var(--accent); margin-right: 7px; text-decoration: none; font-size: 19px; }
a:focus-visible { outline: 2px solid var(--accent); }
.detail-scroll { overflow: auto; flex: 1; min-height: 0; padding: 16px; }
.detail-heading { display: flex; flex-shrink: 0; justify-content: space-between; align-items: center; gap: 16px; padding: 16px; border-bottom: 1px solid var(--separator); background: var(--panel); }
.detail-heading h1 { margin: 0; font-size: 20px; }
.detail-title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; }
.detail-heading h1 { overflow-wrap: anywhere; }
.back-link { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; text-decoration: none; white-space: nowrap; }
.detail-section { background: var(--secondary); border: 1px solid var(--separator); border-radius: 4px; padding: 12px; margin-bottom: 12px; }
.detail-section h2 { color: var(--muted); font-size: 12px; letter-spacing: 1px; margin: 0 0 12px; }
.personal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.detail-section dl { margin: 0; min-width: 0; }
.detail-field { margin-bottom: 10px; }
.detail-field dt { color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.detail-field dd { margin: 0; min-height: 18px; overflow-wrap: anywhere; }
.class-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.class-slot { padding: 10px; border: 1px solid var(--separator); border-radius: 3px; background: var(--panel); overflow-wrap: anywhere; }
.class-slot span, .detail-note { color: var(--muted); }
.marker { margin: 0 0 12px; }
.marker input { accent-color: var(--accent); }
.payment-markers { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 10px 20px; }
.payment-markers .marker { display: inline-flex; align-items: center; gap: 5px; }
.additional-payer + .additional-payer { border-top: 1px solid var(--separator); padding-top: 10px; }
.comments { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel); min-height: 100px; padding: 12px; border-radius: 3px; }

/* Four compact personal-data rows share the photo square's height. */
.personal-layout { --photo-size: 176px; display: grid; grid-template-columns: var(--photo-size) minmax(0, 1fr); gap: 20px; align-items: start; }
.personal-layout .personal-grid { min-height: var(--photo-size); }
.personal-layout .personal-grid > dl { display: grid; grid-template-rows: repeat(4, minmax(44px, auto)); align-content: start; }
.personal-layout .detail-field { margin-bottom: 0; padding-bottom: 2px; }
.personal-layout .detail-field dt { line-height: 13px; margin-bottom: 2px; }
.personal-layout .detail-field input { display: block; height: 24px; line-height: 20px; padding-top: 1px; padding-bottom: 1px; }
.student-photo { width: var(--photo-size); aspect-ratio: 1; display: grid; place-items: center; border: 1px dashed var(--muted); border-radius: 4px; background: var(--panel); color: var(--muted); }
.student-photo { overflow: hidden; }
.student-photo > * { grid-area: 1 / 1; }
.student-photo img { width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.student-photo [hidden] { display: none; }
.detail-section input:not([type=checkbox]), .detail-section select, .detail-section textarea { width: 100%; min-width: 0; box-sizing: border-box; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--separator); border-radius: 3px; padding: 3px 5px; }
.detail-section input:focus, .detail-section textarea:focus, .detail-section select:focus { outline: 1px solid var(--accent); }
#editor-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.photo-editor { position: relative; width: var(--photo-size); }
.photo-add { position: absolute; bottom: -8px; right: -8px; width: 30px; height: 30px; border-radius: 50%; font-size: 22px; padding: 0; }
#photo-menu { position: absolute; top: 100%; right: 0; z-index: 3; padding: 6px; background: var(--panel); border: 1px solid var(--separator); }
#photo-menu button { white-space: nowrap; margin: 3px; }
.field-error { display: block; color: #f28b82; white-space: normal; }
[aria-invalid=true] { border-color: #f28b82 !important; }
.editor-save { display: flex; justify-content: flex-end; padding: 10px 0 20px; }
.editor-save button { min-width: 140px; }
.payment-line { border-bottom: 1px solid var(--separator); margin-bottom: 10px; padding-bottom: 10px; }
.payment-line label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.detail-section textarea.comments { min-height: 110px; resize: vertical; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--separator); border-radius: 5px; max-width: 520px; }
dialog::backdrop { background: #0009; }
.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.contact-phones { gap: 6px; }
.detail-field dd, .payment-line label { position: relative; }
@media (max-width: 1100px) {
  .personal-layout { grid-template-columns: minmax(0, 1fr); }
  .student-photo { grid-row: 1; justify-self: start; }
}
.detail-section input::placeholder, .detail-section textarea::placeholder { color: var(--muted); opacity: 1; }
.detail-section input[data-currency] { width: 10ch; max-width: 100%; font-variant-numeric: tabular-nums; }

.primary-payment-line label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }

/* One charge: paired debtors share the same field rows. */
.payment-markers[hidden], #primary-payment-details[hidden] { display: none; }
.payment-payers .detail-field { min-height: 45px; margin-bottom: 10px; }
.payment-payers input:not([type=checkbox]) { height: 28px; }
.payment-payers .payment-line { border: 0; padding: 0; margin: 0; }
.payment-payers .payment-line label { margin: 0; font-size: inherit; }
#primary-payment-details > .detail-field { margin-bottom: 0; }
#payment-sum { font-size: 12px; color: var(--muted); margin-bottom: 0; }

/* Step 1: compact fee panel; billing placement is handled separately. */
.fees-panel { width: 220px; max-width: 100%; box-sizing: border-box; }
.fees-panel .detail-field:last-child { margin-bottom: 0; }

/* Fees and billing share a row when the detail has enough usable width. */
#student-editor { container-type: inline-size; }
.finance-panels { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: stretch; margin-bottom: 12px; }
.finance-panels > .detail-section { margin-bottom: 0; min-height: 324px; box-sizing: border-box; }
.finance-panels .fees-panel { display: flex; flex-direction: column; }
.finance-panels .fees-panel > dl { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.finance-panels .fees-panel .detail-field { margin-bottom: 0; }
.billing-panel { min-width: 0; display: flex; flex-direction: column; }
.billing-panel .payment-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; margin-bottom: 8px; }
.billing-panel .payment-top .detail-field { margin-bottom: 0; }
.billing-panel .payment-top select { height: 26px; }
.billing-panel .payment-markers { height: 26px; align-items: center; flex-wrap: nowrap; font-size: 12px; gap: 14px; }
.billing-panel .payment-markers .marker { margin: 0; white-space: nowrap; }
.billing-panel .payment-markers input { margin: 0; }
.billing-panel .payment-payers { gap: 12px; flex: 1; }
.billing-panel .payment-payers .detail-field { min-height: 36px; margin-bottom: 6px; }
.billing-panel .payment-payers input:not([type=checkbox]) { height: 24px; font-size: 12px; }
.billing-panel #payment-sum { margin-top: 6px; }
@container (max-width: 760px) {
  .finance-panels { grid-template-columns: minmax(0, 1fr); }
}

/* Persistent detail actions and adjacent student navigation. */
.detail-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.detail-title { flex-wrap: nowrap; }
.detail-title h1 { min-width: 0; }
.student-nav { width: 30px; padding: 0; font-size: 24px; }
.student-nav[hidden] { display: none; }
.detail-actions button:disabled { color: var(--muted); cursor: default; }
@media (max-width: 700px) {
  .detail-heading { flex-wrap: wrap; }
  .detail-actions { margin-left: auto; }
}

/* Empty status messages must not reserve space while opening a student. */
#editor-message:empty { display: none; }

/* Status messages use the existing header space, without moving the form. */
.detail-heading { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) max-content; gap: 12px; }
.detail-feedback { display: flex; align-items: center; gap: 8px; min-width: 0; height: 34px; }
.detail-feedback #editor-message { flex: 1; min-width: 0; margin: 0; font-size: 12px; line-height: 16px; max-height: 32px; overflow: auto; overflow-wrap: anywhere; }
.detail-feedback #editor-reload { flex-shrink: 0; padding: 0 6px; font-size: 11px; }
.detail-feedback #editor-reload[hidden] { display: none; }
@media (max-width: 1100px) {
  .detail-heading { grid-template-columns: minmax(0, 1fr) max-content; }
  .detail-feedback { grid-column: 1 / -1; grid-row: 2; }
}

/* A ready-to-save state reuses the editor's existing dirty/disabled logic. */
#save-student:not(:disabled) { background: var(--action-green); border-color: var(--action-green); color: #fff; cursor: pointer; }
#save-student:not(:disabled):hover { filter: brightness(1.12); }

/* Larger type in the three workspace panels. */
.workspace { grid-template-columns: 200px minmax(0, 1fr) 220px; }
.workspace.menu-hidden { grid-template-columns: 46px minmax(0, 1fr) 220px; }
.workspace.disciplines-hidden { grid-template-columns: 200px minmax(0, 1fr) 46px; }
.workspace.menu-hidden.disciplines-hidden { grid-template-columns: 46px minmax(0, 1fr) 46px; }
.workspace .panel { font-size: 18px; }
.sidebar h2 { font-size: 15px; }
#menu-content .side-list button, .discipline-entry { font-size: 17px; }
#menu-content .side-list button { min-height: 40px; height: auto; white-space: normal; }
#theme-label, .panel-note, .count { font-size: 16px; }
.menu-heading button { font-size: 16px; }
.students-panel h1 { font-size: 28px; }
.students-panel .detail-heading h1 { font-size: 25px; }
.listing-filters input, .listing-filters select, .listing-filters button, .back-link { font-size: 17px; min-height: 39px; height: auto; }
.listing-filters input, .listing-filters select, .listing-filters button { min-height: 39px; }
.filter-bar { flex-wrap: wrap; }
.filter-control { flex-basis: 190px; }
.city-control { flex-basis: 220px; }
.payment-control { flex-basis: 245px; }
table { font-size: 18px; min-width: 1000px; }
th { font-size: 16px; height: 44px; }
td { height: 45px; }
.sort-button { min-height: 37px; height: auto; }
.table-footer { font-size: 15px; }
.open-student { font-size: 24px; }
.detail-section h2, #payment-sum, .billing-panel .payment-markers { font-size: 17px; }
.detail-field dt, .payment-line label, .primary-payment-line label { font-size: 16px; }
.personal-layout { --photo-size: 220px; }
.personal-layout .personal-grid > dl { grid-template-rows: repeat(4, minmax(55px, auto)); }
.personal-layout .detail-field dt { line-height: normal; }
.personal-layout .detail-field input, .billing-panel .payment-payers input:not([type=checkbox]) { height: 30px; line-height: normal; }
.billing-panel .payment-payers input:not([type=checkbox]) { font-size: 17px; }
.billing-panel .payment-top select { height: 32px; }
.billing-panel .payment-markers { height: auto; min-height: 32px; flex-wrap: wrap; }
.detail-feedback { height: auto; min-height: 39px; }
.detail-feedback #editor-message { font-size: 17px; line-height: normal; max-height: 48px; }
.detail-feedback #editor-reload { font-size: 16px; }
.student-nav { font-size: 29px; }

/* Discipline roster and the links in the catalogue. */
.discipline-members a, .discipline-single a { color: inherit; text-decoration: none; }
.discipline-members a:hover, .discipline-single a:hover { color: var(--accent); text-decoration: underline; }
.discipline-members a[aria-current="page"], .discipline-single a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.discipline-view-heading { border-bottom: 1px solid var(--separator); }
.discipline-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.discipline-title h1 { min-width: 0; overflow-wrap: anywhere; }
.discipline-overline { color: var(--muted); font-size: 12px; letter-spacing: 1px; font-weight: 600; }
.discipline-view-content { padding: 20px 24px; overflow: auto; min-height: 0; }
.discipline-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--separator); border: 1px solid var(--separator); border-radius: 5px; overflow: hidden; margin-bottom: 22px; }
.discipline-info > div { background: color-mix(in srgb, var(--discipline-color, var(--secondary)) 28%, var(--secondary)); padding: 15px; min-width: 0; }
:root[data-theme="light"] .discipline-info > div { background: color-mix(in srgb, var(--discipline-color, var(--secondary)) 20%, var(--secondary)); }
.discipline-info span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .5px; margin-bottom: 7px; }
.discipline-info strong { display: block; overflow-wrap: anywhere; font-size: 17px; }
.discipline-info small { font-size: 13px; font-weight: normal; }
.discipline-table-wrap { overflow: auto; border: 1px solid var(--separator); border-radius: 5px; }
.discipline-table { min-width: 740px; }
.discipline-table th, .discipline-table td { text-align: left; padding: 10px 12px; white-space: normal; vertical-align: top; }
.discipline-table th:nth-child(1) { width: 17%; }
.discipline-table th:nth-child(2) { width: 25%; }
.discipline-table th:nth-child(3) { width: 10%; }
.discipline-table td:last-child { color: var(--text); }
.discipline-muted { color: var(--muted); font-size: 15px; }
.discipline-table .discipline-empty { text-align: center; color: var(--muted); padding: 24px; }
.menu-link { display: flex; align-items: center; gap: 4px; min-height: 40px; color: var(--text); font-size: 17px; text-decoration: none; }
.menu-link:hover, .menu-link[aria-current="page"] { color: var(--accent); }
.catalogue-intro { margin: 0 0 16px; color: var(--muted); }
.catalogue-table { min-width: 850px; }
.catalogue-table th, .catalogue-table td { text-align: left; padding: 10px 12px; white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.catalogue-table th:first-child { width: 24%; }
.catalogue-table td:last-child { color: var(--text); }
.catalogue-table .discipline-empty { text-align: center; color: var(--muted); padding: 24px; }
.catalogue-table input { width: 100%; min-width: 0; min-height: 36px; padding: 5px; border: 1px solid var(--separator); border-radius: 3px; color: var(--text); background: var(--panel); font: inherit; }
.catalogue-table input:focus-visible { outline: 2px solid var(--accent); }
.catalogue-feedback { padding: 10px 24px; margin: 0; background: var(--secondary); }
.catalogue-feedback[data-category="error"] { border-left: 4px solid #e87c7c; }

.admin-menu summary { cursor: pointer; list-style: none; }
.admin-menu summary::-webkit-details-marker { display: none; }
.admin-menu-items { list-style: none; margin: 0; padding: 0 0 0 28px; }
.admin-menu-items a { display: block; padding: 6px 0; color: var(--text); text-decoration: none; }
.admin-menu-items a:hover, .admin-menu-items a[aria-current="page"] { color: var(--accent); }
.menu-hidden .admin-menu-items { display: none; }

.listing-title { display: flex; align-items: center; gap: 18px; }

.future-actions a { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.confirm-dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; box-shadow: 0 18px 60px #0006; }
.confirm-dialog h2 { margin: 0 0 12px; font-size: 20px; }
.confirm-dialog p { margin: 0 0 22px; line-height: 1.5; }
.confirm-dialog .dialog-actions { justify-content: flex-end; }
.confirm-dialog button { padding: 9px 16px; border-radius: 4px; border: 1px solid var(--separator); color: var(--text); background: var(--secondary); cursor: pointer; }
.confirm-dialog #confirm-accept { background: var(--action-blue); color: #fff; border-color: var(--action-blue); }

.import-issues { border: 1px solid #c84545; background: color-mix(in srgb, #c84545 10%, var(--panel)); }
.import-issues h2 { color: #d34d4d; }
.import-issue { border-left: 3px solid #d34d4d; padding: 8px 12px; margin: 10px 0; }
.import-issue p { margin: 0 0 8px; overflow-wrap: anywhere; color: #d34d4d; }
.import-issue label { display: block; margin-bottom: 5px; }
.import-issue input, .import-issue select { max-width: 100%; margin-right: 8px; }
.import-invalid { outline: 2px solid #d34d4d; outline-offset: 1px; }

/* Pending import issues remain visible across sorting, filtering and hover. */
.students-panel #student-rows tr.has-import-issues { background: #681f27; color: #fff; }
.students-panel #student-rows tr.has-import-issues:hover { background: #812d35; }
.students-panel #student-rows tr.has-import-issues td:last-child { color: #fff; }
:root[data-theme="light"] .students-panel #student-rows tr.has-import-issues { background: #f9d1d1; color: #541419; }
:root[data-theme="light"] .students-panel #student-rows tr.has-import-issues:hover { background: #f3baba; }
:root[data-theme="light"] .students-panel #student-rows tr.has-import-issues td:last-child { color: #541419; }

.future-actions { justify-content: center; }
.future-actions .action-count { margin-left: 6px; font-variant-numeric: tabular-nums; }
@media (min-width: 1100px) {
  .app-header { position: relative; }
  .app-header .future-actions { position: absolute; left: calc(50% - 10px); transform: translateX(-50%); }
  body:has(.workspace.menu-hidden) .app-header .future-actions { left: calc(50% - 62px); }
  body:has(.workspace.disciplines-hidden) .app-header .future-actions { left: calc(50% + 52px); }
  body:has(.workspace.menu-hidden.disciplines-hidden) .app-header .future-actions { left: 50%; }
  .session-control { margin-left: auto; }
}

#save-disciplines:not(:disabled) { background: var(--action-green); border-color: var(--action-green); color: #fff; cursor: pointer; }
#save-disciplines:not(:disabled):hover { filter: brightness(1.12); }
#catalogue-form { min-height: 0; }

.trial-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.trial-heading h2, .trial-section h2 { margin: 0; font-size: 18px; }
.trial-section { margin-top: 24px; }
.trial-section h2 { margin-bottom: 12px; }
.trial-form { display: grid; gap: 14px; max-width: 520px; }
.trial-form label { display: grid; gap: 5px; }
.trial-form input, .trial-form textarea { width: 100%; padding: 8px; border: 1px solid var(--separator); border-radius: 4px; color: var(--text); background: var(--secondary); font: inherit; }
.trial-form textarea { min-height: 100px; resize: vertical; }
.trial-form button { justify-self: start; }

.mobile-controls, .mobile-backdrop, .mobile-scroll-hint { display: none; }
@media (max-width: 700px) {
  body { height: 100vh; height: 100dvh; }
  .app-header { height: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "logo course" "session session" "controls controls" "actions actions";
    gap: 6px 10px; padding: 8px 10px; }
  .identity { grid-area: logo; min-width: 0; }
  .company-logo { height: 38px; max-width: 100%; }
  .header-course { grid-area: course; height: auto; }
  .header-course .milestone { display: none; }
  .course-year { font-size: 26px; line-height: 1; letter-spacing: 0; }
  .session-control { grid-area: session; justify-content: flex-end; min-width: 0; }
  .session-control button { min-height: 34px; padding: 4px 8px; }
  .mobile-controls { grid-area: controls; display: flex; gap: 8px; }
  .mobile-controls button { flex: 1; min-height: 40px; border: 1px solid var(--separator);
    border-radius: 4px; background: var(--secondary); color: var(--text); font: inherit; font-weight: 600; }
  .future-actions { grid-area: actions; justify-content: center; gap: 6px; min-width: 0; }
  .future-actions button, .future-actions a { flex: 1 1 0; min-width: 0; height: 40px; font-size: 11px; letter-spacing: 0; }
  .future-actions .action-count { margin-left: 4px; }
  .workspace, .workspace.menu-hidden, .workspace.disciplines-hidden,
  .workspace.menu-hidden.disciplines-hidden { display: grid; grid-template-columns: minmax(0, 1fr); padding: 6px; gap: 0; }
  .workspace > .sidebar { position: fixed; z-index: 31; top: 0; bottom: 0; width: min(300px, 86vw);
    max-height: 100dvh; visibility: hidden; transition: transform .18s ease, visibility .18s; box-shadow: 0 0 30px #0008; }
  #menu-panel { left: 0; transform: translateX(-105%); }
  #disciplines-panel { right: 0; transform: translateX(105%); }
  .mobile-menu-open #menu-panel, .mobile-disciplines-open #disciplines-panel { visibility: visible; transform: translateX(0); }
  .mobile-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 30; border: 0; background: #0009; }
  .menu-hidden .menu-label, .menu-hidden #theme-label, .menu-hidden #menu-content .panel-note { display: initial; }
  .menu-hidden .admin-menu-items { display: block; }
  .disciplines-hidden .discipline-label, .disciplines-hidden #disciplines-content .panel-note { display: initial; }
  .disciplines-hidden .discipline-members { display: block; }
  .disciplines-hidden summary::before { display: initial; }
  .students-panel { min-width: 0; }
  .workspace .panel { font-size: 16px; }
  .section-heading { gap: 8px; padding: 12px; }
  .students-panel h1, .students-panel .detail-heading h1 { font-size: 21px; }
  .listing-filters { margin: 0 12px 12px; }
  .filter-control { flex: 1 1 140px; }
  .listing-filters input, .listing-filters select, .listing-filters button, .back-link { font-size: 14px; min-height: 40px; }
  .mobile-scroll-hint { display: block; margin: 0; padding: 0 12px 6px; color: var(--muted); font-size: 12px; }
  .table-scroll, .discipline-table-wrap { -webkit-overflow-scrolling: touch; }
  #students-table { min-width: 760px; }
  #students-table col:nth-child(1) { width: 140px !important; }
  #students-table col:nth-child(2) { width: 145px !important; }
  #students-table col:nth-child(3) { width: 135px !important; }
  #students-table col:nth-child(4) { width: 220px !important; }
  #students-table col:nth-child(5) { width: 120px !important; }
  #students-table tbody td:first-child { position: sticky; left: 0; z-index: 1; background: inherit; }
  #students-table thead th:first-child { left: 0; z-index: 3; }
  table { min-width: 650px; font-size: 14px; }
  .discipline-table { min-width: 600px; }
  .catalogue-table { min-width: 720px; }
  th { font-size: 13px; }
  th, td { padding: 0 8px; }
  .table-footer { padding: 8px 12px; font-size: 12px; overflow-wrap: anywhere; }
  .detail-heading { display: flex; flex-wrap: wrap; align-items: center; padding: 10px; gap: 8px; }
  .detail-title { flex: 1 1 100%; }
  .detail-feedback { flex: 1 1 100%; order: 3; min-height: 0; }
  .detail-actions { flex-wrap: wrap; margin-left: 0; }
  .detail-scroll { padding: 10px; }
  .personal-layout { --photo-size: 128px; gap: 14px; }
  .personal-layout .personal-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-height: 0; }
  .personal-layout .personal-grid > dl { display: block; }
  .personal-layout .detail-field { margin-bottom: 10px; }
  .personal-layout .detail-field input, .billing-panel .payment-payers input:not([type=checkbox]),
  .billing-panel .payment-top select { height: 42px; font-size: 16px; }
  .detail-section input:not([type=checkbox]), .detail-section select, .detail-section textarea { font-size: 16px; min-height: 42px; }
  .class-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .class-slot { padding: 6px; }
  .finance-panels { grid-template-columns: minmax(0, 1fr); }
  .finance-panels > .detail-section { min-height: 0; }
  .fees-panel { width: 100%; }
  .billing-panel .payment-top, .billing-panel .payment-payers { grid-template-columns: minmax(0, 1fr); }
  .billing-panel .payment-markers { height: auto; flex-wrap: wrap; }
  .discipline-view-content { padding: 12px; }
  .discipline-info { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .discipline-info > div { padding: 10px; }
  .catalogue-table th, .catalogue-table td { padding: 8px; }
  .trial-form { max-width: 100%; }
  dialog { max-width: calc(100vw - 24px); }
}

@media (max-width: 700px) {
  .app-header { grid-template-areas: "logo course" "controls session" "actions actions"; }
  .session-control span { display: none; }
  .session-control { justify-content: flex-end; }
  .mobile-controls { min-width: 0; }
  .mobile-controls button { min-width: 0; font-size: 12px; }
  .listing-filters { min-height: 0; flex-shrink: 1; overflow-y: auto; max-height: 35vh; }
  .table-scroll { overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
  #students-table { display: block; width: 100%; min-width: 0; }
  #students-table colgroup { display: none; }
  #students-table thead { display: block; position: sticky; top: 0; z-index: 3; background: var(--table-heading); }
  #students-table thead tr { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
  #students-table thead th { position: static; height: auto; min-height: 38px; padding: 0 8px; }
  #students-table thead th:nth-child(4) { display: none; }
  #students-table thead th:nth-child(5) { grid-column: 1 / -1; padding: 3px 8px; }
  #students-table tbody { display: block; }
  #students-table tbody tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
    grid-template-areas: "name surname" "second field" "disc disc"; padding: 4px 8px; border-bottom: 1px solid var(--separator); }
  #students-table tbody td { min-width: 0; height: auto; padding: 4px 6px; border: 0; overflow: visible;
    white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
  #students-table tbody td::before { content: attr(data-mobile-label) ": "; display: inline; font-size: 11px; color: var(--muted); }
  #students-table tbody td:first-child { position: static; background: transparent; grid-area: name; }
  #students-table tbody td:nth-child(2) { grid-area: surname; }
  #students-table tbody td:nth-child(3) { grid-area: second; }
  #students-table tbody td:nth-child(4) { grid-area: disc; }
  #students-table tbody td:nth-child(5) { grid-area: field; }
  #students-table tbody tr.has-import-issues td::before { color: #f7d4d4; }
  :root[data-theme="light"] #students-table tbody tr.has-import-issues td::before { color: #662121; }
  #students-table #empty-results { display: block; }
  #students-table #empty-results td { text-align: center; }
  #students-table #empty-results td::before { display: none; }
}
