/* Batches & Programs (app/training/batches): the compact administration workspace shared by the redesigned finance and training pages.
   4px spacing scale, brand tokens only, neutral elevation, sentence-case labels, tabular numerals. Teal marks selection and the primary action;
   gold marks what needs attention (a closed draft, a batch without an instructor). Scoped to this page (.bt-page, body[data-nav="batches"]); the
   calendar's own styles (css/batch-calendar.css, shared with the student page) are untouched apart from the view switch below. */

/* ---------------------------------------------------------------- page shell */
body.has-topbar[data-nav="batches"] .admin-header { display: none; }

/* .bt-page is also .admin-content, which grows to fill the viewport: a top-aligned flex column cannot stretch its rows into gaps. */
.bt-page { display: flex; flex-direction: column; align-content: flex-start; gap: 12px; width: 100%; max-width: 1440px; padding-top: 16px; padding-bottom: 32px; caret-color: var(--c-primary); }
.bt-page .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.bt-page ::selection { background: #cde6ec; color: var(--c-text); }
.bt-page > #adminAlert { position: fixed; top: calc(var(--adm-topbar-h, 56px) + 12px); right: 24px; z-index: 1100; width: min(420px, calc(100vw - 32px)); margin: 0; box-shadow: var(--e-2); }
.bt-page :where(button, select, input, th):focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

/* ---------------------------------------------------------------- header: title, a compact search, and the primary action on one row */
.bt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.bt-head h1 { flex: 1 0 auto; margin: 0; color: var(--c-text); font-family: var(--font-sans); font-size: 1.5rem; font-weight: 650; line-height: 1.2; letter-spacing: -.02em; white-space: nowrap; }
.bt-search { position: relative; flex: 1 1 180px; max-width: 280px; min-width: 140px; margin: 0; }
.bt-search i { position: absolute; top: 50%; left: 11px; color: var(--c-text-muted); font-size: .75rem; pointer-events: none; transform: translateY(-50%); }
.bt-search input { width: 100%; height: 36px; padding: 0 10px 0 32px; border: 1px solid var(--c-border-strong); border-radius: 8px; background: #fff; color: var(--c-text); font: inherit; font-size: .8125rem; }
.bt-search input::placeholder { color: var(--c-text-muted); }
.bt-search input:hover { border-color: #aab6c2; }
.bt-search input:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus-ring); }
.bt-head .btn-primary { flex: none; min-height: 36px; padding: 0 16px; border-radius: 8px; background: var(--c-primary); font-size: .875rem; font-weight: 600; white-space: nowrap; }
.bt-head .btn-primary:hover { background: var(--c-primary-hover); }

/* ---------------------------------------------------------------- toolbar: filters, Reset, the count, and the Table / Calendar segmented control, all on one line */
.bt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); }
.bt-control { flex: 0 1 170px; height: 36px; min-width: 128px; max-width: 100%; padding: 0 24px 0 10px; border: 1px solid var(--c-border-strong); border-radius: 8px; background-color: #fff; color: var(--c-text); font: inherit; font-size: .8125rem; }
.bt-control:hover { border-color: #aab6c2; }
.bt-control:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus-ring); }
#filterInstructor.bt-control { flex-basis: 190px; }
#sortBy.bt-control { flex-basis: 200px; }
.bt-ghost { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--c-text-secondary); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; }
.bt-ghost i { font-size: .75rem; }
.bt-ghost:hover { background: var(--c-bg); color: var(--c-text); }
.bt-count { margin-left: auto; color: var(--c-text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bt-count #batchCountBadge { color: var(--c-text); font-weight: 650; }

/* the segmented control (the base rules live in css/batch-calendar.css, shared with the student page) */
.bt-toolbar .view-switch { flex: none; margin: 0; padding: 2px; gap: 2px; overflow: visible; border: 1px solid var(--c-border); border-radius: 8px; background: #f4f6f8; }
.bt-toolbar .view-switch button { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 12px; border-radius: 6px; color: var(--c-text-secondary); font-size: .8125rem; font-weight: 600; transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.bt-toolbar .view-switch button + button { border-left: none; }
.bt-toolbar .view-switch button i { font-size: .75rem; }
.bt-toolbar .view-switch button:hover { color: var(--c-text); }
.bt-toolbar .view-switch button[aria-pressed="true"] { background: #fff; color: var(--c-primary); box-shadow: var(--e-1); }
.bt-toolbar .view-switch button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* the calendar sits as a panel in the same rhythm as the table */
.bt-page .batch-calendar { margin-bottom: 0; border-radius: 12px; box-shadow: var(--e-1); }

/* ---------------------------------------------------------------- table */
.bt-panel { container: bt / inline-size; min-width: 0; margin: 0; border: 1px solid var(--c-border); border-radius: 12px; background: var(--c-surface); box-shadow: var(--e-1); overflow: clip; }
.bt-panel[hidden] { display: none; }
.bt-loader { min-height: 0; padding: 16px; }
.bt-panel .bt-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: .8125rem; }   /* beats admin.css's .table-container table { min-width: 560px } */
.bt-table th { padding: 9px 12px; border-bottom: 1px solid var(--c-border); background: #f8fafb; color: var(--c-text-muted); font-size: .75rem; font-weight: 600; letter-spacing: 0; text-align: left; text-transform: none; white-space: nowrap; }
.bt-table th.sortable-th { cursor: pointer; user-select: none; }
.bt-table th.sortable-th:hover { color: var(--c-text); }
.bt-table th.sortable-th i { margin-left: 4px; color: #b4bec8; font-size: .6875rem; }
.bt-table th.is-sorted { color: var(--c-primary); }
.bt-table th.is-sorted i { color: var(--c-primary); }
.bt-table td { padding: 10px 12px; border-bottom: 1px solid #eef1f4; color: var(--c-text-secondary); vertical-align: middle; }
.bt-table th:first-child, .bt-table td:first-child { padding-left: 16px; }
.bt-table th:last-child, .bt-table td:last-child { padding-right: 16px; }
.bt-table tbody tr:last-child td { border-bottom: 0; }
.bt-table tbody tr:hover td { background: #f9fbfc; }
.bt-program strong { color: var(--c-text); font-weight: 600; }
.bt-date, .bt-seats { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bt-seats { text-align: left; }
.bt-instructor { min-width: 140px; }
.bt-sub { display: block; margin-top: 1px; color: var(--c-text-muted); font-size: .75rem; line-height: 1.35; }
.bt-flag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; background: #fff1d6; color: #7a4d00; font-size: .75rem; font-weight: 600; line-height: 1.4; }
.bt-status-cell { white-space: nowrap; }

/* status: a small dot and its name; a closed draft is gold, an open batch green, a running one teal, a finished or cancelled one quiet grey */
.bt-table .badge.bt-status { display: inline-flex; align-items: center; gap: 8px; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.bt-table .badge.bt-status::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bt-table .bt-status.s-draft { background: #fff1d6; color: #7a4d00; }
.bt-table .bt-status.s-draft::before { background: var(--c-accent); }
.bt-table .bt-status.s-open { background: var(--c-success-bg); color: var(--c-success); }
.bt-table .bt-status.s-active { background: var(--c-primary-soft); color: var(--c-primary); }
.bt-table .bt-status.s-completed { background: #eceff2; color: var(--c-text-secondary); }
.bt-table .bt-status.s-cancelled { background: var(--c-danger-bg); color: var(--c-danger); }

/* row actions: quiet icon buttons that take their meaning from the tooltip and the label, and a tint on hover */
.bt-table td.bt-actions { display: table-cell; width: 1%; white-space: nowrap; }
.bt-table .btn-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-right: 2px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--c-text-muted); font-size: .8125rem; cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.bt-table .btn-icon:last-child { margin-right: 0; }
.bt-table .btn-icon:hover { background: var(--c-bg); color: var(--c-text); }
.bt-table .btn-edit:hover { background: var(--c-primary-soft); color: var(--c-primary); }
.bt-table .btn-status.to-open { color: var(--c-success); }
.bt-table .btn-status.to-open:hover { background: var(--c-success-bg); color: var(--c-success); }
.bt-table .btn-status.to-active, .bt-table .btn-status.to-completed { color: var(--c-primary); }
.bt-table .btn-status.to-active:hover, .bt-table .btn-status.to-completed:hover { background: var(--c-primary-soft); color: var(--c-primary); }
.bt-table .btn-status.to-cancelled { color: var(--c-danger); }
.bt-table .btn-status.to-cancelled:hover { background: var(--c-danger-bg); color: var(--c-danger); }
.bt-empty { padding: 32px 16px !important; color: var(--c-text-muted); font-size: .8125rem; text-align: center; }
.bt-empty i { display: block; margin-bottom: 8px; color: #b4bec8; font-size: 1.25rem; }
.bt-empty strong { display: block; margin-bottom: 8px; color: var(--c-text); font-weight: 600; }
.bt-empty .bt-ghost { border: 1px solid var(--c-border-strong); background: #fff; }

/* the dialogs' titles are h2 now (the page title is the h1, so no level is skipped): same size, weight and rhythm as before */
body[data-nav="batches"] .modal-header h2 { margin: 0; color: var(--c-text); font-family: var(--font-sans); font-size: var(--fs-h3); font-weight: 600; line-height: var(--lh-h3); letter-spacing: -.01em; }

/* ---------------------------------------------------------------- responsive: the table panel's own width decides when rows become cards */
@container bt (max-width: 760px) {
  .bt-table, .bt-table tbody { display: block; width: 100%; }
  .bt-table thead { position: absolute; left: -9999px; }
  .bt-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 10px 12px; border-bottom: 1px solid #eef1f4; }
  .bt-table tbody tr:last-child { border-bottom: 0; }
  .bt-table td, .bt-table td:first-child, .bt-table td:last-child { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-width: 0; padding: 3px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .bt-table tbody tr:hover td { background: transparent; }
  .bt-table td::before { content: attr(data-label); flex: none; color: var(--c-text-muted); font-size: .75rem; font-weight: 600; text-align: left; }
  .bt-table td.bt-program { grid-column: 1; grid-row: 1; display: block; padding-top: 0; font-size: .9375rem; text-align: left; }
  .bt-table td.bt-program::before, .bt-table td.bt-actions::before { display: none; }
  .bt-table td.bt-status-cell { grid-column: 2; grid-row: 1; display: block; padding-top: 0; text-align: right; }
  .bt-table td.bt-status-cell::before { display: none; }
  .bt-table td.bt-date, .bt-table td.bt-seats, .bt-table td.bt-instructor { grid-column: 1 / -1; }
  .bt-table td.bt-actions { grid-column: 1 / -1; display: flex; width: auto; justify-content: flex-end; gap: 4px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--c-border); }
  .bt-table td.bt-instructor { min-width: 0; }
  .bt-empty { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .bt-toolbar .bt-count { margin-left: 0; order: 9; }
}
@media (max-width: 768px) {
  .bt-table .btn-icon { width: 44px; height: 44px; }
  .bt-control, .bt-search input, .bt-ghost, .bt-head .btn-primary { min-height: 44px; height: 44px; }
  .bt-toolbar .view-switch button { min-height: 40px; }
}
@media (max-width: 680px) {
  .bt-page { gap: 8px; padding-top: 8px; }
  .bt-page > #adminAlert { right: 16px; }
  .bt-head { flex-wrap: wrap; }
  .bt-head h1 { font-size: 1.25rem; }
  .bt-search { order: 3; flex: 1 1 100%; max-width: none; }
  .bt-toolbar { padding: 8px; }
  .bt-control { flex: 1 1 calc(50% - 4px); min-width: 0; }
  #filterInstructor.bt-control, #sortBy.bt-control { flex-basis: calc(50% - 4px); }
  .bt-toolbar .view-switch { margin-left: auto; }
  .bt-toolbar .bt-count { margin-left: 0; order: 0; }
}
@media (prefers-reduced-motion: reduce) { .bt-toolbar .view-switch button, .bt-table .btn-icon { transition: none; } }

/* ---------------------------------------------------------------- Create / Edit Batch: a compact form. The header and the actions stay put; only the fields scroll. */
.bf-modal { padding: 12px; box-sizing: border-box; }
.bf-modal .modal-content { display: flex; flex-direction: column; max-width: 560px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: hidden; border-radius: 12px; }
.bf-modal form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.bf-modal .modal-header { flex: none; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 20px; }
.bf-title { display: flex; flex: 1 1 0; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.bf-status { display: inline-flex; align-items: center; gap: 2px; padding-left: 8px; border-radius: 6px; background: #f1f4f7; color: var(--c-text-secondary); font-size: .75rem; font-weight: 600; }
.bf-modal .close-modal { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; }
.bf-modal .close-modal:hover { background: var(--c-bg); color: var(--c-text); }
.bf-modal .modal-header .bf-tip { flex: 1 0 100%; }
.bf-modal .modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 16px; }
.bf-modal .modal-footer { flex: none; gap: 8px; padding: 12px 20px; background: var(--c-surface); }
.bf-modal .modal-footer .btn { min-height: 38px; padding: 0 18px; border-radius: 8px; font-size: .875rem; font-weight: 600; }
.bf-cancel { background: #e9ecef; color: #333; }
.bf-section { margin: 0; padding: 12px 0 0; border: 0; min-width: 0; }
.bf-section + .bf-section { margin-top: 14px; border-top: 1px solid var(--c-border); }
.bf-section h3 { margin: 0 0 8px; color: var(--c-primary); font-family: var(--font-sans); font-size: .75rem; font-weight: 700; letter-spacing: .08em; line-height: 1.4; text-transform: uppercase; }
.bf-field { min-width: 0; }
.bf-section > .bf-field + .bf-field, .bf-section > .bf-field + .bf-row, .bf-section > .bf-row + .bf-field { margin-top: 10px; }
.bf-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; align-items: end; }
.bf-row--seats { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.bf-label { display: flex; align-items: center; gap: 4px; min-height: 24px; margin-bottom: 2px; color: var(--c-text); font-size: .8125rem; font-weight: 600; }
.bf-modal .bf-label label { display: inline; margin: 0; font-weight: 600; }
.bf-help { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--c-text-muted); font-size: .8125rem; cursor: pointer; }
.bf-help:hover, .bf-help[aria-expanded="true"] { background: var(--c-primary-soft); color: var(--c-primary); }
.bf-modal :where(button, input):focus-visible { outline: none; box-shadow: var(--focus-ring); }
.bf-tip { margin: 0 0 6px; padding: 8px 10px; border: 1px solid #cfe3e8; border-radius: 8px; background: #f2f9fa; color: var(--c-text-secondary); font-size: .8125rem; font-weight: 400; line-height: 1.45; }
.bf-tip[hidden] { display: none; }
.bf-modal .form-control { box-sizing: border-box; height: 38px; padding: 0 10px; border: 1px solid var(--c-border-strong); border-radius: 8px; background: #fff; font-size: .875rem; }
.bf-modal .form-control[readonly] { background: #f1f4f7; color: var(--c-text-secondary); }
.bf-money { position: relative; }
.bf-money span { position: absolute; top: 50%; left: 11px; color: var(--c-text-muted); font-size: .875rem; transform: translateY(-50%); pointer-events: none; }
.bf-modal .bf-money .form-control { padding-left: 28px; font-variant-numeric: tabular-nums; }
.bf-lock { margin-top: 8px; }
.bf-lock[hidden], .bf-modal #correctionRow[hidden] { display: none; }
.bf-lock .bf-label { margin: 0; color: var(--c-text-secondary); font-weight: 500; }
.bf-lock .bf-tip { margin: 4px 0 0; }
.bf-warn { margin: 8px 0 0; color: #8a4b00; font-size: .8125rem; line-height: 1.45; }
.bf-warn[hidden] { display: none; }
.bf-correct { margin-top: 8px; border-radius: 8px; background: #fef3c7; color: #92400e; font-size: .8125rem; }
.bf-picker { max-height: 132px; overflow-y: auto; padding: 4px 10px; border: 1px solid var(--c-border-strong); border-radius: 8px; font-size: .875rem; }
.bf-modal .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 600px) {
  .bf-modal { padding: 8px; }
  .bf-modal .modal-content { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .bf-modal .modal-header, .bf-modal .modal-footer { padding: 10px 14px; }
  .bf-modal .modal-body { padding: 0 14px 14px; }
  .bf-modal .form-control { height: 44px; font-size: 1rem; }   /* 16px: phones do not zoom into the field */
  .bf-help { width: 32px; height: 32px; }
  .bf-modal .close-modal { width: 44px; height: 44px; }
  .bf-modal .modal-footer .btn { flex: 1 1 0; min-height: 44px; }
}
@media (max-width: 420px) { .bf-row--dates { grid-template-columns: minmax(0, 1fr); } }
