:root {
    color-scheme: light;
    --background: #f7f8fb;
    --foreground: #14171f;
    --muted: #687083;
    --border: #dfe3ea;
    --panel: #ffffff;
    --panel-soft: #f2f5f8;
    --primary: #176b5b;
    --primary-foreground: #ffffff;
    --warning: #9a6b10;
    --warning-soft: #fff5da;
    --danger: #b42318;
    --danger-soft: #fff0ed;
    --success: #157347;
    --success-soft: #eaf7ef;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 1.25rem;
    line-height: 1.4;
}

h1:focus,
h2:focus,
h3:focus {
    outline: none;
}

h2 {
    font-size: 1.35rem;
    line-height: 1.35;
}

h3 {
    font-size: 0.98rem;
    line-height: 1.4;
}

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 248px minmax(0, 1fr);
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: #ffffff;
    padding: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.25rem 1rem;
}

.sidebar-logo {
    display: block;
    width: 100%;
    max-width: 210px;
    height: auto;
    object-fit: contain;
}

.brand-mark-img {
    display: block;
    width: 2.35rem;
    height: 2.35rem;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-mark {
    display: grid;
    width: 2.35rem;
    height: 2.35rem;
    place-items: center;
    border-radius: 0.5rem;
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 700;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.eyebrow,
.muted,
.page-heading p,
.rule-row small {
    color: var(--muted);
}

.nav-list {
    display: grid;
    gap: 0.25rem;
    margin-top: 0.75rem;
    flex: 1;
    align-content: start;   /* rows always take natural height — never compressed */
    min-height: 0;          /* allows flex child to shrink below content size */
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-list a {
    display: flex;
    align-items: center;
    min-height: 2.4rem;
    border-radius: 0.45rem;
    color: #3b4252;
    padding: 0.62rem 0.75rem;
}

.nav-list a.active,
.nav-list a:hover {
    background: var(--panel-soft);
    color: var(--foreground);
}

.sidebar-footer {
    display: grid;
    gap: 0.65rem;
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 0.9rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.user-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.7rem;
}

.avatar {
    display: grid;
    width: 2.35rem;
    height: 2.35rem;
    place-items: center;
    border-radius: 999px;
    background: #e8f3ef;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 800;
}

.user-details {
    min-width: 0;
}

.user-details strong,
.user-details span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-details strong {
    color: var(--foreground);
    font-size: 0.9rem;
}

.user-details span {
    margin-top: 0.1rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.footer-actions span {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.footer-actions a {
    color: var(--primary);
    font-weight: 750;
}

/* Logout button styled to match the existing footer anchor */
.footer-actions .link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: var(--primary);
    font-weight: 750;
    font-size: inherit;
    font-family: inherit;
    text-decoration: none;
}

.footer-actions .link-button:hover {
    text-decoration: underline;
}

.status-dot {
    display: inline-block;
    flex: 0 0 auto;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    background: var(--success);
}

.app-main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(247, 248, 251, 0.92);
    padding: 1rem 1.25rem;
    backdrop-filter: blur(12px);
}

.eyebrow {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar-actions,
.action-row,
.dashboard-actions,
.range-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dashboard-actions {
    align-items: center;
    justify-content: flex-end;
}

.queue-toolbar,
.archive-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.queue-toolbar label,
.archive-toolbar label {
    display: grid;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
}

.range-picker {
    align-items: flex-end;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    padding: 0.45rem;
}

.range-picker label {
    display: grid;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
}

.pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #ffffff;
    color: #3b4252;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 650;
    white-space: nowrap;
}

.pill.healthy,
.status-badge.success {
    border-color: #b8e0c8;
    background: var(--success-soft);
    color: var(--success);
}

.content-frame {
    padding: 1.25rem;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: #ffffff;
    color: var(--foreground);
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-weight: 650;
}

.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
}

.button.compact {
    min-height: 1.9rem;
    padding: 0.25rem 0.55rem;
    font-size: 0.82rem;
}

/* Align Search/Clear buttons to the same height as .search-input
   inside any toolbar. The input has min-height 2.35rem; this ensures
   toolbar buttons match without affecting compact buttons elsewhere. */
.queue-toolbar .button,
.archive-toolbar .button,
.toolbar-action-group .button {
    min-height: 2.35rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

/* Keeps Search + Clear together as one flex unit so they never separate on wrap */
.toolbar-action-group {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.button.danger {
    border-color: #f4b7b0;
    color: var(--danger);
}

.button.success {
    border-color: #b8e0c8;
    background: var(--success-soft);
    color: var(--success);
}

.button.success:hover {
    background: #d4f0e0;
    border-color: #8ecfaf;
}

.search-input,
.range-select,
.page-size-select,
.date-input,
.field-grid input,
.field-grid select,
.field-grid textarea,
.training-items-table input {
    min-height: 2.35rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: #ffffff;
    color: var(--foreground);
    padding: 0.5rem 0.7rem;
}

.field-grid textarea {
    resize: vertical;
}

.system-prompt-textarea {
    min-height: 34rem;
    line-height: 1.55;
}

.prompt-note {
    margin-top: 0.9rem;
}

.range-select {
    min-width: 10rem;
}

.page-size-select {
    min-width: 6rem;
}

.date-input {
    width: 9.8rem;
}

.search-input {
    width: min(100%, 22rem);
}

.range-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: -0.35rem 0 0.85rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.range-summary strong {
    color: var(--foreground);
}

.range-summary span {
    color: #3b4252;
}

.review-position {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.55rem;
}

.review-position a {
    color: var(--primary);
    font-size: 0.86rem;
    font-weight: 750;
}

.queue-meta,
.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.queue-meta {
    margin-bottom: 0.75rem;
}

.queue-meta strong,
.pagination-bar strong {
    color: var(--foreground);
}

.queue-group {
    display: grid;
    gap: 0.55rem;
    margin-bottom: 0.85rem;
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.empty-state {
    border: 1px dashed var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    padding: 1.25rem;
}

.empty-state p {
    margin-top: 0.25rem;
    color: var(--muted);
}

.pagination-bar {
    justify-content: flex-end;
    margin-top: 0.75rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.jobs-kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.kpi-card,
.panel,
.pdf-panel {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--panel);
}

.kpi-card {
    display: grid;
    gap: 0.35rem;
    min-height: 6rem;
    padding: 0.9rem;
}

.kpi-card span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
}

.kpi-card strong {
    font-size: 1.75rem;
    line-height: 1.1;
}

.kpi-card.success {
    background: var(--success-soft);
}

.kpi-card.warning {
    background: var(--warning-soft);
}

.kpi-card.danger {
    background: var(--danger-soft);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 0.8fr 1.1fr 1.1fr;
    gap: 0.75rem;
}

.panel,
.pdf-panel {
    padding: 0.9rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.panel-header a {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.86rem;
}

.reason-list,
.activity-list,
.alert-list,
.rule-list {
    display: grid;
    gap: 0.55rem;
}

.reason-row,
.activity-row,
.alert-row,
.rule-row {
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: #ffffff;
}

.reason-row {
    display: flex;
    justify-content: space-between;
    padding: 0.65rem 0.75rem;
}

.activity-row,
.alert-row,
.rule-row {
    padding: 0.65rem 0.75rem;
}

.job-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.activity-row span,
.alert-row span {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.activity-row p,
.alert-row p,
.rule-row p {
    margin-top: 0.18rem;
    color: #3b4252;
    font-size: 0.9rem;
}

.activity-row small {
    color: var(--muted);
    font-size: 0.75rem;
}

/* ── Structured audit-trail row (spec018) ───────────────────────────────── */
.activity-row-inner {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}

.activity-row-inner > .status-badge {
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.activity-row-body {
    flex: 1;
    min-width: 0;
}

.activity-event {
    display: block;
    color: var(--foreground);
    font-size: 0.88rem;
    font-weight: 650;
}

.activity-detail {
    margin-top: 0.18rem;
    color: #3b4252;
    font-size: 0.85rem;
}

.activity-row-meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.18rem;
}

.activity-actor {
    color: var(--muted);
    font-size: 0.78rem;

/* ── Dashboard activity row ──────────────────────────────────────────────── */
.activity-row-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
}

.activity-event-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--foreground);
}

.activity-row-meta {
    font-size: 0.82rem;
    margin-bottom: 0.15rem;
}

.activity-lpo-link {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary, #1e6f4f);
    text-decoration: none;
}

.activity-lpo-link:hover {
    text-decoration: underline;
}

.activity-row-detail {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0.1rem 0 0.25rem;
    line-height: 1.4;
}

.activity-row-footer {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}
    font-weight: 600;
}

/* Day-section heading inside the audit trail */
.activity-list h4 {
    margin: 0.75rem 0 0.35rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.activity-list h4:first-child {
    margin-top: 0;
}

.alert-row.critical {
    border-color: #f4b7b0;
    background: var(--danger-soft);
}

.alert-row.warning {
    border-color: #ead08d;
    background: var(--warning-soft);
}

.alert-row.success {
    border-color: #b8e0c8;
    background: var(--success-soft);
}

.table-shell {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--panel);
}

.table-shell.embedded {
    margin: 0.6rem 0 1rem;
}

/* ---- Line-item table (Excel-like, grouped by ship-to) ---- */
.lineitem-table {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.li-group {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--panel);
}

.li-group-head {
    padding: 0.6rem 0.75rem;
    background: var(--panel-soft);
    border-bottom: 1px solid var(--border);
}

.li-group-head label {
    display: block;
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.li-group-head textarea,
.li-group-head input[type="text"],
.li-group-head input:not([type]) {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.45rem 0.6rem;
    color: var(--foreground);
    font-size: 0.85rem;
    resize: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.li-group-head textarea:focus,
.li-group-head input[type="text"]:focus,
.li-group-head input:not([type]):focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.li-group-address {
    font-size: 0.85rem;
    color: var(--foreground);
}

.li-scroll {
    overflow-x: auto;
}

.li-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.li-table th,
.li-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    text-align: left;
    vertical-align: middle;
}

.li-table th {
    background: var(--panel-soft);
    color: #3b4252;
    font-size: 0.72rem;
    font-weight: 750;
}

.li-table td {
    font-size: 0.85rem;
}

.li-table tbody tr:last-child td {
    border-bottom: 0;
}

.li-num {
    width: 2.5rem;
    text-align: center;
    color: var(--muted);
    font-weight: 650;
}

.col-extracted {
    min-width: 180px;
}

.col-erp {
    min-width: 100px;
}

.col-qty {
    width: 7rem;
}

.col-unit {
    width: 7rem;
}

.col-confidence {
    width: 6rem;
}

.col-issue {
    min-width: 100px;
}

.mono {
    font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
    font-size: 0.82rem;
}

/* Always-visible inputs inside the li-table cells */
.li-table td input,
.li-table td textarea {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    color: var(--foreground);
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.li-table td textarea {
    resize: none;
    overflow: hidden;
    min-height: 1.8rem;
    line-height: 1.35;
    field-sizing: content;
}

.li-table td input:focus,
.li-table td textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.li-table td input[type="number"] {
    text-align: right;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 840px;
}

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 0.72rem 0.8rem;
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--panel-soft);
    color: #3b4252;
    font-size: 0.78rem;
    font-weight: 750;
}

td {
    font-size: 0.88rem;
}

tbody tr:last-child td {
    border-bottom: 0;
}

/* ── Inline edit row highlight ───────────────────────────────────────────── */
tr.is-editing > td {
    background-color: rgba(23, 107, 91, 0.05);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    vertical-align: middle;
}

tr.is-editing > td:first-child {
    border-left: 3px solid var(--primary);
    padding-left: calc(0.8rem - 3px);
}

tr.is-editing input {
    display: block;
    width: 100%;
    min-height: 2.2rem;
    border: 1px solid var(--primary);
    border-radius: 0.4rem;
    background: #ffffff;
    color: var(--foreground);
    padding: 0.4rem 0.65rem;
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
    font: inherit;
    transition: box-shadow 0.15s ease;
}

tr.is-editing input:focus {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}

.edit-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.review-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
    gap: 0.9rem;
}

/* Right column wrapper: stacks the inherited badge above the override panel */
.override-column {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}

/* Amber "Inherited from parent" badge shown above the override editor */
.inherited-badge {
    align-self: flex-start;
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* Child-count pill shown next to a parent template's key in the hierarchy tree */
.child-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    background: var(--primary, #176b5b);
    color: #ffffff;
    vertical-align: middle;
}

.pdf-panel img {
    display: block;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    background: #ffffff;
}

.demo-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.extraction-demo-shell {
    display: grid;
    grid-template-columns: minmax(220px, 0.55fr) minmax(360px, 1fr) minmax(360px, 1.05fr);
    gap: 0.8rem;
    align-items: stretch;
    min-height: calc(100vh - 15rem);
}

.demo-list-panel,
.demo-pdf-panel,
.demo-compare-panel {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--panel);
    padding: 0.75rem;
}

.demo-list-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.7rem;
}

.demo-toolbar {
    display: grid;
    gap: 0.6rem;
}

.demo-toolbar label {
    display: grid;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
}

.demo-toolbar input[type="text"],
.demo-toolbar input:not([type]) {
    width: 100%;
}

.checkbox-row {
    display: inline-flex !important;
    grid-template-columns: auto;
    align-items: center;
    gap: 0.45rem !important;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.checkbox-row input {
    width: auto;
}

.demo-file-list {
    display: grid;
    align-content: start;
    gap: 0.35rem;
    overflow: auto;
    padding-right: 0.2rem;
}

.demo-file-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.3rem 0.55rem;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: #ffffff;
    padding: 0.55rem;
    text-align: left;
    cursor: pointer;
}

.demo-file-row.active {
    border-color: #92cabb;
    background: #eef8f5;
}

.demo-file-row strong,
.demo-file-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.demo-file-row small {
    color: var(--muted);
    font-size: 0.74rem;
}

.score-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.65rem;
    border-radius: 999px;
    padding: 0.18rem 0.55rem;
    font-size: 0.76rem;
    font-weight: 800;
    white-space: nowrap;
}

.score-pill.good {
    background: var(--success-soft);
    color: var(--success);
}

.score-pill.ok {
    background: var(--warning-soft);
    color: var(--warning);
}

.score-pill.bad {
    background: var(--danger-soft);
    color: var(--danger);
}

.demo-pdf-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.demo-pdf-panel iframe {
    width: 100%;
    height: 100%;
    min-height: 46rem;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    background: #ffffff;
}

.demo-compare-panel {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0.65rem;
}

.compare-header,
.compare-tabs,
.compare-metrics {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.compare-header {
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.65rem;
}

.compare-header h3,
.compare-header p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compare-tabs {
    flex-wrap: wrap;
}

.field-stack,
.json-stack {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.7rem;
    min-height: 0;
}

.json-stack {
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}

.compare-table-panel,
.mismatch-preview-panel,
.json-panel {
    min-height: 0;
    overflow: hidden;
}

.mismatch-preview-panel .table-shell {
    max-height: 13rem;
    overflow: auto;
}

.compare-table-panel .table-shell {
    max-height: 20rem;
    overflow: auto;
}

.mismatch-preview-panel table,
.compare-table-panel table {
    min-width: 0;
}

.mismatch-preview-panel th,
.mismatch-preview-panel td,
.compare-table-panel th,
.compare-table-panel td {
    padding: 0.45rem 0.55rem;
    font-size: 0.78rem;
    vertical-align: top;
}

.mismatch-row td {
    background: var(--danger-soft);
}

.match-row td {
    background: #ffffff;
}

.json-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.json-panel pre {
    overflow: auto;
    min-height: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    background: #101820;
    color: #f4f7fb;
    padding: 0.75rem;
    font-size: 0.76rem;
    line-height: 1.45;
}

.review-panel {
    min-width: 0;
}

.review-panel h3 {
    margin-top: 1rem;
}

.review-panel > h3:first-child,
.review-panel > .field-grid + h3 {
    margin-top: 1.1rem;
}

/* Space above the view-toggle (JSON expand button) in the audit trail */
.review-panel .view-toggle {
    margin-top: 0.75rem;
}

/* ── Inline action error banner (below header action buttons) ───────────── */
.action-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.action-col .alert-row {
    max-width: 28rem;
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.alert-dismiss {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0 0.15rem;
    margin: 0;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    color: inherit;
    opacity: 0.65;
    font-family: inherit;
}

.alert-dismiss:hover {
    opacity: 1;
}

/* Inline action success banner (below header action buttons) */
.action-success-banner {
    max-width: 28rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #b8e0c8;
    border-radius: 0.45rem;
    background: var(--success-soft);
    color: var(--success);
    font-size: 0.85rem;
    font-weight: 650;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.field-grid.single {
    grid-template-columns: 1fr;
    margin-top: 0.75rem;
}

.field-grid label {
    display: grid;
    gap: 0.32rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.field-grid input {
    width: 100%;
    color: var(--foreground);
}

.field-grid select,
.field-grid textarea {
    width: 100%;
    color: var(--foreground);
}

.field-grid .wide {
    grid-column: 1 / -1;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
    gap: 0.75rem;
}

/* System prompt page: single-column so the textarea uses the full card width */
.system-prompt-grid {
    grid-template-columns: 1fr;
}

.rule-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.editable-rule {
    align-items: stretch;
}

.row-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.rule-editor {
    margin-bottom: 0.85rem;
}

.rule-edit-fields {
    width: 100%;
}

.rule-form-grid {
    grid-template-columns: minmax(14rem, 0.8fr) minmax(22rem, 1.5fr) auto;
    align-items: end;
}

.user-form-grid {
    grid-template-columns: minmax(12rem, 1fr) minmax(16rem, 1.2fr) minmax(10rem, 0.75fr) auto;
    align-items: end;
}

.rule-form-grid .wide {
    grid-column: auto;
}

.check-field,
.field-grid label.check-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.35rem;
    color: var(--foreground) !important;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}

.check-field input,
.field-grid label.check-field input {
    width: auto;
    min-height: auto;
    flex-shrink: 0;
    margin: 0;
}

.form-actions {
    margin-top: 0.75rem;
}

.user-editor {
    margin-bottom: 0.85rem;
}

.training-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.05fr);
    gap: 0.9rem;
    align-items: start;
}

.training-upload-panel {
    display: grid;
    gap: 0.75rem;
}

.upload-zone {
    display: grid;
    gap: 0.3rem;
    border: 1px dashed var(--border);
    border-radius: 0.5rem;
    background: var(--panel-soft);
    padding: 0.9rem;
    cursor: pointer;
}

.upload-zone span {
    color: var(--foreground);
    font-weight: 750;
}

.upload-zone small {
    color: var(--muted);
}

.file-input {
    min-height: auto;
    border: 0;
    padding: 0.35rem 0 0;
}

.pdf-frame,
.pdf-placeholder {
    width: 100%;
    min-height: 54rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
}

.pdf-placeholder {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.35rem;
    padding: 1.25rem;
    text-align: center;
}

.pdf-placeholder p {
    max-width: 20rem;
    color: var(--muted);
}

.training-editor {
    display: grid;
    gap: 0.85rem;
}

.training-editor h3 {
    margin-top: 0.35rem;
}

.training-items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.training-items-table table {
    min-width: 1060px;
}

.training-items-table input {
    width: 100%;
    color: var(--foreground);
}

.jobs-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.jobs-section {
    margin-bottom: 0.75rem;
}

.jobs-section-header {
    margin-bottom: 1rem;
}

.jobs-section-header p {
    margin-top: 0.2rem;
    margin-bottom: 0;
}

.job-card-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.job-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

.compact-table table {
    min-width: 640px;
}

.toast-message {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    max-width: 24rem;
    border: 1px solid #b8e0c8;
    border-radius: 0.5rem;
    background: var(--success-soft);
    color: var(--success);
    padding: 0.75rem 1rem;
    font-weight: 700;
    z-index: 20;
}

.auth-main {
    display: grid;
    min-height: 100vh;
    background: #f3f4f6;
    padding: 1.25rem;
}

.login-shell {
    display: grid;
    min-height: 100%;
    place-items: center;
}

.login-panel {
    display: grid;
    width: min(100%, 430px);
    gap: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--panel);
    padding: 2.75rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.login-logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.75rem;
}

.login-logo {
    display: block;
    max-width: 220px;
    width: 100%;
    height: auto;
    background: transparent;
    mix-blend-mode: multiply;
}

.login-console-label {
    font-size: 0.75rem;
    font-variant: small-caps;
    letter-spacing: 0.1em;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 600;
}

.login-panel p {
    margin-top: 0.3rem;
    color: var(--muted);
}

.login-actions {
    justify-content: stretch;
}

.login-actions .button {
    width: 100%;
}

.permission-group {
    margin-bottom: 0.85rem;
}

.permission-group .eyebrow {
    display: block;
    margin-bottom: 0.45rem;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.35rem 1rem;
}

/* ── Permission / role assignment modal ─────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1rem;
    background: rgba(20, 23, 31, 0.45);
    overflow-y: auto;
}

.modal-panel {
    width: min(100%, 52rem);
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--panel);
    padding: 1.1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
}

/* ── ConfirmDialog — narrower variant of modal-panel ────────────────── */
.modal-panel.confirm-dialog {
    width: min(100%, 26rem);
}

.confirm-dialog-body {
    padding: 0.75rem 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ── W4: System-role badge ───────────────────────────────────────────── */
.pill.system-role {
    border-color: #c9d4e8;
    background: #eef1f8;
    color: #3b4a6b;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

/* ── W4: Tooltip ─────────────────────────────────────────────────────── */
.has-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #1e2330;
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 500;
    padding: 0.3rem 0.55rem;
    border-radius: 0.35rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
    z-index: 100;
}

.has-tooltip:hover::after,
.has-tooltip:focus-within::after {
    opacity: 1;
}

/* ── W4: Inline field validation hints ──────────────────────────────── */
.field-hint {
    display: block;
    margin-top: 0.28rem;
    font-size: 0.76rem;
    color: var(--danger);
    font-weight: 500;
}

.field-hint.info {
    color: var(--muted);
}

input.field-error,
textarea.field-error {
    border-color: var(--danger) !important;
    outline-color: var(--danger);
}

/* ── W4: Permission assignment diff summary ─────────────────────────── */
.permission-diff {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    background: var(--panel-soft);
    font-size: 0.82rem;
    margin-top: 0.75rem;
}

.permission-diff .diff-added {
    color: var(--success);
    font-weight: 650;
}

.permission-diff .diff-removed {
    color: var(--danger);
    font-weight: 650;
}

.permission-diff .diff-total {
    color: var(--muted);
    margin-left: auto;
}

/* ── W4: Success inline feedback ─────────────────────────────────────── */
.inline-success {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--success);
}

/* ── Sortable column headers ───────────────────────────────────────────────── */
th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:hover {
    background: #e4e8ef;
}

th.sortable.sort-active {
    color: var(--primary);
}

.sort-icon {
    display: inline-block;
    margin-left: 0.3rem;
    font-size: 0.68rem;
    opacity: 0.35;
    vertical-align: middle;
}

th.sortable.sort-active .sort-icon {
    opacity: 1;
}

#blazor-error-ui {
    color-scheme: light only;
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: none;
    width: min(30rem, calc(100vw - 2rem));
    border: 1px solid var(--danger);
    border-radius: 0.5rem;
    background: var(--danger-soft);
    color: var(--danger);
    padding: 0.75rem 1rem;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    float: right;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .kpi-grid,
    .demo-kpis,
    .jobs-kpi-grid,
    .dashboard-grid,
    .extraction-demo-shell,
    .review-grid,
    .training-grid,
    .jobs-grid,
    .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell,
    .kpi-grid,
    .demo-kpis,
    .jobs-kpi-grid,
    .dashboard-grid,
    .extraction-demo-shell,
    .review-grid,
    .training-grid,
    .jobs-grid,
    .settings-grid,
    .field-grid,
    .rule-form-grid,
    .user-form-grid {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: relative;
        height: auto;
    }

    .topbar,
    .page-heading,
    .dashboard-actions,
    .range-picker,
    .queue-toolbar,
    .archive-toolbar,
    .queue-meta,
    .pagination-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .range-picker,
    .range-select,
    .page-size-select,
    .queue-toolbar,
    .archive-toolbar,
    .date-input {
        width: 100%;
    }

    .content-frame {
        padding: 1rem;
    }

    .demo-pdf-panel iframe {
        min-height: 32rem;
    }
}

/* ── Auth initialization loading screen ─────────────────────────────────── */
/* Shown by Routes.razor while ProtectedLocalStorage is being read.          */
/* Replaced by the router once token restoration completes.                  */
.auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    min-height: 100vh;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
}

.auth-loading-spinner {
    display: inline-block;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

/* Reusable inline spinner — used by LoadingPlaceholder and other components */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
    flex-shrink: 0;
}

/* LoadingPlaceholder wrapper */
.loading-placeholder {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.5rem 0;
    color: var(--muted);
    font-size: 0.9rem;
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

/* ──────────────────────────────────────────────────────────────────────────
   spec014 — Template Review / Dry-Run UI
   Built on the existing design tokens (--border, --panel, --primary, …).
   ────────────────────────────────────────────────────────────────────────── */

/* Draft badge variant (success variant already exists) */
.status-badge.warning {
    border-color: #f0d9a8;
    background: var(--warning-soft);
    color: var(--warning);
}
.status-badge.error {
    border-color: #f4b7b0;
    color: var(--danger);
    background-color: var(--danger-soft);
}

/* Template identity strip */
.template-identity-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--panel);
    padding: 0.8rem 1rem;
    margin-bottom: 0.9rem;
}

.template-identity-bar .identity-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 1.5rem;
}

.template-identity-bar .identity-fields .label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-right: 0.3rem;
}

.template-identity-bar .identity-fields strong {
    color: var(--foreground);
    font-size: 0.95rem;
    margin-right: 0.4rem;
}

.template-identity-bar .identity-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.template-identity-bar .parked-count {
    color: var(--muted);
    font-size: 0.82rem;
}

/* ── Template identity bar — edit mode ──────────────────────────────────── */

.tib-edit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.tib-edit-row .label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    margin-right: 0.25rem;
}

/* Search input + dropdown container */
.tib-search-wrap {
    position: relative;
    flex: 1 1 260px;
    max-width: 400px;
}

.tib-search-input {
    width: 100%;
    min-height: 2rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: #ffffff;
    color: var(--foreground);
    padding: 0.4rem 0.65rem;
    font: inherit;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.tib-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(23,107,91,0.12);
}

/* Dropdown list */
.tib-dropdown {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.10);
    max-height: 280px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0.3rem 0;
}

.tib-option {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.87rem;
    border-bottom: 1px solid var(--panel-soft);
}

.tib-option:last-child {
    border-bottom: none;
}

.tib-option:hover,
.tib-option-active {
    background: var(--panel-soft);
}

.tib-option-name {
    font-weight: 600;
    color: var(--foreground);
}

.tib-option-key {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: ui-monospace, monospace;
}

.tib-draft-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    min-height: unset;
}

.tib-no-results {
    padding: 0.6rem 0.8rem;
    font-size: 0.84rem;
    color: var(--muted);
    font-style: italic;
}

/* Selected chip shown next to the input after picking */
.tib-selected-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    background: var(--success-soft);
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    padding: 0.25rem 0.55rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--success);
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Error shown below the edit row */
.tib-error {
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.82rem;
    color: var(--danger);
    padding: 0.3rem 0.5rem;
    background: var(--danger-soft);
    border-radius: 0.35rem;
}

/* Override editor panel */
.override-panel {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.override-panel h4 {
    margin: 0;
    font-size: 0.95rem;
}

/* Inherit / Use own radio toggle */
.override-source-toggle {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: var(--panel-soft);
    font-size: 0.875rem;
}

.override-source-toggle label {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: var(--foreground);
    margin: 0;
}

.override-source-toggle input[type="radio"] {
    accent-color: var(--primary);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}

.override-panel .inherited-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
}

.override-panel textarea {
    width: 100%;
    min-height: 9rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: #ffffff;
    padding: 0.6rem 0.7rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.85rem;
    line-height: 1.4;
    resize: vertical;
}

.override-panel textarea[readonly] {
    background: var(--panel-soft);
    color: var(--muted);
    cursor: default;
    opacity: 0.85;
}

.override-panel .form-actions {
    justify-content: flex-start;
}

/* Extracted data panel */
.extracted-data-panel {
    margin-top: 0.4rem;
    border-top: 1px solid var(--border);
    padding-top: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

/* Grid / JSON segmented toggle */
.view-toggle {
    display: inline-flex;
    gap: 0;
}

.view-toggle .button {
    border-radius: 0;
}

.view-toggle .button:first-child {
    border-top-left-radius: 0.45rem;
    border-bottom-left-radius: 0.45rem;
}

.view-toggle .button:last-child {
    border-top-right-radius: 0.45rem;
    border-bottom-right-radius: 0.45rem;
    border-left: none;
}

/* Confidence + paginator row */
.confidence-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: var(--panel-soft);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.confidence-bar strong {
    color: var(--foreground);
}

.confidence-bar .po-paginator {
    margin-left: auto;
}

/* PO paginator */
.po-paginator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--foreground);
}

/* Read-only JSON view */
.json-view {
    margin: 0;
    max-height: 26rem;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: var(--panel-soft);
    padding: 0.7rem 0.85rem;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.8rem;
    line-height: 1.45;
    white-space: pre;
}

/* Breadcrumb above the review page */
.review-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.review-breadcrumb a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.review-breadcrumb a:hover {
    text-decoration: underline;
}

/* ── spec014 — Dry-run read-only display ──────────────────────────────────── */

/* PO header: two-column grid of label/value pairs */
.dry-run-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.dry-run-field {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.dry-run-field .label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.dry-run-field > span:last-child {
    font-size: 0.9rem;
    color: var(--foreground);
    font-weight: 500;
    word-break: break-word;
}

/* Ship-to group wrapper */
.dry-run-ship-group {
    margin-top: 0.6rem;
}

/* Ship-to group header banner */
.ship-group-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 0.4rem 0.4rem 0 0;
    border-bottom: none;
    padding: 0.45rem 0.75rem;
}

.ship-group-icon {
    font-size: 0.9rem;
}

.ship-group-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--foreground);
}

/* Table inherits .lineitem-table top border from the group header */
.dry-run-ship-group .lineitem-table {
    border-top: none;
}

.dry-run-ship-group .li-table {
    border-top: 1px solid var(--border);
    border-radius: 0 0 0.4rem 0.4rem;
}

/* Description column — allow wrap for long names */
.li-table td.dry-run-desc {
    white-space: normal;
    min-width: 140px;
    max-width: 260px;
}

/* Line Total — bold, right-aligned */
.li-table td.dry-run-total {
    font-weight: 600;
    text-align: right;
    padding-right: 0.5rem;
}

/* ── Template Review Page — Edit Properties, Reference Upload, Detection ── */

/* Left column wrapper (PDF + ref-file panel stacked) */
.trev-left-col {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-width: 0;
}

/* Edit Properties toggle button row */
.trev-edit-toggle {
    margin-bottom: 0.5rem;
}

/* Edit Properties panel */
.trev-properties-panel {
    margin-bottom: 0.9rem;
}

/* Reference document panel */
.trev-ref-panel {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.trev-ref-panel h4 {
    margin: 0;
    font-size: 0.95rem;
}

.trev-ref-current {
    margin: 0;
    font-size: 0.87rem;
    color: var(--foreground);
}

.trev-file-label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.trev-file-input {
    font-size: 0.85rem;
    color: var(--foreground);
    border: 1px dashed var(--border);
    border-radius: 0.45rem;
    padding: 0.45rem 0.6rem;
    background: var(--panel-soft);
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.trev-file-input:hover {
    border-color: var(--primary);
    background: var(--panel);
}

.trev-selected-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--foreground);
    padding: 0.3rem 0.5rem;
    background: var(--panel-soft);
    border-radius: 0.4rem;
    border: 1px solid var(--border);
}

/* Detection panel */
.trev-detect-panel {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.trev-detect-panel h4 {
    margin: 0;
    font-size: 0.95rem;
}

.trev-detect-hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

/* Detection result container */
.trev-detect-result {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.3rem;
    border-top: 1px solid var(--border);
    padding-top: 0.7rem;
}

/* Signal rows */
.trev-detect-signals {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.trev-detect-row {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: 0.5rem;
    font-size: 0.85rem;
    align-items: baseline;
}

.trev-detect-markers {
    align-items: start;
}

.trev-detect-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--muted);
    white-space: nowrap;
}

/* Resolution outcome banner */
.trev-detect-resolution {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.45rem;
    font-size: 0.87rem;
    border: 1px solid var(--border);
}

.trev-detect-resolution > div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.trev-detect-ok {
    background: var(--success-soft);
    border-color: #b8e0c8;
    color: var(--success);
}

.trev-detect-warn {
    background: var(--warning-soft);
    border-color: #ead08d;
    color: var(--warning);
}

.trev-detect-fail {
    background: var(--danger-soft);
    border-color: #f4b7b0;
    color: var(--danger);
}

.trev-detect-icon {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.4;
}

.trev-detect-key {
    font-size: 0.78rem;
    font-family: ui-monospace, monospace;
    color: var(--muted);
}

/* Shared error / success inline rows */
.trev-error-row {
    font-size: 0.82rem;
    color: var(--danger);
    padding: 0.3rem 0.5rem;
    background: var(--danger-soft);
    border-radius: 0.35rem;
    border: 1px solid #f4b7b0;
}

.trev-success-row {
    font-size: 0.82rem;
    color: var(--success);
    padding: 0.3rem 0.5rem;
    background: var(--success-soft);
    border-radius: 0.35rem;
    border: 1px solid #b8e0c8;
}

/* ── Template Detection — raw JSON collapsible ───────────────────────────── */

.trev-detect-raw {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
}

.trev-detect-raw-toggle {
    align-self: flex-start;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.01em;
}

.trev-detect-raw-toggle:hover {
    text-decoration: underline;
}

.trev-detect-raw-pre {
    margin: 0;
    padding: 0.65rem 0.75rem;
    background: #101820;
    color: #f4f7fb;
    border-radius: 0.4rem;
    border: 1px solid var(--border);
    font-family: ui-monospace, "SF Mono", monospace;
    font-size: 0.76rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 20rem;
    overflow-y: auto;
}

/* No-file notice on template review page */
.trev-no-file-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 8rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.88rem;
    border: 2px dashed var(--border);
    background: var(--panel-soft);
}

/* Simulate-as-verified checkbox row */
.trev-simulate-label {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--foreground);
    cursor: pointer;
    margin-bottom: 0.3rem;
}

.trev-simulate-hint {
    font-weight: 400;
    color: var(--muted);
    font-size: 0.78rem;
}

/* ── Reject LPO modal ────────────────────────────────────────────────────── */
.reject-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    background: rgba(20, 23, 31, 0.45);
    backdrop-filter: blur(2px);
}

.reject-modal {
    width: min(100%, 28rem);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--panel);
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: grid;
    gap: 0.75rem;
}

.reject-modal h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--foreground);
}

.reject-modal p {
    color: var(--muted);
    font-size: 0.88rem;
}

.reject-modal textarea {
    width: 100%;
    min-height: 5rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: #ffffff;
    color: var(--foreground);
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 0.88rem;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.reject-modal textarea:focus {
    outline: none;
    border-color: var(--danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent);
}

.reject-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ── Multi-PO banner ─────────────────────────────────────────────────────── */
/*
 * Sits ABOVE the review-grid (outside it) so it's always full-width and
 * never disturbs the two-column PDF/panel layout.
 */
.multi-po-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: var(--info-soft, #e8f4fd);
    border: 1px solid var(--info-border, #b3d7f5);
    border-radius: var(--radius, 6px);
    font-size: 0.875rem;
    color: var(--foreground);
    margin-bottom: 0.75rem;
    min-height: 2.5rem;
}

.multi-po-banner .multi-po-icon {
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1;
}

.multi-po-banner .multi-po-label {
    flex-shrink: 0;
    color: var(--muted);
    white-space: nowrap;
}

.multi-po-banner .multi-po-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

/*
 * All pills share identical geometry — height, padding, border-width, font-weight.
 * Only colour changes between current and sibling so the pill never resizes.
 */
.multi-po-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    height: 1.875rem;        /* fixed — same for current and sibling */
    border-radius: 99px;
    border: 2px solid var(--border, #d0d5dd);  /* 2px on ALL pills — never changes */
    background: var(--surface, #fff);
    font-size: 0.8rem;
    font-weight: normal;     /* same weight — no reflow when switching */
    white-space: nowrap;
    text-decoration: none;
    color: var(--foreground);
    transition: background 0.15s, border-color 0.15s;
    box-sizing: border-box;
}

/* Current pill: change colour only — no size changes */
.multi-po-pill.current {
    background: var(--primary-soft, #dbeafe);
    border-color: var(--primary, #3b82f6);
}

/* Sibling hover: colour only */
.multi-po-pill:not(.current):hover {
    background: var(--hover, #f0f4ff);
    border-color: var(--primary, #3b82f6);
    text-decoration: none;
}

/*
 * Fixed-width dot indicator — replaces ●/○ characters which have different
 * glyph widths across fonts and cause the text to shift left/right.
 * Current = filled primary; sibling = hollow grey.
 */
.multi-po-dot {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--border, #d0d5dd);      /* sibling default: grey hollow look */
    border: 2px solid var(--border, #d0d5dd);
    box-sizing: border-box;
    transition: background 0.15s, border-color 0.15s;
}

.multi-po-pill.current .multi-po-dot {
    background: var(--primary, #3b82f6);     /* current: filled blue */
    border-color: var(--primary, #3b82f6);
}

.multi-po-pill:not(.current) .multi-po-dot {
    background: transparent;                 /* sibling: hollow */
    border-color: var(--muted, #aaa);
}

.multi-po-status {
    color: var(--muted, #888);
    font-size: 0.76rem;
}

/* ── Action-row: stable width so buttons never shift position ────────────── */
/*
 * visibility:hidden placeholder buttons keep the row width constant.
 * The row must NOT use flex-wrap so ghost buttons don't land on a new line.
 */
.action-row {
    flex-wrap: nowrap;
}
