:root {
  --gold: #b8922a;
  --champagne: #c6af7a;
  --teal: #007d91;
  --ink: #1a1a1a;
  --deep-ink: #14161a;
  --paper: #faf8f4;
  --surface: #ffffff;
  --warm-gray: #c6beb4;
  --muted: #4a4640;
  --danger: #963d31;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); color-scheme: light; }
body { margin: 0; font-family: "Jost", "Avenir Next", Avenir, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { min-height: 44px; border: 1px solid var(--gold); border-radius: 10px; padding: 9px 14px; background: var(--gold); color: var(--deep-ink); font-weight: 700; cursor: pointer; }
button:hover { background: var(--deep-ink); border-color: var(--deep-ink); color: #fff; }
button:disabled { cursor: not-allowed; background: #e7e2da; border-color: var(--warm-gray); color: var(--muted); }
input, select, textarea { width: 100%; border: 1px solid #81796f; border-radius: 9px; background: var(--surface); color: var(--ink); padding: 11px 12px; }
textarea { resize: vertical; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; z-index: 100; top: -100px; left: 12px; padding: 12px; border-radius: 8px; background: var(--deep-ink); color: #fff; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.app-header { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px max(16px, env(safe-area-inset-left)); background: var(--deep-ink); color: #fff; }
.wordmark { color: inherit; text-decoration: none; font-size: 11px; letter-spacing: .15em; font-weight: 600; }
.wordmark span { font-weight: 300; }
.app-header p { margin: 0; font-size: 11px; letter-spacing: .14em; color: #e8e1d3; }
.truth { position: sticky; top: 0; z-index: 20; display: grid; gap: 3px; padding: 11px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--champagne); background: #f2ebdd; font-size: 12px; line-height: 1.35; }
.truth span { color: var(--muted); }
main { width: min(100%, 1180px); margin: 0 auto; padding: 22px 18px 42px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.02em; }
h1 { margin-bottom: 0; max-width: 18ch; font-size: clamp(2rem, 5vw, 3.35rem); font-weight: 500; line-height: 1.05; }
h2 { font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 700; }
.eyebrow { margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.muted { color: var(--muted); font-size: 13px; }
.status { min-height: 1.5em; margin-bottom: 12px; color: var(--teal); font-size: 13px; font-weight: 700; }
.status.is-error { color: var(--danger); }

.app-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 340px); gap: 28px; align-items: end; margin: 12px 0 26px; }
.person-switcher { padding: 14px; border: 1px solid var(--champagne); border-radius: var(--radius); background: var(--surface); }
.person-switcher label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.person-switcher p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.state-machine { padding: 18px; border: 1px solid var(--gold); border-radius: var(--radius); background: #f5f0e5; }
.machine-copy h2 { max-width: 34ch; }
.state-path { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 0; margin: 18px 0 11px; list-style: none; }
.state-path li { position: relative; min-height: 48px; display: flex; align-items: center; padding: 7px 8px 7px 17px; border: 1px solid var(--warm-gray); border-radius: 9px; background: var(--surface); font-size: 13px; font-weight: 700; line-height: 1.2; }
.state-path li::before { content: ""; position: absolute; left: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); }
.state-path li[data-state-node="blocked"]::before { background: var(--teal); }
.state-path li.is-current { border-color: var(--deep-ink); box-shadow: inset 0 0 0 1px var(--deep-ink); }
.state-note { margin: 0; color: var(--muted); font-size: 12px; }

.workspace { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(0, 1.55fr); gap: 18px; margin-top: 18px; }
.queue-panel, .detail-panel, .export-panel { border: 1px solid var(--champagne); border-radius: var(--radius); background: var(--surface); }
.queue-panel { padding: 18px; }
.panel-top, .detail-heading, .audit-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-top h2 { margin-bottom: 0; }
.panel-top button { white-space: nowrap; }
.queue-panel > .muted { margin: 11px 0 0; }
.request-list { display: grid; gap: 8px; padding: 0; margin: 16px 0 0; list-style: none; }
.request-list button { width: 100%; min-height: 0; padding: 12px; border: 1px solid #e2ddd4; border-radius: 10px; background: var(--paper); color: var(--ink); text-align: left; font-weight: 400; }
.request-list button:hover, .request-list button[aria-current="true"] { border-color: var(--deep-ink); background: var(--deep-ink); color: #fff; }
.request-list strong { display: block; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.request-list span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.request-list button:hover span, .request-list button[aria-current="true"] span { color: #e8e1d3; }
.state-pill { display: inline-flex; align-items: center; min-height: 21px; margin-left: 7px; padding: 2px 7px; border-radius: 99px; background: #e9e2d4; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.request-list button[aria-current="true"] .state-pill { background: var(--gold); color: var(--deep-ink); }
.empty-state { margin-top: 18px; padding: 18px; border: 1px dashed var(--warm-gray); border-radius: 10px; color: var(--muted); }
.empty-state h3 { margin-bottom: 6px; color: var(--ink); }
.empty-state p { margin-bottom: 0; font-size: 14px; }

.detail-panel { min-width: 0; padding: 20px; }
.empty-detail { padding: 14px 4px; color: var(--muted); }
.empty-detail h2 { color: var(--ink); }
.empty-detail p:last-child { margin-bottom: 0; }
.detail-heading { padding-bottom: 18px; border-bottom: 1px solid var(--champagne); }
.detail-heading h2 { margin-bottom: 7px; font-size: clamp(1.55rem, 3vw, 2.1rem); overflow-wrap: anywhere; }
.detail-heading .muted { margin-bottom: 0; }
.state-label { display: inline-flex; margin: 0 0 8px; padding: 4px 8px; border-radius: 99px; background: #eee7d9; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.quiet-button, .secondary-button { border-color: var(--warm-gray); background: var(--surface); color: var(--ink); }
.quiet-button:hover, .secondary-button:hover { background: var(--deep-ink); border-color: var(--deep-ink); color: #fff; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(255px, .8fr); gap: 22px; margin-top: 20px; }
.detail-section { padding: 0 0 18px; margin-bottom: 18px; border-bottom: 1px solid #e5dfd5; }
.detail-section h3 { margin-bottom: 8px; }
.detail-section p { margin-bottom: 0; }
.description { white-space: pre-wrap; overflow-wrap: anywhere; }
.owner-section > p { font-weight: 700; }
.reassign-controls { margin-top: 11px; }
.reassign-controls label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.reassign-controls > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.reassign-controls button { min-height: 42px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.action-row button { background: var(--teal); border-color: var(--teal); color: #fff; }
.action-row button:hover { background: var(--deep-ink); border-color: var(--deep-ink); }
.comment-section { margin-bottom: 0; border-bottom: 0; }
.comment-section form { display: grid; gap: 8px; }
.comment-section form button { justify-self: start; }

.audit-rail { min-width: 0; padding-left: 20px; border-left: 2px solid var(--ink); }
.audit-heading { margin-bottom: 12px; }
.audit-heading h3 { margin-bottom: 0; }
.count { display: inline-flex; align-items: center; min-height: 25px; padding: 2px 8px; border: 1px solid var(--warm-gray); border-radius: 99px; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.audit-list { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; }
.audit-list li { position: relative; padding: 0 0 15px 16px; border-left: 1px solid var(--warm-gray); }
.audit-list li:last-child { padding-bottom: 0; }
.audit-list li::before { content: ""; position: absolute; top: 4px; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.audit-list strong { display: block; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.audit-list p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.audit-list time { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.export-panel { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; padding: 18px; }
.export-panel h2 { margin-bottom: 7px; }
.export-panel p:last-child { margin-bottom: 0; color: var(--muted); font-size: 14px; }
.export-panel button { flex: 0 0 auto; }

dialog { width: min(calc(100% - 32px), 520px); padding: 0; border: 1px solid var(--champagne); border-radius: var(--radius); background: var(--paper); color: var(--ink); box-shadow: 0 18px 48px rgba(20, 22, 26, .28); }
dialog::backdrop { background: rgba(20, 22, 26, .55); }
dialog form { display: grid; gap: 8px; padding: 20px; }
dialog form .eyebrow { margin-bottom: 0; }
dialog h2 { margin-bottom: 10px; font-size: 1.4rem; }
dialog label { font-size: 13px; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

@media (max-width: 820px) {
  .app-intro, .workspace, .detail-grid { grid-template-columns: 1fr; }
  .app-intro { gap: 18px; }
  .state-path { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { gap: 4px; }
  .audit-rail { padding: 18px 0 0; border-top: 2px solid var(--ink); border-left: 0; }
}
@media (max-width: 500px) {
  main { padding-inline: 12px; }
  .truth { padding-inline: 12px; }
  .app-intro { margin-top: 6px; }
  .state-machine, .queue-panel, .detail-panel, .export-panel { padding: 15px; }
  .state-path { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .state-path li { min-height: 42px; font-size: 12px; }
  .panel-top, .detail-heading, .export-panel { align-items: stretch; flex-direction: column; }
  .panel-top button, .detail-heading .quiet-button, .export-panel button { width: 100%; }
  .detail-heading { gap: 14px; }
  .reassign-controls > div { grid-template-columns: 1fr; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions button { flex: 1 1 130px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
