/* Typography, spacing, sidebar and table follow the approved prototype. */
:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --paper: #fff;
  --ink: #14282a;
  --muted: #6b7c7e;
  --line: #e4eceb;
  --accent: #1a6b55;
  --accent-light: #dff1ea;
  --header: #12292b;
  --focus: #1a6b55;
  --warning: #9a5205;
  --warning-light: #fdecd3;
  --danger: #a63a2e;
  --danger-light: #f9dedb;
  --gray: #eceff0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
h1, h2, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 16px; font-weight: 600; }
input, select, button { font: inherit; }
button, input, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--paper);
  color: var(--ink);
}
button { cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { background: var(--bg); }
button:disabled { opacity: .53; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.primary, button.danger.solid { padding: 8px 14px; color: white; font-weight: 600; }
button.primary { background: var(--accent); border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: #155843; }
button.danger.solid { background: var(--danger); border-color: var(--danger); }
button.danger.solid:hover:not(:disabled) { background: #862d24; }
.shell { width: min(1440px, calc(100% - 32px)); margin-inline: auto; }
.top { background: var(--header); color: white; }
.top-inner { display: flex; align-items: center; gap: 12px; padding-block: 12px; }
.brand, .session { display: flex; align-items: center; gap: 10px; }
.brand { flex-wrap: wrap; }
.brand-divider { height: 15px; border-left: 1px solid #678081; }
.session { min-width: 0; margin-inline-start: auto; color: #b9c9c8; }
.environment { color: #b9c9c8; }
.session-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session button { padding: 4px 9px; background: transparent; border-color: #516867; color: white; }
.session button:hover:not(:disabled) { background: #2c4444; }
main { padding-block: 16px 30px; }
.navigation, .tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.navigation { margin-inline-start: 8px; }
.navigation button, .tabs button { padding: 6px 14px; background: transparent; border: 0; font-weight: 600; }
.navigation button { color: #b9c9c8; }
.navigation button.current, .navigation button:hover:not(:disabled) { background: #bfe9d929; color: #bfe9d9; }
.tabs { margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs button { border-radius: 8px 8px 0 0; padding-block: 8px; }
.tabs button.current { background: var(--accent-light); color: var(--accent); }
.list-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; align-items: start; }
.panel, .filters { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.filters { padding: 8px; position: sticky; top: 12px; }
.filters h2 { margin: 10px 8px 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.filter-section + .filter-section { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
.filter-item {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; text-align: start;
}
.filter-item.current, .filter-item.current:hover { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.stat-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.near_expiry .stat-count, .expiry .due-soon { color: var(--warning); }
.ended .stat-count, .expiry .overdue { color: var(--danger); }
.button-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar { padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-toolbar { flex-wrap: nowrap; }
.search { display: flex; gap: 8px; flex: 1; min-width: 0; }
.search input { min-width: 0; width: 100%; background: var(--bg); }
.picker-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: start; }
th, td { padding: 7px 12px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 13px; line-height: 1.35; }
th { padding-block: 8px; text-align: start; color: var(--muted); background: var(--bg); border-top: 0; font-weight: 600; white-space: nowrap; }
td { overflow-wrap: anywhere; }
tbody tr:hover td { background: var(--bg); }
.text-button { background: transparent; color: var(--accent); border: 0; padding: 2px 6px; }
.text-button.destructive { color: var(--danger); }
.school-name { padding: 0; font-weight: 700; white-space: normal; text-align: start; overflow-wrap: anywhere; }
.school-cell .sub, .expiry small { display: block; margin-top: 2px; font-size: 11.5px; }
.school-list table, .account-list table { table-layout: fixed; min-width: 760px; }
.account-list table { min-width: 860px; }
.account-list th:nth-child(1) { width: 23%; }
.account-list th:nth-child(2) { width: 12%; }
.account-list th:nth-child(4) { width: 9%; }
.account-list th:nth-child(5) { width: 24%; }
.account-list td:last-child { padding-inline: 8px; }
.account-list :is(th, td):is(:nth-child(2), :nth-child(4), :nth-child(5)),
.school-list :is(th, td):nth-child(n + 2),
:is(.school-members, .account-schools) :is(th, td):nth-child(n + 2) { text-align: center; }
:is(.account-list, .school-members, .account-schools) td:last-child .button-row { justify-content: center; }
.school-list th:nth-child(2), .school-list th:nth-child(3) { width: 86px; }
.school-list th:nth-child(4) { width: 160px; }
.school-list th:nth-child(5) { width: 110px; }
.school-list th:nth-child(6) { width: 135px; }
.school-list td:nth-child(6) { padding-inline: 8px; font-variant-numeric: tabular-nums; }
.school-list th:last-child { width: 72px; }
@media (min-width: 1140px) {
  .school-list th:first-child { width: 34%; }
  .school-list th:nth-child(2), .school-list th:nth-child(3),
  .school-list th:nth-child(5) { width: 11%; }
  .school-list th:nth-child(4) { width: 14%; }
  .school-list th:nth-child(6) { width: 12%; }
  .school-list th:last-child { width: 7%; }
  .school-list :is(th, td):nth-child(n + 2) { padding-inline: 8px; }
}
.table-scroll td .pill, .facts dd .pill { margin: 0; }
.school-list .row-action { padding-inline: 0; }
.school-members table { min-width: 570px; }
.school-members th:first-child { width: 32%; }
.school-members th:last-child { width: 144px; }
.account-schools table { min-width: 370px; }
.account-schools th:last-child { width: 146px; }
#app[aria-busy="true"], .drawer[aria-busy="true"] { cursor: progress; }
#app[aria-busy="true"] button:not(:disabled), .drawer[aria-busy="true"] button:not(:disabled) { cursor: progress; }
.row-action { font-weight: 600; }
.sub, .expiry small, .muted, .hint { font-size: 12px; color: var(--muted); }
.school-id { margin: 4px 0 12px; overflow-wrap: anywhere; }
.expiry { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; border-radius: 99px; padding: 1px 10px; margin: 2px 4px 2px 0;
  font-size: 12px; white-space: nowrap; background: var(--gray); color: var(--muted); }
.pill.green { background: var(--accent-light); color: var(--accent); }
.pill.amber { background: var(--warning-light); color: var(--warning); }
.pill.red { background: var(--danger-light); color: var(--danger); }
.pill.blue { background: #e4eef9; color: #2a5179; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 8px 12px; }
.pagination button { font-size: 12px; padding: 4px 8px; }
.overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.padded { padding: 16px; }
.facts { margin: 12px 0 0; }
.facts > div { display: grid; grid-template-columns: 6em minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.overview .facts > div { min-height: 40px; }
.overview-footer { margin-top: 12px; }
.overview-footer p { margin-top: 6px; }
.setup-progress { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--accent-light); color: var(--accent); }
@media (min-width: 681px) {
  .overview section:last-child .facts { padding-bottom: 40px; }
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.file-drop { display: grid; justify-items: center; gap: 8px; padding: 18px;
  border: 1px dashed var(--focus); border-radius: 8px; text-align: center; background: var(--bg); }
.file-drop.dragging { background: var(--accent-light); }
.file-name { max-width: 100%; overflow-wrap: anywhere; color: var(--accent); }
.file-name:empty { display: none; }
.file-confirm { display: flex; align-items: flex-start; gap: 7px; }
.audit table { table-layout: fixed; min-width: 760px; }
.audit :is(th, td) { font-size: 12px; padding: 7px 9px; white-space: nowrap; }
.audit th:first-child { width: 140px; }
.audit th:nth-child(2) { width: 92px; }
.audit th:nth-child(3) { width: 80px; }
.audit th:nth-child(4) { width: 128px; }
.audit time { font-variant-numeric: tabular-nums; }
.single-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice {
  position: fixed; right: 24px; bottom: 24px; max-width: min(450px, 100% - 48px); margin: 0;
  padding: 11px 17px; border: 1px solid #aed6c7; border-radius: 8px;
  background: #e8f6ef; color: #145643; box-shadow: 0 5px 24px #1730271c;
}
.notice.error, .dialog-error { background: #fff3ef; color: #8c302a; border: 1px solid #e6bbb4; }
.dialog-error { padding: 9px 12px; border-radius: 7px; }
dialog {
  width: min(100% - 28px, 465px); max-height: calc(100% - 28px); padding: 0; border: 1px solid var(--line);
  border-radius: 13px; color: var(--ink); background: var(--paper); box-shadow: 0 14px 65px #142f3a33;
}
dialog::backdrop { background: #172f39a1; }
.drawer {
  inset: 0 0 0 auto; margin: 0; width: min(900px, 100%); max-width: 100%;
  height: 100%; max-height: 100%; padding: 17px; border: 0; border-radius: 0; background: var(--bg);
  overflow: auto;
}
.drawer::backdrop { background: #08161673; }
@media (prefers-reduced-motion: no-preference) {
  .navigation button, .tabs button, .filter-item { transition: background-color 140ms ease, color 140ms ease; }
  dialog[open] { animation: dialog-enter 165ms ease-out; }
  .drawer[open] { animation: drawer-enter 205ms cubic-bezier(.17,.8,.24,1); }
  dialog[open]::backdrop { animation: backdrop-enter 165ms ease-out; }
  .view-enter { animation: view-enter 150ms ease-out; }
}
@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes drawer-enter {
  from { opacity: .75; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes view-enter {
  from { opacity: .65; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.drawer-header h1 { font-size: 1.4rem; }
.drawer-header button { font-size: .85rem; padding: 4px 8px; min-height: 30px; }
.drawer-header .button-row { flex-wrap: nowrap; }
.drawer-notice { margin-bottom: 10px; padding: 7px 10px; border-radius: 6px; background: #e8f6ef; color: #145643; }
.drawer-notice.error { background: #fff3ef; color: #8c302a; }
.dialog-form, .dialog-fields, .login-form, .field { display: grid; gap: 13px; }
.dialog-form { padding: 22px; gap: 17px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.field { gap: 5px; font-weight: 400; font-size: 14px; }
.field input, .field select { min-width: 0; width: 100%; font-weight: 400; }
.target-name { font-weight: 600; overflow-wrap: anywhere; }
.date-shortcuts { display: flex; flex-wrap: wrap; gap: 6px; }
.date-shortcuts button { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.login { max-width: 400px; margin: clamp(16px, 9vh, 72px) auto 0; padding: clamp(20px, 5vw, 35px); }
.login h1 { margin-bottom: 12px; }
.login .primary { margin-top: 9px; }
@media (max-width: 860px) {
  .list-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .filters { position: static; }
  .filter-group { display: flex; flex-wrap: wrap; gap: 4px; }
  .filter-item { width: auto; }
  .top-inner { flex-wrap: wrap; }
  .navigation { order: 1; width: 100%; margin-inline-start: 0; }
}
@media (max-width: 550px) {
  .shell { width: calc(100% - 20px); }
  .list-toolbar { flex-wrap: wrap; }
  .list-toolbar .search { flex-basis: 100%; }
  .list-toolbar > .primary { margin-inline-start: auto; }
  .drawer { padding: 12px; }
}
@media (max-width: 680px) {
  .overview { grid-template-columns: minmax(0, 1fr); }
}
