/*
 * ════════════════════════════════════════════════════════════════════
 *  AKQUIX CRM — Design System v1.0
 *  Desktop-first · CSS Grid + Flexbox · clamp()-Fluid · CSS Tokens
 *  Architektur: Desktop → Laptop → Tablet → Phone
 * ════════════════════════════════════════════════════════════════════
 */

/* ─────────────────────────────────────────────────────────────────
   1. DESIGN TOKENS  (CSS Custom Properties / :root)
   ─────────────────────────────────────────────────────────────────
   Single source of truth for the entire UI.
   All values cascade from here – no hard-coded values in components.
   ───────────────────────────────────────────────────────────────── */
:root {

  /* ── Brand ── */
  --brand:          #4f63e7;
  --brand-hover:    #4257d9;
  --brand-light:    #6d7ff0;
  --brand-dim:      rgba(79, 99, 231, 0.08);
  --brand-ring:     rgba(79, 99, 231, 0.15);
  --brand2:         #6d4fc0;
  --brand-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  /* ── Surfaces ── */
  --bg:       #f0f2f7;
  --surface:  #ffffff;
  --surface2: #f8f9fc;
  --surface3: #f4f6fa;
  --surface4: #eef0f6;

  /* ── Borders ── */
  --border:  #e2e6ef;
  --border2: #eaecf4;
  --border3: #f0f2f8;

  /* ── Text Scale ── */
  --text:  #111827;
  --text2: #374151;
  --text3: #6b7280;
  --text4: #9ca3af;
  --text5: #d1d5db;

  /* ── Functional Color Triples (bg / border / text) ── */
  --c-blue-bg:   #eff6ff;  --c-blue-bd:   #bfdbfe;  --c-blue-tx:   #1d4ed8;
  --c-violet-bg: #f5f3ff;  --c-violet-bd: #ddd6fe;  --c-violet-tx: #5b21b6;
  --c-amber-bg:  #fffbeb;  --c-amber-bd:  #fde68a;  --c-amber-tx:  #92400e;
  --c-green-bg:  #f0fdf4;  --c-green-bd:  #bbf7d0;  --c-green-tx:  #065f46;
  --c-red-bg:    #fff1f2;  --c-red-bd:    #fecaca;  --c-red-tx:    #b91c1c;
  --c-pink-bg:   #fdf2f8;  --c-pink-bd:   #fbcfe8;  --c-pink-tx:   #be185d;
  --c-orange-bg: #fff7ed;  --c-orange-bd: #fed7aa;  --c-orange-tx: #c2410c;
  --c-slate-bg:  #f8fafc;  --c-slate-bd:  #e2e8f0;  --c-slate-tx:  #475569;
  --c-emerald:   #059669;

  /* ── Radius Scale ── */
  --r-xs:   4px;
  --r-sm:   6px;
  --r:      10px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* ── Shadow Scale ── */
  --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.04);
  --sh:    0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.06);
  --sh-md: 0 4px 16px rgba(0, 0, 0, 0.09), 0 1px 4px rgba(0, 0, 0, 0.05);
  --sh-lg: 0 10px 40px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.08);
  --sh-xl: 0 20px 60px rgba(0, 0, 0, 0.20), 0 8px 24px rgba(0, 0, 0, 0.10);

  /* ── Transition Presets ── */
  --t:         all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast:    all 0.10s ease;
  --t-slow:    all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --t-sidebar: width 0.22s cubic-bezier(0.4, 0, 0.2, 1),
               padding 0.22s cubic-bezier(0.4, 0, 0.2, 1),
               opacity 0.18s ease;

  /* ── Fluid Typography Scale (clamp: min, fluid, max) ── */
  --fs-xs:   clamp(10px,  0.70vw, 11px);
  --fs-sm:   clamp(11px,  0.80vw, 12px);
  --fs-base: clamp(12.5px,0.90vw, 14px);
  --fs-md:   clamp(14px,  1.05vw, 15px);
  --fs-lg:   clamp(15px,  1.20vw, 17px);
  --fs-xl:   clamp(18px,  1.50vw, 22px);
  --fs-2xl:  clamp(22px,  1.80vw, 28px);
  --fs-3xl:  clamp(28px,  2.50vw, 36px);
  --fs-4xl:  clamp(34px,  3.00vw, 48px);

  /* ── Fluid Spacing Scale ── */
  --sp-1:  clamp(3px,   0.25vw, 4px);
  --sp-2:  clamp(6px,   0.50vw, 8px);
  --sp-3:  clamp(10px,  0.75vw, 12px);
  --sp-4:  clamp(13px,  1.00vw, 16px);
  --sp-5:  clamp(17px,  1.35vw, 20px);
  --sp-6:  clamp(21px,  1.65vw, 24px);
  --sp-8:  clamp(27px,  2.10vw, 32px);
  --sp-10: clamp(35px,  2.70vw, 40px);
  --sp-12: clamp(44px,  3.40vw, 48px);

  /* ── Layout Chrome ── */
  --sidebar-w:           260px;
  --sidebar-collapsed-w: 56px;
  --admin-sidebar-w:     220px;
  --topbar-h:            54px;
  --actionbar-h:         46px;
  --header-h:            56px;

  /* ── Container Widths ── */
  --c-sm:  680px;   /* auth, narrow forms */
  --c-md:  900px;   /* settings, account */
  --c-doc: 920px;   /* document/prose reading */
  --c-lg:  1240px;  /* standard dashboard */
  --c-xl:  1500px;  /* wide dashboard */
  --c-max: 1800px;  /* ultrawide guard */
  --c-pad: clamp(16px, 2.5vw, 40px);

  /* ── Z-Index Stack ── */
  --z-base:     1;
  --z-sticky:   10;
  --z-dropdown: 100;
  --z-sidebar:  300;
  --z-overlay:  400;
  --z-modal:    500;
  --z-toast:    600;
  --z-tooltip:  700;
}


/* ─────────────────────────────────────────────────────────────────
   2. BASE
   ───────────────────────────────────────────────────────────────── */

/* Thin, elegant scrollbar system */
::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: var(--text5); }


/* ─────────────────────────────────────────────────────────────────
   3. CONTAINER SYSTEM
   ─────────────────────────────────────────────────────────────────

   Usage:
     <div class="ax-container">              → max 1240px (default)
     <div class="ax-container ax-c--sm">     → max 680px  (auth, narrow forms)
     <div class="ax-container ax-c--md">     → max 900px  (settings, account)
     <div class="ax-container ax-c--doc">    → max 920px  (documents, prose)
     <div class="ax-container ax-c--lg">     → max 1500px (wide dashboard)
     <div class="ax-container ax-c--xl">     → max 1800px (ultrawide-safe)
     <div class="ax-container ax-c--fluid">  → no max-width

   All containers have auto side margins + fluid horizontal padding.
   ───────────────────────────────────────────────────────────────── */

.ax-container {
  width: 100%;
  max-width: var(--c-lg);
  margin-inline: auto;
  padding-inline: var(--c-pad);
}

.ax-c--sm    { max-width: var(--c-sm); }
.ax-c--md    { max-width: var(--c-md); }
.ax-c--doc   { max-width: var(--c-doc); }
.ax-c--lg    { max-width: var(--c-xl); }
.ax-c--xl    { max-width: var(--c-max); }
.ax-c--fluid { max-width: none; }


/* ─────────────────────────────────────────────────────────────────
   4. RESPONSIVE GRID SYSTEM
   ─────────────────────────────────────────────────────────────────

   Auto-fit grids (responsive without media queries):
     .ax-grid-kpi    → 4+ equal KPI cards, min 180px
     .ax-grid-cards  → card grid, min 260px
     .ax-grid-stats  → stat blocks, min 200px
     .ax-grid-charts → chart panels, min 380px

   Fixed-column grids:
     .ax-grid-2 / -3 / -4

   Form grids:
     .ax-form-2 / -3

   Span helpers:
     .ax-col-2 → span 2 columns
     .ax-col-full → full width
   ───────────────────────────────────────────────────────────────── */

/* Auto-fit grids */
.ax-grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4);
  align-items: stretch;
}

.ax-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--sp-4);
  align-items: stretch;
}

.ax-grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  align-items: stretch;
}

.ax-grid-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: var(--sp-5);
}

/* Fixed-column grids */
.ax-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.ax-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.ax-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

/* Form grids */
.ax-form-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.ax-form-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }

/* Span helpers */
.ax-col-2    { grid-column: span 2; }
.ax-col-3    { grid-column: span 3; }
.ax-col-full { grid-column: 1 / -1; }


/* ─────────────────────────────────────────────────────────────────
   5. FLEXBOX UTILITIES
   ───────────────────────────────────────────────────────────────── */

.ax-flex         { display: flex; }
.ax-flex-col     { display: flex; flex-direction: column; }
.ax-flex-wrap    { flex-wrap: wrap; }
.ax-flex-1       { flex: 1; min-width: 0; }
.ax-flex-shrink0 { flex-shrink: 0; }
.ax-items-center { align-items: center; }
.ax-items-start  { align-items: flex-start; }
.ax-items-end    { align-items: flex-end; }
.ax-justify-center  { justify-content: center; }
.ax-justify-between { justify-content: space-between; }
.ax-justify-end     { justify-content: flex-end; }

/* Toolbar pattern: horizontal flex with wrapping and spacing */
.ax-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.ax-toolbar--space { justify-content: space-between; }

.ax-toolbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}


/* ─────────────────────────────────────────────────────────────────
   6. APP LAYOUT SHELL
   ─────────────────────────────────────────────────────────────────

   Full-height desktop app chrome:

     <div class="ax-shell">
       <header class="ax-topbar">...</header>
       <div class="ax-workspace">
         <nav class="ax-sidebar">...</nav>
         <main class="ax-main">
           <div class="ax-actionbar">...</div>
           <div class="ax-content">...</div>
         </main>
       </div>
     </div>
   ───────────────────────────────────────────────────────────────── */

.ax-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.ax-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  flex-shrink: 0;
  z-index: var(--z-sticky);
}

.ax-topbar-logo {
  font-size: var(--fs-md);
  font-weight: 800;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ax-topbar-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
  flex-shrink: 0;
}

.ax-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ax-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.ax-content {
  flex: 1;
  padding: var(--sp-5) var(--c-pad);
}

.ax-actionbar {
  height: var(--actionbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  gap: var(--sp-2);
  flex-shrink: 0;
}


/* ─────────────────────────────────────────────────────────────────
   7. SIDEBAR SYSTEM
   ─────────────────────────────────────────────────────────────────

   States:
     Default:     width var(--sidebar-w) = 260px – full labels visible
     Collapsed:   .ax-sidebar--collapsed → width var(--sidebar-collapsed-w) = 56px
                  Text labels fade out, only icons remain.
                  Toggle button flips direction.

   HTML pattern:
     <nav class="ax-sidebar" id="mainSidebar">
       <button class="ax-sidebar-toggle" onclick="toggleSidebar()">‹</button>
       <div class="ax-sidebar-inner">
         <div class="ax-sidebar-section">
           <div class="ax-sidebar-title sidebar-label">Aktionen</div>
           <button class="ax-nav-item">
             <span class="ax-nav-icon">🔍</span>
             <span class="sidebar-label">Suchen</span>
           </button>
         </div>
       </div>
     </nav>
   ───────────────────────────────────────────────────────────────── */

.ax-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--t-sidebar);
  position: relative;
  z-index: var(--z-sidebar);
}

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

/* Toggle button: floats at edge of sidebar, sticks out visually */
.ax-sidebar-toggle {
  position: absolute;
  top: 14px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: calc(var(--z-sidebar) + 2);
  box-shadow: var(--sh-sm);
  transition: var(--t);
  color: var(--text3);
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
  padding: 0;
  font-family: inherit;
}

.ax-sidebar-toggle:hover {
  background: var(--brand-dim);
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: var(--sh);
}

.ax-sidebar-toggle[aria-expanded="false"] {
  transform: scaleX(-1); /* flip arrow direction when collapsed */
}

.ax-sidebar-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 12px;
}

/* Text labels – hidden smoothly when sidebar collapses */
.ax-sidebar .sidebar-label {
  opacity: 1;
  overflow: hidden;
  white-space: nowrap;
  max-width: 200px;
  transition: opacity 0.16s ease, max-width 0.22s ease, margin 0.18s ease;
  flex-shrink: 1;
}

.ax-sidebar--collapsed .sidebar-label {
  opacity: 0;
  max-width: 0;
  margin: 0 !important;
}

/* Section title row */
.ax-sidebar-section {
  padding: 0 10px 4px;
}

.ax-sidebar-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text4);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 6px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.16s ease, height 0.22s ease, padding 0.22s ease;
}

.ax-sidebar--collapsed .ax-sidebar-title {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
}

/* Navigation items */
.ax-nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 7px 8px;
  border-radius: var(--r-sm);
  color: var(--text2);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--t);
  white-space: nowrap;
  overflow: hidden;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.4;
}

.ax-nav-item:hover {
  background: var(--surface3);
  color: var(--text);
}

.ax-nav-item.ax-nav-active {
  background: var(--brand-dim);
  color: var(--brand);
  font-weight: 600;
}

.ax-nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

/* Collapsed: center icons, remove text space */
.ax-sidebar--collapsed .ax-sidebar-inner {
  padding: 8px 4px 12px;
}

.ax-sidebar--collapsed .ax-sidebar-section {
  padding: 0 4px 4px;
}

.ax-sidebar--collapsed .ax-nav-item {
  padding: 7px;
  justify-content: center;
}

.ax-sidebar--collapsed .ax-nav-icon {
  width: 22px;
  height: 22px;
  font-size: 15px;
}

/* Sidebar divider */
.ax-sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 10px;
  flex-shrink: 0;
}

/* Sidebar footer pinned to bottom */
.ax-sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 12px 10px;
  flex-shrink: 0;
  overflow: hidden;
}

.ax-sidebar--collapsed .ax-sidebar-footer {
  padding: 12px 4px;
}


/* ─────────────────────────────────────────────────────────────────
   8. PAGE LAYOUT PATTERNS
   ─────────────────────────────────────────────────────────────────

   .ax-page              → standard page (header + body)
   .ax-page-header       → page title bar
   .ax-page-body         → scrollable content area
   .ax-page-centered     → max 900px centered (settings/account)
   .ax-page-centered--doc→ max 920px centered (documents/legal)
   .ax-page-dashboard    → wide dashboard page (max 1500px)
   ───────────────────────────────────────────────────────────────── */

.ax-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.ax-page-header {
  padding: var(--sp-5) var(--c-pad) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.ax-page-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.ax-page-subtitle {
  font-size: var(--fs-sm);
  color: var(--text3);
  margin-top: 3px;
}

.ax-page-body {
  flex: 1;
  padding: var(--sp-5) var(--c-pad);
}

/* Centered layout (settings / account / auth) */
.ax-page-centered {
  max-width: var(--c-md);
  margin-inline: auto;
  width: 100%;
}

.ax-page-centered--doc { max-width: var(--c-doc); }
.ax-page-centered--sm  { max-width: var(--c-sm); }

/* Dashboard layout (wider) */
.ax-page-dashboard {
  max-width: var(--c-xl);
  margin-inline: auto;
  width: 100%;
}


/* ─────────────────────────────────────────────────────────────────
   9. CARD SYSTEM
   ───────────────────────────────────────────────────────────────── */

.ax-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
}

.ax-card--flat     { box-shadow: none; }
.ax-card--elevated { box-shadow: var(--sh-md); }
.ax-card--hover    { transition: box-shadow 0.18s ease, border-color 0.18s ease; }
.ax-card--hover:hover {
  box-shadow: var(--sh-md);
  border-color: var(--border2);
}

.ax-card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.ax-card-header h2,
.ax-card-header h3 {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.ax-card-body {
  padding: var(--sp-4) var(--sp-5);
}

.ax-card-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border2);
  background: var(--surface2);
  border-radius: 0 0 var(--r-md) var(--r-md);
}


/* ─────────────────────────────────────────────────────────────────
   10. KPI CARD SYSTEM
   ─────────────────────────────────────────────────────────────────

   Usage with .ax-grid-kpi for auto-responsive card grid:

     <div class="ax-grid-kpi">
       <div class="ax-kpi">
         <div class="ax-kpi-label">Überfällig</div>
         <div class="ax-kpi-value">14</div>
         <div class="ax-kpi-sub">Wiedervorlagen</div>
       </div>
     </div>
   ───────────────────────────────────────────────────────────────── */

.ax-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  box-shadow: var(--sh-sm);
  min-height: 88px;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: default;
}

.ax-kpi:hover {
  box-shadow: var(--sh);
  border-color: var(--border2);
}

.ax-kpi--clickable { cursor: pointer; }

.ax-kpi--danger  { border-left: 3px solid var(--c-red-tx); }
.ax-kpi--warning { border-left: 3px solid var(--c-amber-tx); }
.ax-kpi--success { border-left: 3px solid var(--c-green-tx); }
.ax-kpi--brand   { border-left: 3px solid var(--brand); }

.ax-kpi-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text3);
}

.ax-kpi-value {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-top: 4px;
}

.ax-kpi-sub {
  font-size: var(--fs-xs);
  color: var(--text4);
  margin-top: 2px;
}


/* ─────────────────────────────────────────────────────────────────
   11. TABLE SYSTEM
   ─────────────────────────────────────────────────────────────────

   .ax-table-wrap   → scroll container (horizontal + sticky header)
   .ax-table        → the table
   .ax-table--compact → less padding

   Usage:
     <div class="ax-table-wrap">
       <table class="ax-table">
         <thead>...</thead>
         <tbody>...</tbody>
       </table>
     </div>
   ───────────────────────────────────────────────────────────────── */

.ax-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-sm);
}

.ax-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  min-width: 480px; /* prevent layout collapse on narrow screens */
}

.ax-table thead {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.ax-table thead th {
  background: var(--surface2);
  border-bottom: 1.5px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}

.ax-table tbody tr {
  border-bottom: 1px solid var(--border2);
  transition: background 0.1s ease;
}

.ax-table tbody tr:last-child {
  border-bottom: none;
}

.ax-table tbody tr:hover {
  background: var(--surface3);
}

.ax-table tbody td {
  padding: 10px 14px;
  color: var(--text2);
  vertical-align: middle;
}

.ax-table tbody td:first-child {
  font-weight: 600;
  color: var(--text);
}

/* Compact variant */
.ax-table--compact thead th,
.ax-table--compact tbody td {
  padding: 7px 12px;
}


/* ─────────────────────────────────────────────────────────────────
   12. FORM COMPONENTS
   ───────────────────────────────────────────────────────────────── */

.ax-input,
.ax-select,
.ax-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  line-height: 1.5;
}

.ax-input:focus,
.ax-select:focus,
.ax-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.ax-input::placeholder,
.ax-textarea::placeholder {
  color: var(--text4);
}

.ax-textarea { resize: vertical; min-height: 80px; }

.ax-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
}

.ax-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ax-field-hint {
  font-size: var(--fs-xs);
  color: var(--text4);
}

.ax-field-error {
  font-size: var(--fs-xs);
  color: var(--c-red-tx);
}


/* ─────────────────────────────────────────────────────────────────
   13. BUTTON SYSTEM
   ─────────────────────────────────────────────────────────────────

   Base:    .ax-btn
   Variant: .ax-btn--primary / --secondary / --ghost / --danger
   Size:    .ax-btn--sm / .ax-btn--lg
   ───────────────────────────────────────────────────────────────── */

.ax-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 36px;
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--t);
  font-family: inherit;
  text-decoration: none;
  line-height: 1;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.ax-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ax-btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 99, 231, 0.25);
}
.ax-btn--primary:hover:not(:disabled) {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  box-shadow: 0 3px 10px rgba(79, 99, 231, 0.35);
  transform: translateY(-1px);
}

.ax-btn--secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text2);
}
.ax-btn--secondary:hover:not(:disabled) {
  background: var(--surface3);
  border-color: var(--border2);
}

.ax-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text3);
}
.ax-btn--ghost:hover:not(:disabled) {
  background: var(--surface3);
  color: var(--text2);
}

.ax-btn--danger {
  background: var(--c-red-bg);
  border-color: var(--c-red-bd);
  color: var(--c-red-tx);
}
.ax-btn--danger:hover:not(:disabled) {
  background: var(--c-red-bd);
  border-color: var(--c-red-tx);
}

/* Sizes */
.ax-btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-xs);
  border-radius: var(--r-xs);
}

.ax-btn--lg {
  height: 44px;
  padding: 0 24px;
  font-size: var(--fs-md);
}


/* ─────────────────────────────────────────────────────────────────
   14. BADGE / PILL SYSTEM
   ───────────────────────────────────────────────────────────────── */

.ax-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.ax-badge--blue   { background: var(--c-blue-bg);   border-color: var(--c-blue-bd);   color: var(--c-blue-tx); }
.ax-badge--violet { background: var(--c-violet-bg); border-color: var(--c-violet-bd); color: var(--c-violet-tx); }
.ax-badge--green  { background: var(--c-green-bg);  border-color: var(--c-green-bd);  color: var(--c-green-tx); }
.ax-badge--amber  { background: var(--c-amber-bg);  border-color: var(--c-amber-bd);  color: var(--c-amber-tx); }
.ax-badge--red    { background: var(--c-red-bg);    border-color: var(--c-red-bd);    color: var(--c-red-tx); }
.ax-badge--orange { background: var(--c-orange-bg); border-color: var(--c-orange-bd); color: var(--c-orange-tx); }
.ax-badge--slate  { background: var(--c-slate-bg);  border-color: var(--c-slate-bd);  color: var(--c-slate-tx); }
.ax-badge--brand  { background: var(--brand-dim);   border-color: var(--brand-ring);  color: var(--brand); }


/* ─────────────────────────────────────────────────────────────────
   15. DOCUMENT / PROSE LAYOUT
   ─────────────────────────────────────────────────────────────────

   For legal documents, help pages, text-heavy content.
   ~920px centered reading column, Notion/linear style.
   ───────────────────────────────────────────────────────────────── */

.ax-prose {
  max-width: var(--c-doc);
  margin-inline: auto;
  padding: var(--sp-10) var(--c-pad);
}

.ax-prose h1 {
  font-size: var(--fs-3xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin-bottom: var(--sp-4);
}

.ax-prose h2 {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text);
  margin-top: var(--sp-8);
  margin-bottom: var(--sp-3);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border2);
}

.ax-prose h3 {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text2);
  margin-top: var(--sp-5);
  margin-bottom: var(--sp-2);
}

.ax-prose p {
  font-size: var(--fs-base);
  color: var(--text2);
  line-height: 1.8;
  margin-bottom: var(--sp-4);
}

.ax-prose ul,
.ax-prose ol {
  padding-left: 1.5em;
  margin-bottom: var(--sp-4);
}

.ax-prose li {
  font-size: var(--fs-base);
  color: var(--text2);
  line-height: 1.8;
  margin-bottom: var(--sp-1);
}

.ax-prose-paper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: clamp(28px, 4vw, 60px);
}


/* ─────────────────────────────────────────────────────────────────
   16. AUTH / LOGIN PAGE LAYOUT
   ───────────────────────────────────────────────────────────────── */

.ax-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gradient);
  padding: var(--sp-5);
}

.ax-auth-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  width: 100%;
  max-width: 420px;
  padding: clamp(28px, 3vw, 44px);
}


/* ─────────────────────────────────────────────────────────────────
   17. ULTRAWIDE GUARD
   ─────────────────────────────────────────────────────────────────

   Prevents content from stretching infinitely on 34"+ monitors.
   Wrap page content in .ax-uw-guard for controlled expansion.
   ───────────────────────────────────────────────────────────────── */

.ax-uw-guard {
  width: 100%;
  max-width: var(--c-max);
  margin-inline: auto;
}

/* Growing side padding on very wide screens */
.ax-uw-pad {
  padding-inline: clamp(16px, 4vw, 80px);
}


/* ─────────────────────────────────────────────────────────────────
   18. SPACING UTILITIES
   ───────────────────────────────────────────────────────────────── */

.ax-gap-1  { gap: var(--sp-1); }
.ax-gap-2  { gap: var(--sp-2); }
.ax-gap-3  { gap: var(--sp-3); }
.ax-gap-4  { gap: var(--sp-4); }
.ax-gap-5  { gap: var(--sp-5); }

.ax-p-4    { padding: var(--sp-4); }
.ax-p-5    { padding: var(--sp-5); }
.ax-px-4   { padding-inline: var(--sp-4); }
.ax-py-4   { padding-block: var(--sp-4); }
.ax-px-5   { padding-inline: var(--sp-5); }
.ax-py-5   { padding-block: var(--sp-5); }
.ax-mt-auto { margin-top: auto; }
.ax-mx-auto { margin-inline: auto; }


/* ─────────────────────────────────────────────────────────────────
   19. TYPOGRAPHY UTILITIES
   ───────────────────────────────────────────────────────────────── */

.ax-text-brand   { color: var(--brand); }
.ax-text-muted   { color: var(--text3); }
.ax-text-danger  { color: var(--c-red-tx); }
.ax-text-success { color: var(--c-green-tx); }
.ax-text-warning { color: var(--c-amber-tx); }

.ax-fs-xs   { font-size: var(--fs-xs); }
.ax-fs-sm   { font-size: var(--fs-sm); }
.ax-fs-base { font-size: var(--fs-base); }
.ax-fs-md   { font-size: var(--fs-md); }
.ax-fs-lg   { font-size: var(--fs-lg); }
.ax-fs-xl   { font-size: var(--fs-xl); }

.ax-fw-medium  { font-weight: 500; }
.ax-fw-semibold{ font-weight: 600; }
.ax-fw-bold    { font-weight: 700; }
.ax-fw-black   { font-weight: 800; }

.ax-truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-sr-only   { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }


/* ─────────────────────────────────────────────────────────────────
   20. VISUAL UTILITIES
   ───────────────────────────────────────────────────────────────── */

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

.ax-surface     { background: var(--surface); }
.ax-surface2    { background: var(--surface2); }

.ax-border      { border: 1px solid var(--border); }
.ax-shadow-sm   { box-shadow: var(--sh-sm); }
.ax-shadow      { box-shadow: var(--sh); }
.ax-shadow-md   { box-shadow: var(--sh-md); }

.ax-overflow-hidden { overflow: hidden; }


/* ─────────────────────────────────────────────────────────────────
   21. BREAKPOINTS  (Desktop-first — max-width)
   ─────────────────────────────────────────────────────────────────

   Name         Width       Target Devices
   ────────────────────────────────────────────
   --bp-ultra   ≥ 2000px    Ultrawide 49" / 4K
   --bp-4k      ≥ 2560px    4K monitors
   --bp-wide    ≤ 1600px    Wide desktop 27"
   --bp-laptop  ≤ 1280px    Laptop 13-15"
   --bp-s-lap   ≤ 1100px    Small laptop / compressed
   --bp-tablet  ≤  900px    Tablet landscape
   --bp-phone   ≤  640px    Phone / narrow
   ───────────────────────────────────────────────────────────────── */

/* 4K / Ultrawide: more generous spacing and wider min-sizes */
@media (min-width: 2000px) {
  :root {
    --c-pad:      60px;
    --sidebar-w:  280px;
  }

  .ax-grid-kpi   { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .ax-grid-cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
  .ax-grid-stats { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

/* Wide desktop (≤1600px): keep comfortable padding */
@media (max-width: 1600px) {
  :root { --c-pad: clamp(20px, 2.5vw, 40px); }
}

/* Laptop (≤1280px): slight sidebar compression */
@media (max-width: 1280px) {
  :root { --sidebar-w: 240px; }
}

/* Small laptop / compressed view (≤1100px): sidebar auto-collapses */
@media (max-width: 1100px) {
  .ax-sidebar { width: var(--sidebar-collapsed-w); }
  .ax-sidebar .sidebar-label { opacity: 0; max-width: 0; }
  .ax-sidebar .ax-sidebar-title { opacity: 0; height: 0; padding: 0; overflow: hidden; }
  .ax-sidebar .ax-nav-item { padding: 7px; justify-content: center; }
  .ax-sidebar .ax-sidebar-inner { padding: 8px 4px 12px; }
  .ax-sidebar .ax-sidebar-section { padding: 0 4px 4px; }

  /* Adjust grids */
  .ax-grid-2 { grid-template-columns: 1fr; }
  .ax-form-2 { grid-template-columns: 1fr 1fr; } /* forms stay 2-col */
}

/* Tablet (≤900px): collapse multi-col grids */
@media (max-width: 900px) {
  :root { --c-pad: clamp(14px, 2vw, 24px); }

  .ax-grid-3,
  .ax-grid-4        { grid-template-columns: repeat(2, 1fr); }
  .ax-grid-charts   { grid-template-columns: 1fr; }
  .ax-form-3        { grid-template-columns: 1fr 1fr; }
  .ax-col-2,
  .ax-col-3         { grid-column: span 1; }
}

/* Phone (≤640px): everything single column */
@media (max-width: 640px) {
  :root { --c-pad: 16px; }

  .ax-grid-2,
  .ax-grid-3,
  .ax-grid-4,
  .ax-form-2,
  .ax-form-3        { grid-template-columns: 1fr; }
  .ax-grid-kpi      { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .ax-toolbar       { flex-direction: column; align-items: stretch; }
}

/* Print */
@media print {
  .ax-sidebar,
  .ax-topbar,
  .ax-actionbar,
  .ax-sidebar-toggle { display: none !important; }

  .ax-main { overflow: visible; }
}
