:root {
  /* Фирменные цвета «Тоёка»: бордовый, золото, крем */
  --brand: #8a000f; --brand-dark: #6d000c; --gold: #cd9739; --cream: #f4eee2;
  --bg: #faf7f1; --card: #fff; --text: #2a1a1c; --muted: #7a6a66; --line: #eadfd3;
  --primary: var(--brand); --danger: #b3261e; --warn: #9a6200; --ok: #2e7d32;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
a { color: var(--primary); }
.top { background: var(--brand); border-bottom: 3px solid var(--gold); padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; }
.top .logo img { height: 40px; display: block; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; flex: 1; }
.top nav a:not(.btn) { text-decoration: none; color: var(--cream); }
.top nav a:not(.btn):hover { color: var(--gold); }
.top nav .btn.primary { background: var(--gold); border-color: var(--gold); color: var(--brand-dark); font-weight: 600; }
.who { display: flex; gap: 8px; align-items: center; color: var(--cream); font-size: 13px; opacity: .9; }
.who button.link { color: var(--gold); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.narrow { max-width: 380px; margin: 40px auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 10px; }
.grid .wide { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
input, select, textarea { font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input[type=checkbox] { width: 20px; height: 20px; }
.btn { display: inline-block; font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.big { padding: 12px 28px; font-size: 16px; }
.btn.small { padding: 4px 10px; }
button.link { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
details > summary { cursor: pointer; }
details.card > summary.btn { list-style: none; }
details[open] > summary { margin-bottom: 12px; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 0 0 12px; }
.item-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.item.is-rejected { background: #fff5f5; }
.item .rejected-only { display: none; }
.item.is-rejected .rejected-only { display: flex; }
.item.is-rejected .accepted-only { display: none; }
.actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.total { font-weight: 600; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafbfc; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.rejected td { color: var(--muted); text-decoration: line-through; }
tr.rejected td:last-child, tr.rejected td:nth-last-child(2) { text-decoration: none; }
tr.overdue td { background: #fff5f5; }
table.journal { font-size: 13px; }
tr.colnums th { text-align: center; padding: 2px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #eef0f3; color: var(--muted); white-space: nowrap; }
.tag.danger { background: #fdecea; color: var(--danger); font-weight: 600; }
.tag.warn { background: #fff4e0; color: var(--warn); }
.tag.ok { background: #e8f5e9; color: var(--ok); }
.cert-expired { color: var(--danger); font-weight: 600; }
.cert-missing { color: var(--warn); }
.badge { background: var(--gold); color: var(--brand-dark); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.btn.primary:hover { background: var(--brand-dark); }
h1 { color: var(--brand); }
th { background: #f7f0e6 !important; }
.login-logo { display: block; margin: 0 auto 16px; background: var(--brand); border-radius: 10px; padding: 12px; width: 100%; max-width: 320px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters label { width: auto; }
form.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
form.inline input[type=date] { width: auto; padding: 4px; }
.notes { list-style: none; padding: 0; }
.notes li { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.notes li.unread { border-left: 4px solid var(--danger); }
@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .grid .wide { grid-column: 1 / -1; }
}
@media print {
  .top, .filters, .actions, button { display: none !important; }
  main { padding: 0; max-width: none; }
  .table-wrap { border: 0; overflow: visible; }
  th, td { border: 1px solid #999; }
  @page { size: A4 landscape; margin: 10mm; }
}
.hint { margin: 0 0 8px; color: var(--primary); }
.warnings { margin-top: 10px; background: #fff4e0; color: var(--warn); border-radius: 8px; padding: 4px 12px; }
#recognize-status { display: inline-block; margin-left: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 16px; text-decoration: none; background: var(--card); border: 1px solid var(--line); color: var(--text); }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs a.active .muted { color: var(--cream); }
.filters a.active { font-weight: 600; color: var(--text); }
.issue-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.issue p { margin: 8px 0; }
.issue.status-resolved, .issue.status-skipped { opacity: .75; }
.issue-form { display: flex; flex-direction: column; gap: 8px; }
.issue-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cert-status { white-space: nowrap; }
.danger-link { color: var(--danger) !important; }
details.cert { border-top: 1px solid var(--line); padding: 10px 0; }
details.cert > summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
details.add { margin-top: 12px; }
details.add > summary { list-style: none; display: inline-block; }
.add-product { flex: 1 1 100%; }
.add-product > summary { list-style: none; display: inline-block; }
#product-search { max-width: 360px; }
.tag.muted { background: #eef0f3; color: var(--muted); }
.item-main { display: grid; grid-template-columns: minmax(200px, 3fr) 80px repeat(3, minmax(80px, 1fr)) minmax(130px, 1.3fr); gap: 10px; margin-bottom: 8px; }
.item-cert { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-bottom: 10px; }
.item-cert details[open] { flex: 1 1 100%; }
.cert-state.ok { color: var(--ok); }
.cert-state.warn { color: var(--warn); }
.cert-state.danger { color: var(--danger); font-weight: 600; }
.hint .warn { color: var(--warn); font-weight: 600; }
.totals { font-weight: 600; }
.totals .check-ok { color: var(--ok); }
.totals .check-bad { color: var(--danger); }
@media (max-width: 800px) {
  .item-main { grid-template-columns: 1fr 1fr; }
  .item-main .f-name { grid-column: 1 / -1; }
}
input.need { border-color: var(--danger); background: #fff3f2; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tag.pay-new { background: #fff4e0; color: var(--warn); }
.tag.pay-in_bank { background: #f6ecd7; color: #7a5518; }
.tag.pay-paid { background: #e8f5e9; color: var(--ok); }
.draft-note { background: #fff4e0; border-color: #f0d9a8; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cert-cell { min-width: 220px; }
.cert-fix[open] { margin-top: 6px; }
.pay-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.pay-bar { position: sticky; bottom: 0; background: var(--brand); color: var(--cream); padding: 10px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: 0 -4px 12px rgba(0,0,0,.12); }
.pay-bar .btn.primary { background: var(--gold); border-color: var(--gold); color: var(--brand-dark); font-weight: 600; }
.pay-bar input[type=date] { width: auto; padding: 4px; }
.paid-group { display: inline-flex; gap: 6px; align-items: center; }
.cert-choice { flex: 1 1 100%; background: #fff4e0; border-radius: 8px; padding: 6px 10px; }
.cert-choice p { margin: 0 0 4px; }
.cert-choice .warn { color: var(--warn); font-weight: 600; }
.delete-receipt { margin: 20px 0; text-align: right; }
.who a.me { color: var(--cream); }
.who a.me:hover { color: var(--gold); }
.ok-note { color: var(--ok); font-weight: 600; }
.cert-choice label.check { display: flex; gap: 8px; align-items: center; justify-content: flex-start; margin: 2px 0; font-size: 13px; }
.cert-choice input[type=radio] { width: 16px; height: 16px; flex: none; }
[hidden] { display: none !important; }
.item-cert { display: block; margin-bottom: 10px; }
.cert-modes { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.cert-modes .cert-title { color: var(--muted); }
.cert-modes label.check { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; }
.cert-modes input[type=radio] { width: 16px; height: 16px; }
.item-cert .cert-state { margin: 4px 0; }
.cert-ref-box { display: flex; flex-direction: column; max-width: 520px; margin-top: 4px; }
.cert-manual { margin-top: 4px; }
.flash { border-color: #d9c69b; background: #fffaf0; }
.flash li.warn { color: var(--warn); font-weight: 600; }
h2 .btn.small { margin-left: 10px; font-size: 13px; vertical-align: middle; }
.picked-files { margin: 4px 0 0; padding-left: 20px; color: var(--text); }
.picked-files li { margin: 2px 0; }
.picked-files .add-more { list-style: none; margin-left: -20px; }
tr.row-error td { background: #ffd9dc !important; color: #8b0010; font-weight: 600; }
tr.row-error td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.error-banner { background: #ffd9dc; color: #8b0010; font-weight: 700; padding: 10px 14px; border-radius: 8px; }
.warn-banner { background: #fff4e0; color: var(--warn); padding: 10px 14px; border-radius: 8px; }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card.month { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); }
.card.month:hover { border-color: var(--gold); }
.card.month.has-errors { border-left: 5px solid var(--danger); }
.title-page { display: none; text-align: center; }
.title-page .tp-name { font-size: 34px; margin: 60px 0 8px; color: var(--text); }
.title-page .tp-sub { font-size: 18px; font-weight: 600; }
.title-page .tp-org { font-size: 16px; margin-top: 40px; }
.title-page .tp-period { font-size: 18px; margin: 40px 0; }
.title-page .tp-dates, .title-page .tp-resp { font-size: 15px; text-align: left; margin-left: 50%; }
dialog { border: 0; border-radius: 12px; padding: 20px; max-width: 520px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(40, 0, 5, .45); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@media print {
  .no-print { display: none !important; }
  .title-page { display: block; page-break-after: always; min-height: 90vh; }
  tr.row-error td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media screen { .title-page { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 20px 20px; margin-bottom: 14px; }
  .title-page .tp-name { margin-top: 20px; } .title-page .tp-org { margin-top: 10px; } .title-page .tp-period { margin: 16px 0; } }
.toast { position: fixed; top: 70px; right: 16px; z-index: 50; padding: 10px 16px; border-radius: 10px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); animation: toast-out 4s forwards; }
.toast-ok { background: #e8f5e9; color: var(--ok); border: 1px solid #b7dfba; }
.toast-error { background: #ffd9dc; color: #8b0010; border: 1px solid #f1a3aa; animation: none; }
@keyframes toast-out { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }
@media print { .toast { display: none; } }
@media print {
  .title-page { padding-top: 40mm; }
  .title-page .tp-org { font-size: 16pt; } .title-page .tp-address { font-size: 13pt; }
  .title-page .tp-name { font-size: 40pt; margin-top: 30mm; } .title-page .tp-sub { font-size: 18pt; }
  .title-page .tp-basis { font-size: 11pt; } .title-page .tp-period { font-size: 18pt; margin: 20mm 0; }
  .title-page .tp-dates, .title-page .tp-resp { font-size: 14pt; }
}
