:root {
  --bg: #f4f6f8;
  --panel: #fff;
  --border: #d0d7de;
  --accent: #1f6feb;
  --text: #1f2328;
  --muted: #57606a;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
.brand { color: var(--accent); font-size: 18px; font-weight: 700; text-decoration: none; }
.brand-dot { color: #FFB7C5; font-size: 14px; margin-left: 0; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; }
.nav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.nav a.active, .nav a:hover { background: #e0e9ff; color: var(--accent); }
.toolbar-spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.procurement-page { padding: 12px; }
.page-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.page-heading h1 { margin: 0; font-size: 21px; }
.page-status { color: var(--muted); font-size: 12px; }
.page-status.error { color: #d1242f; }
.lists-strip { display: flex; align-items: flex-start; gap: 10px; overflow-x: auto; padding: 2px 2px 14px; }
.lists-strip:has(> .list-card) { max-height: calc(100vh - 175px); overflow: auto; }
.list-card { flex: 0 0 300px; max-width: calc(100vw - 32px); padding: 8px; border: 1px solid #c9cfd6; border-radius: 3px; background: #ffffff; }
.list-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-header h2 { margin: 0; font-size: 17px; font-weight: 500; }
.list-metrics { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 7px; }
.list-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 5px 0; }
.add-list-card { display: flex; flex: 0 0 210px; min-height: 180px; align-items: center; justify-content: center; padding: 18px; border: 2px dashed #9db4d2; border-radius: 5px; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-weight: 600; text-align: center; }
.add-list-card:hover { background: #edf4ff; border-color: var(--accent); }
.purchase-card { margin-top: 8px; padding: 7px; border: none; border-radius: 2px; background: #fff; }
.purchase-card.complete, .table-purchase.complete { background: #d9f2df; }
.purchase-card.incomplete, .table-purchase.incomplete { background: #ffdce2; }
.purchase-title { display: flex; align-items: center; flex-wrap: nowrap; gap: 6px 10px; }
.purchase-title h3 { flex: 1; min-width: 0; margin: 0; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.purchase-done { flex: none; color: #16866c; font-size: 12px; white-space: nowrap; }
.count-badge { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; min-width: 15px; height: 15px; padding: 0 3px; border: 0; background: #d1242f; color: #fff; cursor: pointer; font: inherit; font-size: 9px; line-height: 1; }
.list-card.attention-day-4 { outline: 2px solid #ffd1dc; outline-offset: 1px; }
.list-card.attention-day-5 { outline: 2px solid #ffabc1; outline-offset: 1px; }
.list-card.attention-day-6 { outline: 2px solid #ff7d9d; outline-offset: 1px; }
.list-card.attention-day-7 { outline: 2px solid #ff3366; outline-offset: 1px; }
.procurement-table tr.attention-day-4 { outline: 2px solid #ffd1dc; outline-offset: -2px; }
.procurement-table tr.attention-day-5 { outline: 2px solid #ffabc1; outline-offset: -2px; }
.procurement-table tr.attention-day-6 { outline: 2px solid #ff7d9d; outline-offset: -2px; }
.procurement-table tr.attention-day-7 { outline: 2px solid #ff3366; outline-offset: -2px; }
.metric { display: inline-block; padding: 2px 5px; color: #fff; font-size: 11px; font-weight: 600; line-height: 1.2; }
.metric-total { background: #16866c; }
.metric-paid { background: #239fa4; }
.metric-remaining { background: #ef704d; }
.purchase-actions { display: flex; flex: none; flex-wrap: wrap; gap: 10px; margin-bottom: 0; margin-left: 0; }
.purchase-entry-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 5px 0; }
.entry-list { display: grid; gap: 3px; margin-top: 0; }
.entry-row { display: flex; align-items: center; gap: 5px; padding: 0; background: transparent; cursor: pointer; font-size: 11px; }
.entry-row input[type="checkbox"] { width: 13px; height: 13px; margin: 0; }
.entry-row.done { color: var(--muted); text-decoration: none; }
.entry-vat { padding: 1px 3px; border-radius: 3px; background: #555555; color: #fff; font-size: 10px; white-space: nowrap; }
.entry-amount, .entry-quantity { padding: 2px 5px; }
.entry-amount.pending { background: #ef704d; color: #fff; }
.entry-row[data-edit-entry="receipts"] .entry-amount.pending { background: #00c8c8; color: #fff; }
.entry-amount.done, .entry-quantity.done { background: #e2e4e6; color: #4b5560; }
.entry-quantity.pending { background: #fff; color: var(--text); }
.entry-row .entry-delete { margin-left: auto; }
.text-action { padding: 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: 11px; text-decoration: none; }
.text-action:hover { text-decoration: underline; }
.text-action.danger { color: #d1242f; }
.btn { padding: 7px 11px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); cursor: pointer; font: inherit; }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.small { padding: 3px 7px; font-size: 12px; }
.btn.danger { color: #d1242f; }
input, select { width: 100%; max-width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); font: inherit; }
.empty { padding: 10px 0; color: var(--muted); font-size: 12px; }
.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(31, 35, 40, 0.35); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(440px, calc(100vw - 32px)); padding: 20px; border-radius: 12px; background: #fff; box-shadow: 0 16px 50px rgba(31, 35, 40, 0.25); }
.modal h2 { margin: 0 0 16px; font-size: 20px; }
.modal-form { display: grid; gap: 12px; }
.modal-form label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
.modal-form .check-label { display: flex; align-items: center; gap: 6px; }
.modal-form .check-label input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#modalDeletePurchase { margin-right: auto; }
.view-toggle { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); }
.view-toggle button { padding: 5px 10px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.view-toggle button.active { background: var(--accent); color: #fff; }
.add-list-heading { margin-right: auto; }
.table-scroll { width: 100%; overflow-x: auto; }
.procurement-table { width: 100%; table-layout: auto; border-collapse: collapse; background: #fff; }
.procurement-table th, .procurement-table td { border-bottom: 1px solid #e6ebf0; text-align: left; vertical-align: top; }
.procurement-table th { padding: 8px; background: #f3f5f7; color: var(--muted); font-size: 12px; white-space: nowrap; }
.procurement-table td { min-width: 220px; padding: 0; border-right: 1px solid #eeeeee; }
.procurement-table .project-cell { min-width: 260px; }
.table-purchase { padding: 7px; }
.table-purchase-heading { display: flex; align-items: center; flex-wrap: nowrap; gap: 6px; }
.table-counterparty { min-width: 0; margin-bottom: 0; overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.table-purchase + .table-purchase { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e6ebf0; }
.service-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.service-tabs button { padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font: inherit; }
.service-tabs button.active { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.invoice-filter { width: auto; min-width: 150px; margin-left: auto; padding: 5px 8px; font-size: 12px; }
.invoices-table-wrap { overflow-x: auto; background: var(--panel); }
.invoices-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.invoices-table th, .invoices-table td { padding: 9px; border-bottom: 1px solid #e6ebf0; text-align: left; vertical-align: top; }
.invoices-table th { background: #f3f5f7; color: var(--muted); white-space: nowrap; }
.invoices-table td { min-width: 100px; }
.invoices-table td:first-child { min-width: 190px; }
.invoices-table a { color: var(--accent); text-decoration: none; }
.invoices-table a:hover { text-decoration: underline; }
.invoice-status-badge { display: inline-block; padding: 3px 6px; border-radius: 3px; white-space: nowrap; }
.invoice-status-badge.draft { background: #e2e4e6; color: #4b5560; }
.invoice-status-badge.pending { background: #fff0c2; color: #735c00; }
.invoice-status-badge.approved { background: #d9f2df; color: #146636; }
.invoice-status-badge.rejected { background: #ffdce2; color: #a01826; }
.invoice-actions { display: flex; flex-wrap: wrap; gap: 7px; min-width: 120px; }
.invoice-comment { max-width: 180px; margin-top: 5px; color: #a01826; }
.invoice-edit-modal { width: min(720px, calc(100vw - 32px)); }
.invoice-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.invoice-form-grid label.needs-review { padding: 6px; border-radius: 5px; background: #fff0c2; color: #735c00; }
.ocr-notice { margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.ocr-notice.warning { color: #8a5a00; }
.ocr-text { margin-top: 14px; font-size: 12px; }
.ocr-text pre { max-height: 180px; overflow: auto; padding: 8px; background: #f3f5f7; white-space: pre-wrap; }
.modal-form textarea { width: 100%; max-width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font: inherit; resize: vertical; }
.modal-form label[hidden] { display: none; }
@media (max-width: 640px) {
  .invoice-form-grid { grid-template-columns: 1fr; }
}
