/* ============================================================
   BNSF Railway ATS — Application Stylesheet
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bnsf-orange: #FF6600;
    --bnsf-green: #006633;
    --bnsf-dark: #1A1A2E;
    --bnsf-darker: #16162A;
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #06B6D4;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --sidebar-w: 250px;
    --sidebar-collapsed: 60px;
    --header-h: 56px;
}

html { font-size: 14px; }
body { font-family: var(--font-sans); color: var(--gray-800); background: var(--gray-50); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }
img { max-width: 100%; }
table { border-collapse: collapse; width: 100%; }

/* ---- Layout ---- */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); background: var(--bnsf-dark); color: #fff;
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
    display: flex; flex-direction: column; transition: width .2s;
    overflow-y: auto; overflow-x: hidden;
}
.no-transition { transition: none !important; }
html.sb-collapsed .sidebar { width: var(--sidebar-collapsed); overflow: hidden; }
html.sb-collapsed .main-content { margin-left: var(--sidebar-collapsed); }
.sidebar.collapsed { width: var(--sidebar-collapsed); overflow-x: hidden; overflow-y: auto; }
.sidebar.collapsed .nav-text, .sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 14px 8px; }
.sidebar.collapsed .sidebar-header .brand { display: none; }
.sidebar.collapsed .sidebar-header .sidebar-toggle { display: block; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 8px; }
.sidebar.collapsed .nav-icon { margin: 0; }
.sidebar.collapsed .nav-section { display: none; }
.sidebar.collapsed .sidebar-footer { display: flex; flex-direction: column; align-items: center; padding: 8px; gap: 4px; }
.sidebar.collapsed .sidebar-footer .nav-text { display: none; }
.sidebar.collapsed .sidebar-footer .nav-item { justify-content: center; padding: 9px 8px; width: 100%; }
.sidebar.collapsed .sidebar-user-link { justify-content: center; padding: 9px 8px; width: 100%; }
.sidebar.collapsed .sidebar-user-info { display: none; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
    background: var(--bnsf-orange); color: #fff; font-weight: 800;
    padding: 4px 8px; border-radius: 4px; font-size: .85rem; letter-spacing: 1px;
}
.brand-text { font-weight: 600; font-size: .95rem; white-space: nowrap; }
.sidebar-toggle {
    background: none; border: none; color: #fff; font-size: 1.1rem;
    cursor: pointer; padding: 4px;
}

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius);
    color: rgba(255,255,255,.7); font-size: .875rem; transition: all .2s;
    margin-bottom: 2px; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.3); color: #fff; font-weight: 600; }
.nav-icon { font-size: 1.05rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: 8px 12px; }
.nav-section { padding: 8px 0 2px; }

.sidebar-footer {
    padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8rem; color: rgba(255,255,255,.5);
}
.sidebar-user { display: flex; align-items: center; gap: 8px; }
.sidebar-user-link {
    display: flex; align-items: center; gap: 8px;
    padding: 8px; border-radius: var(--radius); text-decoration: none;
    transition: background .2s; width: 100%;
}
.sidebar-user-link:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.sidebar-user-link.active { background: rgba(59,130,246,.3); }
.sidebar-user .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bnsf-orange); display: flex; align-items: center;
    justify-content: center; font-weight: 700; font-size: .75rem; color: #fff;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-weight: 500; color: #fff; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sidebar-user-role { font-size: .7rem; }
.user-avatar { background: var(--bnsf-orange); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; color: #fff; font-style: normal; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column;
    transition: margin-left .2s;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

.content-header {
    background: #fff; border-bottom: 1px solid var(--gray-200);
    padding: 16px 28px; display: flex; align-items: center;
    justify-content: space-between; min-height: var(--header-h);
}
.content-header h1 { font-size: 1.25rem; font-weight: 600; color: var(--gray-900); }
.content-body { padding: 24px 28px; flex: 1; }

/* ---- Cards ---- */
.card {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200); overflow: hidden; transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--gray-50);
}
.card-header h2, .card-header h3 { font-size: .9rem; font-weight: 700; margin: 0; color: var(--gray-700); text-transform: uppercase; letter-spacing: .3px; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* ---- Stat Cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-grid > * { min-width: 0; }
.stat-card {
    background: #fff; border-radius: var(--radius-lg); padding: 18px 20px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card .stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .6px; color: var(--gray-500); margin-bottom: 6px; font-weight: 600; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
.stat-card .stat-change { font-size: .8rem; margin-top: 4px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ---- Tables ---- */
.data-table { width: 100%; font-size: .875rem; border-collapse: collapse; }
.data-table thead th {
    text-align: left; padding: 10px 14px; font-weight: 700;
    color: var(--gray-500); background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200); font-size: .75rem;
    text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}
.data-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- Badges & Status ---- */
.badge {
    display: inline-flex; align-items: center; padding: 2px 10px;
    border-radius: 100px; font-size: .75rem; font-weight: 600;
    line-height: 1.6; white-space: nowrap;
}
.badge-primary { background: #DBEAFE; color: #1D4ED8; }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #CFFAFE; color: #155E75; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

.status-draft            { background: var(--gray-100); color: var(--gray-600); }
.status-pending_approval { background: #FEF3C7; color: #92400E; }
.status-approved         { background: #DBEAFE; color: #1D4ED8; }
.status-open             { background: #D1FAE5; color: #065F46; }
.status-on_hold          { background: #FEF3C7; color: #92400E; }
.status-filled           { background: #D1FAE5; color: #065F46; }
.status-cancelled        { background: #FEE2E2; color: #991B1B; }

.priority-low    { border-left: 3px solid var(--gray-400); }
.priority-medium { border-left: 3px solid var(--primary); }
.priority-high   { border-left: 3px solid var(--warning); }
.priority-urgent { border-left: 3px solid var(--danger); }

.level-badge { font-weight: 700; font-size: .7rem; padding: 2px 8px; border-radius: 4px; }
.level-L3, .level-L4 { background: #DBEAFE; color: #1D4ED8; }
.level-L5, .level-L6 { background: #D1FAE5; color: #065F46; }
.level-L7, .level-L8 { background: #FEF3C7; color: #92400E; }
.level-L9, .level-L10 { background: #FEE2E2; color: #991B1B; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px; border-radius: var(--radius); font-size: .875rem;
    font-weight: 500; cursor: pointer; border: 1px solid transparent;
    transition: all .2s ease; text-decoration: none; line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled,
.btn[disabled] {
    background: var(--gray-300) !important;
    border-color: var(--gray-300) !important;
    color: var(--gray-600) !important;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    transform: none;
    opacity: 1;
}
.btn:disabled:hover,
.btn[disabled]:hover {
    background: var(--gray-300) !important;
    border-color: var(--gray-300) !important;
    color: var(--gray-600) !important;
    box-shadow: none;
    transform: none;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,.3); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,.3); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #D97706; color: #fff; box-shadow: 0 4px 12px rgba(245,158,11,.3); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-800); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 10px 24px; font-size: 1rem; }
.btn-icon { padding: 6px 8px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; margin-bottom: 6px; font-weight: 600;
    font-size: .8rem; color: var(--gray-600); text-transform: uppercase;
    letter-spacing: .3px;
}
.form-label .required { color: var(--danger); }
.form-control {
    width: 100%; padding: 9px 12px; border: 1px solid var(--gray-300);
    border-radius: var(--radius); font-size: .875rem; font-family: var(--font-sans);
    color: var(--gray-800); background: #fff; transition: border-color .2s, box-shadow .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-control:hover:not(:focus) { border-color: var(--gray-400); }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: .78rem; color: var(--gray-500); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 4px; }
.form-static { font-size: .9rem; color: var(--gray-800); padding: 6px 0; }

select.form-control { appearance: auto; cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.checkbox-list { display: flex; flex-direction: column; gap: 6px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.checkbox-item input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }

/* ── Multi-select dropdown ──────────────────────────────────────────────────── */
.ms-dropdown { position: relative; }
.ms-toggle {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; text-align: left; background: #fff; user-select: none;
  width: 100%;
}
.ms-toggle:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.ms-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-400); }
.ms-label.has-value { color: var(--gray-800); }
.ms-arrow { margin-left: 8px; font-size: .6rem; color: var(--gray-400); transition: transform .15s; flex-shrink: 0; }
.ms-toggle.open .ms-arrow { transform: rotate(180deg); }
.ms-panel {
  display: none; position: fixed;
  background: #fff; border: 1px solid var(--gray-300); border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.1); max-height: 220px; overflow-y: auto; z-index: 1000;
}
.ms-panel.open { display: block; }
.ms-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer; font-size: .875rem; transition: background .1s;
}
.ms-option:hover { background: var(--gray-50); }
.ms-option input[type="checkbox"] { width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; }
.ms-text { flex: 1; }

/* Grouped (drill-down) variant — opt-in via .ms-dropdown--grouped. */
.ms-group, .ms-back {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: 0; text-align: left;
  padding: 8px 12px; font: inherit; color: inherit; cursor: pointer;
}
.ms-group:hover, .ms-back:hover { background: var(--gray-50); }
.ms-group .ms-text { flex: 1; }
.ms-group-arrow { opacity: .55; font-size: 1.05em; }
.ms-group-count { color: var(--gray-500); font-size: .85em; }
.ms-back {
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
  font-weight: 500;
  margin-bottom: 2px;
}

.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.form-actions { padding-top: 8px; display: flex; gap: 8px; align-items: center; }

/* ---- Alerts ---- */
.alert {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px;
    border-radius: var(--radius); margin-bottom: 16px; font-size: .875rem;
}
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #CFFAFE; color: #155E75; border: 1px solid #A5F3FC; }
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.alert-close {
    margin-left: auto; background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: inherit; opacity: .6; padding: 0;
}
.alert-close:hover { opacity: 1; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 20px; justify-content: center; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 8px;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    font-size: .85rem; color: var(--gray-700);
}
.pagination a:hover { background: var(--gray-50); text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--gray-400); pointer-events: none; }

/* ---- Filter Bar ---- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    padding: 14px 18px; background: linear-gradient(180deg, #FCFDFE 0%, var(--gray-50) 100%);
    border-bottom: 1px solid var(--gray-100);
}
.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1 1 160px;
    min-width: 160px;
}
.filter-bar .form-group--actions {
    flex: 0 0 auto;
    min-width: 0;
}
.filter-bar .form-control,
.filter-bar .ms-toggle {
    min-width: 0;
    min-height: 36px;
    padding: 7px 10px;
    font-size: .82rem;
}
.filter-bar .form-label {
    font-size: .68rem;
    margin-bottom: 4px;
    color: var(--gray-500);
    letter-spacing: .5px;
}
.filter-bar .btn {
    min-height: 36px;
    padding: 7px 12px;
}
.filter-bar .ms-dropdown,
.filter-bar .ms-panel {
    width: 100%;
}
.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}
.filter-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-toolbar .filter-bar {
    margin-left: auto;
}
.filter-bar--inline {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--gray-200);
}
.filter-bar--inline .form-group {
    flex: 1 1 150px;
    min-width: 150px;
}
.filter-bar--stacked {
    display: block;
}
.filter-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px 12px;
}
.filter-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}
.filter-note {
    margin: 10px 0 0;
}

/* ---- Detail sections ---- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-item { margin-bottom: 12px; min-width: 0; }
.detail-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); margin-bottom: 2px; overflow-wrap: break-word; }
.detail-value { font-size: .9rem; color: var(--gray-900); overflow-wrap: break-word; word-break: break-word; }

/* Pipeline stages (horizontal) */
.pipeline { display: flex; gap: 4px; flex-wrap: wrap; margin: 16px 0; }
.pipeline-stage {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px;
    border-radius: 100px; font-size: .78rem; font-weight: 500;
    background: var(--gray-100); color: var(--gray-600);
}
.pipeline-stage.active { background: var(--primary); color: #fff; }
.pipeline-stage .stage-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Timeline / Approval history */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
    content: ''; position: absolute; left: -21px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #fff; border: 2px solid var(--gray-300);
}
.timeline-item.approved::before { border-color: var(--success); background: #D1FAE5; }
.timeline-item.rejected::before { border-color: var(--danger); background: #FEE2E2; }
.timeline-item.pending::before { border-color: var(--warning); background: #FEF3C7; }
.timeline-date { font-size: .75rem; color: var(--gray-500); }
.timeline-content { font-size: .875rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed); overflow-x: hidden; overflow-y: auto; }
    .sidebar .nav-text, .sidebar .brand-text { display: none; }
    .sidebar .nav-section { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 9px 8px; }
    .sidebar .nav-icon { margin: 0; }
    .sidebar .sidebar-header { justify-content: center; padding: 14px 8px; }
    .sidebar .sidebar-header .brand { justify-content: center; }
    .sidebar .sidebar-header .sidebar-toggle { display: none; }
    .sidebar .sidebar-footer { display: flex; flex-direction: column; align-items: center; padding: 8px; gap: 4px; }
    .sidebar .sidebar-footer .nav-text { display: none; }
    .sidebar .sidebar-footer .nav-item { justify-content: center; padding: 9px 8px; width: 100%; }
    .sidebar .sidebar-user-link { justify-content: center; padding: 9px 8px; width: 100%; }
    .sidebar .sidebar-user-info { display: none; }
    .main-content { margin-left: var(--sidebar-collapsed); }
    .mobile-toggle { display: block; }
    .form-row, .form-row-3, .detail-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .content-body { padding: 16px; }
    .filter-bar { flex-direction: column; }
    .filter-bar .form-group,
    .filter-bar .form-group--actions,
    .filter-toolbar .filter-bar {
        width: 100%;
        min-width: 0;
    }
    .filter-row,
    .filter-actions,
    .filter-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-grid { grid-template-columns: 1fr; }
}

/* ---- Auth layout ---- */
.auth-layout {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--bnsf-dark) 0%, #2D2D5E 100%);
}
.auth-card { width: 100%; max-width: 420px; padding: 24px; }
.auth-card .card { box-shadow: var(--shadow-lg); }
.auth-brand { text-align: center; margin-bottom: 24px; color: #fff; }
.auth-brand .brand-icon { display: inline-block; font-size: 1.2rem; margin-bottom: 8px; }
.auth-brand h1 { font-size: 1.3rem; font-weight: 600; }

/* ---- Misc ---- */
.text-muted { color: var(--gray-500); }
.text-sm { font-size: .8rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 16px; }  .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.mr-2 { margin-right: 8px; }
.d-flex { display: flex; } .align-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.no-wrap { white-space: nowrap; }
.w-full { width: 100%; }

/* ---- Content Grids ---- */
.content-grid { display: grid; gap: 24px; }
.content-grid > * { min-width: 0; }
.content-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.content-grid.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 768px) {
    .content-grid.two-col, .content-grid.three-col { grid-template-columns: 1fr; }
}

/* ---- Top Bar ---- */
.top-bar {
    background: #fff; border-bottom: 1px solid var(--gray-200);
    padding: 14px 28px; display: flex; align-items: center;
    justify-content: space-between; min-height: var(--header-h);
    position: sticky; top: 0; z-index: 50;
}
.page-heading { font-size: 1.15rem; font-weight: 700; color: var(--gray-900); margin: 0; }
.mobile-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-600); padding: 4px; }

/* ---- Badges polish ---- */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 100px; font-size: .73rem; font-weight: 600;
    line-height: 1.5; white-space: nowrap; letter-spacing: .2px;
}

.candidate-stage-badge {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
}

/* Confirmation modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999;
    display: none; align-items: center; justify-content: center;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius-lg); padding: 24px; max-width: 480px; width: 90%; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Empty states */
.empty-state { text-align: center; padding: 48px 24px; color: var(--gray-500); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* ---- Sidebar nav polish ---- */

/* ---- CSS Tooltip ---- */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip-wrap .tooltip-box {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: #fff;
    font-size: .75rem;
    line-height: 1.5;
    padding: 6px 10px;
    border-radius: var(--radius);
    white-space: nowrap;
    z-index: 999;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}
.tooltip-wrap .tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--gray-800);
}
.tooltip-wrap:hover .tooltip-box { display: block; }

/* ─── Stage picker (drill-down) ───────────────────────────────────────────── */
.stage-picker { position: relative; }
.stage-picker-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    width: 100%;
    background: #fff;
    cursor: pointer;
}
.stage-picker-toggle:hover { background: var(--gray-50, #f9fafb); }
.stage-picker-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-picker-caret { margin-left: 8px; opacity: .55; font-size: .8em; }
.stage-picker-panel {
    /* Fixed positioning avoids being clipped by ancestors with overflow:hidden
       (card bodies, the sticky bulk-bar). JS sets top/left on open. */
    position: fixed;
    min-width: 220px;
    max-width: 360px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: var(--radius, 6px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    z-index: 2000;
    overflow: hidden;
}
.stage-picker-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 320px;
    overflow-y: auto;
}
.stage-picker-list button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    padding: 9px 14px;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
.stage-picker-list button:hover,
.stage-picker-list button:focus-visible { background: rgba(0, 0, 0, .05); outline: none; }
.stage-picker-group { font-weight: 500; }
.stage-picker-arrow { opacity: .55; font-size: 1.05em; }
.stage-picker-back {
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 0, 0, .08) !important;
    margin-bottom: 4px;
}
.stage-picker-item.is-selected {
    background: rgba(59, 130, 246, .08);
    font-weight: 500;
}
.stage-picker-null { color: var(--gray-500, #6b7280); font-style: italic; }
.stage-picker-auto {
    color: #FF6600;
    font-size: .95em;
    margin-left: 6px;
    flex: 0 0 auto;
}
/* Inside the dark bulk-action bar, size the picker like other controls and
   keep the toggle text legible against the white form-control background. */
#bulkBar .stage-picker { width: auto; min-width: 200px; }
#bulkBar .stage-picker-toggle { color: var(--gray-900, #111827); }
