:root {
    --canvas: #fbfbfc;
    --surface: #ffffff;
    --surface-subtle: #fafbfc;
    --ink: #17191d;
    --muted: #5f6670;
    --line: #d7dbe0;
    --line-strong: #b9c0ca;
    --navy: #062b68;
    --navy-hover: #041f4d;
    --shadow: 0 18px 50px rgba(20, 24, 31, .14);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
input:disabled, textarea:disabled { cursor: not-allowed; background: #f0f1f2; color: #70757d; }
a { color: inherit; }
.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; }
.icon { width: 19px; height: 19px; flex: 0 0 auto; }
.icon-sm { width: 16px; height: 16px; flex: 0 0 auto; }
.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar {
    height: 74px;
    padding: 0 30px;
    display: grid;
    grid-template-columns: 340px auto 1fr;
    align-items: stretch;
    gap: 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.brand {
    width: max-content;
    display: inline-flex;
    align-items: center;
    gap: 17px;
    color: var(--ink);
    text-decoration: none;
}
.brand-icon { width: 31px; height: 31px; stroke-width: 1.7; }
.brand-name { font-size: 23px; font-weight: 680; }
.topnav { height: 100%; display: flex; align-items: stretch; }
.nav-button {
    min-width: 96px;
    padding: 0 16px;
    border: 0;
    border-bottom: 4px solid transparent;
    background: transparent;
    color: #4f5662;
    font-size: 17px;
    font-weight: 520;
}
.nav-button:hover { color: var(--ink); }
.nav-button.active { color: var(--ink); border-bottom-color: var(--navy); font-weight: 620; }
.nav-count { min-width: 20px; height: 20px; margin-left: 5px; padding: 0 6px; display: inline-grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 11px; font-weight: 700; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; }
.system-state { display: inline-flex; align-items: center; gap: 14px; color: #3f4653; font-size: 18px; white-space: nowrap; }
.system-state .icon { width: 20px; height: 20px; }
.system-state.issue { color: var(--ink); }
.system-dot { display: none; }

.shell { width: 100%; padding: 0 25px 24px; }
.summary-strip {
    height: 90px;
    display: flex;
    align-items: center;
    gap: 0;
}
.summary-item {
    min-width: 155px;
    padding: 0 36px 0 4px;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.summary-item + .summary-item { padding-left: 42px; border-left: 1px solid #aeb4bc; }
.summary-label { font-size: 17px; }
.summary-value { font-size: 17px; font-weight: 720; font-variant-numeric: tabular-nums; }
.page { display: none; }
.page.active { display: block; }

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(420px, 34%) minmax(640px, 1fr);
    gap: 16px;
    align-items: stretch;
}
.intake-panel, .activity-panel, .review-panel, .issues-panel, .audit-panel {
    min-height: calc(100vh - 188px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}
.panel-head {
    height: 72px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.panel-head h1 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 680; }
.panel-caption { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.drop-zone {
    min-height: 257px;
    margin: 0 22px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    border: 1px dashed #99a4b2;
    border-radius: 6px;
    background: var(--surface);
    text-align: center;
    outline: 0;
    transition: border-color .15s ease, background .15s ease;
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragover { border-color: var(--navy); background: #fafcff; }
.drop-zone.has-batch {
    min-height: 94px;
    padding: 18px 28px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 22px;
    text-align: left;
}
.drop-zone.has-batch .choose-button { width: auto; min-width: 128px; height: 40px; margin-left: auto; padding: 0 18px; border-color: var(--line-strong); background: var(--surface); color: #303642; }
.drop-zone.has-batch .choose-button:hover { border-color: var(--ink); }
.drop-zone.has-batch .drop-meta { display: none; }
.upload-icon { width: 52px; height: 52px; stroke-width: 1.5; }
.drop-title { max-width: 440px; color: #303642; font-size: 16px; line-height: 1.45; }
.drop-zone.has-batch .drop-title { color: var(--ink); font-size: 17px; }
.drop-meta { margin-top: -5px; color: var(--muted); font-size: 15px; }
.button {
    min-height: 38px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 560;
    text-decoration: none;
}
.button:hover { border-color: #8f97a2; background: var(--surface-subtle); }
.button.primary { border-color: var(--navy); background: var(--navy); color: #fff; }
.button.primary:hover { border-color: var(--navy-hover); background: var(--navy-hover); }
.choose-button { width: 212px; height: 54px; font-size: 17px; }
.button.small { min-height: 31px; padding: 5px 10px; font-size: 12px; }
.button.quiet-danger { color: var(--ink); border-style: dashed; }
.button.quiet-danger:hover { border-color: var(--ink); }
.icon-button { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.icon-button:hover { color: var(--ink); background: var(--surface-subtle); }
.icon-button.bordered { border: 1px solid var(--line); background: var(--surface); }

.auto-submit-row {
    height: 76px;
    margin: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
}
.auto-submit-copy { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; }
.info-icon { width: 18px; height: 18px; color: #3d4550; }
.switch-control { position: relative; width: 56px; height: 29px; flex: 0 0 auto; }
.switch-control input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 2; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: #a7adb5; transition: background .15s ease, box-shadow .15s ease; }
.switch-track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform .15s ease; }
.switch-control input:checked + .switch-track { background: #168647; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.switch-control input:checked + .switch-track::after { transform: translateX(27px); }
.switch-control input:focus-visible + .switch-track { box-shadow: 0 0 0 3px rgba(22,134,71,.2); }

.batch-section { margin: 0 22px; border-top: 1px solid var(--line); }
.batch-head { height: 58px; display: flex; align-items: center; }
.batch-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.empty-state { min-height: 180px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.batch-list { overflow-y: auto; }
.batch-item {
    min-height: 64px;
    display: grid;
    grid-template-columns: 29px minmax(0, 1.35fr) minmax(110px, .9fr) 31px;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--line);
}
.batch-item:last-child { border-bottom: 0; }
.batch-file-icon { width: 27px; height: 27px; color: #2d343e; }
.batch-name { min-width: 0; color: #343b47; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch-detail { min-width: 0; color: #535c68; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch-state-icon { width: 31px; height: 31px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink); }
.batch-state-icon .icon { width: 25px; height: 25px; }
.batch-state-icon.processing { animation: spin .9s linear infinite; }
.batch-state-icon.remove:hover { background: var(--surface-subtle); }
.batch-footer { min-height: 76px; padding-top: 24px; display: flex; align-items: flex-start; justify-content: space-between; color: #3c444f; font-size: 14px; }

.rule-note {
    min-height: 54px;
    margin: 0 22px 16px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    color: #3e4652;
    font-size: 14px;
}
.activity-tools { padding: 0 22px 15px; display: grid; grid-template-columns: minmax(300px, 1fr) 255px; gap: 15px; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 16px; top: 18px; color: #313944; pointer-events: none; }
.search-wrap input { width: 100%; padding-left: 49px; }
.control, .input, .textarea { min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 5px; outline: 0; background: var(--surface); color: var(--ink); }
.control:focus, .input:focus, .textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 2px rgba(6,43,104,.09); }
.activity-tools .control { height: 62px; font-size: 16px; }
.activity-tools select { padding: 0 17px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); color: #262c34; font-size: 15px; text-align: left; font-weight: 520; }
td { height: 80px; padding: 0 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: 0; }
.invoice-cell { display: flex; align-items: center; gap: 14px; min-width: 0; }
.row-document-icon { width: 22px; height: 22px; flex: 0 0 auto; color: #3f4652; }

.cell-main { min-width: 0; color: #343b46; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money { color: #343b46; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-row { height: 190px; padding: 38px; text-align: center; color: var(--muted); cursor: default; }
.status-cell { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; min-height: 34px; padding: 5px 11px; border: 1px solid var(--line-strong); border-radius: 4px; color: #303742; font-size: 14px; white-space: nowrap; }
.status { color: #303742; font-size: 14px; line-height: 1.25; }
.review-button { min-height: 37px; padding: 6px 13px; white-space: nowrap; }

.review-panel { min-height: calc(100vh - 188px); }
.review-title-row { height: 90px; }
.review-summary { display: flex; align-items: center; gap: 22px; color: var(--muted); font-size: 13px; }
.review-summary strong { margin-right: 4px; color: var(--ink); font-size: 15px; }
.review-tools { padding: 16px 22px; display: grid; grid-template-columns: minmax(320px,1fr) 240px; gap: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.review-search .icon { top: 13px; }
.review-search input { padding-left: 46px; }
.review-table th { height: 46px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.review-table td { height: 86px; font-size: 13px; }
.review-table .escalated-row { box-shadow: inset 3px 0 0 var(--navy); background: #fafbfc; }
.cell-sub { margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.issue-label { font-weight: 680; }
.issue-detail { margin-top: 4px; max-width: 520px; color: var(--muted); font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
.escalation-meta { margin-top: 7px; display: grid; gap: 2px; color: var(--muted); font-size: 11px; }
.escalation-meta strong { color: var(--navy); font-size: 10px; text-transform: uppercase; }
.review-actions { display: flex; align-items: center; gap: 7px; }

.issues-panel { min-height: calc(100vh - 188px); }
.issues-title-row { height: 90px; }
.issue-metrics { min-height: 72px; display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--line); }
.issue-metrics > div { min-width: 0; padding: 14px 22px; display: grid; gap: 5px; border-right: 1px solid var(--line); }
.issue-metrics > div:last-child { border-right: 0; }
.issue-metrics span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.issue-metrics strong { font-size: 18px; font-weight: 720; }
.issues-tools { padding: 16px 22px; display: grid; grid-template-columns: minmax(320px,1fr) 220px; gap: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.issues-search .icon { top: 13px; }
.issues-search input { padding-left: 46px; }
.issues-table { min-width: 1120px; }
.issues-table th { height: 46px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.issues-table td { min-height: 72px; font-size: 12px; vertical-align: top; }
.occurrence { display: inline-block; padding: 3px 7px; border: 1px solid var(--line-strong); border-radius: 4px; white-space: nowrap; font-size: 10px; font-weight: 700; }
.occurrence.repeat { border-color: var(--navy); color: var(--navy); }
.issue-resolution { color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
.issue-status { display: inline-flex; min-height: 28px; padding: 5px 8px; align-items: center; border: 1px solid var(--navy); border-radius: 4px; color: var(--navy); font-size: 10px; font-weight: 750; white-space: nowrap; }
.issue-status.solved { border-color: var(--line-strong); color: var(--muted); }

.audit-panel { min-height: calc(100vh - 188px); }
.audit-title-row { height: 90px; }
.audit-tools { padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.audit-search { width: min(520px, 70%); }
.audit-search .icon { top: 13px; }
.audit-search input { padding-left: 46px; }
.audit-table th { height: 46px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.audit-table td { height: 56px; font-size: 13px; }
.audit-details { color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
.muted-copy { color: var(--muted); font-size: 11px; }

/* Invoice review */
dialog { width: min(1480px, calc(100vw - 32px)); height: min(920px, calc(100vh - 32px)); max-width: none; max-height: none; padding: 0; overflow: hidden; border: 0; border-radius: 7px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(21,23,26,.56); }
.detail-shell { height: 100%; display: flex; flex-direction: column; background: var(--surface); }
.detail-head { min-height: 82px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.dialog-kicker { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.detail-title { min-width: 0; }
.detail-title h2 { margin: 4px 0 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-title p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.detail-body { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(410px,.9fr) minmax(580px,1.35fr); }
.document-pane { min-height: 0; padding: 12px; display: flex; flex-direction: column; gap: 9px; border-right: 1px solid var(--line); background: #eceeef; }
.pane-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.document-frame { width: 100%; min-height: 0; flex: 1; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); }
.form-pane { min-height: 0; overflow-y: auto; }
.status-banner { margin: 14px 16px 0; padding: 11px 12px; display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--line); border-left: 3px solid var(--navy); border-radius: 4px; background: var(--surface-subtle); color: var(--ink); font-size: 12px; line-height: 1.45; }
.status-banner .status-detail { margin-top: 3px; color: var(--muted); }
.status-banner.processing .icon { animation: spin .9s linear infinite; }
.form-section { padding: 17px 16px; border-bottom: 1px solid var(--line); }
.form-section h3 { margin: 0; font-size: 12px; }
.section-row, .lines-toolbar { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lines-toolbar > div { display: grid; gap: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 11px; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 740; text-transform: uppercase; }
.field .input, .field .textarea { width: 100%; }
.textarea { min-height: 62px; resize: vertical; }
.line-table { width: 100%; table-layout: auto; }
.line-table th { height: 36px; padding: 8px 7px; background: var(--surface-subtle); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.line-table td { height: auto; padding: 5px 4px; border-bottom: 0; }
.line-table input { width: 100%; min-width: 72px; }
.line-table .desc-input { min-width: 230px; }
.line-table .item-code-input { min-width: 100px; }
.line-table .tax-code-input { min-width: 76px; }
.item-code-editor { min-width: 190px; display: grid; gap: 5px; }
.item-code-review { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.item-code-suggestion { min-height: 26px; padding: 3px 7px; border: 1px solid var(--navy); border-radius: 4px; background: var(--surface); color: var(--navy); font-size: 10px; font-weight: 700; cursor: pointer; }
.item-code-suggestion:hover { background: var(--surface-subtle); }
.item-code-remember { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; line-height: 1.3; cursor: pointer; }
.item-code-remember input { width: 14px; min-width: 14px; height: 14px; margin: 0; accent-color: var(--navy); }
.item-code-remember:has(input:disabled) { opacity: .55; cursor: default; }
.remove-line { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); }
.remove-line:hover { color: var(--ink); background: var(--surface-subtle); }
.audit-list { display: grid; border-top: 1px solid var(--line); }
.audit-entry { padding: 9px 0; display: grid; grid-template-columns: 150px 190px 1fr; gap: 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.audit-action { color: var(--ink); font-weight: 680; }
.detail-actions { min-height: 58px; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.action-group { display: flex; gap: 8px; }

dialog.escalation-dialog { width: min(540px,calc(100vw - 32px)); height: fit-content; max-height: calc(100vh - 32px); }
.escalation-shell { height: fit-content; display: grid; background: var(--surface); }
.escalation-head { min-height: 78px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.escalation-head h2 { margin: 4px 0 0; font-size: 18px; }
.escalation-body { padding: 18px 16px; }
.escalation-body label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.escalation-body .textarea { width: 100%; min-height: 120px; }
.escalation-actions { padding: 12px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 70; width: min(390px,calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { padding: 11px 13px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid #fff; border-radius: 5px; background: var(--navy); color: #fff; box-shadow: var(--shadow); animation: toastIn .18s ease-out; }
.toast.error, .toast.success { background: var(--navy); }
.toast-body { min-width: 0; flex: 1; }
.toast-title { font-weight: 720; }
.toast-message { margin-top: 2px; opacity: .78; font-size: 12px; overflow-wrap: anywhere; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* Login */
.login-body { min-height: 100vh; background: var(--canvas); }
.login-topbar { height: 74px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--surface); }
.login-workspace { display: inline-flex; align-items: center; gap: 12px; color: #3f4652; font-size: 17px; }
.login-main { min-height: calc(100vh - 74px); padding: 32px 20px; display: grid; place-items: center; }
.login-card { width: min(440px,100%); padding: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.login-card-head { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 24px; }
.login-icon { width: 29px; height: 29px; margin-top: 2px; color: var(--ink); }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 680; }
.login-card p { margin: 7px 0 0; color: var(--muted); line-height: 1.5; }
.login-field label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 650; }
.login-field .input { width: 100%; min-height: 48px; }
.login-submit { width: 100%; min-height: 48px; margin-top: 16px; }
.login-error { margin-bottom: 18px; padding: 11px 13px; border: 1px solid var(--line-strong); border-left: 3px solid var(--navy); border-radius: 4px; background: var(--surface-subtle); font-size: 13px; }
@media (max-width: 1120px) {
    .topbar { grid-template-columns: 300px auto 1fr; }
    .brand-name { font-size: 20px; }
    .workspace-grid { grid-template-columns: 1fr; }
    .intake-panel, .activity-panel { min-height: auto; }
    .intake-panel { padding-bottom: 18px; }
    .document-pane { min-height: 350px; }
}

@media (max-width: 780px) {
    .topbar { height: auto; min-height: 68px; padding: 10px 14px; grid-template-columns: 1fr auto; gap: 8px; }
    .brand-icon { width: 25px; height: 25px; }
    .brand-name { font-size: 16px; }
    .system-state span { display: none; }
    .topnav { width: 100%; grid-column: 1 / -1; grid-row: 2; height: 42px; }
    .nav-button { min-width: 0; padding: 0 6px; flex: 1; font-size: 13px; line-height: 1.05; white-space: normal; }
    .shell { padding: 0 12px 24px; }
    .summary-strip { height: 72px; display: grid; grid-template-columns: repeat(4,1fr); }
    .summary-item { min-width: 0; padding: 0 8px; flex-direction: column; gap: 4px; }
    .summary-item + .summary-item { padding-left: 12px; }
    .summary-label, .summary-value { font-size: 12px; }
    .workspace-grid { grid-template-columns: 1fr; }
    .panel-head { height: 65px; }
    .drop-zone { min-height: 210px; }
    .drop-zone.has-batch { min-height: 100px; }
    .activity-tools { grid-template-columns: 1fr; }
    .review-tools { grid-template-columns: 1fr; }
    .issues-tools { grid-template-columns: 1fr; }
    .review-title-row { height: auto; min-height: 90px; align-items: flex-start; flex-direction: column; justify-content: center; }
    .issues-title-row { height: auto; min-height: 118px; align-items: flex-start; flex-direction: column; justify-content: center; }
    .issue-metrics { grid-template-columns: repeat(2,1fr); }
    .issue-metrics > div:nth-child(2) { border-right: 0; }
    .issue-metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .review-summary { width: 100%; justify-content: space-between; }
    .activity-tools .control { height: 52px; }
    .detail-body { display: block; overflow-y: auto; }
    .document-pane { height: 45vh; border-right: 0; border-bottom: 1px solid var(--line); }
    .form-pane { overflow: visible; }
    .login-topbar { height: 68px; padding: 0 14px; }
    .login-workspace { font-size: 0; gap: 0; }
    .login-main { min-height: calc(100vh - 68px); padding: 20px 12px; }
    .login-card { padding: 24px 20px; }
}

@media (max-width: 620px) {
    .drop-zone.has-batch { flex-wrap: wrap; }
    .drop-zone.has-batch .choose-button { width: 100%; margin-left: 0; }
    .batch-item { grid-template-columns: 26px minmax(0,1fr) 32px; }
    .batch-detail { grid-column: 2; grid-row: 2; }
    .batch-state-icon { grid-column: 3; grid-row: 1 / span 2; }
    .activity-table colgroup, .activity-table thead { display: none; }
    .activity-table, .activity-table tbody { display: block; }
    .activity-table tbody tr { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line); }
    .activity-table td { display: block; height: auto; padding: 6px 0; border: 0; }
    .activity-table td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
    .activity-table .empty-row { min-height: 140px; display: grid; place-items: center; }
    .activity-table .empty-row::before { display: none; }
    .invoice-cell { gap: 10px; }
    .status-cell { align-items: flex-start; }
    .audit-tools { align-items: stretch; flex-direction: column; }
    .audit-search { width: 100%; }
    .audit-table colgroup, .audit-table thead { display: none; }
    .audit-table, .audit-table tbody { display: block; }
    .audit-table tbody tr { display: block; padding: 12px; border-bottom: 1px solid var(--line); }
    .audit-table td { display: block; height: auto; padding: 5px 0; border: 0; }
    .audit-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; }
    .audit-table .empty-row::before { display: none; }
    .review-table colgroup, .review-table thead { display: none; }
    .review-table, .review-table tbody { display: block; }
    .review-table tbody tr { display: block; padding: 12px; border-bottom: 1px solid var(--line); }
    .review-table td { display: block; height: auto; padding: 6px 0; border: 0; }
    .review-table td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
    .review-table .empty-row::before { display: none; }
    .review-actions { flex-wrap: wrap; }
    .issues-table { min-width: 0; }
    .issues-table colgroup, .issues-table thead { display: none; }
    .issues-table, .issues-table tbody { display: block; }
    .issues-table tbody tr { display: block; padding: 12px; border-bottom: 1px solid var(--line); }
    .issues-table td { display: block; min-height: 0; padding: 6px 0; border: 0; }
    .issues-table td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
    .issues-table .empty-row::before { display: none; }
    .issue-metrics { grid-template-columns: 1fr 1fr; }
    .issue-metrics > div { padding: 11px 12px; }
    dialog { width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0; }
    dialog.escalation-dialog { width: calc(100vw - 24px); height: auto; border-radius: 6px; }
    .form-grid { grid-template-columns: 1fr; }
    .field.span-2, .field.span-3 { grid-column: span 1; }
    .section-row, .lines-toolbar { align-items: flex-start; flex-direction: column; }
    .audit-entry { grid-template-columns: 1fr; gap: 3px; }
    .detail-actions { align-items: stretch; flex-direction: column; }
    .action-group { width: 100%; }
    .action-group .button { flex: 1; }
}
