:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --sidebar: #fbfcfa;
  --text: #202a25;
  --muted: #657069;
  --line: #e1e6e0;
  --green: #156b52;
  --green-dark: #0e5541;
  --green-soft: #eaf4ef;
  --amber: #925f13;
  --amber-soft: #fff4dc;
  --red: #a33a3a;
  --red-soft: #fff0ee;
  --shadow: 0 8px 28px rgba(31, 49, 40, .06);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
:focus-visible { outline: 3px solid #77ad97; outline-offset: 3px; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 10px 14px; background: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; width: 236px; display: flex; flex-direction: column; padding: 22px 14px 18px; background: var(--sidebar); border-right: 1px solid var(--line); }
.brand-wrap { padding: 0 10px 20px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 21px; font-weight: 750; letter-spacing: -.4px; }
.brand svg { color: var(--green); width: 24px; height: 24px; }
.demo-badge { display: inline-flex; align-items: center; width: max-content; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.demo-label { margin: 8px 0 0 32px; color: var(--muted); font-size: 12px; }
.side-nav { display: grid; gap: 5px; margin-top: 14px; }
.nav-link { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 12px; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.nav-link:hover { background: #f0f4ef; }
.nav-link[aria-current="page"] { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.side-footer { display: grid; gap: 14px; margin-top: auto; padding: 18px 10px 0; border-top: 1px solid var(--line); }
.demo-user { display: grid; }
.demo-user span { color: var(--muted); font-size: 12px; }

.main { min-height: 100vh; margin-left: 236px; padding: 22px 28px 48px; }
.demo-notice { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding: 10px 14px; border: 1px solid #c9ded3; border-radius: 10px; background: var(--green-soft); color: var(--green-dark); font-size: 13px; }
.demo-notice strong { text-transform: uppercase; letter-spacing: .05em; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
h1 { margin: 0; font-size: clamp(23px, 2vw, 29px); line-height: 1.2; letter-spacing: -.6px; }
.heading-group p { margin: 6px 0 0; color: var(--muted); }
.topbar-actions { display: flex; align-items: flex-end; gap: 10px; }
.period-label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
select, input[type="search"] { min-height: 42px; border: 1px solid #cfd7d0; border-radius: 8px; background: var(--surface); color: var(--text); }
select { min-width: 172px; padding: 8px 34px 8px 11px; }
input[type="search"] { width: min(310px, 100%); padding: 9px 12px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 8px; font-weight: 650; text-decoration: none; }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border-color: var(--line); background: var(--surface); }
.button-secondary:hover { background: #f1f5f1; }
.button-danger { background: var(--red); color: #fff; }
.button-small { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

.basket-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.basket-card, .panel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.basket-card { padding: 20px; }
.basket-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.basket-card h2 { margin: 0; font-size: 16px; }
.basket-description { min-height: 42px; margin: 6px 0 17px; color: var(--muted); font-size: 13px; }
.basket-badge { display: inline-flex; padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 11px; }
.basket-card dl { margin: 0; }
.basket-card dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 8px; }
.basket-card dt { color: var(--muted); font-size: 13px; }
.basket-card dd { margin: 0; font-weight: 700; }
.basket-card .remaining { font-size: 24px; letter-spacing: -.5px; }
.progress-row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
progress { width: 100%; height: 7px; border: 0; border-radius: 999px; overflow: hidden; background: #e6ebe6; }
progress::-webkit-progress-bar { background: #e6ebe6; }
progress::-webkit-progress-value { background: var(--green); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 999px; }
.progress-row span { min-width: 48px; color: var(--muted); font-size: 12px; text-align: right; }
.total-strip { display: flex; justify-content: space-between; gap: 16px; margin: 18px 0; padding: 4px 2px 16px; border-bottom: 1px solid var(--line); }
.total-strip p { margin: 0; }
.attention-ok { color: var(--green); }
.attention-needed { color: var(--amber); }

.panel { overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 18px 18px 14px; }
.panel-header h2 { margin: 0; font-size: 18px; }
.document-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.filter-group { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #f6f8f5; }
.filter-button { min-height: 32px; padding: 5px 10px; border: 0; border-radius: 6px; background: transparent; font-size: 12px; }
.filter-button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 4px rgba(20, 40, 30, .12); font-weight: 700; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 14px; background: #f5f6f2; color: #626b64; font-size: 12px; text-align: left; white-space: nowrap; }
td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
td.amount, th.amount { text-align: right; white-space: nowrap; }
.document-number { display: block; font-weight: 750; }
.document-meta { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 11px; white-space: nowrap; }
.status-approved { background: var(--green-soft); color: var(--green-dark); }
.status-review { background: var(--amber-soft); color: var(--amber); }
.empty-state { padding: 32px 18px; color: var(--muted); text-align: center; }
.registry-panel { margin-top: 4px; }
.report-grid { display: grid; gap: 18px; }
.report-actions { display: flex; gap: 8px; }
.report-summary { color: var(--muted); }
.negative { color: var(--red); }

.modal { width: min(780px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 40px)); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(20, 35, 28, .24); }
.modal::backdrop { background: rgba(22, 34, 28, .5); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 20px 8px; }
.modal-header > div { display: grid; gap: 8px; }
.modal h2 { margin: 0; font-size: 21px; }
.modal-description, .reset-modal p { margin: 0; padding: 0 20px 16px; color: var(--muted); }
.library-list { display: grid; gap: 8px; max-height: 520px; padding: 0 20px 16px; overflow-y: auto; }
.library-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 9px; }
.library-item h3 { margin: 0 0 3px; font-size: 14px; }
.library-item p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.library-item-actions { display: flex; align-items: center; gap: 12px; }
.library-item-actions strong { white-space: nowrap; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 15px 20px; border-top: 1px solid var(--line); }
.reset-modal { width: min(460px, calc(100vw - 32px)); padding-top: 20px; }
.reset-modal h2 { padding: 0 20px 10px; }
.toast { position: fixed; z-index: 30; right: 22px; bottom: 22px; max-width: min(400px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 9px; background: #203c31; color: #fff; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .main { padding-inline: 20px; }
  .basket-grid { grid-template-columns: 1fr; }
  .basket-description { min-height: auto; }
  .topbar { flex-wrap: wrap; }
  .document-controls { justify-content: flex-start; width: 100%; }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-wrap { padding: 0 0 12px; }
  .brand { font-size: 20px; }
  .demo-label { margin-left: 0; }
  .side-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
  .nav-link { justify-content: center; gap: 6px; min-width: 0; padding: 8px 6px; font-size: 12px; line-height: 1.25; text-align: center; white-space: normal; }
  .side-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding: 10px 0 0; }
  .main { margin-left: 0; padding: 16px 14px 32px; }
  .demo-notice { align-items: flex-start; flex-direction: column; gap: 3px; margin-bottom: 16px; }
  .topbar { gap: 14px; margin-bottom: 18px; }
  .topbar-actions { align-items: stretch; width: 100%; }
  .period-label { flex: 1; }
  .period-label select { width: 100%; min-width: 0; }
  .basket-card { padding: 17px; }
  .total-strip { flex-direction: column; gap: 5px; }
  .panel-header { align-items: stretch; padding: 16px 14px 12px; }
  .document-controls { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; }
  .filter-group { width: 100%; }
  .filter-button { flex: 1; }
  input[type="search"] { width: 100%; }
  .table-wrap { overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tr { display: block; padding: 12px 14px; border-top: 1px solid var(--line); }
  td { display: grid; grid-template-columns: minmax(96px, .7fr) 1fr; gap: 10px; padding: 5px 0; border: 0; text-align: left !important; white-space: normal; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  td[data-label="Dokument"] { padding-top: 0; }
  .document-meta { overflow-wrap: anywhere; }
  .report-actions { width: 100%; }
  .report-actions .button { flex: 1; }
  .library-item { grid-template-columns: 1fr; gap: 10px; }
  .library-item-actions { justify-content: space-between; }
  .modal-header, .modal-footer { padding-inline: 16px; }
  .modal-description, .reset-modal p { padding-inline: 16px; }
  .library-list { padding-inline: 16px; }
  .toast { right: 16px; bottom: 16px; }
}

@media (max-width: 420px) {
  .topbar-actions { flex-direction: column; }
  .side-footer { align-items: stretch; flex-direction: column; }
  .demo-user { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
  .filter-group { flex-direction: column; }
  .filter-button { width: 100%; }
  .report-actions { flex-direction: column; }
}

@media print {
  .sidebar, .demo-notice, .topbar-actions, .report-actions, .toast { display: none !important; }
  .main { margin: 0; padding: 0; }
  .panel { box-shadow: none; break-inside: avoid; }
  body { background: #fff; font-size: 11px; }
  .topbar { margin-bottom: 14px; }
}
