:root {
  --bg: #edf2f7;
  --panel: #ffffff;
  --ink: #203247;
  --muted: #6a7c8f;
  --line: #ccd7e2;
  --accent: #2878a9;
  --accent-dark: #1f5f87;
  --danger: #b42318;
  --warning: #a15c00;
  --radius: 7px;
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { min-height: 64px; padding: 0 5vw; display: flex; align-items: center; gap: 28px; background: #102a2d; color: white; }
.topbar a, .topbar .link-button { color: white; }
.brand { font-weight: 800; letter-spacing: .02em; margin-right: 10px; }
.topbar nav { display: flex; gap: 22px; flex: 1; }
.topbar form { margin: 0; }
.link-button { border: 0; background: transparent; cursor: pointer; font: inherit; padding: 8px 0; }
.container { width: min(1180px, 92vw); margin: 36px auto 72px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(1.65rem, 4vw, 2.35rem); }
h2 { font-size: 1.12rem; }
.eyebrow { margin-bottom: 7px; color: var(--accent); font-size: .74rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.button { display: inline-flex; min-height: 42px; padding: 9px 15px; align-items: center; justify-content: center; border: 1px solid #bbc8ce; border-radius: 10px; color: var(--ink); background: white; font: inherit; font-weight: 700; cursor: pointer; }
.button:hover { border-color: var(--accent); text-decoration: none; }
.button.primary { color: white; border-color: var(--accent); background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.panel { margin-bottom: 22px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 5px 18px rgba(25, 51, 57, .045); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-head p { margin: 5px 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stats a { display: flex; min-height: 118px; padding: 20px; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); }
.stats a:hover { border-color: var(--accent); text-decoration: none; }
.stats span { color: var(--muted); font-weight: 650; }
.stats strong { font-size: 2.2rem; }
.stats .danger-card { border-color: #f1b5ae; background: #fff8f7; }
.stats .danger-card strong { color: var(--danger); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar input { flex: 1; min-width: 180px; }
.toolbar-export { margin-left: auto; white-space: nowrap; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #b9c7ce; border-radius: 9px; background: white; color: var(--ink); font: inherit; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(15, 118, 110, .14); border-color: var(--accent); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 0 12px 11px; color: var(--muted); font-size: .76rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 15px 12px; border-top: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #f8fbfb; }
.empty { padding: 34px 18px; color: var(--muted); text-align: center; }
.status { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: .78rem; font-weight: 800; white-space: nowrap; background: #edf1f3; }
.status.active { color: #087344; background: #dcf8e9; }
.status.draft { color: #59636b; background: #edf1f3; }
.status.completed { color: #175cd3; background: #e7efff; }
.status.terminated, .status.expired { color: var(--danger); background: #fee9e7; }
.warning { color: var(--warning); font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 7px; font-size: .9rem; font-weight: 720; }
.form-grid .wide { grid-column: 1 / -1; }
.field-error { color: var(--danger); font-size: .82rem; font-weight: 650; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 5px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.detail-grid > div { display: flex; flex-direction: column; gap: 6px; }
.detail-grid span { color: var(--muted); font-size: .82rem; }
.detail-grid .wide { grid-column: 1 / -1; }
.detail-grid p { margin: 0; white-space: pre-wrap; }
.alert { margin-bottom: 18px; padding: 13px 15px; border-radius: 10px; }
.alert.error { color: #84220f; border: 1px solid #f2b8ad; background: #fff1ef; }
.login-page { display: grid; min-height: 100vh; padding: 22px; place-items: center; background: radial-gradient(circle at top, #dbeceb, #f4f7f9 55%); }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 22px 70px rgba(18, 54, 60, .13); }
.login-card p { margin: 10px 0 24px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-stack label { display: flex; flex-direction: column; gap: 7px; font-size: .9rem; font-weight: 720; }
@media (max-width: 800px) {
  .topbar { padding: 0 4vw; gap: 16px; }
  .topbar nav { gap: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .toolbar input { width: 100%; flex-basis: 100%; }
  .toolbar-export { margin-left: 0; }
}
@media (max-width: 560px) {
  .topbar { min-height: auto; padding-block: 14px; flex-wrap: wrap; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .container { width: min(94vw, 1180px); margin-top: 24px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .actions { width: 100%; }
  .actions .button { flex: 1; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats a { min-height: 98px; padding: 15px; }
  .stats strong { font-size: 1.75rem; }
  .panel { padding: 16px; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid .wide, .detail-grid .wide { grid-column: auto; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}

/* Плотная оболочка учётной системы: знакомая логика без копирования фирменной палитры. */
.app-body { overflow-x: hidden; }
.appbar { height: 58px; padding: 0 20px; display: flex; align-items: center; gap: 18px; background: #213a57; color: #fff; border-bottom: 3px solid #36a6a0; }
.app-brand { display: flex; align-items: center; gap: 11px; color: #fff; }
.app-brand:hover { text-decoration: none; }
.app-brand > span:last-child { display: flex; flex-direction: column; line-height: 1.1; }
.app-brand small { margin-top: 4px; color: #b9c8d7; font-size: .7rem; font-weight: 500; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 5px; background: #36a6a0; color: #fff; font-size: .8rem; font-weight: 900; letter-spacing: .05em; }
.appbar-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 4px; color: #e7eef5; font-size: .84rem; }
.user-dot { width: 7px; height: 7px; border-radius: 50%; background: #52d3a7; }
.appbar .link-button { color: #fff; }
.app-shell { display: grid; min-height: calc(100vh - 58px); grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { padding: 14px 10px 30px; background: #f7f9fc; border-right: 1px solid #c5d0dc; }
.nav-section { margin: 18px 10px 6px; color: #8a99a8; font-size: .67rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.nav-section:first-child { margin-top: 4px; }
.nav-item { display: flex; min-height: 36px; padding: 7px 10px; align-items: center; gap: 9px; border-radius: 4px; color: #30475e; font-size: .88rem; font-weight: 650; }
.nav-item:hover { color: #163d5e; background: #e2edf5; text-decoration: none; }
.nav-sub { min-height: 31px; padding-left: 39px; color: #5f7183; font-size: .81rem; font-weight: 500; }
.nav-icon { width: 19px; color: #2d829d; font-size: 1rem; text-align: center; }
.workspace { min-width: 0; }
.commandbar { height: 39px; padding: 0 22px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #cdd8e2; background: #fff; color: #7d8b98; font-size: .78rem; }
.commandbar a { color: #396d91; }
.workspace .container { width: auto; max-width: 1500px; margin: 0; padding: 24px 26px 70px; }
.workspace .page-head { margin-bottom: 16px; }
.page-note { margin: 7px 0 0; color: var(--muted); }
.workspace .panel { padding: 17px; border-radius: 6px; box-shadow: 0 1px 3px rgba(28, 52, 74, .04); }
.workspace .button { min-height: 34px; padding: 6px 12px; border-radius: 4px; font-size: .84rem; }
.workspace .button.compact { min-height: 29px; padding: 4px 9px; font-size: .76rem; }
.workspace input, .workspace select, .workspace textarea { min-height: 35px; padding: 6px 9px; border-radius: 3px; font-size: .86rem; }
.workspace th { padding: 8px 9px; border-bottom: 1px solid #b8c6d3; background: #eef3f8; color: #4c6173; font-size: .7rem; position: sticky; top: 0; z-index: 1; }
.workspace td { padding: 9px; font-size: .83rem; }
.workspace tbody tr:nth-child(even) { background: #fbfcfd; }
.dense-table td { padding-block: 7px; }
.grid-panel { padding: 0 !important; overflow: hidden; }
.grid-panel .table-wrap { max-height: 68vh; }
.mono { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: -.02em; }
.number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.credit-text { color: #087a5a !important; }
.debit-text { color: #b4483b !important; }
.warning { color: #a15c00; }
.success { color: #0a674d; border: 1px solid #a9ddca; background: #eaf8f3; }
.warning-alert { color: #795013; border: 1px solid #e6c886; background: #fff8e6; }
.warning-alert ul { margin: 8px 0 0; padding-left: 20px; }
.warning-card { border-color: #e5c477 !important; background: #fffaf0 !important; }
.bank-callout { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-left: 4px solid #36a6a0; }
.bank-callout p { margin: 6px 0 0; }
.bank-stats { grid-template-columns: 1fr 1.35fr 1.35fr 1fr; }
.stats .money-stat { font-size: clamp(1.05rem, 1.7vw, 1.5rem); }
.stat-box { display: flex; min-height: 106px; padding: 17px; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.stat-box span { color: var(--muted); font-size: .81rem; }
.stat-box strong { font-size: 1.18rem; font-variant-numeric: tabular-nums; }
.two-panels { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(310px, .8fr); gap: 18px; }
.import-list { display: flex; flex-direction: column; }
.import-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 2px; border-top: 1px solid var(--line); }
.import-row:first-child { border-top: 0; }
.import-row > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.import-row span { color: var(--muted); font-size: .76rem; }
.import-count { min-width: 52px; padding: 5px 7px; border-radius: 3px; background: #e8f1f7; color: #32617f; font-weight: 800; text-align: center; }
.truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-panel { max-width: 820px; }
.upload-zone { min-height: 260px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 9px; border: 2px dashed #9bb7cb; border-radius: 7px; background: #f4f9fc; color: #60788a; cursor: pointer; }
.upload-zone:hover { border-color: var(--accent); background: #edf7fb; }
.upload-zone strong { color: #274a65; font-size: 1.08rem; }
.upload-zone input { width: auto; min-height: auto; margin-top: 8px; border: 0; background: transparent; }
.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #d9ecf4; color: var(--accent); font-size: 1.8rem; }
.help-panel { max-width: 820px; }
.check-list { margin-top: 15px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.check-list span { color: #476477; font-size: .84rem; }
.summary-strip { margin-bottom: 16px; display: grid; grid-template-columns: 1fr 1.4fr 1.1fr .6fr; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.summary-strip > div { min-width: 0; padding: 13px 15px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.summary-strip > div:first-child { border-left: 0; }
.summary-strip span { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.summary-strip strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.preview-totals { grid-template-columns: repeat(4, 1fr); }
.description-cell { min-width: 280px; max-width: 560px; white-space: normal; }
.confirm-bar { position: sticky; bottom: 0; margin: 0 -26px -70px; padding: 13px 26px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #b9c7d3; background: rgba(255,255,255,.96); box-shadow: 0 -5px 18px rgba(31, 58, 82, .08); z-index: 4; }
.filter-grid { display: grid; grid-template-columns: minmax(240px, 1fr) 150px 165px 135px 135px auto auto; }
.filter-grid .button { white-space: nowrap; }
.status.bank-new { color: #8a5b08; background: #fff0c9; }
.status.bank-matched { color: #08735a; background: #dff6ee; }
.status.bank-ignored { color: #687582; background: #e9edf1; }
.operations-table { min-width: 1180px; }
.finance-stats .money-stat { font-size: clamp(.95rem, 1.45vw, 1.35rem); }
.table-panel-head { margin: 0; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.receivables-table { min-width: 980px; }
.receivables-filter label { min-width: 180px; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.esf-filter { display: grid; grid-template-columns: minmax(280px, 1fr) 170px 180px auto auto auto; }
.esf-table { min-width: 1100px; }
.status.tax-accepted { color: #087344; background: #dcf8e9; }
.status.tax-draft { color: #8a5b08; background: #fff0c9; }
.status.tax-cancelled { color: #687582; background: #e9edf1; }
.esf-preview-summary { grid-template-columns: .7fr .9fr 1fr .8fr 1.5fr; }
.reconciliation-filter { display: grid; grid-template-columns: minmax(250px, 1.4fr) minmax(220px, 1fr) 145px 145px auto; gap: 12px; align-items: end; }
.reconciliation-filter label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.act-sheet { max-width: 1120px; margin-inline: auto; color: #172737; }
.act-header { margin-bottom: 22px; text-align: center; }
.act-header h2 { font-size: 1.22rem; letter-spacing: .04em; }
.act-header p { margin: 7px 0 0; }
.act-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 16px; }
.act-parties > div { padding: 13px; display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); }
.act-parties span, .act-parties small { color: var(--muted); }
.act-contract { margin: 12px 0; font-weight: 700; }
.act-table { min-width: 850px; border: 1px solid #aebbc8; }
.act-table th, .act-table td { border: 1px solid #c6d0d9; }
.act-table tfoot th { padding: 10px 9px; background: #eef3f8; }
.opening-row { background: #f6f8fa !important; }
.act-balance { margin-top: 18px; padding: 14px; display: flex; justify-content: space-between; gap: 18px; border: 2px solid #8fa3b5; }
.act-balance strong { text-align: right; }
.act-signatures { margin-top: 55px; display: grid; grid-template-columns: 1fr 1fr; gap: 70px; }
.act-signatures div { line-height: 2.2; }
.act-signatures span { white-space: nowrap; }
.login-page { background: linear-gradient(135deg, #dbe8f2, #eef3f7 48%, #dcefeb); }
.login-card { border-radius: 8px; border-top: 5px solid #36a6a0; box-shadow: 0 18px 55px rgba(32, 56, 80, .16); }
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 188px minmax(0, 1fr); }
  .filter-grid { grid-template-columns: 1fr 1fr 1fr; }
  .filter-grid input[type="search"] { grid-column: 1 / -1; }
  .two-panels { grid-template-columns: 1fr; }
  .reconciliation-filter { grid-template-columns: 1fr 1fr; }
  .esf-filter { grid-template-columns: 1fr 1fr; }
  .esf-filter input[type="search"] { grid-column: 1 / -1; }
  .esf-preview-summary { grid-template-columns: 1fr 1fr; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-strip > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .summary-strip > div:nth-child(4) { border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .appbar { padding-inline: 12px; }
  .app-brand small, .user-chip { display: none; }
  .app-shell { display: block; }
  .sidebar { padding: 8px; display: flex; gap: 4px; overflow-x: auto; border-right: 0; border-bottom: 1px solid #c5d0dc; }
  .nav-section, .nav-sub { display: none; }
  .nav-item { min-width: max-content; }
  .workspace .container { padding: 18px 14px 68px; }
  .commandbar { padding-inline: 14px; }
  .bank-stats, .preview-totals, .finance-stats { grid-template-columns: 1fr 1fr; }
  .check-list { grid-template-columns: 1fr 1fr; }
  .filter-grid, .esf-filter { grid-template-columns: 1fr 1fr; }
  .filter-grid input[type="search"] { grid-column: 1 / -1; }
  .confirm-bar { margin-inline: -14px; padding-inline: 14px; }
  .bank-callout { align-items: stretch; flex-direction: column; }
  .act-parties, .act-signatures { grid-template-columns: 1fr; gap: 18px; }
  .act-balance { flex-direction: column; }
  .act-balance strong { text-align: left; }
}

@media print {
  .appbar, .sidebar, .commandbar, .no-print { display: none !important; }
  .app-shell { display: block; }
  .workspace .container { padding: 0; }
  .act-sheet { max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .act-table { min-width: 0; }
  body, :root { background: #fff; color: #000; }
}
@media (max-width: 480px) {
  .app-brand > span:last-child { display: none; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-strip > div { border-left: 0; border-top: 1px solid var(--line); }
  .summary-strip > div:first-child { border-top: 0; }
  .bank-stats, .preview-totals, .finance-stats, .check-list, .filter-grid, .esf-filter, .esf-preview-summary { grid-template-columns: 1fr; }
  .confirm-bar { flex-direction: column-reverse; }
}
