:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #657178;
  --line: #d9dfe1;
  --paper: #ffffff;
  --canvas: #f3f5f4;
  --deep: #17323a;
  --teal: #0c7b73;
  --teal-dark: #075f59;
  --amber: #d99116;
  --red: #b83b3b;
  --green-bg: #e5f5ef;
  --amber-bg: #fff3d9;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
[hidden] { display: none !important; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-nav { position: fixed; z-index: 50; inset: 0 auto 0 0; width: 224px; padding: 17px 12px 12px; display: flex; flex-direction: column; background: var(--deep); color: white; transition: width .2s ease, transform .2s ease; }
.app-nav .brand { min-height: 42px; padding: 0 8px; }
.app-nav .brand > div { min-width: 0; white-space: nowrap; overflow: hidden; }
.nav-links { display: grid; gap: 5px; margin-top: 34px; }
.nav-link, .nav-collapse { width: 100%; min-height: 44px; border: 0; border-radius: 5px; background: transparent; color: #d7e2e3; display: flex; align-items: center; gap: 12px; padding: 0 12px; cursor: pointer; text-align: left; white-space: nowrap; }
.nav-link:hover, .nav-collapse:hover { background: #23434c; color: white; }
.nav-link.active { background: #e4efed; color: var(--deep); font-weight: 800; }
.nav-link svg, .nav-collapse svg { width: 19px; flex: 0 0 19px; }
.nav-link b { min-width: 21px; height: 21px; margin-left: auto; padding: 0 5px; border-radius: 11px; display: grid; place-items: center; background: var(--amber); color: #222a2c; font-size: 10px; }
.nav-collapse { margin-top: auto; border-top: 1px solid #35535a; border-radius: 0; }
.app-shell { min-width: 0; margin-left: 224px; transition: margin-left .2s ease; }
.nav-collapsed .app-nav { width: 72px; }
.nav-collapsed .app-shell { margin-left: 72px; }
.nav-collapsed .app-nav .brand > div, .nav-collapsed .nav-link span, .nav-collapsed .nav-collapse span { display: none; }
.nav-collapsed .nav-link, .nav-collapsed .nav-collapse { justify-content: center; padding: 0; }
.nav-collapsed .nav-link b { position: absolute; margin: -27px 0 0 25px; min-width: 17px; height: 17px; padding: 0 3px; }
.nav-overlay { position: fixed; inset: 0; z-index: 48; border: 0; background: rgba(13,28,33,.48); }
.topbar { position: sticky; z-index: 30; top: 0; min-height: 64px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: var(--deep); color: white; }
.view-heading strong, .view-heading small { display: block; }
.view-heading small { margin-top: 3px; color: #b9cacc; font-size: 11px; }
.app-view { min-width: 0; }
.menu-button { position: relative; width: 38px; height: 38px; border: 1px solid #6e9096; border-radius: 4px; background: transparent; color: white; display: none; place-items: center; cursor: pointer; }
.menu-button:hover { background: #23434c; }
.menu-button svg { width: 19px; }
.menu-button span { position: absolute; top: -7px; right: -7px; min-width: 19px; height: 19px; padding: 0 4px; border-radius: 10px; display: grid; place-items: center; background: var(--amber); color: #1f2527; font-size: 10px; font-weight: 800; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #68a6a1; color: #a9e3dc; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { color: #b9cacc; margin-top: 2px; }
.status { display: flex; align-items: center; gap: 8px; color: #d4e0e1; font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #55c28a; }
.company-switcher { display: flex; align-items: center; gap: 8px; min-width: 0; }
.company-switcher select { width: 220px; height: 36px; border: 1px solid #54737a; border-radius: 4px; background: #23434c; color: white; padding: 0 9px; }
.company-switcher select option, select option { background: #ffffff; color: #172126; }
.company-switcher select option:checked, select option:checked { background: #e4efed; color: #17323a; }
.company-filter-prompt { padding: 5px 7px; border: 1px solid #d6a725; border-radius: 4px; background: #fff1b8; color: #6f5300; font-size: 11px; font-weight: 800; line-height: 1.2; white-space: nowrap; }
.company-filter-prompt[hidden] { display: none; }
.top-action { height: 36px; border: 1px solid #6e9096; border-radius: 4px; background: transparent; color: white; display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; cursor: pointer; }
.top-action:hover { background: #23434c; }
.top-action svg { width: 16px; }

.capture-band { background: #e4efed; border-bottom: 1px solid #c8d8d5; padding: 34px max(28px, calc((100vw - 1360px) / 2)); display: grid; grid-template-columns: minmax(260px, .8fr) minmax(520px, 1.4fr); gap: 56px; align-items: center; }
.capture-copy h1 { font-size: 32px; margin: 4px 0 8px; letter-spacing: 0; }
.capture-copy p:last-child { color: #536567; margin: 0; max-width: 520px; line-height: 1.5; }
.eyebrow { margin: 0; color: var(--teal); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.capture-form { display: grid; grid-template-columns: 1fr; gap: 13px; }
.select-field { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 10px; color: #41565a; font-size: 12px; font-weight: 800; }
.select-field select { width: 100%; height: 38px; border: 1px solid #9bb5b2; border-radius: 4px; background: white; padding: 0 10px; }
.file-pickers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.camera-button { min-height: 64px; border: 2px dashed #78a6a0; background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; font-weight: 750; border-radius: 6px; }
.camera-button:hover { border-color: var(--teal); background: white; }
.camera-button svg { width: 25px; }
.batch-note { margin: -3px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.upload-queue { max-height: 184px; overflow-y: auto; border: 1px solid #b8ceca; background: rgba(255,255,255,.8); }
.queue-item { min-height: 51px; display: grid; grid-template-columns: 24px minmax(0, 1fr) 34px; align-items: center; gap: 9px; padding: 7px 9px; border-bottom: 1px solid #d8e3e1; }
.queue-item:last-child { border-bottom: 0; }
.queue-item > svg { width: 19px; color: var(--teal); }
.queue-item.error > svg { color: var(--red); }
.queue-item strong, .queue-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item strong { font-size: 12px; }
.queue-item small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #9bb5b2; border-radius: 6px; overflow: hidden; background: white; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { min-height: 38px; display: grid; place-items: center; border-right: 1px solid #c9d6d4; font-size: 13px; font-weight: 650; }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--deep); color: white; }

.primary, .secondary, .copy-url, .icon-button { border-radius: 5px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.primary { min-height: 42px; border: 1px solid var(--teal); background: var(--teal); color: white; font-weight: 750; padding: 0 18px; }
.primary:hover { background: var(--teal-dark); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.secondary { min-height: 38px; border: 1px solid #b7c0c3; background: white; color: var(--ink); padding: 0 13px; font-weight: 650; }
.secondary:hover { border-color: var(--teal); color: var(--teal); }
.primary svg, .secondary svg { width: 17px; }
.progress { text-align: center; color: var(--muted); font-size: 13px; }
.progress span { display: block; height: 3px; background: var(--teal); animation: loading 1.2s ease-in-out infinite; }
.progress p { margin: 7px 0 0; }
@keyframes loading { 0% { transform: scaleX(.15); transform-origin: left; } 50% { transform: scaleX(1); } 100% { transform: scaleX(.15); transform-origin: right; } }

.workspace { max-width: 1360px; margin: 0 auto; padding: 28px; display: grid; grid-template-columns: 235px minmax(0, 1fr); gap: 28px; align-items: start; }
.connection-panel { border-right: 1px solid var(--line); padding-right: 28px; }
.connection-panel h2, .records-head h2 { margin: 4px 0 18px; font-size: 20px; }
.connection-panel img { display: block; width: 180px; height: 180px; border: 8px solid white; }
.connection-panel > p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.45; }
.copy-url { width: 100%; min-height: 38px; border: 1px solid var(--line); background: white; padding: 7px 9px; color: var(--ink); }
.copy-url span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.copy-url svg { width: 15px; flex: 0 0 auto; }
.network-addresses { min-width: 0; display: grid; gap: 7px; }
.copy-url.fallback { background: #f7f9f8; color: var(--muted); }
.warning { margin-top: 14px; padding: 10px; display: flex; gap: 8px; background: var(--amber-bg); color: #71500d; font-size: 12px; line-height: 1.4; border-left: 3px solid var(--amber); }
.warning svg { width: 17px; flex: 0 0 auto; }

.records-panel { min-width: 0; }
.records-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.exports { display: flex; gap: 8px; }
.exports input[type="month"] { height: 38px; border: 1px solid #b7c0c3; border-radius: 4px; background: white; padding: 0 9px; }
.company-export-bar { display: grid; grid-template-columns: minmax(210px, 1fr) 155px auto auto; gap: 9px; align-items: center; margin-bottom: 16px; padding: 13px 15px; background: #e4efed; border: 1px solid #c4d6d3; }
.company-export-bar input { height: 42px; border: 1px solid #9fb3b1; border-radius: 4px; background: white; padding: 0 9px; }
.export-company-copy small, .export-company-copy strong { display: block; }
.export-company-copy small { color: var(--teal); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.export-company-copy strong { margin-top: 4px; font-size: 14px; }
.source { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); background: white; margin-bottom: 16px; }
.metrics div { padding: 13px 16px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span, .metrics small { display: block; }
.metrics span { font-size: 22px; font-weight: 800; }
.metrics small { color: var(--muted); margin-top: 2px; }
.toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) 145px 165px 180px; gap: 10px; margin-bottom: 12px; }
.search { position: relative; min-width: 0; }
.search svg { position: absolute; left: 11px; top: 10px; width: 17px; color: var(--muted); }
.search input, .toolbar select { width: 100%; height: 38px; border: 1px solid #c7ced1; background: white; border-radius: 4px; }
.search input { padding: 0 12px 0 36px; }
.toolbar select { min-width: 0; width: 100%; padding: 0 10px; }

.records { border-top: 1px solid var(--line); }
.record { display: grid; grid-template-columns: 68px minmax(140px, 1.2fr) minmax(110px, .8fr) 170px 92px 70px 145px; gap: 14px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--line); }
.record:hover { background: #f9fbfa; }
.thumb-link { position: relative; width: 58px; height: 58px; display: block; }
.thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: #e6e9e8; }
.record-sequence { position: absolute; left: 3px; bottom: 3px; max-width: 52px; padding: 3px 5px; border-radius: 3px; background: rgba(23,50,58,.92); color: white; font-size: 9px; font-weight: 850; white-space: nowrap; }
.record-main strong, .record-main small, .record-meta span, .record-meta small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-main small, .record-meta small { color: var(--muted); margin-top: 4px; font-size: 12px; }
.record-meta small { margin: 0 0 4px; font-size: 10px; font-weight: 800; }
.record-total { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.record-total > time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.record-total-main { display: grid; justify-items: end; gap: 4px; }
.record-total-main small { color: var(--muted); font-size: 10px; font-weight: 800; }
.record-total-main strong { font-size: 13px; white-space: nowrap; }
.pill { justify-self: start; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.pill.compra { background: #e2eef4; color: #285c76; }
.pill.venta { background: var(--green-bg); color: #176c4f; }
.validation { font-size: 11px; font-weight: 800; color: #207154; }
.validation.accepted { color: #176c4f; }
.validation.review { color: #9a6506; }
.record-actions { display: flex; justify-content: flex-end; gap: 5px; }
.icon-button { width: 32px; height: 32px; border: 1px solid var(--line); background: white; color: #4b575c; }
.icon-button:hover { color: var(--teal); border-color: var(--teal); }
.icon-button.danger:hover { color: var(--red); border-color: var(--red); }
.icon-button svg { width: 16px; }
.edit-action { width: auto; padding: 0 9px; color: var(--teal); border-color: #9bbdb8; font-weight: 750; }
.edit-action span { font-size: 12px; }
.review-tag { display: block; margin-top: 3px; font-size: 10px; font-weight: 800; color: #80601d; }
.review-tag.accepted { color: #207154; }
.review-tag.rejected { color: var(--red); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); background: white; border-bottom: 1px solid var(--line); }
.empty svg { width: 32px; margin-bottom: 8px; }

dialog { width: min(760px, calc(100vw - 32px)); border: 0; border-radius: 7px; padding: 0; box-shadow: 0 24px 70px rgba(14,31,37,.28); }
dialog::backdrop { background: rgba(13,28,33,.55); }
#edit-form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2 { margin: 4px 0 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.edit-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.edit-preview { width: 100%; height: 440px; border: 1px solid var(--line); background: #eef1f0; }
#edit-dialog { width: min(980px, calc(100vw - 32px)); }
#edit-dialog .form-grid { max-height: 56vh; overflow-y: auto; padding-right: 5px; }
.form-grid label { color: #4f5b60; font-size: 12px; font-weight: 700; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select { width: 100%; height: 38px; margin-top: 5px; border: 1px solid #c5cccf; border-radius: 4px; padding: 0 9px; background: white; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.dialog-note { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 15px 0 0; }
#company-dialog { width: min(560px, calc(100vw - 32px)); }
#company-form { padding: 24px; }
#toast { position: fixed; z-index: 20; top: 76px; left: 50%; max-width: min(360px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 5px; background: var(--deep); color: white; box-shadow: 0 10px 30px rgba(0,0,0,.2); transform: translate(-50%, -18px); opacity: 0; transition: .2s ease; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
.capture-guard { margin: 12px 0 0; padding: 9px 11px; border-left: 3px solid var(--amber); background: var(--amber-bg); color: #73500c; font-size: 12px; font-weight: 750; }
.capture-guard[hidden], .capture-guard:empty { display: none; }
.camera-button.disabled { opacity: .5; cursor: not-allowed; }

.review-page { height: calc(100vh - 64px); background: var(--paper); display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.review-head { max-height: 64px; min-height: 54px; padding: 8px 22px; display: flex; align-items: center; justify-content: space-between; gap: 18px; overflow: hidden; border-bottom: 1px solid var(--line); transition: max-height .24s ease, min-height .24s ease, padding .24s ease, opacity .18s ease, transform .24s ease, border-color .24s ease; }
.review-head h2 { margin: 0; font-size: 18px; }
.review-navigation { display: flex; align-items: center; gap: 8px; }
.review-navigation { min-height: 38px; padding: 2px 7px; border: 1px solid var(--line); background: #f7f9f8; }
.review-navigation .icon-button { width: 34px; height: 34px; }
.review-position-inline { align-self: center; min-width: 56px; color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 800; text-align: center; }
.review-list-toggle { min-height: 38px; padding: 0 11px; color: var(--teal-dark); border-color: #9bbdb8; font-size: 12px; font-weight: 800; }
.review-list-toggle svg { width: 16px; }
.review-filters { padding: 8px 22px; display: grid; grid-template-columns: minmax(160px, 260px) max-content max-content minmax(180px, 240px); gap: 9px; border-bottom: 1px solid var(--line); background: #f4f6f5; }
.review-filters select { width: 100%; height: 40px; border: 1px solid #bcc5c7; border-radius: 4px; background: white; padding: 0 10px; }
.review-layout { min-height: 0; display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr) minmax(260px, 380px); overflow: hidden; isolation: isolate; transition: grid-template-columns .24s ease; }
.review-layout.list-collapsed { grid-template-columns: 0 minmax(0, 1fr) minmax(260px, 380px); }
.review-list { min-width: 0; overflow: auto; border-right: 1px solid var(--line); background: #f7f8f8; opacity: 1; transform: translateX(0); transition: opacity .18s ease, transform .24s ease, border-color .24s ease; }
.review-layout.list-collapsed .review-list { overflow: hidden; opacity: 0; transform: translateX(-10px); border-color: transparent; }
.review-page.focus-mode .review-head { max-height: 0; min-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; transform: translateY(-5px); border-color: transparent; pointer-events: none; }
.review-list-item { width: 100%; min-height: 84px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.review-list-item:hover { background: white; }
.review-list-item.active { background: #e4efed; box-shadow: inset 3px 0 var(--teal); }
.review-list-item strong, .review-list-item span, .review-list-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-list-item strong { font-size: 14px; }
.review-list-item span { margin-top: 6px; font-size: 13px; }
.review-list-item small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.review-viewer { position: relative; z-index: 0; min-width: 0; min-height: 0; overflow: hidden; isolation: isolate; display: grid; grid-template-rows: auto minmax(0, 1fr); background: #dfe4e3; }
.viewer-toolbar { position: relative; z-index: 2; min-width: 0; min-height: 48px; padding: 7px 10px; display: flex; align-items: center; align-content: center; flex-wrap: wrap; gap: 7px; border-bottom: 1px solid #c3cbca; background: #f5f7f6; }
.review-zoom-controls { min-width: 190px; flex: 1 1 230px; display: flex; align-items: center; gap: 7px; }
.review-zoom-controls input { min-width: 70px; flex: 1; accent-color: var(--teal); }
.viewer-toolbar span { width: 43px; color: var(--muted); font-size: 11px; font-weight: 750; text-align: right; }
.review-adjustments { position: relative; flex: 0 0 auto; }
.review-adjustments summary { min-height: 34px; padding: 0 9px; display: flex; align-items: center; gap: 5px; border: 1px solid #9bbdb8; border-radius: 4px; background: white; color: var(--teal-dark); cursor: pointer; font-size: 11px; font-weight: 800; list-style: none; }
.review-adjustments summary::-webkit-details-marker { display: none; }
.review-adjustments summary svg { width: 15px; }
.review-adjustments-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 4; width: min(230px, calc(100vw - 32px)); padding: 11px; display: grid; gap: 9px; border: 1px solid #b7c7c5; border-radius: 5px; background: white; box-shadow: 0 9px 24px rgba(26,38,41,.18); }
.review-adjustments-panel label { display: grid; grid-template-columns: 58px minmax(0, 1fr) 38px; align-items: center; gap: 7px; color: #41565a; font-size: 11px; font-weight: 800; }
.review-adjustments-panel input { min-width: 0; accent-color: var(--teal); }
.review-adjustments-panel output { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; text-align: right; }
.review-adjustments-panel button { min-height: 32px; justify-content: center; padding: 0 8px; font-size: 11px; }
.review-adjustments-panel button svg { width: 14px; }
.review-highlights-toggle.active { border-color: #78aaa4; background: #e4f0ee; color: var(--teal-dark); }
.viewer-toolbar .review-highlights-status { width: auto; min-width: 0; margin-left: auto; color: #486168; font-size: 10px; white-space: nowrap; }
@media (max-width: 640px) { .viewer-toolbar .review-highlights-status { display: none; } }
.review-canvas { position: relative; min-width: 0; min-height: 0; overflow: auto; padding: 18px; box-sizing: border-box; overscroll-behavior: contain; overflow-anchor: none; cursor: grab; isolation: isolate; }
.review-canvas.is-panning { cursor: grabbing; user-select: none; }
.review-image-frame { position: relative; flex: 0 0 auto; box-sizing: border-box; margin: 0 auto; }
.review-image-stage { position: absolute; left: 50%; top: 50%; width: 0; max-width: none; box-sizing: border-box; box-shadow: 0 3px 16px rgba(26,38,41,.2); background: white; transform: translate(-50%, -50%) rotate(var(--review-rotation, 0deg)); transform-origin: center; }
.review-image-stage img { display: block; width: 100%; height: auto; background: white; user-select: none; -webkit-user-drag: none; }
.review-highlights { position: absolute; inset: 0; pointer-events: none; }
.review-highlight { position: absolute; min-height: 5px; border: 1px solid var(--highlight-color); border-radius: 3px; background: var(--highlight-color); opacity: .28; box-sizing: border-box; transform-origin: left top; animation: highlight-appear .18s ease-out both; }
@keyframes highlight-appear { from { opacity: 0; } to { opacity: .28; } }
.review-canvas iframe { width: 100%; height: 100%; border: 0; background: white; }
.review-empty { height: 100%; min-height: 240px; display: grid; place-items: center; align-content: center; gap: 10px; color: #69777b; }
.review-empty svg { width: 30px; }
.review-data { position: relative; z-index: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 22px; box-sizing: border-box; border-left: 1px solid var(--line); background: white; }
.review-data.is-editing { padding: 0; overflow: hidden; }
.review-data.is-editing > :not(.review-inline-editor) { display: none; }
.review-inline-editor { height: 100%; min-height: 0; }
.review-inline-editor #edit-form { display: grid; height: 100%; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; padding: 18px; box-sizing: border-box; }
.review-inline-editor .dialog-head h2 { margin-bottom: 12px; font-size: 18px; }
.review-inline-editor .edit-layout { min-height: 0; display: block; }
.review-inline-editor .edit-preview { display: none; }
.review-inline-editor .form-grid { max-height: none; height: 100%; grid-template-columns: 1fr; overflow-y: auto; padding-right: 6px; }
.review-inline-editor .dialog-actions { margin-top: 14px; }
.review-data-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.review-data-head > div { min-width: 0; }
.review-data-head small, .review-data-head strong { display: block; }
.review-data-head small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.review-data-head strong { margin-top: 5px; font-size: 20px; }
.review-state { padding: 5px 7px; border-radius: 4px; background: var(--amber-bg); color: #7a560e; font-size: 10px; font-weight: 800; }
.review-state.accepted { background: var(--green-bg); color: #176c4f; }
.review-state.rejected { background: #fae6e6; color: var(--red); }
.review-badges { display: grid; justify-items: end; gap: 6px; }
.review-source { max-width: 190px; padding: 5px 7px; border-radius: 4px; background: #e9eef0; color: #486168; font-size: 10px; font-weight: 800; line-height: 1.2; text-align: right; }
.review-source.qr { background: var(--green-bg); color: #176c4f; }
.review-validation { margin: 17px 0 14px; padding: 12px 13px; border-left: 4px solid var(--teal); background: #edf5f3; color: #315a57; font-size: 12px; line-height: 1.45; }
.review-validation.warning { border-color: var(--amber); background: var(--amber-bg); color: #73500c; }
.review-validation.error { border-color: var(--red); background: #fae6e6; color: #7c2727; }
.review-validation.qr-verified { border-color: #17845d; background: var(--green-bg); color: #176c4f; }
.review-validation p { margin: 6px 0 0; }
.review-accounting-controls { margin: 0 0 14px; padding: 12px; border: 1px solid #b7d1cc; background: #f2f8f6; }
.review-accounting-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.review-accounting-head strong { font-size: 13px; }
.review-accounting-head small { color: var(--muted); font-size: 11px; }
.review-accounting-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }
.review-accounting-grid label { display: grid; gap: 5px; color: #41565a; font-size: 11px; font-weight: 800; }
.review-accounting-grid select { width: 100%; height: 39px; border: 1px solid #9bbdb8; border-radius: 4px; background: white; padding: 0 9px; color: var(--ink); font-size: 12px; }
.review-accounting-grid select:focus { border-color: var(--teal); outline: 2px solid rgba(12, 123, 115, .15); }
.review-error-list { margin: 9px 0 0; padding-left: 18px; }
.review-error-list li { margin: 7px 0; }
.review-error-list strong, .review-error-list span { display: block; }
.review-error-list span { margin-top: 2px; font-size: 12px; }
.field-hint { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.35; }
.validation-status, .validation-error-title, .qr-badge { display: flex; align-items: center; gap: 8px; }
.validation-status svg, .validation-error-title svg { width: 17px; flex: 0 0 17px; }
.qr-badge { color: #0f6f4b; font-size: 16px; }
.qr-badge svg { width: 20px; flex: 0 0 20px; }
.qr-evidence-link { color: inherit; font-weight: 800; }
.review-fields { margin: 0; border-top: 1px solid var(--line); }
.review-fields div { display: grid; grid-template-columns: minmax(130px, .9fr) minmax(0, 1.1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid #e5e9ea; }
.review-fields dt { color: var(--muted); font-size: 12px; }
.review-field-label { display: inline-flex; align-items: center; gap: 7px; }
.review-field-color { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: var(--field-color); box-shadow: 0 0 0 2px color-mix(in srgb, var(--field-color) 18%, white); }
.review-fields dd { margin: 0; overflow-wrap: anywhere; font-size: 15px; font-weight: 750; text-align: right; }
.review-note { display: block; margin-top: 16px; color: var(--muted); font-size: 12px; font-weight: 700; }
.review-note textarea { width: 100%; margin-top: 5px; padding: 8px; resize: vertical; border: 1px solid #c5cccf; border-radius: 4px; font: inherit; letter-spacing: 0; }
.review-actions { position: static; margin: 18px 0 0; padding: 13px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: transparent; border-top: 1px solid var(--line); }
.review-actions #review-edit, .review-actions #review-reprocess { grid-column: 1 / -1; }
.review-actions .reject { color: var(--red); border-color: #dfb0b0; }

.settings-page { max-width: 1040px; margin: 0 auto; padding: 34px 28px 70px; }
.settings-head h1 { margin: 4px 0 26px; font-size: 28px; }
.settings-section { padding: 24px 0; border-top: 1px solid var(--line); }
.settings-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.settings-section-head h2 { margin: 0; font-size: 18px; }
.settings-section-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.settings-field { max-width: 520px; margin-top: 20px; display: grid; gap: 7px; color: #4f5b60; font-size: 12px; font-weight: 750; }
.settings-field select { width: 100%; height: 40px; border: 1px solid #b8c1c4; border-radius: 4px; background: white; padding: 0 10px; }
.settings-companies { margin-top: 18px; border-top: 1px solid var(--line); }
.settings-company-row { min-height: 55px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.settings-company-row strong, .settings-company-row small { display: block; }
.settings-company-row small { margin-top: 4px; color: var(--muted); }
.settings-company-row span { color: var(--teal); font-size: 11px; font-weight: 800; }
.settings-mobile { width: min(520px, 100%); margin-top: 20px; display: grid; grid-template-columns: 160px minmax(0, 1fr); align-items: center; gap: 18px; }
.settings-mobile img { width: 160px; height: 160px; border: 8px solid white; }
.settings-toggle { margin-top: 20px; display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 13px; font-weight: 750; cursor: pointer; }
.settings-toggle input { width: 18px; height: 18px; accent-color: var(--teal); }
.logs-page { min-height: calc(100vh - 64px); padding: 34px 28px 70px; background: var(--paper); }
.logs-head { max-width: 1100px; margin: 0 auto 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.logs-head h1 { margin: 4px 0 8px; font-size: 28px; }
.logs-head p:not(.eyebrow) { max-width: 620px; margin: 0; color: var(--muted); font-size: 13px; }
.logs-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.logs-status { color: var(--muted); font-size: 12px; font-weight: 750; }
.logs-actions .danger { color: var(--red); border-color: #dfb0b0; }
.logs-list { max-width: 1100px; margin: 0 auto; border-top: 1px solid var(--line); background: white; }
.log-entry { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.log-entry.error { border-left: 4px solid var(--red); }
.log-entry.warning { border-left: 4px solid var(--amber); }
.log-entry-meta { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.log-entry-meta span { padding: 3px 6px; border-radius: 4px; background: #e8efed; color: var(--teal-dark); font-size: 10px; font-weight: 850; }
.log-entry.error .log-entry-meta span { background: #fae6e6; color: var(--red); }
.log-entry strong { display: block; font-size: 13px; }
.log-entry code { display: block; margin-top: 7px; overflow-wrap: anywhere; color: var(--muted); font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.logs-empty { border-bottom: 0; }
.network-details { width: min(520px, 100%); margin: 18px 0 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.network-details div { display: grid; grid-template-columns: minmax(175px, .9fr) minmax(0, 1.1fr); gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.network-details dt { color: var(--muted); font-size: 12px; }
.network-details dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 12px; font-weight: 750; text-align: right; }

.itbis-page { max-width: 1120px; margin: 0 auto; padding: 34px 28px 70px; }
.itbis-head h1 { margin: 4px 0 24px; font-size: 28px; }
.itbis-controls { display: grid; grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(110px, .7fr)) repeat(2, minmax(120px, .8fr)) minmax(96px, auto); gap: 10px; align-items: end; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.itbis-controls > *, .itbis-import > *, .itbis-import-form > * { min-width: 0; }
.itbis-controls label, .itbis-import-form select, .itbis-import-form input { min-width: 0; }
.itbis-controls label { display: grid; gap: 6px; color: #4f5b60; font-size: 12px; font-weight: 750; }
.itbis-controls input, .itbis-controls select, .itbis-import-form select, .itbis-import-form input { width: 100%; height: 40px; border: 1px solid #b8c1c4; border-radius: 4px; background: white; padding: 0 10px; }
.itbis-import { display: grid; grid-template-columns: minmax(220px, .75fr) minmax(0, 1.25fr); gap: 18px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.itbis-import h2 { margin: 0; font-size: 18px; }
.itbis-import p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.itbis-import-form { display: grid; grid-template-columns: minmax(100px, .7fr) minmax(140px, 1fr) minmax(0, 1.2fr) minmax(96px, auto); gap: 9px; align-items: center; }
.itbis-import-form input[type="file"] { max-width: 100%; box-sizing: border-box; overflow: hidden; padding-left: 6px; }
.itbis-summary { display: grid; grid-template-columns: repeat(4, 1fr); margin: 20px 0 16px; border: 1px solid var(--line); background: white; }
.itbis-stat { padding: 14px 16px; border-right: 1px solid var(--line); }
.itbis-stat:last-child { border-right: 0; }
.itbis-stat small, .itbis-stat strong { display: block; }
.itbis-stat small { color: var(--muted); font-size: 12px; }
.itbis-stat strong { margin-top: 3px; font-size: 23px; }
.itbis-stat.warning-soft strong { color: #9a6506; }
.itbis-table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); }
.itbis-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.itbis-table th, .itbis-table td { height: 42px; padding: 9px 12px; border-bottom: 1px solid #e5e9ea; }
.itbis-table th { text-align: left; font-weight: 750; }
.itbis-table td:nth-child(2) { width: 54px; color: var(--muted); font-size: 12px; }
.itbis-table td:last-child { width: 190px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; }
.itbis-table tr.result { background: #f7faf9; }
.itbis-table tr.total { background: var(--deep); color: white; }
.itbis-table tr.total td:nth-child(2) { color: #cbd9da; }
.itbis-table-actions { display: flex; justify-content: flex-end; padding-top: 14px; }

.database-page { min-width: 0; padding: 30px 28px 64px; }
.database-head { max-width: 1360px; margin: 0 auto; }
.database-head h1 { margin: 4px 0 7px; font-size: 28px; }
.database-intro { max-width: 760px; margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.database-toolbar { max-width: 1360px; margin: 0 auto 12px; display: grid; grid-template-columns: minmax(260px, 1fr) minmax(200px, .45fr) auto; gap: 10px; align-items: end; padding: 14px; border: 1px solid #c8d8d5; background: #e4efed; }
.database-toolbar label { display: grid; gap: 6px; color: #4f5b60; font-size: 11px; font-weight: 800; }
.database-toolbar select, .database-search-field { width: 100%; height: 40px; border: 1px solid #9fb3b1; border-radius: 4px; background: white; }
.database-toolbar select { padding: 0 10px; }
.database-search-field { position: relative; display: flex; align-items: center; }
.database-search-field svg { width: 16px; margin-left: 10px; color: var(--muted); }
.database-search-field input { width: 100%; height: 38px; border: 0; outline: 0; padding: 0 10px; background: transparent; }
.database-clear { height: 40px; white-space: nowrap; }
.database-summary { max-width: 1360px; margin: 0 auto 10px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12px; }
.database-summary strong { color: var(--ink); font-size: 14px; }
.database-summary span + span { margin-left: auto; }
.database-hint { color: var(--muted); font-size: 11px; }
.database-table-wrap { max-width: 1360px; max-height: calc(100vh - 285px); min-height: 280px; margin: 0 auto; overflow: auto; border: 1px solid var(--line); background: white; }
.database-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; }
.database-table th { position: sticky; top: 0; z-index: 2; height: 40px; padding: 0; border-right: 1px solid #42636a; border-bottom: 1px solid #42636a; background: var(--deep); color: white; text-align: left; white-space: nowrap; }
.database-table th:last-child { border-right: 0; }
.database-sort { width: 100%; min-height: 39px; border: 0; padding: 0 10px; background: transparent; color: inherit; cursor: pointer; font-size: 11px; font-weight: 800; text-align: left; white-space: nowrap; }
.database-sort:hover, .database-sort:focus-visible { background: #28535b; outline: 0; }
.database-table td { height: 37px; max-width: 260px; padding: 7px 10px; border-right: 1px solid #edf0f0; border-bottom: 1px solid #e1e7e6; color: #283538; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.database-table tbody tr:nth-child(even) { background: #f8faf9; }
.database-table tbody tr:hover { background: #eaf4f1; }
.database-table td.database-number { min-width: 105px; text-align: right; font-variant-numeric: tabular-nums; }
.database-table td.database-tag-cell { color: var(--teal-dark); font-weight: 800; }
.database-table td.database-id-cell { min-width: 205px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.database-edit { margin-left: 9px; padding: 3px 7px; border: 1px solid #9bbdb8; border-radius: 3px; background: white; color: var(--teal-dark); cursor: pointer; font-family: inherit; font-size: 10px; font-weight: 800; }
.database-edit:hover, .database-edit:focus-visible { border-color: var(--teal); background: #e4efed; outline: 0; }
.database-documents-cell { min-width: 84px; white-space: nowrap; }
.database-document-link { display: inline-grid; width: 28px; height: 28px; margin-right: 5px; place-items: center; border: 1px solid #9bbdb8; border-radius: 3px; color: var(--teal-dark); background: white; vertical-align: middle; }
.database-document-link:hover, .database-document-link:focus-visible { border-color: var(--teal); background: #e4efed; outline: 0; }
.database-document-link svg { width: 15px; height: 15px; }
.database-empty { height: 180px !important; padding: 30px !important; color: var(--muted) !important; text-align: center; white-space: normal !important; }

@media (max-width: 1080px) and (min-width: 851px) {
  .itbis-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .itbis-controls label:first-child { grid-column: span 2; }
  .itbis-import-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1400px) {
  .workspace { grid-template-columns: 1fr; }
  .connection-panel { display: none; }
}

@media (max-width: 850px) {
  .app-nav { width: min(260px, calc(100vw - 48px)); transform: translateX(-102%); box-shadow: 14px 0 42px rgba(13,28,33,.25); }
  .nav-mobile-open .app-nav { transform: translateX(0); }
  .app-shell, .nav-collapsed .app-shell { margin-left: 0; }
  .nav-collapsed .app-nav { width: min(260px, calc(100vw - 48px)); }
  .nav-collapsed .app-nav .brand > div, .nav-collapsed .nav-link span, .nav-collapsed .nav-collapse span { display: block; }
  .nav-collapsed .nav-link, .nav-collapsed .nav-collapse { justify-content: flex-start; padding: 0 12px; }
  .nav-collapsed .nav-link b { position: static; margin: 0 0 0 auto; min-width: 21px; height: 21px; }
  .topbar { min-height: 0; padding: 9px 12px; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 8px; }
  .menu-button { display: grid; flex: 0 0 36px; }
  .view-heading { flex: 1; margin-left: 11px; }
  .status { display: none; }
  .company-switcher { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 7px; align-items: center; }
  .company-switcher select { width: 100%; min-width: 0; }
  .company-filter-prompt { grid-column: 1 / -1; width: max-content; max-width: 100%; white-space: normal; }
  .top-action span { display: none; }
  .top-action { width: 36px; padding: 0; justify-content: center; }
  .capture-band { grid-template-columns: 1fr; padding: 26px 16px; gap: 22px; }
  .capture-copy h1 { font-size: 27px; }
  .workspace { grid-template-columns: 1fr; padding: 20px 16px 90px; }
  .connection-panel { display: none; }
  .records-head { display: block; }
  .exports { margin-bottom: 14px; }
  .exports { display: grid; grid-template-columns: 1fr 1fr; }
  .exports input[type="month"] { grid-column: 1 / -1; width: 100%; }
  .company-export-bar { grid-template-columns: 1fr 1fr; }
  .export-company-copy, .company-export-bar input { grid-column: 1 / -1; width: 100%; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .toolbar { display: grid; grid-template-columns: 1fr; }
  .toolbar select { width: 100%; }
  .record { grid-template-columns: 58px 1fr auto; gap: 10px; padding: 13px 2px; }
  .thumb { width: 52px; height: 52px; }
  .record-meta { grid-column: 2; }
  .record-total { grid-column: 3; grid-row: 1; }
  .record-total { gap: 7px; }
  .pill { grid-column: 2; }
  .validation { grid-column: 2; }
  .record-actions { grid-column: 3; grid-row: 2 / 4; flex-direction: column; }
  .edit-action { width: 32px; padding: 0; }
  .edit-action span { display: none; }
  .edit-layout { grid-template-columns: 1fr; }
  .edit-preview { height: 210px; }
  .form-grid { grid-template-columns: 1fr; max-height: 58vh; overflow-y: auto; padding-right: 4px; }
  .form-grid label.wide { grid-column: auto; }
  .review-page { height: auto; min-height: calc(100vh - 64px); }
  .review-head { min-height: 48px; padding: 7px 16px; }
  .review-head h2 { font-size: 17px; }
  .review-navigation { margin-left: 0; }
  .review-filters { padding: 8px 16px; grid-template-columns: minmax(0, 1fr) max-content max-content; }
  .review-filters select { grid-column: 1 / -1; }
  .review-layout { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(340px, 48vh) auto; overflow-y: auto; }
  .review-layout.list-collapsed { grid-template-rows: 0 minmax(340px, 48vh) auto; }
  .review-list { display: flex; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); }
  .review-layout.list-collapsed .review-list { height: 0; min-height: 0; overflow: hidden; border: 0; }
  .review-list-item { flex: 0 0 210px; border-right: 1px solid var(--line); }
  .review-viewer { height: auto; min-height: 0; }
  .review-data { overflow: visible; border-left: 0; border-top: 1px solid var(--line); }
  .review-data.is-editing { overflow: visible; }
  .review-inline-editor { height: auto; }
  .review-inline-editor #edit-form { height: auto; }
  .review-inline-editor .form-grid { height: auto; max-height: 62vh; }
  .settings-page { padding: 26px 16px 70px; }
  .logs-page { padding: 26px 16px 70px; }
  .logs-head { display: block; }
  .logs-actions { margin-top: 16px; justify-content: flex-start; }
  .itbis-page { padding: 26px 16px 70px; }
  .itbis-controls { grid-template-columns: 1fr 1fr; }
  .itbis-controls label:first-child, .itbis-controls .primary { grid-column: 1 / -1; }
  .itbis-import { grid-template-columns: 1fr; }
  .itbis-import-form { grid-template-columns: 1fr; }
  .itbis-summary { grid-template-columns: repeat(2, 1fr); }
  .itbis-stat:nth-child(2) { border-right: 0; }
  .itbis-stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .database-page { padding: 26px 16px 70px; }
  .database-toolbar { grid-template-columns: 1fr; padding: 12px; }
  .database-clear { width: 100%; }
  .database-table-wrap { max-height: calc(100vh - 330px); min-height: 240px; }
  .database-summary { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
  .database-summary span + span { margin-left: 0; }
  .database-hint { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .app-nav .brand small { display: block; }
  .app-nav .brand-mark { display: grid; }
  .app-nav .brand strong { font-size: 15px; }
  .view-heading small { display: none; }
  .company-filter-prompt { max-width: 100%; white-space: normal; }
  .company-switcher select { width: 100%; font-size: 12px; }
  .segmented span { font-size: 12px; padding: 0 4px; }
  .file-pickers { grid-template-columns: 1fr; }
  .exports .secondary { flex: 1; }
  .record { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .settings-section-head { display: block; }
  .settings-section-head .primary { width: 100%; margin-top: 14px; }
  .settings-mobile { grid-template-columns: 1fr; }
  .network-details div { grid-template-columns: 1fr; gap: 3px; }
  .network-details dd { text-align: left; }
  .itbis-controls { grid-template-columns: 1fr; }
  .itbis-summary { grid-template-columns: 1fr; }
  .itbis-stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .itbis-stat:last-child { border-bottom: 0; }
  .review-head { display: flex; }
  .review-navigation { margin-left: 0; }
  .review-list-toggle { width: 100%; }
  .review-source { max-width: 145px; }
  .review-data { padding: 18px 16px; }
  .review-actions { margin-right: 0; margin-left: 0; padding-right: 0; padding-left: 0; }
}
.account-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; color: white; font-weight: 650; }
.account-actions form { margin: 0; }
.password-change-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; align-items: end; }
.password-change-form label { display: grid; gap: 6px; color: #344d52; font-weight: 600; }
.password-change-form input { min-height: 42px; padding: 8px 10px; border: 1px solid #cbd6d5; border-radius: 8px; font: inherit; }
.password-change-form button { min-height: 42px; }
