/* Panel firmy – wygląd. Najpierw telefon (390 px), potem tablet (od 720 px) i komputer (od 1100 px).
   Kolory tylko przez zmienne. Ciemny motyw ma dwa bloki o tej samej treści: ustawienie systemu i ręczny
   przełącznik (data-theme). Test tests/test_pulpit.py pilnuje, żeby bloki były identyczne i kontrasty ≥ 4,5:1.
   Kolor marki (PANEL_ACCENT) nadpisuje --accent, --accent-text i --accent-ink w /brand.css. */
:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #111827; --muted: #5b6472; --line: #e5e7eb;
  --accent: #1d4ed8; --accent-text: #ffffff; --accent-ink: #1d4ed8;
  --good: #15803d; --bad: #b91c1c; --warn: #a54a08;
  --good-soft: #dcfce7; --bad-soft: #fee2e2; --warn-soft: #fef3c7; --on-status: #ffffff;
  --chip: #eef2ff; --bubble-in: #f1f5f9; --bubble-out: #dbeafe;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08); --shadow-pop: 0 8px 28px rgba(0, 0, 0, .2);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --card: #121a2e; --text: #e5e7eb; --muted: #9ca3af; --line: #24304a;
    --accent: #60a5fa; --accent-text: #0b1020; --accent-ink: #60a5fa;
    --good: #4ade80; --bad: #f87171; --warn: #fbbf24;
    --good-soft: #11301f; --bad-soft: #3d171b; --warn-soft: #35290b; --on-status: #0b1020;
    --chip: #1e293b; --bubble-in: #1e293b; --bubble-out: #1e3a5f;
    --shadow: none; --shadow-pop: 0 8px 28px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0b1020; --card: #121a2e; --text: #e5e7eb; --muted: #9ca3af; --line: #24304a;
    --accent: #60a5fa; --accent-text: #0b1020; --accent-ink: #60a5fa;
    --good: #4ade80; --bad: #f87171; --warn: #fbbf24;
    --good-soft: #11301f; --bad-soft: #3d171b; --warn-soft: #35290b; --on-status: #0b1020;
    --chip: #1e293b; --bubble-in: #1e293b; --bubble-out: #1e3a5f;
    --shadow: none; --shadow-pop: 0 8px 28px rgba(0, 0, 0, .6);
    color-scheme: dark;
}
/* Skala: tekst 13 / 15 / 17 / 20 / 28 px (12 px tylko znaczniki i liczniki), odstępy co 4 px,
   przyciski pod palec 44 px (na komputerze z myszką niższe). */
:root {
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 28px;
  --tap: 44px; --tap-sm: 40px; --nav-w: 216px; --top-h: 52px;
}
@media (pointer: fine) and (min-width: 720px) { :root { --tap: 36px; --tap-sm: 32px; } }

/* ---- podstawy ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: var(--fs-md)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
h1 { font-size: var(--fs-xl); margin: 4px 0 12px; }
h2 { font-size: var(--fs-md); margin: 0; }
p { margin: 0 0 8px; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic .thick { stroke-width: 3; }
.muted { color: var(--muted); font-size: var(--fs-sm); }
code { font: var(--fs-sm)/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--chip); padding: 0 4px; border-radius: 4px; }

button, .button { font: inherit; border: 0; border-radius: 10px; padding: 8px 14px; min-height: var(--tap); cursor: pointer;
  background: var(--accent); color: var(--accent-text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:disabled { opacity: .55; cursor: default; }
button.secondary, .button.secondary { background: var(--chip); color: var(--text); }
button.ghost { background: transparent; color: var(--muted); }
button.small { padding: 6px 10px; font-size: var(--fs-sm); min-height: var(--tap-sm); }
button.wide { width: 100%; margin-top: 8px; }
input, select, textarea { font: inherit; font-size: 16px; } /* 16 px: telefon nie powiększa strony po dotknięciu pola */
input, textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text);
  min-width: 0; min-height: var(--tap); }
input[type=checkbox] { min-height: 0; }
.badge { background: var(--warn); color: var(--on-status); border-radius: 6px; padding: 1px 6px; font-size: var(--fs-xs); font-weight: 600; margin-left: 6px; }

/* ---- nagłówek: nazwa, świeżość danych, menu ---- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px; min-height: var(--top-h);
  padding: 4px 8px 4px 16px; padding-top: max(4px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; white-space: nowrap; }
.sync { margin-left: auto; background: transparent; color: var(--muted); font-size: var(--fs-sm); padding: 6px 8px; min-width: 0; }
.sync #sync-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--good); }
.dot.stale { background: var(--warn); }
.dot.err { background: var(--bad); }
.menu { position: relative; }
.menu > summary { list-style: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; cursor: pointer; color: var(--muted); }
summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--chip); color: var(--text); }
.menu-box { position: absolute; right: 0; top: calc(100% + 6px); width: 248px; z-index: 20; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-pop); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.menu-box form { margin: 0; }
.menu-box > button, .menu-box form button { width: 100%; }
.menu-box .chips { margin: 0; flex-wrap: nowrap; }
.menu-box .chips .chip { flex: 1; padding-left: 8px; padding-right: 8px; }
.menu-label { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; background: var(--warn-soft);
  color: var(--text); border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.banner button { flex: none; white-space: nowrap; background: var(--card); }
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 12; margin: 0 auto; max-width: 480px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); font-size: var(--fs-sm); }
.toast button { color: inherit; text-decoration: underline; min-height: 36px; flex: none; }

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

/* ---- karty, kafelki, liczby ---- */
.card { background: var(--card); color: var(--text); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
  border: 1px solid var(--line); }
.card, .supplier { scroll-margin-top: calc(var(--top-h) + 12px); } /* przewijanie do karty nie chowa jej pod nagłówkiem */
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head h2 { display: inline-flex; align-items: center; gap: 6px; }
.card-head.plain { margin: 16px 0 8px; align-items: center; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; text-align: left; min-height: 0; cursor: default; }
.tile.link { cursor: pointer; }
.tile .label, .kpi .label, .stat .label { color: var(--muted); font-size: var(--fs-sm); }
.tile .value { font-size: var(--fs-xl); font-weight: 700; line-height: 1.2; }
.tile .sub, .kpi .sub, .stat .sub { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.tile.alert .value { color: var(--bad); }
.tiles.small .tile .value { font-size: var(--fs-lg); }

/* Cztery liczby na górze pulpitu: jeden pasek, kolor dopiero przy problemie (obok zawsze ikona i słowo). */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow); }
.kpi { background: var(--card); color: var(--text); border-radius: 0; padding: 12px; min-height: 96px; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: flex-start; gap: 2px; text-align: left; }
.kpi:focus-visible { outline-offset: -3px; }
.kpi .vrow, .stat .vrow { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.kpi .value, .stat .value { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.15; }
.kpi.pilne .value { color: var(--bad); }
.st { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: 700; padding: 1px 7px 1px 5px; border-radius: 999px;
  background: var(--chip); color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; vertical-align: 1px; }
.st .ic { width: 14px; height: 14px; stroke-width: 2.4; }
.st.pilne { background: var(--bad-soft); color: var(--bad); }
.st.uwaga { background: var(--warn-soft); color: var(--warn); }

/* Kafelek obrotu z wykresem 30 dni: linia w spokojnym szarym, kropka „dziś” w kolorze marki. */
button.card { justify-content: flex-start; }
.stat { width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 2px; text-align: left; }
.delta { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--warn); }
.spark { display: block; margin-top: 8px; }
.spark svg { display: block; width: 100%; height: 48px; }
.spark .line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--muted); opacity: .1; }
.spark .ring { fill: var(--card); }
.spark .dot { fill: var(--accent-ink); }
.spark-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-xs); }

/* ---- pulpit: tryb, zdanie dnia, sprawy ---- */
.mode-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.mode-bar .chips { margin-bottom: 0; }
.lead { margin: 0 0 12px; min-height: 44px; }
.notes { display: flex; flex-direction: column; }
.note { padding: 12px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.note:first-child { border-top: 0; padding-top: 4px; }
.note:last-child { padding-bottom: 4px; }
.note .ntext { overflow-wrap: anywhere; }
.nact { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nact .ic { width: 16px; height: 16px; }
.note.mini { flex-direction: row; align-items: center; justify-content: space-between; padding: 6px 0; }
.note.mini .ntext { flex: 1; min-width: 0; }
.note.mini .nact { flex: none; }
button.ntext.link { display: block; background: transparent; color: var(--text); text-align: left; padding: 4px 0; border-radius: 6px; min-height: var(--tap-sm); }
.note .why { display: block; color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.empty { color: var(--muted); padding: 16px; text-align: center; }
.empty.good { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--good); }
details.more { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
details.more > summary, details.urgent > summary, details.done-list > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm);
  min-height: var(--tap-sm); display: flex; align-items: center; gap: 6px; list-style: none; border-radius: 6px; }
details.more > summary::before, details.urgent > summary::before, details.done-list > summary::before { content: "▸"; width: 12px; flex: none; }
details[open].more > summary::before, details[open].urgent > summary::before, details[open].done-list > summary::before { content: "▾"; }
details.card.more { margin-top: 0; padding-top: 6px; padding-bottom: 6px; border-top: 1px solid var(--line); }
details.card.urgent { border-color: var(--bad); padding-top: 6px; padding-bottom: 6px; }
details.urgent > summary { color: var(--text); font-size: var(--fs-md); font-weight: 600; flex-wrap: wrap; }
details.done-list { margin-top: 12px; }
.idea .card-head { align-items: center; }
.idea .card-head .ic { color: var(--accent-ink); }
details.urgent > summary .ic { color: var(--bad); }
.idea-text { font-size: var(--fs-lg); font-weight: 600; margin: 4px 0 6px; overflow-wrap: anywhere; }
.idea .nact { margin-top: 12px; }

/* ---- wątki ---- */
.watki { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.watek-card { text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: 14px; padding: 12px; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 6px; }
.watek-card.has-alert { border-color: var(--bad); }
.watek-card .wname { font-weight: 700; display: flex; align-items: flex-start; gap: 8px; overflow-wrap: anywhere; }
.watek-card .wname .ic { color: var(--muted); margin-top: 1px; }
.watek-card .wopis { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; }
.watek-card .wmeta { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); border-radius: 6px; padding: 2px 6px; background: var(--chip);
  color: var(--text); margin-right: 4px; white-space: nowrap; vertical-align: 1px; }
.tag .ic { width: 13px; height: 13px; stroke-width: 2.4; }
.tag.red { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.tag.green { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.kind { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.wmeta .tag { margin-right: 0; }
.integr { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.integ { border-top: 1px solid var(--line); padding-top: 8px; }
.integ:first-child { border-top: 0; padding-top: 0; }
.integ .iname { font-weight: 600; margin-right: 6px; }

/* ---- listy, rozmowy, tabele ---- */
.view > h1 { font-size: var(--fs-xl); margin: 4px 0 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 200px; }
.toolbar .chips { margin-bottom: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chips.sub { margin-bottom: 12px; }
.chip { background: var(--chip); color: var(--text); border-radius: 999px; padding: 6px 14px; font-size: var(--fs-sm); min-height: var(--tap-sm); }
.chip.on { background: var(--accent); color: var(--accent-text); }
.chip .n { background: var(--card); color: var(--text); border-radius: 999px; padding: 0 6px; font-size: var(--fs-xs); font-weight: 600; }
.chip .n.hot { background: var(--bad); color: var(--on-status); }
.chip .n:empty { display: none; }
.list .item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; cursor: pointer; }
.list .item.static { cursor: default; }
.item .row { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.item .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.item .when { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.item .preview { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item.unread { border-left: 4px solid var(--accent-ink); }
.item .meta-row { display: flex; align-items: center; gap: 4px; margin-top: 4px; min-width: 0; }
.item .meta-row .tag { margin-right: 0; flex: none; }
.item .meta-row .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; margin-left: 2px; }
.newdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); margin-right: 6px; vertical-align: 1px; }
.thread .bubble { max-width: 85%; padding: 9px 12px; border-radius: 12px; margin: 6px 0; }
.thread .bubble .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.thread .in { background: var(--bubble-in); }
.thread .out { background: var(--bubble-out); margin-left: auto; }
.thread .meta { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 2px; }
.thread-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 180px; }
table.fit td.wrap { min-width: 0; overflow-wrap: anywhere; }
.cell-sub { display: block; }
td.empty { text-align: center; }

/* ---- wykres sprzedaży: cienkie słupki, jedna seria, liczby w tabeli obok ---- */
.chart { position: relative; display: flex; align-items: stretch; justify-content: space-between; gap: 2px; height: 172px; padding-top: 20px;
  border-bottom: 1px solid var(--line); }
.chart::before { content: ""; position: absolute; left: 0; right: 0; top: 20px; border-top: 1px solid var(--line); }
.chart .ymax { position: absolute; left: 0; top: 0; font-size: var(--fs-xs); color: var(--muted); }
.chart .col { position: relative; flex: 1; min-width: 0; display: flex; align-items: flex-end; justify-content: center; border-radius: 4px 4px 0 0; }
.chart .col.on { background: var(--chip); }
.chart .bar { width: 100%; max-width: 24px; background: var(--accent-ink); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .78; }
.chart .bar.today, .chart .col.on .bar { opacity: 1; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-xs); margin-top: 4px; }
/* wykres ze znakiem (zysk): słupki w górę i w dół od linii zera */
.chart.signed .col { align-items: stretch; border-radius: 4px; }
.chart.signed .bar { position: absolute; left: 0; right: 0; margin: 0 auto; min-height: 0; }
.chart.signed .bar.neg { border-radius: 0 0 4px 4px; }
.chart.signed .zero { position: absolute; left: 0; right: 0; border-top: 1px solid var(--muted); opacity: .55; pointer-events: none; }
.tag.new { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }
.tile .vrow { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.profit-list .porder { border-top: 1px solid var(--line); }
.profit-list .porder:first-child { border-top: 0; }
.profit-list summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px;
  align-items: baseline; padding: 10px 0; min-height: var(--tap); }
.profit-list summary::-webkit-details-marker { display: none; }
.profit-list .pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profit-list .pval { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.profit-list .pval.neg { color: var(--bad); }
.profit-list .pmeta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; color: var(--muted); font-size: var(--fs-sm); }
.profit-list .pmeta .tag { margin-right: 0; }
.breakdown { margin: 0 0 8px; }
.breakdown tr.sum td { font-weight: 700; border-bottom: 0; }

/* ---- zadania ---- */
.task-form { display: flex; gap: 8px; flex-wrap: wrap; }
.task-form input { flex: 1 1 220px; }
.task-form textarea { flex: 1 1 100%; }
.group h3 { font-size: var(--fs-sm); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 16px 0 8px; }
.task { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.task .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task .owner { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task.doing { border-left: 4px solid var(--warn); }
.task .st-btn { white-space: nowrap; flex: none; }
select.who { font-size: var(--fs-sm); padding: 2px 4px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.task .result { font-size: var(--fs-sm); margin-top: 4px; padding: 6px 8px; border-radius: 8px; background: var(--chip); white-space: pre-wrap; }
.task .hist { padding: 2px 0; min-height: 28px; }
.task .history { margin-top: 4px; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; font: var(--fs-sm)/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg); padding: 12px; border-radius: 8px; max-height: 60vh; overflow: auto; }
ul.rules { margin: 8px 0 0; padding-left: 18px; }
ul.rules li { margin: 4px 0; }

/* ---- zakupy ---- */
.bar-free { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.bar-free span { display: block; height: 100%; background: var(--good); }
.deadline { margin-top: 8px; font-weight: 600; display: flex; align-items: flex-start; gap: 6px; }
.deadline .ic { margin-top: 1px; }
.deadline.soon { color: var(--bad); }
.plist { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.pitem { display: flex; gap: 12px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 8px; }
.pitem input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
.pitem .pname { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.pitem .pprice { text-align: right; white-space: nowrap; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.pitem.ordered { opacity: .6; }
.order-btn { width: 100%; }
.lastcmd { margin-top: 8px; }
.flash { animation: flash 1.8s ease-out 1; }
@keyframes flash { 0%, 35% { box-shadow: 0 0 0 3px var(--accent-ink); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ---- gotowość do pracy (wątek IT) ---- */
.verdict { font-weight: 600; margin: 0 0 4px; }
.ready { display: flex; flex-direction: column; margin-bottom: 8px; }
.rrow { padding: 8px 0; border-top: 1px solid var(--line); }
.rrow .tag { margin-right: 8px; font-weight: 600; }
.rname { font-weight: 600; overflow-wrap: anywhere; }
.rrow .muted { overflow-wrap: anywhere; }
.how { font: var(--fs-sm)/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; margin-top: 2px; }

/* ---- dolne zakładki (telefon) z przyciskiem asystenta pośrodku ---- */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: var(--card); border-top: 1px solid var(--line); z-index: 7; padding-bottom: env(safe-area-inset-bottom); }
.tabs button { position: relative; background: transparent; color: var(--muted); border-radius: 0; padding: 8px 2px; font-size: var(--fs-xs);
  flex-direction: column; gap: 2px; min-height: 56px; }
.tabs button.on { color: var(--accent-ink); font-weight: 700; }
.tabs .ic { width: 22px; height: 22px; }
.count { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--bad); color: var(--on-status); border-radius: 999px; padding: 0 5px;
  font-size: var(--fs-xs); line-height: 17px; min-width: 17px; text-align: center; font-weight: 700; }
.count.calm { background: var(--chip); color: var(--text); font-weight: 600; }
.count:empty { display: none; }
.tabs .fab { align-self: center; justify-self: center; width: 54px; height: 54px; min-height: 54px; border-radius: 50%; padding: 0; margin-top: -20px;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }
.tabs .fab .ic { width: 24px; height: 24px; }
.tabs .fab .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- asystent ---- */
.sheet { position: fixed; inset: auto 0 0 0; top: 10vh; background: var(--card); z-index: 9;
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .25); display: flex; flex-direction: column;
  max-width: 760px; margin: 0 auto; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sheet-head .toggle { margin-left: auto; font-size: var(--fs-sm); color: var(--muted); display: flex; gap: 4px; align-items: center; }
.chat { flex: 1; overflow-y: auto; padding: 12px 16px; }
.chat .msg { max-width: 88%; width: fit-content; padding: 9px 12px; border-radius: 12px; margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat .user { background: var(--bubble-out); margin-left: auto; }
.chat .assistant { background: var(--bubble-in); }
.chat .msg.pending { color: var(--muted); font-style: italic; }
.examples { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 8px; }
.examples .chip { white-space: nowrap; flex: none; }
.chat-form { display: flex; gap: 8px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-form input { flex: 1; }
.mic { width: 46px; padding: 0; background: var(--chip); color: var(--text); flex: none; }
.mic.listening { background: var(--bad); color: var(--on-status); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* ---- logowanie ---- */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--muted); }
.error { color: var(--bad); margin: 0; }

/* ---- ładowanie: szkielety tylko przy pierwszym otwarciu, potem stare dane zostają do czasu nowych ---- */
.skel { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--line) 25%, var(--chip) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel.line { height: 12px; width: 100%; margin: 5px 0; }
.skel.line.short { width: 45%; }
.skel.big { height: 28px; width: 60%; margin: 5px 0; }
.skel.row { height: 44px; margin: 8px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel, .mic.listening, .flash { animation: none; }
}

/* ---- tablet ---- */
@media (min-width: 720px) {
  .kpis, .tiles, .watki { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- komputer: menu z boku, pulpit w trzech kolumnach (sprawy | liczby i wykres | wątki) ---- */
@media (min-width: 1100px) {
  body { padding-bottom: 0; }
  .top { padding-left: 24px; padding-right: 16px; }
  .banner { margin-left: var(--nav-w); padding-left: 24px; }
  main { max-width: none; margin: 0 0 0 var(--nav-w); padding: 16px 24px 32px; }
  main > .view { max-width: 1360px; margin: 0 auto; }
  .tabs { top: var(--top-h); right: auto; width: var(--nav-w); display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 12px; border-top: 0; border-right: 1px solid var(--line); }
  .tabs button { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 8px 12px; font-size: var(--fs-md); border-radius: 10px;
    min-height: 40px; }
  .tabs button.on { background: var(--chip); }
  .tabs .count { position: static; margin-left: auto; }
  .tabs .fab { order: 9; align-self: stretch; width: auto; height: auto; min-height: 44px; margin-top: 12px; border-radius: 10px; padding: 8px 12px;
    justify-content: center; box-shadow: none; }
  .tabs .fab .lbl { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  #view-pulpit.active { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, .85fr);
    grid-template-areas: "mode mode mode" "lead lead lead" "kpi kpi kpi" "notes side watki"; column-gap: 16px; align-items: start; }
  #p-mode { grid-area: mode; }
  #p-lead { grid-area: lead; min-height: 0; font-size: var(--fs-lg); }
  #p-kpi { grid-area: kpi; margin-bottom: 16px; }
  #p-notes { grid-area: notes; }
  #p-side { grid-area: side; }
  #p-watki { grid-area: watki; }
  #p-watki .card-head.plain { margin-top: 0; min-height: var(--tap-sm); }
  #p-watki .watki { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  #p-watki .watek-card .wopis { -webkit-line-clamp: 2; }
  .sheet { top: var(--top-h); left: auto; right: 0; bottom: 0; width: 420px; max-width: none; margin: 0; border-radius: 0;
    border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); }
  .toast { left: calc(var(--nav-w) + 12px); bottom: 20px; }
}
/* na co idzie sprzedaż: koszt i zysk jako część sprzedaży netto */
.split .srow { display: grid; grid-template-columns: minmax(0, 1fr) auto 4.6em; gap: 2px 12px; align-items: baseline; padding: 7px 0; }
.split .sname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split .sval, .split .spct { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.split .spct { color: var(--muted); }
.split .sbar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.split .sbar i { display: block; height: 100%; border-radius: 4px; background: var(--muted); opacity: .6; }
.split .srow.profit { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-weight: 700; }
.split .srow.profit .sbar i { background: var(--accent); opacity: 1; }
.split .srow.profit.neg .sbar i { background: var(--bad); }
.split .srow.profit.neg .sval { color: var(--bad); }
/* dopisanie kosztu do zamówienia */
.cost-form { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; padding: 4px 0 12px; }
.cost-form label { display: grid; gap: 3px; font-size: var(--fs-sm); color: var(--muted); }
.cost-form select, .cost-form input { min-height: var(--tap); padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); }
.cost-form input { width: 8.5em; }
.cost-form .hint { flex-basis: 100%; }
.breakdown button.small { display: block; margin: 4px 0 0 -10px; text-decoration: underline; }
/* termin przy reklamacji: opis może się zawijać, znacznik zostaje w całości */
.item .meta-row.due { flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.item .meta-row.due .muted { white-space: normal; overflow: visible; margin-left: 0; }
/* pomysł dnia: efekt, dowody i decyzja */
.idea-effect { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.idea-effect .tag { margin-right: 0; }
.idea-facts { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: var(--fs-sm); }
.idea-facts li { margin: 2px 0; }
.idea .nact.idea-more { margin-top: 2px; }
/* pierwszy krok przy rozmowie */
.first-step { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.first-step .fs-head { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.first-step .fs-head .tag { margin-right: 0; }
.first-step ol { margin: 8px 0 0; padding-left: 20px; }
.first-step li { margin: 4px 0; }
.first-step .draft { margin-top: 10px; padding: 10px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.first-step .draft .muted { display: flex; gap: 6px; align-items: center; font-size: var(--fs-sm); }
.first-step .draft .ic { width: 16px; height: 16px; flex: none; }
.first-step .draft-text { margin: 6px 0 10px; overflow-wrap: anywhere; }
ol.steps { margin: 6px 0 4px; padding-left: 20px; color: var(--muted); font-size: var(--fs-sm); }
ol.steps li { margin: 3px 0; }
/* tydzień do tygodnia: kanał jako blok, liczby w wierszach – czytelne także na telefonie */
.week-list .wk { padding: 10px 0; border-top: 1px solid var(--line); }
.week-list .wk:first-child { border-top: 0; padding-top: 2px; }
.week-list .wk-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-bottom: 4px; }
.week-list .wk-head .tag { margin-right: 0; }
.week-list .wk-row { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) 4.5em; gap: 8px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.week-list .wk-row > span:first-child { color: var(--muted); }
.week-list .wk-row .num { text-align: right; }
.week-list .wk-delta { font-weight: 600; }
@media (max-width: 520px) { .week-list .wk-row .num .muted { display: block; } }
