/* School Management - panel and staff-app styles (ADR-0007), split by area into ui.css and ui-*.css. Load order, kept in
   Web App.razor and the staff app's index.html (UiCssFilesTests): tokens.css, palettes.css, ui.css, ui-people.css, ui-records.css, ui-dashboard.css, ui-gate.css, ui-misc.css, then app.css
   (web) or mobile.css (staff app). A later file may override an earlier one, as the single file did.
   This file: base elements, home, roles (master/detail), shared pieces, academic structure. */
/*
  School Management - admin panel.
  Brand colours shared with the School Inventory app: green, yellow, white.
  Deep green carries the frame (sidebar, primary actions); yellow is the spark (active marks, avatar, highlights)
  and is never used as text on a light background.
*/
/* Font and design tokens: tokens.css (loaded first). */

* { box-sizing: border-box; }
:root { accent-color: var(--green); caret-color: var(--green); scrollbar-color: #C9D2C7 transparent; }
::selection { background: var(--green-100); color: var(--green-950); }
a { text-underline-offset: 3px; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1 { font-size: 1.85rem; line-height: 1.2; font-weight: 700; margin: 0 0 .4rem; letter-spacing: -.015em; }
h2 { font-size: 1rem; font-weight: 600; margin: 0; }
p { margin: 0 0 .75rem; }
a { color: var(--green); }
small, .small { font-size: .8rem; }
.num { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.pad { padding: 12px 16px; margin: 0; }
.icon { flex: none; display: block; }

.spinner {
  inline-size: 16px; block-size: 16px; flex: none;
  border: 2px solid var(--line-strong); border-top-color: var(--green);
  border-radius: 50%;
  animation: spin var(--dur-spin) linear infinite;
}
.spinner.light { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.soon {
  margin-inline-start: auto;
  font-size: .68rem; font-weight: 500;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.62);
}

.icon-btn {
  display: grid; place-items: center;
  inline-size: 32px; block-size: 32px; flex: none;
  border: none; border-radius: var(--r-sm);
  background: transparent; color: inherit; opacity: .7;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.icon-btn:hover { opacity: 1; background: rgba(255,255,255,.08); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head p { margin: 0; max-width: 70ch; }
.account-password { max-inline-size: 480px; }

/* ================================================================ home */
.home-grid {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 16px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel-foot { margin: 16px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }

.progress { block-size: 6px; border-radius: 999px; background: var(--green-50); overflow: hidden; margin: 14px 0 6px; }
.progress span { display: block; block-size: 100%; border-radius: inherit; background: var(--green); transition: inline-size var(--dur-slow) var(--ease); }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: center; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: none; padding-bottom: 0; }
.step-icon { color: var(--line-strong); display: flex; }
.step.is-done .step-icon { color: var(--green-600); }
.step-text { display: flex; flex-direction: column; flex: 1; line-height: 1.4; }
.step-text small { color: var(--muted); }
.step.is-done .step-text strong, .step.is-soon .step-text strong { color: var(--muted); font-weight: 500; }
.step .soon { background: var(--bg); color: var(--faint); }

/* Label left, figure right, one right edge for every number. */
.figures { margin: 10px 0 0; }
.figure { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.figure:last-child { border-bottom: none; }
.figure dt { color: var(--muted); }
.figure dd { margin: 0; font-size: 1.15rem; font-weight: 600; }
.figure dd a { color: var(--text); text-decoration: none; }
.figure dd a:hover { color: var(--green); text-decoration: underline; }

/* Loading placeholder: a flat grey bar at the value's real size, no shimmer. */
.skeleton { display: inline-block; inline-size: 2.5em; block-size: .9em; border-radius: 4px; background: #E9ECE7; vertical-align: middle; }
.skeleton.w-20 { inline-size: 20%; }
 .skeleton.w-30 { inline-size: 30%; }
 .skeleton.w-50 { inline-size: 50%; }

/* ================================================================ roles: master / detail */
.split {
  display: grid; grid-template-columns: 300px minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
  min-height: 560px;
}
.split-list { border-inline-end: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; }
.split-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.role-list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.role-item {
  inline-size: 100%;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
  padding: 10px 12px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.role-item:hover { background: var(--surface); border-color: var(--line); }
.role-item.is-selected { background: var(--surface); border-color: var(--green-100); }
.role-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-meta { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.role-bar { grid-column: 1 / -1; block-size: 3px; border-radius: 3px; background: var(--green-50); overflow: hidden; margin-top: 6px; }
.role-bar span { display: block; block-size: 100%; background: var(--green-600); border-radius: inherit; }

.split-detail { display: flex; flex-direction: column; min-width: 0; }
.detail-head { padding: 22px 26px 6px; display: flex; flex-direction: column; gap: 2px; }
.title-input, .subtitle-input {
  border: none; background: transparent; padding: 4px 0; font: inherit; color: var(--text);
  inline-size: 100%;
}
.title-input { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.subtitle-input { color: var(--muted); }
.title-input:focus, .subtitle-input:focus { outline: none; box-shadow: inset 0 -2px 0 var(--green-100); }
.title-input::placeholder, .subtitle-input::placeholder { color: var(--faint); }

.detail-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 26px 14px; border-bottom: 1px solid var(--line); }
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; inline-size: min(320px, 100%);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--faint);
}
.search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-50); }
.search input { border: none; outline: none; background: transparent; padding: 8px 0; font: inherit; color: var(--text); inline-size: 100%; }

.perm-list { padding: 8px 26px 24px; flex: 1; overflow-y: auto; }
.perm-section { padding: 14px 0 6px; border-bottom: 1px solid var(--line); }
.perm-section:last-child { border-bottom: none; }
.perm-section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.perm-section-head .link-btn { margin-inline-start: auto; }
.perm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 9px 12px; margin-inline: -12px;
  border-radius: var(--r-md);
  cursor: pointer;
}
.perm-row:hover { background: var(--bg); }

/* Switch (styled checkbox, role="switch") */
.switch {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  inline-size: 38px; block-size: 22px; margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease);
}
.switch::after {
  content: "";
  position: absolute; inset-block-start: 3px; inset-inline-start: 3px;
  inline-size: 16px; block-size: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform var(--dur-base) var(--ease);
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(-16px); }
[dir="ltr"] .switch:checked::after { transform: translateX(16px); }

.savebar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 26px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
}
.savebar-actions, .savebar-confirm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.savebar-confirm span { color: var(--muted); font-size: .85rem; }

/* ================================================================ shared pieces */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  background: var(--green-50); color: var(--green);
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px;
  padding: 48px 24px;
  color: var(--muted);
}
.empty strong { color: var(--text); }
.empty-icon { display: grid; place-items: center; inline-size: 48px; block-size: 48px; border-radius: 50%; background: var(--fill-muted); color: var(--muted); margin-bottom: 4px; }
.empty p { max-width: 42ch; margin: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
label { font-weight: 500; font-size: .88rem; }

.field input {
  inline-size: 100%;
  padding: 11px 14px;
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field input:hover { border-color: var(--line-hover); }
.field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-50); }
.field input:disabled { background: var(--bg); color: var(--muted); }
.field input::placeholder { color: var(--faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; text-decoration: none; line-height: 1.4;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:active:not(:disabled), .chip:active:not(:disabled), .tab:active { transform: scale(.98); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }
.btn-danger { background: var(--error); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-block { inline-size: 100%; padding-block: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.danger-text { color: var(--error); border-color: transparent; background: transparent; }
.danger-text:hover:not(:disabled) { background: var(--error-50); }
.link-btn { border: none; background: none; padding: 2px 4px; font: inherit; font-size: .82rem; font-weight: 600; color: var(--green); cursor: pointer; border-radius: 6px; }
.link-btn:hover { background: var(--green-50); }

.error { color: var(--error); background: var(--error-50); border: 1px solid var(--error-line); border-radius: var(--r-md); padding: 10px 14px; }
.notice { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--r-md); padding: 10px 14px; animation: fade var(--dur-base) var(--ease); }

.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden; }
.table { inline-size: 100%; border-collapse: collapse; }
.table th { text-align: start; padding: 11px 20px; font-size: .78rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
.table td { padding: 13px 20px; border-bottom: 1px solid var(--line); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* Staff accounts */
.staff-create, .staff-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px; }
.staff-create { margin-bottom: 16px; }
.staff-section-head { margin-bottom: 12px; }
.staff-section-head h2 { margin: 0; font-size: 1.15rem; }
.staff-section-head p { margin: 5px 0 0; }
.staff-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-block: 16px; }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; gap: 12px; }
.staff-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.staff-card h2 { margin: 0; font-size: 1.1rem; }
.staff-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.staff-card-head p { margin: 4px 0 0; }
.staff-details { display: flex; flex-direction: column; margin: 0; }
.staff-details > div { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; padding-block: 7px; border-bottom: 1px solid var(--line); }
.staff-details > div:last-child { border-bottom: 0; }
.staff-details dt { color: var(--muted); font-size: .84rem; }
.staff-details dd { margin: 0; overflow-wrap: anywhere; }
.staff-roles { border: 0; border-top: 1px solid var(--line); margin: 16px 0; padding: 14px 0 0; min-inline-size: 0; }
.staff-roles legend { padding-inline-end: 8px; font-weight: 600; }
.staff-role-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.staff-role-option { display: flex; align-items: flex-start; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; font-weight: 400; }
.staff-role-option .check { flex: none; margin-top: 2px; }
.staff-role-option > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.staff-role-option small { font-size: .78rem; }
.staff-reset { border-top: 1px solid var(--line); padding-top: 12px; }
.staff-reset p { margin-block: 8px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; }
.status::before { content: ""; inline-size: 7px; block-size: 7px; border-radius: 50%; background: currentColor; }
.status.on { color: var(--green-600); }
.status.off { color: var(--faint); }
.tag { flex: none; white-space: nowrap; font-size: .76rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.tag.ok { background: var(--tag-ok-bg); color: var(--tag-ok-fg); }
.tag.late { background: var(--tag-late-bg); color: var(--tag-late-fg); }

/* ================================================================ academic structure */
.tabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px;
  background: var(--fill-soft); border-radius: var(--r-lg);
  max-width: 100%; overflow-x: auto;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: none; border-radius: var(--r-md);
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .88rem;
  cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--green); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.year-picker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-inline-size: 34px; padding: 4px 12px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer; font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.chip:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.chip:disabled { cursor: default; opacity: 1; }
.chip.is-active, .chip.is-active:hover:not(:disabled) { background: var(--green); border-color: var(--green); color: #fff; }
.chip-dot { inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.chip-add { border-style: dashed; color: var(--muted); padding-inline: 8px; }

.card-empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-xl); }
.card-empty .row-actions { justify-content: center; margin-top: 10px; }

.stage-list { display: grid; gap: 16px; }
.stage-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden; }
.stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.stage-head h2 { font-size: 1.02rem; }
.class-list { list-style: none; margin: 0; padding: 0; }
.class-row {
  display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.class-row:last-child { border-bottom: none; }
.class-row:hover { background: #FCFDFB; }
.class-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.35; }
.class-name .link-btn { padding: 0; font-weight: 500; }
.section-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.icon-btn.subtle { color: var(--muted); opacity: 1; }
.icon-btn.subtle:hover { background: var(--bg); color: var(--text); }

.subject-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.subject-card {
  inline-size: 100%; display: flex; align-items: center; gap: 12px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: inherit; font: inherit; text-align: start; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease);
}
.subject-card:hover:not(:disabled) { border-color: var(--line-strong); }
.subject-card:disabled { cursor: default; }
.subject-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.subject-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-text small { color: var(--muted); }

.table td .pill { margin-inline-start: 8px; }
.cell-actions { text-align: end; white-space: nowrap; }
.cell-actions > * { vertical-align: middle; }

.foot-note, .foot-delete, .foot-confirm { margin-inline-start: auto; }
.foot-confirm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; align-items: start; margin-block: 12px; }
.form-grid .field:has(textarea) { grid-column: 1 / -1; }
.form-grid > .btn { align-self: end; justify-self: start; }
.form-grid.one-col { grid-template-columns: minmax(0, 1fr); }
.transport-form .form-grid { margin-block: 0; }

.pick-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pick-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: var(--r-md); min-block-size: 44px; }
.pick-row:hover { background: var(--bg); }
.pick-row.is-picked { background: var(--green-50); }
.pick-label { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; flex: 1; }
.check { inline-size: 18px; block-size: 18px; accent-color: var(--green); margin: 0; }
.periods { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.periods input {
  inline-size: 58px; padding: 5px 8px; text-align: center;
  font: inherit; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
}
.periods input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-50); }
