/* KGR CRM - ten sam system wizualny co kgr-media.com: ciemne tło, Inter, pomarańczowy akcent, linie zamiast boksów. */
:root {
  --bg: #111111; --surface: #1a1a1a; --surface-2: #222222; --hover: rgba(255,255,255,.05);
  --line: rgba(255,255,255,.08); --line-strong: rgba(255,255,255,.16);
  --text: #f2f0eb; --muted: rgba(242,240,235,.62); --faint: rgba(242,240,235,.46);
  --accent: #ff5a1f; --accent-ink: #111; --ok: #45c07a; --warn: #e0a100; --bad: #ff6b5b;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.22,1,.36,1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }

/* Układ */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 1.5rem; padding: 1.4rem 1rem; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; padding: 0 .5rem; font-weight: 700; letter-spacing: -.03em; font-size: 1rem; }
.brand em { font-style: normal; font-weight: 600; font-size: .7rem; letter-spacing: .1em; padding: .15rem .45rem; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem; border-radius: 8px; color: var(--muted); transition: background .2s, color .2s; }
.nav a svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.side-add { margin-top: auto; padding: .7rem 1rem; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-align: left; }
.side-add:hover { background: #ff6f3a; }
.me { font-size: .75rem; color: var(--faint); padding: 0 .5rem; word-break: break-all; }
.main { min-width: 0; padding: 2rem clamp(1.25rem, 3vw, 3rem) 4rem; outline: none; }
.loading, .empty { color: var(--muted); padding: 2rem 0; }

/* Nagłówki widoków */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.label { display: inline-flex; align-items: center; gap: .5rem; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.label::before { content: ''; width: 6px; height: 6px; background: var(--accent); }
.h1 { margin-top: .6rem; font-size: clamp(1.8rem, 3vw, 2.5rem); font-weight: 620; letter-spacing: -.045em; line-height: 1.05; }
.sub { margin-top: .4rem; color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Przyciski i pola */
.btn { display: inline-flex; align-items: center; gap: .45rem; height: 2.5rem; padding: 0 1rem; border-radius: 10px; border: 1px solid var(--line-strong); font-weight: 540; white-space: nowrap; transition: border-color .2s, background .2s; }
.btn:hover { border-color: var(--text); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.pri:hover { background: #ff6f3a; }
.btn.sm { height: 2rem; padding: 0 .75rem; font-size: .85rem; border-radius: 8px; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.link { color: var(--muted); border-bottom: 1px solid var(--line-strong); transition: color .2s, border-color .2s; }
.link:hover { color: var(--accent); border-color: var(--accent); }
.in, .sel, .ta { width: 100%; padding: .6rem .75rem; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); transition: border-color .2s; }
.in:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--accent); }
.ta { resize: vertical; min-height: 5rem; }
.fld { display: flex; flex-direction: column; gap: .35rem; }
.fld > span { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { padding: .4rem .8rem; border: 1px solid var(--line-strong); border-radius: 999px; font-size: .85rem; color: var(--muted); transition: all .2s; }
.chip:hover { color: var(--text); border-color: var(--text); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip b { margin-left: .3rem; font-weight: 600; opacity: .7; }

/* Etapy */
.st { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 560; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.st::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-nowy { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.st-kontakt { color: #7fb4ff; background: rgba(127,180,255,.12); }
.st-rozmowa { color: #c79bff; background: rgba(199,155,255,.12); }
.st-oferta { color: var(--warn); background: rgba(224,161,0,.13); }
.st-klient { color: var(--ok); background: rgba(69,192,122,.13); }
.st-utracony { color: var(--faint); }
.st-cold { color: var(--faint); }

/* Liczby na pulpicie */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 2.5rem; }
.kpi { padding: 1.4rem 1.4rem 1.5rem; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi dt { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.kpi dd { margin: .6rem 0 0; font-size: clamp(1.7rem, 2.8vw, 2.4rem); font-weight: 620; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi small { display: block; margin-top: .4rem; font-size: .8rem; color: var(--muted); }
.kpi.hot dd { color: var(--accent); }
.cols2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2.5rem; }
.sec-t { font-size: 1.05rem; font-weight: 600; letter-spacing: -.02em; margin-bottom: .75rem; display: flex; justify-content: space-between; align-items: baseline; }
.sec-t a { font-size: .82rem; font-weight: 500; }

/* Listy z liniami */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows li { border-bottom: 1px solid var(--line); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem 1rem; align-items: center; padding: .8rem .25rem; transition: background .2s; }
a.row:hover { background: var(--hover); }
.row b { font-weight: 560; }
.row small { color: var(--muted); font-size: .82rem; }
.row .r { text-align: right; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.due { color: var(--accent) !important; }
.overdue { color: var(--bad) !important; }

/* Tabela kontaktów */
.tbl-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 500; padding: .7rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr[data-href] { cursor: pointer; }
.tbl tr[data-href]:hover td { background: var(--hover); }
.tbl .nm b { font-weight: 560; display: block; }
.tbl .nm small { color: var(--muted); }
.tools { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.tools .in { max-width: 22rem; }
.more { margin-top: 1rem; }

/* Lejek */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: 1rem; }
.colm { display: flex; flex-direction: column; min-height: 60vh; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.colm.over { border-color: var(--accent); }
.colm-h { display: flex; justify-content: space-between; align-items: center; padding: .85rem .9rem; border-bottom: 1px solid var(--line); }
.colm-h small { color: var(--faint); font-variant-numeric: tabular-nums; }
.cards { display: flex; flex-direction: column; gap: .5rem; padding: .6rem; flex: 1; }
.card { display: block; padding: .8rem .85rem; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); cursor: grab; transition: border-color .2s, transform .2s var(--ease); }
.card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.card.drag { opacity: .4; }
.card b { display: block; font-weight: 560; line-height: 1.3; }
.card small { display: block; margin-top: .3rem; color: var(--muted); font-size: .8rem; }
.card .meta { display: flex; justify-content: space-between; gap: .5rem; margin-top: .55rem; font-size: .78rem; color: var(--faint); }

/* Szczegóły kontaktu */
.detail { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.quick { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.panel { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: 1.75rem; }
.panel:first-child { margin-top: 0; }
.next { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .75rem; }
.compose { display: grid; gap: .6rem; }
.compose .actions { justify-content: space-between; }
.tl { list-style: none; margin: 1.25rem 0 0; padding: 0; }
.tl li { position: relative; padding: 0 0 1.1rem 1.4rem; border-left: 1px solid var(--line); margin-left: .35rem; }
.tl li::before { content: ''; position: absolute; left: -5px; top: .35rem; width: 9px; height: 9px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-strong); }
.tl li.t-notatka::before, .tl li.t-mail::before, .tl li.t-telefon::before, .tl li.t-spotkanie::before { background: var(--accent); border-color: var(--accent); }
.tl li.t-oferta::before { background: var(--warn); border-color: var(--warn); }
.tl .when { font-size: .75rem; color: var(--faint); display: flex; gap: .6rem; align-items: center; }
.tl .txt { margin-top: .2rem; white-space: pre-wrap; word-break: break-word; }
.tl .del { opacity: 0; color: var(--faint); font-size: .75rem; transition: opacity .2s; }
.tl li:hover .del { opacity: 1; }
.saved { font-size: .78rem; color: var(--ok); opacity: 0; transition: opacity .3s; }
.saved.on { opacity: 1; }

/* Oferta: edytor */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.item { padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); display: grid; gap: .6rem; }
.item-top { display: grid; grid-template-columns: minmax(0, 1fr) 5rem 8rem auto; gap: .6rem; align-items: end; }
.totals { display: flex; justify-content: flex-end; gap: 2rem; align-items: baseline; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line-strong); }
.totals b { font-size: 1.8rem; font-weight: 620; letter-spacing: -.04em; }
.cat-g { margin-top: 1rem; }
.cat-g h4 { margin: 0 0 .4rem; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 500; }
.cat-i { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .65rem .5rem; border-top: 1px solid var(--line); text-align: left; width: 100%; border-radius: 6px; }
.cat-i:hover { background: var(--hover); }
.cat-i small { color: var(--muted); grid-column: 1; }
.cat-i em { font-style: normal; color: var(--accent); font-weight: 600; }

/* Import */
.drop { display: grid; place-items: center; gap: .5rem; padding: 3rem 1rem; border: 1.5px dashed var(--line-strong); border-radius: 14px; text-align: center; color: var(--muted); transition: border-color .2s, background .2s; cursor: pointer; }
.drop.over, .drop:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.drop b { color: var(--text); font-size: 1.1rem; }
.note { margin-top: 1rem; padding: .9rem 1rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* Okno i powiadomienie */
.modal { width: min(640px, calc(100vw - 2rem)); max-height: 86vh; padding: 1.5rem; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 40px 80px -30px rgba(0,0,0,.8); }
.modal::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal h2 { font-size: 1.35rem; letter-spacing: -.03em; margin-bottom: 1rem; }
.modal .actions { justify-content: flex-end; margin-top: 1.25rem; }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50; padding: .8rem 1.1rem; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 540; box-shadow: 0 20px 40px -20px rgba(0,0,0,.6); }
.toast.bad { background: var(--bad); color: #fff; }
.lock { max-width: 34rem; padding: 3rem 0; }
.lock p { margin-top: .75rem; color: var(--muted); }

@media (max-width: 1100px) { .detail, .cols2 { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } .kpi:nth-child(3) { border-left: 0; padding-left: 0; } .kpi:nth-child(n+3) { border-top: 1px solid var(--line); } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .75rem 1rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .nav a { padding: .4rem .55rem; font-size: .85rem; }
  .nav a svg { display: none; }
  .side-add { margin: 0 0 0 auto; padding: .45rem .8rem; }
  .me { display: none; }
  .grid2, .grid3, .next, .item-top { grid-template-columns: 1fr; }
}

/* ---------------- Oferta: dokument do PDF (A4) ---------------- */
.doc-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.doc { width: 210mm; margin: 0 auto; color: #16140f; font-size: 10.5pt; line-height: 1.5; box-shadow: 0 40px 80px -30px rgba(0,0,0,.8); }
.pg { position: relative; width: 210mm; min-height: 297mm; padding: 18mm 18mm 22mm; background: #f6f4f0; }
.pg + .pg { margin-top: 10mm; }
.pg-cover { background: #111; color: #f2f0eb; display: flex; flex-direction: column; }
.d-brand { display: flex; align-items: center; gap: 3mm; font-weight: 700; font-size: 13pt; letter-spacing: -.03em; }
.d-brand img { width: 9mm; height: 9mm; }
.d-k { display: flex; align-items: center; gap: 2.5mm; font-size: 8pt; letter-spacing: .14em; text-transform: uppercase; color: rgba(242,240,235,.6); font-weight: 500; }
.d-k::before { content: ''; width: 2mm; height: 2mm; background: #ff5a1f; }
.cov-mid { margin-top: auto; }
.cov-t { margin-top: 6mm; font-size: 34pt; line-height: 1.02; letter-spacing: -.05em; font-weight: 620; }
.cov-for { margin-top: 6mm; font-size: 15pt; color: rgba(242,240,235,.7); }
.cov-for b { color: #ff5a1f; font-weight: 600; }
.cov-meta { margin-top: 16mm; display: grid; grid-template-columns: 1fr 1fr 1.1fr 1.4fr; border-top: 1px solid rgba(255,255,255,.16); }
.cov-meta div { padding: 5mm 4mm 0 0; }
.cov-meta dt { font-size: 7pt; letter-spacing: .12em; text-transform: uppercase; color: rgba(242,240,235,.5); }
.cov-meta dd { margin: 1.5mm 0 0; font-size: 10.5pt; font-weight: 560; white-space: nowrap; }
.cov-total { margin-top: 10mm; display: flex; justify-content: space-between; align-items: baseline; padding-top: 5mm; border-top: 1px solid rgba(255,255,255,.16); }
.cov-total span { font-size: 9pt; color: rgba(242,240,235,.6); }
.cov-total b { font-size: 26pt; letter-spacing: -.04em; font-weight: 620; color: #ff5a1f; }
.pg .d-k { color: rgba(22,20,15,.55); }
.pg-cover .d-k { color: rgba(242,240,235,.6); }
.d-h { margin-top: 3mm; font-size: 20pt; letter-spacing: -.04em; line-height: 1.1; font-weight: 620; }
.d-intro { margin-top: 5mm; font-size: 11pt; color: rgba(22,20,15,.78); white-space: pre-wrap; max-width: 150mm; }
.d-sec { margin-top: 12mm; }
.d-items { list-style: none; margin: 6mm 0 0; padding: 0; border-top: 1px solid rgba(22,20,15,.18); }
.d-item { display: grid; grid-template-columns: 10mm minmax(0, 1fr) 34mm; gap: 2mm 5mm; padding: 5mm 0; border-bottom: 1px solid rgba(22,20,15,.12); break-inside: avoid; }
.d-n { font-size: 8.5pt; color: #ff5a1f; font-weight: 600; font-variant-numeric: tabular-nums; padding-top: .8mm; }
.d-item h3 { font-size: 12.5pt; letter-spacing: -.02em; font-weight: 600; }
.d-item p { margin-top: 1.2mm; color: rgba(22,20,15,.7); font-size: 9.5pt; }
.d-item ul { margin: 2.5mm 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 1mm 5mm; font-size: 9pt; }
.d-item li { display: flex; gap: 2mm; }
.d-item li::before { content: '✓'; color: #ff5a1f; font-weight: 700; }
.d-time { margin-top: 2.5mm; font-size: 8.5pt; color: rgba(22,20,15,.55); }
.d-price { text-align: right; font-weight: 600; font-size: 11pt; font-variant-numeric: tabular-nums; }
.d-price small { display: block; font-weight: 400; font-size: 8pt; color: rgba(22,20,15,.55); }
.d-sum { margin-top: 6mm; margin-left: auto; width: 85mm; break-inside: avoid; }
.d-sum div { display: flex; justify-content: space-between; padding: 2mm 0; font-size: 10pt; color: rgba(22,20,15,.7); font-variant-numeric: tabular-nums; }
.d-sum .tot { margin-top: 1mm; padding-top: 3.5mm; border-top: 1.5px solid #16140f; color: #16140f; font-size: 13pt; font-weight: 650; }
.d-sum .tot b { color: #ff5a1f; font-size: 17pt; letter-spacing: -.03em; }
.d-note { margin-top: 2mm; text-align: right; font-size: 8pt; color: rgba(22,20,15,.5); }
.d-steps { margin: 6mm 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5mm; break-inside: avoid; }
.d-steps li { padding-top: 3mm; border-top: 1px solid rgba(22,20,15,.18); font-size: 9.5pt; color: rgba(22,20,15,.72); }
.d-steps b { display: block; margin-bottom: 1mm; color: #16140f; font-size: 10.5pt; }
.d-steps i { font-style: normal; color: #ff5a1f; font-weight: 600; font-size: 8.5pt; display: block; margin-bottom: 1.5mm; }
.d-terms { margin-top: 4mm; font-size: 9pt; color: rgba(22,20,15,.7); white-space: pre-wrap; break-inside: avoid; }
.d-foot { position: absolute; left: 18mm; right: 18mm; bottom: 10mm; display: flex; justify-content: space-between; font-size: 7.5pt; color: rgba(22,20,15,.5); border-top: 1px solid rgba(22,20,15,.12); padding-top: 3mm; }
.d-contact { margin-top: 12mm; padding: 6mm; border-radius: 3mm; background: #111; color: #f2f0eb; display: flex; justify-content: space-between; align-items: center; gap: 6mm; break-inside: avoid; }
.d-contact b { font-size: 13pt; letter-spacing: -.02em; }
.d-contact span { font-size: 9pt; color: rgba(242,240,235,.65); display: block; margin-top: 1mm; }
.d-contact em { font-style: normal; color: #ff5a1f; font-weight: 600; }

@page { size: A4; margin: 0; }
@media print {
  html, body { background: #fff; }
  .side, .doc-bar, .toast { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .doc { box-shadow: none; width: auto; }
  .pg { width: 210mm; min-height: 297mm; break-after: page; }
  .pg + .pg { margin-top: 0; }
  .pg:last-child { break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
