/* =============================================================================
   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;

  /* ----- 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);
}

/* ----- 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: auto;
  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 {
  content: " *";
  color: var(--danger);
}

.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);
}

@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;
    -webkit-overflow-scrolling: touch;
    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; }

/* ===== 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 {
    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-body { }
.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; }
}

/* ===== 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);
    backdrop-filter: blur(12px);
    -webkit-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)); }
}

/* ===== 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: var(--shadow-md);
}
.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 ===== */
.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);
  }
}

/* ===== 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; }
}
