:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #111923;
  --muted: #647184;
  --line: #dce3e9;
  --nav: #10171e;
  --nav-2: #18222c;
  --accent: #f5a524;
  --accent-2: #ffbe4d;
  --success: #0b8f68;
  --danger: #b73d35;
  --shadow: 0 16px 42px rgba(17, 25, 35, 0.10);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 70% 0%, #fff8e9 0, transparent 28rem), var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.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; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: #b66b00; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.14em; }

.screen-center, .login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.loader { width: 38px; height: 38px; border-radius: 50%; border: 4px solid #d6dde4; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { background: linear-gradient(135deg, rgba(16,23,30,.97), rgba(23,34,44,.94)), radial-gradient(circle at 80% 20%, #6b4a17, transparent 40%); }
.login-card { width: min(440px, 100%); padding: 38px; border-radius: 24px; background: rgba(255,255,255,.98); box-shadow: 0 32px 90px rgba(0,0,0,.35); }
.login-card h1 { margin: 0; font-size: clamp(2rem, 7vw, 3rem); line-height: 1; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: #111; font-weight: 900; box-shadow: 0 10px 30px rgba(245,165,36,.35); margin-bottom: 22px; }
.brand-mark.small { width: 42px; height: 42px; margin: 0; border-radius: 12px; }
.form-stack { display: grid; gap: 10px; margin-top: 28px; }
.form-stack label { font-weight: 700; font-size: .9rem; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: #fff; color: var(--ink); }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(245,165,36,.32); outline-offset: 2px; border-color: var(--accent); }
.security-note { margin: 24px 0 0; text-align: center; color: var(--muted); font-size: .8rem; }

.button { min-height: 44px; border-radius: 11px; border: 1px solid transparent; padding: 0 16px; font-weight: 800; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.button.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #15100a; box-shadow: 0 8px 22px rgba(245,165,36,.24); }
.button.secondary { background: var(--nav); color: #fff; }
.button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.button.full { width: 100%; }
.icon-button { border: 0; background: transparent; font-size: 1.5rem; padding: 8px; border-radius: 10px; display: none; }

.alert { margin: 16px 28px 0; padding: 13px 16px; border-radius: 12px; background: #eef6ff; border: 1px solid #c9e1fa; color: #174a77; }
.alert.error { margin: 8px 0 0; background: #fff1f0; border-color: #f0c2be; color: #8b2d27; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; background: linear-gradient(180deg, var(--nav), #0c1218); color: #fff; z-index: 10; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-brand strong { display: block; font-size: 1.05rem; }
.sidebar-brand span { color: #99a8b6; font-size: .8rem; }
.nav-list { display: grid; gap: 5px; padding: 20px 0; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; min-height: 46px; border: 0; border-radius: 12px; padding: 0 14px; background: transparent; color: #c7d0d8; text-align: left; font-weight: 700; }
.nav-item:hover:not(:disabled), .nav-item.active { color: #fff; background: var(--nav-2); }
.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.disabled { opacity: .45; cursor: default; }
.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.09); }
.user-chip { margin-bottom: 12px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.06); font-size: .82rem; color: #cbd4dc; }

.workspace { min-width: 0; }
.topbar { height: 88px; display: flex; align-items: center; gap: 16px; padding: 0 28px; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5; }
.topbar h1 { margin: 0; font-size: 1.55rem; }
.connection-pill { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 999px; background: #e8f8f2; color: #087252; font-weight: 800; font-size: .8rem; }
.connection-pill span { width: 8px; height: 8px; border-radius: 50%; background: #17b785; box-shadow: 0 0 0 5px rgba(23,183,133,.12); }
.content-panel { padding: 28px; max-width: 1600px; margin: 0 auto; }
.hero-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 30px; border-radius: var(--radius); color: #fff; background: linear-gradient(115deg, #101820 0%, #192631 60%, #51391a 100%); box-shadow: var(--shadow); }
.hero-card h2 { margin: 0 0 8px; font-size: clamp(1.7rem, 3vw, 2.6rem); }
.hero-card p:last-child { margin-bottom: 0; color: #c4ced7; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin: 20px 0 32px; }
.metric-card { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(17,25,35,.05); }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-weight: 800; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.metric-card strong { display: block; margin: 8px 0 2px; font-size: 2.35rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 26px 0 14px; }
.section-heading h2 { margin: 0; font-size: 1.45rem; }
.section-heading p { margin-bottom: 0; }
.applications-heading { align-items: center; margin-top: 0; }

.filters { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) auto auto; gap: 10px; margin-bottom: 14px; padding: 15px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.table-card { overflow: hidden; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(17,25,35,.06); }
.table-wrap { overflow-x: auto; min-height: 150px; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: #4d5d6c; font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; }
td { font-size: .9rem; }
td strong { display: block; margin-bottom: 3px; }
.subtext { color: var(--muted); font-size: .78rem; }
.status { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; background: #fff1d6; color: #8c5b00; font-size: .72rem; font-weight: 900; text-transform: capitalize; }
.status.hired, .status.qualified { background: #e4f7ef; color: #087252; }
.status.rejected { background: #fde9e7; color: #9a332c; }
.empty-state { display: grid; place-items: center; padding: 48px; color: var(--muted); text-align: center; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .icon-button { display: inline-grid; place-items: center; }
}

@media (max-width: 720px) {
  .content-panel, .topbar { padding-left: 16px; padding-right: 16px; }
  .connection-pill { display: none; }
  .hero-card, .section-heading { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .login-card { padding: 28px 22px; }
}

textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; color: var(--ink); font: inherit; resize: vertical; }
textarea:focus { outline: 3px solid rgba(245,165,36,.32); outline-offset: 2px; border-color: var(--accent); }
.alert.success { background: #e8f8f2; border-color: #b8e6d6; color: #087252; }
.button.small { min-height: 34px; padding: 0 12px; font-size: .78rem; }
.button.danger { background: var(--danger); color: #fff; }
.clickable-row { cursor: pointer; transition: background .15s ease; }
.clickable-row:hover, .clickable-row:focus { background: #fffaf0; outline: none; }
.status.screening, .status.interview { background: #e9efff; color: #3557a8; }
.status.documents_pending { background: #fff0df; color: #9a5700; }
.status.approved, .status.active { background: #e4f7ef; color: #087252; }
.status.archived { background: #edf0f3; color: #52606d; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: minmax(0, 1fr); }
.modal-backdrop { position: absolute; inset: 0; border: 0; background: rgba(5, 10, 15, .68); backdrop-filter: blur(4px); }
.modal-panel { position: relative; justify-self: end; width: min(980px, 96vw); height: 100vh; overflow-y: auto; background: var(--bg); box-shadow: -24px 0 70px rgba(0,0,0,.28); }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 24px 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.modal-header h2 { margin: 0; font-size: 1.7rem; }
.title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.icon-button.visible { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; font-size: 1.8rem; background: var(--surface-2); border: 1px solid var(--line); }
.modal-content { display: grid; gap: 16px; padding: 22px 28px 50px; }
.modal-section { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(17,25,35,.04); }
.modal-section h3 { margin: 0 0 16px; }
.section-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.info-item { min-height: 74px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid #e8edf1; }
.info-item span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.info-item strong { display: block; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 7px; font-weight: 700; font-size: .84rem; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.retention-box { padding: 14px; border-radius: 12px; background: #fff8e9; border: 1px solid #f0d69d; }
.checkbox-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px !important; }
.checkbox-row input { width: 18px; min-height: 18px; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.note-form { display: grid; gap: 10px; margin-bottom: 16px; }
.timeline { display: grid; gap: 10px; max-height: 360px; overflow-y: auto; }
.timeline-item { padding: 13px; border-radius: 12px; background: var(--surface-2); border: 1px solid #e7ecf0; }
.timeline-item strong { display: inline-block; margin-right: 8px; }
.timeline-item time { color: var(--muted); font-size: .75rem; }
.timeline-item p { margin: 7px 0 0; white-space: pre-wrap; }
.timeline-item.compact p { margin-top: 2px; color: var(--muted); font-size: .78rem; }
.details-card summary, .danger-zone summary { cursor: pointer; font-weight: 900; }
.conversion-form, .danger-zone form { margin-top: 18px; }
.linked-driver { display: grid; gap: 4px; margin-top: 14px; padding: 14px; border-radius: 12px; background: #e8f8f2; border: 1px solid #b8e6d6; }
.linked-driver span, .linked-driver small { color: #087252; }
.danger-zone { border-color: #efc4c0; background: #fff8f7; }
.modal-open { overflow: hidden; }

@media (max-width: 760px) {
  .modal-panel { width: 100vw; }
  .modal-header, .modal-content { padding-left: 16px; padding-right: 16px; }
  .info-grid, .form-grid, .two-column { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}


/* Active Drivers module */
.button-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.driver-metric-grid { margin-top: 18px; margin-bottom: 20px; }
.driver-modal-panel { width: min(1120px, 100%); }
.status.onboarding { background: #e9efff; color: #3557a8; }
.status.on_leave { background: #fff0df; color: #9a5700; }
.status.inactive, .status.pending { background: #edf0f3; color: #52606d; }
.status.terminated, .status.expired, .status.missing { background: #fde9e7; color: #9a332c; }
.status.expiring { background: #fff1d6; color: #8c5b00; }
.status.valid { background: #e4f7ef; color: #087252; }
.document-list { display: grid; gap: 10px; margin-bottom: 14px; }
.document-card { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(120px, .8fr) minmax(130px, .8fr) auto; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.document-card strong, .document-card span, .document-card small { display: block; }
.document-card small { color: var(--muted); margin-top: 3px; }
.document-card .document-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.document-form-details { margin-top: 12px; }
.driver-alert { color: #9a332c; font-weight: 900; }
.driver-clear { color: #087252; font-weight: 900; }
@media (max-width: 860px) {
  .document-card { grid-template-columns: 1fr; }
  .document-card .document-actions { justify-content: flex-start; }
  .button-row { justify-content: flex-start; }
}
