/* Triggy Hub — nowy wygląd (wersja równoległa do portalu „/”, strona /nowy). */
:root {
  --bg: #f6f5f2; --panel: #ffffff; --side: #fbfaf8; --line: #e8e5df; --line-2: #f0eee9;
  --ink: #1c1a17; --ink-2: #4a453e; --muted: #8a837a; --faint: #b4ada3;
  --brand: #e2551f; --brand-soft: #fdeee7;
  --green: #067647; --green-soft: #e7f4ec; --amber: #b86e00; --amber-viz: #e29513; --amber-soft: #fdf3e0;
  --red: #d92d20; --red-soft: #fdecea; --blue: #1a56b8; --blue-soft: #e8effb; --track: #eceae6;
  --r: 10px; --r-sm: 7px;
  --shadow: 0 1px 2px rgba(28, 26, 23, .04), 0 1px 1px rgba(28, 26, 23, .03);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 13.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.hide { display: none !important; }

/* ---------- układ ---------- */
.frame { height: 100vh; }
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100%; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; scrollbar-width: thin; }
.nav-label { font-size: 10.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 14px 8px 5px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: var(--r-sm); color: var(--ink-2); cursor: pointer; user-select: none; }
.nav-item:hover { background: #f1efeb; color: var(--ink); }
.nav-item.active { background: #fff; color: var(--ink); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; flex: none; opacity: .85; }
.nav-item.active svg { stroke: var(--brand); opacity: 1; }
.nav-item span:not(.dot-nav) { flex: 1; }
.dot-nav { width: 16px; height: 16px; flex: none; position: relative; }
.dot-nav::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--faint); }
.nav-item.active .dot-nav::after { background: var(--brand); }
.pill { font-style: normal; font-size: 11px; font-weight: 600; min-width: 20px; text-align: center; padding: 0 6px; border-radius: 20px; background: #ebe8e3; color: var(--ink-2); line-height: 18px; }
.pill.warn { background: var(--red-soft); color: var(--red); }
.side-foot { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2b2723; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 650; flex: none; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11.5px; color: var(--muted); }
.foot-actions { display: flex; gap: 6px; }
.mini { border: 1px solid var(--line); background: #fff; border-radius: var(--r-sm); padding: 4px 9px; font-size: 12px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.mini:hover { border-color: #d6d1c9; color: var(--ink); }
.mini.icon { padding: 4px 6px; }
.mini svg, .ghost svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 5; }
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 10px; height: 34px; flex: 1; max-width: 520px; }
.search:focus-within { border-color: #cfc8be; box-shadow: 0 0 0 3px rgba(226, 85, 31, .08); }
.search svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; flex: none; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; height: 100%; }
.search kbd { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; background: var(--side); }
.search.inline { max-width: 340px; height: 32px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ghost { border: 1px solid transparent; background: transparent; border-radius: var(--r-sm); height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); position: relative; }
.ghost:hover { background: #fff; border-color: var(--line); color: var(--ink); }
.ghost.icon { width: 34px; padding: 0; justify-content: center; }
.badge-dot { position: absolute; top: 3px; right: 3px; font-style: normal; font-size: 9.5px; font-weight: 700; background: var(--brand); color: #fff; border-radius: 10px; min-width: 15px; height: 15px; display: grid; place-items: center; padding: 0 3px; }
.mode-badge { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.mode-badge.demo { background: var(--amber-soft); color: var(--amber); }
.mode-badge.live { background: var(--green-soft); color: var(--green); }

.content { flex: 1; overflow-y: auto; padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 16px; }
/* Karty z overflow:hidden (.card.flush) mają min-height 0 — bez tego kolumna flex ściska je do zera, gdy treść jest dłuższa niż ekran. */
.content > * { flex-shrink: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 21px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h1.mono { font-size: 19px; }
h2 { font-size: 14px; font-weight: 620; margin: 0; letter-spacing: -.005em; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.sub b { color: var(--ink-2); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back { align-self: flex-start; border: 0; background: none; color: var(--muted); padding: 0; font-size: 12.5px; }
.back:hover { color: var(--ink); }

/* ---------- przyciski i drobne elementy ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: var(--r-sm); height: 32px; padding: 0 12px; font-weight: 550; font-size: 13px; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-shadow: var(--shadow); white-space: nowrap; }
.btn:hover { border-color: #d3cdc4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #cf4a17; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.link { border: 0; background: none; color: var(--brand); font-weight: 550; padding: 0; font-size: 12.5px; }
.link:hover { text-decoration: underline; }
.seg { display: inline-flex; background: #ebe8e3; border-radius: var(--r-sm); padding: 2px; }
.seg-btn { border: 0; background: transparent; padding: 4px 10px; border-radius: 5px; font-size: 12.5px; color: var(--ink-2); }
.seg-btn.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.tabs { display: inline-flex; gap: 2px; background: #f1efeb; border-radius: var(--r-sm); padding: 2px; }
.tab { border: 0; background: transparent; padding: 3px 9px; border-radius: 5px; font-size: 12px; color: var(--muted); }
.tab.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 3px 11px; font-size: 12.5px; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.chip i { font-style: normal; color: var(--muted); font-size: 11.5px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on i { color: #cfc9c0; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 20px; background: #efece7; color: var(--ink-2); white-space: nowrap; }
.tag.danger { background: var(--red-soft); color: var(--red); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 550; color: var(--ink-2); white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.st.blue { color: var(--blue); } .st.blue::before { background: var(--blue); }
.st.amber { color: var(--amber); } .st.amber::before { background: var(--amber-viz); }
.st.red { color: var(--red); } .st.red::before { background: var(--red); }
.st.green { color: var(--green); } .st.green::before { background: var(--green); }
.st.big { font-size: 13px; padding: 5px 12px; border-radius: 20px; background: #fff; border: 1px solid var(--line); }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: #f1efeb; border-radius: 20px; padding: 0 7px; margin-left: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.blue { background: var(--blue); } .dot.amber { background: var(--amber-viz); } .dot.red { background: var(--red); } .dot.green { background: var(--green); }
.red-t { color: var(--red); font-weight: 550; }
.warn-t { color: var(--amber); font-weight: 550; }
.row-act { border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 12px; padding: 2px 9px; color: var(--ink-2); }
.row-act:hover { color: var(--ink); border-color: #d3cdc4; }
.kebab { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 5px; }
.kebab:hover { background: #f1efeb; color: var(--ink); }

/* ---------- karty ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { flex: 1; display: flex; align-items: center; }
.card-head > .viz { margin-left: auto; }
.card-foot { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }

/* ---------- pulpit ---------- */
.attention { display: flex; align-items: stretch; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; box-shadow: var(--shadow); flex-wrap: wrap; }
.att-lead { display: flex; align-items: center; gap: 8px; padding: 0 10px; font-weight: 620; font-size: 13px; }
.att-lead span { background: var(--brand); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.att-item { flex: 1; min-width: 200px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 10px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--side); border: 1px solid var(--line-2); cursor: pointer; }
.att-item:hover { border-color: var(--line); background: #fff; }
.att-item b { font-weight: 600; font-size: 13px; }
.att-item span { grid-row: 2; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-item em { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; color: var(--brand); font-weight: 600; font-size: 12px; }
.att-item.danger { background: var(--red-soft); border-color: #f8d4cf; }
.att-item.danger b { color: var(--red); }
.att-item.ok { background: var(--green-soft); border-color: #cde8d8; }
.kpi-row { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; gap: 16px; }
.kpi-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi.main { background: linear-gradient(180deg, #fff 0%, #fffaf7 100%); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 550; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.15; }
.kpi-value.sm { font-size: 20px; }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-note { font-size: 12px; color: var(--muted); }
.delta { font-size: 12px; font-weight: 650; border-radius: 20px; padding: 1px 7px; }
.delta.up { background: var(--green-soft); color: var(--green); }
.delta.down { background: var(--red-soft); color: var(--red); }
.delta.flat { background: #efece7; color: var(--muted); }
.viz-legend { display: flex; gap: 10px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.viz-legend span { display: inline-flex; align-items: center; gap: 4px; }
.viz-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin: -4px 0 8px; }
.lg-bar { width: 10px; height: 10px; border-radius: 2px; background: #f3b59b; display: inline-block; }
.lg-line { width: 14px; height: 2px; background: var(--ink-2); display: inline-block; margin-left: 10px; }
.chart { display: grid; grid-template-columns: 54px 1fr; height: 220px; }
.ylab { display: flex; flex-direction: column; justify-content: space-between; font-size: 10.5px; color: var(--faint); padding: 0 8px 20px 0; text-align: right; }
.chart .bars { position: relative; display: flex; align-items: flex-end; gap: 6px; padding-bottom: 20px; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0, transparent calc(20% - 1px), var(--line-2) calc(20% - 1px), var(--line-2) 20%); background-size: 100% calc(100% - 20px); background-repeat: no-repeat; }
.chart .bar { flex: 1; background: #f3b59b; border-radius: 4px 4px 0 0; position: relative; min-height: 2px; transition: background .15s; }
.chart .bar:hover { background: #ec8c63; }
.chart .bar.cur { background: var(--brand); }
.chart .bar.neg { background: #f2b8b2; }
.chart .bar i { position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart .bar[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; padding: 4px 7px; border-radius: 5px; white-space: pre; z-index: 3; pointer-events: none; }
.overlay { position: absolute; inset: 0 0 20px 0; width: 100%; height: calc(100% - 20px); pointer-events: none; overflow: visible; }
.overlay polyline { fill: none; stroke: var(--ink-2); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-dasharray: 4 3; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .num { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.mini-list .nm { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .amt { font-family: var(--mono); font-size: 12.5px; }
.list-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); font-size: 12px; }

/* ---------- tabele ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--side); }
.card:not(.flush) .tbl th { background: transparent; padding-left: 0; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.card:not(.flush) .tbl td { padding-left: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl.rows tbody tr:hover { background: #fbfaf8; }
.tbl tr[data-go], .tbl tr[data-id], .tbl tr.click { cursor: pointer; }
.tbl tr.sel { background: var(--brand-soft) !important; }
.tbl td b { font-weight: 600; display: block; }
.tbl .sec { display: block; font-size: 12px; color: var(--muted); }
.tbl .w28 { width: 28px; } .tbl .w32 { width: 32px; }
.tbl .num-col { white-space: nowrap; }
.tbl input[type=checkbox] { accent-color: var(--brand); }
.tbl-empty { padding: 28px; text-align: center; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar.tight { gap: 8px; }
.bulkbar { display: flex; align-items: center; gap: 10px; padding: 0 4px; font-size: 12.5px; }
.bulkbar .sep { width: 1px; height: 14px; background: var(--line); }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.mini-stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; box-shadow: var(--shadow); }
.mini-stat span { font-size: 12px; color: var(--muted); }
.mini-stat b { grid-row: 2; font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.mini-stat .viz { grid-row: 1 / span 2; grid-column: 2; }
.mini-stat.click { cursor: pointer; }
.mini-stat.click:hover { border-color: #d3cdc4; }

/* ---------- poczta ---------- */
.mail { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 260px); overflow-y: auto; }
.mail li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line-2); cursor: pointer; }
.mail li:hover { background: #fbfaf8; }
.mail li.sel { background: var(--brand-soft); }
.mail li > span.unread { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; }
.mail li.unread > span.unread { background: var(--brand); }
.mail li b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail li.unread b { font-weight: 650; }
.mail li p { margin: 1px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail li div { min-width: 0; }
.mail-meta { font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }
.mail-meta em { font-style: normal; font-size: 10.5px; background: #f1efeb; border-radius: 4px; padding: 0 5px; }
.mail-head { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }
.mail-body { padding: 12px 0; color: var(--ink-2); line-height: 1.6; }
.mail-body p { margin: 0 0 8px; }
.mail-msg { border-bottom: 1px solid var(--line-2); padding: 12px 0; }
.mail-msg:last-child { border-bottom: 0; }
.mail-msg header { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.mail-msg pre { white-space: pre-wrap; word-break: break-word; font: 13px/1.55 var(--font); color: var(--ink-2); margin: 8px 0 0; max-height: 420px; overflow: auto; }
.attach { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--side); margin-top: 6px; font-size: 12.5px; }
.attach .mono { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- szczegóły ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.detail-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rail { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; }
.rail-group { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.rail-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.hist { list-style: none; margin: 0; padding: 0; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.hist li { display: flex; flex-direction: column; }
.hist li span { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; margin: 0; }
.meta dt { font-size: 11.5px; color: var(--muted); }
.meta dd { margin: 1px 0 0; font-weight: 550; overflow-wrap: anywhere; }
.sum { display: flex; justify-content: flex-end; gap: 16px; align-items: baseline; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
.sum span { color: var(--muted); font-size: 12.5px; }
.sum b { font-size: 16px; }
.problems { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.problems li { background: var(--amber-soft); color: #7a4a00; border-radius: var(--r-sm); padding: 6px 10px; font-size: 12.5px; }

/* ---------- KSeF ---------- */
.ksef { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.ksef-list { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.ksef-prev { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; position: sticky; top: 0; }
.prev-bar { display: flex; justify-content: space-between; align-items: center; }
.paper { background: #fdfcfa; border: 1px solid var(--line); border-radius: 6px; padding: 18px; box-shadow: inset 0 0 0 4px #fff; display: flex; flex-direction: column; gap: 10px; }
.paper-h { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.paper-h span { color: var(--brand); }
.paper-num { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.paper-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 12.5px; }
.paper-grid small { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.paper-sum { display: flex; justify-content: space-between; border-top: 1px dashed var(--line); padding-top: 8px; font-size: 12.5px; }
.prev-foot { display: flex; gap: 8px; }

/* ---------- finanse ---------- */
.bucket-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.bucket { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.bucket span { font-size: 12px; color: var(--muted); }
.bucket b { font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); margin-top: 6px; }
.conf { display: flex; align-items: center; gap: 8px; }
.conf .viz { width: 80px; }
.conf span { font-size: 12px; color: var(--muted); }
.progress { display: flex; align-items: center; gap: 12px; }
.progress .viz { flex: 1; }
.sugg { display: grid; grid-template-columns: 60px 1fr 36px; align-items: center; gap: 8px; font-size: 12.5px; }
.sugg small { color: var(--muted); text-align: right; }
.funnel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.funnel-step { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.funnel-step span { font-size: 12px; color: var(--muted); }
.funnel-step b { font-size: 20px; font-weight: 650; }
.code { background: #1f1c19; color: #f3ede5; border-radius: var(--r-sm); padding: 12px 14px; font: 12px/1.6 var(--mono); overflow-x: auto; margin: 0; }
.run-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12.5px; }
.row-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.row-line:last-child { border-bottom: 0; }
.row-line b { font-weight: 600; }
.role { display: grid; grid-template-columns: 110px 40px 1fr; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.role b { text-align: right; }
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 58px auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.log li:last-child { border-bottom: 0; }
.log li .det { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- asystent ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 460px; }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: calc(100vh - 300px); }
.bubble { max-width: 82%; padding: 10px 13px; border-radius: 12px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--side); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.bot .viz { margin: 8px 0 2px; }
.bubble.err { border-color: #f8d4cf; background: var(--red-soft); color: var(--red); }
.bubble small { display: block; margin-top: 4px; font-size: 11px; }
.composer { display: flex; gap: 8px; border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: auto; }
.composer input, .composer textarea { flex: 1; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; outline: 0; resize: none; }
.composer input:focus, .composer textarea:focus { border-color: #cfc8be; }
.prop { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.prop span { font-size: 12px; color: var(--muted); }
.prop-act { display: flex; gap: 6px; }
.opt { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.opt span { font-size: 12px; color: var(--muted); }
.opt.on { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- konto, formularze ---------- */
.tg { position: relative; width: 34px; height: 20px; display: inline-block; }
.tg input { opacity: 0; width: 0; height: 0; position: absolute; }
.tg i { position: absolute; inset: 0; background: #d8d3cb; border-radius: 20px; transition: background .15s; cursor: pointer; }
.tg i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.tg input:checked + i { background: var(--brand); }
.tg input:checked + i::after { transform: translateX(14px); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form input { border: 1px solid var(--line); border-radius: var(--r-sm); height: 34px; padding: 0 10px; outline: 0; color: var(--ink); background: #fff; }
.form input:focus { border-color: #cfc8be; box-shadow: 0 0 0 3px rgba(226, 85, 31, .08); }
.msg { font-size: 12.5px; padding: 7px 10px; border-radius: var(--r-sm); }
.msg.err { background: var(--red-soft); color: var(--red); }
.msg.ok { background: var(--green-soft); color: var(--green); }

/* ---------- stany: ładowanie, błąd, demo ---------- */
.notice { display: flex; align-items: center; gap: 10px; background: var(--amber-soft); border: 1px solid #f3dcae; color: #7a4a00; border-radius: var(--r); padding: 9px 14px; font-size: 12.5px; }
.notice.info { background: var(--blue-soft); border-color: #cfdcf4; color: #173f80; }
.notice .link { margin-left: auto; }
.loading { color: var(--muted); padding: 28px; text-align: center; font-size: 12.5px; }
.loading::before { content: ""; display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; margin-right: 8px; vertical-align: -2px; animation: obrot .8s linear infinite; }
@keyframes obrot { to { transform: rotate(360deg); } }
.err-card { background: var(--red-soft); border: 1px solid #f8d4cf; color: var(--red); border-radius: var(--r); padding: 14px 16px; }

.overlay-login { position: fixed; inset: 0; background: rgba(28, 26, 23, .45); display: grid; place-items: center; z-index: 50; }
.login-card { width: 340px; background: #fff; border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .18); display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { padding: 0; }

/* ---------- wizualizacje (viz.js) ---------- */
.viz { position: relative; }
.viz svg { overflow: visible; }
.viz.donut.sm { width: 56px; height: 56px; }
.viz.donut.xs { width: 34px; height: 34px; }
.viz.donut:not(.sm):not(.xs) { width: 72px; height: 72px; }
.viz.gauge { width: 100%; max-width: 180px; }
.viz.gauge.xs { width: 56px; }
.viz.aging, .viz.bar-single { width: 100%; }
.mini-stat .viz.aging { width: 70px; }
.mini-stat .viz.spark, .mini-stat .viz.bars { width: 80px; }
.viz.spark, .viz.bars, .viz.line { width: 100%; }
.viz.heat { width: 100%; }
.viz-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 5px; white-space: nowrap; transform: translate(-50%, -120%); z-index: 4; }

@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .split, .detail, .ksef { grid-template-columns: 1fr; }
  .bucket-row, .funnel, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 16px; }
}
