/* Freight AI — clean enterprise light */
@import url('https://fonts.googleapis.com/css?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Surfaces */
  --bg-page: #FAFBFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F6F7F9;
  --bg-soft: #EFF1F5;
  --bg-inverse: #0F1E37;

  /* Brand — primary actions */
  --brand-50:  #EEF4FF;
  --brand-100: #DCE7FF;
  --brand-200: #B9CEFF;
  --brand-300: #8FAFFF;
  --brand-500: #2D6BFF;
  --brand-600: #1659CB;   /* primary */
  --brand-700: #0F47A6;
  --brand-800: #0B3680;

  /* Agent — violet (AI-authored content) */
  --agent-50:  #F4F1FF;
  --agent-100: #EAE3FF;
  --agent-200: #D6CAFF;
  --agent-400: #9C84FF;
  --agent-500: #7C5CFF;   /* canonical */
  --agent-600: #6244E5;
  --agent-700: #4D34B8;

  /* Semantic */
  --success-50: #ECFDF3;
  --success-100:#D1FADF;
  --success-500:#12B76A;
  --success-700:#027A48;

  --warning-50:#FFFAEB;
  --warning-100:#FEF0C7;
  --warning-500:#F79009;
  --warning-700:#B54708;

  --danger-50:#FEF3F2;
  --danger-100:#FEE4E2;
  --danger-500:#F04438;
  --danger-700:#B42318;

  /* Neutrals */
  --n-0:#FFFFFF;
  --n-25:#FCFCFD;
  --n-50:#F9FAFB;
  --n-75:#F2F4F7;
  --n-100:#EAECF0;
  --n-150:#E1E4EA;
  --n-200:#D0D5DD;
  --n-300:#98A2B3;
  --n-400:#667085;
  --n-500:#475467;
  --n-600:#344054;
  --n-700:#1D2939;
  --n-900:#101828;

  /* Text */
  --fg-1: #101828;
  --fg-2: #344054;
  --fg-3: #667085;
  --fg-4: #98A2B3;

  /* Shadows — subtle */
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.05);
  --shadow-sm: 0 1px 3px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
  --shadow-md: 0 4px 8px -2px rgba(16,24,40,0.08), 0 2px 4px -2px rgba(16,24,40,0.04);
  --shadow-lg: 0 12px 24px -6px rgba(16,24,40,0.10), 0 4px 8px -4px rgba(16,24,40,0.06);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Type */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
.mono { font-family: var(--mono); font-feature-settings: 'tnum'; }
.tnum { font-variant-numeric: tabular-nums; }

/* Scrollbar — discreet */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--n-150); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--n-200); border: 2px solid transparent; background-clip: content-box; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 64px 1fr 340px;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  width: 100vw;
  min-width: 1280px;
  background: var(--bg-page);
}
.app.activity-collapsed { grid-template-columns: 64px 1fr 48px; }
.app.no-activity { grid-template-columns: 64px 1fr; }

.topbar {
  grid-column: 1 / -1;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--n-100);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 10;
}
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--n-100);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 12px 0;
}
.main { overflow: auto; min-width: 0; background: var(--bg-page); }
.activity-panel { background: var(--bg-surface); border-left: 1px solid var(--n-100); overflow: hidden; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #1659CB 0%, #2D6BFF 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px; letter-spacing: -0.02em;
}
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.brand-name .accent { color: var(--agent-500); font-weight: 600; }
.global-search {
  background: var(--n-50);
  border: 1px solid var(--n-100);
  border-radius: 8px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; width: 360px;
  font-size: 12.5px; color: var(--fg-3);
  transition: border-color .12s, background .12s;
}
.global-search:hover { border-color: var(--n-200); }
.global-search input { background: transparent; border: 0; outline: 0; flex: 1; color: var(--fg-1); font-size: 12.5px; min-width: 0; }
.kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border: 1px solid var(--n-150); border-radius: 4px; color: var(--fg-3); background: white; }

.role-switch {
  display: flex; align-items: center; background: var(--n-75); border: 1px solid var(--n-100); border-radius: 8px; padding: 2px;
}
.role-switch button {
  border: 0; background: transparent; padding: 5px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--fg-3); display: inline-flex; align-items: center; gap: 6px;
  transition: all .14s;
}
.role-switch button.active { background: var(--bg-surface); color: var(--fg-1); box-shadow: var(--shadow-xs); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; color: var(--fg-3);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--n-50); color: var(--fg-1); }
.bell-dot { position: relative; }
.bell-dot::after {
  content: ''; position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; background: var(--danger-500); border-radius: 50%; border: 2px solid var(--bg-surface);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 11px; color: white;
  background: linear-gradient(135deg, #7C5CFF 0%, #4DA4FF 100%);
}

/* ---------- Sidebar ---------- */
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; margin: 2px 8px; border-radius: 8px;
  color: var(--fg-3); border: 0; background: transparent;
  font-size: 10.5px; font-weight: 500; line-height: 1.1;
  position: relative;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--n-50); color: var(--fg-2); }
.nav-item.active { background: var(--brand-50); color: var(--brand-700); }
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; background: var(--brand-600); border-radius: 0 4px 4px 0;
}
.nav-item .badge {
  position: absolute; top: 6px; right: 8px;
  min-width: 16px; height: 14px; padding: 0 4px; font-size: 9.5px; font-weight: 700;
  background: var(--brand-600); color: white; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-item .badge.agent { background: var(--agent-500); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--n-100);
  border-radius: 12px;
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: 16px; }
.card-pad-lg { padding: 20px; }
.card-head { display:flex; align-items:center; justify-content:space-between; padding: 14px 16px; border-bottom: 1px solid var(--n-100); }
.card-title { font-size: 13.5px; font-weight: 600; color: var(--fg-1); }
.card-sub { font-size: 11.5px; color: var(--fg-3); }
.hairline { height: 1px; background: var(--n-100); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid transparent; font-size: 12.5px; font-weight: 600;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn-lg { height: 38px; padding: 0 16px; font-size: 13px; }
.btn-primary { background: var(--brand-600); color: white; border-color: var(--brand-600); box-shadow: 0 1px 0 rgba(16,24,40,0.05); }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-secondary { background: var(--bg-surface); color: var(--fg-2); border-color: var(--n-150); }
.btn-secondary:hover { background: var(--n-50); border-color: var(--n-200); color: var(--fg-1); }
.btn-ghost { background: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--n-50); color: var(--fg-1); }
.btn-agent { background: var(--agent-500); color: white; border-color: var(--agent-500); }
.btn-agent:hover { background: var(--agent-600); border-color: var(--agent-600); }
.btn-agent-ghost { background: var(--agent-50); color: var(--agent-700); border-color: var(--agent-100); }
.btn-agent-ghost:hover { background: var(--agent-100); }
.btn-danger { background: var(--bg-surface); color: var(--danger-700); border-color: var(--danger-100); }
.btn-danger:hover { background: var(--danger-50); }

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.b-neutral { background: var(--n-75); color: var(--fg-2); border-color: var(--n-100); }
.b-blue { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.b-agent { background: var(--agent-50); color: var(--agent-700); border-color: var(--agent-100); }
.b-success { background: var(--success-50); color: var(--success-700); border-color: var(--success-100); }
.b-warning { background: var(--warning-50); color: var(--warning-700); border-color: var(--warning-100); }
.b-danger { background: var(--danger-50); color: var(--danger-700); border-color: var(--danger-100); }

.agent-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px 2px 5px; border-radius: 999px;
  background: var(--agent-50); color: var(--agent-700);
  font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--agent-100);
}
.agent-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--agent-500); display: inline-block; }
.agent-dot.pulse { animation: pulse 1.8s ease-in-out infinite; box-shadow: 0 0 0 0 rgba(124,92,255,.45); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,92,255,.45); }
  50% { box-shadow: 0 0 0 5px rgba(124,92,255,0); }
}

/* ---------- KPI tiles ---------- */
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--n-100);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.kpi-label { font-size: 11.5px; font-weight: 500; color: var(--fg-3); letter-spacing: 0.01em; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg-1); line-height: 1; }
.kpi-trend { font-size: 11.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.kpi-trend.up { color: var(--success-700); }
.kpi-trend.down { color: var(--danger-700); }
.kpi-trend.flat { color: var(--fg-3); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.table th {
  text-align: left; padding: 8px 12px;
  font-size: 11px; font-weight: 600; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--n-50);
  border-bottom: 1px solid var(--n-100);
  position: sticky; top: 0; z-index: 1;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--n-75);
  color: var(--fg-2);
  vertical-align: middle;
}
.table tr.selectable { cursor: pointer; }
.table tr.selectable:hover td { background: var(--n-25); }
.table tr.selected td { background: var(--brand-50); }
.table tr.recommended td { background: var(--agent-50); }

/* ---------- Inputs ---------- */
.input {
  height: 32px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--n-150); background: var(--bg-surface);
  font-size: 12.5px; color: var(--fg-1);
  transition: border-color .12s, box-shadow .12s;
  outline: 0;
}
.input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.input-search { padding-left: 30px; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--n-100); }
.tab {
  border: 0; background: transparent; padding: 10px 14px;
  font-size: 12.5px; font-weight: 600; color: var(--fg-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.tab.active { color: var(--fg-1); border-bottom-color: var(--brand-600); }
.tab:hover:not(.active) { color: var(--fg-2); }

/* Filter chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--bg-surface); border: 1px solid var(--n-150);
  font-size: 12px; font-weight: 500; color: var(--fg-2);
  transition: all .12s;
}
.chip:hover { background: var(--n-50); border-color: var(--n-200); }
.chip.active { background: var(--brand-600); color: white; border-color: var(--brand-600); }
.chip-count { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--n-100); color: var(--fg-2); font-size: 10px; font-weight: 700; }
.chip.active .chip-count { background: rgba(255,255,255,0.25); color: white; }

/* Sparkline area */
.sparkline { display: block; }

/* Streaming dots */
.dots { display: inline-flex; gap: 3px; align-items: center; }
.dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--agent-500); animation: bounce 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.caret { display: inline-block; width: 2px; height: 1em; background: currentColor; vertical-align: middle; margin-left: 1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Stage tracker */
.stage-track { display: flex; align-items: center; gap: 0; width: 100%; }
.stage-step { flex: 1; display: flex; align-items: center; gap: 8px; position: relative; min-width: 0; }
.stage-step + .stage-step::before {
  content: ''; height: 2px; background: var(--n-100); flex: 0 0 14px;
}
.stage-step.done + .stage-step::before { background: var(--success-500); }
.stage-step.current + .stage-step::before { background: linear-gradient(to right, var(--brand-600), var(--n-100)); }
.stage-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-surface); border: 2px solid var(--n-200); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stage-step.done .stage-dot { background: var(--success-500); border-color: var(--success-500); color: white; }
.stage-step.current .stage-dot { background: var(--brand-600); border-color: var(--brand-600); color: white; box-shadow: 0 0 0 4px var(--brand-50); }
.stage-label { font-size: 11px; font-weight: 600; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-step.done .stage-label { color: var(--success-700); }
.stage-step.current .stage-label { color: var(--brand-700); }
.stage-step:not(.done):not(.current) .stage-label { color: var(--fg-4); }

/* Flag — country emoji glyph */
.flag {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1;
  width: 18px; height: 13px;
  letter-spacing: 0;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.04));
}
.flag-lg { font-size: 18px; width: 24px; height: 18px; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--n-75) 0%, var(--n-100) 50%, var(--n-75) 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Tooltip-ish */
.tip { position: relative; }
.tip-bubble {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--n-900); color: white; padding: 6px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .12s;
  z-index: 100;
}
.tip:hover .tip-bubble { opacity: 1; }

/* Why this expandable */
.why {
  background: var(--agent-50);
  border: 1px solid var(--agent-100);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--agent-700);
  line-height: 1.55;
}

/* Code-like quote */
.email-quote {
  background: var(--n-50);
  border-left: 3px solid var(--n-200);
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--fg-2);
  line-height: 1.6;
  border-radius: 0 6px 6px 0;
  white-space: pre-wrap;
}

/* For attention card */
.attn-card {
  background: var(--bg-surface);
  border: 1px solid var(--n-100);
  border-left: 3px solid var(--agent-500);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 280px;
}
.attn-card.priority-warning { border-left-color: var(--warning-500); }
.attn-card.priority-danger { border-left-color: var(--danger-500); }

/* Heat map */
.heat-cell {
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
  position: relative;
  user-select: none;
}
.heat-cell:hover { transform: scale(1.04); box-shadow: 0 2px 8px rgba(16,24,40,.15); z-index: 2; }
.heat-cell.selected { outline: 2px solid var(--brand-600); outline-offset: 1px; z-index: 3; }
.heat-cell.empty {
  background: repeating-linear-gradient(45deg, var(--n-75), var(--n-75) 4px, var(--n-100) 4px, var(--n-100) 8px);
  color: var(--fg-4);
}

/* Module card on dashboard */
.module-card {
  background: var(--bg-surface);
  border: 1px solid var(--n-100);
  border-radius: 12px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.module-card:hover { border-color: var(--n-200); box-shadow: var(--shadow-sm); }

/* Mini status pills cluster */
.mini-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--n-75); }
.mini-bar div { height: 100%; }

/* Drawer */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,0.30);
  z-index: 50; display: flex; justify-content: flex-end;
  animation: fade .14s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  width: 560px; max-width: 95vw; height: 100%; background: var(--bg-surface);
  display: flex; flex-direction: column;
  animation: slide-in .2s ease-out;
}
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,0.35);
  z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .14s;
}
.modal {
  width: 560px; max-width: 100%; background: var(--bg-surface); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}

/* Activity panel */
.activity-item {
  display: flex; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--n-75);
  cursor: pointer;
  transition: background .12s;
}
.activity-item:hover { background: var(--n-25); }
.activity-icon {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px;
  background: var(--agent-50); color: var(--agent-700);
  display: flex; align-items: center; justify-content: center;
}
.activity-icon.b { background: var(--brand-50); color: var(--brand-700); }
.activity-icon.s { background: var(--success-50); color: var(--success-700); }
.activity-icon.w { background: var(--warning-50); color: var(--warning-700); }

/* Misc */
.muted { color: var(--fg-3); }
.subtle { color: var(--fg-4); }
.strong { color: var(--fg-1); font-weight: 600; }

.divider-v { width: 1px; height: 20px; background: var(--n-100); }
.divider-h { height: 1px; background: var(--n-100); margin: 12px 0; }

/* Pretty wrapping */
h1, h2, h3, h4, p { text-wrap: pretty; margin: 0; }

/* Anchor links inside detail */
a { color: var(--brand-600); }

/* Focus ring globally */
button:focus-visible, .input:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--brand-500); outline-offset: 2px;
}

/* Slider */
input[type="range"].markup {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--agent-500) 0%, var(--agent-500) var(--p,50%), var(--n-100) var(--p,50%), var(--n-100) 100%);
  outline: 0;
}
input[type="range"].markup::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: white; border: 2px solid var(--agent-500); box-shadow: var(--shadow-sm);
  cursor: pointer;
}
input[type="range"].markup::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: white; border: 2px solid var(--agent-500); cursor: pointer;
}
