/**
 * KAITALK Design System
 * Apple-grade tokens — single source of truth for all app screens
 * Imported by dashboard, onboarding, billing, compliance, and shared components
 */

/* ─── Fonts ──────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Jost:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Noto+Sans+Devanagari:wght@300;400;500;600&family=Noto+Sans+Telugu:wght@300;400;500;600&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --color-bg:             #FAFAFA;
  --color-surface:        #FFFFFF;
  --color-surface-raised: #FFFFFF;
  --color-surface-inset:  #F5F5F7;

  /* Text */
  --color-text:           #1D1D1F;
  --color-text-secondary: #5B6373;
  --color-text-tertiary:  #8A8F9C;
  --color-text-inverse:   #FFFFFF;

  /* Accent (deep green) */
  --color-accent:         #16a34a;
  --color-accent-hover:   #15803d;
  --color-accent-light:   #dcfce7;
  --color-accent-dim:     rgba(22, 163, 74, 0.12);

  /* Semantic */
  --color-success:        #16a34a;
  --color-success-bg:     #dcfce7;
  --color-warning:        #B45309;
  --color-warning-bg:     #FEF3C7;
  --color-error:          #C0392B;
  --color-error-bg:       #FEE2E2;
  --color-info:           #1D4ED8;
  --color-info-bg:        #EFF6FF;

  /* Borders */
  --color-border:         #E5E5E7;
  --color-border-strong:  #C7C7CC;
  --color-border-accent:  var(--color-accent);

  /* Sidebar */
  --color-sidebar-bg:     #FAFAFA;
  --color-sidebar-border: #E5E5E7;

  /* ─── Typography ─────────────────────────── */
  --font-display: 'Jost', 'Noto Sans Devanagari', 'Noto Sans Telugu', sans-serif;
  --font-body:    'Jost', 'Noto Sans Devanagari', 'Noto Sans Telugu', 'Helvetica Neue', sans-serif;

  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.875rem;   /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg:   1.125rem;   /* 18px */
  --text-xl:   1.25rem;    /* 20px */
  --text-2xl:  1.5rem;     /* 24px */
  --text-3xl:  1.875rem;   /* 30px */
  --text-4xl:  2.25rem;    /* 36px */
  --text-5xl:  3rem;       /* 48px */

  --leading-tight:  1.25;
  --leading-snug:   1.375;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;

  --tracking-tight: -0.02em;
  --tracking-snug:  -0.01em;
  --tracking-wide:  0.05em;
  --tracking-wider: 0.1em;

  /* ─── Spacing (8px grid) ─────────────────── */
  --space-1:   8px;
  --space-2:   16px;
  --space-3:   24px;
  --space-4:   32px;
  --space-5:   40px;
  --space-6:   48px;
  --space-8:   64px;
  --space-10:  80px;
  --space-15: 120px;
  --space-20: 160px;

  /* ─── Shadows ────────────────────────────── */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.05);
  --shadow-xl:  0 24px 48px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);
  --shadow-accent: 0 4px 16px rgba(22, 163, 74, 0.22);
  --shadow-inner: inset 0 1px 3px rgba(0,0,0,0.06);

  /* ─── Border Radius ──────────────────────── */
  --radius-xs:  4px;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ─── Transitions ────────────────────────── */
  --duration-fast:   150ms;
  --duration-base:   200ms;
  --duration-slow:   300ms;
  --ease:            cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring:     cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:        cubic-bezier(0, 0, 0.2, 1);

  /* ─── Layout ─────────────────────────────── */
  --sidebar-w: 220px;
  --content-max: 1100px;
  --card-max:    560px;
}

/* ─── Light-only design system ─────────────────────────────────────── */
/* Dark mode has been removed. The `.dark-mode` and `.bright` classes are
   retained as no-ops (mapped to the light token set) so any legacy markup or
   JS that still applies them renders the accessible light theme rather than a
   broken dark/cream mix. The light tokens live in :root above. */
.dark-mode,
.bright {
  --color-bg:             #FAFAFA;
  --color-surface:        #FFFFFF;
  --color-surface-raised: #FFFFFF;
  --color-surface-inset:  #F5F5F7;
  --color-text:           #1D1D1F;
  --color-text-secondary: #5B6373;
  --color-text-tertiary:  #8A8F9C;
  --color-border:         #E5E5E7;
  --color-border-strong:  #C7C7CC;
  --color-sidebar-bg:     #FAFAFA;
  --color-sidebar-border: #E5E5E7;
  --color-accent:         #0d9488;
  --color-accent-hover:   #0f766e;
  --color-accent-light:   rgba(13,148,136,0.10);
  --color-accent-dim:     rgba(13,148,136,0.08);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.8);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.9);
  --shadow-lg:  0 12px 32px rgba(0,0,0,0.12);
  --shadow-accent: 0 4px 16px rgba(13,148,136,0.18);
}

/* ─── Reset + Base ─────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ─── Typography Utilities ─────────────────────────────────────────── */
.display {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}
.heading-xl {
  font-family: var(--font-body);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}
.heading-lg {
  font-family: var(--font-body);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-snug);
}
.heading-md {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  font-weight: 600;
}
.heading-sm {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
}
.label-sm {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.body-sm { font-size: var(--text-sm); color: var(--color-text-secondary); }
.body-xs { font-size: var(--text-xs); color: var(--color-text-tertiary); }

/* ─── Button System ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: all var(--duration-base) var(--ease);
  cursor: pointer;
  border: none;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 6px 20px rgba(196, 168, 130, 0.25);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.btn-ghost:hover {
  background: var(--color-surface-inset);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid rgba(192,57,43,0.15);
}
.btn-danger:hover {
  background: var(--color-error);
  color: #fff;
}

.btn-sm { height: 34px; padding: 0 14px; font-size: var(--text-xs); }
.btn-lg { height: 52px; padding: 0 28px; font-size: var(--text-base); border-radius: var(--radius-md); }
.btn-full { width: 100%; }

/* ─── Card ──────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-lg { border-radius: var(--radius-xl); }
.card-body { padding: var(--space-3); }
.card-header {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.card-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-inset);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ─── Form Elements ─────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.form-label .optional {
  font-weight: 400;
  color: var(--color-text-tertiary);
  margin-left: 4px;
}
.form-hint { font-size: var(--text-xs); color: var(--color-text-secondary); }
.form-error { font-size: var(--text-xs); color: var(--color-error); }

.input, .textarea, .select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-dim);
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-tertiary); }
.input.error { border-color: var(--color-error); }
.input.error:focus { box-shadow: 0 0 0 3px rgba(192,57,43,0.12); }
.textarea { height: auto; min-height: 100px; padding: 12px 14px; resize: vertical; line-height: var(--leading-relaxed); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236E6E73' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* ─── Badge / Status ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-green  { background: var(--color-success-bg);  color: var(--color-success); }
.badge-red    { background: var(--color-error-bg);    color: var(--color-error); }
.badge-amber  { background: var(--color-warning-bg);  color: var(--color-warning); }
.badge-gray   { background: var(--color-surface-inset); color: var(--color-text-secondary); }
.badge-blue   { background: var(--color-info-bg);     color: var(--color-info); }

.badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── Toast ─────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--color-text);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn var(--duration-slow) var(--ease-spring);
  max-width: 340px;
}
.toast.toast-success { background: var(--color-accent); }
.toast.toast-error   { background: var(--color-error); }
.toast.toast-warning { background: var(--color-warning); }
.toast.toast-out     { animation: toastOut var(--duration-slow) var(--ease) forwards; }
@keyframes toastIn  { from { opacity:0; transform: translateX(20px) scale(0.95); } to { opacity:1; transform: translateX(0) scale(1); } }
@keyframes toastOut { from { opacity:1; transform: translateX(0); }  to { opacity:0; transform: translateX(20px); } }

/* ─── Skeleton / Loading ─────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-border) 25%, var(--color-surface-inset) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-xs);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-text  { height: 14px; margin-bottom: 8px; }
.skel-text.w-full { width: 100%; }
.skel-text.w-3\/4 { width: 75%; }
.skel-text.w-1\/2 { width: 50%; }
.skel-text.w-1\/4 { width: 25%; }
.skel-metric { height: 48px; border-radius: var(--radius-sm); margin-bottom: 4px; }
.skel-row    { height: 52px; border-radius: var(--radius-sm); margin-bottom: 6px; }

/* ─── Table ─────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}
.data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background var(--duration-fast);
}
.data-table tbody tr:hover { background: var(--color-surface-inset); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody td {
  padding: 14px 16px;
  font-size: var(--text-sm);
  color: var(--color-text);
  vertical-align: middle;
}

/* ─── Progress Bar ──────────────────────────────────────────────────── */
.progress-track {
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width 0.6s var(--ease-out);
}
.progress-fill.warning { background: var(--color-warning); }
.progress-fill.danger  { background: var(--color-error); }

/* ─── Divider ────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-3) 0;
}

/* ─── Metric Card ────────────────────────────────────────────────────── */
.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-base);
}
.metric-card:hover { box-shadow: var(--shadow-md); }
.metric-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}
.metric-value {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  line-height: 1;
  margin-top: 4px;
}
.metric-trend {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: 2px;
}
.metric-trend.up   { color: var(--color-success); }
.metric-trend.down { color: var(--color-error); }

/* ─── Sidebar Nav ────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--duration-slow) var(--ease);
}
.sidebar-logo {
  padding: 20px var(--space-2) 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-logo-text {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: var(--tracking-snug);
}
.sidebar-logo-text span { color: var(--color-accent); }
.sidebar-nav {
  flex: 1;
  padding: var(--space-2) var(--space-1);
  overflow-y: auto;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  padding: 0 var(--space-1);
  margin: var(--space-2) 0 var(--space-1);
}
.nav-section-label:first-child { margin-top: 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--duration-fast);
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 2px;
  user-select: none;
}
.nav-link:hover {
  background: var(--color-surface-inset);
  color: var(--color-text);
}
.nav-link.active {
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-weight: 600;
}

.nav-link:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.nav-link svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-link.active svg { opacity: 1; }
.nav-link:hover svg { opacity: 1; }

.sidebar-footer {
  padding: var(--space-2) var(--space-1);
  border-top: 1px solid var(--color-border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.sidebar-user:hover { background: var(--color-surface-inset); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-accent-dim);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-lg { width: 40px; height: 40px; font-size: 16px; }
.user-name { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); }
.user-email { font-size: var(--text-xs); color: var(--color-text-secondary); }

/* ─── Main Layout ────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.page-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: var(--tracking-snug); }
.page-body {
  padding: var(--space-4);
  flex: 1;
}

/* ─── Live Pill ──────────────────────────────────────────────────────── */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--color-success-bg);
  color: var(--color-success);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.live-pill .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse 1.4s ease-in-out infinite;
}
.live-pill.offline { background: var(--color-surface-inset); color: var(--color-text-tertiary); }
.live-pill.offline .dot { background: var(--color-text-tertiary); animation: none; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ─── Mobile ─────────────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  padding: 14px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.mobile-nav-tabs {
  display: none;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.mobile-nav-tabs::-webkit-scrollbar { display: none; }
.mobile-nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 16px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--duration-fast);
  user-select: none;
  text-decoration: none;
}
.mobile-nav-tab svg { width: 18px; height: 18px; opacity: 0.6; }
.mobile-nav-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}
.mobile-nav-tab.active svg { opacity: 1; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .main-content { margin-left: 0; }
  .mobile-topbar { display: flex; }
  .mobile-nav-tabs { display: flex; }
  .page-header { display: none; }
  .page-body { padding: var(--space-2); }
  .metric-value { font-size: var(--text-2xl); }
}

@media (max-width: 480px) {
  :root { --space-3: 16px; --space-4: 16px; }
  .page-body { padding: var(--space-1); }
}

/* ─── Overlay (mobile sidebar) ───────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ─── Utilities ──────────────────────────────────────────────────────── */
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-2); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
.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); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.text-center { text-align: center; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.muted { color: var(--color-text-secondary); }

/* ─── Text Overflow Safety ──────────────────────────────────────────── */
.break-word { word-wrap: break-word; overflow-wrap: break-word; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ─── Icon Utilities (consistent sizing + alignment) ───────────────── */
.icon-sm  { width: 16px; height: 16px; flex-shrink: 0; }
.icon-md  { width: 20px; height: 20px; flex-shrink: 0; }
.icon-lg  { width: 24px; height: 24px; flex-shrink: 0; }
.icon-xl  { width: 32px; height: 32px; flex-shrink: 0; }
.icon-inline { display: inline-flex; align-items: center; vertical-align: middle; }

/* ─── Responsive Table Wrapper ──────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── Focus visible (accessibility) ─────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ─── Screen reader only ────────────────────────────────────────────── */
.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;
}

/* ─── Additional Responsive Breakpoints ─────────────────────────────── */
@media (max-width: 375px) {
  :root { --space-3: 14px; --space-4: 14px; }
  .page-body { padding: 6px; }
  .metric-value { font-size: var(--text-xl); }
  .btn { height: 40px; padding: 0 14px; font-size: var(--text-xs); }
  .btn-lg { height: 46px; padding: 0 20px; }
}

@media (min-width: 1024px) and (max-width: 1440px) {
  .page-body { padding: var(--space-3) var(--space-4); }
}
