:root {
  --ink: #252422;
  --paper: #fffcf2;
  --signal: #eb5e28;
  --control: #4f6d7a;
  --line: #dedbd1;
  --muted: #77746d;
  --white: #fffefa;
  --nav: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; overflow-x: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--signal) 45%, transparent); outline-offset: 2px; }
.topbar { height: var(--nav); display: flex; align-items: center; gap: 30px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,252,242,.96); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; border: 0; background: none; padding: 0; font-size: 17px; letter-spacing: -.02em; }
.brand img { display: block; }
.main-nav { display: flex; align-self: stretch; gap: 25px; }
.nav-item { border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); padding: 2px 0 0; font-size: 12px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.nav-item span { margin-left: 5px; color: var(--control); }
.nav-item.is-active { color: var(--ink); border-color: var(--signal); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.metric { display: flex; align-items: baseline; gap: 8px; margin-right: 8px; }
.metric small, .finance-total small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { font-size: 14px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--white); font-size: 22px; }
.icon-button:hover { border-color: var(--control); }
.icon-button svg, .search-row svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-button.subtle { border-color: transparent; background: transparent; }
.primary-button, .ghost-button { min-height: 40px; border-radius: 6px; padding: 0 16px; border: 1px solid var(--ink); font-weight: 700; }
.primary-button { background: var(--ink); color: var(--paper); }
.primary-button:hover { background: var(--signal); border-color: var(--signal); }
.ghost-button { background: transparent; }
.view { display: none; }
.view.is-active { display: block; animation: view-in .25s ease-out; }
@keyframes view-in { from { opacity: .45; transform: translateY(3px); } }
.workspace { display: grid; grid-template-columns: minmax(300px, 26%) minmax(430px, 1fr) minmax(290px, 24%); height: calc(100vh - var(--nav)); min-height: 620px; }
.queue-panel, .record-panel, .action-panel { min-width: 0; overflow-y: auto; }
.queue-panel { border-right: 1px solid var(--line); background: #f7f4eb; }
.record-panel { padding: 34px clamp(28px, 4vw, 62px); background: var(--white); }
.action-panel { border-left: 1px solid var(--line); padding: 34px 28px; background: var(--paper); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; padding: 26px 22px 18px; }
.eyebrow, .section-label { display: block; color: var(--control); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.04em; }
h2 { font-size: clamp(23px, 2.2vw, 34px); line-height: 1.12; letter-spacing: -.045em; }
.panel-heading h1 { margin-top: 3px; }
.search-row { display: flex; margin: 0 22px 12px; padding: 9px 11px; border: 1px solid var(--line); background: var(--white); border-radius: 6px; gap: 8px; }
.search-row input { width: 100%; border: 0; outline: 0; background: transparent; }
.filter-strip { display: flex; padding: 0 22px 14px; gap: 4px; border-bottom: 1px solid var(--line); transition: background .2s; }
.filter-strip.is-emphasized { background: #ece9df; }
.filter-strip button, .mobile-switcher button { border: 0; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 14px; font-size: 12px; font-weight: 700; }
.filter-strip button.is-active, .mobile-switcher button.is-active { color: var(--paper); background: var(--control); }
.case-row { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; width: 100%; text-align: left; padding: 17px 18px 17px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; }
.case-row:hover { background: rgba(255,255,255,.6); }
.case-row.is-selected { background: var(--white); box-shadow: inset 3px 0 var(--ink); }
.priority-mark { border-radius: 0 3px 3px 0; background: transparent; }
.priority-mark.urgent { background: var(--signal); }
.priority-mark.waiting { background: var(--control); }
.case-main { min-width: 0; }
.case-main strong, .case-main small { display: block; }
.case-main strong { font-size: 14px; margin: 4px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-main small { color: var(--muted); }
.case-meta { display: flex; color: var(--muted); font-size: 10px; letter-spacing: .03em; text-transform: uppercase; }
.case-meta b { color: var(--ink); }
.case-meta time { margin-left: auto; }
.status-chip, .doc-status { align-self: center; display: inline-block; border-radius: 12px; padding: 3px 8px; background: #e8ebe8; color: #3d574d; font-size: 10px; font-weight: 800; font-style: normal; white-space: nowrap; }
.status-chip.urgent { background: #f8ddd2; color: #a9360b; }
.status-chip.waiting { background: #dfe7ea; color: #3c5a66; }
.empty-state, .record-empty { padding: 55px 30px; text-align: center; color: var(--muted); }
.empty-state span { display: block; font-size: 32px; color: var(--control); }
.empty-state strong { color: var(--ink); }
.empty-state button { border: 0; background: none; color: var(--signal); font-weight: 700; }
.record-top { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.record-top h2 { max-width: 680px; margin: 6px 0 0; }
.record-person { display: flex; align-items: center; gap: 12px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.record-person > span:first-child { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--control); color: white; font-size: 11px; font-weight: 800; }
.record-person div { flex: 1; }
.record-person small, .record-person strong { display: block; }
.record-person small, .facts small { color: var(--muted); font-size: 11px; }
.record-copy { padding: 25px 0 13px; }
.record-copy p { max-width: 720px; margin: 10px 0; font-size: 16px; line-height: 1.7; }
.facts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { padding: 16px 10px 16px 0; }
.facts strong { display: block; margin-top: 4px; font-size: 13px; }
.owner-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--control); }
.danger-text { color: var(--signal); }
.timeline { padding-top: 26px; }
.timeline > div { display: grid; grid-template-columns: 9px 42px 1fr; gap: 12px; margin-top: 16px; }
.timeline i { width: 9px; height: 9px; margin-top: 6px; border: 2px solid var(--control); border-radius: 50%; }
.timeline time { color: var(--muted); font-size: 11px; padding-top: 2px; }
.timeline p { margin: 0; font-size: 13px; }
.action-head { display: flex; justify-content: space-between; }
.progress { color: var(--control); font-weight: 800; }
.action-panel h2 { font-size: 23px; margin: 8px 0 18px; }
.next-action { font-size: 16px; line-height: 1.55; }
.deadline-line { display: flex; justify-content: space-between; margin: 22px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.deadline-line span { color: var(--muted); }
.checklist { display: grid; gap: 4px; margin-bottom: 24px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.checklist input { width: 18px; height: 18px; accent-color: var(--control); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; }
.note-field span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
textarea, input, select { border: 1px solid var(--line); border-radius: 5px; background: var(--white); padding: 11px; }
.note-field textarea { width: 100%; resize: vertical; }
.full { width: 100%; margin-top: 18px; }
.text-button { width: 100%; margin-top: 12px; border: 0; background: none; color: var(--control); font-weight: 700; }
.mobile-switcher { display: none; }
.secondary-view { padding: 48px clamp(28px, 5vw, 78px); }
.section-head { display: flex; justify-content: space-between; align-items: end; max-width: 1240px; margin: 0 auto 36px; }
.section-head h1 { margin: 4px 0 8px; font-size: 42px; }
.section-head p { margin: 0; color: var(--muted); }
.document-table, .finance-layout { max-width: 1240px; margin: auto; border-top: 2px solid var(--ink); }
.table-row { display: grid; grid-template-columns: 2fr .7fr .7fr .8fr; align-items: center; min-height: 72px; border-bottom: 1px solid var(--line); }
.table-row span { padding-right: 18px; }
.table-row strong, .table-row small, .ledger-row small { display: block; }
.table-row small, .ledger-row small { margin-top: 3px; color: var(--muted); }
.table-header { min-height: 38px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.finance-total { text-align: right; }
.finance-total strong { display: block; font-size: 32px; letter-spacing: -.04em; }
.finance-layout { display: grid; grid-template-columns: 1fr 300px; }
.ledger { padding-right: 38px; }
.ledger-head, .ledger-row { display: grid; grid-template-columns: 1.2fr 1.5fr .8fr .8fr; align-items: center; min-height: 72px; border-bottom: 1px solid var(--line); }
.ledger-head { min-height: 38px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.finance-note { padding: 24px; border-left: 1px solid var(--line); background: #f2efe6; }
.finance-note strong { display: block; margin: 10px 0; font-size: 24px; }
.overlay[hidden] { display: none; }
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgba(37,36,34,.35); opacity: 0; transition: opacity .18s; }
.overlay.is-open { opacity: 1; }
.drawer { width: min(520px, 100%); height: 100%; overflow-y: auto; padding: 32px; background: var(--paper); transform: translateX(20px); transition: transform .18s; }
.overlay.is-open .drawer { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 30px; }
.drawer-head h2 { margin: 5px 0 0; }
.drawer form, .drawer label { display: grid; gap: 7px; }
.drawer form { gap: 18px; }
.drawer label { color: var(--muted); font-size: 11px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 100; padding: 11px 16px; border-radius: 5px; background: var(--ink); color: var(--paper); opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 1280px) {
  .workspace { grid-template-columns: 370px minmax(560px, 1fr) 340px; }
  .record-panel { padding-left: 56px; padding-right: 56px; }
}

@media (max-width: 900px) {
  .metric { display: none; }
  .workspace { grid-template-columns: 310px 1fr; }
  .action-panel { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 760px) {
  :root { --nav: 112px; }
  .topbar { height: var(--nav); padding: 12px 16px; gap: 10px; flex-wrap: wrap; align-content: center; }
  .brand { margin-right: auto; }
  .brand span { font-size: 15px; }
  .top-actions { margin-left: 0; }
  .top-actions .icon-button { display: none; }
  .primary-button { padding: 0 12px; }
  .main-nav { order: 3; width: 100%; height: 34px; gap: 20px; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; font-size: 10px; }
  .mobile-switcher { height: 44px; display: flex; align-items: center; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--white); }
  .workspace { display: block; height: calc(100svh - var(--nav) - 44px); min-height: 0; }
  .workspace > [data-panel] { display: none; height: 100%; overflow-y: auto; }
  .workspace[data-current-panel="queue"] > [data-panel="queue"],
  .workspace[data-current-panel="record"] > [data-panel="record"],
  .workspace[data-current-panel="action"] > [data-panel="action"] { display: block; animation: view-in .2s ease-out; }
  .record-panel, .action-panel { padding: 24px 20px 36px; border: 0; }
  .panel-heading { padding-top: 20px; }
  .facts { grid-template-columns: 1fr; }
  .facts div { border-bottom: 1px solid var(--line); }
  .record-top h2 { font-size: 27px; }
  .secondary-view { padding: 26px 16px 60px; }
  .section-head { display: block; margin-bottom: 26px; }
  .section-head h1 { font-size: 34px; }
  .section-head .primary-button, .finance-total { margin-top: 20px; }
  .finance-total { text-align: left; }
  .table-header { display: none; }
  .table-row { grid-template-columns: 1fr auto; gap: 8px; padding: 14px 0; }
  .table-row > span:nth-child(2) { grid-column: 1; }
  .table-row > span:nth-child(3) { grid-column: 2; grid-row: 1; }
  .finance-layout { display: block; }
  .ledger { padding: 0; }
  .ledger-head { display: none; }
  .ledger-row { grid-template-columns: 1fr auto; gap: 7px; padding: 13px 0; }
  .ledger-row > span:nth-child(2) { grid-column: 1; }
  .ledger-row > strong { grid-column: 2; grid-row: 1; }
  .finance-note { border: 0; margin-top: 24px; }
  .drawer { padding: 24px 18px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .brand img { width: 29px; height: 29px; }
  .top-actions .primary-button { font-size: 12px; }
  .main-nav { gap: 16px; }
  .case-row { padding-right: 12px; gap: 9px; }
  .status-chip { padding-left: 6px; padding-right: 6px; }
  .record-panel, .action-panel { padding-left: 16px; padding-right: 16px; }
  .timeline > div { grid-template-columns: 9px 36px 1fr; gap: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
