:root {
  --paper: #eee4ce;
  --paper-light: #fbf4e3;
  --paper-deep: #dfd2b8;
  --ink: #1b1c18;
  --muted: #66695f;
  --coral: #ee6b62;
  --coral-dark: #cb4f49;
  --green: #287557;
  --green-soft: #cce1c8;
  --blue: #d8e5eb;
  --yellow: #f1d98f;
  --red-soft: #f3c5be;
  --line: #262721;
  --shadow: 4px 4px 0 var(--line);
  --font: MiSans, "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}
button, input, select { font: inherit; }
a { color: inherit; }
.skip-link { position: fixed; top: -60px; left: 12px; z-index: 1000; padding: 8px 12px; background: var(--ink); color: #fff; }
.skip-link:focus { top: 12px; }

.retro-shell { width: min(1560px, calc(100% - 48px)); min-height: calc(100vh - 48px); margin: 24px auto; background: var(--paper-light); border: 2px solid var(--line); box-shadow: 7px 7px 0 rgba(27,28,24,.18); }
.retro-header { min-height: 72px; display: grid; grid-template-columns: minmax(190px, 1fr) auto; align-items: center; gap: 24px; padding: 10px 26px; border-bottom: 2px solid var(--line); }
.brand { display: inline-flex; width: fit-content; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; background: var(--coral); border: 2px solid var(--line); box-shadow: 3px 3px 0 var(--line); font-size: 20px; font-weight: 900; line-height: 1; }
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 16px; font-weight: 850; letter-spacing: -.03em; }
.brand-copy small { margin-top: -1px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--blue); font-size: 13px; font-weight: 900; }
.retro-main { width: min(1460px, calc(100% - 64px)); margin: 0 auto; padding: 38px 0 56px; }

.retro-version-switcher { position: relative; z-index: 80; width: 172px; }
.retro-version-switcher summary { display: flex; min-height: 42px; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 2px; background: var(--coral); box-shadow: 3px 3px 0 var(--line); cursor: pointer; list-style: none; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.retro-version-switcher summary::-webkit-details-marker { display: none; }
.retro-version-switcher summary:hover { transform: translate(-1px, -1px); background: #f1786f; box-shadow: 4px 4px 0 var(--line); }
.retro-version-switcher summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.retro-version-switcher summary span { font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.retro-version-switcher summary strong { font-size: 11px; font-weight: 900; }
.retro-version-menu { position: absolute; top: calc(100% + 10px); right: 0; display: grid; width: 100%; gap: 7px; padding: 9px; border: 1.5px solid var(--line); border-radius: 2px; background: var(--paper-light); box-shadow: 4px 4px 0 var(--line); }
.retro-version-menu a { display: flex; min-height: 43px; flex-direction: column; justify-content: center; padding: 7px 9px; border: 1.5px solid var(--line); border-radius: 1px; background: #fff9eb; color: var(--ink); text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.retro-version-menu a:hover { transform: translate(-1px, -1px); background: var(--yellow); box-shadow: 2px 2px 0 var(--line); }
.retro-version-menu a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.retro-version-menu a span { font-size: 11px; font-weight: 850; }
.retro-version-menu a small { margin-top: 1px; color: var(--muted); font-size: 8px; font-weight: 650; }

.hero { max-width: 800px; margin: 0 auto 34px; text-align: center; }
.hero-kicker { display: inline-block; margin-bottom: 10px; padding: 4px 8px; border: 1px solid var(--line); background: var(--yellow); font-size: 10px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(34px, 5vw, 58px); font-weight: 850; letter-spacing: -.065em; line-height: 1.05; }
.hero p { max-width: 620px; margin: 12px auto 0; color: var(--muted); font-size: 14px; }
.hero-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 16px; }
.meta-label, .status-label { padding: 5px 9px; border: 1px solid #8b8577; background: transparent; color: #4f5048; font-size: 11px; font-weight: 700; }
.status-label { border-color: #6f8d76; background: #e0ebdc; color: #315b46; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 20px; font-weight: 850; letter-spacing: -.035em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.section-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }

.btn { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 2px; background: var(--paper-light); box-shadow: 2px 2px 0 var(--line); color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 800; line-height: 1.2; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--line); }
.btn:active { transform: translate(1px, 1px); box-shadow: none; }
.btn-primary { background: var(--coral); box-shadow: 3px 3px 0 var(--line); }
.btn-primary:hover { background: #f1786f; box-shadow: 4px 4px 0 var(--line); }
.btn-secondary { background: var(--yellow); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { color: #a23834; }
.btn-sm { min-height: 31px; padding: 6px 10px; font-size: 11px; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.panel { margin-bottom: 22px; padding: 20px; border: 1px solid #716d62; border-radius: 3px; background: #f8efd9; }
.panel.shadowed { box-shadow: none; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -20px -20px 18px; padding: 13px 20px; border-bottom: 1px solid #8b8577; }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 16px; font-weight: 850; letter-spacing: -.02em; }
.panel-header .index { margin-right: 7px; color: var(--coral-dark); font-size: 11px; }
.panel-title-row { display: flex; align-items: center; gap: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 13px; }
.field { display: flex; grid-column: span 3; flex-direction: column; gap: 5px; }
.field.span-4 { grid-column: span 4; }
.field.span-6 { grid-column: span 6; }
.field.span-8 { grid-column: span 8; }
.field.span-12 { grid-column: 1 / -1; }
.field label { color: #44473e; font-size: 10px; font-weight: 850; letter-spacing: .04em; }
.field input, .field select, .compact-select, .inline-input { width: 100%; min-height: 39px; padding: 8px 9px; border: 1.5px solid var(--line); border-radius: 1px; background: #fff9eb; color: var(--ink); }
.field input[type="file"] { padding: 6px; }
.field-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }

.workflow-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 28px; border: 0; background: transparent; }
.tab-btn { display: grid; min-width: 0; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 8px; padding: 11px 10px; border: 1.5px solid var(--line); background: var(--paper-deep); box-shadow: 2px 2px 0 var(--line); color: var(--ink); cursor: pointer; font: inherit; text-align: left; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.tab-btn:hover { transform: translate(-1px, -1px); background: #f4c8b5; box-shadow: 3px 3px 0 var(--line); }
.tab-btn:active { transform: translate(1px, 1px); box-shadow: none; }
.tab-btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.tab-btn.active { background: var(--coral); box-shadow: 3px 3px 0 var(--line); }
.workflow-step { display: grid; width: 27px; height: 27px; place-items: center; border: 1.5px solid var(--line); background: var(--paper-light); font-size: 11px; font-weight: 900; }
.workflow-copy { min-width: 0; font-size: 11px; font-weight: 850; line-height: 1.25; }
.workflow-copy small { display: block; margin-top: 2px; overflow: hidden; color: #55584f; font-size: 9px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.task-list { display: grid; gap: 14px; }
.task-card { display: grid; grid-template-columns: minmax(250px, 2fr) repeat(4, minmax(90px, .65fr)) auto; align-items: center; gap: 18px; padding: 17px 18px; border: 1px solid #716d62; background: #f8efd9; }
.task-card h3 { margin: 0; font-size: 17px; letter-spacing: -.03em; }
.task-card p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.task-stat span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.task-stat strong { font-size: 18px; font-weight: 900; }
.task-card-actions { display: flex; gap: 7px; }
.empty-state { padding: 56px 24px; border: 1.5px solid var(--line); background: #f8efd9; text-align: center; box-shadow: var(--shadow); }
.empty-state h2 { margin: 0 0 7px; font-size: 24px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }

.review-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin-bottom: 20px; }
.summary-card { padding: 16px; border: 1px solid #716d62; background: #f8efd9; }
.summary-card:nth-child(1) { background: var(--yellow); }
.summary-card:nth-child(2) { background: var(--green-soft); }
.summary-card:nth-child(3) { background: var(--red-soft); }
.summary-card span { display: block; font-size: 10px; font-weight: 850; letter-spacing: .04em; }
.summary-card strong { display: inline-block; margin-top: 4px; font-size: 26px; font-weight: 900; letter-spacing: -.04em; }

.invoice-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.filter-chip { min-height: 28px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 1px; background: var(--paper-light); box-shadow: 1.5px 1.5px 0 var(--line); cursor: pointer; font-size: 10px; font-weight: 800; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.filter-chip:hover { transform: translate(-1px, -1px); background: #f4c8b5; box-shadow: 2.5px 2.5px 0 var(--line); }
.filter-chip.active { background: var(--coral); }
.invoice-list { display: grid; gap: 14px; }
.invoice-card { display: grid; grid-template-columns: 148px minmax(0, 1fr) 130px 132px; gap: 18px; align-items: center; padding: 14px; border: 1px solid #716d62; border-radius: 2px; background: #fff7e6; }
.invoice-preview-wrap { display: block; height: 98px; overflow: hidden; border: 1.5px solid var(--line); background: #fff; }
.invoice-preview-wrap:hover { box-shadow: 2px 2px 0 var(--line); }
.invoice-preview { width: 100%; height: 100%; object-fit: cover; }
.invoice-main { min-width: 0; }
.invoice-name { margin: 0 0 8px; overflow: hidden; font-size: 14px; font-weight: 850; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.invoice-meta { display: flex; flex-wrap: wrap; gap: 5px 13px; margin: 0; color: var(--muted); font-size: 10px; }
.invoice-meta strong { color: var(--ink); }
.match-copy { margin-top: 9px; font-size: 11px; }
.match-copy span { display: block; margin-top: 2px; }
.invoice-amount { color: var(--coral-dark); font-size: 21px; font-weight: 900; letter-spacing: -.04em; text-align: right; }
.invoice-actions { display: flex; flex-direction: column; align-items: stretch; gap: 7px; }
.invoice-delete-trigger { margin-top: 1px; background: #fff4e5; }
.invoice-delete-trigger:hover { background: var(--red-soft); }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; width: fit-content; align-items: center; min-height: 22px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 1px; font-size: 9px; font-weight: 850; white-space: nowrap; }
.tag-success { background: var(--green-soft); }
.tag-warning { background: var(--yellow); }
.tag-danger { background: var(--red-soft); }
.tag-source { background: var(--blue); }
.tag-muted { background: var(--paper-deep); }
.match-panel { display: none; grid-column: 1 / -1; padding-top: 13px; border-top: 1.5px solid var(--line); }
.match-panel.open { display: block; }
.match-helper { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 9px; max-height: 220px; margin: 10px 0; overflow-y: auto; padding: 2px 3px 4px 2px; }
.tx-check-card { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto; align-items: center; gap: 7px; padding: 8px; border: 1.5px solid var(--line); background: var(--paper-light); box-shadow: 2px 2px 0 var(--line); cursor: pointer; font-size: 10px; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.tx-check-card:hover { transform: translate(-1px, -1px); background: #f4e2c8; box-shadow: 3px 3px 0 var(--line); }
.tx-check-card.selected { background: var(--green-soft); }
.tx-check-copy { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linked-marker { display: inline-flex; align-items: center; min-height: 20px; padding: 2px 5px; border: 1px solid #287557; background: #edf5e9; color: #1f6549; font-size: 9px; font-weight: 850; white-space: nowrap; }
.tx-check-card .amount { grid-column: 4; }
.check-box { display: grid; width: 16px; height: 16px; place-items: center; border: 1px solid var(--line); background: #fff; color: transparent; }
.tx-check-card.selected .check-box { background: var(--green); color: #fff; }
.match-actions { display: flex; align-items: center; gap: 8px; }
.match-total { margin-left: auto; font-size: 11px; font-weight: 850; }

.table-wrap { width: 100%; overflow-x: auto; border: 1.5px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff8e9; font-size: 11px; }
th { padding: 9px 8px; background: var(--paper-deep); border-bottom: 1.5px solid var(--line); font-size: 9px; letter-spacing: .03em; text-align: left; white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid #c8bea8; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f5ead2; }
.tx-thumb { width: 68px; height: 45px; border: 1px solid var(--line); object-fit: cover; }
.amount { color: var(--coral-dark); font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap; }
.review-table { width: 100%; min-width: 0; table-layout: fixed; }
.review-table col.col-invoice { width: 6.5%; }
.review-table col.col-time { width: 8.5%; }
.review-table col.col-type { width: 7.5%; }
.review-table col.col-counterparty { width: 9%; }
.review-table col.col-product { width: 15%; }
.review-table col.col-source { width: 5%; }
.review-table col.col-direction { width: 5.5%; }
.review-table col.col-amount { width: 6.5%; }
.review-table col.col-payment { width: 8.5%; }
.review-table col.col-status { width: 8.5%; }
.review-table col.col-system { width: 7.5%; }
.review-table col.col-confirmation { width: 12%; }
.review-table th { overflow: visible; white-space: nowrap; }
.review-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.export-table { width: 100%; table-layout: fixed; }
.export-table col.export-col-preview { width: 10%; }
.export-table col.export-col-time { width: 10%; }
.export-table col.export-col-counterparty { width: 13%; }
.export-table col.export-col-product { width: 17%; }
.export-table col.export-col-amount { width: 9%; }
.export-table col.export-col-seller { width: 13%; }
.export-table col.export-col-invoice-amount { width: 10%; }
.export-table col.export-col-file { width: 18%; }
.export-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-table thead { position: relative; z-index: 20; }
#tab-review .table-wrap { overflow: visible; }
.table-filterable { min-width: 74px; padding: 7px 5px; vertical-align: top; transition: background .12s ease, box-shadow .12s ease; }
.table-filterable.is-active { background: #f4c8b5; box-shadow: inset 0 -3px 0 var(--coral); }
.table-head-control { display: grid; gap: 5px; }
.table-column-heading { display: flex; min-width: 0; align-items: center; gap: 4px; }
.table-column-heading > span { min-width: 0; overflow: hidden; font-weight: 900; text-overflow: ellipsis; }
.table-filter-menu { position: relative; width: 100%; z-index: 30; }
.table-filter-menu[open] { z-index: 60; }
.table-filter-trigger { display: flex; min-height: 25px; align-items: center; padding: 4px 6px; border: 1px solid var(--line); border-radius: 1px; background: var(--paper-light); box-shadow: 2px 2px 0 var(--line); color: var(--ink); cursor: pointer; font-size: 9px; font-weight: 800; list-style: none; }
.table-filter-trigger::-webkit-details-marker { display: none; }
.table-filter-trigger:hover, .table-filter-menu[open] .table-filter-trigger { background: var(--yellow); }
.table-filter-trigger:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.table-control-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-menu-popover { position: absolute; top: calc(100% + 6px); left: 0; display: grid; width: max(100%, 138px); max-height: 250px; overflow-y: auto; padding: 6px; border: 1.5px solid var(--line); border-radius: 2px; background: var(--paper-light); box-shadow: 4px 4px 0 var(--line); }
.table-filterable:nth-last-child(-n+2) .table-menu-popover { right: 0; left: auto; }
.table-menu-option { width: 100%; min-height: 30px; padding: 6px 8px; border: 0; border-bottom: 1px solid #c8bea8; background: transparent; color: var(--ink); cursor: pointer; font-size: 10px; font-weight: 750; text-align: left; white-space: nowrap; }
.table-menu-option:last-child { border-bottom: 0; }
.table-menu-option:hover, .table-menu-option:focus-visible { background: var(--yellow); outline: 0; }
.table-menu-option.selected { background: var(--coral); font-weight: 900; }
.table-filterable.is-active .table-filter-trigger { background: var(--coral); }
.review-table [data-column-key][hidden] { display: none; }
.column-visibility-menu { position: relative; z-index: 70; }
.column-visibility-menu > summary { list-style: none; }
.column-visibility-menu > summary::-webkit-details-marker { display: none; }
.column-visibility-trigger { display: inline-flex; min-height: 28px; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 1px; background: var(--paper-light); box-shadow: 2px 2px 0 var(--line); cursor: pointer; font-size: 9px; font-weight: 850; }
.column-visibility-trigger span { color: var(--coral-dark); font-variant-numeric: tabular-nums; }
.column-visibility-trigger:hover, .column-visibility-menu[open] > .column-visibility-trigger { background: var(--yellow); }
.column-visibility-trigger:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.column-visibility-popover { position: absolute; top: calc(100% + 7px); left: 0; display: grid; width: 230px; padding: 7px; border: 1.5px solid var(--line); border-radius: 2px; background: var(--paper-light); box-shadow: 4px 4px 0 var(--line); }
.column-visibility-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 5px 8px; border-bottom: 1px solid #c8bea8; }
.column-visibility-header strong { font-size: 10px; }
.column-visibility-header button { padding: 2px 4px; border: 1px solid var(--line); border-radius: 1px; background: var(--yellow); cursor: pointer; font-size: 8px; font-weight: 850; }
.column-visibility-list { display: grid; grid-template-columns: 1fr 1fr; }
.column-visibility-option { display: flex; min-height: 32px; align-items: center; gap: 7px; padding: 6px 5px; border-bottom: 1px solid #d6ccb7; background: transparent; color: var(--ink); cursor: pointer; font-size: 10px; font-weight: 750; }
.column-visibility-option:last-child { border-bottom: 0; }
.column-visibility-option:hover, .column-visibility-option:focus-within { background: var(--yellow); }
.column-visibility-option input { width: 14px; height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; }
.column-visibility-option.is-hidden { background: #eadfca; color: #756f64; }
.review-table .truncate-cell { max-width: 132px; overflow: hidden; text-overflow: ellipsis; }
.review-table .product-cell { max-width: 170px; }
.overflow-tooltip-cell.is-truncated { cursor: help; }
.overflow-tooltip-cell.is-truncated:focus-visible { outline: 2px solid var(--coral); outline-offset: -3px; }
.retro-cell-tooltip { position: fixed; z-index: 200; width: max-content; max-width: min(360px, calc(100vw - 24px)); padding: 9px 11px 10px; border: 1.5px solid var(--line); border-radius: 2px; background: var(--paper-light); box-shadow: 4px 4px 0 var(--line); pointer-events: none; }
.retro-cell-tooltip[hidden] { display: none; }
.retro-cell-tooltip span { display: inline-block; margin-bottom: 5px; padding: 2px 5px; border: 1px solid var(--line); background: var(--coral); font-size: 8px; font-weight: 900; letter-spacing: .04em; }
.retro-cell-tooltip p { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 11px; font-weight: 700; line-height: 1.5; white-space: normal; }
.source-cell { width: 48px; text-align: center; }

/* ── Retro Date Picker ─ */
.retro-date-picker { position: relative; }
.retro-date-picker input[type="hidden"] { display: none; }
.retro-date-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 39px; padding: 8px 9px; border: 1.5px solid var(--line); border-radius: 1px; background: #fff9eb; color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 700; }
.retro-date-trigger:hover { background: var(--yellow); }
.retro-date-trigger:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.retro-date-trigger .date-icon { flex-shrink: 0; font-size: 16px; }
.retro-date-trigger .date-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.retro-date-trigger .clear-btn { flex-shrink: 0; padding: 2px 6px; border: 1px solid var(--line); border-radius: 1px; background: var(--paper-light); font-size: 9px; font-weight: 850; color: var(--muted); cursor: pointer; }
.retro-date-trigger .clear-btn:hover { background: var(--coral); color: #fff; }
.retro-calendar-popover { position: absolute; top: calc(100% + 6px); left: 0; z-index: 100; width: 280px; padding: 12px; border: 2px solid var(--line); border-radius: 3px; background: var(--paper-light); box-shadow: 6px 6px 0 var(--line); }
.retro-calendar-popover[hidden] { display: none; }
.retro-calendar-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.retro-calendar-header button { display: grid; width: 30px; height: 30px; place-items: center; border: 1.5px solid var(--line); border-radius: 2px; background: var(--paper-light); box-shadow: 2px 2px 0 var(--line); cursor: pointer; font-size: 14px; font-weight: 900; color: var(--ink); }
.retro-calendar-header button:hover { background: var(--yellow); }
.retro-calendar-header button:active { transform: translate(1px, 1px); box-shadow: none; }
.retro-calendar-header .month-year { font-size: 14px; font-weight: 850; letter-spacing: -.02em; }
.retro-calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.retro-calendar-weekdays span { text-align: center; font-size: 9px; font-weight: 850; color: var(--muted); padding: 4px 0; }
.retro-calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.retro-calendar-days button { display: grid; width: 100%; aspect-ratio: 1; place-items: center; border: 1.5px solid transparent; border-radius: 2px; background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--ink); }
.retro-calendar-days button:hover:not(:disabled) { background: var(--yellow); border-color: var(--line); }
.retro-calendar-days button:active:not(:disabled) { transform: translate(1px, 1px); }
.retro-calendar-days button.selected { background: var(--coral); color: #fff; border-color: var(--line); }
.retro-calendar-days button.today { border-color: var(--coral); }
.retro-calendar-days button.other-month { color: #b8b2a4; }
.retro-calendar-days button:disabled { cursor: not-allowed; opacity: .4; }
.retro-calendar-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid #c8bea8; }
.retro-calendar-footer button { flex: 1; min-height: 30px; padding: 5px 8px; border: 1.5px solid var(--line); border-radius: 2px; background: var(--paper-light); box-shadow: 2px 2px 0 var(--line); cursor: pointer; font-size: 10px; font-weight: 850; }
.retro-calendar-footer button:hover { background: var(--yellow); }
.retro-calendar-footer button.primary { background: var(--coral); color: #fff; }
.retro-calendar-footer button.primary:hover { background: #f1786f; }
.source-mark { display: inline-grid; width: 30px; height: 30px; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--paper-light); font-size: 13px; font-weight: 900; line-height: 1; }
.source-wechat { border-color: #247451; color: #247451; }
.source-alipay { border-color: #246bb3; color: #246bb3; }
.cfm-group { display: flex; width: 100%; min-width: 0; border: 1px solid var(--line); }
.cfm-btn { flex: 1; min-width: 0; padding: 6px 5px; border: 0; background: var(--paper-light); cursor: pointer; font-size: 10px; font-weight: 800; white-space: nowrap; }
.cfm-btn + .cfm-btn { border-left: 1px solid var(--line); }
.cfm-btn.belongs.active { background: var(--green); color: #fff; }
.cfm-btn.not-belongs.active { background: var(--coral); }
.tx-row.belongs-hidden { display: none; }
#clear-table-controls:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; transform: none; }

.itinerary-list { display: grid; gap: 8px; }
.itinerary-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--line); background: var(--paper-light); font-size: 11px; }
.itinerary-edit { display: none; padding: 10px; border: 1px solid var(--line); background: var(--paper-deep); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.inline-form .inline-input { width: auto; min-width: 130px; }
.itinerary-row { margin-bottom: 12px; padding: 14px; border: 1px solid var(--line); background: var(--paper-light); }
.btn-remove-itinerary { margin-top: 8px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 1px; background: var(--paper-light); color: var(--muted); font-size: 11px; font-weight: 850; cursor: pointer; }
.btn-remove-itinerary:hover { background: var(--coral); color: #fff; border-color: var(--coral); }
.file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.file-row input[type="file"] { min-width: 280px; padding: 7px; border: 1px solid var(--line); background: var(--paper-light); }
.empty { margin: 0; padding: 34px 16px; color: var(--muted); font-size: 12px; text-align: center; }
.export-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 14px; padding: 15px; border: 1.5px solid var(--line); background: var(--yellow); }
.export-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.screen-reader { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.retro-modal-backdrop { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; background: rgba(27,28,24,.48); }
.retro-modal-backdrop[hidden] { display: none; }
.retro-modal { width: min(440px, 100%); padding: 22px; border: 2px solid var(--line); border-radius: 3px; background: var(--paper-light); box-shadow: 7px 7px 0 var(--line); }
.retro-modal-kicker { display: inline-block; margin-bottom: 11px; padding: 3px 6px; border: 1px solid var(--line); background: var(--coral); font-size: 8px; font-weight: 900; letter-spacing: .1em; }
.retro-modal h3 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.retro-modal-file { margin: 14px 0 0; padding: 9px; border: 1px solid #8b8577; background: #fff8e9; font-size: 11px; overflow-wrap: anywhere; }
.retro-modal-note { margin: 10px 0 0; color: var(--muted); font-size: 10px; }
.retro-modal-error { margin: 10px 0 0; color: #9f302d; font-size: 10px; font-weight: 850; }
.retro-modal-actions { display: flex; gap: 9px; margin-top: 18px; }

/* ── Add Itinerary Modal ── */
.modal-backdrop { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; background: rgba(27,28,24,.48); }
.modal-content { width: min(500px, 100%); padding: 22px; border: 2px solid var(--line); border-radius: 3px; background: var(--paper-light); box-shadow: 7px 7px 0 var(--line); }
.modal-content h3 { margin: 0 0 18px; font-size: 21px; letter-spacing: -.03em; }
.modal-content .form-row { display: flex; flex-wrap: wrap; gap: 13px; margin-bottom: 18px; }
.modal-content .form-group { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 5px; }
.modal-content .form-group label { color: #44473e; font-size: 10px; font-weight: 850; letter-spacing: .04em; }
.modal-content .form-group input { width: 100%; min-height: 39px; padding: 8px 9px; border: 1.5px solid var(--line); border-radius: 1px; background: #fff9eb; color: var(--ink); }
.modal-content .form-actions { display: flex; gap: 10px; }

/* ── Retro Date Picker ── */
.retro-date-picker { position: relative; display: inline-block; }
.retro-date-trigger { display: inline-flex; align-items: center; gap: 8px; min-width: 142px; min-height: 39px; padding: 7px 10px; border: 1.5px solid var(--line); border-radius: 1px; background: #fff9eb; color: var(--ink); font-size: 13px; cursor: pointer; }
.retro-date-trigger:hover { border-color: var(--coral); }
.retro-date-trigger .date-label { flex: 1; text-align: left; }
.retro-date-trigger .clear-btn { padding: 1px 6px; border: 1px solid var(--line); border-radius: 1px; background: var(--paper-light); color: var(--muted); font-size: 10px; font-weight: 850; cursor: pointer; line-height: 1.4; }
.retro-date-trigger .clear-btn:hover { background: var(--coral); color: #fff; border-color: var(--coral); }

.retro-calendar-popover { position: absolute; top: calc(100% + 4px); left: 0; z-index: 200; width: 264px; padding: 12px; border: 2px solid var(--line); border-radius: 3px; background: var(--paper-light); box-shadow: 5px 5px 0 var(--line); }
.retro-calendar-popover[hidden] { display: none; }

.retro-calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.retro-calendar-header .month-year { font-size: 13px; font-weight: 850; color: var(--ink); letter-spacing: -.01em; }
.retro-calendar-header button { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 1px; background: #fff9eb; color: var(--ink); font-size: 15px; cursor: pointer; line-height: 1; }
.retro-calendar-header button:hover { background: var(--coral); color: #fff; border-color: var(--coral); }

.retro-calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; text-align: center; }
.retro-calendar-weekdays span { font-size: 10px; font-weight: 850; color: var(--muted); padding: 4px 0; }

.retro-calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.retro-calendar-days button { width: 100%; aspect-ratio: 1; padding: 0; border: 1px solid transparent; border-radius: 1px; background: transparent; color: var(--ink); font-size: 12px; cursor: pointer; }
.retro-calendar-days button:hover:not(:disabled):not(.other-month) { border-color: var(--line); background: #fff9eb; }
.retro-calendar-days button.today { border-color: var(--line); font-weight: 850; }
.retro-calendar-days button.selected { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 850; }
.retro-calendar-days button.selected:hover { background: var(--coral); border-color: var(--coral); }
.retro-calendar-days button.other-month { color: #c6c2b6; cursor: default; }

.retro-calendar-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.retro-calendar-footer button { padding: 5px 12px; border: 1.5px solid var(--line); border-radius: 1px; background: #fff9eb; color: var(--ink); font-size: 11px; font-weight: 850; cursor: pointer; }
.retro-calendar-footer button:hover { border-color: var(--coral); }
.retro-calendar-footer button.confirm-btn { background: var(--ink); border-color: var(--ink); color: #fff; }
.retro-calendar-footer button.confirm-btn:hover { background: var(--coral); border-color: var(--coral); }

@media (max-width: 1050px) {
  #tab-review .table-wrap { overflow-x: auto; }
  .review-table { min-width: 1120px; }
  .export-table { min-width: 980px; }
  .task-card { grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(80px, .5fr)) auto; }
  .task-card .task-stat:nth-of-type(3), .task-card .task-stat:nth-of-type(4) { display: none; }
  .invoice-card { grid-template-columns: 130px minmax(0, 1fr) 110px; }
  .invoice-actions { grid-column: 2 / -1; flex-direction: row; align-items: center; }
}

@media (max-width: 760px) {
  .retro-shell { width: 100%; min-height: 100vh; margin: 0; border-right: 0; border-left: 0; box-shadow: none; }
  .retro-header { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px; }
  .retro-main { width: calc(100% - 28px); padding-top: 28px; }
  .hero h1 { font-size: 36px; }
  .workflow-nav { grid-template-columns: repeat(5, minmax(132px, 1fr)); overflow-x: auto; }
  .section-heading, .panel-header, .export-summary { align-items: flex-start; flex-direction: column; }
  .field, .field.span-4, .field.span-6, .field.span-8 { grid-column: 1 / -1; }
  .review-summary { grid-template-columns: 1fr; }
  .task-card { grid-template-columns: 1fr 1fr; }
  .task-card > div:first-child, .task-card-actions { grid-column: 1 / -1; }
  .task-card .task-stat { display: block !important; }
  .invoice-card { grid-template-columns: 104px 1fr; gap: 12px; }
  .invoice-preview-wrap { height: 78px; }
  .invoice-amount { text-align: left; }
  .invoice-actions { grid-column: 1 / -1; }
  .match-panel { grid-column: 1 / -1; }
  .export-actions { justify-content: flex-start; }
  .retro-version-switcher { width: 112px; }
  .retro-version-switcher summary { min-height: 38px; padding: 7px 9px; }
  .retro-version-switcher summary span { display: none; }
  .retro-version-menu { width: 154px; }
}

@media (max-width: 420px) {
  .brand-copy { display: none; }
}

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

/* Demo-only virtual invoice preview */
.virtual-invoice-thumb {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px;
  background:
    linear-gradient(90deg, transparent 49%, rgba(38,39,33,.12) 50%, transparent 51%),
    #fffdf5;
  color: var(--ink);
  font-family: Georgia, "Songti SC", serif;
  text-align: center;
}
.virtual-invoice-thumb strong { font-size: 13px; letter-spacing: .08em; }
.virtual-invoice-thumb span { font-size: 9px; color: var(--muted); }
.invoice-preview-wrap { width: 100%; padding: 0; border: 0; color: inherit; cursor: pointer; font: inherit; text-align: left; }
.invoice-cell-button { display: inline-block; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; }
.invoice-cell-button:hover .tx-thumb { box-shadow: 2px 2px 0 var(--line); }
.demo-only-note {
  margin: -6px 0 18px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
}
.demo-only-note strong { font-weight: 900; }
.demo-readonly { opacity: .88; }
.demo-readonly input { color: var(--muted); }
.demo-invoice-modal { width: min(720px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; }
.virtual-invoice-paper {
  position: relative;
  padding: 22px;
  border: 1.5px solid var(--line);
  background: #fffdf8;
}
.virtual-invoice-paper::after {
  content: "演示样票 · 不具备财务凭证效力";
  position: absolute;
  right: 19px;
  bottom: 19px;
  color: rgba(203,79,73,.58);
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: 900;
  transform: rotate(-12deg);
}
.virtual-invoice-paper .invoice-kicker {
  color: var(--coral-dark);
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
}
.virtual-invoice-paper h3 { margin: 7px 0 19px; text-align: center; font-size: 24px; letter-spacing: .15em; }
.virtual-invoice-paper .invoice-paper-grid { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); }
.virtual-invoice-paper .invoice-paper-field { min-width: 0; padding: 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.virtual-invoice-paper .invoice-paper-field:nth-child(2n) { border-right: 0; }
.virtual-invoice-paper .invoice-paper-field span { display: block; color: var(--muted); font-family: "Courier New", monospace; font-size: 9px; }
.virtual-invoice-paper .invoice-paper-field strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-size: 13px; }
.virtual-invoice-paper .invoice-paper-total { display: flex; justify-content: space-between; gap: 14px; margin-top: 16px; padding: 12px; border: 1.5px solid var(--line); background: var(--yellow); font-weight: 900; }
.demo-disabled { cursor: not-allowed; opacity: .58; }
@media (max-width: 760px) {
  .virtual-invoice-paper .invoice-paper-grid { grid-template-columns: 1fr; }
  .virtual-invoice-paper .invoice-paper-field:nth-child(2n) { border-right: 1px solid var(--line); }
}
