/*
 * CarriersVault design system
 *
 * Tokens first, then base, layout (app shell), and components.
 * Pages compose these classes; avoid inline styles in page templates.
 */

/* ---------- Tokens ---------- */
:root {
  /* Brand (from the CarriersVault logo) */
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-500: #4f5ef7;
  --brand-600: #3b4ae8;
  --brand-700: #2f3bc4;
  --brand-gradient: linear-gradient(135deg, #5b8cff 0%, #3b4ae8 100%);

  /* Neutrals */
  --gray-0: #ffffff;
  --gray-25: #fcfcfd;
  --gray-50: #f8f9fb;
  --gray-100: #f1f3f6;
  --gray-150: #e9ecf1;
  --gray-200: #e2e6ec;
  --gray-300: #cfd5de;
  --gray-400: #9aa3b2;
  --gray-500: #6b7485;
  --gray-600: #4d5566;
  --gray-700: #363d4a;
  --gray-800: #20252f;
  --gray-900: #11141a;

  /* Status */
  --green-50: #ecfdf3;
  --green-200: #a6f4c5;
  --green-600: #079455;
  --green-700: #067647;
  --amber-50: #fffaeb;
  --amber-200: #fedf89;
  --amber-600: #dc6803;
  --amber-700: #b54708;
  --red-50: #fef3f2;
  --red-200: #fecdca;
  --red-600: #d92d20;
  --red-700: #b42318;
  --blue-50: #eff8ff;
  --blue-700: #175cd3;

  /* Semantic */
  --bg: var(--gray-50);
  --surface: var(--gray-0);
  --surface-muted: var(--gray-50);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --text-subtle: var(--gray-400);
  --accent: var(--brand-600);
  --accent-hover: var(--brand-700);
  --accent-soft: var(--brand-50);
  --focus-ring: 0 0 0 4px rgba(79, 94, 247, 0.18);

  /* Type */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Shape & depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px -6px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.22);

  --sidebar-width: 260px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.015em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-xs { width: 14px; height: 14px; }

.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  /* Paint the sidebar column (and its border) the full page height, not just one screen */
  background: linear-gradient(to right,
    var(--surface) 0, var(--surface) calc(var(--sidebar-width) - 1px),
    var(--border) calc(var(--sidebar-width) - 1px), var(--border) var(--sidebar-width),
    var(--bg) var(--sidebar-width));
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 18px;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.sidebar-brand img { width: 30px; height: 30px; }
.sidebar-brand:hover { color: var(--text); }

.nav-section-label {
  padding: 14px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.nav-links { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-link .icon { color: var(--gray-400); transition: color 0.15s var(--ease); }
.nav-link:hover { background: var(--gray-100); color: var(--text); }
.nav-link:hover .icon { color: var(--gray-600); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active .icon { color: var(--accent); }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.source-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  font-size: 12px;
  color: var(--text-muted);
}
.source-card strong { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; margin-bottom: 2px; }

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-600);
  box-shadow: 0 0 0 3px rgba(7, 148, 85, 0.15);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(7, 148, 85, 0.06); } }

/* User menu (bottom of sidebar); opens upward */
.nav-dropdown { position: relative; }

.user-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.user-button:hover, .nav-dropdown.open .user-button { background: var(--gray-100); }
.user-button .icon { margin-left: auto; color: var(--text-subtle); }

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-meta { min-width: 0; line-height: 1.3; }
.user-meta .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .email { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-dropdown-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  display: none;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.nav-dropdown:hover .nav-dropdown-content,
.nav-dropdown.open .nav-dropdown-content,
.nav-dropdown-content.show { display: block; animation: pop 0.14s var(--ease); }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  color: var(--gray-700);
  cursor: pointer;
  text-align: left;
}
.menu-item .icon { color: var(--gray-400); }
.menu-item:hover { background: var(--gray-100); color: var(--text); }
.menu-item.danger { color: var(--red-600); }
.menu-item.danger .icon { color: var(--red-600); }
.menu-divider { height: 1px; margin: 6px 4px; background: var(--border); }

@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(0.98); } }

/* Mobile top bar (sidebar becomes a drawer) */
.mobile-bar { display: none; }

.main { min-width: 0; }
.page { max-width: 1240px; margin: 0 auto; padding: 32px 40px 64px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
.page-subtitle { margin-top: 4px; color: var(--text-muted); font-size: 14.5px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease), visibility 0.22s;
    visibility: hidden;
  }
  /* Shadow only while open, so the closed drawer leaves no strip on the left edge */
  .app.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
  }
  .mobile-bar img { width: 26px; height: 26px; }
  .page { padding: 24px 18px 48px; }
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(17, 20, 26, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 15px; border-radius: var(--radius); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }

.btn-secondary {
  color: var(--gray-700);
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); color: var(--text); }

.btn-ghost { color: var(--gray-600); background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--text); }

.btn-danger-outline {
  color: var(--red-700);
  background: var(--surface);
  border-color: var(--red-200);
}
.btn-danger-outline:hover:not(:disabled) { background: var(--red-50); }

.btn-success { color: #fff; background: var(--green-600); }
.btn-success:hover:not(:disabled) { background: var(--green-700); color: #fff; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--gray-500);
  cursor: pointer;
}
.icon-button:hover { background: var(--gray-100); color: var(--text); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 600; }
.card-description { margin-top: 2px; color: var(--text-muted); font-size: 13px; }
.card-body { padding: 22px; }
.card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- Forms ---------- */
.form-section + .form-section { margin-top: 26px; padding-top: 26px; border-top: 1px dashed var(--border); }
.form-section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 14px; }
.step {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
}

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.hint { font-size: 12.5px; color: var(--text-muted); }

.input, .select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover { border-color: var(--gray-400); }
.input:focus, .select:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--focus-ring); }
.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.input-group { position: relative; }
.input-group .prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-weight: 600;
  font-size: 13px;
  pointer-events: none;
}
.input-group .input { padding-left: 40px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
}
.chip:hover { border-color: var(--brand-300); color: var(--accent); background: var(--accent-soft); }

.range-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.range-preview strong { color: var(--text); font-weight: 600; }

/* Selectable option cards (radio) */
.option-list { display: grid; gap: 10px; }
.option-card {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}
.option-card:hover { border-color: var(--border-strong); }
.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-card:has(input:checked) { border-color: var(--brand-500); background: linear-gradient(0deg, rgba(79, 94, 247, 0.035), rgba(79, 94, 247, 0.035)), var(--surface); box-shadow: 0 0 0 3px rgba(79, 94, 247, 0.12); }
.option-card:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.option-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-600);
  flex-shrink: 0;
}
.option-card:has(input:checked) .option-icon { background: var(--brand-gradient); color: #fff; }
.option-body { flex: 1; min-width: 0; }
.option-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.option-description { margin-top: 2px; color: var(--text-muted); font-size: 13px; }
.option-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.radio-dot {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  flex-shrink: 0;
  transition: border 0.15s var(--ease);
}
.option-card:has(input:checked) .radio-dot { border: 5px solid var(--brand-600); }

.disclosure { margin-top: 4px; }
.disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  list-style: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary .icon { transition: transform 0.15s var(--ease); }
.disclosure[open] > summary .icon { transform: rotate(90deg); }
.disclosure > summary:hover { color: var(--text); }
.disclosure-body { display: grid; gap: 10px; padding-top: 8px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-brand { background: var(--accent-soft); color: var(--accent); border-color: var(--brand-100); }
.badge-green { background: var(--green-50); color: var(--green-700); border-color: var(--green-200); }
.badge-amber { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-200); }
.badge-red { background: var(--red-50); color: var(--red-700); border-color: var(--red-200); }
.badge-outline { background: var(--surface); color: var(--gray-600); border-color: var(--border); }

/* ---------- Alerts / banners ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--gray-700);
}
.alert .icon { margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--text); }
.alert-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.alert-brand { border-color: var(--brand-100); background: linear-gradient(90deg, var(--brand-50), var(--surface) 70%); }
.alert-brand > .icon { color: var(--accent); }
@media (max-width: 640px) {
  .alert { flex-wrap: wrap; }
  .alert-body { flex-basis: calc(100% - 32px); }
  .alert-actions { width: 100%; margin-left: 30px; }
}
.alert-warning { border-color: var(--amber-200); background: var(--amber-50); }
.alert-warning > .icon, .alert-warning .alert-title { color: var(--amber-700); }
.alert-danger { border-color: var(--red-200); background: var(--red-50); }
.alert-danger > .icon { color: var(--red-600); }
.alert-info { border-color: var(--border); background: var(--surface-muted); }
.alert-info > .icon { color: var(--gray-500); }
.stack { display: grid; gap: 12px; }

/* ---------- Stats & progress ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { margin-top: 2px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value.green { color: var(--green-700); }

.progress { height: 8px; border-radius: 999px; background: var(--gray-100); overflow: hidden; }
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--brand-gradient);
  transition: width 0.4s var(--ease);
}
.progress.done .progress-bar { background: var(--green-600); }
.progress.running .progress-bar {
  background-image: linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%), var(--brand-gradient);
  background-size: 16px 16px, auto;
  animation: stripes 0.8s linear infinite;
}
@keyframes stripes { to { background-position: 16px 0, 0 0; } }
.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Terminal-style log */
.console {
  height: 300px;
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0d1017;
  border: 1px solid #1c212c;
  color: #c9d1e0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: #2a3140 transparent;
}
.console { overflow-x: auto; }
.console .log-line { white-space: pre; }
.console a { color: #8fb0ff; text-decoration: underline; }

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--brand-100);
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty h3 { font-size: 15px; font-weight: 600; }
.empty p { margin-top: 4px; max-width: 320px; color: var(--text-muted); font-size: 13.5px; }

/* ---------- Status badge (job) ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--gray-100);
  color: var(--gray-600);
}
.status-badge.running { background: var(--accent-soft); color: var(--accent); }
.status-badge.completed { background: var(--green-50); color: var(--green-700); }
.status-badge.cancelled { background: var(--amber-50); color: var(--amber-700); }
.status-badge.error { background: var(--red-50); color: var(--red-700); }

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Drawer ---------- */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(17, 20, 26, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  display: flex;
  flex-direction: column;
  width: min(520px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s var(--ease);
}
.drawer.open { transform: none; }
.drawer.open + .drawer-scrim, .drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-muted); }

.prose h3 { font-size: 14px; font-weight: 600; margin: 22px 0 8px; }
.prose h3:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--gray-600); font-size: 13.5px; }
.prose ul, .prose ol { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.prose strong { color: var(--text); font-weight: 600; }
.prose code { font-family: var(--font-mono); font-size: 12px; padding: 1px 5px; border-radius: 4px; background: var(--gray-100); color: var(--gray-700); }

.definition-list { display: grid; gap: 8px; margin-top: 6px; }
.definition-list div { display: grid; grid-template-columns: 190px 1fr; gap: 10px; font-size: 13px; color: var(--gray-600); }
@media (max-width: 520px) { .definition-list div { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 20, 26, 0.5);
  backdrop-filter: blur(3px);
}
.modal-content {
  width: 100%;
  max-width: 440px;
  padding: 26px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s var(--ease);
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-description { margin-top: 4px; color: var(--text-muted); }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(400px, calc(100vw - 40px));
}
.toast {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  color: var(--gray-700);
  animation: pop 0.18s var(--ease);
  white-space: pre-line;
}
.toast .icon { margin-top: 1px; }
.toast-error .icon { color: var(--red-600); }
.toast-success .icon { color: var(--green-600); }
.toast-info .icon { color: var(--accent); }
.toast strong { display: block; color: var(--text); }

/* ---------- Layout helpers ---------- */
.grid-2 { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.sticky-top { position: sticky; top: 24px; }
@media (max-width: 1100px) { .sticky-top { position: static; } }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* Tooltip */
.tooltip-trigger { position: relative; display: inline-flex; color: var(--text-subtle); cursor: help; vertical-align: middle; }
.tooltip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s var(--ease);
  z-index: 10;
}
.tooltip-content a { color: #a5b4fc; text-decoration: underline; }
.tooltip-trigger:hover .tooltip-content, .tooltip-trigger:focus-within .tooltip-content { opacity: 1; visibility: visible; }

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

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  position: sticky;
  top: 0;
  padding: 10px 16px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--gray-700); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.12s var(--ease); }
.table tbody tr:hover { background: var(--gray-25); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-strong { color: var(--text); font-weight: 600; }
.table .cell-sub { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.table .actions { text-align: right; white-space: nowrap; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--radius-lg); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--radius-lg); }

/* ---------- Toolbar, tabs, segmented filters ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 22px; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; min-width: 220px; flex: 1; max-width: 360px; }
.toolbar .search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }
.toolbar .search .input { padding-left: 36px; height: 36px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-sm); background: var(--gray-100); }
.seg button { height: 30px; padding: 0 12px; border: none; border-radius: 5px; background: none; font: inherit; font-size: 13px; font-weight: 500; color: var(--gray-600); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi { padding: 18px 20px; }
.kpi .stat-label { display: flex; align-items: center; gap: 6px; }
.kpi .stat-value { font-size: 26px; margin-top: 6px; }
.kpi .kpi-foot { margin-top: 6px; font-size: 12.5px; color: var(--text-muted); }
.meter { height: 6px; margin-top: 12px; border-radius: 999px; background: var(--gray-100); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter.warn > span { background: var(--amber-600); }
.meter.danger > span { background: var(--red-600); }

/* ---------- Description list ---------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; color: var(--text); font-weight: 500; }

/* ---------- Row action menu ---------- */
.row-menu { position: relative; display: inline-block; }
.row-menu-content {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  display: none;
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.row-menu.open .row-menu-content { display: block; animation: pop 0.14s var(--ease); }

/* ---------- Modal (sizes + scrolling body) ---------- */
.modal-content.modal-lg { max-width: 640px; }
.modal-content.modal-xl { max-width: 880px; }
.modal-content.modal-scroll { display: flex; flex-direction: column; max-height: calc(100vh - 32px); padding: 0; }
.modal-scroll .modal-head { padding: 22px 26px 14px; border-bottom: 1px solid var(--border); }
.modal-scroll .modal-body { padding: 20px 26px; overflow-y: auto; }
.modal-scroll .modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 26px; border-top: 1px solid var(--border); background: var(--surface-muted); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* ---------- Public (logged-out) pages ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--bg);
}
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 96px); background: var(--surface); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; font-weight: 700; font-size: 18px; color: var(--text); }
.auth-brand img { width: 34px; height: 34px; }
.auth-form { width: 100%; max-width: 400px; }
.auth-title { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
.auth-subtitle { margin-top: 6px; margin-bottom: 28px; color: var(--text-muted); }
.auth-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px;
  overflow: hidden;
  color: #fff;
  background: radial-gradient(1200px 600px at 100% 0%, rgba(91, 140, 255, 0.55), transparent 60%),
              radial-gradient(900px 500px at 0% 100%, rgba(59, 74, 232, 0.65), transparent 60%),
              #0f1530;
}
.auth-aside h2 { color: #fff; font-size: 28px; line-height: 1.2; max-width: 440px; }
.auth-aside p { margin-top: 12px; max-width: 420px; color: rgba(255, 255, 255, 0.75); }
.auth-aside .auth-points { display: grid; gap: 10px; margin-top: 28px; font-size: 14px; color: rgba(255, 255, 255, 0.85); }
.auth-aside .auth-points div { display: flex; gap: 10px; align-items: center; }
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

/* ---------- Misc ---------- */
.text-right { text-align: right; }
.w-full { width: 100%; }
.gap-2 { gap: 8px; }
.section-gap { display: grid; gap: 24px; }
.link-button { border: none; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.link-button:hover { color: var(--accent-hover); text-decoration: underline; }
.btn-danger { color: #fff; background: var(--red-600); }
.btn-danger:hover:not(:disabled) { background: var(--red-700); color: #fff; }

/* ---------- Shared additions requested by page work ---------- */
.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; }
.alert-success { border-color: var(--green-200); background: var(--green-50); }
.alert-success > .icon, .alert-success .alert-title { color: var(--green-700); }
.field-error { font-size: 12.5px; color: var(--red-600); }
.input.is-invalid, .select.is-invalid { border-color: var(--red-600); box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.12); }
.menu-item.is-disabled, .menu-item:disabled { color: var(--text-subtle); cursor: not-allowed; background: none; }
.menu-item .menu-hint { display: block; font-size: 12px; color: var(--text-subtle); }
.kpi-of { font-size: 15px; font-weight: 500; color: var(--text-subtle); }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
/* Grid children may shrink, so wide tables scroll inside their card instead of widening the page */
.section-gap > *, .grid-2 > *, .kpi-grid > * { min-width: 0; }
/* Spacing helpers last, so they win over component margins */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
