:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-muted: #f7f8f5;
  --ink: #1c2521;
  --muted: #69736e;
  --line: #dce1dd;
  --line-strong: #cbd2cd;
  --green: #176b4d;
  --green-dark: #0f543c;
  --green-soft: #e8f3ed;
  --amber: #a76612;
  --amber-soft: #fbf0dc;
  --red: #b33a36;
  --red-soft: #fbeae8;
  --blue: #315f86;
  --blue-soft: #eaf1f7;
  --shadow: 0 12px 35px rgba(26, 38, 31, .08);
  --sidebar: 88px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf0ed; }
.login-panel { width: min(390px, 100%); padding: 30px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-brand .brand-mark { color: #fff; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 17px; }
.login-brand small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.login-heading { margin: 30px 0 22px; }
.login-heading h1 { margin: 0 0 6px; font-size: 24px; }
.login-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.login-panel .field { display: block; margin-bottom: 15px; }
.login-panel .field span { display: block; margin-bottom: 7px; color: #4e5752; font-size: 12px; font-weight: 600; }
.login-submit { width: 100%; margin-top: 5px; }
.login-error { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 11px; text-align: center; }
.busy { opacity: .65; pointer-events: none; }
.skeleton-row td { color: var(--muted); text-align: center !important; }
.document-button { min-width: 58px; height: 29px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; cursor: pointer; font-size: 11px; }
.document-button:hover { border-color: var(--green); color: var(--green); }
.document-button:disabled { opacity: .55; cursor: not-allowed; }
.status-text { color: var(--muted); font-size: 11px; white-space: nowrap; }
.status-text.success { color: var(--green); }
.status-text.warning { color: var(--amber); }
.status-text.error { color: var(--red); }
.modal-error { padding: 10px 12px; color: var(--red); border: 1px solid #efc4c1; background: var(--red-soft); font-size: 11px; }
.invoice-pagination { margin-top: auto; padding: 9px 12px; display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); background: #fff; font-size: 11px; color: var(--muted); }
.invoice-pagination div { display: flex; gap: 5px; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-summary { display: flex; align-items: center; gap: 20px; color: var(--muted); font-size: 11px; }
.inline-summary strong { margin-left: 4px; color: var(--ink); }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar); padding: 14px 8px;
  display: flex; flex-direction: column; color: #eef3ef; background: #202824; border-right: 1px solid #303a35;
}
.brand { height: 64px; padding: 0 0 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-bottom: 1px solid #36413b; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid #56806d; background: #294b3c; border-radius: 6px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 12px; white-space: nowrap; }
.brand small { display: none; }
.main-nav { display: grid; gap: 4px; margin-top: 16px; }
.nav-item { width: 100%; height: 56px; padding: 5px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; border-radius: 5px; color: #aebbb4; background: transparent; cursor: pointer; text-align: center; white-space: nowrap; font-size: 11px; }
.nav-item:hover { color: #fff; background: #2b3530; }
.nav-item.active { color: #fff; background: #176b4d; }
.sidebar-foot { margin-top: auto; display: grid; gap: 14px; }
.operator { padding: 12px 2px 2px; display: flex; flex-direction: column; align-items: center; gap: 5px; border-top: 1px solid #36413b; text-align: center; }
.operator strong, .operator small { display: block; }
.operator small { display: none; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #d9e7df; color: #1b513c; font-weight: 700; }

.main-area { margin-left: var(--sidebar); min-width: 0; }
.topbar { height: 62px; padding: 0 26px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-left > svg { width: 14px; color: #a2aaa5; }
.topbar-left strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb, .today { color: var(--muted); font-size: 13px; }
.today { margin-left: 4px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 5px; background: transparent; cursor: pointer; position: relative; }
.icon-button:hover { background: var(--surface-muted); border-color: var(--line); }
.has-dot::after { content: ""; width: 6px; height: 6px; position: absolute; top: 7px; right: 7px; border-radius: 50%; background: #d65f4c; border: 1px solid white; }
.mobile-only { display: none; }

.workspace { width: min(1720px, 100%); margin: 0 auto; padding: 26px 28px 48px; }
.hidden { display: none !important; }
.list-page-heading { min-height: 92px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.list-page-heading h1 { margin: 5px 0 5px; font-size: 27px; }
.list-page-heading p { margin: 0; color: var(--muted); }
.page-kicker { color: var(--green); font-size: 12px; font-weight: 700; }
.list-toolbar { min-height: 62px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.search-field { width: min(380px, 100%); height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 4px; }
.search-field svg { width: 16px; color: var(--muted); }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); }
.segmented button { height: 29px; padding: 0 11px; border: 0; border-radius: 3px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.segmented button.active { color: var(--green); background: #fff; box-shadow: 0 1px 3px rgba(25,38,31,.1); font-weight: 700; }
.list-table-band { margin-top: 14px; }
.list-table-scroll { overflow-x: auto; }
.list-table { width: 100%; min-width: 1080px; border-collapse: collapse; font-size: 12px; }
.list-table th { height: 44px; padding: 9px 12px; color: var(--muted); background: #f5f7f4; border-bottom: 1px solid var(--line-strong); text-align: left; white-space: nowrap; }
.list-table td { height: 58px; padding: 9px 12px; border-bottom: 1px solid #e7eae7; vertical-align: middle; }
.list-table tbody tr:hover { background: #fafbf9; }
.list-table .num { text-align: right; }
.project-list-table :is(th, td):nth-child(6),
.project-list-table :is(th, td):nth-child(7),
.company-list-table :is(th, td):nth-child(6),
.company-list-table :is(th, td):nth-child(7),
.company-list-table :is(th, td):nth-child(8),
.company-list-table :is(th, td):nth-child(9),
.company-list-table :is(th, td):nth-child(10) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.company-list-table { min-width: 1450px; }
.company-list-table :is(th, td):nth-child(4),
.company-list-table :is(th, td):nth-child(5) { text-align: center; }
.driver-list-table { min-width: 760px; }
.company-list-table th:last-child, .company-list-table td:last-child { text-align: center; }
.row-actions { display: flex; align-items: center; justify-content: center; gap: 5px; }
.list-primary strong, .list-primary small { display: block; }
.list-primary small { margin-top: 4px; color: var(--muted); }
.library-summary { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 12px; }
.library-summary strong { margin-left: 4px; color: var(--ink); }
.company-detail { min-width: 0; display: grid; gap: 20px; }
.detail-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 5px; background: #f8faf8; }
.detail-metrics > div { min-height: 82px; padding: 14px 16px; border-right: 1px solid var(--line); }
.detail-metrics > div:last-child { border-right: 0; }
.detail-metrics small, .detail-metrics strong { display: block; }
.detail-metrics small { color: var(--muted); font-size: 11px; }
.detail-metrics strong { margin-top: 9px; font-size: 18px; font-variant-numeric: tabular-nums; }
.detail-section { min-width: 0; border-top: 1px solid var(--line); padding-top: 16px; }
.detail-section-head { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.detail-section-head h4 { margin: 0 0 3px; font-size: 14px; }
.detail-section-head p { margin: 0; color: var(--muted); font-size: 11px; }
.detail-table-scroll { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
.detail-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 11px; }
.detail-table th, .detail-table td { min-height: 40px; padding: 9px 10px; border-bottom: 1px solid #e8ebe8; text-align: left; vertical-align: middle; }
.detail-table th { color: var(--muted); background: #f5f7f4; white-space: nowrap; }
.detail-table tr:last-child td { border-bottom: 0; }
.detail-table .num { text-align: right; }
.detail-table strong, .detail-table small { display: block; }
.detail-table small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.empty-state-compact { padding: 24px; border: 1px dashed var(--line-strong); color: var(--muted); text-align: center; font-size: 12px; }
.settlement-summary { margin-bottom: 18px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 5px; }
.settlement-summary span { padding: 12px 14px; color: var(--muted); font-size: 11px; border-right: 1px solid var(--line); }
.settlement-summary span:last-child { border-right: 0; }
.settlement-summary strong { display: block; margin-top: 6px; color: var(--ink); font-size: 16px; }
.reconciliation-summary { margin-top: 14px; padding: 12px; display: flex; justify-content: flex-end; gap: 30px; border-top: 1px solid #8c928e; }
.month-switch { margin-right: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.month-switch input { height: 34px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 4px; }
.project-heading { min-height: 90px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.project-heading h1 { margin: 7px 0 6px; font-size: 27px; line-height: 1.25; letter-spacing: 0; }
.project-heading p { margin: 0; color: var(--muted); }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 12px; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2b9c6b; box-shadow: 0 0 0 3px #dff1e8; }
.project-code { color: #8b938e; font-weight: 500; }
.heading-actions { display: flex; align-items: center; gap: 8px; }
.button { min-height: 36px; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 13px; }
.button.primary { color: #fff; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: #fff; border-color: var(--line-strong); }
.button.secondary:hover, .button.ghost:hover { border-color: #aeb8b1; background: #f9faf8; }
.button.ghost { color: var(--green); background: transparent; border-color: var(--line); }
.button.danger { color: var(--red); background: #fff; border-color: #e6c4c1; }
.button.small { min-height: 30px; padding: 0 9px; font-size: 12px; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.health-bar { min-height: 40px; margin: 8px 0 14px; padding: 9px 13px; display: flex; align-items: center; gap: 9px; border: 1px solid; border-radius: 5px; font-size: 13px; }
.health-bar.success { color: #145b41; border-color: #bcdaca; background: #edf7f1; }
.health-bar.warning { color: #87500c; border-color: #e5c891; background: #fff7e8; }
.health-bar strong { margin-left: 2px; }
.health-bar .health-detail { margin-left: auto; font-variant-numeric: tabular-nums; }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.metric { min-height: 105px; padding: 17px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric > span, .metric small { display: block; color: var(--muted); }
.metric > span { font-size: 12px; }
.metric strong { display: block; margin: 8px 0 6px; font-size: 20px; font-variant-numeric: tabular-nums; }
.metric small { font-size: 11px; }
.metric.emphasis { background: #f2f7f4; }
.metric.emphasis strong { color: var(--green); }

.section-band { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.section-title-row { min-height: 68px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.section-title-row h2 { margin: 0 0 4px; font-size: 15px; }
.section-title-row p { margin: 0; color: var(--muted); font-size: 12px; }
.chain-flow { min-height: 94px; padding: 18px; display: flex; align-items: center; overflow-x: auto; }
.chain-node { min-width: 132px; position: relative; display: flex; align-items: center; flex: 0 0 auto; }
.chain-company { min-width: 102px; height: 54px; padding: 7px 9px; display: flex; flex-direction: column; justify-content: center; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; }
.chain-company strong { font-size: 12px; white-space: nowrap; }
.chain-company small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.chain-company.origin { border-color: #78ad95; background: #eef7f2; }
.chain-company.terminal { border-color: #d3b97f; background: #fff8ea; }
.chain-arrow { width: 30px; display: grid; place-items: center; color: #92a099; }
.chain-arrow svg { width: 15px; }

.legend { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.ready { background: #3f946b; }.legend-dot.pending { background: #d59c3d; }.legend-dot.warn { background: #c6564e; }
.table-scroll { overflow-x: auto; }
.business-table { width: 100%; min-width: 1050px; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.business-table th:nth-child(1) { width: 145px; }
.business-table th:nth-child(2) { width: 72px; }
.business-table th:nth-child(3) { width: 76px; }
.business-table th:nth-child(4), .business-table th:nth-child(5) { width: 82px; }
.business-table th:nth-child(6) { width: 68px; }
.business-table th:nth-child(7) { width: 90px; }
.business-table th:nth-child(8) { width: 64px; }
.business-table th:nth-child(9) { width: 80px; }
.business-table th:nth-child(10) { width: 88px; }
.business-table th:nth-child(11) { width: 88px; }
.business-table th:nth-child(12) { width: 115px; }
.business-table th { position: sticky; top: 0; z-index: 4; height: 43px; padding: 8px 7px; color: #5f6863; background: #f5f7f4; border-bottom: 1px solid var(--line-strong); text-align: left; white-space: nowrap; font-weight: 600; }
.business-table th:nth-child(2),
.business-table th:nth-child(3),
.business-table th:nth-child(4),
.business-table th:nth-child(5),
.business-table th:nth-child(6),
.business-table th:nth-child(10) { text-align: right; }
.business-table th:nth-child(7),
.business-table th:nth-child(8),
.business-table th:nth-child(9),
.business-table th:nth-child(11),
.business-table th:nth-child(12),
.business-table td:nth-child(7),
.business-table td:nth-child(8),
.business-table td:nth-child(9),
.business-table td:nth-child(11),
.business-table td:nth-child(12) { text-align: center; }
.business-table td { height: 52px; padding: 7px; border-bottom: 1px solid #e6e9e6; vertical-align: middle; background: #fff; }
.business-table tbody tr:hover td { background: #fafbf9; }
.business-table .sticky-col { position: sticky; left: 0; z-index: 3; min-width: 176px; box-shadow: 1px 0 0 var(--line); }
.business-table th.sticky-col { z-index: 6; background: #f5f7f4; }
.business-table tfoot td { height: 48px; position: sticky; bottom: 0; z-index: 2; background: #f7f9f6; border-top: 1px solid var(--line-strong); font-weight: 600; }
.company-cell strong, .company-cell small { display: block; }
.company-cell small { margin-top: 4px; color: var(--muted); }
.company-cell .company-index { margin-right: 6px; color: #9aa29d; font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-positive { color: var(--green); font-weight: 700; }
.money-due { color: var(--red); font-weight: 700; }
.money-zero { color: #76807a; }
.edit-number { width: 76px; height: 32px; padding: 0 8px; border: 1px solid #bfc8c2; border-radius: 4px; text-align: right; background: #fffdf7; font-variant-numeric: tabular-nums; }
.edit-number:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(23,107,77,.15); border-color: var(--green); }
.doc-action { display: flex; align-items: center; gap: 5px; }
.table-action { min-height: 28px; padding: 0 8px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; font-size: 11px; white-space: nowrap; }
.table-action:hover { border-color: #81a793; color: var(--green); }
.table-action svg { width: 14px; height: 14px; }
.table-action.success { color: #176143; border-color: #bfd8ca; background: #f1f8f4; }
.table-action.pending { color: #8a560e; border-color: #e4cfaa; background: #fffaf0; }
.table-action.neutral { color: #59635d; }
.mini-count { min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 9px; color: #fff; background: var(--green); font-size: 10px; }
.badge { min-height: 24px; padding: 3px 7px; display: inline-flex; align-items: center; gap: 5px; border-radius: 3px; white-space: nowrap; font-size: 11px; font-weight: 600; }
.badge.success { color: #176143; background: var(--green-soft); }.badge.pending { color: #8a560e; background: var(--amber-soft); }.badge.danger { color: #9b342f; background: var(--red-soft); }.badge.info { color: #315f86; background: var(--blue-soft); }.badge.neutral { color: #626b66; background: #eef0ee; }
.progress-cell { display: flex; align-items: center; }
.progress-trigger { padding: 0; border: 0; background: transparent; cursor: pointer; }
.progress-trigger:hover .badge { box-shadow: inset 0 0 0 1px #7aa58f; }
.terminal-row td { background: #fbfaf5; color: #69706c; }

.activity-list { padding: 2px 18px 12px; }
.activity-item { min-height: 52px; display: grid; grid-template-columns: 145px 100px 1fr; align-items: center; gap: 16px; border-bottom: 1px solid #edf0ed; font-size: 12px; }
.activity-item:last-child { border-bottom: 0; }
.activity-time, .activity-user { color: var(--muted); }

.modal-layer { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(21,28,24,.48); }
.modal-layer.open { display: flex; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: #fff; border: 1px solid #bfc8c2; border-radius: 7px; box-shadow: var(--shadow); overflow: hidden; }
.modal.medium { width: min(900px, calc(100vw - 48px)); }
.modal.large { width: min(1120px, calc(100vw - 48px)); }
.modal.wide { width: min(1220px, calc(100vw - 48px)); }
.modal.xlarge { width: min(1500px, calc(100vw - 48px)); }
.modal-head { min-height: 62px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0 0 3px; font-size: 17px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 11px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { min-height: 62px; padding: 12px 18px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); background: #fafbf9; }
.modal-notice { padding: 10px 12px; color: #87500c; border: 1px solid #e5c891; border-radius: 4px; background: #fff7e8; font-size: 11px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; color: #4e5752; font-size: 12px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; color: var(--ink); }
.field textarea { min-height: 76px; resize: vertical; }
.field small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.field-error { min-height: 17px; margin-top: 4px; color: var(--red); font-size: 11px; }
.inline-fields { display: grid; grid-template-columns: 1fr 20px 1fr; align-items: center; gap: 8px; }
.inline-fields > span { text-align: center; color: var(--muted); }
.divider { height: 1px; margin: 20px 0; background: var(--line); }

.chain-editor { display: grid; grid-template-columns: minmax(250px, .8fr) minmax(360px, 1.2fr); gap: 18px; }
.chain-draft-summary { min-height: 48px; margin-bottom: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 14px; border: 1px solid; border-radius: 5px; font-size: 12px; }
.chain-draft-summary.success { color: #145b41; border-color: #bcdaca; background: #edf7f1; }
.chain-draft-summary.warning { color: #87500c; border-color: #e5c891; background: #fff7e8; }
.chain-draft-summary > span:nth-child(2) { margin-left: auto; }
.editor-panel { border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.editor-panel h4 { margin: 0; padding: 11px 13px; background: var(--surface-muted); border-bottom: 1px solid var(--line); font-size: 12px; }
.company-library { max-height: 360px; overflow: auto; }
.company-option { min-height: 48px; padding: 8px 11px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #edf0ed; }
.selected-company { min-height: 48px; padding: 8px 11px; display: grid; grid-template-columns: 56px minmax(260px, 1fr) 150px 56px; align-items: center; gap: 12px; border-bottom: 1px solid #edf0ed; }
.company-option:last-child, .selected-company:last-child { border-bottom: 0; }
.company-option strong, .company-option small, .selected-company strong, .selected-company small { display: block; }
.company-option small, .selected-company small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.selected-company-name { min-width: 130px; }
.selected-company-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.chain-profit-field { height: 32px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.chain-profit-field input { width: 70px; height: 30px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 4px; text-align: right; color: var(--ink); background: #fffdf7; font-variant-numeric: tabular-nums; }
.chain-profit-field input:focus { outline: 2px solid rgba(23,107,77,.15); border-color: var(--green); }
.chain-profit-field small { width: 38px; margin: 0; white-space: nowrap; }
.row-tools { display: flex; gap: 4px; }
.row-tools button { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; }
.row-tools svg { width: 13px; }
.chain-grid-head { min-height: 38px; padding: 7px 11px; display: grid; grid-template-columns: 56px minmax(260px, 1fr) 150px 56px; align-items: center; gap: 12px; color: var(--muted); background: #fafbf9; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; }
.chain-grid-head span:first-child, .chain-grid-head span:last-child, .chain-row-number { text-align: center; }
.selected-company select, .chain-profit-input { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; }
.chain-profit-input { text-align: right; font-variant-numeric: tabular-nums; }
.selected-company > .icon-button { justify-self: center; color: var(--red); }

.document-preview { padding: 28px 34px; border: 1px solid #d4d7d4; background: #fff; box-shadow: 0 4px 20px rgba(26,38,31,.06); color: #242824; line-height: 1.8; }
.signed-document-preview { min-height: min(72vh, 900px); display: flex; align-items: center; justify-content: center; border: 1px solid #d4d7d4; background: #f5f7f5; }
.signed-document-preview iframe { width: 100%; height: min(76vh, 980px); border: 0; background: #fff; }
.signed-document-preview img { display: block; max-width: 100%; max-height: min(76vh, 980px); object-fit: contain; background: #fff; }
.document-form-panel { margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 5px; background: #f8faf8; }
.auto-field-note { margin-top: 12px; padding-top: 10px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.driver-selection-preview { margin-top: 14px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #cdd9d2; border-radius: 4px; background: #fff; color: var(--muted); font-size: 11px; }
.pickup-setup-body { display: grid; gap: 16px; }
.pickup-config-summary { min-height: 66px; padding: 10px 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 5px; background: #f8faf8; }
.pickup-config-summary > div { min-width: 0; }
.pickup-config-summary small, .pickup-config-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pickup-config-summary small { color: var(--muted); font-size: 9px; }
.pickup-config-summary strong { margin-top: 5px; font-size: 11px; }
.pickup-config-editor { margin: 0; }
.pickup-config-actions { margin-top: 15px; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); }
.pickup-config-actions span { color: var(--muted); font-size: 10px; }
.pickup-driver-panel { border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.pickup-driver-head { min-height: 64px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #f7f9f7; border-bottom: 1px solid var(--line); }
.pickup-driver-head h4 { margin: 0 0 4px; font-size: 13px; }
.pickup-driver-head p { margin: 0; color: var(--muted); font-size: 10px; }
.pickup-driver-table-wrap { overflow: visible; }
.pickup-driver-table { width: 100%; min-width: 1180px; border-collapse: collapse; font-size: 11px; }
.pickup-driver-table th, .pickup-driver-table td { padding: 8px 10px; border-bottom: 1px solid #e8ebe8; text-align: left; vertical-align: middle; }
.pickup-driver-table th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f5f7f4; }
.pickup-driver-table :is(th, td):nth-child(3),
.pickup-driver-table :is(th, td):nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pickup-driver-table td strong, .pickup-driver-table td small { display: block; }
.pickup-driver-table td small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.pickup-driver-table .row-index { width: 48px; color: var(--muted); text-align: center; }
.pickup-driver-table th:first-child { width: 48px; text-align: center; }
.pickup-driver-table th:last-child, .pickup-driver-table td:last-child { width: 126px; text-align: center; }
.pickup-driver-table input { width: 100%; min-width: 110px; height: 32px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; }
.pickup-driver-table input[type="date"] { background: #fff; color: var(--ink); color-scheme: light; }
.pickup-driver-table input:disabled { opacity: 1; color: var(--ink); background: #fff; }
.pickup-driver-table input.num { text-align: right; }
.pickup-driver-table .danger-icon { color: var(--red); }
.driver-rows-empty, .invalid-row td { padding: 22px !important; color: var(--muted); text-align: center !important; }
.invalid-row td { color: var(--red); background: var(--red-soft); }
.pickup-driver-total { min-height: 46px; padding: 9px 12px; display: flex; align-items: center; justify-content: flex-end; gap: 20px; font-size: 11px; border-top: 1px solid var(--line); }
.pickup-driver-total.success { color: #145b41; background: #edf7f1; }
.pickup-driver-total.warning { color: #87500c; background: #fff7e8; }
.pickup-row-editor-host { display: none; border-top: 1px solid var(--line); background: #f7f9f7; }
.pickup-row-editor-host.open { display: block; }
.pickup-row-editor { padding: 14px; }
.pickup-row-editor-head { margin-bottom: 13px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pickup-row-editor-head h4 { margin: 0 0 4px; font-size: 13px; }
.pickup-row-editor-head p { margin: 0; color: var(--muted); font-size: 10px; }
.pickup-driver-table tr.driver-match-open { position: relative; z-index: 20; }
.plate-lookup-field { position: relative; }
.pickup-driver-table tr.driver-match-open .plate-lookup-field { z-index: 21; }
.plate-match-dropdown { width: 100%; min-width: 260px; max-height: 220px; position: absolute; left: 0; top: calc(100% - 1px); z-index: 30; display: none; overflow-y: auto; border: 1px solid #9db4a7; border-radius: 4px; background: #fff; box-shadow: 0 10px 24px rgba(26,38,31,.14); }
.plate-match-dropdown.open { display: grid; }
.plate-match-dropdown button { min-height: 52px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; }
.plate-match-dropdown button:last-child { border-bottom: 0; }
.plate-match-dropdown button:hover { background: #f1f7f3; }
.plate-match-dropdown strong, .plate-match-dropdown small { display: block; }
.plate-match-dropdown small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.plate-match-dropdown b { color: var(--green); font-size: 10px; }
.pickup-row-editor-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }
.document-preview h2 { margin: 0 0 18px; text-align: center; font-size: 22px; }
.document-company-name { text-align: center; font-size: 15px; font-weight: 700; }
.document-preview .contract-no { text-align: right; font-size: 12px; }
.contract-meta-lines { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 22px; margin: 14px 0; }
.contract-intro, .contract-clauses p { text-align: justify; }
.contract-clauses p { margin: 7px 0; line-height: 1.75; }
.contract-end { margin-top: 16px !important; text-align: center !important; }
.contract-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 16px 0; }
.contract-table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 12px; }
.contract-table th, .contract-table td { padding: 8px; border: 1px solid #8c928e; text-align: center; }
.signature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; margin-top: 34px; }
.pickup-summary { display: flex; justify-content: space-between; gap: 20px; margin: 14px 0; padding: 10px 12px; border: 1px solid #a5aaa7; }
.document-note { padding: 10px 0; font-size: 12px; }
.upload-zone { min-height: 112px; display: grid; place-items: center; padding: 20px; border: 1px dashed #9eaaa3; border-radius: 5px; background: #fafbf9; text-align: center; cursor: pointer; }
.upload-zone:hover { border-color: var(--green); background: #f4f9f6; }
.upload-zone input { display: none; }
.upload-zone svg { margin-bottom: 7px; color: var(--green); }
.upload-zone strong, .upload-zone small { display: block; }
.upload-zone small { margin-top: 5px; color: var(--muted); }
.invoice-list { display: grid; gap: 8px; margin-bottom: 18px; }
.invoice-modal-body { padding: 0; }
.invoice-workbench { height: min(70vh, 720px); min-height: 600px; display: grid; grid-template-columns: minmax(360px, .8fr) minmax(620px, 1.2fr); }
.invoice-list-pane, .invoice-recognition-pane { min-width: 0; display: flex; flex-direction: column; }
.invoice-list-pane { border-right: 1px solid var(--line); background: #fafbf9; }
.invoice-pane-head { min-height: 68px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); background: #fff; }
.invoice-pane-head strong, .invoice-pane-head small { display: block; }
.invoice-pane-head small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.invoice-search { width: 160px; height: 34px; padding: 0 8px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 4px; }
.invoice-search svg { width: 14px; color: var(--muted); }
.invoice-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 11px; }
.invoice-long-list { min-height: 0; padding: 8px; display: grid; flex: 1 1 auto; align-content: start; gap: 6px; overflow-y: auto; }
.invoice-list-row { min-height: 64px; padding: 8px 9px; display: grid; grid-template-columns: minmax(0, 1fr) 100px auto; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.invoice-list-row.mismatch { border-color: #d98580; background: var(--red-soft); box-shadow: inset 4px 0 0 var(--red); }
.invoice-list-row.deleted { opacity: .68; background: #f3f3f2; }
.invoice-list-row strong, .invoice-list-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-list-row small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.invoice-state-label.mismatch { width: fit-content; padding: 3px 7px; color: #8f2825; border: 1px solid #dfa19d; border-radius: 3px; background: #fff; font-size: 11px; font-weight: 700; }
.invoice-row-action { display: flex; justify-content: flex-end; }
.invoice-empty, .recognition-empty { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); text-align: center; }
.invoice-empty strong, .invoice-empty span, .recognition-empty strong, .recognition-empty span { display: block; }
.invoice-empty span, .recognition-empty span { font-size: 10px; }
.invoice-recognition-pane { padding-bottom: 14px; }
.invoice-recognition-pane > .invoice-pane-head { margin-bottom: 14px; }
.invoice-upload { margin: 0 14px; }
.recognition-result { margin: 14px; }
.recognition-queue-head { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recognition-queue-head span { color: var(--muted); font-size: 10px; }
.recognition-queue { max-height: 270px; display: grid; gap: 7px; overflow-y: auto; }
.recognized-invoice { padding: 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.recognized-invoice.mismatch { border-color: #d98580; }
.recognized-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.invoice-mismatch-alert { margin-top: 10px; padding: 10px 12px; color: #7f2421; border: 1px solid #d98580; border-left: 4px solid var(--red); background: var(--red-soft); }
.invoice-mismatch-alert strong, .invoice-mismatch-alert span { display: block; }
.invoice-mismatch-alert strong { font-size: 13px; }.invoice-mismatch-alert span { margin-top: 4px; font-size: 10px; }
.recognized-fields { margin-top: 9px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.recognized-fields > div { min-width: 0; padding: 7px; border: 1px solid #e7eae7; background: #f8faf8; }
.recognized-fields > div.mismatch { color: #7f2421; border-color: #d98580; background: var(--red-soft); }
.recognized-fields small, .recognized-fields strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recognized-fields small, .request-id { color: var(--muted); font-size: 9px; }
.recognized-fields strong { margin-top: 3px; font-size: 10px; }
.request-id { display: block; margin-top: 7px; }
.invoice-submit { width: 100%; margin-top: 10px; }
.invoice-recognition-pane > .comparison-box { margin: auto 14px 0; }
.invoice-item { min-height: 58px; padding: 9px 11px; display: grid; grid-template-columns: 1fr 120px 100px auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 4px; }
.invoice-item strong, .invoice-item small { display: block; }
.invoice-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.comparison-box { margin-top: 16px; padding: 12px; border: 1px solid var(--line); background: #f8faf8; border-radius: 4px; }
.comparison-box.mismatch { border-color: #d98580; background: #fff8f7; }
.comparison-box h4 { margin: 0 0 8px; font-size: 12px; }
.comparison-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.compare-field { padding: 8px; background: #fff; border: 1px solid #e1e5e1; }
.compare-field.mismatch { color: #7f2421; border-color: #d98580; background: var(--red-soft); }
.compare-field.matched strong { color: var(--green); }
.compare-field small, .compare-field strong { display: block; }
.compare-field small { color: var(--muted); font-size: 10px; }.compare-field strong { margin-top: 4px; font-size: 11px; }
.compare-field span { display: block; margin-top: 4px; font-size: 9px; line-height: 1.45; }

.chain-graph-modal { min-width: 0; }.chain-graph-summary { display:flex; align-items:baseline; justify-content:space-between; gap:16px; margin-bottom:12px; }.chain-graph-summary span { color:var(--muted); font-size:12px; }
.chain-graph-canvas { overflow-x:auto; border:1px solid var(--line); background:#fbfcfb; border-radius:5px; }.chain-graph-canvas svg { display:block; min-width:760px; width:100%; height:170px; }.chain-graph-edge path { stroke:#2a6750; stroke-width:2; fill:none; }.chain-graph-edge marker path { fill:#2a6750; }.chain-graph-edge text { fill:#53605a; font-size:11px; }.chain-graph-node circle { fill:#fff; stroke:#1f6b4c; stroke-width:2; }.chain-graph-node text { fill:#1c3026; font-size:12px; font-weight:700; }.chain-graph-node .chain-graph-index { fill:#7a847e; font-size:9px; font-weight:400; }
.chain-graph-editors { display:grid; gap:7px; margin-top:14px; }.chain-graph-editor-row { display:grid; grid-template-columns:28px minmax(180px,1fr) 210px 145px; align-items:center; gap:12px; padding:9px 10px; border:1px solid var(--line); background:#fff; }.chain-graph-editor-row > span { color:var(--muted); font-variant-numeric:tabular-nums; }.chain-graph-editor-row label { display:flex; align-items:center; justify-content:flex-end; gap:7px; color:var(--muted); font-size:11px; }.chain-graph-editor-row input { width:84px; text-align:right; }.chain-graph-editor-row small { color:var(--muted); font-size:10px; text-align:right; }.form-help { margin:12px 0 0; color:var(--muted); font-size:11px; }

.toast-region { position: fixed; top: 76px; right: 22px; z-index: 100; width: min(360px, calc(100vw - 32px)); display: grid; gap: 8px; }
.toast { min-height: 48px; padding: 11px 13px; display: flex; align-items: flex-start; gap: 9px; color: #fff; background: #26322c; border-radius: 5px; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: #913934; }.toast.success { background: #176143; }
.toast strong, .toast small { display: block; }.toast small { margin-top: 3px; opacity: .8; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1180px) {
  .metric-strip { grid-template-columns: repeat(3, 1fr); }.metric:nth-child(3) { border-right: 0; }.metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .sidebar { width: 220px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  body.menu-open .sidebar { transform: translateX(0); }.sidebar .brand { height: 48px; flex-direction: row; justify-content: flex-start; padding: 0 8px 12px; }.sidebar .brand > span:last-child, .sidebar .nav-item span, .sidebar .operator > span:last-child { display: block; }.sidebar .nav-item { height: 42px; flex-direction: row; justify-content: flex-start; padding: 0 11px; font-size: 14px; }.sidebar .operator { flex-direction: row; justify-content: flex-start; padding-inline: 8px; text-align: left; }
  .mobile-only { display: grid; }.topbar { padding: 0 14px; }.today, .crumb { display: none; }
  .workspace { padding: 18px 14px 36px; }.project-heading { display: block; }.heading-actions { margin-top: 17px; flex-wrap: wrap; }.heading-actions .button { flex: 1 1 calc(50% - 4px); }
  .list-page-heading { display: block; }.list-page-heading .heading-actions { width: 100%; margin-top: 16px; }.list-page-heading .heading-actions .button { flex: 1; margin-top: 0; }.list-page-heading > .button { width: 100%; margin-top: 16px; }.list-toolbar { align-items: stretch; flex-direction: column; }.search-field { width: 100%; }.library-summary { justify-content: space-between; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }.metric { min-height: 96px; padding: 14px; border-bottom: 1px solid var(--line); }.metric:nth-child(odd) { border-right: 1px solid var(--line); }.metric:nth-child(even) { border-right: 0; }.metric:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .section-title-row { align-items: flex-start; }.legend { display: none; }.chain-flow { padding: 14px; }
  .form-grid, .form-grid.three, .form-grid.four, .chain-editor { grid-template-columns: 1fr; }.modal-layer { padding: 10px; }.modal { max-height: calc(100vh - 20px); }.modal-body { padding: 15px; }.modal-foot { flex-wrap: wrap; }
  .detail-metrics { grid-template-columns: repeat(2, 1fr); }.detail-metrics > div { border-bottom: 1px solid var(--line); }.detail-metrics > div:nth-child(even) { border-right: 0; }.detail-metrics > div:nth-last-child(-n+2) { border-bottom: 0; }.detail-section-head { align-items: flex-start; flex-direction: column; }.detail-section-head .button { width: 100%; }
  .settlement-summary { grid-template-columns: 1fr; }.settlement-summary span { border-right: 0; border-bottom: 1px solid var(--line); }.settlement-summary span:last-child { border-bottom: 0; }.month-switch { width: 100%; margin: 0; justify-content: space-between; }.reconciliation-summary { align-items: flex-end; flex-direction: column; gap: 8px; }
  .pickup-config-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }.pickup-config-summary .button { grid-column: 1 / -1; width: 100%; }.pickup-config-actions { align-items: stretch; flex-direction: column; }.pickup-config-actions .button { width: 100%; }
  .pickup-driver-head { align-items: stretch; flex-direction: column; }.pickup-driver-head .button { width: 100%; }.pickup-driver-total { align-items: flex-start; justify-content: flex-start; flex-wrap: wrap; gap: 8px 16px; }
  .invoice-workbench { height: auto; min-height: 0; grid-template-columns: 1fr; }.invoice-list-pane { border-right: 0; border-bottom: 1px solid var(--line); }.invoice-long-list { max-height: 260px; flex: 0 1 auto; }.invoice-pane-head { align-items: flex-start; flex-direction: column; }.invoice-search { width: 100%; }.recognized-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chain-draft-summary { align-items: flex-start; flex-wrap: wrap; }.chain-draft-summary > span:nth-child(2) { width: 100%; margin-left: 0; }.chain-table { overflow-x: auto; }.chain-grid-head, .selected-company { min-width: 500px; grid-template-columns: 42px minmax(220px, 1fr) 105px 42px; gap: 8px; }.selected-company { align-items: center; }.selected-company-controls { align-items: center; flex-direction: row; }
  .activity-item { grid-template-columns: 110px 1fr; gap: 8px; }.activity-item div:last-child { grid-column: 1 / -1; padding-bottom: 10px; }
  .invoice-item { grid-template-columns: 1fr auto; }.invoice-item > div:nth-child(2), .invoice-item > div:nth-child(3) { display: none; }.comparison-grid { grid-template-columns: 1fr; }
  .chain-graph-summary { align-items:flex-start; flex-direction:column; gap:4px; }.chain-graph-editor-row { grid-template-columns:28px 1fr; }.chain-graph-editor-row label, .chain-graph-editor-row small { justify-content:flex-start; text-align:left; }
}

@media print {
  body * { visibility: hidden !important; }
  .modal-layer.open, .modal-layer.open *, .document-preview, .document-preview * { visibility: visible !important; }
  .modal-layer.open { position: absolute; inset: 0; padding: 0; background: #fff; }
  .modal { width: 100%; max-height: none; border: 0; box-shadow: none; }.modal-head, .modal-foot { display: none; }.modal-body { padding: 0; overflow: visible; }.document-preview { border: 0; box-shadow: none; }
}
