/* =====================================================================
   DQH Platform — design system
   Tokeny (kolory, typografia, odstępy) w :root; tryb ciemny przez
   prefers-color-scheme albo data-theme="dark". Kolor marki: --brand
   (ustawiany per wdrożenie w base.html z BRAND_ACCENT).
   ===================================================================== */

:root {
  --brand: #3b5bfd;
  --accent: var(--brand);
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --accent-strong: color-mix(in srgb, var(--accent) 82%, #000);

  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --surface-3: #e9ecf3;
  --border: #e3e6ee;
  --border-strong: #cfd5e1;
  --text: #0e1525;
  --text-2: #3b4559;
  --muted: #6a7489;

  --won: #15964b;    --won-soft: #e4f6eb;
  --lost: #d93a2b;   --lost-soft: #fdebe9;
  --warn: #c27400;   --warn-soft: #fff3db;
  --info: #0b7fc7;   --info-soft: #e3f2fc;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: color-mix(in srgb, var(--brand) 78%, #fff);
    --bg: #0b0f18; --surface: #121825; --surface-2: #171f2f; --surface-3: #1f2839;
    --border: #232d40; --border-strong: #31405a;
    --text: #e8ecf4; --text-2: #c2cada; --muted: #8e9ab1;
    --won: #3fcf7f; --won-soft: #12301f; --lost: #ff6b5e; --lost-soft: #3a1714;
    --warn: #f0a83a; --warn-soft: #362712; --info: #4fb3f2; --info-soft: #0f2a3c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: color-mix(in srgb, var(--brand) 78%, #fff);
  --bg: #0b0f18; --surface: #121825; --surface-2: #171f2f; --surface-3: #1f2839;
  --border: #232d40; --border-strong: #31405a;
  --text: #e8ecf4; --text-2: #c2cada; --muted: #8e9ab1;
  --won: #3fcf7f; --won-soft: #12301f; --lost: #ff6b5e; --lost-soft: #3a1714;
  --warn: #f0a83a; --warn-soft: #362712; --info: #4fb3f2; --info-soft: #0f2a3c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- podstawy ---------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -.015em; margin: 0 0 .25rem; }
h2 { font-size: .95rem; font-weight: 600; margin: 0 0 .75rem; }
p { margin: .25rem 0 .75rem; }
code, kbd { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: .05rem .4rem;
  color: var(--muted); background: var(--surface); font-size: .72rem; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.ok { color: var(--won); }
.error { color: var(--lost); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; margin: .25rem 0 0; }
.i { flex-shrink: 0; vertical-align: middle; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ---------- powłoka aplikacji ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  transition: grid-template-columns .2s ease; }
:root[data-sidebar="collapsed"] .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: .5rem;
  background: var(--surface); border-right: 1px solid var(--border); padding: .9rem .7rem; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .35rem .9rem; min-height: 44px; }
.brand img { height: 30px; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #7c3aed));
  color: #fff; font-weight: 700; font-size: .78rem; letter-spacing: .02em; }
.brand-name { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 1rem; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  padding: 0 .6rem .3rem; font-weight: 600; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: .65rem; padding: .5rem .6rem; border-radius: 8px;
  color: var(--text-2); font-weight: 500; font-size: .92rem; white-space: nowrap; border: 0; background: none;
  font-family: inherit; cursor: pointer; width: 100%; text-align: left; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active .i { color: var(--accent); }
.collapse-btn { color: var(--muted); margin-top: auto; }
:root[data-sidebar="collapsed"] .sidebar .brand-name,
:root[data-sidebar="collapsed"] .sidebar .nav-item span,
:root[data-sidebar="collapsed"] .sidebar .nav-label { display: none; }
:root[data-sidebar="collapsed"] .sidebar .nav-item { justify-content: center; }
:root[data-sidebar="collapsed"] .sidebar .nav-group { padding-top: .5rem; border-top: 1px solid var(--border); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); }
.search-trigger { display: flex; align-items: center; gap: .6rem; width: min(440px, 100%); height: 38px;
  padding: 0 .75rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; text-align: left; }
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger:hover { border-color: var(--border-strong); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.theme-light { display: none; }
:root[data-theme="dark"] .theme-light { display: inline; }
:root[data-theme="dark"] .theme-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-light { display: inline; }
  :root:not([data-theme="light"]) .theme-dark { display: none; }
}
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: .8rem; list-style: none; }
.avatar::-webkit-details-marker { display: none; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .35rem; display: flex; flex-direction: column; }
.menu-panel a, .menu-link { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border-radius: 7px;
  color: var(--text); font: inherit; font-size: .9rem; background: none; border: 0; cursor: pointer; width: 100%; }
.menu-panel a:hover, .menu-link:hover { background: var(--surface-2); text-decoration: none; }
.menu-head { display: flex; flex-direction: column; padding: .5rem .6rem .6rem; border-bottom: 1px solid var(--border);
  margin-bottom: .3rem; }
.menu-head small { color: var(--muted); }

.content { padding: 1.5rem; max-width: 1680px; width: 100%; }

/* ---------- paleta poleceń (Ctrl+K) ---------- */
.palette { width: min(640px, calc(100vw - 32px)); margin: 12vh auto auto; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.palette::backdrop { background: rgba(8, 12, 22, .45); backdrop-filter: blur(2px); }
.palette-input { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border);
  color: var(--muted); }
.palette-input input { flex: 1; border: 0; background: none; font: inherit; font-size: 1.05rem; color: var(--text);
  outline: none; box-shadow: none; padding: 0; }
.palette-results { max-height: 60vh; overflow-y: auto; padding: .4rem; }
.palette-hint { padding: .6rem .7rem; margin: 0; font-size: .88rem; }
.palette-group > span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: .6rem .7rem .3rem; font-weight: 600; }
.palette-hit { display: grid; grid-template-columns: auto 1fr; column-gap: .65rem; align-items: center;
  padding: .5rem .7rem; border-radius: 8px; color: var(--text); }
.palette-hit small { grid-column: 2; color: var(--muted); font-size: .8rem; }
.palette-hit b { font-weight: 550; }
.palette-hit:hover, .palette-hit:focus { background: var(--accent-soft); text-decoration: none; box-shadow: none; }
.palette-hit .i { grid-row: span 2; color: var(--muted); }

/* ---------- komunikaty ---------- */
.toast { display: flex; align-items: center; gap: .5rem; padding: .65rem .9rem; margin-bottom: 1rem;
  border-radius: var(--radius); background: var(--won-soft); color: var(--won); font-weight: 500;
  transition: opacity .4s, transform .4s; }
.toast.error { background: var(--lost-soft); color: var(--lost); }
.toast.hide { opacity: 0; transform: translateY(-6px); }
.notice { padding: .7rem .9rem; border-radius: var(--radius); background: var(--info-soft); color: var(--text-2);
  border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.empty { display: grid; place-items: center; gap: .3rem; padding: 2.5rem 1rem; color: var(--muted); text-align: center; }

/* ---------- karty, siatki, nagłówki ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm); }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem;
  flex-wrap: wrap; }
.head h1 small { font-size: .9rem; font-weight: 500; }
.grid2, .grid3, .kpis, .module-grid { display: grid; gap: 1rem; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 1rem; }
.module-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.module.on { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.kpi { display: flex; flex-direction: column; gap: .2rem; margin: 0; }
.kpi small { color: var(--muted); font-weight: 500; }
.kpi strong { font-size: 1.55rem; font-weight: 650; letter-spacing: -.02em; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }

/* ---------- przyciski i pola ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; height: 38px; padding: 0 .95rem;
  border-radius: 9px; border: 1px solid transparent; background: var(--accent); color: #fff; font: inherit;
  font-weight: 550; font-size: .9rem; cursor: pointer; white-space: nowrap; list-style: none;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent); transition: background .15s; }
.btn:hover { background: var(--accent-strong); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 32px; padding: 0 .7rem; font-size: .84rem; }
.btn.lg { height: 44px; font-size: .95rem; }
.btn.block { display: flex; width: 100%; }
.btn.danger { background: var(--lost); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
button.link.danger { color: var(--lost); }
summary.link { color: var(--accent); cursor: pointer; list-style: none; margin-top: .5rem; font-size: .9rem; font-weight: 500; }
summary::-webkit-details-marker { display: none; }

input, select, textarea { font: inherit; font-size: .92rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: .5rem .65rem; min-height: 38px;
  transition: border-color .15s, box-shadow .15s; }
textarea { min-height: auto; resize: vertical; }
select[multiple] { padding: .3rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input[type=checkbox], input[type=radio] { min-height: auto; accent-color: var(--accent); width: 16px; height: 16px; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--text-2); font-weight: 500; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.4rem; max-width: 980px; padding: 1.4rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .84rem; color: var(--text-2); font-weight: 500; }
.field.check label { color: var(--text); font-size: .95rem; display: flex; gap: .5rem; align-items: center; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; }
.field small { font-size: .78rem; }
.span2 { grid-column: 1 / -1; }
.actions { display: flex; gap: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }
.stack.compact { gap: .5rem; margin-top: .6rem; }
.stack.compact > div { display: flex; flex-direction: column; gap: .2rem; font-size: .84rem; }
.stack.compact input, .stack.compact select { width: 100%; }

/* ---------- logowanie ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #7c3aed 10%, transparent), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 2rem; box-shadow: var(--shadow-lg); }
.brand.big { padding: 0 0 1.2rem; }
.local-login { margin-top: 1rem; }
.local-login summary { cursor: pointer; color: var(--muted); font-size: .88rem; margin-bottom: .7rem; }

/* ---------- etykiety i statusy ---------- */
.tag { display: inline-block; background: var(--surface-2); color: var(--text-2); border-radius: 999px;
  padding: .05rem .55rem; font-size: .75rem; margin-right: .25rem; font-weight: 500; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .1rem .55rem; font-size: .74rem;
  font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.status-won, .badge.status-rfq { background: var(--won-soft); color: var(--won); }
.badge.status-lost, .badge.status-error { background: var(--lost-soft); color: var(--lost); }
.badge.status-stale, .badge.status-other { background: var(--surface-3); color: var(--muted); }
.badge.status-verify, .badge.status-new { background: var(--warn-soft); color: var(--warn); }
.badge.status-thread, .badge.status-known { background: var(--info-soft); color: var(--info); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip-filter { padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: .85rem; font-weight: 500; }
.chip-filter.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-filter:hover { text-decoration: none; border-color: var(--border-strong); }

/* ---------- tabele i listy ---------- */
table { width: 100%; border-collapse: collapse; }
td, th { padding: .6rem .65rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
th { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* overflow: clip (nie hidden) — hidden tworzy kontener przewijania i psuje przyklejony nagłówek */
table.list { padding: 0; overflow: clip; display: table; }
table.list thead th { background: var(--surface-2); position: sticky; top: var(--topbar-h); }
table.list tbody tr:hover { background: var(--surface-2); }
table.list tr:last-child td { border-bottom: 0; }
ul.plain { list-style: none; margin: 0 0 .5rem; padding: 0; }
ul.plain li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }
/* align-content: start — bez tego rozciągnięty dl (np. w siatce kolumn) rozpycha wiersze na całą wysokość */
dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; align-content: start; }
dt { color: var(--muted); font-size: .88rem; }
dd { margin: 0; }

/* ---------- filtry i widoki ---------- */
.filters, .filterbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filterbar { padding: .75rem; }
.filterbar input[name=q] { flex: 1 1 240px; }
.filters input { flex: 1; }
.filterbar .inline { display: flex; align-items: center; gap: .35rem; font-size: .84rem; color: var(--muted); }
.toggle { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.toggle a { padding: .35rem .8rem; color: var(--text-2); border-radius: 7px; font-size: .88rem; font-weight: 500; }
.toggle a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.toggle a:hover { text-decoration: none; }
.saved { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: -.25rem 0 1rem; font-size: .85rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .15rem .65rem; }
.chip form { display: inline; }
.save-filter[open] form { margin-top: .4rem; }

/* ---------- tablica projektów (kanban) ---------- */
.board { display: flex; gap: .85rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.column { flex: 0 0 272px; background: var(--surface-2); border-radius: var(--radius-lg); padding: .55rem; border: 1px solid var(--border); }
.column header { display: flex; flex-direction: column; padding: .3rem .35rem .65rem; }
.column header strong { font-size: .9rem; }
.column header small { color: var(--muted); font-variant-numeric: tabular-nums; }
.column.won header strong { color: var(--won); }
.column.lost header strong { color: var(--lost); }
.deal { display: flex; flex-direction: column; gap: .1rem; background: var(--surface); border-radius: var(--radius);
  padding: .7rem .75rem; margin-bottom: .5rem; color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .15s; }
.deal:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.deal strong { font-weight: 600; font-size: .92rem; }
.deal span, .deal small { color: var(--muted); font-size: .84rem; }
.deal .badge { align-self: flex-start; margin-top: .35rem; }

/* ---------- karta projektu (3 kolumny) ---------- */
.card3 { display: grid; grid-template-columns: 310px minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.card3 .card { margin-bottom: .85rem; }
.title { font-size: 1.25rem; margin: .55rem 0 .2rem; letter-spacing: -.01em; }
.facts { margin-top: 1rem; font-size: .9rem; }
.keyinfo { border-left: 3px solid var(--warn); }
.keyinfo summary { cursor: pointer; list-style: none; }
.reg-approved { color: var(--won); }
.reg-rejected, .reg-expired { color: var(--lost); }
.section { font-size: .76rem; color: var(--muted); margin: .4rem 0 .6rem; text-transform: uppercase; letter-spacing: .06em; }
.card form.note { display: block; margin: 0; }
.note .tabs { display: flex; gap: .3rem; font-size: .85rem; margin-bottom: .6rem; flex-wrap: wrap; }
.note .tabs label { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--border); cursor: pointer; color: var(--text-2); }
.note .tabs label:has(input:checked) { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 550; }
.note .tabs input { display: none; }
.note .row { flex-wrap: nowrap; align-items: stretch; }
.note textarea { flex: 1; }
.tasks li { display: flex; flex-direction: column; }
.tasks label { display: flex; gap: .5rem; align-items: center; cursor: pointer; }
.tasks li.done label { text-decoration: line-through; color: var(--muted); }
.tasks li.late label { color: var(--lost); font-weight: 600; }
.status-buttons { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .85rem; }
.pill { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px;
  padding: .3rem .8rem; cursor: pointer; font: inherit; font-size: .84rem; font-weight: 500; }
.pill:hover { border-color: var(--border-strong); }
.pill.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill.won.on { background: var(--won); border-color: var(--won); }
.pill.stale.on { background: var(--muted); border-color: var(--muted); }
.pill.lost.on { background: var(--lost); border-color: var(--lost); color: #fff; }
.lost-box { display: contents; }
.lost-box[open] input { width: 100%; margin: .3rem 0; }
.prob { display: flex; justify-content: space-between; font-size: .85rem; }
.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: .35rem; }
.bar div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.process { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.stage-name { width: 100%; text-align: left; border: 0; border-radius: 8px; padding: .5rem .7rem; background: var(--surface-2);
  color: var(--text-2); font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer; }
.stage-name:hover:not(:disabled) { background: var(--surface-3); }
.stage-name:disabled { cursor: default; }
.process li.passed .stage-name { background: var(--accent-soft); color: var(--accent); }
.process li.current .stage-name { background: var(--accent); color: #fff; font-weight: 600; }
.steps { list-style: none; padding: .5rem .25rem .3rem .45rem; margin: 0; }
.steps li { padding: .25rem 0; font-size: .9rem; }
.steps label { cursor: pointer; display: flex; gap: .5rem; align-items: center; }
.steps form { margin: 0; }
.hint-text { display: block; color: var(--muted); font-size: .78rem; margin: .1rem 0 0 1.5rem; }
table.items td { font-size: .88rem; vertical-align: top; padding: .45rem .3rem; }
table.items tr.sum td { font-weight: 650; border-bottom: 0; }

/* ---------- tablica aktywności ---------- */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { position: relative; padding: .55rem .9rem .7rem 1.4rem; margin-bottom: .55rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); }
.timeline li::before { content: ""; position: absolute; left: .55rem; top: .95rem; width: 7px; height: 7px; border-radius: 50%;
  background: var(--border-strong); }
.timeline li.note::before { background: var(--accent); }
.timeline li.system::before { background: var(--muted); }
.timeline li.email_in::before, .timeline li.email_out::before { background: var(--warn); }
.timeline li.call::before, .timeline li.meeting::before { background: var(--won); }
.timeline strong { display: block; font-weight: 600; }

/* ---------- cele ---------- */
.goal h2 { margin: 0; }
.goal .ok { color: var(--won); }
.goal .behind { color: var(--warn); }
.metric { margin: .7rem 0; font-size: .88rem; }
.metric .bar { position: relative; overflow: visible; height: 9px; }
.metric .bar div.full { background: var(--won); }
.pace { position: absolute; top: -4px; width: 2px; height: 17px; background: var(--text); opacity: .45; border-radius: 2px; }

/* ---------- procesy ---------- */
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .9rem; align-items: center;
  color: var(--text); margin-bottom: .6rem; transition: border-color .15s, transform .15s; }
.task-row:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.task-row.late { border-left: 3px solid var(--lost); }
.task-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); }
.task-main { display: flex; flex-direction: column; min-width: 0; }
.task-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-step { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.start-list { display: flex; flex-direction: column; gap: .35rem; }
.start-item { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem; border-radius: var(--radius);
  color: var(--text); border: 1px solid var(--border); }
.start-item:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.start-item .i { color: var(--accent); margin-top: 2px; }
.start-item span { display: flex; flex-direction: column; }
.start-item small { font-size: .8rem; }
.badge.wf-active { background: var(--info-soft); color: var(--info); }
.badge.wf-done { background: var(--won-soft); color: var(--won); }
.badge.wf-cancelled { background: var(--lost-soft); color: var(--lost); }
.badge.wf-draft { background: var(--surface-3); color: var(--muted); }
.req { color: var(--lost); }
.wf-form input:disabled, .wf-form select:disabled, .wf-form textarea:disabled { background: var(--surface-2);
  color: var(--text-2); border-style: dashed; }

.stepper { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 0 0 1.2rem; }
.stepper li { display: flex; align-items: center; gap: .45rem; padding: .35rem .8rem .35rem .4rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: .86rem; color: var(--muted); font-weight: 500; }
.stepper .dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3);
  font-size: .75rem; font-weight: 650; }
.stepper li.done { color: var(--won); }
.stepper li.done .dot { background: var(--won-soft); color: var(--won); }
.stepper li.current { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.stepper li.current .dot { background: var(--accent); color: #fff; }

.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); margin-bottom: 1rem; }
.notice.warn ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.ok-notice { display: flex; gap: .5rem; align-items: center; background: var(--won-soft); color: var(--won);
  border-color: color-mix(in srgb, var(--won) 25%, transparent); margin-bottom: 1rem; }
.flow { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .4rem; }
.flow-step { flex: 0 0 230px; border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem;
  background: var(--surface-2); display: flex; flex-direction: column; gap: .2rem; position: relative; }
.flow-step.kind-start { border-top: 3px solid var(--accent); }
.flow-step.kind-end { border-top: 3px solid var(--won); }
.flow-step.kind-task { border-top: 3px solid var(--info); }
.flow-head { display: flex; justify-content: space-between; align-items: center; }
.flow-paths { list-style: none; padding: 0; margin: .4rem 0 0; font-size: .8rem; display: flex; flex-direction: column; gap: .25rem; }
.flow-paths li { padding: .25rem .45rem; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.flow-paths li.path-danger { border-color: color-mix(in srgb, var(--lost) 40%, var(--border)); }
.flow-paths code { font-size: .72rem; }
.table-scroll { overflow-x: auto; margin-bottom: .6rem; }
table.matrix th, table.matrix td { white-space: nowrap; }
table.matrix select { min-height: 32px; padding: .2rem .4rem; font-size: .82rem; }
.acc-hidden { color: var(--muted); }
.acc-required { border-color: var(--lost); }
.acc-edit { border-color: var(--accent); }

/* ---------- KSeF ---------- */
.badge.inv-review { background: var(--info-soft); color: var(--info); }
.badge.inv-approved { background: var(--accent-soft); color: var(--accent); }
.badge.inv-booked { background: var(--won-soft); color: var(--won); }
.badge.inv-rejected { background: var(--lost-soft); color: var(--lost); }
.badge.inv-new { background: var(--warn-soft); color: var(--warn); }
.notice ol { margin: .4rem 0; padding-left: 1.2rem; }

/* ---------- rejestry (GUS, Biała lista) ---------- */
.lookup-bar { max-width: 980px; border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.lookup-bar > .row { flex-wrap: nowrap; }
.lookup-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent); }
.lookup-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lookup-input { width: 220px; font-variant-numeric: tabular-nums; }
.suggestion { margin-top: .8rem; padding: .8rem .9rem; border-radius: var(--radius); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.suggestion.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent);
  display: flex; gap: .5rem; align-items: center; }
.suggestion .badge { margin-left: .3rem; }
.just-filled { border-color: var(--won) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--won) 20%, transparent); }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* ---------- responsywność ---------- */
@media (max-width: 1280px) {
  .card3 { grid-template-columns: 290px minmax(0, 1fr); }
  .col-right { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: .85rem; }
}
@media (max-width: 900px) {
  .app, :root[data-sidebar="collapsed"] .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .5rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: .25rem; }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .collapse-btn { display: none; }
  .brand { padding: .25rem .5rem; }
  .topbar { padding: 0 1rem; }
  .search-trigger kbd { display: none; }
  .content { padding: 1rem; }
  .grid2, .grid3, .card3, .form-grid, .grid-main-side { grid-template-columns: 1fr; }
}
