:root {
  --ink: #17212B;
  --ink-2: #3A4550;
  --muted: #56616C;
  --line: #DDE1E6;
  --line-soft: #ECEEF1;
  --bg: #F3F4F6;
  --card: #FFFFFF;
  --brand: #0E6B66;
  --brand-dark: #0B4F4B;
  --brand-tint: #E3F1EF;
  --brand-ring: #7CC4BE;
  --warn-bg: #FCEFD9;
  --warn-ink: #6E3606;
  --warn: #B4580F;
  --err-bg: #FBE7E7;
  --err-ink: #8A1C1C;
  --err: #C0392B;
  --ok: #1F7A4D;
  --radius: 12px;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.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; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

.demo-banner { background: #1F2A36; color: #E6EDF3; text-align: center; font-size: 13px; padding: 8px 16px; }

/* ---------- top bar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 12px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 4px; flex: 1 1 auto; }
.nav-btn { height: 44px; padding: 0 16px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.nav-btn:hover { background: var(--bg); }
.nav-btn[aria-current="page"] { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; }
.link-btn { background: none; border: 0; padding: 8px 4px; color: var(--brand); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; outline: none; }

/* ---------- shared ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .main-col { flex: 999 1 560px; min-width: 0; }
.split > .side-col { flex: 1 1 340px; min-width: 0; }

.btn { height: 46px; padding: 0 22px; border-radius: 8px; font-weight: 600; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--card); border-color: #B9C0C8; color: var(--ink); font-weight: 500; }
.btn-secondary:hover { background: var(--bg); }
.btn-warn { background: var(--card); border-color: var(--warn); color: var(--warn-ink); }
.btn-danger { background: var(--card); border-color: var(--err); color: var(--err-ink); }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 80px 0; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice { padding: 14px 16px; border-radius: 8px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice svg { flex: none; margin-top: 2px; }
.notice-info { background: var(--brand-tint); color: var(--brand-dark); }
.notice-warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice-err { background: var(--err-bg); color: var(--err-ink); }

/* ---------- form ---------- */
.form-section + .form-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line-soft); }
.form-section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 14px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.field label, .field .label { font-weight: 500; }
.req { color: var(--err); margin-left: 2px; }
.hint { font-size: 12.5px; color: var(--muted); }
.field input, .field select { height: 44px; padding: 0 12px; border: 1px solid #B9C0C8; border-radius: 8px; background: var(--card); width: 100%; }
.field input:focus { border-color: var(--brand); }
.field.invalid input, .field.invalid select { border-color: var(--err); }
.field .error { font-size: 12.5px; color: var(--err-ink); font-weight: 500; }

.combo-list { position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(23,33,43,.12); z-index: 4; max-height: 280px; overflow: auto; }
.combo-list li { padding: 10px 12px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: var(--brand-tint); }
.combo-list .sub { font-size: 12.5px; color: var(--muted); }
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 8px 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.chip .who { display: flex; flex-direction: column; line-height: 1.25; }
.chip .who span { font-size: 12.5px; color: var(--muted); }

.upn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 44px; padding: 6px 12px; border-radius: 8px; background: var(--bg); border: 1px dashed #B9C0C8; }
.upn-row .mono { font-size: 14px; overflow-wrap: anywhere; flex: 1 1 200px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 3px 10px; border-radius: 13px; font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.pill::before { flex: none; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok { background: #E2F3EA; color: var(--ok); }
.pill-busy { background: var(--brand-tint); color: var(--brand-dark); }
.pill-wait { background: #EEF0F2; color: var(--ink-2); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill-err { background: var(--err-bg); color: var(--err-ink); }

/* ---------- timeline (what happens next / detail) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; }
.timeline .rail { display: flex; flex-direction: column; align-items: center; }
.timeline .dot { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; background: #EEF0F2; color: var(--muted); }
.timeline .bar { width: 2px; flex: 1; background: var(--line); margin: 4px 0; min-height: 12px; }
.timeline li:last-child .bar { display: none; }
.timeline .body { padding-bottom: 18px; min-width: 0; }
.timeline .when { font-size: 12px; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; }
.timeline .what { font-weight: 600; }
.timeline .note { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.timeline .done .dot { background: var(--brand); color: #fff; }
.timeline .current .dot { background: var(--card); border: 2px solid var(--brand); color: var(--brand); }
.timeline .err .dot { background: var(--err); color: #fff; }
.timeline .warn .dot { background: var(--warn); color: #fff; }
.timeline .future .what { color: var(--ink-2); font-weight: 500; }
.timeline .done .bar { background: var(--brand); }

/* ---------- review ---------- */
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
@media (max-width: 640px) { .summary { grid-template-columns: minmax(0, 1fr); } }
.summary div { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.summary dt { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.summary dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }

.success { text-align: center; max-width: 620px; margin: 32px auto; }
.success h1 { font-size: 24px; margin: 14px 0 6px; }
.success p { color: var(--muted); margin: 0 0 22px; }

/* ---------- tracker ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat.attn .n { color: var(--warn); }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; background: #E6E9ED; border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { height: 36px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; font-weight: 500; color: var(--ink-2); font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--brand-dark); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.search { flex: 1 1 220px; height: 44px; padding: 0 12px 0 38px; border: 1px solid #B9C0C8; border-radius: 8px; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2356616C' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat 13px center; }

.hire-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.hire-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.6fr); gap: 14px; align-items: center; width: 100%; text-align: left; padding: 14px 18px; border: 0; border-bottom: 1px solid var(--line-soft); background: var(--card); }
.hire-row:last-child { border-bottom: 0; }
.hire-row:hover { background: #F8F9FA; }
.hire-row[aria-current="true"] { background: #EEF6F5; box-shadow: inset 4px 0 0 var(--brand); }
.hire-row .name { font-weight: 600; }
.hire-row .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 6px; border-radius: 3px; background: #E6E9ED; overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.progress.attn span { background: var(--warn); }
@media (max-width: 640px) {
  .hire-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
}
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.detail h2 { font-size: 20px; }
.detail .meta { font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 18px 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.detail h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 12px; }
.inline-form .field { flex: 1 1 200px; }

/* ---------- toasts & dialog ---------- */
.toast-region { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 20; width: min(520px, calc(100% - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 14px; }
.toast.err { background: var(--err-ink); }
.dialog { border: 0; border-radius: 14px; padding: 26px; width: min(480px, calc(100% - 32px)); box-shadow: 0 24px 64px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(23,33,43,.45); }
.dialog h2 { font-size: 19px; margin-bottom: 10px; }
.dialog p { margin: 0 0 10px; color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

@media (max-width: 640px) {
  main { padding: 20px 16px 48px; }
  .topbar-inner { padding: 10px 16px; }
  .card { padding: 20px; }
  .user-name { display: none; }
}

/* ---------- worker type picker & tags ---------- */
.type-picker { border: 0; margin: 0; padding: 0; min-width: 0; }
.type-picker legend { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 14px; padding: 0; }
.type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .type-grid { grid-template-columns: minmax(0, 1fr); } }
.type-card { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 14px 44px; border: 1px solid #B9C0C8; border-radius: 10px; cursor: pointer; background: var(--card); }
.type-card:hover { border-color: var(--brand); }
.type-card input { position: absolute; left: 14px; top: 16px; width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.type-card:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.type-card:has(input:focus-visible) { outline: 3px solid var(--brand-ring); outline-offset: 2px; }
.type-name { font-weight: 600; }
.type-desk { font-size: 13px; font-weight: 600; color: var(--brand-dark); }
.type-blurb { font-size: 12.5px; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; vertical-align: 1px; margin-right: 4px; }
.tag-employee { background: #E6E9ED; color: var(--ink-2); }
.tag-contractor { background: #E4ECFA; color: #1F4A8A; }
.tag-vendor { background: #F1E7F7; color: #5B2A7A; }
