:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #142338;
  --muted: #52657a;
  --line: #e1e8f0;
  --nav: #0d2035;
  --nav-active: #183b60;
  --blue: #155eef;
  --blue-dark: #0c47bd;
  --mint: #0b8f6a;
  --amber: #b97810;
  --red: #bb414b;
  --shadow: 0 16px 45px rgba(20, 40, 70, .08);
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.5 Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(21, 94, 239, .3); outline-offset: 2px; }
.hidden { display: none !important; }
.eyebrow { display: block; color: var(--blue); font-size: 10px; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.eyebrow.light { color: #b8d6ff; }
.logo-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; color: #fff; background: linear-gradient(145deg, #2bb7d4, #165eef); font-size: 22px; font-weight: 900; box-shadow: 0 14px 30px rgba(8, 70, 190, .28); }
.logo-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(460px, 1.15fr) minmax(390px, .85fr); background: #fff; }
.login-visual { position: relative; overflow: hidden; display: flex; align-items: center; padding: 80px clamp(45px, 7vw, 110px); color: #fff; background: radial-gradient(circle at 85% 75%, rgba(39, 122, 255, .55), transparent 36%), linear-gradient(145deg, #0b1829, #11395f); }
.login-visual::after { content: ""; position: absolute; width: 620px; height: 620px; right: -290px; bottom: -310px; border: 1px solid rgba(255, 255, 255, .13); border-radius: 50%; box-shadow: 0 0 0 90px rgba(255, 255, 255, .035), 0 0 0 180px rgba(255, 255, 255, .02); }
.brand-lockup, .side-brand { display: flex; align-items: center; gap: 12px; }
.brand-lockup { position: absolute; top: 48px; left: clamp(45px, 7vw, 110px); }
.brand-lockup strong, .brand-lockup small, .side-brand strong, .side-brand small { display: block; }
.brand-lockup small, .side-brand small { margin-top: 4px; color: #a8bed7; font-size: 9px; letter-spacing: .14em; }
.visual-copy { position: relative; z-index: 1; max-width: 720px; }
.visual-copy h1 { margin: 24px 0 20px; font-size: clamp(38px, 4.4vw, 68px); line-height: 1.08; letter-spacing: -.055em; }
.visual-copy p { max-width: 630px; color: #cad8e9; font-size: 16px; line-height: 1.85; }
.visual-notes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.visual-notes span { padding: 8px 12px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 7px; background: rgba(255, 255, 255, .07); font-size: 12px; }
.login-panel { display: grid; place-items: center; padding: 54px; background: #fbfcfe; }
.login-card { width: min(420px, 100%); }
.login-card h2 { margin: 12px 0 8px; font-size: 31px; letter-spacing: -.035em; }
.login-card > p { margin: 0 0 28px; color: var(--muted); line-height: 1.7; }
.login-card label { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: 12px; font-weight: 800; }
.login-card small { color: var(--muted); font-weight: 500; }
.login-meta { display: flex; justify-content: space-between; margin-top: 18px; color: var(--muted); font-size: 10px; }

input, select, textarea { min-height: 40px; border: 1px solid #d5dfeb; border-radius: 8px; padding: 9px 11px; color: var(--ink); background: #fff; }
input[readonly] { background: #f3f6f9; color: #627187; }
.primary, .secondary, .danger, .table-button, .text-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 8px; padding: 10px 14px; font-weight: 800; }
.primary { color: #fff; background: var(--blue); box-shadow: 0 8px 18px rgba(21, 94, 239, .18); }
.primary:hover { background: var(--blue-dark); }
.secondary { color: #174dbd; background: #edf3ff; border: 1px solid #d7e4ff; }
.secondary:hover { background: #e1ebff; }
.danger { color: #fff; background: var(--red); }
.wide { width: 100%; margin-top: 24px; }
.text-button { color: var(--muted); background: transparent; font-size: 11px; }
.table-button { padding: 6px 9px; color: #40566f; background: #edf2f7; font-size: 10px; }
.table-button.good { color: #067357; background: #e4f8ef; }
.table-button.warn { color: #9b6711; background: #fff3d7; }
.table-button.bad { color: #a83d46; background: #ffeded; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 246px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 246px; display: flex; flex-direction: column; padding: 20px 14px; color: #fff; background: var(--nav); overflow-y: auto; }
.side-brand { padding: 0 8px 20px; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; margin-top: 13px; }
.nav-group { margin: 14px 12px 5px; color: #8aa5c0; font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #a8bbce; background: transparent; text-align: left; font-size: 12px; }
.nav-item span { width: 18px; color: #7595b4; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: var(--nav-active); }
.nav-item.active span { color: #7eb1ff; }
.side-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; padding: 17px 7px 3px; border-top: 1px solid rgba(255, 255, 255, .09); color: #8198af; font-size: 9px; }
.mode-pill { padding: 5px 8px; border-radius: 5px; color: #ffe8af; background: #714313; font-weight: 900; }
.mode-pill.live { color: #b8f5df; background: #075640; }
.workspace { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; height: 80px; display: flex; align-items: center; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); }
.topbar h1 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.025em; }
.menu-button { display: none; width: 36px; height: 36px; margin-right: 12px; border-radius: 8px; color: #40536a; background: #eef2f7; }
.account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--blue); background: #e3edff; font-weight: 900; }
.account strong, .account small { display: block; }
.account small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.scope-banner { margin: 22px 30px 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 15px; border: 1px solid #d8e7ff; border-left: 3px solid var(--blue); border-radius: 10px; background: #f7faff; }
.scope-banner strong { display: block; margin-top: 4px; font-size: 13px; }
.scope-banner > span { color: var(--muted); font-size: 10px; }
.module-view { padding: 24px 30px 50px; }
.module-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.module-head h2 { margin: 6px 0 5px; font-size: 23px; letter-spacing: -.035em; }
.module-head p { margin: 0; color: var(--muted); font-size: 12px; }

.panel, .capability-card { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.panel { padding: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 14px; }
.capability-card { margin-bottom: 16px; padding: 16px; color: #77531a; background: #fffaf0; border-color: #f1dfbc; }
.capability-card.enabled { color: #09664f; background: #eefbf6; border-color: #c7eadc; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { position: relative; overflow: hidden; min-height: 120px; padding: 17px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: var(--shadow); }
.stat-card::after { content: ""; position: absolute; right: -35px; bottom: -45px; width: 100px; height: 100px; border-radius: 50%; background: rgba(21, 94, 239, .07); }
.stat-card span, .stat-card strong, .stat-card small { display: block; }
.stat-card span { color: var(--muted); font-size: 10px; }
.stat-card strong { margin: 15px 0 7px; font-size: 25px; letter-spacing: -.03em; }
.stat-card small { color: #5d6e82; font-size: 9px; }
.stat-card button { margin-top: 10px; padding: 0; color: var(--blue); background: transparent; font-size: 10px; font-weight: 800; }
.two-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.three-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.record-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 11px; }
.record-line:first-child { border-top: 0; }
.record-line span { color: var(--muted); }
.card { padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card p { margin: 6px 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.badge { display: inline-flex; padding: 4px 7px; border-radius: 5px; color: #51647a; background: #eef2f7; font-size: 9px; font-weight: 900; }
.badge.good { color: #087357; background: #e3f7ee; }
.badge.warn { color: #966311; background: #fff1d2; }
.badge.bad { color: #a63d46; background: #ffebed; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 7px; color: #42546b; font-size: 11px; font-weight: 800; }
.span-2 { grid-column: span 2; }
.form-actions, .form-footer, .dialog-actions, .button-row { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.form-footer { justify-content: space-between; margin-top: 17px; padding-top: 15px; border-top: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.filters input, .filters select { min-width: 150px; flex: 1; }
.filters button { flex: none; }
.line-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.line-toolbar strong, .line-toolbar small { display: block; }
.line-toolbar small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.recipient-lines { display: flex; flex-direction: column; gap: 8px; }
.line-row { display: grid; grid-template-columns: 28px 1.2fr 1fr 1.5fr 32px; gap: 8px; align-items: center; padding: 9px; border: 1px solid #e4eaf1; border-radius: 9px; background: #f9fbfd; }
.line-row.payout-line { grid-template-columns: 28px 1.3fr 1fr 1fr 32px; }
.line-no { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 6px; color: var(--blue); background: #e7efff; font-size: 10px; font-weight: 900; }
.contract-display { min-height: 38px; display: flex; align-items: center; padding: 8px 10px; border: 1px solid #dce4ee; border-radius: 7px; color: var(--muted); background: #fff; font-size: 10px; line-height: 1.4; }
.contract-display.pending { color: #8a6200; background: #fff8dd; border-color: #f0dc9d; }
.contract-display.ready { color: #116044; background: #eaf8f2; border-color: #a8ddc8; }
.contract-display.error { color: #a52f3c; background: #fff0f1; border-color: #efb7bd; }
.remove-line { width: 29px; height: 29px; border-radius: 7px; color: var(--red); background: #ffedef; }
.history-field { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 10px 12px; border-radius: 8px; background: #f6f9fc; font-size: 11px; font-weight: 800; }
.history-field select { flex: 1; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel > h3 { padding: 18px 20px 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { color: #52657a; background: #f5f7fa; font-size: 13px; font-weight: 700; }
td code { color: #8c3951; font-size: 13px; font-weight: 600; }
.action-row { display: flex; flex-wrap: wrap; gap: 5px; }
.empty { padding: 35px 18px; color: var(--muted); text-align: center; font-size: 11px; }
.key-values { display: grid; gap: 8px; margin-bottom: 15px; }
.key-values div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 10px; }
.key-values span { color: var(--muted); }
.code-block { overflow: auto; max-height: 340px; padding: 14px; border-radius: 9px; color: #cfe0f7; background: #102136; font: 11px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.inline-form { display: flex; gap: 8px; margin: 12px 0; }
.inline-form input { flex: 1; }

.toast { position: fixed; top: 18px; right: 20px; z-index: 100; max-width: min(420px, calc(100vw - 40px)); padding: 11px 15px; border-radius: 8px; color: #fff; background: #102136; box-shadow: var(--shadow); font-size: 11px; transform: translateY(-75px); opacity: 0; transition: transform .2s, opacity .2s; }
.toast.show { transform: none; opacity: 1; }
.toast.success { background: #087555; }
.toast.error { background: #9f363e; }
.toast.warning { background: #8b6019; }
dialog { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 13px; box-shadow: 0 28px 90px rgba(10, 24, 45, .28); }
dialog::backdrop { background: rgba(10, 25, 45, .55); }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-head button { width: 31px; height: 31px; border-radius: 7px; color: #45566b; background: #f0f3f6; font-size: 18px; }
.dialog-body { padding: 20px; }
.dialog-actions { padding: 14px 20px; border-top: 1px solid var(--line); }
.dialog-body .dialog-actions { padding: 14px 0 0; border-top: 0; }
.qr-body { text-align: center; }
.authorization-qr-image { display: block; width: min(320px, 78vw); height: auto; margin: 0 auto 16px; border: 12px solid #fff; border-radius: 12px; outline: 1px solid #d9e1ea; background: #fff; }
fieldset { margin: 0; border: 1px solid var(--line); border-radius: 9px; padding: 12px; }
fieldset label { display: inline-flex; flex-direction: row !important; align-items: center; margin: 4px 10px 4px 0; font-weight: 600 !important; }
fieldset input { min-height: 0; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .three-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 28px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .menu-open .sidebar { transform: none; }
  .workspace { grid-column: 1; }
  .menu-button { display: inline-grid; place-items: center; }
  .topbar { height: 72px; padding: 0 14px; }
  .account > div { display: none; }
  .scope-banner { margin: 14px 14px 0; align-items: flex-start; flex-direction: column; }
  .module-view { padding: 18px 14px 38px; }
  .module-head { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .line-row, .line-row.payout-line { grid-template-columns: 26px 1fr 1fr 32px; }
  .line-row.payout-line select:first-of-type { grid-column: span 2; }
  .line-row:not(.payout-line) .recipient-uid { grid-column: 2 / span 2; }
  .line-row:not(.payout-line) .remove-line { grid-column: 4; grid-row: 1; }
  .line-row:not(.payout-line) .amount-value { grid-column: 2; }
  .line-row:not(.payout-line) .contract-display { grid-column: 3 / span 2; }
  .filters input, .filters select { min-width: 130px; }
}

@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr; }
  .account { gap: 4px; }
  .scope-banner > span { display: none; }
  .filters { align-items: stretch; flex-direction: column; }
  .filters input, .filters select, .filters button { width: 100%; }
  .line-row, .line-row.payout-line { grid-template-columns: 24px 1fr 32px; }
  .line-row select, .line-row input { grid-column: span 2; }
  .contract-display { grid-column: span 2; }
  .line-row:not(.payout-line) .recipient-uid { grid-column: 2; }
  .line-row:not(.payout-line) .remove-line { grid-column: 3; grid-row: 1; }
  .line-row:not(.payout-line) .amount-value,
  .line-row:not(.payout-line) .contract-display { grid-column: 2 / span 2; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .form-footer button { width: 100%; }
  .history-field { align-items: stretch; flex-direction: column; }
}

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

/* Finance uses the established palette with one responsive company work area. */
.finance-app { width: 100%; display: grid; grid-template-columns: 196px minmax(0,1fr); min-height: 100vh; }
.finance-navigation { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 16px 20px; color: #c8d5e3; background: var(--nav); overflow-y: auto; }
.finance-brand { display: grid; gap: 3px; padding: 0 12px 25px; color: #fff; text-decoration: none; border-bottom: 1px solid #ffffff18; }
.finance-brand b { font-size: 24px; letter-spacing: 2px; }.finance-brand span { color: #b1c5db; font-size: 12px; }
.finance-navigation nav { display: grid; gap: 4px; margin-top: 22px; }
.finance-navigation nav p { margin: 22px 12px 5px; color: #90a6bd; font-size: 12px; }
.finance-navigation nav a { display: block; padding: 10px 12px; border-radius: 7px; color: #c8d5e3; text-decoration: none; }
.finance-navigation nav a:hover,.finance-navigation nav a.active { color: #fff; background: var(--nav-active); }
.finance-navigation nav a.active { box-shadow: inset 3px 0 #71a5ff; }
.finance-navigation nav small { display: block; margin-top: 3px; color: #a9bed4; font-size: 11px; }
.finance-navigation-note { margin-top: auto; padding: 32px 12px 0; color: #90a6bd; font-size: 12px; line-height: 1.8; }
.finance-main { min-width: 0; }
.finance-view { display: grid; gap: 18px; min-width: 0; align-content: start; }
.finance-company-context { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 3px 0; }
.finance-company-context span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.finance-company-context strong { display: block; font-size: 22px; overflow-wrap: anywhere; }
.finance-company-context small { color: var(--muted); }
.finance-home-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; }
.finance-product-entry { display: block; border: 1px solid #cddcf6; border-radius: 8px; background: #f6f9ff; padding: 22px; color: var(--ink); text-decoration: none; }
.finance-product-entry:hover { border-color: var(--blue); background: #edf4ff; }.finance-product-entry strong { display: block; color: var(--blue); font-size: 14px; margin-top: 24px; }
.finance-product-name { font-size: 23px; font-weight: 700; }.finance-product-name span { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 4px; }
.finance-shortcuts { display: grid; }.finance-shortcuts a { display: grid; grid-template-columns: minmax(0,1fr) auto; padding: 14px 0; gap: 4px 16px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.finance-shortcuts a:first-child { padding-top: 0; }.finance-shortcuts a:last-child { border-bottom: 0; padding-bottom: 0; }.finance-shortcuts span { grid-column: 1; color: var(--muted); font-size: 13px; }.finance-shortcuts b { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--blue); }
.finance-reference-links { display: flex; flex-wrap: wrap; gap: 18px 36px; }.finance-reference-links a { color: var(--blue); text-decoration: none; }
.finance-view a:focus-visible,.finance-navigation a:focus-visible { outline: 3px solid #6c9df5; outline-offset: 3px; }
.finance-topbar { min-height: 72px; height: auto; padding: 12px 24px; }
.finance-workspace { display: grid; gap: 16px; padding: 20px 24px 48px; max-width: 1500px; margin: auto; min-width: 0; }
.finance-workspace .panel { padding: 20px; min-width: 0; box-shadow: 0 2px 6px #14233805; }
.finance-workspace h2 { margin: 0 0 16px; font-size: 19px; }
.finance-workspace p { color: var(--muted); line-height: 1.7; }
.runtime-banner { border: 1px solid #ead5a6; background: #fff8e8; padding: 9px 14px; color: #795014; border-radius: 8px; font-size: 13px; }
.workbench-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.summary-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 14px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.summary-item span { color: var(--muted); font-size: 13px; }.summary-item strong { font-size: 24px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.finance-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; gap: 18px 20px; }
.finance-row,.finance-lines-toolbar,.line-container,.finance-line:first-child { display: contents; }
.finance-row > :nth-child(1) { grid-area: 1 / 1; }
.finance-row > :nth-child(2) { grid-area: 1 / 2; }
.finance-row > :nth-child(3) { grid-area: 1 / 3; }
.finance-field,.finance-contract-field { display: grid; gap: 7px; min-width: 0; font-size: 13px; }
.finance-field input { width: 100%; min-width: 0; }
.finance-line:first-child .obligation-field { grid-area: 1 / 4; }
.finance-line:first-child .receipt-account-field { grid-area: 2 / 1; }
.finance-line:first-child .amount-field { grid-area: 2 / 2; padding-right: 74px; }
.finance-line:first-child .remove-line-button { grid-area: 2 / 2; justify-self: end; align-self: end; }
.finance-line:only-child .remove-line-button { display: none; }
.finance-contract-field { grid-area: 2 / 3; }
.finance-create-actions { grid-area: 2 / 4; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.finance-create-actions button { flex: 1 1 auto; min-height: 40px; padding: 9px 10px; white-space: nowrap; }
.finance-line:not(:first-child) { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; align-items: end; padding-top: 16px; border-top: 1px solid var(--line); }
.finance-line:not(:first-child) .amount-field { max-width: 180px; }
.finance-line:not(:first-child) .remove-line-button { justify-self: end; }
.finance-create-panel { scroll-margin-top: 110px; }
.finance-create-panel .finance-create-heading { flex-direction: row; align-items: center; margin: -20px -20px 20px; padding: 13px 20px; border-bottom: 1px solid var(--line); border-radius: 11px 11px 0 0; background: #f4f8fc; }
.finance-create-panel .finance-create-heading h2 { margin: 0; font-size: 17px; }
.finance-help { position: relative; color: var(--muted); font-size: 13px; }
.finance-help summary { cursor: pointer; list-style: none; }
.finance-help summary::-webkit-details-marker { display: none; }
.finance-help summary::after { content: '⌄'; margin-left: 8px; }
.finance-help summary:focus-visible { outline: 3px solid #155eef4d; outline-offset: 3px; }
.finance-help[open] > p,.finance-help-content { position: absolute; right: 0; top: calc(100% + 8px); z-index: 11; width: min(360px, 80vw); margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px #1423381a; }
.finance-help-content strong { color: var(--ink); }
.finance-help-content p { margin: 8px 0 0; font-size: 13px; }
.finance-contract-help summary { display: flex; align-items: center; justify-content: center; gap: 7px; height: 40px; width: fit-content; padding: 8px 14px; color: #40566f; background: #fff; border: 1px solid #d5dfeb; border-radius: 6px; }
.finance-contract-help .finance-help-content { right: auto; left: 0; }
.finance-form input,.finance-form button { border-radius: 6px; }
.finance-form button { height: 40px; }
.finance-form .primary,.finance-filters .primary { box-shadow: none; }
.finance-topbar .eyebrow, .finance-topbar .account small { font-size: 12px; letter-spacing: 0; }
.finance-workspace .module-head p { font-size: 14px; }
.finance-workspace .module-head h2 { margin-bottom: 6px; }
.finance-topbar .text-button, .finance-workspace .text-button { font-size: 14px; }
.finance-task-table { table-layout: fixed; min-width: 1000px; }
.finance-task-table .task-id-col { width: 4%; }
.finance-task-table .task-code-col { width: 17%; }
.finance-task-table .task-name-col { width: 14%; }
.finance-task-table .task-company-col { width: 17%; }
.finance-task-table .task-money-col { width: 9%; }
.finance-task-table .task-status-col { width: 12%; }
.finance-task-table .task-date-col { width: 12%; }
.finance-task-table .task-actions-col { width: 15%; }
.finance-task-table td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.finance-task-table td:nth-child(5) { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.finance-task-table td:nth-child(2) { font: 13px/1.6 ui-monospace, Consolas, monospace; }
.finance-task-table td:nth-child(3) { font-weight: 600; }
.finance-task-table th:last-child, .finance-task-table td:last-child { position: sticky; right: 0; z-index: 1; background: #fff; box-shadow: -1px 0 var(--line); }
.finance-task-table th:last-child { background: #f5f7fa; }
.finance-task-table .row-actions { display: table-cell; }
.finance-task-table .row-actions button { display: inline-flex; min-height: 34px; margin: 0 4px 6px 0; padding: 6px 8px; font-size: 13px; }
.table-scroll-hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.obligation-details summary { cursor: pointer; font-size: 16px; font-weight: 600; }
.obligation-details[open] summary { margin-bottom: 16px; }
.dialog-heading button { min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #f4f7fb; }
.finance-filters { gap: 8px; padding: 0 0 16px; border: 0; border-radius: 0; }
.finance-filters input,.finance-filters select { flex: 0 1 180px; width: 180px; min-width: 0; }
.finance-filters input[type="date"] { flex-basis: 148px; width: 148px; }
.finance-filters #searchInput { flex: 1 1 200px; }
.finance-filters button { height: 40px; padding: 8px 12px; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }.row-actions button { white-space: nowrap; padding: 8px 10px; }
.finance-dialog { width: min(860px, 94vw); max-height: 90vh; padding: 28px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); overflow: auto; }
.finance-dialog::backdrop { background: #14233888; }.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.finance-contract-field #materialOpen { min-height: 40px; width: max-content; padding: 8px 14px; }
#materialSummary { color: var(--muted); font-size: 12px; }
.material-dialog { width: min(660px,94vw); }
.material-fields { display: grid; gap: 14px; margin-top: 20px; }
.material-fields label { display: grid; gap: 7px; min-width: 0; }
.material-fields input,.material-fields select { width: 100%; min-width: 0; }
.material-picker input { padding: 12px; background: #f5f8fc; border: 1px dashed #aebfd4; }
.material-note { color: var(--muted); font-size: 13px; line-height: 1.7; }
.material-list { list-style: none; padding: 0; margin: 16px 0; }
.material-item { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.material-info { display: grid; gap: 5px; flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.material-info small,.material-empty { color: var(--muted); }
.material-item button,.material-item a { min-height: 34px; padding: 7px 10px; font-size: 13px; white-space: nowrap; }
.material-error { color: #b53640; }
.material-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.task-materials:not(:empty) { border-top: 1px solid var(--line); padding: 12px 0 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }.detail-grid dt { color: var(--muted); font-size: 12px; }.detail-grid dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.task-timeline { padding-left: 22px; line-height: 1.9; }.supplement-form { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 12px; }.supplement-form label { display: grid; gap: 6px; }
.qr-dialog { max-width: 480px; text-align: center; }.qr-dialog img { max-width: 100%; height: auto; }
.task-cell-note { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.65; font-weight: 400; }
#qrCaption { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.8; }
#qrMessage { color: #9a5618; }
.qr-navigation { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0; }
.qr-dialog > small { display: block; color: var(--muted); line-height: 1.6; }
.api-guide { max-width: 1100px; margin: auto; padding: 32px 24px 64px; color: var(--ink); }
.api-guide header, .api-guide section { margin-bottom: 24px; }
.api-guide nav { display: flex; flex-wrap: wrap; gap: 16px; margin: 20px 0 32px; }
.api-guide section { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px; line-height: 1.85; }
.api-guide h2 { margin-top: 0; }.api-guide li { margin-bottom: 8px; }
.api-guide td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.api-guide code { overflow-wrap: anywhere; }.api-guide pre { overflow-x: auto; padding: 18px; background: #f3f6fa; }
@media (max-width:600px) { .api-guide { padding: 20px 12px; }.api-guide section { padding: 16px; }.api-guide table { min-width: 550px; } }
@media (min-width: 701px) and (max-width: 1050px) {
  .finance-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-row > :nth-child(3) { grid-area: 2 / 1; }
  .finance-line:first-child .obligation-field { grid-area: 2 / 2; }
  .finance-line:first-child .receipt-account-field { grid-area: 3 / 1; }
  .finance-line:first-child .amount-field,.finance-line:first-child .remove-line-button { grid-area: 3 / 2; }
  .finance-contract-field { grid-area: 4 / 1; }
  .finance-create-actions { grid-area: 4 / 2; }
  .finance-line:not(:first-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .finance-app { grid-template-columns: minmax(0,1fr); }.finance-navigation { position: static; height: auto; padding: 16px 12px; overflow: visible; }.finance-brand { padding: 0 3px 12px; display: flex; gap: 12px; align-items: baseline; }.finance-brand b { font-size: 20px; }
  .finance-navigation nav { margin: 12px 0 0; display: flex; overflow-x: auto; gap: 4px; }.finance-navigation nav a { flex: none; white-space: nowrap; padding: 8px 10px; }.finance-navigation nav p,.finance-navigation nav small,.finance-navigation-note { display: none; }.finance-navigation nav a.active { box-shadow: inset 0 -2px #71a5ff; }
  .finance-home-grid { grid-template-columns: minmax(0,1fr); }.finance-company-context strong { font-size: 19px; }.finance-view > .module-head { flex-wrap: wrap; }
  .finance-topbar { align-items: flex-start; padding: 18px; gap: 12px; flex-wrap: wrap; }.finance-topbar h1 { font-size: 20px; }.finance-account { flex-wrap: wrap; }
  .finance-workspace { padding: 16px 12px 40px; gap: 15px; }.finance-workspace .panel { padding: 17px; }.workbench-summary { gap: 8px; }.summary-item { display: grid; gap: 6px; padding: 12px 8px; }.summary-item strong { font-size: 20px; }.summary-item span { font-size: 12px; }
  .finance-form { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
  .finance-field,.finance-contract-field { width: 100%; }
  .finance-line:first-child .amount-field { padding-right: 0; }
  .finance-line:first-child .remove-line-button { align-self: flex-end; }
  .finance-create-actions { width: 100%; }
  .finance-line:not(:first-child) { display: grid; grid-template-columns: 1fr; gap: 14px; }
  .finance-line:not(:first-child) .amount-field { max-width: none; }
  .finance-create-panel .finance-create-heading { margin: -17px -17px 17px; padding: 13px 17px; }
  .finance-contract-help .finance-help-content { width: min(360px, calc(100vw - 60px)); }
  .finance-contract-help[open] .finance-help-content { position: static; width: 100%; margin-top: 10px; box-shadow: none; }
  .finance-filters { flex-direction: row; align-items: center; }
  .finance-filters input,.finance-filters select { flex: 1 1 130px; height: 40px; }
  .finance-filters button { width: auto; flex: 1 1 auto; }
  .finance-filters .filter-separator { display: none; }
  .finance-dialog { padding: 20px; }.detail-grid { grid-template-columns: 1fr; }.table-wrap { overflow-x: auto; }.finance-line button { min-height: 38px; }
}
.batch-build-panel { margin: 14px 0; padding: 12px 14px; border: 1px solid #e1e8f2; border-radius: 10px; background: #f8faff; }
.batch-build-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.batch-build-toolbar label { font-weight: 600; }
.batch-build-toolbar select { width: min(100%, 335px); min-width: 0; }
.batch-build-toolbar button { white-space: nowrap; }
.batch-build-toolbar span { color: #64748b; font-size: 13px; }
.batch-build-results { padding: 0; margin: 0; list-style: none; max-height: 240px; overflow-y: auto; }
.batch-build-results:not(:empty) { margin-top: 10px; }
.batch-build-results li { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid #e1e8f2; font-size: 13px; overflow-wrap: anywhere; }
.batch-build-results strong { flex-shrink: 0; font-weight: 500; }
.batch-build-results [data-status="SUCCEEDED"], .batch-build-results [data-status="CONFIRMED"] { color: #14764d; }
.batch-build-results [data-status="UNKNOWN"], .batch-build-results [data-status="FAILED"] { color: #9a5618; }
@media (max-width: 600px) { .batch-build-toolbar select { flex: 1 1 200px; } .batch-build-toolbar span { flex-basis: 100%; } }

/* Financial products share the current company shell. */
.workbench-embedded .finance-navigation, .workbench-embedded .finance-topbar, .workbench-embedded .finance-company-context { display: none; }
.workbench-embedded .finance-app { display: block; min-height: 0; }
.workbench-embedded .finance-workspace { padding: 0; }
.finance-navigation{max-height:100vh;overflow-y:auto}.finance-products-home{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.finance-products-home h2{grid-column:1/-1}.finance-product-entry{margin:0;padding:20px;border:1px solid #dce5f0;border-radius:12px}.finance-product-entry:hover{border-color:#2563eb;background:#f6f9ff}#financeProductPanel[hidden]{display:none}#financeProductFrame{display:block;width:100%;height:calc(100vh - 200px);min-height:580px;border:0;background:transparent}@media(max-width:700px){.finance-products-home{grid-template-columns:1fr}.finance-navigation{max-height:none}#financeProductFrame{height:78vh;min-height:480px}}
.finance-nav-group summary { padding: 12px 15px; color: #a8bbce; cursor: pointer; border-radius: 7px; }
.finance-nav-group summary:hover, .finance-nav-group[open] summary { color: #fff; background: #183b60; }
.finance-navigation .finance-nav-group a { margin: 4px 0 4px 16px; padding-left: 16px; font-size: 13px; border-left: 1px solid #34516b; border-radius: 0 7px 7px 0; }
