:root {
  color-scheme: light;
  --paper: #f6f7fb;
  --surface: #fff;
  --ink: #141b2c;
  --muted: #626d85;
  --line: #e4e8f1;
  --brand: #294de5;
  --brand-soft: #ebefff;
  --sidebar: #11182a;
  --radius: 15px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--brand); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(29px, 3vw, 41px); font-weight: 740; letter-spacing: -.045em; line-height: 1.1; }
h2 { font-size: 23px; letter-spacing: -.025em; }
h3 { font-size: 16px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #9aaaf5; outline-offset: 2px; }
[hidden] { display: none !important; }
.loading { padding: 30px; }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: white; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 15px 16px; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 9px; text-transform: uppercase; font-size: 15px; letter-spacing: .095em; font-weight: 800; }
.brand img { width: 35px; height: 35px; }
.brand small { display: block; color: #a1acc3; font-size: 10px; margin-top: 2px; letter-spacing: .15em; font-weight: 600; }
.nav-list { display: flex; flex-direction: column; gap: 5px; margin-top: 44px; }
.nav-btn { background: transparent; color: #bec8db; border: 0; text-align: left; padding: 12px 12px; border-radius: 9px; display: flex; align-items: center; gap: 11px; font-weight: 620; }
.nav-btn .nav-icon { width: 18px; text-align: center; font-size: 17px; }
.nav-btn:hover { background: #1b263e; color: white; }
.nav-btn.active { background: #263556; color: #fff; }
.profile { margin-top: auto; display: flex; align-items: center; gap: 9px; border-top: 1px solid #30384a; padding: 16px 5px 0; }
.avatar { background: #232f51; color: #dce5ff; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; }
.profile-name { font-size: 12px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.profile-name small { display: block; color: #a1acc3; margin-top: 2px; }
.logout { border: 0; background: transparent; color: #c0cee9; font-size: 20px; padding: 0 3px; }
.topbar { background: white; border-bottom: 1px solid var(--line); min-height: 65px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.topbar b { color: var(--ink); font-weight: 650; }
.content { max-width: 1570px; margin: auto; padding: 32px 34px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
.sub { color: var(--muted); margin-top: 8px; line-height: 1.5; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 39px; border: 1px solid transparent; border-radius: 9px; background: var(--brand); color: white; padding: 8px 14px; text-decoration: none; font-weight: 650; white-space: nowrap; }
.btn:hover { background: #2040c9; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.secondary { color: var(--ink); background: white; border-color: #d9dfeb; }
.btn.secondary:hover { background: #f2f5ff; }
.btn.quiet { color: var(--brand); background: var(--brand-soft); }
.btn.quiet:hover { background: #dce5ff; }
.btn.small { min-height: 30px; font-size: 12px; padding: 4px 9px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 17px 15px; text-align: left; min-width: 0; color: var(--ink); }
.stat:hover, .stat.selected { border-color: #8da0fb; background: #fafbff; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 620; }
.stat b { display: block; font-size: 25px; letter-spacing: -.045em; margin-top: 5px; line-height: 1.24; font-variant-numeric: tabular-nums; }
.surface { border: 1px solid var(--line); background: white; border-radius: var(--radius); min-width: 0; }
.tabs { display: flex; gap: 23px; padding: 0 18px; overflow: auto; border-bottom: 1px solid var(--line); }
.tab { min-height: 48px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 630; background: transparent; white-space: nowrap; padding: 0 1px; }
.tab:hover, .tab.active { color: var(--brand); }
.tab.active { border-color: var(--brand); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 13px 17px; }
.filters input, .filters select { max-width: 205px; }
.filters input[type=search] { max-width: 320px; flex: 1 1 200px; }
input, select, textarea { width: 100%; min-width: 0; color: var(--ink); background: white; border: 1px solid #d9dfeb; border-radius: 8px; padding: 9px 10px; min-height: 38px; }
textarea { min-height: 78px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #75819a; }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; margin: 0; }
.table-box { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 14px; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
thead { background: #f4f6fc; }
th { font-size: 11px; letter-spacing: .035em; color: #535f78; font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.doc-table tbody tr:hover { background: #fafbff; }
.doc-name { background: none; color: var(--ink); white-space: nowrap; text-align: left; border: 0; padding: 0; font-weight: 730; }
.doc-name:hover { color: var(--brand); text-decoration: underline; }
.meta { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; max-width: 275px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bank-name { white-space: nowrap; }
.doc-date { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.status { border-radius: 20px; display: inline-flex; padding: 5px 9px; font-size: 11px; font-weight: 650; color: #46546d; background: #edf0f6; white-space: nowrap; }
.status.paid, .status.signed { color: #176044; background: #e4f4ec; }
.status.sent, .status.issued { color: #29449b; background: #e8edff; }
.status.partial { color: #845009; background: #fff1d9; }
.status.cancelled { color: #9c3131; background: #fae8e8; }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 13px; }
.party-card { padding: 18px; display: grid; gap: 12px; align-content: start; }
.party-card h3 { overflow-wrap: anywhere; }
.party-list { margin-bottom: 14px; max-width: 365px; }
.endnote { color: var(--muted); font-size: 12px; padding: 13px 18px; border-top: 1px solid var(--line); }
.empty { text-align: center; padding: 32px 20px; color: var(--muted); border-top: 1px solid var(--line); }
.login-page { min-height: 100vh; background: #eef1fe; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 419px); padding: 32px; border-radius: 22px; box-shadow: 0 18px 55px #15224d16; background: white; }
.login-card .brand { padding: 0; color: var(--ink); margin-bottom: 28px; }
.login-card .brand small { color: var(--muted); }
.login-card h1 { font-size: 31px; margin-bottom: 20px; }
.login-card .btn { width: 100%; margin-top: 4px; }
fieldset { padding: 0; border: none; margin: 0; min-inline-size: 0; }
.field { display: flex; flex-direction: column; align-items: stretch; gap: 5px; font-weight: 630; color: #36425b; font-size: 13px; min-width: 0; }
.field input, .field select, .field textarea { font-weight: 400; }
.field small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.form-row { display: grid; grid-template-columns: repeat(2,minmax(0, 1fr)); gap: 12px; }
.span { grid-column: 1 / -1; }
.stack { display: grid; gap: 13px; }
.checkline { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
dialog { border: 0; border-radius: 17px; width: min(900px, calc(100% - 28px)); max-height: min(92vh, 1050px); padding: 0; color: var(--ink); box-shadow: 0 18px 65px #131c4a44; }
dialog::backdrop { background: #11183080; }
.dialog-head { position: sticky; top: 0; z-index: 2; background: white; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 17px 22px; }
.dialog-head button { background: white; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; font-size: 20px; color: var(--ink); }
.dialog-body { padding: 18px 22px 22px; }
.form-footer { border-top: 1px solid var(--line); padding-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.section { padding: 14px; border: 1px solid var(--line); border-radius: 11px; }
.section h3 { margin-bottom: 10px; }
.item-head, .item-row { display: grid; grid-template-columns: minmax(170px, 1fr) 65px 72px 95px 93px 105px 33px; gap: 5px; align-items: center; }
.item-head { font-size: 11px; color: var(--muted); padding: 4px 0; }
.item-row { margin: 5px 0; }
.item-row input, .item-row select { padding: 7px 5px; }
.item-row output { text-align: right; white-space: nowrap; font-size: 12px; }
.item-row button { min-height: 32px; background: white; border: 1px solid var(--line); color: #8b263a; border-radius: 8px; }
.item-total { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; }
.detail-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.detail-grid div { padding: 11px; min-width: 0; background: var(--paper); border-radius: 9px; overflow-wrap: anywhere; }
.detail-grid span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.history { display: grid; gap: 5px; margin-top: 9px; color: var(--muted); padding-left: 19px; }
.history li { padding: 2px 0; }
.files { display: flex; gap: 8px; flex-wrap: wrap; }
.download { display: grid; gap: 2px; text-align: left; padding: 8px 10px; background: var(--brand-soft); border-radius: 8px; color: #263c96; text-decoration: none; max-width: 100%; overflow-wrap: anywhere; }
.download b { font-size: 12px; }
.download span { font-size: 11px; }
.error { color: #9c2525; background: #fff0f0; border: 1px solid #f3cece; padding: 10px; border-radius: 8px; }
.note { color: var(--muted); line-height: 1.5; font-size: 12px; }
.notices { position: fixed; bottom: 20px; right: 20px; z-index: 4; }
.toast { background: #202c4a; color: white; border-radius: 10px; padding: 12px 17px; margin-top: 6px; box-shadow: 0 5px 15px #17254124; }
@media (max-width: 1050px) {
  .layout { grid-template-columns: 180px minmax(0,1fr); }
  .topbar { padding: 0 22px; }
  .content { padding: 25px 22px 50px; }
  th, td { padding: 10px; }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { height: auto; position: static; padding: 13px 12px; }
  .brand { padding-left: 1px; }
  .nav-list { flex-direction: row; gap: 4px; margin-top: 13px; flex-wrap: wrap; }
  .nav-btn { padding: 8px; font-size: 12px; }
  .profile { display: none; }
  .topbar { min-height: 44px; padding: 0 12px; }
  .content { padding: 20px 12px 35px; }
  .page-head { flex-wrap: wrap; align-items: start; }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .stat { padding: 12px; }
  .filters input,.filters select { min-width: min(140px, 100%); }
  .detail-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .item-head, .item-row { grid-template-columns: minmax(150px,1fr) 60px 60px 72px 70px 80px 26px; }
  .items-wrap { overflow-x: auto; }
  .item-head, .item-row { min-width: 540px; }
}
@media (max-width: 430px) {
  .form-row { grid-template-columns: 1fr; }
  .dialog-head { padding: 14px; }
  .dialog-body { padding: 13px; }
  .login-card { padding: 23px; }
}

.demo-banner { color: #624721; background: #fff1d7; border: 1px solid #efdfb7; padding: 9px 13px; margin-bottom: 16px; border-radius: 9px; font-size: 12px; font-weight: 660; }
