/* ============================================================
   YBS85 — Design System & Global Styles
   Yayasan Build and Share Delapan Lima
   ISAK 35 Financial Management System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ============================================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================ */
:root {
  /* Brand Colors */
  --brand-primary:    #4f46e5;  /* Indigo 600 */
  --brand-primary-d: #3730a3;  /* Indigo 800 */
  --brand-primary-l: #818cf8;  /* Indigo 400 */
  --brand-secondary: #0ea5e9;  /* Sky 500 */
  --brand-accent:    #8b5cf6;  /* Violet 500 */

  /* Semantic Colors — Light Mode */
  --color-success:  #10b981;
  --color-warning:  #f59e0b;
  --color-danger:   #ef4444;
  --color-info:     #3b82f6;

  /* Surfaces — Light Mode */
  --surface-bg:       #f8faff;
  --surface-base:     #ffffff;
  --surface-raised:   #f1f5f9;
  --surface-overlay:  rgba(255,255,255,0.85);
  --surface-sidebar:  #1e1b4b;
  --surface-sidebar-hover: rgba(255,255,255,0.08);
  --surface-sidebar-active: rgba(255,255,255,0.15);

  /* Text — Light Mode */
  --text-primary:    #0f172a;
  --text-secondary:  #475569;
  --text-muted:      #94a3b8;
  --text-inverse:    #ffffff;
  --text-on-sidebar: rgba(255,255,255,0.85);

  /* Borders */
  --border-base:    #e2e8f0;
  --border-strong:  #cbd5e1;
  --border-focus:   var(--brand-primary);

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.15);

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Border Radius */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  /* Sidebar */
  --sidebar-width: 256px;
  --sidebar-collapsed: 70px;

  /* Header */
  --header-height: 64px;

  /* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4,0,0.2,1);
  --transition-base:   250ms cubic-bezier(0.4,0,0.2,1);
  --transition-slow:   400ms cubic-bezier(0.4,0,0.2,1);

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sidebar:  200;
  --z-header:   150;
  --z-modal:    300;
  --z-toast:    400;
}

/* ============================================================
   2. DARK MODE
   ============================================================ */
[data-theme="dark"] {
  --surface-bg:       #0f0e1a;
  --surface-base:     #1a1827;
  --surface-raised:   #23213a;
  --surface-overlay:  rgba(26,24,39,0.92);
  --surface-sidebar:  #13111f;
  --surface-sidebar-hover: rgba(255,255,255,0.06);
  --surface-sidebar-active: rgba(99,102,241,0.25);

  --text-primary:    #f1f5f9;
  --text-secondary:  #94a3b8;
  --text-muted:      #475569;
  --text-on-sidebar: rgba(241,245,249,0.85);

  --border-base:    #2d2b45;
  --border-strong:  #3d3b58;

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.55);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.6);

  --brand-primary-l: #6366f1;
  color-scheme: dark;
}

/* ============================================================
   3. RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
  scroll-behavior: smooth;
}

[data-theme="dark"] html { color-scheme: dark; }

body {
  font-family: var(--font-sans);
  background-color: var(--surface-bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--transition-base), color var(--transition-base);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ============================================================
   4. APP LAYOUT (Shell)
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface-sidebar);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.app-sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  padding: var(--space-5) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  min-height: var(--header-height);
}

.sidebar-logo {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: var(--text-sm);
  color: #fff;
  letter-spacing: -0.5px;
}

.sidebar-logo-img {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 3px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-title-main {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-inverse);
  white-space: nowrap;
  font-family: var(--font-display);
  letter-spacing: -0.2px;
}

.sidebar-title-sub {
  font-size: var(--text-xs);
  color: var(--text-on-sidebar);
  opacity: 0.6;
  white-space: nowrap;
}

.app-sidebar.collapsed .sidebar-title {
  display: none;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.nav-section {
  margin-bottom: var(--space-6);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 0 var(--space-3) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
}

.app-sidebar.collapsed .nav-section-label {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-on-sidebar);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--surface-sidebar-active);
  color: #fff;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--brand-primary-l);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-label {
  font-size: var(--text-sm);
  font-weight: 500;
  transition: opacity var(--transition-base);
}

.app-sidebar.collapsed .nav-label {
  opacity: 0;
  pointer-events: none;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.app-sidebar.collapsed .nav-badge { display: none; }

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-secondary), var(--brand-primary));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
  flex: 1;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}

.app-sidebar.collapsed .sidebar-user-info { display: none; }

/* ============================================================
   5. MAIN CONTENT AREA
   ============================================================ */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
  /* Prevent content from overflowing the viewport width */
  overflow-x: hidden;
  min-width: 0;
}

.app-sidebar.collapsed + .app-main {
  margin-left: var(--sidebar-collapsed);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--surface-base);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  z-index: var(--z-header);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: var(--surface-overlay);
}

.header-toggle {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.header-toggle:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.header-breadcrumb-item {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.header-breadcrumb-item.current {
  color: var(--text-primary);
  font-weight: 600;
}

.header-breadcrumb-sep {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-icon-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.header-icon-btn:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
}

.header-icon-btn .badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--color-danger);
  border-radius: 50%;
  border: 2px solid var(--surface-base);
}

/* Page Content */
.page-content {
  flex: 1;
  padding: var(--space-6);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  box-sizing: border-box;
}

/* Page Header */
.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* SPA View Management */
.spa-view {
  width: 100%;
  min-width: 0;
}

.spa-view:focus {
  outline: none;
}

.spa-view.inactive {
  display: none !important;
}


/* ============================================================
   6. TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }

.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extrabold{ font-weight: 800; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-danger    { color: var(--color-danger); }
.text-brand     { color: var(--brand-primary); }

.text-right  { text-align: right; }
.text-center { text-align: center; }

/* Currency display */
.currency {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: -0.3px;
}

/* ============================================================
   7. UTILITY CLASSES
   ============================================================ */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.hidden { display: none !important; }
.invisible { visibility: hidden; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.overflow-hidden { overflow: hidden; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   8. LOADING STATE
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-raised) 25%,
    var(--border-base) 50%,
    var(--surface-raised) 75%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border-base);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-overlay);
  border-radius: inherit;
  z-index: 10;
}

/* ============================================================
   9. TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  max-width: 420px;
  pointer-events: all;
  animation: toast-in var(--transition-base) forwards;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.toast.success::before { background: var(--color-success); }
.toast.error::before   { background: var(--color-danger); }
.toast.warning::before { background: var(--color-warning); }
.toast.info::before    { background: var(--color-info); }

.toast-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-icon.success { color: var(--color-success); }
.toast-icon.error   { color: var(--color-danger); }
.toast-icon.warning { color: var(--color-warning); }
.toast-icon.info    { color: var(--color-info); }

.toast-body { flex: 1; }
.toast-title { font-weight: 600; font-size: var(--text-sm); margin-bottom: 2px; }
.toast-message { font-size: var(--text-xs); color: var(--text-secondary); }

.toast-close {
  width: 20px; height: 20px;
  border: none; background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.toast-close:hover { color: var(--text-primary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.removing {
  animation: toast-out var(--transition-base) forwards;
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); max-height: 200px; }
  to   { opacity: 0; transform: translateX(100%); max-height: 0; }
}

/* ============================================================
   10. MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fade-in var(--transition-base) forwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface-base);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modal-in var(--transition-base) forwards;
}

.modal.modal-lg { max-width: 860px; }
.modal.modal-xl { max-width: 1100px; }
.modal.modal-sm { max-width: 440px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}

.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--surface-raised);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
  background: var(--border-base);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-base);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ============================================================
   11. EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  gap: var(--space-4);
}

.empty-state-icon {
  width: 64px; height: 64px;
  background: var(--surface-raised);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 320px;
}

/* ============================================================
   12. RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
}

@media (max-width: 768px) {
  html {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
    width: 100vw;
    max-width: 100%;
  }

  .app-sidebar {
    transform: translateX(-100%);
    width: 260px !important;
    max-width: 80vw !important;
    box-shadow: var(--shadow-xl);
    z-index: 1010 !important;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  #sidebar-overlay {
    z-index: 1000 !important;
  }

  /* Header fixed on mobile — always visible */
  .app-header {
    position: fixed !important;
    top: 0; left: 0; right: 0;
    padding: 0 var(--space-4) !important;
    z-index: 999 !important;
    width: 100%;
  }

  .app-main {
    margin-left: 0 !important;
    padding-top: var(--header-height) !important;
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .header-toggle {
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0;
  }

  .page-content {
    padding: var(--space-3) !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Responsive Layout Helpers */
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-3) !important;
  }

  .page-header > div:last-child {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: var(--space-2) !important;
  }

  .page-header > div:last-child button,
  .page-header > div:last-child a {
    flex: 1 1 auto !important;
    justify-content: center !important;
  }

  .filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: var(--space-3) !important;
  }

  .filter-bar > * {
    width: 100% !important;
  }

  .modal-body {
    padding: var(--space-4) !important;
  }

  .modal-footer {
    padding: var(--space-4) !important;
    flex-direction: column-reverse !important;
    gap: var(--space-2) !important;
  }

  .modal-footer button {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Modal fits within screen */
  .modal {
    margin: var(--space-4) !important;
    max-height: 90vh !important;
    width: calc(100vw - var(--space-8)) !important;
    max-width: calc(100vw - var(--space-8)) !important;
  }

  /* Tables scroll horizontally in their wrapper, not the whole page */
  .table-container {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Cards don't stretch beyond their container */
  .card {
    max-width: 100%;
    overflow: hidden;
  }

  /* Stats grid 1 or 2 column on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-3) !important;
  }

  /* Dashboard grid single column */
  .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   13. PRINT
   ============================================================ */
@media print {
  .app-sidebar, .app-header, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: white; color: black; }
}

/* ============================================================
   14. REDUCED MOTION
   ============================================================ */
@property --animation-reduced {
  syntax: "*";
  inherits: false;
  initial-value: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
