/* =============================================================================
   CrewSync Design System — v3.2-ui-refresh
   Enterprise B2B SaaS · Travel Management (ITL World × ADC Group)
   -----------------------------------------------------------------------------
   Use the cs- prefix to keep this isolated from the existing class names while
   the cut-over is in progress. Drop the prefix once the legacy CSS is removed.
   ============================================================================= */


/* =============================================================================
   1. Design tokens
   ============================================================================= */
:root {
  /* ---------- Palette: brand (deep corporate blue) -------------------------*/
  --cs-brand-50:  #EEF3FE;
  --cs-brand-100: #DCE5FC;
  --cs-brand-200: #B7C8F8;
  --cs-brand-300: #8AA5F2;
  --cs-brand-400: #5A80E8;
  --cs-brand-500: #2E5BD9;
  --cs-brand-600: #1A46C2;   /* primary actions, focus rings */
  --cs-brand-700: #163A9F;
  --cs-brand-800: #122E7C;
  --cs-brand-900: #0B2056;   /* sidebar deep-fill option */

  /* ---------- Palette: neutrals (cool slate) -------------------------------*/
  --cs-slate-0:   #FFFFFF;
  --cs-slate-50:  #F8FAFC;   /* canvas */
  --cs-slate-100: #F1F5F9;   /* muted surface */
  --cs-slate-200: #E2E8F0;   /* subtle border */
  --cs-slate-300: #CBD5E1;   /* default border */
  --cs-slate-400: #94A3B8;   /* placeholder */
  --cs-slate-500: #64748B;   /* tertiary text */
  --cs-slate-600: #475569;   /* secondary text */
  --cs-slate-700: #334155;
  --cs-slate-800: #1E293B;
  --cs-slate-900: #0F172A;   /* primary text */

  /* ---------- Palette: semantic (muted, modern) ----------------------------*/
  --cs-success-50:  #ECFDF5;
  --cs-success-100: #D1FAE5;
  --cs-success-600: #059669;
  --cs-success-700: #047857;

  --cs-warning-50:  #FFFBEB;
  --cs-warning-100: #FEF3C7;
  --cs-warning-600: #D97706;
  --cs-warning-700: #B45309;

  --cs-danger-50:   #FEF2F2;
  --cs-danger-100:  #FEE2E2;
  --cs-danger-600:  #DC2626;
  --cs-danger-700:  #B91C1C;

  --cs-info-50:     #EFF6FF;
  --cs-info-100:    #DBEAFE;
  --cs-info-600:    #2563EB;
  --cs-info-700:    #1D4ED8;

  /* ---------- Semantic aliases (use these in component CSS) ----------------*/
  --cs-bg-canvas:        var(--cs-slate-50);
  --cs-bg-surface:       var(--cs-slate-0);
  --cs-bg-muted:         var(--cs-slate-100);
  --cs-bg-inverse:       var(--cs-slate-900);

  --cs-text-primary:     var(--cs-slate-900);
  --cs-text-secondary:   var(--cs-slate-600);
  --cs-text-tertiary:    var(--cs-slate-500);
  --cs-text-placeholder: var(--cs-slate-400);
  --cs-text-on-brand:    var(--cs-slate-0);
  --cs-text-link:        var(--cs-brand-600);

  --cs-border-subtle:    var(--cs-slate-200);
  --cs-border-default:   var(--cs-slate-300);
  --cs-border-strong:    var(--cs-slate-400);
  --cs-border-focus:     var(--cs-brand-500);

  --cs-brand-primary:        var(--cs-brand-600);
  --cs-brand-primary-hover:  var(--cs-brand-700);
  --cs-brand-primary-active: var(--cs-brand-800);

  /* ---------- Typography ---------------------------------------------------*/
  --cs-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  --cs-font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', Consolas, monospace;

  --cs-text-xs:   11px;
  --cs-text-sm:   12px;
  --cs-text-base: 13px;
  --cs-text-md:   14px;
  --cs-text-lg:   16px;
  --cs-text-xl:   18px;
  --cs-text-2xl:  20px;
  --cs-text-3xl:  24px;
  --cs-text-4xl:  30px;

  --cs-leading-tight:   1.25;
  --cs-leading-normal:  1.5;
  --cs-leading-relaxed: 1.65;

  --cs-tracking-tight:  -0.015em;
  --cs-tracking-normal: 0;
  --cs-tracking-wide:   0.04em;

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

  /* ---------- Radii --------------------------------------------------------*/
  --cs-radius-xs:   4px;
  --cs-radius-sm:   6px;
  --cs-radius-md:   8px;
  --cs-radius-lg:   12px;
  --cs-radius-xl:   16px;
  --cs-radius-full: 999px;

  /* ---------- Shadows ------------------------------------------------------*/
  --cs-shadow-xs:    0 1px 2px rgba(15, 23, 42, 0.04);
  --cs-shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --cs-shadow-md:    0 4px 8px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --cs-shadow-lg:    0 12px 24px -8px rgba(15, 23, 42, 0.10), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
  --cs-shadow-xl:    0 24px 48px -16px rgba(15, 23, 42, 0.18), 0 8px 16px -8px rgba(15, 23, 42, 0.10);
  --cs-shadow-focus: 0 0 0 3px rgba(46, 91, 217, 0.20);

  /* ---------- Layout -------------------------------------------------------*/
  --cs-topbar-h:    56px;
  --cs-sidebar-w:   240px;
  --cs-content-max: 1440px;

  /* ---------- Motion -------------------------------------------------------*/
  --cs-transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --cs-transition-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --cs-transition-slow: 260ms cubic-bezier(0.4, 0, 0.2, 1);

  /* ---------- z-index scale ------------------------------------------------*/
  --cs-z-base:     1;
  --cs-z-sticky:   10;
  --cs-z-dropdown: 100;
  --cs-z-overlay:  200;
  --cs-z-modal:    300;
  --cs-z-toast:    400;
}


/* =============================================================================
   2. Reset & base
   ============================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  font-family: var(--cs-font-sans);
  font-size: var(--cs-text-md);
  line-height: var(--cs-leading-normal);
  color: var(--cs-text-primary);
  background: var(--cs-bg-canvas);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
hr { border: 0; border-top: 1px solid var(--cs-border-subtle); margin: var(--cs-space-6) 0; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
::selection { background: var(--cs-brand-100); color: var(--cs-brand-900); }


/* =============================================================================
   3. Typography
   ============================================================================= */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--cs-space-3);
  font-weight: 600;
  color: var(--cs-text-primary);
  letter-spacing: var(--cs-tracking-tight);
  line-height: var(--cs-leading-tight);
}
h1 { font-size: var(--cs-text-3xl); font-weight: 700; }
h2 { font-size: var(--cs-text-2xl); }
h3 { font-size: var(--cs-text-xl); }
h4 { font-size: var(--cs-text-lg); }
h5 { font-size: var(--cs-text-md); font-weight: 600; }
h6 {
  font-size: var(--cs-text-sm); font-weight: 600;
  text-transform: uppercase; letter-spacing: var(--cs-tracking-wide);
  color: var(--cs-text-secondary);
}
p { margin: 0 0 var(--cs-space-3); }
small { font-size: var(--cs-text-sm); color: var(--cs-text-secondary); }
a { color: var(--cs-text-link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, pre { font-family: var(--cs-font-mono); font-size: 0.92em; }
code { background: var(--cs-bg-muted); padding: 1px 6px; border-radius: var(--cs-radius-xs); }

.cs-eyebrow {
  font-size: var(--cs-text-xs);
  font-weight: 600;
  letter-spacing: var(--cs-tracking-wide);
  color: var(--cs-text-tertiary);
  text-transform: uppercase;
}


/* =============================================================================
   4. App shell — Grid-based topbar / sidebar / main
   ============================================================================= */
.cs-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--cs-sidebar-w) 1fr;
  grid-template-rows: var(--cs-topbar-h) 1fr;
  grid-template-areas:
    "topbar  topbar"
    "sidebar main";
  background: var(--cs-bg-canvas);
}

.cs-topbar {
  grid-area: topbar;
  background: var(--cs-bg-surface);
  border-bottom: 1px solid var(--cs-border-subtle);
  display: flex; align-items: center;
  padding: 0 var(--cs-space-5);
  gap: var(--cs-space-4);
  position: sticky; top: 0; z-index: var(--cs-z-sticky);
}
.cs-topbar-brand { display: flex; align-items: center; gap: var(--cs-space-3); min-width: 0; }
.cs-topbar-brand img { height: 28px; max-width: 140px; object-fit: contain; }
.cs-topbar-divider { width: 1px; height: 24px; background: var(--cs-border-subtle); flex-shrink: 0; }
.cs-topbar-product {
  font-size: var(--cs-text-md);
  font-weight: 600;
  letter-spacing: var(--cs-tracking-tight);
  color: var(--cs-text-primary);
}
.cs-topbar-product-sub {
  font-size: var(--cs-text-xs);
  color: var(--cs-text-tertiary);
  margin-top: 1px;
}
.cs-topbar-spacer { flex: 1; }
.cs-topbar-actions { display: flex; align-items: center; gap: var(--cs-space-2); }

.cs-sidebar {
  grid-area: sidebar;
  background: var(--cs-bg-surface);
  border-right: 1px solid var(--cs-border-subtle);
  padding: var(--cs-space-3) 0 var(--cs-space-6);
  overflow-y: auto;
}
.cs-nav-section {
  font-size: var(--cs-text-xs);
  font-weight: 600;
  color: var(--cs-text-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--cs-tracking-wide);
  padding: var(--cs-space-4) var(--cs-space-5) var(--cs-space-2);
}
.cs-nav-item {
  display: flex; align-items: center; gap: var(--cs-space-3);
  padding: var(--cs-space-2) var(--cs-space-3);
  margin: 1px var(--cs-space-2);
  border-radius: var(--cs-radius-sm);
  color: var(--cs-text-secondary);
  font-weight: 500;
  font-size: var(--cs-text-md);
  cursor: pointer;
  border: 0; background: transparent; width: calc(100% - var(--cs-space-4));
  text-align: left;
  transition: background var(--cs-transition-fast), color var(--cs-transition-fast);
}
.cs-nav-item:hover { background: var(--cs-bg-muted); color: var(--cs-text-primary); }
.cs-nav-item.cs-active {
  background: var(--cs-brand-50);
  color: var(--cs-brand-700);
  font-weight: 600;
}
.cs-nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; display: inline-flex; align-items: center; justify-content: center; }
.cs-nav-item.cs-active .cs-nav-icon { opacity: 1; }
.cs-nav-badge {
  margin-left: auto;
  background: var(--cs-brand-600);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--cs-radius-full);
  min-width: 18px; text-align: center;
}
.cs-nav-item.cs-active .cs-nav-badge { background: var(--cs-brand-700); }

.cs-main {
  grid-area: main;
  padding: var(--cs-space-6) var(--cs-space-8);
  overflow-y: auto;
  max-width: var(--cs-content-max);
  width: 100%;
}
.cs-page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--cs-space-4);
  margin-bottom: var(--cs-space-6);
}
.cs-page-title { font-size: var(--cs-text-2xl); font-weight: 700; letter-spacing: var(--cs-tracking-tight); margin: 0; }
.cs-page-sub   { color: var(--cs-text-secondary); font-size: var(--cs-text-md); margin-top: var(--cs-space-1); }


/* =============================================================================
   5. Buttons
   ============================================================================= */
.cs-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--cs-space-2);
  height: 36px;
  padding: 0 var(--cs-space-4);
  font-size: var(--cs-text-md);
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--cs-radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--cs-text-primary);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--cs-transition-fast), border-color var(--cs-transition-fast),
              color var(--cs-transition-fast), box-shadow var(--cs-transition-fast);
}
.cs-btn:focus-visible { outline: none; box-shadow: var(--cs-shadow-focus); }
.cs-btn:disabled, .cs-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.cs-btn-primary {
  background: var(--cs-brand-primary);
  color: var(--cs-text-on-brand);
  border-color: var(--cs-brand-primary);
}
.cs-btn-primary:hover  { background: var(--cs-brand-primary-hover);  border-color: var(--cs-brand-primary-hover); }
.cs-btn-primary:active { background: var(--cs-brand-primary-active); }

.cs-btn-secondary {
  background: var(--cs-bg-surface);
  color: var(--cs-text-primary);
  border-color: var(--cs-border-default);
}
.cs-btn-secondary:hover  { background: var(--cs-bg-muted); border-color: var(--cs-border-strong); }
.cs-btn-secondary:active { background: var(--cs-slate-200); }

.cs-btn-ghost { background: transparent; color: var(--cs-text-secondary); }
.cs-btn-ghost:hover  { background: var(--cs-bg-muted); color: var(--cs-text-primary); }
.cs-btn-ghost:active { background: var(--cs-slate-200); }

.cs-btn-danger {
  background: var(--cs-danger-600);
  color: white;
  border-color: var(--cs-danger-600);
}
.cs-btn-danger:hover  { background: var(--cs-danger-700); border-color: var(--cs-danger-700); }
.cs-btn-danger-ghost { background: transparent; color: var(--cs-danger-700); }
.cs-btn-danger-ghost:hover { background: var(--cs-danger-50); }

.cs-btn-sm    { height: 28px; padding: 0 var(--cs-space-3); font-size: var(--cs-text-sm); }
.cs-btn-lg    { height: 44px; padding: 0 var(--cs-space-5); font-size: var(--cs-text-lg); }
.cs-btn-icon  { width: 36px; padding: 0; }
.cs-btn-icon.cs-btn-sm { width: 28px; }
.cs-btn-block { display: flex; width: 100%; }


/* =============================================================================
   6. Forms
   ============================================================================= */
.cs-field { display: flex; flex-direction: column; gap: var(--cs-space-1); }
.cs-label {
  font-size: var(--cs-text-sm);
  font-weight: 500;
  color: var(--cs-text-primary);
}
.cs-label-req::after { content: '*'; color: var(--cs-danger-600); margin-left: 2px; }

.cs-input, .cs-select, .cs-textarea {
  width: 100%;
  height: 36px;
  padding: 0 var(--cs-space-3);
  font-family: inherit;
  font-size: var(--cs-text-md);
  color: var(--cs-text-primary);
  background: var(--cs-bg-surface);
  border: 1px solid var(--cs-border-default);
  border-radius: var(--cs-radius-md);
  transition: border-color var(--cs-transition-fast), box-shadow var(--cs-transition-fast);
}
.cs-textarea {
  height: auto; min-height: 80px;
  padding: var(--cs-space-2) var(--cs-space-3);
  line-height: 1.5; resize: vertical;
}
.cs-input::placeholder, .cs-textarea::placeholder { color: var(--cs-text-placeholder); }
.cs-input:hover, .cs-select:hover, .cs-textarea:hover   { border-color: var(--cs-border-strong); }
.cs-input:focus, .cs-select:focus, .cs-textarea:focus   {
  outline: none;
  border-color: var(--cs-border-focus);
  box-shadow: var(--cs-shadow-focus);
}
.cs-input:disabled, .cs-select:disabled, .cs-textarea:disabled {
  background: var(--cs-bg-muted);
  color: var(--cs-text-tertiary);
  cursor: not-allowed;
}
.cs-field-help  { font-size: var(--cs-text-sm); color: var(--cs-text-tertiary); }
.cs-field-error { font-size: var(--cs-text-sm); color: var(--cs-danger-700); display: flex; align-items: center; gap: var(--cs-space-1); }
.cs-input.cs-error, .cs-select.cs-error, .cs-textarea.cs-error { border-color: var(--cs-danger-600); }
.cs-input.cs-error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }

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


/* =============================================================================
   7. Cards
   ============================================================================= */
.cs-card {
  background: var(--cs-bg-surface);
  border: 1px solid var(--cs-border-subtle);
  border-radius: var(--cs-radius-lg);
  box-shadow: var(--cs-shadow-sm);
  overflow: hidden;
}
.cs-card-header {
  padding: var(--cs-space-4) var(--cs-space-5);
  border-bottom: 1px solid var(--cs-border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--cs-space-3);
}
.cs-card-title { font-size: var(--cs-text-lg); font-weight: 600; margin: 0; }
.cs-card-body  { padding: var(--cs-space-5); }
.cs-card-footer {
  padding: var(--cs-space-3) var(--cs-space-5);
  border-top: 1px solid var(--cs-border-subtle);
  background: var(--cs-bg-canvas);
  display: flex; justify-content: flex-end; gap: var(--cs-space-2);
}
.cs-card-tight .cs-card-body { padding: var(--cs-space-4); }

.cs-stat-card {
  background: var(--cs-bg-surface);
  border: 1px solid var(--cs-border-subtle);
  border-radius: var(--cs-radius-lg);
  padding: var(--cs-space-5);
  display: flex; flex-direction: column; gap: var(--cs-space-2);
  transition: box-shadow var(--cs-transition-base), transform var(--cs-transition-base);
}
.cs-stat-card:hover { box-shadow: var(--cs-shadow-md); }
.cs-stat-card-label { font-size: var(--cs-text-sm); color: var(--cs-text-secondary); font-weight: 500; }
.cs-stat-card-value {
  font-size: var(--cs-text-4xl);
  font-weight: 700;
  color: var(--cs-text-primary);
  letter-spacing: var(--cs-tracking-tight);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.cs-stat-card-trend {
  display: inline-flex; align-items: center; gap: var(--cs-space-1);
  font-size: var(--cs-text-sm);
  font-weight: 500;
  color: var(--cs-text-secondary);
}
.cs-stat-card-trend.cs-up   { color: var(--cs-success-700); }
.cs-stat-card-trend.cs-down { color: var(--cs-danger-700); }


/* =============================================================================
   8. Tables — data-dense, sticky header, soft dividers
   ============================================================================= */
.cs-table-wrap {
  background: var(--cs-bg-surface);
  border: 1px solid var(--cs-border-subtle);
  border-radius: var(--cs-radius-lg);
  box-shadow: var(--cs-shadow-sm);
  overflow: hidden;
}
.cs-table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--cs-space-3);
  padding: var(--cs-space-3) var(--cs-space-4);
  border-bottom: 1px solid var(--cs-border-subtle);
  background: var(--cs-bg-surface);
}
.cs-table-search { width: 280px; }
.cs-table-scroll { overflow-x: auto; max-height: calc(100vh - 280px); }

.cs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--cs-text-md);
}
.cs-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--cs-bg-muted);
  color: var(--cs-text-secondary);
  font-size: var(--cs-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--cs-tracking-wide);
  text-align: left;
  padding: var(--cs-space-3) var(--cs-space-4);
  border-bottom: 1px solid var(--cs-border-subtle);
  white-space: nowrap;
}
.cs-table tbody td {
  padding: var(--cs-space-3) var(--cs-space-4);
  border-bottom: 1px solid var(--cs-border-subtle);
  color: var(--cs-text-primary);
  vertical-align: middle;
}
.cs-table tbody tr:last-child td { border-bottom: 0; }
.cs-table tbody tr   { transition: background var(--cs-transition-fast); }
.cs-table tbody tr:hover                { background: var(--cs-bg-canvas); }
.cs-table tbody tr.cs-row-selected      { background: var(--cs-brand-50); }
.cs-table tbody tr.cs-row-emergency td  { box-shadow: inset 3px 0 0 var(--cs-danger-600); }

.cs-table .cs-num { text-align: right; font-variant-numeric: tabular-nums; }
.cs-cell-primary   { font-weight: 500; color: var(--cs-text-primary); }
.cs-cell-secondary { color: var(--cs-text-secondary); font-size: var(--cs-text-sm); }

.cs-empty {
  text-align: center;
  padding: var(--cs-space-12) var(--cs-space-6);
  color: var(--cs-text-secondary);
}
.cs-empty-icon { font-size: 40px; opacity: 0.5; margin-bottom: var(--cs-space-2); }


/* =============================================================================
   9. Badges & pills — soft background, bold text, dot indicator
   ============================================================================= */
.cs-badge {
  display: inline-flex; align-items: center; gap: var(--cs-space-1);
  height: 22px;
  padding: 0 var(--cs-space-2);
  font-size: var(--cs-text-xs);
  font-weight: 600;
  border-radius: var(--cs-radius-sm);
  white-space: nowrap;
  background: var(--cs-bg-muted);
  color: var(--cs-text-secondary);
}
.cs-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.cs-badge-success { background: var(--cs-success-50); color: var(--cs-success-700); }
.cs-badge-warning { background: var(--cs-warning-50); color: var(--cs-warning-700); }
.cs-badge-danger  { background: var(--cs-danger-50);  color: var(--cs-danger-700); }
.cs-badge-info    { background: var(--cs-info-50);    color: var(--cs-info-700); }
.cs-badge-brand   { background: var(--cs-brand-50);   color: var(--cs-brand-700); }
.cs-badge-neutral { background: var(--cs-slate-100);  color: var(--cs-slate-700); }
.cs-badge-solid-danger { background: var(--cs-danger-600); color: white; }
.cs-badge-solid-danger::before { background: white; }
.cs-badge-flat::before { display: none; }


/* =============================================================================
   10. Modals
   ============================================================================= */
.cs-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.40);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: var(--cs-z-overlay);
  display: flex; align-items: center; justify-content: center;
  padding: var(--cs-space-4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--cs-transition-base);
}
.cs-modal-backdrop.cs-open { opacity: 1; pointer-events: auto; }
.cs-modal {
  background: var(--cs-bg-surface);
  border-radius: var(--cs-radius-lg);
  box-shadow: var(--cs-shadow-xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
  transform: translateY(8px) scale(0.98);
  transition: transform var(--cs-transition-base);
}
.cs-modal-backdrop.cs-open .cs-modal { transform: translateY(0) scale(1); }
.cs-modal-lg { max-width: 800px; }
.cs-modal-xl { max-width: 1080px; }

.cs-modal-header {
  padding: var(--cs-space-4) var(--cs-space-5);
  border-bottom: 1px solid var(--cs-border-subtle);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--cs-space-3);
}
.cs-modal-title    { font-size: var(--cs-text-lg); font-weight: 600; margin: 0; }
.cs-modal-subtitle { font-size: var(--cs-text-sm); color: var(--cs-text-secondary); margin-top: var(--cs-space-1); }
.cs-modal-close {
  width: 32px; height: 32px;
  border: 0; background: transparent;
  border-radius: var(--cs-radius-sm);
  color: var(--cs-text-tertiary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; line-height: 1;
}
.cs-modal-close:hover { background: var(--cs-bg-muted); color: var(--cs-text-primary); }
.cs-modal-body { padding: var(--cs-space-5); overflow-y: auto; flex: 1; }
.cs-modal-footer {
  padding: var(--cs-space-3) var(--cs-space-5);
  border-top: 1px solid var(--cs-border-subtle);
  display: flex; justify-content: flex-end; gap: var(--cs-space-2);
  background: var(--cs-bg-canvas);
  border-bottom-left-radius: var(--cs-radius-lg);
  border-bottom-right-radius: var(--cs-radius-lg);
}


/* =============================================================================
   11. User menu + avatar + dropdown
   ============================================================================= */
.cs-user-menu {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--cs-space-2);
  padding: var(--cs-space-1) var(--cs-space-2);
  border-radius: var(--cs-radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--cs-transition-fast), border-color var(--cs-transition-fast);
}
.cs-user-menu:hover { background: var(--cs-bg-muted); }
.cs-user-menu[aria-expanded="true"] {
  background: var(--cs-bg-muted);
  border-color: var(--cs-border-subtle);
}

.cs-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--cs-brand-100);
  color: var(--cs-brand-700);
  font-weight: 600;
  font-size: var(--cs-text-sm);
  flex-shrink: 0;
  text-transform: uppercase;
}
.cs-avatar-sm { width: 22px; height: 22px; font-size: var(--cs-text-xs); }
.cs-avatar-lg { width: 36px; height: 36px; font-size: var(--cs-text-md); }
.cs-avatar-xl { width: 48px; height: 48px; font-size: var(--cs-text-lg); }

.cs-user-meta { line-height: 1.2; text-align: left; min-width: 0; }
.cs-user-name { font-size: var(--cs-text-sm); font-weight: 600; color: var(--cs-text-primary); white-space: nowrap; }
.cs-user-role { font-size: 11px; color: var(--cs-text-tertiary); white-space: nowrap; }

.cs-dropdown {
  position: absolute;
  top: calc(100% + 4px); right: 0;
  background: var(--cs-bg-surface);
  border: 1px solid var(--cs-border-subtle);
  border-radius: var(--cs-radius-md);
  box-shadow: var(--cs-shadow-lg);
  min-width: 240px;
  padding: var(--cs-space-1);
  z-index: var(--cs-z-dropdown);
  display: none;
}
.cs-dropdown.cs-open { display: block; }
.cs-dropdown-header {
  padding: var(--cs-space-3);
  border-bottom: 1px solid var(--cs-border-subtle);
  margin-bottom: var(--cs-space-1);
}
.cs-dropdown-item {
  display: flex; align-items: center; gap: var(--cs-space-2);
  padding: var(--cs-space-2) var(--cs-space-3);
  border-radius: var(--cs-radius-sm);
  color: var(--cs-text-primary);
  font-size: var(--cs-text-md);
  cursor: pointer;
  text-decoration: none;
}
.cs-dropdown-item:hover  { background: var(--cs-bg-muted); }
.cs-dropdown-item.cs-danger        { color: var(--cs-danger-700); }
.cs-dropdown-item.cs-danger:hover  { background: var(--cs-danger-50); }
.cs-dropdown-sep { height: 1px; background: var(--cs-border-subtle); margin: var(--cs-space-1) 0; }


/* =============================================================================
   12. Network status pill — matches v3.1.2 SW behavior, restyled
   ============================================================================= */
.cs-net-pill {
  display: inline-flex; align-items: center; gap: var(--cs-space-2);
  height: 24px;
  padding: 0 10px;
  border-radius: var(--cs-radius-full);
  font-size: var(--cs-text-xs);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--cs-transition-fast);
  background: var(--cs-bg-muted);
  color: var(--cs-text-secondary);
}
.cs-net-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.cs-net-pill-online  { background: var(--cs-success-50); color: var(--cs-success-700); border-color: var(--cs-success-100); }
.cs-net-pill-offline { background: var(--cs-warning-50); color: var(--cs-warning-700); border-color: var(--cs-warning-100); }
.cs-net-pill-syncing { background: var(--cs-info-50);    color: var(--cs-info-700);    border-color: var(--cs-info-100); }
.cs-net-pill-offline::before { animation: cs-net-pulse 1.5s ease-in-out infinite; }
@keyframes cs-net-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.cs-net-pill-count {
  background: rgba(0, 0, 0, 0.08);
  padding: 0 6px;
  border-radius: var(--cs-radius-full);
  font-size: 10px;
  line-height: 14px;
}


/* =============================================================================
   13. Utilities
   ============================================================================= */
.cs-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;
}
.cs-grid           { display: grid; }
.cs-grid-stats     { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--cs-space-4); }
.cs-grid-2         { grid-template-columns: repeat(2, 1fr); gap: var(--cs-space-4); }
.cs-flex           { display: flex; }
.cs-flex-1         { flex: 1; }
.cs-items-center   { align-items: center; }
.cs-justify-between{ justify-content: space-between; }
.cs-gap-2          { gap: var(--cs-space-2); }
.cs-gap-3          { gap: var(--cs-space-3); }
.cs-gap-4          { gap: var(--cs-space-4); }
.cs-mt-1           { margin-top: var(--cs-space-1); }
.cs-mt-2           { margin-top: var(--cs-space-2); }
.cs-mt-3           { margin-top: var(--cs-space-3); }
.cs-mt-4           { margin-top: var(--cs-space-4); }
.cs-mt-6           { margin-top: var(--cs-space-6); }
.cs-mb-4           { margin-bottom: var(--cs-space-4); }
.cs-mb-6           { margin-bottom: var(--cs-space-6); }


/* =============================================================================
   14. Responsive
   ============================================================================= */
@media (max-width: 1024px) {
  .cs-main { padding: var(--cs-space-5); }
}
@media (max-width: 768px) {
  .cs-app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .cs-sidebar {
    position: fixed; inset: var(--cs-topbar-h) 0 0 0;
    z-index: var(--cs-z-overlay);
    transform: translateX(-100%);
    transition: transform var(--cs-transition-base);
  }
  .cs-sidebar.cs-open { transform: translateX(0); }
  .cs-main         { padding: var(--cs-space-4); }
  .cs-page-header  { flex-direction: column; align-items: flex-start; }
  .cs-table-search { width: 100%; }
  .cs-user-meta    { display: none; }
}
