/* Tendio — „Rejestr przetargowy". Granat + papier + mono; teal tylko dla warstwy AI. */

:root {
  --ink: #17232f;          /* granatowy atrament — marka, nagłówki, tekst główny */
  --ink-soft: #55636f;     /* tekst drugorzędny */
  --ink-faint: #8b96a0;    /* podpisy, mono-meta */
  --paper: #f2f3f0;        /* tło strony — chłodny papier */
  --card: #ffffff;
  --line: #e0e3dd;         /* włoskowate obramowania */
  --line-soft: #ecefe9;

  --accent: #0b6e75;       /* teal — WYŁĄCZNIE warstwa AI + focus/linki */
  --accent-ink: #084f54;
  --accent-bg: #e5f0f0;

  --good: #2e7d4f;   --good-bg: #e6f0e9;   --good-line: #c3ddce;
  --mid:  #b0771f;   --mid-bg:  #f5ecd8;   --mid-line:  #e6d3a8;
  --weak: #77828c;   --weak-bg: #eceef0;   --weak-line: #dde1e4;
  --danger: #b23a28;

  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 2px rgba(23,35,47,.05), 0 4px 16px -8px rgba(23,35,47,.12);
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.mono { font-family: var(--mono); font-feature-settings: 'tnum' 1; }

/* ── Nagłówek ── */
.topbar {
  background: var(--ink);
  color: #eef1f3;
  border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 30;
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.wordmark {
  font-family: var(--sans); font-weight: 700; font-size: 25px;
  letter-spacing: -.02em; line-height: 1; color: #fff;
}
.wordmark::after {
  content: '·'; color: var(--accent); margin-left: 2px;
  font-weight: 700;
}
.kicker {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em;
  text-transform: uppercase; color: #93a2ad;
}

.ledger-stats {
  display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap;
  margin-left: auto;
  font-family: var(--mono); font-size: 12.5px; color: #b7c2cb;
}
.ledger-stats .fig { color: #fff; font-weight: 600; }
.ledger-stats .stat-sep { color: #3d4c58; }
.ledger-stats .unit { font-size: 11px; letter-spacing: .04em; }

.btn {
  font-family: var(--sans); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .14s, border-color .14s, color .14s;
}
.btn svg { width: 16px; height: 16px; }
.btn-solid { background: #fff; color: var(--ink); }
.btn-solid:hover { background: #dfe6ea; }
.btn-solid:disabled { opacity: .55; cursor: wait; }

.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #24374a; }
.btn-block { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }

.btn-accent {
  background: var(--accent-bg); color: var(--accent-ink);
  border-color: var(--accent); font-size: 13px; padding: 8px 13px;
}
.btn-accent:hover { background: #d6e8e8; text-decoration: none; }
.btn-accent:disabled { opacity: .6; cursor: wait; }

.btn-ghost {
  background: var(--card); color: var(--ink-soft);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.btn-ghost:hover { border-color: var(--ink-faint); color: var(--ink); }

/* ── Layout ── */
.layout {
  max-width: 1240px; margin: 26px auto; padding: 0 24px;
  display: grid; grid-template-columns: 314px 1fr; gap: 26px; align-items: start;
}
@media (max-width: 940px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

/* Lewy panel: przyklejony, ale z WŁASNYM przewijaniem — ustawisz profil bez
   zjeżdżania prawą kolumną na sam dół */
.sidebar {
  display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 92px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 8px 10px 2px; margin: -2px 0 0 -2px;
  scrollbar-width: thin;
  scrollbar-color: #c6ccc4 transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #c6ccc4; border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }
@media (max-width: 940px) {
  .sidebar { position: static; max-height: none; overflow: visible; padding: 0; margin: 0; }
}

.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between;
}
.card-head h2 {
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.card-body { padding: 20px; }

/* ── Formularz profilu ── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label,
.field-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink);
  margin-bottom: 6px; letter-spacing: .01em;
}
.field small { font-weight: 400; color: var(--ink-faint); }

input[type="text"], input[type="number"], input[type="search"], textarea, select {
  width: 100%; font-family: var(--sans); font-size: 13.5px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; transition: border-color .14s, box-shadow .14s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
textarea { resize: vertical; line-height: 1.45; }
.field .mono-input { font-family: var(--mono); font-size: 12.5px; letter-spacing: .02em; }

.province-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px;
}
.province-grid label {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 400; color: var(--ink-soft); cursor: pointer;
  padding: 2px 0;
}
.province-grid input { width: auto; accent-color: var(--accent); }
.province-grid label.is-main { color: var(--ink); font-weight: 600; }

.budget-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.save-note { font-size: 12.5px; color: var(--good); margin-top: 10px; min-height: 16px; text-align: center; }

/* ── Legenda punktacji ── */
.key-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.key-row { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; color: var(--ink-soft); }
.key-weight {
  font-family: var(--mono); font-weight: 600; font-size: 12px; color: var(--ink);
  min-width: 42px; text-align: right;
}
.key-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.key-bar > i { display: block; height: 100%; background: var(--ink); }
.key-scale { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }

/* ── Pasek narzędzi wyników ── */
.results-head { margin-bottom: 16px; }
.toolbar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
  padding: 12px 14px;
}

/* Segmented control — filtr portali */
.segmented {
  display: inline-flex; background: var(--paper);
  border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px;
}
.seg-btn {
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--ink-soft); background: transparent; border: none; cursor: pointer;
  padding: 7px 13px; border-radius: 6px; display: inline-flex; align-items: center; gap: 7px;
  transition: background .14s, color .14s, box-shadow .14s;
}
.seg-btn .seg-count {
  font-family: var(--mono); font-size: 11px; color: var(--ink-faint);
  background: #fff; padding: 1px 6px; border-radius: 20px; border: 1px solid var(--line);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-pressed="true"] {
  background: var(--ink); color: #fff; box-shadow: var(--shadow);
}
.seg-btn[aria-pressed="true"] .seg-count { color: var(--ink); background: #fff; border-color: transparent; }

.search-wrap { position: relative; flex: 1; min-width: 210px; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-faint); pointer-events: none; }
.search-wrap input { padding-left: 34px; }

.select-inline { width: auto; min-width: 150px; cursor: pointer; font-size: 13px; }

.list-info {
  font-size: 12.5px; color: var(--ink-faint); margin: 0 4px 14px;
  font-family: var(--mono); letter-spacing: .01em;
}
.list-info b { color: var(--ink-soft); font-weight: 600; }

/* ── Karty ogłoszeń ── */
.notice-list { display: flex; flex-direction: column; gap: 14px; }

.notice-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px 20px;
  display: grid; grid-template-columns: 62px 1fr; gap: 18px;
  transition: border-color .14s, box-shadow .14s;
}
.notice-card:hover { border-color: var(--ink-faint); box-shadow: 0 2px 4px rgba(23,35,47,.06), 0 8px 24px -12px rgba(23,35,47,.18); }
.notice-card.tier-good { border-left: 3px solid var(--good); }
.notice-card.tier-mid  { border-left: 3px solid var(--mid); }
.notice-card.tier-weak { border-left: 3px solid var(--line); }

/* Sygnatura: pierścień-miernik dopasowania */
.score { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.gauge {
  --v: 0; --track: var(--weak-line); --fill: var(--weak);
  position: relative; width: 56px; height: 56px; border-radius: 50%;
  background: conic-gradient(var(--fill) calc(var(--v) * 3.6deg), var(--track) 0);
}
.gauge::after {
  content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--card);
}
.gauge > b {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 600; font-size: 18px; color: var(--ink);
  letter-spacing: -.03em;
}
.gauge.tier-good { --fill: var(--good); --track: var(--good-line); }
.gauge.tier-mid  { --fill: var(--mid);  --track: var(--mid-line); }
.gauge.tier-weak { --fill: var(--weak); --track: var(--weak-line); }
.score-label {
  font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
}

.notice-body { min-width: 0; }
.notice-top { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; }
.notice-title { font-size: 16px; font-weight: 600; line-height: 1.34; letter-spacing: -.01em; }
.notice-title a { color: var(--ink); }
.notice-title a:hover { color: var(--accent); }

.src-tag {
  flex-shrink: 0; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .04em; padding: 4px 9px; border-radius: 6px; white-space: nowrap;
  border: 1px solid; margin-top: 2px;
}
.src-tag .src-scope { font-weight: 400; opacity: .7; }
.src-tag.src-bzp { color: #7a4a12; background: var(--mid-bg); border-color: var(--mid-line); }
.src-tag.src-ted { color: var(--accent-ink); background: var(--accent-bg); border-color: #bcd9d9; }

.notice-meta {
  display: flex; flex-wrap: wrap; gap: 5px 16px; margin: 9px 0 12px;
  font-size: 12.5px; color: var(--ink-soft);
}
.notice-meta .m { display: inline-flex; align-items: center; gap: 6px; }
.notice-meta svg { width: 14px; height: 14px; color: var(--ink-faint); flex-shrink: 0; }
.notice-meta .m-id { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.notice-meta .urgent { color: var(--danger); font-weight: 600; }
.notice-meta .urgent svg { color: var(--danger); }

/* Rozbicie punktacji */
.parts { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.part {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; padding: 4px 9px; border-radius: 7px;
  background: var(--paper); border: 1px solid var(--line); color: var(--ink-soft);
}
.part .part-pts { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--ink-faint); }
.part.hit { background: var(--good-bg); border-color: var(--good-line); color: #24603d; }
.part.hit .part-pts { color: var(--good); }
.part.partial { background: var(--mid-bg); border-color: var(--mid-line); color: #7a4a12; }
.part.partial .part-pts { color: var(--mid); }

.notice-excerpt { font-size: 13px; color: var(--ink-soft); line-height: 1.55; margin-bottom: 14px; }

.notice-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.link-ext { font-size: 12.5px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 5px; }
.link-ext svg { width: 13px; height: 13px; }
.link-ext:hover { color: var(--accent); text-decoration: none; }

/* ── Notatka analityka (AI) ── */
.ai-panel {
  margin-top: 14px; padding: 15px 17px; border-radius: var(--r);
  background: var(--accent-bg); border: 1px solid #bcd9d9;
  border-left: 3px solid var(--accent);
}
.ai-eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 11px; display: flex; align-items: center; gap: 8px;
}
.ai-eyebrow .ai-model { color: var(--accent); opacity: .75; letter-spacing: .04em; }
.ai-verdict-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.verdict {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; padding: 5px 13px; border-radius: 7px; color: #fff;
}
.verdict::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.verdict.startuj { background: var(--good); }
.verdict.rozwaz { background: var(--mid); }
.verdict.odpusc { background: var(--weak); }
.ai-gauge-wrap { flex: 1; min-width: 130px; display: flex; align-items: center; gap: 9px; }
.ai-bar { flex: 1; height: 6px; background: #cfe3e3; border-radius: 4px; overflow: hidden; }
.ai-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.ai-num { font-family: var(--mono); font-weight: 600; font-size: 13px; color: var(--accent-ink); }
.ai-panel p { font-size: 13px; line-height: 1.55; color: var(--ink); margin-bottom: 7px; }
.ai-panel p:last-child { margin-bottom: 0; }
.ai-panel .ai-lead { font-weight: 600; color: var(--accent-ink); }
.ai-error { font-size: 12.5px; color: var(--danger); margin-top: 10px; }

/* ── Stany ── */
.empty-state {
  text-align: center; padding: 56px 24px; color: var(--ink-soft);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.empty-state b { color: var(--ink); display: block; margin-bottom: 6px; font-size: 15px; }
.empty-state span { font-size: 13.5px; }

.skeleton { display: flex; flex-direction: column; gap: 14px; }
.skel-card { height: 128px; border-radius: var(--r-lg); background: var(--card); border: 1px solid var(--line); position: relative; overflow: hidden; }
.skel-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(23,35,47,.04), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* Stronicowanie */
.pagination {
  display: flex; justify-content: center; align-items: center; gap: 6px;
  margin: 22px 0 8px; flex-wrap: wrap;
}
.page-btn {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  min-width: 36px; height: 36px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  transition: border-color .14s, color .14s, background .14s;
}
.page-btn:hover:not(:disabled):not(.is-current) { border-color: var(--ink-faint); color: var(--ink); }
.page-btn.is-current { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; cursor: default; }
.page-btn:disabled { opacity: .4; cursor: default; }
.page-btn.page-nav { font-size: 16px; }
.page-gap { font-family: var(--mono); color: var(--ink-faint); padding: 0 2px; }

.footer {
  max-width: 1240px; margin: 0 auto; padding: 28px 24px 40px;
  font-size: 12px; color: var(--ink-faint); font-family: var(--mono); letter-spacing: .01em;
  border-top: 1px solid var(--line); margin-top: 12px;
}
.footer a { color: var(--ink-soft); }

.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(11,110,117,.25);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; flex-shrink: 0;
}
.btn-primary .spinner { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 620px) {
  .topbar-inner { padding: 14px 16px; gap: 16px; }
  .ledger-stats { gap: 12px; width: 100%; }
  .layout { padding: 0 16px; margin: 18px auto; }
  .notice-card { grid-template-columns: 1fr; gap: 14px; }
  .score { flex-direction: row; gap: 12px; align-self: flex-start; }
  .toolbar { padding: 12px; }
  .select-inline { flex: 1; }
}
