:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17221e;
  background: #f4f6f5;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a.button { min-height: 44px; min-width: 44px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: #176b52; }
.loading { padding: 32px; text-align: center; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: #176b52; color: white;
}
.topbar h1 { font-size: 22px; margin: 0; flex: 1; }
.topbar button { border: 0; background: transparent; color: white; padding: 4px 8px; }
.network-banner { padding: 10px 16px; background: #fff0f0; color: #922e2e; text-align: center; font-weight: 650; }
.network-banner.stale { background: #fff7df; color: #6d5312; }
main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px 12px calc(110px + env(safe-area-inset-bottom)); }
.bottom-nav {
  position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; display: flex; justify-content: center;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: white; border-top: 1px solid #d8dfdc;
}
.bottom-nav button { flex: 1; max-width: 280px; border: 0; background: transparent; color: #52615b; border-radius: 10px; }
.bottom-nav button.active { color: #176b52; background: #e8f3ee; font-weight: 700; }
.panel, .expense-group { background: white; border-radius: 14px; padding: 14px; margin-bottom: 14px; box-shadow: 0 1px 3px #17392d12; }
.panel h2, .expense-group h2 { margin: 0 0 12px; font-size: 18px; }
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.total { background: #e8f3ee; border-radius: 14px; padding: 12px; }
.total span { display: block; font-size: 13px; color: #52615b; }
.total strong { display: block; margin-top: 4px; font-size: 17px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filters .wide { grid-column: 1 / -1; }
label { display: block; font-size: 13px; color: #4b5b54; font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 11px; border: 1px solid #bac7c1;
  border-radius: 9px; background: white; color: #17221e; min-height: 44px; font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"] { width: 24px; min-height: 24px; height: 24px; margin: 0; }
.check { display: flex; align-items: center; gap: 9px; min-height: 44px; }
.expense-row {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; width: 100%;
  text-align: left; border: 0; border-top: 1px solid #edf0ee; background: white; padding: 12px 0;
}
.expense-row:first-of-type { border-top: 0; }
.expense-row.selected, .finance-expense-row.selected { background: #e8f3ee; }
.finance-table-wrapper { display: none; }
.finance-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 12px; }
.finance-table th, .finance-table td { padding: 6px 5px; border-top: 1px solid #edf0ee; text-align: left; vertical-align: middle; }
.finance-table th button { width: 100%; padding: 5px 2px; border: 0; background: transparent; color: #52615b; text-align: left; font-size: 12px; font-weight: 700; }
.finance-expense-row { cursor: pointer; }
.finance-expense-row:hover { background: #f4f8f6; }
.detail-container:empty { display: none; }
.status-dot { width: 10px; height: 42px; border-radius: 8px; }
.status-yellow { background: #c48a12; }  /* «Распознано. Проверьте» — ждёт адвоката, не тревога */
.status-green { background: #25875f; }
.status-red { background: #cc4949; }  /* «Не распознано. Внимание» — суммы не сходятся, возврат, не распознано */
.expense-main strong, .expense-main small { display: block; }
.expense-main small { margin-top: 4px; color: #617069; }
.expense-amount { text-align: right; white-space: nowrap; font-weight: 700; }
.expense-amount small { display: block; color: #617069; font-weight: 400; margin-top: 4px; }
.primary, .secondary, .danger, a.button {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; padding: 10px 14px;
  text-decoration: none; border: 1px solid transparent; font-weight: 650;
}
.primary { background: #176b52; color: white; }
.secondary, a.button { background: white; color: #176b52; border-color: #9db5aa; }
.danger { background: #fff3f3; color: #a22d2d; border-color: #e1b2b2; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.full { width: 100%; }
.message { padding: 10px 12px; border-radius: 9px; background: #e8f3ee; margin: 10px 0; }
.message.note { background: #fdf6e3; border-left: 4px solid #c48a12; }
.error { background: #fff0f0; color: #922e2e; white-space: pre-wrap; }
[aria-invalid="true"] { border-color: #a22d2d; }
.field-error { display: block; margin-top: 5px; color: #922e2e; font-size: 13px; font-weight: 500; }
.empty { text-align: center; color: #617069; padding: 30px 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.visually-hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-actions { display: grid; gap: 10px; }
.upload-choice { min-height: 60px; font-size: 17px; }
.drop-zone { display: flex; align-items: center; justify-content: center; min-height: 76px; margin-top: 14px; padding: 14px; border: 2px dashed #9db5aa; border-radius: 12px; color: #52615b; text-align: center; }
.drop-zone.dragging { background: #e8f3ee; border-color: #176b52; }
.selected-files { display: grid; gap: 10px; margin-top: 14px; }
.upload-file { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid #edf0ee; }
.file-thumbnail { flex: 0 0 72px; width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: #e9edeb; }
.file-kind { display: flex; align-items: center; justify-content: center; color: #617069; font-size: 13px; }
.upload-file-info { flex: 1; min-width: 0; }
.upload-file-info strong, .upload-file-info small { display: block; overflow-wrap: anywhere; }
.upload-file-info small { margin-top: 5px; color: #617069; }
.upload-file-info progress { display: block; width: 100%; margin-top: 9px; }
.upload-item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.document-preview-button { display: block; width: 100%; padding: 0; border: 0; background: transparent; }
.document-preview { width: 100%; max-height: 55vh; object-fit: contain; border: 0; border-radius: 9px; background: #e9edeb; }
.image-viewer { position: fixed; inset: 0; z-index: 100; overflow: auto; background: #000; touch-action: pan-x pan-y pinch-zoom; }
.image-viewer img { width: 100%; height: 100%; object-fit: contain; touch-action: pan-x pan-y pinch-zoom; }
.image-viewer-close { position: fixed; z-index: 101; top: calc(12px + env(safe-area-inset-top)); right: 12px; background: #fff; }
.badge { display: inline-block; border-radius: 20px; padding: 4px 9px; font-size: 13px; font-weight: 700; color: #17221e; }
.badge { font-weight: 600; }
/* Status badges — soft tint + coloured word (как на пульте, SR 05.12). Bars/dots stay solid. */
.badge.status-yellow { background: #fbefd2; color: #9a6500; }
.badge.status-green { background: #dff2e7; color: #1d7a4e; }
.badge.status-red { background: #fbe3e3; color: #b83434; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { border-top: 1px solid #edf0ee; padding: 10px 0; font-size: 13px; }
.history small { display: block; color: #617069; margin-bottom: 4px; }
.table-scroll { overflow-x: auto; }
.security-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 680px; }
.security-table th, .security-table td { padding: 9px 7px; border-top: 1px solid #edf0ee; text-align: left; vertical-align: top; }
.security-table th { color: #52615b; }
.security-table small { color: #617069; }
.login { max-width: 440px; margin: 8vh auto; }
.login h1 { color: #176b52; }
.login label { margin-top: 14px; }
.hint { color: #617069; font-size: 13px; line-height: 1.5; }
@media (min-width: 1024px) {
  main { padding: 24px 20px 40px; }
  .bottom-nav { position: static; justify-content: flex-start; padding: 8px 20px; border-top: 0; border-bottom: 1px solid #d8dfdc; }
  .bottom-nav button { flex: 0 1 180px; font-size: 14px; }
  .expense-workspace { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr); gap: 16px; align-items: start; }
  .detail-container:not(:empty) { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow-y: auto; padding-bottom: 20px; }
  .finance-mobile { display: none; }
  .finance-table-wrapper { display: block; overflow-x: auto; padding: 6px; background: white; border-radius: 14px; }
  .back-button { display: none; }
}
@media (min-width: 700px) {
  main { padding-top: 24px; padding-left: 20px; padding-right: 20px; }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .filters .wide { grid-column: auto; }
}
@media (max-width: 600px) {
  .topbar .user-name { display: none; }
  .topbar { gap: 4px; }
  .bottom-nav { padding-left: 2px; padding-right: 2px; }
  .bottom-nav button { font-size: 12px; padding-left: 2px; padding-right: 2px; }
}
@media (max-width: 420px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .totals { grid-template-columns: 1fr; }
}
.expense-amount .badge-small { display: table; margin: 4px 0 0 auto; font-size: 11px; padding: 2px 8px; white-space: normal; max-width: 120px; text-align: center; line-height: 1.25; }
