:root {
  --navy-950: #071324;
  --navy-900: #0c1e36;
  --navy-800: #152d4f;
  --blue-600: #1d4ed8;
  --blue-500: #2563eb;
  --blue-50: #eff6ff;
  --teal-600: #0d9488;
  --emerald-600: #059669;
  --emerald-50: #ecfdf5;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --rose-600: #dc2626;
  --rose-50: #fef2f2;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--slate-900);
  background: var(--slate-100);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================================================
   MODE 2: FREIGHTEK DIGITAL FMS LAYOUT
   ========================================================= */
.fms-shell {
  display: flex;
  min-height: 100vh;
}
.fms-sidebar {
  width: 256px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950) 0%, var(--navy-900) 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.fms-brand {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.fms-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.fms-brand-title { font-weight: 700; font-size: 14.5px; color: #fff; letter-spacing: 0.2px; }
.fms-brand-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.fms-nav { padding: 12px 10px; flex: 1; }
.fms-nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: #64748b;
  font-weight: 700;
  padding: 12px 12px 5px;
}
.fms-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}
.fms-nav-link:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
  text-decoration: none;
}
.fms-nav-link.active {
  background: linear-gradient(90deg, rgba(37,99,235,0.92), rgba(29,78,216,0.78));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.fms-nav-icon { width: 18px; text-align: center; font-size: 14px; opacity: 0.92; }

.fms-sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.18);
}

.fms-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.fms-topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--slate-200);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.fms-search-form {
  flex: 1;
  max-width: 440px;
  display: flex;
}
.fms-search-input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
  font-size: 13px;
}
.fms-search-input:focus {
  outline: none;
  border-color: var(--blue-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.fms-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.branch-pills {
  display: inline-flex;
  background: var(--slate-100);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--slate-200);
}
.branch-pill {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
}
.branch-pill:hover { text-decoration: none; color: var(--slate-900); }
.branch-pill.active {
  background: var(--navy-900);
  color: #fff;
}
.mode-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #f59e0b;
  background: #fffbeb;
  color: #92400e;
}
.mode-switch-btn:hover { background: #fef3c7; text-decoration: none; }

.fms-content {
  padding: 22px 26px 40px;
  max-width: 1600px;
  width: 100%;
}

/* =========================================================
   MODE 1: SSM CLASSIC LAYOUT (1:1 LEGACY PARITY)
   ========================================================= */
body.theme-ssm {
  background: #eef2f6;
  font-size: 12.5px;
}
.ssm-header {
  background: linear-gradient(180deg, #1b4b7a 0%, #12365a 100%);
  color: #fff;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #f59e0b;
}
.ssm-title-block { display: flex; align-items: center; gap: 12px; }
.ssm-logo-badge {
  background: #fff;
  color: #12365a;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 4px;
  font-size: 13px;
}
.ssm-menubar {
  background: #23588a;
  padding: 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border-bottom: 1px solid #0e2c4a;
}
.ssm-menu-item {
  color: #f1f5f9;
  padding: 8px 13px;
  font-weight: 600;
  font-size: 12px;
  display: inline-block;
  border-right: 1px solid rgba(255,255,255,0.08);
}
.ssm-menu-item:hover, .ssm-menu-item.active {
  background: #f59e0b;
  color: #0f172a;
  text-decoration: none;
}
.ssm-subbar {
  background: #dbe5f0;
  padding: 6px 18px;
  border-bottom: 1px solid #b8c7d9;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
}
.ssm-subbar a { color: #12365a; font-weight: 600; }
.ssm-container { padding: 14px 18px 36px; }

/* =========================================================
   SHARED UI COMPONENTS (CARDS, KPI, TABLES, FORMS, STEPPER)
   ========================================================= */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 21px; font-weight: 700; color: var(--slate-900); }
.page-sub { margin: 4px 0 0; color: var(--slate-500); font-size: 13px; }
body.theme-ssm .page-title { font-size: 16px; color: #12365a; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--blue-500);
}
.kpi-card.emerald::before { background: var(--emerald-600); }
.kpi-card.amber::before { background: var(--amber-600); }
.kpi-card.teal::before { background: var(--teal-600); }
.kpi-card.rose::before { background: var(--rose-600); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-val { font-size: 23px; font-weight: 800; color: var(--slate-900); margin: 6px 0 4px; }
.kpi-foot { font-size: 12px; color: var(--slate-500); }

.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
body.theme-ssm .card { border-radius: 4px; border-color: #b8c7d9; }
.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--slate-900); }
.card-body { padding: 16px 18px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .fms-sidebar { width: 210px; }
}

.table-wrap { width: 100%; overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
body.theme-ssm table.data-table { font-size: 12px; }
table.data-table th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-weight: 700;
  text-align: left;
  padding: 9px 11px;
  border-bottom: 2px solid var(--slate-200);
  white-space: nowrap;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
body.theme-ssm table.data-table th {
  background: #dce6f2;
  color: #12365a;
  border: 1px solid #b8c7d9;
  padding: 6px 8px;
}
table.data-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--slate-200);
  vertical-align: middle;
}
body.theme-ssm table.data-table td {
  padding: 5px 8px;
  border: 1px solid #d5dfec;
}
table.data-table tbody tr:hover { background: #f8fbff; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-sea { background: #dbeafe; color: #1e40af; }
.badge-air { background: #ede9fe; color: #5b21b6; }
.badge-inland { background: #fef3c7; color: #92400e; }
.badge-other { background: #e2e8f0; color: #334155; }

.st-approved { background: #dcfce7; color: #166534; }
.st-submitted { background: #fef3c7; color: #92400e; }
.st-locked { background: #e0e7ff; color: #3730a3; }
.st-pending { background: #f1f5f9; color: #475569; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-success { background: var(--emerald-600); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-warning { background: var(--amber-600); color: #fff; }
.btn-outline { background: #fff; border-color: var(--slate-300); color: var(--slate-700); }
.btn-outline:hover { background: var(--slate-50); border-color: var(--slate-500); }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 5px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--slate-600); }
.form-control {
  padding: 7px 10px;
  border: 1px solid var(--slate-300);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--slate-900);
}
.form-control:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 2px rgba(37,99,235,0.12); }

.alert {
  padding: 11px 15px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid transparent;
}
.alert-success { background: var(--emerald-50); border-color: #a7f3d0; color: #065f46; }
.alert-error { background: var(--rose-50); border-color: #fecaca; color: #991b1b; }
.alert-info { background: var(--blue-50); border-color: #bfdbfe; color: #1e40af; }

/* Milestone Stepper (Freightek Job Workspace) */
.milestone-track {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.milestone-step {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}
.milestone-step.done {
  border-color: #34d399;
  background: #ecfdf5;
}
.milestone-step.current {
  border-color: var(--blue-500);
  background: var(--blue-50);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}
.milestone-num { font-weight: 800; font-size: 11px; color: var(--slate-500); }
.milestone-step.done .milestone-num { color: var(--emerald-600); }
.milestone-name { font-weight: 700; margin-top: 3px; color: var(--slate-900); }

.tabs-nav {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--slate-200);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 9px 15px;
  font-weight: 600;
  font-size: 13px;
  color: var(--slate-600);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
}
.tab-btn.active, .tab-btn:hover {
  color: var(--blue-600);
  border-bottom-color: var(--blue-600);
  text-decoration: none;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--slate-200);
  flex-wrap: wrap;
  gap: 10px;
}
.page-links { display: flex; gap: 4px; flex-wrap: wrap; }
.page-link {
  padding: 5px 10px;
  border: 1px solid var(--slate-300);
  border-radius: 5px;
  background: #fff;
  color: var(--slate-700);
  font-size: 12px;
  font-weight: 600;
}
.page-link.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 14px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 34px; }
.bar-fill {
  width: 100%;
  max-width: 34px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-radius: 5px 5px 0 0;
  min-height: 4px;
}
.bar-lbl { font-size: 10.5px; color: var(--slate-500); font-weight: 600; }
