:root {
  /* Kelly Benefits palette */
  --kb-green: #15503c;        /* primary deep green (from brand) */
  --kb-green-600: #1b6049;
  --kb-green-700: #114031;
  --kb-green-050: #eef4f1;    /* tint */
  --page: #f4f6f5;            /* light page background */
  --card: #ffffff;
  --card-border: #e2e8e5;
  --text: #16241f;            /* near-black green-tinted */
  --muted: #5f726b;
  --accent: var(--kb-green);
  --accent2: var(--kb-green-600);
  --ok: #1b8a5a;
  --warn: #b9770b;
  --err: #c0392b;
  --line: #e2e8e5;
  --surface-2: #fafcfb;       /* subtle raised surface (dropzone, rows) */
  --radius: 14px;
}

/* ---------- Dark theme (opt-in via data-theme="dark"; light is default) ---------- */
[data-theme="dark"] {
  --kb-green: #2e8b63;        /* lighter green reads better on dark */
  --kb-green-600: #37a074;
  --kb-green-700: #256b4c;
  --kb-green-050: #16241f;    /* dark tint */
  --page: #0e1512;
  --card: #15201b;
  --card-border: #27332d;
  --text: #e7efea;
  --muted: #93a79d;
  --accent: var(--kb-green);
  --accent2: var(--kb-green-600);
  --ok: #37d399;
  --warn: #e0a641;
  --err: #ef6a5c;
  --line: #27332d;
  --surface-2: #11201a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { --header-h: 72px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--page);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- Sticky header (stays put on scroll) ---------- */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--kb-green);
  color: #fff;
  box-shadow: 0 2px 14px rgba(0,0,0,0.14);
}
.app-header-inner {
  max-width: 1280px; height: 100%; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  font-size: 20px; color: var(--kb-green); border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; color: #fff; line-height: 1.2; }
.subtitle {
  color: rgba(255,255,255,0.82); font-size: 12.5px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.header-btn {
  height: 36px; padding: 0 14px; border-radius: 9px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.14); color: #fff;
  border: 1px solid rgba(255,255,255,0.32);
  transition: background .15s, border-color .15s;
}
.header-btn:hover { background: rgba(255,255,255,0.26); border-color: rgba(255,255,255,0.5); }
.header-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.header-btn.icon { width: 36px; padding: 0; font-size: 16px; }

/* ---------- Workspace: one column before processing, two after ---------- */
.main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 40px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
  gap: 24px;
  align-items: start;
}
/* After "Upload & Process": upload panel moves left, results take the right. */
.workspace.processing {
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  justify-content: stretch;
}
/* Many files: shrink the upload panel so the results get more room. */
.workspace.processing.many { grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); }

/* The upload panel stays in view while the results column scrolls. */
.workspace.processing .upload-col {
  position: sticky; top: calc(var(--header-h) + 20px);
}
.workspace.processing .status-card { margin-bottom: 0; }

/* Compact the upload panel once it is the narrow left column. */
.workspace.processing .card-lead { display: none; }
.workspace.processing .card-title { margin-bottom: 16px; }
.workspace.processing .dropzone { padding: 24px 14px; }

.card-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.card-lead { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin-bottom: 20px; }

/* Page view switch in the header (same pattern as the architecture page) */
.view-switch { display: inline-flex; gap: 3px; padding: 3px; border-radius: 10px;
  background: rgba(0,0,0,0.18); border: 1px solid rgba(255,255,255,0.22); flex: none; }
.view-switch button { border: none; background: transparent; color: rgba(255,255,255,0.78); font: inherit;
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.view-switch button:hover:not(:disabled) { color: #fff; }
.view-switch button[aria-checked="true"] { background: #fff; color: var(--kb-green); }
.view-switch button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.view-switch button:disabled { opacity: .55; cursor: not-allowed; }
@media (max-width: 860px) { .view-switch button { padding: 6px 9px; font-size: 12px; } .subtitle { display: none; } }

/* Second tab: two labelled, required drop areas */
.dz-block { margin-bottom: 16px; }
.dz-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.dz-num { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px;
  color: #fff; background: var(--kb-green); flex: none; }
.dz-req { font-weight: 500; font-size: 12px; color: var(--muted); margin-left: auto; }
.dropzone.dropzone-compact { padding: 20px 16px; }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
#mappedCol .btn-primary { margin-top: 4px; }
.fs-kind { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--kb-green);
  background: var(--kb-green-050); border-radius: 6px; padding: 2px 6px; margin-left: 8px; }

/* Narrow screens: stack the columns again. */
@media (max-width: 900px) {
  .workspace.processing,
  .workspace.processing.many { grid-template-columns: minmax(0, 1fr); }
  .workspace.processing .upload-col { position: static; }
}
@media (max-width: 560px) {
  html { --header-h: 64px; }
  .subtitle { display: none; }
  .app-header-inner, .main { padding-left: 16px; padding-right: 16px; }
}

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 4px 18px rgba(21,80,60,0.06);
  margin-bottom: 20px;
}

/* Field */
.field { margin-bottom: 20px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.field input, .field select {
  width: 100%; padding: 12px 14px; font-size: 15px;
  color: var(--text); background: var(--card);
  border: 1px solid var(--card-border); border-radius: 10px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--kb-green); box-shadow: 0 0 0 3px rgba(21,80,60,0.15); }
.hint { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
code { background: var(--kb-green-050); color: var(--kb-green-700); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* Dropzone */
.dropzone {
  border: 1.5px dashed #bcd0c8;
  border-radius: 14px; padding: 36px 20px; text-align: center;
  cursor: pointer; transition: all .18s; margin-bottom: 20px; background: var(--surface-2);
}
.dropzone:hover, .dropzone:focus { border-color: var(--kb-green); background: var(--kb-green-050); }
.dropzone.drag { border-color: var(--kb-green); background: var(--kb-green-050); transform: scale(1.01); }
.dz-icon {
  width: 48px; height: 48px; margin: 0 auto 14px; display: grid; place-items: center;
  font-size: 22px; border-radius: 12px;
  background: var(--kb-green-050); color: var(--kb-green);
}
.dz-text { font-size: 15px; }
.dz-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.dz-file { margin-top: 12px; font-size: 13px; color: var(--ok); font-weight: 600; word-break: break-all; }
.link { background: none; border: none; color: var(--kb-green); cursor: pointer; font: inherit; text-decoration: underline; }
.link.small { font-size: 12px; }

/* Button */
.btn-primary {
  width: 100%; padding: 14px; font-size: 15px; font-weight: 600;
  color: #fff; border: none; border-radius: 11px; cursor: pointer;
  background: var(--kb-green);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: background .15s, transform .1s;
}
.btn-primary:hover:not(:disabled) { background: var(--kb-green-600); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.45); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Status */
.status-card { animation: rise .3s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.status-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.status-head h2 { font-size: 17px; font-weight: 600; }

.steps { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.step { display: flex; align-items: center; gap: 12px; padding: 9px 0; font-size: 14px; color: var(--muted); }
.step .dot {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid #cdd8d3; transition: all .2s;
}
.step.active { color: var(--text); }
.step.active .dot { border-color: var(--kb-green); box-shadow: 0 0 0 4px rgba(21,80,60,0.12); }
.step.done { color: var(--text); }
.step.done .dot { background: var(--ok); border-color: var(--ok); }
.step.err .dot { background: var(--err); border-color: var(--err); }

.dataset-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.ds-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--card-border);
  font-size: 13.5px;
}
.ds-name { font-weight: 500; }
.ds-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.ds-badge.ok { background: rgba(27,138,90,0.12); color: var(--ok); }
.ds-badge.run { background: rgba(185,119,11,0.14); color: var(--warn); }
.ds-badge.err { background: rgba(192,57,43,0.12); color: var(--err); }
.ds-rows { color: var(--muted); font-variant-numeric: tabular-nums; }
.ds-row-top { display: flex; align-items: center; justify-content: space-between; }
.ds-reason { margin-top: 7px; font-size: 12.5px; line-height: 1.45; }
.ds-reason.err { color: var(--err); }
.ds-reason.warn { color: var(--warn); }

.status-msg { margin-top: 14px; font-size: 13px; line-height: 1.5; }
.status-msg.err { color: var(--err); }
.status-msg.ok { color: var(--ok); }

/* Informational note (extra columns kept as-is). Hidden when empty. */
.fs-note { margin-top: 8px; font-size: 12px; line-height: 1.45; color: var(--warn); }
.fs-note:empty { display: none; }

/* "Read more" / "Show less" toggle for long flag/reject messages. Inherits the
   surrounding text color (err red or warn amber) but underlined + bold so it
   reads as an action. */
.read-more {
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
  color: inherit;
}
.read-more:hover { opacity: 0.8; }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* --- multi-file per-file status panels --- */
/* Tiles auto-fit the width of the results column: more files, more columns. */
.file-status-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  align-items: start;
}
.fs-item { animation: rise .25s ease; }
.fs-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); }
.fs-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.fs-name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.fs-group { font-size: 12px; color: var(--muted); }
.fs-msg { margin-top: 6px; }
.opt { font-size: 11px; color: var(--muted); font-weight: 400; }

/* --- sign-in gate (Kelly Benefits light) --- */
.auth-gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--kb-green); z-index: 9999; }
.auth-card { width: min(92vw, 380px); text-align: center; padding: 36px 32px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,0.25); }
.auth-logo { font-size: 30px; color: var(--kb-green); margin-bottom: 10px; }
.auth-title { margin: 0 0 6px; font-size: 20px; font-weight: 700; color: var(--text); }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.auth-btn { width: 100%; justify-content: center; }
.auth-foot { margin: 18px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

/* ---------- disruption confirmation modal (light) ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(21, 36, 31, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-top: 4px solid var(--warn);
  border-radius: 12px;
  max-width: 560px; width: 100%;
  padding: 1.25rem 1.4rem;
  box-shadow: 0 16px 50px rgba(0,0,0,0.25);
}
.modal h3 { margin: 0 0 .6rem; color: var(--warn); font-size: 1.05rem; }
.modal p { margin: .4rem 0; line-height: 1.45; }
.modal-list { margin: .6rem 0; padding-left: 1.2rem; }
.modal-list li { margin: .25rem 0; }
.modal-file { margin: .5rem 0 .2rem; }
.modal-file + .modal-file { border-top: 1px solid var(--card-border); padding-top: .5rem; }
.modal-file-name { font-weight: 600; font-size: .92rem; }
.modal { max-height: 80vh; overflow-y: auto; }
.modal-note { font-size: .82rem; color: var(--muted); }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.btn-ghost, .btn-danger {
  padding: .55rem 1rem; border-radius: 8px; cursor: pointer; font-weight: 600; border: 1px solid transparent;
}
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--card-border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--kb-green); color: #fff; }
.btn-danger:hover { background: var(--kb-green-600); }

/* Client combobox (searchable select) */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  margin: 4px 0 0; padding: 4px; max-height: 280px; overflow-y: auto; list-style: none;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.combo-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.combo-list li.active, .combo-list li:hover { background: var(--kb-green-050); }
.combo-list li[aria-selected="true"] .combo-id { color: var(--kb-green); }
.combo-id { font-weight: 600; white-space: nowrap; }
.combo-name { color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-list li.combo-empty { color: var(--muted); cursor: default; justify-content: flex-start; }
.combo-list li.combo-empty:hover { background: transparent; }