/* =============================================================================
   Mastex SchoolOS — Design System v3
   -----------------------------------------------------------------------------
   QUICK REFERENCE (classes)
   • Surfaces: .content-card, .card, .card-header, .metric-card
   • Type: .ds-h1–.ds-h4, .page-subtitle, .ds-caption, .ds-prose, a.ds-link
   • Page chrome: .page-heading (flex title + actions row)
   • Buttons: .btn + .btn-primary | .secondary | .ghost | .danger | .danger-outline
              | .warning | .success | .outline-primary | .outline-secondary
              | .outline-danger | .outline | .sm | .lg | .block | .icon | .pill
   • States: :disabled, .is-disabled, .is-loading (+ aria-busy)
   • Forms: .form-stack, .form-row, .form-group, .form-hint, .form-error-text
   • Data: .table-responsive, .badge-*, .alert-*, .tabs, .empty-state
   • Dashboard shell: .dash-section, .dash-quick-row, .dash-quick-tile, .dash-attention-row,
     .attention-tile, .chart-canvas-host, .dash-col-stack, .notifications-scroll
   Tokens: all --color-*, --surface-*, --text-*, --space-*, --radius-*, --shadow-*
   Load order: design-system.css → styles.css → dashboard_enhancements.css
   ============================================================================= */

:root {
  /* ----- Brand (primary actions, focus rings, active nav) ----- */
  --color-brand-400: #4ade80;
  --color-brand-500: #22c55e;
  --color-brand-600: #16a34a;
  --color-brand-700: #15803d;
  --color-brand-on: #022c22;

  /* ----- Semantic status ----- */
  --color-success: #22c55e;
  --color-success-soft: rgba(34, 197, 94, 0.12);
  --color-warning: #f59e0b;
  --color-warning-soft: rgba(245, 158, 11, 0.12);
  --color-danger: #ef4444;
  --color-danger-soft: rgba(239, 68, 68, 0.12);
  --color-info: #3b82f6;
  --color-info-soft: rgba(59, 130, 246, 0.12);

  /* ----- Surfaces (dark ERP shell) ----- */
  --surface-page: #0f172a;
  --surface-page-deep: #020617;
  --surface-elevated: rgba(15, 23, 42, 0.95);
  --surface-input: rgba(15, 23, 42, 0.98);
  --surface-overlay: rgba(2, 6, 23, 0.98);
  --surface-header: linear-gradient(to bottom, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.92));

  /* ----- Borders ----- */
  --border-default: rgba(148, 163, 184, 0.35);
  --border-strong: rgba(148, 163, 184, 0.5);
  --border-subtle: rgba(148, 163, 184, 0.25);
  --border-focus: var(--color-brand-500);

  /* ----- Text ----- */
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-inverse: #f8fafc;
  /* Readable ink on white / near-white panels (nav search, print, shims) */
  --text-on-light-surface: #0f172a;

  /* ----- Typography ----- */
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  --text-xs: 0.72rem;
  --text-sm: 0.82rem;
  --text-base: 0.9rem;
  --text-md: 0.95rem;
  --text-lg: 1.05rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --tracking-tight: -0.02em;
  --tracking-wide: 0.06em;

  /* ----- Spacing scale (rem) ----- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* ----- Radius ----- */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 0.9rem;
  --radius-pill: 999px;
  --radius-btn: var(--radius-md);

  /* ----- Shadows ----- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.45);
  --shadow-lg: 0 18px 45px rgba(15, 23, 42, 0.85);
  --shadow-brand: 0 2px 12px rgba(34, 197, 94, 0.35);
  --shadow-brand-lg: 0 10px 28px rgba(34, 197, 94, 0.28);

  /* ----- Motion ----- */
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 280ms;

  /* ----- Z-index scale ----- */
  --z-dropdown: 50;
  --z-sticky: 20;
  --z-modal: 100;
  --z-toast: 200;

  /* ----- Legacy aliases (do not remove — used across templates) ----- */
  --bg: var(--surface-page);
  --bg-elevated: var(--surface-page-deep);
  --card-bg: #0b1120;
  --accent: var(--color-brand-500);
  --accent-soft: rgba(34, 197, 94, 0.1);
  --accent-strong: rgba(34, 197, 94, 0.3);
  --danger: #f97373;
  --success: var(--color-success);
  --text-main: var(--text-primary);
  --text-muted: var(--text-secondary);
  --text-soft: var(--text-muted);
  --shadow-soft: var(--shadow-lg);
}

/* ===== GLOBAL ACCESSIBILITY UTILITIES ===== */

/* Screen-reader only — visually hidden but available to assistive tech */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Global keyboard focus ring — only shown for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-brand-500, #22c55e);
  outline-offset: 2px;
}
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-brand-500, #22c55e);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Smooth fade-in for alerts and dynamic content */
.fade-in {
  animation: fadeInDown 0.25s ease;
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ----- Base typography (pages inherit from shell in base.html) ----- */
.ds-prose {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
}

h1, .page-heading h1, .ds-h1 {
  font-family: var(--font-sans);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin: 0 0 var(--space-4);
}

h2, .ds-h2 {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: 650;
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin: 0 0 var(--space-3);
}

h3, .ds-h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-3);
}

h4, .ds-h4 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-2);
}

.page-heading .page-subtitle,
.page-subtitle,
.ds-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
  margin: var(--space-1) 0 0;
}

.ds-caption {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

a.ds-link {
  color: var(--color-brand-400);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a.ds-link:hover {
  color: var(--color-brand-500);
  text-decoration: underline;
}

/* Page title row — use inside .content-card: title + toolbar */
.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.page-heading > .page-heading-main {
  min-width: 0;
  flex: 1 1 12rem;
}
.page-heading > .page-heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* =============================================================================
   Buttons — behavior: focus-visible, disabled, active, loading
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  min-height: 2.5rem;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.btn:focus {
  outline: none;
}
.btn:focus-visible {
  outline: 2px solid var(--color-brand-500);
  outline-offset: 2px;
}

.btn:disabled,
.btn[disabled],
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* Primary — main ERP actions */
.btn-primary {
  background: linear-gradient(135deg, var(--color-brand-500), var(--color-brand-600));
  color: var(--color-brand-on);
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-brand-400), var(--color-brand-500));
  box-shadow: var(--shadow-brand-lg);
  transform: translateY(-1px);
}

/* Secondary — neutral outline */
.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-secondary);
  background: rgba(15, 23, 42, 1);
  transform: translateY(-1px);
}

/* Ghost — low emphasis */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: rgba(148, 163, 184, 0.08);
}

/* Danger — destructive */
.btn-danger {
  background: linear-gradient(135deg, #f87171, var(--color-danger));
  color: #fff;
  border-color: rgba(248, 113, 113, 0.5);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  transform: translateY(-1px);
}

/* Outline danger (toolbar / tables) */
.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: rgba(249, 115, 115, 0.55);
}
.btn-danger-outline:hover:not(:disabled) {
  background: rgba(249, 115, 115, 0.12);
  border-color: var(--danger);
}

/* Warning */
.btn-warning {
  background: linear-gradient(135deg, #fbbf24, var(--color-warning));
  color: #1f2937;
  border-color: rgba(251, 191, 36, 0.5);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2);
}
.btn-warning:hover:not(:disabled) {
  transform: translateY(-1px);
}

/* Success — exports, approve, positive secondary actions (distinct from primary brand) */
.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ecfdf5;
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 2px 10px rgba(5, 150, 105, 0.28);
}
.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #10b981, #059669);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

/* Outline variants (Bootstrap-compatible names) */
.btn-outline-primary {
  background: transparent;
  color: var(--color-brand-400);
  border-color: rgba(34, 197, 94, 0.55);
}
.btn-outline-primary:hover:not(:disabled) {
  background: var(--color-success-soft);
  border-color: var(--color-brand-500);
  color: #86efac;
}

.btn-outline-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-outline-secondary:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(249, 115, 115, 0.55);
}
.btn-outline-danger:hover:not(:disabled) {
  background: rgba(249, 115, 115, 0.12);
  border-color: var(--danger);
}

/* Generic outline (neutral) */
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--text-secondary);
  background: rgba(148, 163, 184, 0.06);
}

/* Sizes */
.btn-sm {
  padding: 0.4rem 0.85rem;
  min-height: 2.125rem;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 0.75rem 1.5rem;
  min-height: 2.875rem;
  font-size: var(--text-md);
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Pill variant — header / compact toolbars */
.btn-pill,
header .btn,
.nav .btn,
.button-row .btn {
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.95rem;
  min-height: unset;
  font-size: var(--text-sm);
  font-weight: 500;
}

/* Loading state: add .is-loading + aria-busy on button */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ds-spin 0.65s linear infinite;
  color: var(--color-brand-on);
}
.btn-secondary.is-loading::after,
.btn-ghost.is-loading::after {
  color: var(--text-primary);
}
@keyframes ds-spin {
  to { transform: rotate(360deg); }
}

/* Icon-only */
.btn-icon {
  padding: 0.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
}

/* =============================================================================
   Forms — field layout, validation, groups
   ============================================================================= */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 42rem;
}

.form-group label,
label.ds-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  letter-spacing: 0.01em;
}

.form-group label.required::after,
label.ds-label.required::after,
label.required::after {
  content: " *";
  color: var(--color-danger, #ef4444);
  font-weight: 700;
}

/* Input focus enhancement */
.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-brand-500, #22c55e);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-4);
}

.form-hint {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

.form-error-text {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: #f87171;
}

/* Content shell — primary page container */
.content-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-8);
  margin: var(--space-6);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  min-width: 0;
  transition: box-shadow 0.18s ease, transform 0.12s ease;
}
.content-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
}

@media (max-width: 640px) {
  .content-card {
    margin: var(--space-4);
    padding: var(--space-5);
  }
}

/* Form footer actions — aligns with ERP “Save / Cancel” patterns */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
}
.form-actions .btn {
  min-width: 7rem;
}
@media (max-width: 480px) {
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===== RESPONSIVE TABLE WRAPPER ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg, 0.75rem);
    border: 1px solid var(--border-subtle, rgba(148, 163, 184, 0.25));
}
.table-responsive table { min-width: 600px; }

/* Sticky column header inside scrollable table */
.table-responsive.table-sticky-head th,
.table-card-scroll.table-sticky-head th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-page, #0f172a);
    box-shadow: 0 1px 0 var(--border-default);
}

/* Base table element defaults */
.table-responsive table th,
.data-table th {
    white-space: nowrap;
}
.table-responsive table td,
.data-table td {
    vertical-align: middle;
}
.table-responsive table,
.data-table {
    border-collapse: collapse;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

/* ===== ERP Finance (payout pages) ===== */
.erp-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.erp-summary-text {
    color: var(--text-primary, #e5e7eb);
    line-height: 1.55;
    min-width: 0;
}

.erp-status-positive { color: #16a34a; font-weight: 600; }
.erp-status-warning { color: #d97706; font-weight: 600; }
.erp-status-danger { color: #dc2626; font-weight: 600; }
.erp-status-muted { color: #64748b; }
.erp-status-info { color: #2563eb; font-weight: 600; }
.erp-status-accent { color: #7c3aed; font-weight: 600; }

.erp-filter-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.erp-filter-select {
    min-width: 180px;
}

.erp-inline-form {
    display: inline;
}

.erp-nowrap { white-space: nowrap; }

.erp-note-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.55;
}

.erp-soft-panel {
    background: rgba(15, 23, 42, 0.42);
}

.erp-actions-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.erp-actions-row--center { justify-content: center; }

.erp-mb-lg { margin-bottom: 1.25rem; }
.erp-mb-md { margin-bottom: 0.75rem; }
.erp-mb-sm { margin-bottom: 0.5rem; }
.erp-mt-lg { margin-top: 1.25rem; }
.erp-mt-sm { margin-top: 0.5rem; }
.erp-m-0 { margin: 0 !important; }
.erp-max-600 { max-width: 600px; }
.erp-title-tight { margin-top: 0; }
.erp-copy-sm { font-size: 0.85rem; line-height: 1.5; }
.erp-text-right { text-align: right; }
.erp-text-sm { font-size: 0.85rem; }

.erp-detail-table {
    width: 100%;
    max-width: 700px;
    border-collapse: collapse;
}

.erp-detail-table--compact {
    max-width: 600px;
}

.erp-detail-label {
    padding: 0.35rem 1rem 0.35rem 0;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    width: 1%;
}

.erp-detail-meta { color: #64748b; }
.erp-note-danger { color: #dc2626; }
.erp-note-muted { color: #6b7280; }

.erp-help-panel {
    background: rgba(148, 163, 184, 0.08);
}

/* ===== GENERAL ERP UTILITIES ===== */
.erp-grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    align-items: flex-start;
}

.erp-grid-compact { gap: 0.85rem; }

.form-group.full-width { grid-column: 1 / -1; }

.erp-settings-note,
.erp-form-note {
    font-size: 0.9rem;
    color: var(--text-soft);
    line-height: 1.55;
    margin-bottom: 1rem;
}

.erp-progress {
    width: 100%;
    max-width: 120px;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    overflow: hidden;
}

.erp-progress__bar {
    height: 100%;
    border-radius: inherit;
    background: #22c55e;
    transition: width 0.2s ease;
}

.erp-progress__bar--warning { background: #f97316; }
.erp-progress__bar--success { background: #22c55e; }

.erp-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
}

.erp-modal.is-open { display: flex; }

.erp-modal__dialog {
    background: rgba(2, 6, 23, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 440px;
    width: min(100%, 440px);
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.65);
}

.erp-radio-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.erp-radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.erp-form-section {
    border-top: 1px solid rgba(148, 163, 184, 0.35);
    padding-top: 0.9rem;
    margin-top: 0.75rem;
}

.is-hidden { display: none !important; }

.erp-table-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}

.erp-table-controls__group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.erp-filter-input {
    min-width: 11rem;
}

.erp-details-inline summary {
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--accent);
}

.erp-detail-list {
    font-size: 0.78rem;
    margin: 0.5rem 0 0;
    padding-left: 1rem;
    color: var(--text-soft);
}

/* ── Detail-list (definition list for profile/detail pages) ── */
.detail-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin: 0;
    padding: 0;
}
.detail-list__row {
    display: grid;
    grid-template-columns: 11rem 1fr;
    gap: 0.5rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(148,163,184,0.12);
    font-size: 0.88rem;
    align-items: baseline;
}
.detail-list__row:last-child { border-bottom: none; }
.detail-list__row dt {
    color: var(--text-soft);
    font-weight: 500;
    font-size: 0.8rem;
}
.detail-list__row dd {
    color: var(--text-main);
    margin: 0;
    word-break: break-word;
}
@media (max-width: 480px) {
    .detail-list__row { grid-template-columns: 1fr; gap: 0.1rem; }
    .detail-list__row dt { font-size: 0.72rem; }
}

.erp-input-inline {
    width: 90px;
    padding: 0.4rem 0.55rem;
    border-radius: var(--radius-md, 8px);
}

.erp-input-reason {
  width: 140px;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-md, 8px);
}

.erp-input-full {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-md);
}

.erp-card-narrow {
  max-width: 700px;
  margin: 0 auto;
}

.erp-student-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--border-subtle);
}

.erp-student-card__icon {
  font-size: 2rem;
}

.erp-student-card__title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.erp-student-card__meta {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.erp-form-actions-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.erp-card-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.erp-card-list__item {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.erp-card-list__title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.erp-card-list__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.erp-select-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.erp-info-note {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.erp-chart-canvas-lg {
  position: relative;
  height: 240px;
}

.erp-platform-metrics {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.erp-platform-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.erp-platform-chart-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-lg, 0.9rem);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  overflow: hidden;
}

.erp-platform-chart-card--center {
  align-items: stretch;
}

.erp-platform-chart-card--wide {
  width: 100%;
}

.erp-platform-chart-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary, #e5e7eb);
}

.erp-platform-chart-subtext {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
}

.erp-platform-chart-shell {
  position: relative;
  min-height: 220px;
  width: 100%;
}

.erp-platform-chart-shell canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted, #94a3b8);
  font-size: 0.85rem;
  background: rgba(15, 23, 42, 0.6);
  border-radius: inherit;
  border: 1px dashed rgba(148, 163, 184, 0.35);
}

.chart-empty-state.is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .erp-platform-charts {
      grid-template-columns: 1fr;
  }
  .erp-platform-chart-shell {
      min-height: 200px;
  }
}

@media (max-width: 899px) {
    .data-table { min-width: 680px; }
}

@media (max-width: 640px) {
    .erp-filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .erp-filter-form .btn,
    .erp-filter-select {
        width: 100%;
        min-width: 0;
    }
    .erp-actions-row .btn {
        flex: 1 1 100%;
        justify-content: center;
    }
    .erp-detail-label {
        white-space: normal;
        width: auto;
    }
}

/* ===== STATUS BADGES (consistent across all pages) ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.6;
}
.badge-success, .badge-paid, .badge-active, .badge-approved, .badge-present, .badge-completed {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.35);
}
.badge-danger, .badge-unpaid, .badge-expired, .badge-rejected, .badge-absent, .badge-failed {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.35);
}
.badge-warning, .badge-partial, .badge-pending, .badge-late {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.35);
}
.badge-info, .badge-excused {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
}
.badge-muted,
.badge-secondary {
    background: rgba(148, 163, 184, 0.1);
    color: #9ca3af;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* ===== ENHANCED ALERTS ===== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    position: relative;
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.1rem; }
.alert-body { flex: 1; min-width: 0; }
.alert-dismiss {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.alert-dismiss:hover { opacity: 1; }
.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}
.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}
.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

/* ===== CARD VARIANTS ===== */
.card {
    border-radius: 0.9rem;
    background:
        linear-gradient(150deg, rgba(255, 255, 255, 0.035) 0%, transparent 40%),
        rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.28);
    padding: 1rem;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 36px rgba(0, 0, 0, 0.2);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    gap: 0.5rem;
}
.card-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}
.card-header-action { font-size: 0.78rem; }
.card-footer {
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}
.card-flush { padding: 0; }
.card-flush .card-header { padding: 0.75rem 1rem; margin-bottom: 0; }
.card-flush .card-body { padding: 0; }
.card-flush .card-footer { padding: 0.75rem 1rem; margin-top: 0; }

/* ===== ENHANCED METRIC CARDS ===== */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}
.metric-card {
    border-radius: 0.85rem;
    padding: 0.85rem 1rem;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.04) 0%, transparent 42%),
        rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.22);
    transition: transform 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}
.metric-card:hover {
    transform: translateY(-2px);
    border-color: rgba(148, 163, 184, 0.4);
}
.metric-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 0.65rem;
}
.metric-card-icon.green  { background: rgba(34, 197, 94, 0.15); }
.metric-card-icon.blue   { background: rgba(59, 130, 246, 0.15); }
.metric-card-icon.amber  { background: rgba(245, 158, 11, 0.15); }
.metric-card-icon.red    { background: rgba(239, 68, 68, 0.15); }
.metric-card-icon.purple { background: rgba(168, 85, 247, 0.15); }
.metric-card-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.25rem;
}
.metric-card-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.metric-card-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 0.3rem;
}
.metric-card-trend.up   { color: #4ade80; }
.metric-card-trend.down { color: #f87171; }
.metric-card-trend.flat { color: #9ca3af; }

/* ===== PROGRESS BAR ===== */
.progress {
    width: 100%;
    height: 6px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s ease;
}
.progress-bar-green  { background: linear-gradient(90deg, #22c55e, #4ade80); }
.progress-bar-blue   { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.progress-bar-amber  { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-bar-red    { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 0.55rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-soft);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab:hover { color: var(--text-main); }
.tab.active, .tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== AVATAR ===== */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 700;
    flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-md { width: 36px; height: 36px; font-size: 0.85rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-green { background: linear-gradient(135deg, #22c55e, #16a34a); color: #022c22; }
.avatar-blue  { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #eff6ff; }
.avatar-amber { background: linear-gradient(135deg, #f59e0b, #d97706); color: #451a03; }

/* ===== STAT ROW (inline key-value) ===== */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    font-size: 0.84rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-row-label { color: var(--text-soft); }
.stat-row-value { font-weight: 600; color: var(--text-main); }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1rem;
}
.filter-bar select,
.filter-bar input {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 0.5rem;
    min-width: 140px;
}
.filter-bar .btn { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

/* ===== SKELETON LOADING ===== */
.skeleton {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.06) 25%, rgba(148, 163, 184, 0.12) 50%, rgba(148, 163, 184, 0.06) 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}
@keyframes skeletonPulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Chart canvas skeleton overlay — used by MastexCharts.lazy() */
.chart-skeleton {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    background: linear-gradient(90deg,
        rgba(148, 163, 184, 0.06) 25%,
        rgba(148, 163, 184, 0.14) 50%,
        rgba(148, 163, 184, 0.06) 75%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
    color: var(--text-muted, #6b7280);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

/* ===== MOBILE BOTTOM NAV ===== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: rgba(2, 6, 23, 0.97);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(148, 163, 184, 0.25);
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
}
.mobile-bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 480px;
    margin: 0 auto;
}
/* School admin / superuser: extra bottom-nav items (Messages, Broadcast) */
.mobile-bottom-nav-inner--dense {
    flex-wrap: wrap;
    row-gap: 0.15rem;
    max-width: 100%;
    padding: 0 0.15rem;
}
.mobile-bottom-nav-inner--dense .mobile-nav-item {
    min-width: 44px;
    font-size: 0.55rem;
    padding: 0.25rem 0.35rem;
}
.mobile-bottom-nav-inner--dense .mobile-nav-icon {
    font-size: 1rem;
}
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.3rem 0.5rem;
    text-decoration: none;
    color: var(--text-soft);
    font-size: 0.62rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: color 0.15s;
    min-width: 52px;
}
.mobile-nav-item:hover, .mobile-nav-item.active { color: var(--accent); }
.mobile-nav-icon { font-size: 1.15rem; }
@media (max-width: 899px) {
    .mobile-bottom-nav { display: block; }
    body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}

/* WCAG 2.5.5 touch target minimums */
@media (max-width: 899px) {
    .btn { min-height: 44px; padding-top: 0.5rem; padding-bottom: 0.5rem; }
    .nav-item { min-height: 44px; }
    select, input[type="text"], input[type="email"], input[type="number"],
    input[type="password"], input[type="date"], textarea {
        min-height: 44px;
        font-size: 16px; /* prevent iOS auto-zoom */
    }
}

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
    display: grid;
    gap: 1rem;
}
.dashboard-grid-2 { grid-template-columns: repeat(2, 1fr); }
.dashboard-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 768px) {
    .dashboard-grid-2, .dashboard-grid-3 { grid-template-columns: 1fr; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ===== DASHBOARD SHELL (role dashboards, attention strip) ===== */
.dash-section { margin-bottom: 1.25rem; }
.dash-quick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.dash-quick-tile {
    flex: 1;
    min-width: 140px;
    text-align: center;
    padding: 1rem !important;
    text-decoration: none;
    color: inherit;
    transition:
        transform var(--duration-fast) var(--ease-out),
        border-color var(--duration-normal),
        box-shadow var(--duration-normal);
}
.dash-quick-tile:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    background: rgba(34, 197, 94, 0.06);
}
.dash-quick-tile:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}
.dash-quick-tile-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    line-height: 1;
}
.dash-quick-tile-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.dash-attention-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.attention-tile {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem !important;
    text-decoration: none;
    color: inherit;
    border-left: 4px solid var(--border-default);
    transition: transform var(--duration-fast) var(--ease-out), border-color var(--duration-normal);
}
.attention-tile:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
}
.attention-tile__value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}
.attention-tile__label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}
.attention-tile--warning {
    border-left-color: var(--color-warning);
}
.attention-tile--warning .attention-tile__value { color: var(--color-warning); }
.attention-tile--danger {
    border-left-color: var(--color-danger);
}
.attention-tile--danger .attention-tile__value { color: var(--color-danger); }
.attention-tile--info {
    border-left-color: var(--color-info);
}
.attention-tile--info .attention-tile__value { color: var(--color-info); }
.chart-canvas-host {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
}
.chart-canvas-host--trend {
    height: 220px;
}
.dash-col-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.notifications-scroll {
    max-height: 260px;
    overflow-y: auto;
}
.activity-list--flush { margin: 0; }
.activity-item--top { align-items: flex-start; }
.badge-spaced { margin-right: 0.5rem; }
.text-unread-accent { color: var(--color-info); }

/* Legacy staff_dashboard.html helpers (not default route; keeps layout valid if used) */
.dashboard-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}
.bottom-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.25rem;
}
@media (max-width: 768px) {
    .bottom-grid { grid-template-columns: 1fr; }
}
.quick-actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-margin-top { margin-top: 1.25rem; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 0.5rem; }
.metric.metric-blue {
    border-color: rgba(59, 130, 246, 0.45);
    background: radial-gradient(circle at 0 0, rgba(59, 130, 246, 0.14) 0, rgba(15, 23, 42, 0.8) 45%);
}
.metric.metric-green {
    border-color: rgba(34, 197, 94, 0.4);
    background: radial-gradient(circle at 0 0, rgba(34, 197, 94, 0.12) 0, rgba(15, 23, 42, 0.8) 45%);
}
.metric.metric-red {
    border-color: rgba(239, 68, 68, 0.45);
    background: radial-gradient(circle at 0 0, rgba(239, 68, 68, 0.12) 0, rgba(15, 23, 42, 0.8) 45%);
}
.metric.metric-purple {
    border-color: rgba(168, 85, 247, 0.45);
    background: radial-gradient(circle at 0 0, rgba(168, 85, 247, 0.12) 0, rgba(15, 23, 42, 0.8) 45%);
}
.metric-value-lg { font-size: 1.35rem; font-weight: 700; }
.color-blue { color: #60a5fa; }
.color-green { color: #4ade80; }
.color-red { color: #f87171; }
.color-purple { color: #c084fc; }
.color-white { color: var(--text-primary); }
.event-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.event-item:last-child { border-bottom: none; }
.event-title { font-weight: 600; font-size: 0.88rem; }
.event-date { font-size: 0.78rem; color: var(--text-soft); margin-top: 0.15rem; }
.summary-section { margin-bottom: 1rem; }
.summary-section:last-child { margin-bottom: 0; }
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}
.progress-container {
    width: 100%;
    height: 8px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar-success,
.progress-bar-danger {
    height: 100%;
    border-radius: 999px;
    transition: width 0.55s ease;
}
.progress-bar-success {
    background: linear-gradient(90deg, var(--color-brand-600), var(--color-brand-400));
}
.progress-bar-danger {
    background: linear-gradient(90deg, #dc2626, #f87171);
}
.height-full { height: 100%; }

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    text-align: center;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.35rem; color: var(--text-main); }
.empty-state-desc { font-size: 0.85rem; color: var(--text-soft); max-width: 360px; }

/* ===== HOVER TABLE ROWS ===== */
.table-hover tbody tr { cursor: pointer; transition: background 0.15s; }
.table-hover tbody tr:hover { background: rgba(34, 197, 94, 0.05); }

/* ===== TRUNCATE ===== */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== LAYOUT UTILITIES ===== */
img { max-width: 100%; height: auto; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs  { gap: 0.25rem; }
.gap-sm  { gap: 0.5rem; }
.gap-md  { gap: 0.75rem; }
.gap-lg  { gap: 1rem; }
.gap-xl  { gap: 1.5rem; }
.w-full  { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.text-muted { color: var(--text-soft); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ===== ACCESSIBILITY — respect reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .metric-card,
  .quick-action-btn,
  .tab,
  .table-hover tbody tr {
    transition: none !important;
  }
  .btn:hover:not(:disabled),
  .btn-primary:hover:not(:disabled),
  .btn-secondary:hover:not(:disabled),
  .btn-success:hover:not(:disabled),
  .btn-danger:hover:not(:disabled),
  .btn-warning:hover:not(:disabled),
  .btn-ghost:hover:not(:disabled) {
    transform: none;
  }
  .btn.is-loading::after {
    animation: none;
    opacity: 0.55;
  }
  .skeleton {
    animation: none;
    background: rgba(148, 163, 184, 0.1);
  }
}

/* ===== INLINE FORM VALIDATION ERRORS ===== */
.field-error {
    color: var(--color-error, #ef4444);
    font-size: 0.78rem;
    margin-top: 0.25rem;
    display: block;
}
.field-error-list { list-style: none; padding: 0; margin: 0.25rem 0 0; }
.field-error-list li { color: var(--color-error, #ef4444); font-size: 0.78rem; }
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: var(--color-error, #ef4444) !important;
}

/* ===== PAGE HEADER PARTIAL ===== */
.page-header-block {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-header-text {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.page-header-icon { font-size: 1.5rem; line-height: 1; margin-top: 0.15rem; }
.page-header-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 0.2rem;
}
.page-header-sub {
    font-size: 0.875rem;
    color: var(--text-soft);
    margin: 0;
}
.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ===== QUICK PAY CARD ===== */
.quick-pay-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--radius-md, 0.5rem);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.quick-pay-info { display: flex; flex-direction: column; gap: 0.15rem; }
.quick-pay-name { font-weight: 600; font-size: 0.9rem; color: var(--text-main); }
.quick-pay-amount { font-size: 0.82rem; color: var(--color-error, #ef4444); font-weight: 500; }

/* ===== JOB STATUS CARD ===== */
.job-status-card {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md, 0.5rem);
    padding: 1rem 1.25rem;
    background: var(--surface-card);
    margin-bottom: 1rem;
}
.job-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.job-title { font-weight: 600; color: var(--text-main); }
.job-status-pill {
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.status-pending, .status-running { background: rgba(234,179,8,0.15); color: #ca8a04; }
.status-done { background: rgba(34,197,94,0.15); color: #16a34a; }
.status-failed { background: rgba(239,68,68,0.15); color: #dc2626; }
.job-progress { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.progress-bar-track { flex: 1; height: 6px; background: var(--border-default); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent, #22c55e); transition: width 0.4s ease; }
.progress-label { font-size: 0.78rem; color: var(--text-soft); min-width: 2.5rem; text-align: right; }
.job-error { color: var(--color-error, #ef4444); font-size: 0.82rem; margin-top: 0.5rem; }

/* ===== QUICK ACTION CARD ===== */
.quick-action-card {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md, 0.5rem);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}
.quick-action-card h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.75rem; color: var(--text-main); }
.quick-action-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm, 0.35rem);
    background: rgba(34,197,94,0.07);
    color: var(--accent, #22c55e);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    transition: background 0.15s;
}
.quick-action-link:hover { background: rgba(34,197,94,0.15); }
.quick-action-link::after { content: "→"; margin-left: auto; }

/* ===== MOBILE TOUCH TARGETS (WCAG 2.5.5) ===== */
@media (max-width: 899px) {
    .btn {
        min-height: 44px;
    }
    /* Prevent iOS Safari from zooming on input focus (requires 16px min) */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="password"],
    input[type="date"],
    input[type="tel"],
    input[type="search"],
    textarea,
    select {
        font-size: max(16px, 1rem);
    }
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        cursor: pointer;
        accent-color: var(--color-brand-500, #22c55e);
    }
}

/* ===== ACCESSIBILITY ===== */

/* Global keyboard focus ring — visible to keyboard users only */
:focus-visible {
    outline: 2px solid var(--color-brand-500, #22c55e);
    outline-offset: 2px;
}

/* Visually hidden but screen-reader accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== WORKFLOW STEPPER ===== */
.workflow-stepper {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin: var(--space-4) 0;
    overflow-x: auto;
    padding-bottom: var(--space-2);
}
.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 80px;
    text-align: center;
}
.workflow-step::before {
    content: '';
    position: absolute;
    top: 14px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border-default);
    z-index: 0;
}
.workflow-step:first-child::before { display: none; }
.workflow-step__dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-elevated);
    border: 2px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
}
.workflow-step--done .workflow-step__dot {
    background: var(--color-brand-500);
    border-color: var(--color-brand-500);
    color: #fff;
}
.workflow-step--done::before { background: var(--color-brand-500); }
.workflow-step--active .workflow-step__dot {
    border-color: var(--color-brand-500);
    color: var(--color-brand-500);
    box-shadow: 0 0 0 4px rgba(34,197,94,0.15);
}
.workflow-step--rejected .workflow-step__dot {
    background: var(--color-danger, #ef4444);
    border-color: var(--color-danger, #ef4444);
    color: #fff;
}
.workflow-step__label {
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: .35rem;
    line-height: 1.25;
    max-width: 72px;
}
.workflow-step--active .workflow-step__label,
.workflow-step--done .workflow-step__label {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== STAT ROW (attention item list pattern) ===== */
.stat-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
}
.stat-row:last-child { border-bottom: none; }
.stat-row__icon {
    min-width: 2.25rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}
.stat-row__icon--warning { background: #ffedd5; color: #9a3412; }
.stat-row__icon--info { background: #e0f2fe; color: #0369a1; }
.stat-row__icon--danger { background: #fee2e2; color: #991b1b; }
.stat-row__icon--success { background: #dcfce7; color: #166534; }
.stat-row__body { flex: 1; min-width: 0; }
.stat-row__label { font-weight: 600; color: var(--text-primary); text-decoration: none; }
.stat-row__label:hover { text-decoration: underline; }
.stat-row__detail { font-size: var(--text-xs); color: var(--text-muted); margin-top: .2rem; line-height: 1.35; }

/* ===== SETUP CHECKLIST ===== */
.setup-checklist { list-style: none; padding: 0; margin: 0; }
.setup-checklist__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
}
.setup-checklist__item:last-child { border-bottom: none; }
.setup-checklist__item--done .setup-checklist__label {
    color: var(--text-muted);
    text-decoration: line-through;
}
.setup-checklist__status { font-size: 1.1rem; flex-shrink: 0; }
.setup-checklist__label { flex: 1; }

/* ===== MOBILE FEE CARDS ===== */
.mobile-fee-cards { display: none; }
.mobile-fee-card {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-4, 1rem);
    margin-bottom: var(--space-3, 0.75rem);
    background: var(--surface-elevated, var(--surface-card));
}
.mobile-fee-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3, 0.75rem);
}
.mobile-fee-card__body { margin-bottom: var(--space-3, 0.75rem); }
.mobile-fee-card__row {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm, 0.82rem);
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-subtle, rgba(148,163,184,0.1));
}
.mobile-fee-card__row:last-child { border-bottom: none; }
.mobile-fee-card__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
@media (max-width: 640px) {
    .mobile-fee-cards { display: block; }
    .desktop-fee-table { display: none; }
}

/* ===== TABLE LOADING OVERLAY ===== */
/* Add class to tbody (or table wrapper) while data is loading */
.table-loading-overlay {
    position: relative;
    pointer-events: none;
}
.table-loading-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--surface-page, #0f172a);
    opacity: 0.7;
    border-radius: var(--radius-lg);
}

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar, header, footer, .mobile-bottom-nav,
    .quick-actions, .btn, .filter-bar, .nav-toggle,
    .notification-bell, .profile-menu { display: none !important; }
    .layout { grid-template-columns: 1fr !important; }
    .content-card { border: none; box-shadow: none; background: white; color: black; }
    body { background: white; color: black; }
}

/* ===== REPORT CARD PRINT STYLES ===== */
@media print {
    .report-card-actions.no-print,
    .mobile-nav,
    .sidebar,
    .topbar,
    .breadcrumbs,
    .page-heading-actions,
    .no-print {
        display: none !important;
    }
    .report-card-shell {
        box-shadow: none !important;
        border: none !important;
        background: white !important;
        color: #1a1a1a !important;
    }
    .report-card-masthead {
        background: white !important;
        color: #1a1a1a !important;
    }
    .report-card-masthead h1,
    .report-card-masthead p {
        color: #1a1a1a !important;
    }
    .report-card-results table th {
        background: #f0f0f0 !important;
        color: #1a1a1a !important;
    }
    .report-card-results table td {
        color: #1a1a1a !important;
        border-color: #ccc !important;
    }
    main { margin-left: 0 !important; padding: 0 !important; }
    body { background: white !important; }
    a { color: #1a1a1a !important; text-decoration: none !important; }
}
