/* Reusable components. One section per component in js/components/. */

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 38px; padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-alt); border-color: var(--color-text-faint); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-neutral-soft); color: var(--color-text); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { background: #8f1e18; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #185f3c; }
.btn-sm { min-height: 30px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-icon { min-height: 38px; width: 38px; padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn-sm { min-height: 36px; } }

/* --- Cards --- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border);
}
.card-header h2, .card-header h3 { font-size: var(--text-md); }
.card-body { padding: var(--space-5); }
.card-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-alt); border-radius: 0 0 var(--radius) var(--radius); }

/* --- Stat cards --- */
.stat { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.stat-label { font-size: var(--text-sm); color: var(--color-text-muted); display: flex; align-items: center; gap: var(--space-2); }
.stat-label svg { width: 16px; height: 16px; color: var(--color-primary); }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat.accent { border-top: 3px solid var(--color-primary); }
.stat.bad { border-top: 3px solid var(--color-error); }
a.stat:hover { text-decoration: none; box-shadow: var(--shadow); }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: 0.02em;
  white-space: nowrap; background: var(--color-neutral-soft); color: var(--color-text-muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge.plain::before, .badge-icon::before { display: none; }
.badge-icon svg { width: 12px; height: 12px; stroke-width: 2.6; }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-error { background: var(--color-error-soft); color: var(--color-error); }
.badge-info { background: var(--color-info-soft); color: var(--color-info); }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-lg { font-size: var(--text-sm); padding: 5px 14px; }

/* --- Alerts --- */
.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  border: 1px solid; font-size: var(--text-sm);
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert-success { background: var(--color-success-soft); border-color: #b9e0c9; color: #14522f; }
.alert-error { background: var(--color-error-soft); border-color: #f1c1bc; color: #7d1a15; }
.alert-warning { background: var(--color-warning-soft); border-color: #f0d9a8; color: #6b4500; }
.alert-info { background: var(--color-info-soft); border-color: #c3d6ec; color: #1b4a7b; }

/* --- Forms --- */
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.field .req { color: var(--color-error); margin-left: 2px; }
.field .help { font-size: var(--text-xs); color: var(--color-text-muted); }
.field .error-text { font-size: var(--text-xs); color: var(--color-error); font-weight: var(--weight-medium); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--color-surface); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); font-size: var(--text-base);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--color-error); }
.input[readonly] { background: var(--color-surface-alt); }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); font-weight: var(--weight-semibold); }
.input-prefix .input { padding-left: 30px; font-variant-numeric: tabular-nums; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }

/* --- Toolbar / filters --- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center;
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border);
}
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--color-text-faint); }
.search .input { padding-left: 34px; }
.toolbar .select { width: auto; min-width: 150px; flex: 0 1 200px; }
.toolbar .input[type="date"] { width: auto; flex: 0 1 160px; }
@media (max-width: 640px) { .toolbar .search, .toolbar .select, .toolbar .input[type="date"] { flex: 1 1 100%; max-width: none; } }
.form-alert:empty { display: none; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
.table th, .table td { padding: 12px var(--space-4); text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table th {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-text-muted); font-weight: var(--weight-semibold); background: var(--color-surface-alt);
  white-space: nowrap;
}
.table th.num, .table td.num { text-align: right; }
.table th button { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th button:hover { color: var(--color-text); }
.table th button svg { width: 12px; height: 12px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--color-surface-alt); }
.table tfoot td { font-weight: var(--weight-bold); background: var(--color-surface-alt); border-top: 2px solid var(--color-border-strong); }
.cell-title { font-weight: var(--weight-semibold); color: var(--color-text); }
.cell-sub { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Phones: each row becomes a card; labels come from data-label. */
@media (max-width: 720px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
  .table.responsive td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: var(--space-4); text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-size: var(--text-xs); color: var(--color-text-muted); font-weight: var(--weight-semibold); text-align: left; }
  .table.responsive td.num { justify-content: space-between; }
  .table.responsive tfoot { display: block; }
}

.pagination {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3);
  padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border);
  font-size: var(--text-sm); color: var(--color-text-muted);
}
.pagination .pages { display: flex; gap: var(--space-2); align-items: center; }

/* --- States: loading / empty / error --- */
.state { padding: var(--space-10) var(--space-6); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); color: var(--color-text-muted); }
.state svg.state-icon { width: 40px; height: 40px; color: var(--color-text-faint); }
.state h3 { color: var(--color-text); }
.state.error svg.state-icon { color: var(--color-error); }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--color-primary-soft); border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.btn .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
.btn-secondary .spinner { border-color: var(--color-primary-soft); border-top-color: var(--color-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 25, 23, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh var(--space-4) var(--space-4); overflow-y: auto;
  animation: fade 120ms ease;
}
.modal {
  width: 100%; max-width: 560px; background: var(--color-surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: rise 160ms ease;
}
.modal.lg { max-width: 760px; }
.modal.sm { max-width: 440px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-3); }
.modal-header h2 { font-size: var(--text-lg); }
.modal-body { padding: var(--space-2) var(--space-5) var(--space-5); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-border); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; overflow-y: auto; }
}

/* --- Toasts --- */
.toasts { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 80; display: flex; flex-direction: column; gap: var(--space-2); width: min(400px, calc(100vw - 2rem)); }
.toast {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  background: var(--color-surface); box-shadow: var(--shadow-lg); border-left: 4px solid var(--color-info);
  animation: rise 180ms ease; font-size: var(--text-sm);
}
.toast svg { width: 20px; height: 20px; flex: none; }
.toast .toast-body { flex: 1; }
.toast .toast-body strong { display: block; }
.toast .toast-body p { color: var(--color-text-muted); margin-top: 2px; }
.toast button { border: 0; background: none; color: var(--color-text-faint); padding: 2px; }
.toast-success { border-left-color: var(--color-success); } .toast-success svg { color: var(--color-success); }
.toast-error { border-left-color: var(--color-error); } .toast-error svg { color: var(--color-error); }
.toast-warning { border-left-color: var(--color-warning); } .toast-warning svg { color: var(--color-warning); }

/* --- Detail lists --- */
.details { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); }
.details dt { color: var(--color-text-muted); }
.details dd { margin: 0; font-weight: var(--weight-medium); min-width: 0; overflow-wrap: anywhere; }

/* --- Money summary + balance bar --- */
.money-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.money-grid div { padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--color-surface-alt); border: 1px solid var(--color-border); }
.money-grid span { display: block; font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.money-grid strong { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.money-grid .remaining { background: var(--color-primary-soft); border-color: #bcdcd7; }
.money-grid .remaining strong { color: var(--color-primary); }
@media (max-width: 520px) { .money-grid { grid-template-columns: 1fr; } }
.bar { height: 8px; border-radius: var(--radius-pill); background: var(--color-neutral-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--color-primary); border-radius: inherit; }
.bar.low > span { background: var(--color-warning); }
.bar.empty > span { background: var(--color-error); }
.bar-cell { min-width: 120px; }
.bar-cell .bar { margin-top: 4px; }

/* --- Timeline --- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 var(--space-5) 36px; }
.timeline li::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--color-border); }
.timeline li:last-child::before { display: none; }
.timeline li.done::before { background: #9fd0c8; }
.timeline .dot { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--color-surface); border: 2px solid var(--color-border-strong); }
.timeline li.done .dot { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.timeline li.bad .dot { background: var(--color-error); border-color: var(--color-error); }
.timeline .dot svg { width: 13px; height: 13px; }
.timeline .t-label { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.timeline li:not(.done) .t-label { color: var(--color-text-muted); }
.timeline .t-meta { font-size: var(--text-xs); color: var(--color-text-muted); }

/* --- Notification feed --- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.feed li:last-child { border-bottom: 0; }
.feed .f-icon { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--color-primary-soft); color: var(--color-primary); }
.feed .f-icon svg { width: 16px; height: 16px; }
.feed .f-body { flex: 1; min-width: 0; }
.feed .f-title { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.feed .f-text { font-size: var(--text-sm); color: var(--color-text-muted); }
.feed .f-meta { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: 2px; display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }

/* --- Tabs --- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-5); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tabs button:hover { color: var(--color-text); }

/* --- Charts --- */
.chart { width: 100%; }
.chart text { font-family: var(--font-sans); font-size: 11px; fill: var(--color-text-muted); }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .bar-rect { transition: opacity var(--transition); }
.chart .bar-rect:hover { opacity: 0.8; }
.c1 { fill: var(--chart-1); }

/* --- Document upload + document lists (public apply/status, staff review) --- */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* Upload tile: Uiverse "file-upload-label" (alsaad1060), made keyboard-reachable. */
.file-field { display: flex; flex-direction: column; gap: var(--space-2); }
.file-field > .help { flex: 1; }
.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  width: 100%; padding: 30px clamp(16px, 4vw, 70px); cursor: pointer; text-align: center;
  background: var(--upload-bg); color: var(--upload-ink);
  border: 2px dashed var(--upload-ink); border-radius: 40px;
  box-shadow: 0 0 200px -50px var(--upload-shadow);
  transition: border-color .3s, background .3s;
}
.file-drop > svg { height: 50px; width: auto; fill: var(--upload-ink); margin-bottom: 20px; }
.file-drop-text { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; max-width: 100%; }
.file-drop-text p { margin: 0; }
.file-drop-text small { font-size: var(--text-xs); color: var(--upload-ink); opacity: .8; margin-top: 4px; }
.browse-button {
  background: var(--upload-ink); color: #fff; padding: 5px 15px; border-radius: 10px;
  transition: background .3s;
}
.file-drop:hover .browse-button { background: var(--upload-ink-hover); }
.file-drop.dragging { border-color: var(--color-primary); background: var(--color-primary-soft); }
.file-drop-name { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; overflow-wrap: anywhere; font-weight: 600; }
.file-drop-name svg { width: 16px; height: 16px; flex: none; color: var(--color-success); }
.file-field:focus-within .file-drop { box-shadow: var(--focus-ring); }
.file-field.has-file .file-drop { border-style: solid; border-color: var(--color-success); }
.file-field.invalid .file-drop { border-color: var(--color-error); }
.file-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-5); }
.file-grid .file-drop { min-height: 250px; padding-inline: 16px; }
.doc-replace .file-drop { max-width: 340px; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list.staff .doc-item { padding: var(--space-4) var(--space-5); }
.doc-item { padding: var(--space-4) 0; border-bottom: 1px solid var(--color-border); }
.doc-item:last-child { border-bottom: 0; }
.doc-item.needs-action { background: linear-gradient(90deg, var(--color-error-soft), transparent 60%); }
.doc-list:not(.staff) .doc-item.needs-action { padding-left: var(--space-3); border-radius: var(--radius-sm); }
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.doc-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.doc-note { display: flex; gap: var(--space-2); align-items: flex-start; margin-top: var(--space-2); font-size: var(--text-sm); color: var(--color-error); }
.doc-note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.doc-replace { margin-top: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); }
.doc-status h3 { font-size: var(--text-md); margin-bottom: var(--space-2); }

/* --- Sign-in card (js/components/signin.js): staff login and applicant portal --- */
.signin {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; max-width: 450px; padding: 30px;
  background: var(--color-surface); border-radius: 20px;
  box-shadow: var(--shadow);
}
.signin-head h2 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: var(--signin-ink); }
.signin-head p { color: var(--color-text-muted); font-size: 14px; margin: 4px 0 6px; }
.signin-field { display: flex; flex-direction: column; gap: 8px; }
.signin-label { color: var(--signin-ink); font-weight: 600; }
.signin-box {
  display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 6px 0 12px;
  border: 1.5px solid var(--signin-line); border-radius: 10px; background: var(--color-surface);
  transition: border-color .2s ease-in-out;
}
.signin-box > svg { width: 20px; height: 20px; flex: none; color: var(--signin-ink); }
.signin-box:focus-within { border-color: var(--color-primary); }
.signin-field.invalid .signin-box { border-color: var(--color-error); }
.signin-input {
  flex: 1; width: 0; min-width: 0; height: 100%; border: none; background: transparent; /* width 0: no built-in input width on small phones */
  font: inherit; color: var(--color-text);
}
/* The box shows focus (below); base.css's ring on the bare input would draw a second box. */
.signin-input:focus, .signin-input:focus-visible { outline: none; box-shadow: none; }
.signin-box:focus-within { box-shadow: var(--focus-ring); }
.signin-input::placeholder { color: var(--color-text-faint); }
.signin-reveal {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: none; border-radius: 8px; background: none; color: var(--color-text-muted); cursor: pointer;
}
.signin-reveal:hover { color: var(--signin-ink); }
.signin-reveal:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.signin-reveal svg { width: 18px; height: 18px; }
.signin-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--color-text-muted); }
.signin-submit {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 50px; margin: 20px 0 10px;
  border: none; border-radius: 10px; background: var(--signin-ink); color: #fff;
  font: inherit; font-size: 15px; font-weight: 500; cursor: pointer;
}
.signin-submit:hover:not(:disabled) { background: var(--signin-ink-hover); }
.signin-submit:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.signin-submit:disabled { opacity: .75; cursor: progress; }
.signin-submit .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
.signin-foot { text-align: center; font-size: 14px; color: var(--signin-ink); margin: 5px 0; }
.signin-link { margin-left: 5px; color: var(--color-primary); font-weight: 500; }
.signin .alert { margin: 0; }
@media (max-width: 520px) { .signin { padding: 22px 18px; border-radius: 16px; } }

/* --- Name reveal: dashboard greeting (Uiverse "btn-wrapper" by dexter-st, as a heading) --- */
.name-reveal { display: inline-block; vertical-align: middle; margin: 6px 6px 12px; max-width: calc(100% - 12px); font-size: clamp(1.2rem, 6vw, 1.75rem); }   /* room for the corner points; shrinks on small phones */
.nr-box {
  position: relative; display: inline-grid; padding: .3em 1.1em;
  filter: drop-shadow(0 6px 2px #00000022) drop-shadow(0 14px 6px #00000018);
}
.nr-frame {
  position: absolute; inset: 0; z-index: 1;
  border: 1px solid var(--reveal-line); background: var(--reveal-bg);
  box-shadow: inset 0 1px 4px 1px #fff5;
  animation: nr-open calc(var(--reveal-speed) * .5) ease forwards;
}
.nr-point {
  position: absolute; width: 8px; aspect-ratio: 1; border-radius: 25%;
  border: 1px solid var(--reveal-line); background-color: var(--reveal-point);
  background-image: radial-gradient(circle at 50% 120%, #0005, #ffff);
}
.nr-point.top { top: -4px; }
.nr-point.bottom { bottom: -4px; }
.nr-point.left { left: -4px; }
.nr-point.right { right: -4px; }
.nr-txt-box {
  position: relative; z-index: 2; display: grid; white-space: nowrap;
  animation: nr-clip-open calc(var(--reveal-speed) * .5) ease forwards;
}
.nr-txt-box::after {                       /* faint moving sheen over the text */
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: repeating-linear-gradient(45deg, var(--reveal-shine), #ebf8e1 15%, #fff 20%);
  background-size: 440%; mix-blend-mode: hard-light; filter: blur(1px); opacity: .1;
  transition: background-size .4s ease-in;
}
.nr-txt {
  grid-area: 1 / 1; justify-self: center; font-family: var(--font-sans); font-weight: 500; color: var(--reveal-ink);
  text-shadow: 0 -1px 1px #ffffff60, 0 2px 1px #00000015, 0 4px 2px #00000015, 0 8px 4px #00000015;
}
.nr-alt { opacity: 0; }
.name-reveal:hover .nr-frame { animation: nr-pulse var(--reveal-speed) ease; }
.name-reveal:hover .nr-txt-box { animation: nr-clip-pulse var(--reveal-speed) ease; }
.name-reveal:hover .nr-txt-box::after { background-size: 700%; }
.name-reveal:hover .nr-txt:not(.nr-alt) { animation: nr-txt-out calc(var(--reveal-speed) * .5) forwards; }
.name-reveal:hover .nr-alt { animation: nr-txt-in calc(var(--reveal-speed) * .5) forwards; }
@keyframes nr-open { from { inset: 0 50%; } to { inset: 0 0; } }
@keyframes nr-pulse { 50% { inset: 0 50%; } }
@keyframes nr-clip-open { from { clip-path: inset(0 50%); } to { clip-path: inset(0 0); } }
@keyframes nr-clip-pulse { 50% { clip-path: inset(0 50%); } }
@keyframes nr-txt-out { 50% { opacity: 1; } 100% { opacity: 0; } }
@keyframes nr-txt-in { 90% { opacity: 0; } 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .nr-frame, .nr-txt-box, .name-reveal:hover .nr-frame, .name-reveal:hover .nr-txt-box { animation: none; }
}

/* --- shadcn/ui-style Card, Tabs and BorderBeam (js/components/ui.js) --- */
.ui-card {
  position: relative; background: var(--color-surface); color: var(--ui-fg);
  border: 1px solid var(--ui-border); border-radius: var(--ui-radius); box-shadow: var(--ui-shadow-sm);
}
/* The beam's travelling square hangs past the edge; clip it so it never widens the page. */
.ui-card.has-beam { overflow: hidden; }
.ui-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); padding: 20px 24px 14px; }
.ui-card-heading { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-card-title { font-size: 1rem; font-weight: 600; line-height: 1; letter-spacing: -0.01em; }
.ui-card-description { font-size: 0.875rem; color: var(--ui-muted-fg); }
.ui-card-content { min-width: 0; }
.ui-card-content > .card-body { padding: 0 24px 24px; }

.ui-tabs { display: flex; flex-direction: column; gap: var(--space-4); }
.ui-tabs-list {
  display: inline-flex; align-self: flex-start; align-items: center; gap: 2px; height: 40px; padding: 4px;
  border-radius: var(--ui-radius); background: var(--ui-muted); color: var(--ui-muted-fg);
  max-width: 100%; overflow-x: auto;
}
.ui-tabs-trigger {
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  height: 32px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent;
  color: inherit; font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.ui-tabs-trigger:hover { color: var(--ui-fg); }
.ui-tabs-trigger[data-state="active"] { background: var(--color-surface); color: var(--ui-fg); box-shadow: var(--ui-shadow-sm); }
.ui-tabs-trigger:focus-visible, .ui-tabs-content:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ui-tabs-content { border-radius: var(--ui-radius); }

/* BorderBeam (Magic UI): a gradient dot travels the border along offset-path; the
   mask keeps only the border ring visible. */
.border-beam {
  pointer-events: none; position: absolute; inset: 0; border-radius: inherit;
  border: calc(var(--border-width) * 1px) solid transparent;
  -webkit-mask: linear-gradient(transparent, transparent), linear-gradient(#fff, #fff);
  -webkit-mask-clip: padding-box, border-box; -webkit-mask-composite: source-in;
  mask: linear-gradient(transparent, transparent), linear-gradient(#fff, #fff);
  mask-clip: padding-box, border-box; mask-composite: intersect;
}
.border-beam::after {
  content: ""; position: absolute; aspect-ratio: 1; width: calc(var(--size) * 1px);
  background: linear-gradient(to left, var(--color-from), var(--color-to), transparent);
  offset-anchor: calc(var(--anchor) * 1%) 50%;
  offset-path: rect(0 auto auto 0 round calc(var(--size) * 1px));
  animation: border-beam calc(var(--duration) * 1s) infinite linear; animation-delay: var(--delay);
}
@keyframes border-beam { to { offset-distance: 100%; } }
@media (prefers-reduced-motion: reduce) { .border-beam { display: none; } }

/* --- Full-page sign-in layout: staff login (admin/) and student portal (portal.html) --- */
.login {
  min-height: 100vh; display: flex; animation: fade 220ms ease;
  /* Graduation photo (assets/signin-bg.jpg, Zheyu Huang on Unsplash) under a teal layer. */
  background: var(--login-overlay), url("../assets/signin-bg.jpg") center 42% / cover no-repeat, var(--color-sidebar);
}
/* Copy and card share one centred, width-limited row, both vertically centred. */
.login-inner {
  width: 100%; max-width: 1180px; margin: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 450px);
  gap: clamp(40px, 6vw, 96px); align-items: center;
  padding: 48px clamp(24px, 5vw, 64px);
}
.login-hero { display: flex; flex-direction: column; gap: var(--space-8); color: #d7ebe8; }
.login-brand strong { font-family: var(--font-display); font-size: 1.2rem; letter-spacing: .03em; color: #fff; }
.login-hero .brand-mark { width: 46px; height: 46px; }
.login-copy { max-width: 34rem; }
.login-kicker {
  color: var(--color-gold); font-size: var(--text-xs); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; margin-bottom: var(--space-3);
}
.login-hero h1 {
  color: #fff; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2rem, 3.4vw, 3rem); line-height: 1.12; max-width: 13em; text-wrap: balance;
}
.login-lead { font-size: var(--text-md); line-height: 1.6; max-width: 42ch; margin-top: var(--space-4); color: #d7ebe8; }
.login-hero ul {
  list-style: none; padding: var(--space-6) 0 0; margin: var(--space-6) 0 0; display: grid; gap: var(--space-3);
  border-top: 1px solid rgba(217, 178, 95, 0.35);
}
.login-hero li { display: flex; gap: var(--space-3); align-items: center; line-height: 1.4; }
.login-hero li svg { width: 18px; height: 18px; flex: none; color: #5fc2b5; }
.login-panel .signin { max-width: none; box-shadow: var(--shadow-lg); }
@media (max-width: 860px) {
  .login { background: var(--login-overlay-narrow), url("../assets/signin-bg.jpg") center 42% / cover no-repeat, var(--color-sidebar); }
  .login-inner { grid-template-columns: minmax(0, 1fr); align-items: start; align-self: start; gap: var(--space-6); padding: 24px 16px 32px; max-width: 520px; }
  .login-hero { gap: var(--space-6); padding: 0 4px; }
  .login-hero .brand-mark { width: 38px; height: 38px; }
  .login-brand strong { font-size: 1.05rem; }
  .login-kicker { margin-bottom: var(--space-2); }
  .login-hero h1 { font-size: clamp(1.6rem, 6.4vw, 2rem); max-width: 16em; }
  .login-lead { font-size: var(--text-sm); margin-top: var(--space-2); }
  .login-hero ul { display: none; }
}
/* Student portal only: a quiet way back to the public site under the copy. */
.login-back { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--space-6); color: #cfe0dd; font-size: var(--text-sm); }
.login-back:hover { color: #fff; }
.login-back svg { width: 16px; height: 16px; }

/* The portal does not load layout.css, whose .row puts the logo and name side by side on admin/. */
.login-brand { display: flex; align-items: center; gap: var(--space-3); }

/* Student portal sign-in: its own photo (assets/portal-bg.jpg, students with laptops by Iwaria Inc. on Unsplash).
   A wide photo, so it simply covers the page like the staff one. */
.login.login-portal { background: var(--login-overlay), url("../assets/portal-bg.jpg") center 55% / cover no-repeat, var(--color-sidebar); }
@media (max-width: 860px) {
  .login.login-portal { background: var(--login-overlay-narrow), url("../assets/portal-bg.jpg") 60% center / cover no-repeat, var(--color-sidebar); }
}

/* Touch screens: every control is at least 44 x 44 px (BUG-055). */
@media (pointer: coarse) {
  .btn-sm { min-height: 44px; }
  .btn-icon { width: 44px; min-height: 44px; }
  .signin-reveal { width: 44px; height: 44px; }
  .ui-tabs-list { height: auto; }
  .ui-tabs-trigger, .dash-tabs .ui-tabs-trigger { min-height: 44px; height: auto; }
  .toast button { min-width: 44px; min-height: 44px; }
}


/* Phones and tablets: form fields at 16px so iOS Safari does not zoom on tap. Placed after
   .input above, which would otherwise win over the same rule in base.css. (BUG-055) */
@media (max-width: 640px), (pointer: coarse) {
  .input, .select, .textarea, .signin-input { font-size: 16px; }
}
