/* LegMon — panel monitoringu legislacyjnego */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1d2530;
  --muted: #6b7686;
  --line: #e3e7ee;
  --accent: #d2232a;         /* czerwień Lewiatana */
  --accent-dark: #a91b21;
  --ok: #1e8e3e;
  --warn: #b7791f;
  --err: #c5221f;
  --info: #1a73e8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

/* ---------- nagłówek ---------- */
header.top {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.top-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .logo {
  width: 26px; height: 26px; border-radius: 6px; background: var(--accent);
  color: #fff; font-weight: 800; font-size: 15px; display: inline-flex;
  align-items: center; justify-content: center; align-self: center;
}
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.brand .sub { color: var(--muted); font-size: 12.5px; }
nav.tabs { display: flex; gap: 4px; margin-left: auto; }
nav.tabs button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 8px;
  font: inherit; color: var(--muted); cursor: pointer; font-weight: 500;
}
nav.tabs button:hover { background: #f0f2f6; color: var(--ink); }
nav.tabs button.active { background: #fdeeef; color: var(--accent-dark); font-weight: 600; }
.health { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--err); }

main { max-width: 1100px; margin: 24px auto 80px; padding: 0 20px; }
.view { display: none; }
.view.active { display: block; }

/* ---------- elementy wspólne ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
h2.title { font-size: 19px; margin: 0 0 4px; }
p.hint { color: var(--muted); margin: 0 0 16px; font-size: 13.5px; }
label.fld { display: block; margin-bottom: 14px; }
label.fld > span, .fld-head {
  display: block; font-size: 12.5px; font-weight: 600; color: #3d4757;
  margin-bottom: 5px; letter-spacing: .01em;
}
.opt { color: var(--muted); font-weight: 400; }
.pick-hint { margin-top: 5px; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.pick-hint.ok { color: var(--ok); }
.pick-hint.err { color: var(--err); }
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 90px; }
textarea.mono, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid #f6c2c4; border-color: var(--accent);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- akty Dziennika Ustaw ---------- */
.acts-hero {
  position: relative; overflow: hidden; display: flex; justify-content: space-between;
  gap: 24px; padding: 28px 30px; margin-bottom: 16px; border-radius: 14px;
  color: #fff; background: linear-gradient(118deg, #7f1118 0%, #bd2028 58%, #e05649 100%);
  box-shadow: 0 12px 32px rgba(127, 17, 24, .2);
}
.acts-hero::after { content: "Dz.U."; position: absolute; right: 150px; bottom: -44px; color: rgba(255,255,255,.08); font: 800 120px Georgia, serif; }
.acts-hero h2 { margin: 2px 0 6px; font: 700 30px Georgia, "Times New Roman", serif; }
.acts-hero p { max-width: 650px; margin: 0; color: #ffe8e6; }
.eyebrow { font-size: 11px; font-weight: 750; letter-spacing: .14em; color: #ffd1cd; }
.acts-source { align-self: center; min-width: 190px; padding-left: 18px; border-left: 1px solid rgba(255,255,255,.35); font-size: 12px; color: #ffd1cd; }
.acts-source b { color: #fff; font-size: 13px; }
.acts-controls { padding-bottom: 10px; }
.acts-form { display: grid; grid-template-columns: 180px 180px auto auto auto; gap: 10px; align-items: end; }
.acts-form .fld { margin: 0; }
.acts-form .primary, .acts-form .ghost { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; }
.acts-export.disabled { opacity: .45; pointer-events: none; }
.spin.dark { border-color: #9ca4af; border-top-color: transparent; }
.acts-controls .hint { margin: 10px 0 0; }
.acts-stats { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: stretch; gap: 10px; margin: 16px 0; }
.acts-stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 13px 16px; box-shadow: var(--shadow); }
.acts-stats strong { display: block; color: var(--accent-dark); font: 700 25px Georgia, serif; }
.acts-stats span { color: var(--muted); font-size: 12px; }
.acts-stats i { align-self: center; color: #bf7b7f; font-style: normal; font-size: 21px; }
.acts-table-card { padding: 0; overflow: hidden; }
.acts-table-wrap { overflow-x: auto; }
.acts-table { min-width: 920px; }
.acts-table th { background: #f9eeee; color: #7f1118; }
.acts-table td { vertical-align: top; padding-top: 12px; padding-bottom: 12px; }
.acts-table tr.relevant td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.acts-pos { white-space: nowrap; color: var(--muted); }
.acts-pos b { color: var(--ink); }
.act-kind { text-transform: uppercase; letter-spacing: .06em; color: var(--accent-dark); font-size: 10px; font-weight: 750; }
.act-title { margin-top: 3px; max-width: 520px; font-family: Georgia, "Times New Roman", serif; font-size: 14px; line-height: 1.4; }
.badge.act-relevant { background: #fff1d6; color: #8a5a00; }
.badge.act-affected { margin-top: 5px; background: #e6f4ea; color: #17663a; }
.muted { color: var(--muted); }
.acts-bulk {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  align-items: flex-end; margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.acts-bulk-left, .acts-bulk-right {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.acts-bulk-mid {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  flex: 1 1 320px; min-width: 280px;
}
.acts-bulk-mid .fld-inline { margin: 0; min-width: 140px; }
.acts-bulk-mid select { max-width: 220px; }
.acts-bulk-mid #acts-bulk-consensus { min-width: 160px; }
.acts-bulk .hint { color: var(--muted); font-size: 12.5px; }
.acts-table td.acts-check { width: 36px; text-align: center; padding-top: 14px; }
.acts-bulk-busy { opacity: .7; pointer-events: none; }
@media (max-width: 760px) {
  .acts-hero { padding: 22px; }
  .acts-source { display: none; }
  .acts-form { grid-template-columns: 1fr 1fr; }
  .acts-stats { grid-template-columns: 1fr 1fr; }
  .acts-stats i { display: none; }
}

button.primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 22px; font: inherit; font-weight: 600; cursor: pointer;
}
button.primary:hover { background: var(--accent-dark); }
button.primary:disabled { background: #e7a4a7; cursor: default; }
button.ghost {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 14px; font: inherit; color: var(--ink); cursor: pointer;
}
button.ghost:hover { border-color: #c6cdd8; background: #f7f8fa; }
button.ghost:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}
#findings-pager { margin-top: 12px; padding: 10px 14px; }
a.ghost {
  display: inline-block; text-decoration: none; line-height: 1.3; font-size: 14px;
}
button.danger { color: var(--err); }
button.link {
  border: 0; background: none; color: var(--info); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: auto; }

/* ---------- odznaki ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.prio-Wysoki { background: #fde8e8; color: #b3261e; }
.badge.prio-Średni { background: #fdf1dc; color: #96650f; }
.badge.prio-Niski  { background: #edf0f4; color: #57606e; }
.badge.st-Do-weryfikacji { background: #e8f0fe; color: #185abc; }
.badge.st-Potwierdzona-zmiana { background: #fde8e8; color: #b3261e; }
.badge.st-Do-aktualizacji { background: #fdf1dc; color: #96650f; }
.badge.st-W-trakcie { background: #fff7e0; color: #8a6d00; }
.badge.st-Zaktualizowano { background: #e6f4ea; color: #1e8e3e; }
.badge.st-Nie-dotyczy { background: #edf0f4; color: #57606e; }
.badge.st-Wymaga-ponownej-analizy { background: #f3e8fd; color: #7627bb; }
.badge.job { text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.badge.job.queued { background: #edf0f4; color: #57606e; }
.badge.job.running { background: #e8f0fe; color: #185abc; }
.badge.job.done { background: #e6f4ea; color: #1e8e3e; }
.badge.job.error, .badge.job.cancelled { background: #fde8e8; color: #b3261e; }
.badge.method { background: #f4f0ff; color: #5b21b6; }
.badge.conf { background: #eefaf1; color: #17663a; }

/* ---------- kolejka zadań ---------- */
.job-item {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 10px; cursor: pointer;
}
.job-item:hover { border-color: #c9d0da; }
.job-main { flex: 1; min-width: 0; }
.job-main .t { font-weight: 600; margin-bottom: 2px; }
.job-main .m { color: var(--muted); font-size: 12.5px; }
.progress {
  height: 6px; background: #edf0f4; border-radius: 99px; overflow: hidden;
  margin-top: 8px; max-width: 480px;
}
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.job-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ---------- szczegóły zadania ---------- */
.jobmeta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
.jobmeta b { color: var(--ink); }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .fld-inline { min-width: 170px; }
.filters label { font-size: 12.5px; font-weight: 600; color: #3d4757; display: block; margin-bottom: 4px; }

.finding { margin-bottom: 14px; }
.finding .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.finding .head .t { font-weight: 650; font-size: 15.5px; }
.finding .head .u { font-size: 12.5px; word-break: break-all; }
.finding .why { margin: 10px 0 4px; }
.finding .why b.lbl, .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.fragment {
  border-left: 3px solid var(--accent); background: #fbfbfc;
  padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 10px 0;
}
.fragment .sec { font-size: 12.5px; font-weight: 600; color: var(--accent-dark); margin-bottom: 4px; }
.fragment blockquote {
  margin: 4px 0; padding: 6px 10px; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; font-style: italic; font-size: 13.5px;
}
.fragment .fld-head { margin-top: 8px; }
.basis-note {
  background: #f4f0ff; border: 1px solid #e4dbfa; border-radius: 8px;
  padding: 8px 12px; font-size: 13.5px; margin-top: 10px;
}
.status-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.status-line select { width: auto; min-width: 170px; }
details.raw { margin-top: 8px; font-size: 12px; }
details.raw pre { background: #f6f7f9; padding: 10px; border-radius: 8px; overflow: auto; max-height: 300px; }

/* ---------- scraping: status przebiegu ---------- */
.scrape-line { font-size: 13.5px; color: var(--muted); }
.scrape-line b { color: var(--ink); }
.scrape-hist { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.scrape-hist .h { display: flex; gap: 14px; padding: 3px 0; flex-wrap: wrap; }
.scrape-hist .h .chg { color: var(--ok); font-weight: 600; }
.scrape-hist .h .err { color: var(--err); font-weight: 600; }

/* ---------- tabela dokumentów (klikalna) ---------- */
#docs-table tr.doc-row { cursor: pointer; }
#docs-table tr.doc-row:hover td { background: #f7f8fa; }
.doc-title-cell { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fresh { color: var(--ok); }
.stale { color: #c9a227; }

/* ---------- modal podglądu ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(18, 24, 34, .45); z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
}
.modal {
  background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
  width: 100%; max-width: 860px; max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head .title { font-size: 16.5px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.finding-modal { max-width: 1400px; height: calc(100vh - 80px); }
.finding-split { display: grid; grid-template-columns: minmax(320px, 430px) 1fr; min-height: 0; flex: 1; }
.finding-inspector { padding: 18px; overflow-y: auto; border-right: 1px solid var(--line); }
.finding-preview { min-width: 0; display: flex; flex-direction: column; background: #eef1f5; }
.finding-preview iframe { border: 0; width: 100%; flex: 1; background: #fff; }
.preview-bar { padding: 8px 12px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); background: #fff; }
.finding-panel-block { margin-bottom: 14px; }
.finding-panel-block p { margin: 5px 0 0; font-size: 13.5px; }
.finding-panel-block blockquote { margin: 5px 0 0; padding: 8px 10px; background: #fffdf0; border-left: 3px solid #d2232a; font-size: 13px; }
.finding-panel-block .draft { padding: 9px; border: 1px dashed var(--line); border-radius: 6px; background: #fbfbfc; }
.badge.decision-NO_ACTION { background: #edf0f4; color: #57606e; }
.badge.decision-LINK { background: #e8f0fe; color: #185abc; }
.badge.decision-ADD, .badge.decision-AMEND { background: #e6f4ea; color: #17663a; }
.badge.decision-REPLACE, .badge.decision-REMOVE { background: #fde8e8; color: #b3261e; }
.badge.decision-EDITOR_REVIEW { background: #fdf1dc; color: #96650f; }
@media (max-width: 900px) { .finding-split { grid-template-columns: 1fr; grid-template-rows: 48% 52%; } .finding-inspector { border-right: 0; border-bottom: 1px solid var(--line); } }
.dm-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.dm-meta b { color: var(--ink); }
.doc-section { margin-bottom: 14px; }
.doc-section .nm { font-weight: 650; font-size: 14.5px; color: var(--accent-dark); margin-bottom: 3px; }
.doc-section .tx { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.vers { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
.vers .v { display: flex; gap: 14px; align-items: baseline; padding: 4px 0; font-size: 13px; flex-wrap: wrap; }
.vers .v .d { font-weight: 600; min-width: 150px; }
.vers .v code { background: #f4f5f7; padding: 1px 6px; border-radius: 5px; font-size: 11.5px; }
.vers .v .cur { color: var(--ok); font-weight: 600; }

/* ---------- dokumenty ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #222a35; color: #fff; border-radius: 8px; padding: 10px 18px;
  font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--err); }
.spin {
  width: 14px; height: 14px; border: 2px solid #fff; border-top-color: transparent;
  border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 6px;
  animation: r .7s linear infinite;
}
@keyframes r { to { transform: rotate(360deg); } }

/* ---------- logowanie (AUTH_PASSWORD) ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(245, 246, 248, .92); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.auth-overlay[hidden] { display: none; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 28px 24px; width: 100%; max-width: 340px;
}
.auth-err {
  color: var(--err); font-size: 13px; margin-top: 8px; text-align: center;
}
