/* =====================================================================
   PR Pulse — dashboard. Tokeny: jasny (domyślny) + ciemny.
   ===================================================================== */
:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-3: #f1f1ed;
  --line: rgba(11, 11, 11, 0.08);
  --line-2: rgba(11, 11, 11, 0.14);
  --ink: #141413;
  --ink-2: #52514e;
  --ink-3: #85837d;
  --grid: #ebeae5;
  --axis: #c3c2b7;
  --hover: rgba(11, 11, 11, 0.04);
  --press: rgba(11, 11, 11, 0.07);
  --shadow-1: 0 1px 2px rgba(20, 20, 18, 0.04), 0 0 0 1px rgba(20, 20, 18, 0.02);
  --shadow-2: 0 10px 30px -12px rgba(20, 20, 18, 0.18), 0 2px 6px rgba(20, 20, 18, 0.05);
  --shadow-3: 0 24px 60px -20px rgba(20, 20, 18, 0.30), 0 4px 14px rgba(20, 20, 18, 0.08);

  /* seria danych (paleta zwalidowana; kolejność stała) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;

  /* statusy (zarezerwowane) */
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b; --info: #2a78d6;
  --good-ink: #0b6b0b; --warn-ink: #8a5800; --crit-ink: #b42323; --info-ink: #1c5cab;
  --good-bg: rgba(12, 163, 12, 0.09); --warn-bg: rgba(250, 178, 25, 0.14); --crit-bg: rgba(208, 59, 59, 0.09); --info-bg: rgba(42, 120, 214, 0.09);

  --brand: #6d5ef5;
  --brand-soft: color-mix(in oklab, var(--brand) 10%, transparent);
  --brand-softer: color-mix(in oklab, var(--brand) 5%, transparent);
  --brand-line: color-mix(in oklab, var(--brand) 32%, transparent);
  --brand-ink: color-mix(in oklab, var(--brand) 78%, #000);
  --focus: color-mix(in oklab, var(--brand) 70%, #2a78d6);

  --r-xs: 6px; --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
  --sb-w: 268px;
  --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0e0e0d; --surface: #1a1a19; --surface-2: #1f1f1e; --surface-3: #262624;
    --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.14);
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8d86;
    --grid: #2c2c2a; --axis: #3d3d3a; --hover: rgba(255, 255, 255, 0.05); --press: rgba(255, 255, 255, 0.08);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow-2: 0 12px 32px -12px rgba(0, 0, 0, 0.6); --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --good-ink: #3fc63f; --warn-ink: #fab219; --crit-ink: #f07272; --info-ink: #6da7ec;
    --good-bg: rgba(12, 163, 12, 0.14); --warn-bg: rgba(250, 178, 25, 0.13); --crit-bg: rgba(208, 59, 59, 0.16); --info-bg: rgba(57, 135, 229, 0.15);
    --brand-ink: color-mix(in oklab, var(--brand) 70%, #fff);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e0e0d; --surface: #1a1a19; --surface-2: #1f1f1e; --surface-3: #262624;
  --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.14);
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8d86;
  --grid: #2c2c2a; --axis: #3d3d3a; --hover: rgba(255, 255, 255, 0.05); --press: rgba(255, 255, 255, 0.08);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow-2: 0 12px 32px -12px rgba(0, 0, 0, 0.6); --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --good-ink: #3fc63f; --warn-ink: #fab219; --crit-ink: #f07272; --info-ink: #6da7ec;
  --good-bg: rgba(12, 163, 12, 0.14); --warn-bg: rgba(250, 178, 25, 0.13); --crit-bg: rgba(208, 59, 59, 0.16); --info-bg: rgba(57, 135, 229, 0.15);
  --brand-ink: color-mix(in oklab, var(--brand) 70%, #fff);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 190px; }
body {
  margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden;
}
svg { width: 18px; height: 18px; flex: none; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 8px; text-decoration: none; }
.skip-link:focus { top: 12px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; outline: none; }
.content { padding: 28px 36px 120px; max-width: 1480px; margin: 0 auto; }

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 20px 16px 16px; border-right: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; z-index: 40;
}
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 18px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; font-size: 16.5px; letter-spacing: -0.01em; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--ink); color: var(--surface); }
.logo-mark svg { width: 19px; height: 19px; }
.icon-btn.sb-close { display: none; }
.sb-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 4px 10px 6px; }

.client-switch { position: relative; margin-bottom: 18px; }
.client-current {
  width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 10px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.client-current:hover { border-color: var(--line-2); }
.client-current[aria-expanded="true"] { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  font-weight: 650; font-size: 13px; color: #fff; letter-spacing: .02em; background: var(--av, var(--brand));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 11.5px; }
.cc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 4px 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.cc-meta > span:first-child { flex-basis: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-chev { color: var(--ink-3); width: 16px; height: 16px; transition: transform .2s var(--ease); }
.client-current[aria-expanded="true"] .cc-chev { transform: rotate(180deg); }
.client-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-3); padding: 6px;
  animation: pop .16s var(--ease);
}
.client-opt { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none; border-radius: 9px; text-align: left; }
.client-opt:hover, .client-opt:focus-visible { background: var(--hover); }
.client-opt[aria-selected="true"] { background: var(--brand-softer); }
.client-opt .co-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.client-opt .co-name { font-weight: 560; display: flex; gap: 6px; align-items: center; }
.client-opt .co-ind { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-opt .co-check { color: var(--brand-ink); width: 16px; height: 16px; }

.pill { display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.pill-demo { background: var(--warn-bg); color: var(--warn-ink); }
.pill-src { background: var(--surface-3); color: var(--ink-2); letter-spacing: .02em; text-transform: none; font-weight: 560; }
.pill-src.excel { background: rgba(0, 131, 0, .1); color: var(--good-ink); }
.pill-src.imm { background: var(--info-bg); color: var(--info-ink); }

.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; text-decoration: none;
  color: var(--ink-2); font-weight: 520; position: relative; transition: background .15s, color .15s;
}
.nav-link svg { color: var(--ink-3); transition: color .15s; }
.nav-link:hover { background: var(--hover); color: var(--ink); }
.nav-link.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.nav-link.active svg { color: var(--brand); }
.nav-link.active::before { content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 600; display: grid; place-items: center; background: var(--crit-bg); color: var(--crit-ink); }

.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 18px; }
.mode-card { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.mode-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-top: 6px; flex: none; }
.mode-card.server .mode-dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.mode-card.offline .mode-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.mode-title { font-weight: 600; font-size: 13px; }
.mode-sub { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.theme-toggle { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; border: 0; background: none; color: var(--ink-2); font-weight: 520; }
.theme-toggle:hover { background: var(--hover); color: var(--ink); }
.theme-toggle .t-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .t-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .t-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .t-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .t-moon { display: none; }
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; padding: 14px 36px 12px;
  background: color-mix(in oklab, var(--page) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, var(--brand), color-mix(in oklab, var(--brand) 0%, transparent) 70%); opacity: .8; }
.tb-row { display: flex; align-items: center; gap: 12px; max-width: 1408px; margin: 0 auto; }
.tb-row1 { margin-bottom: 12px; }
.tb-row2 { margin-bottom: 10px; }
.tb-title { min-width: 0; flex: 1; }
.tb-title h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tb-sub .dot-sep::before { content: "·"; margin-right: 8px; }
@media (max-width: 760px) { .tb-sub { gap: 0 10px; } .tb-sub .dot-sep::before { display: none; } }
.tb-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn.menu-btn { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid transparent; font-weight: 560; font-size: 13.5px; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .1s, box-shadow .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover:not(:disabled) { background: color-mix(in oklab, var(--ink) 86%, var(--brand)); }
.btn-brand { background: var(--brand); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 4px 14px -6px var(--brand); }
.btn-brand:hover:not(:disabled) { background: color-mix(in oklab, var(--brand) 88%, #000); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); box-shadow: var(--shadow-1); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-3); }
.btn-ghost { background: none; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-sm svg { width: 14px; height: 14px; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; border: 0; background: none; color: var(--ink-2); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.tip-wrap { display: inline-flex; }

/* period */
.period { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--line); gap: 2px; }
.seg button { height: 28px; padding: 0 12px; border-radius: 7px; border: 0; background: none; font-size: 13px; font-weight: 540; color: var(--ink-2); white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.months { display: inline-flex; gap: 3px; flex-wrap: nowrap; }
.mchip { min-width: 34px; height: 28px; padding: 0 7px; border-radius: 7px; border: 1px solid transparent; background: none; font-size: 12.5px; font-weight: 560; color: var(--ink-2); letter-spacing: .02em; transition: all .15s; }
.mchip:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.mchip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-ink); }
.mchip:disabled { color: var(--ink-3); opacity: .45; cursor: default; }
.period-label { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

/* filters */
.tb-row3 { gap: 8px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { position: relative; }
.fchip > button {
  height: 30px; display: inline-flex; align-items: center; gap: 6px; padding: 0 9px 0 11px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 12.5px; font-weight: 540; color: var(--ink-2); white-space: nowrap; transition: all .15s;
}
.fchip > button:hover { border-color: var(--ink-3); color: var(--ink); }
.fchip > button svg { width: 14px; height: 14px; color: var(--ink-3); }
.fchip.on > button { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-ink); }
.fchip.on > button svg { color: var(--brand-ink); }
.fchip .fcount { min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 650; display: grid; place-items: center; }
.pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; width: 300px; max-height: min(440px, 70vh); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-3); animation: pop .16s var(--ease); overflow: hidden;
}
.pop.wide { width: 380px; }
.pop-search { padding: 8px; border-bottom: 1px solid var(--line); }
.pop-search input { width: 100%; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 0 10px; outline: none; }
.pop-search input:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.pop-list { overflow-y: auto; padding: 6px; }
.pop-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; background: none; border-radius: 7px; text-align: left; font-size: 13px; }
.pop-opt:hover, .pop-opt:focus-visible { background: var(--hover); }
.pop-opt .box { width: 16px; height: 16px; border-radius: 4.5px; border: 1.5px solid var(--line-2); display: grid; place-items: center; flex: none; transition: all .12s; }
.pop-opt .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.pop-opt[aria-checked="true"] .box { background: var(--brand); border-color: var(--brand); }
.pop-opt[aria-checked="true"] .box svg { opacity: 1; }
.pop-opt .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-opt .lbl small { display: block; color: var(--ink-3); font-size: 11.5px; }
.pop-opt .cnt { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.pop-opt .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.pop-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.pop-foot button { border: 0; background: none; color: var(--ink-2); font-weight: 560; font-size: 12.5px; padding: 4px 6px; border-radius: 6px; }
.pop-foot button:hover { background: var(--hover); color: var(--ink); }
.pop-empty { padding: 18px; text-align: center; color: var(--ink-3); font-size: 13px; }

.search { position: relative; display: flex; align-items: center; margin-left: auto; }
.search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--ink-3); pointer-events: none; }
.search input { height: 30px; width: 230px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 12px 0 31px; outline: none; font-size: 13px; transition: border-color .15s, box-shadow .15s, width .2s var(--ease); }
.search input:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); width: 280px; }
.active-filters { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); width: 100%; }
.active-filters .af-count { font-weight: 600; color: var(--ink); }
.linkish { border: 0; background: none; padding: 2px 4px; color: var(--brand-ink); font-weight: 560; border-radius: 5px; text-decoration: underline; text-decoration-color: var(--brand-line); text-underline-offset: 3px; }
.linkish:hover { text-decoration-color: currentColor; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 9px; border-radius: 999px; background: var(--surface-3); font-size: 12px; color: var(--ink-2); max-width: 260px; }
.tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag button { width: 18px; height: 18px; border: 0; border-radius: 50%; display: grid; place-items: center; background: none; color: var(--ink-3); padding: 0; }
.tag button:hover { background: var(--press); color: var(--ink); }
.tag button svg { width: 12px; height: 12px; }

/* ---------- sections & cards ---------- */
.section { margin-bottom: 44px; scroll-margin-top: 12px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 8px 2px 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.015em; }
.section-head p { margin: 0; color: var(--ink-3); font-size: 13.5px; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.span-12 { grid-column: span 12; } .span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; position: relative; transition: box-shadow .3s, border-color .3s; }
.card-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 4px; }
.card-titles { flex: 1; min-width: 0; }
.card-title { margin: 0; font-size: 15px; font-weight: 620; letter-spacing: -0.005em; }
.card-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.card-tools { display: flex; gap: 2px; align-items: center; flex: none; }
.card-tools .icon-btn { width: 30px; height: 30px; }
.card-tools .icon-btn svg { width: 16px; height: 16px; }
.card-body { padding: 8px 20px 18px; }
.card.flash { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft), var(--shadow-2); }
.ask-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 0; background: none; color: var(--ink-2); font-size: 12.5px; font-weight: 560; white-space: nowrap; }
.ask-btn:hover { background: var(--brand-soft); color: var(--brand-ink); }
.ask-btn svg { width: 15px; height: 15px; }
.chart { width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 4px 20px 0; font-size: 12.5px; color: var(--ink-2); }
.legend .li { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .sw.diamond { transform: rotate(45deg) scale(.8); border-radius: 2px; }
.legend .li.toggle { cursor: pointer; border: 0; background: none; padding: 2px 4px; border-radius: 6px; }
.legend .li.toggle:hover { background: var(--hover); }
.legend .li.off { opacity: .4; }

.ai-note { margin: 6px 20px 0; border-radius: 10px; background: var(--brand-softer); border: 1px solid color-mix(in oklab, var(--brand) 14%, transparent); font-size: 13px; color: var(--ink-2); }
.ai-note summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-weight: 560; color: var(--brand-ink); font-size: 12.5px; }
.ai-note summary::-webkit-details-marker { display: none; }
.ai-note summary svg { width: 14px; height: 14px; }
.ai-note summary .chev { margin-left: auto; transition: transform .2s; color: var(--ink-3); }
.ai-note[open] summary .chev { transform: rotate(90deg); }
.ai-note p { margin: 0; padding: 0 12px 10px 34px; line-height: 1.55; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--ink-3); }
.empty svg { width: 28px; height: 28px; color: var(--ink-3); opacity: .7; }
.empty strong { color: var(--ink-2); font-weight: 600; }

/* ---------- AI panel ---------- */
.ai-panel { margin-bottom: 18px; }
.ai-card {
  position: relative; border-radius: var(--r-xl); padding: 26px 28px 24px; background:
    radial-gradient(1200px 300px at 0% 0%, color-mix(in oklab, var(--brand) 9%, transparent), transparent 60%),
    radial-gradient(800px 260px at 100% 0%, color-mix(in oklab, var(--s7) 6%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-1); overflow: hidden;
}
.ai-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, var(--brand-line), transparent 40%, transparent 70%, color-mix(in oklab, var(--s7) 25%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
.ai-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ai-kicker { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-ink); }
.ai-kicker svg { width: 16px; height: 16px; }
.ai-src { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; color: var(--ink-2); background: var(--surface-3); border: 1px solid var(--line); }
.ai-src .d { width: 6px; height: 6px; border-radius: 50%; background: var(--s7); }
.ai-src.rules .d { background: var(--ink-3); }
.ai-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ai-headline { font-size: 24px; line-height: 1.3; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 10px; max-width: 980px; text-wrap: balance; }
.ai-summary { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.65; max-width: 980px; text-wrap: pretty; }
.ai-hint { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 9px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info-ink); font-size: 13px; }
.ai-hint svg { width: 16px; height: 16px; }
.insights { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 22px; }
.ins {
  display: flex; flex-direction: column; gap: 8px; padding: 15px 16px 13px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); position: relative; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
}
.ins:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
.ins-top { display: flex; align-items: center; gap: 8px; }
.sev { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.sev svg { width: 15px; height: 15px; }
.sev.positive { background: var(--good-bg); color: var(--good-ink); }
.sev.warning { background: var(--warn-bg); color: var(--warn-ink); }
.sev.critical { background: var(--crit-bg); color: var(--crit-ink); }
.sev.info { background: var(--info-bg); color: var(--info-ink); }
.ins-sevlbl { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.metric { margin-left: auto; font-size: 12.5px; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ins h4 { margin: 2px 0 0; font-size: 14.5px; font-weight: 620; line-height: 1.35; letter-spacing: -0.005em; }
.ins p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.ins-foot { margin-top: auto; padding-top: 4px; display: flex; }
.show-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 4px 0; color: var(--brand-ink); font-weight: 560; font-size: 12.5px; }
.show-btn svg { width: 14px; height: 14px; transition: transform .2s; }
.show-btn:hover svg { transform: translateX(3px); }
.ins-more { display: flex; justify-content: center; margin-top: 10px; }
.ins-more .flip { transform: rotate(180deg); }
.ins p { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.rec p { align-self: start; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.recs { margin-top: 18px; }
.recs-title { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px; }
.rec-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.rec { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.rec-num { grid-row: span 2; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-2); font-size: 12px; font-weight: 650; color: var(--ink-2); }
.rec-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-h strong { font-weight: 600; font-size: 13.5px; }
.rec p { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.prio { font-size: 10.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; }
.prio.high { background: var(--crit-bg); color: var(--crit-ink); }
.prio.medium { background: var(--warn-bg); color: var(--warn-ink); }
.prio.low { background: var(--surface-3); color: var(--ink-2); }
.owner { font-size: 11.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.owner svg { width: 12px; height: 12px; }

.skel { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 8px; }
.ai-progress { display: flex; align-items: center; gap: 10px; color: var(--brand-ink); font-weight: 560; font-size: 13.5px; margin-bottom: 14px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand-line); border-top-color: var(--brand); animation: spin .8s linear infinite; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 6px; min-height: 150px; }
.kpi-top { display: flex; align-items: center; gap: 6px; }
.kpi-label { font-size: 13px; color: var(--ink-2); font-weight: 540; }
.kpi-info { width: 20px; height: 20px; border: 0; background: none; color: var(--ink-3); padding: 0; display: grid; place-items: center; border-radius: 50%; }
.kpi-info:hover, .kpi-info:focus-visible { color: var(--ink); background: var(--hover); }
.kpi-info svg { width: 15px; height: 15px; }
.kpi-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.kpi-value { font-size: 30px; line-height: 1.1; font-weight: 650; letter-spacing: -0.025em; white-space: nowrap; }
.kpi-value .unit { font-size: 17px; font-weight: 600; color: var(--ink-2); margin-left: 3px; letter-spacing: -0.01em; }
.kpi-spark { width: 112px; height: 38px; flex: none; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; padding: 1px 7px 1px 5px; border-radius: 6px; white-space: nowrap; }
.delta svg { width: 13px; height: 13px; }
.delta.up { color: var(--good-ink); background: var(--good-bg); }
.delta.down { color: var(--crit-ink); background: var(--crit-bg); }
.delta.down svg { transform: rotate(180deg); }
.delta.flat { color: var(--ink-2); background: var(--surface-3); }
.kpi-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); flex-wrap: wrap; }
.kpi-split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 2px; margin-top: 4px; }
.kpi-split span { display: block; height: 100%; border-radius: 3px; min-width: 3px; }
.kpi-split-legend { display: flex; gap: 3px 12px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.kpi-split-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.kpi-note { font-size: 12px; color: var(--ink-3); line-height: 1.45; margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--line); display: flex; gap: 6px; }
.kpi-note svg { width: 13px; height: 13px; color: var(--brand); margin-top: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.t th { text-align: left; font-weight: 560; color: var(--ink-3); font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
.t th.r, .t td.r { text-align: right; }
.t th button { border: 0; background: none; padding: 0; color: inherit; font: inherit; display: inline-flex; gap: 4px; align-items: center; }
.t th button:hover { color: var(--ink); }
.t th .sort { width: 12px; height: 12px; opacity: 0; transition: opacity .15s, transform .15s; }
.t th[aria-sort] .sort { opacity: 1; color: var(--ink); }
.t th[aria-sort="ascending"] .sort { transform: rotate(180deg); }
.t td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tbody tr { transition: background .12s; }
.t tbody tr:hover { background: var(--surface-2); }
.t tbody tr.clickable { cursor: pointer; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tfoot td { font-weight: 650; border-top: 1px solid var(--line-2); padding: 10px; }
.t td.num, .t th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.t .title-cell { max-width: 460px; }
.t .title-cell .tt { font-weight: 540; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t .title-cell .ts { font-size: 12px; color: var(--ink-3); margin-top: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.barcell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.barcell .bar { height: 6px; border-radius: 3px; background: var(--s1); min-width: 2px; }
.barcell .bar.ave { background: var(--s7); }
.barcell .track { width: 90px; display: flex; justify-content: flex-start; }
.chip { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 600; letter-spacing: .02em; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.badge i { width: 8px; height: 8px; border-radius: 2.5px; flex: none; }
.ext { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); text-decoration: none; font-weight: 520; max-width: 280px; }
.ext span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext svg { width: 13px; height: 13px; color: var(--ink-3); flex: none; }
.ext:hover { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.ext:hover svg { color: var(--brand-ink); }
.iconlink { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; color: var(--ink-3); }
.iconlink:hover { background: var(--hover); color: var(--brand-ink); }
.iconlink svg { width: 14px; height: 14px; }
.t .sel td { background: var(--brand-softer); }

.tbl-toolbar { display: flex; align-items: center; gap: 10px; padding: 0 20px 12px; flex-wrap: wrap; }
.tbl-toolbar .grow { flex: 1; }
.tbl-search { position: relative; }
.tbl-search svg { position: absolute; left: 9px; top: 8px; width: 14px; height: 14px; color: var(--ink-3); }
.tbl-search input { height: 30px; width: 240px; padding: 0 10px 0 29px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); outline: none; font-size: 13px; }
.tbl-search input:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px 16px; font-size: 12.5px; color: var(--ink-3); border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .pg { display: flex; gap: 4px; align-items: center; }
.pager button { min-width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--ink-2); padding: 0 8px; }
.pager button:hover:not(:disabled) { border-color: var(--line-2); color: var(--ink); }
.pager button[aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button svg { width: 14px; height: 14px; vertical-align: -2px; }

.wk-row td:first-child { width: 36px; }
.wk-toggle { width: 26px; height: 26px; border: 0; background: none; border-radius: 7px; display: grid; place-items: center; color: var(--ink-3); }
.wk-toggle:hover { background: var(--hover); color: var(--ink); }
.wk-toggle svg { width: 15px; height: 15px; transition: transform .2s; }
.wk-row[aria-expanded="true"] .wk-toggle svg { transform: rotate(90deg); }
.wk-detail td { background: var(--surface-2); padding: 0 !important; }
.wk-detail .inner { padding: 8px 16px 14px 56px; }
.wk-label { font-weight: 560; }
.wk-label small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.minilist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.minilist li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.minilist li:last-child { border-bottom: 0; }
.minilist .ml-sub { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- schedule (Gantt) ---------- */
.sch-stats { display: flex; gap: 10px; flex-wrap: wrap; padding: 6px 20px 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); min-width: 130px; }
.stat b { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--ink-3); }
.gantt-wrap { overflow-x: auto; padding: 0 20px 18px; -webkit-overflow-scrolling: touch; }
.gantt { --wk: 18px; display: grid; grid-template-columns: 280px repeat(var(--weeks), var(--wk)); position: relative; font-size: 12.5px; min-width: max-content; }
.g-head { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.g-month { grid-row: 1; font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 0 0 4px 3px; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-transform: uppercase; letter-spacing: .04em; }
.g-wk { grid-row: 2; font-size: 10px; color: var(--ink-3); text-align: center; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.g-corner { grid-row: 1 / span 2; border-bottom: 1px solid var(--line); }
.g-stream { grid-column: 1 / -1; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); padding: 14px 0 6px; border-bottom: 1px solid var(--line); position: sticky; left: 0; }
.g-title { grid-column: 1; padding: 0 12px 0 0; height: 30px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); min-width: 0; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.g-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-title .lnk { border: 0; background: none; padding: 0; text-align: left; color: var(--ink); cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.g-title .lnk:hover { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 3px; }
.g-cell { height: 30px; border-bottom: 1px solid var(--line); position: relative; }
.g-cell.alt { background: var(--surface-2); }
.g-mark { position: absolute; inset: 7px 2px; border-radius: 4px; }
.g-mark.st-sent { background: var(--good); }
.g-mark.st-accepted { background: var(--s1); }
.g-mark.st-send_planned { background: var(--s7); }
.g-mark.st-topic_planned { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.g-mark.st-in_review { background: var(--warn); }
.g-mark.st-other { background: var(--ink-3); }
.g-today { position: absolute; top: 40px; bottom: 0; width: 2px; background: var(--crit); z-index: 3; pointer-events: none; border-radius: 1px; }
.g-wk.now { color: var(--crit-ink); font-weight: 700; position: relative; z-index: 4; overflow: visible; }
.g-wk.now span { background: var(--crit); color: #fff; border-radius: 4px; padding: 1px 3px; }
.g-sel { position: absolute; top: 0; bottom: 0; background: var(--brand-soft); z-index: 0; pointer-events: none; }
.sw-st { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- quality ---------- */
.q-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 8px 20px 18px; }
.q-stat { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.q-stat b { display: block; font-size: 26px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; }
.q-stat span { font-size: 12.5px; color: var(--ink-2); }
.q-stat.hl { background: linear-gradient(135deg, var(--brand-soft), transparent 80%), var(--surface-2); border-color: var(--brand-line); }
.q-meter { height: 6px; border-radius: 3px; background: var(--crit-bg); overflow: hidden; margin-top: 8px; }
.q-meter i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.q-value { margin: 0 20px 18px; padding: 14px 16px; border-radius: 12px; background: var(--good-bg); color: var(--ink); display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; line-height: 1.55; }
.q-value svg { color: var(--good-ink); width: 20px; height: 20px; margin-top: 1px; }
.q-cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; padding: 0 20px 20px; }
.q-sub { font-size: 13px; font-weight: 620; margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; }
.q-sub small { font-weight: 400; color: var(--ink-3); }
.q-group { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; overflow: hidden; background: var(--surface); }
.q-group summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.q-group summary::-webkit-details-marker { display: none; }
.q-group summary:hover { background: var(--surface-2); }
.q-group .q-name { flex: 1; min-width: 0; font-weight: 540; font-size: 13px; }
.q-group .q-name small { display: block; color: var(--ink-3); font-weight: 400; font-size: 11.5px; }
.q-group .q-cnt { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 12.5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); }
.q-group .chev { color: var(--ink-3); width: 15px; height: 15px; transition: transform .2s; }
.q-group[open] .chev { transform: rotate(90deg); }
.q-items { list-style: none; margin: 0; padding: 0 12px 10px; max-height: 320px; overflow-y: auto; }
.q-items li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.q-items .cell { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); display: block; margin-bottom: 2px; }
.lvl { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.lvl svg { width: 14px; height: 14px; }
.lvl.error { background: var(--crit-bg); color: var(--crit-ink); }
.lvl.warning { background: var(--warn-bg); color: var(--warn-ink); }
.lvl.info { background: var(--info-bg); color: var(--info-ink); }
.cmp td, .cmp th { padding: 7px 8px; font-size: 12.5px; }
.cmp td.num { min-width: 64px; }
.cmp .mm { background: var(--crit-bg); border-radius: 6px; }
.cmp .mm .cv { color: var(--crit-ink); font-weight: 650; }
.cmp .mm .rv { display: block; font-size: 11px; color: var(--ink-3); text-decoration: line-through; }
.cmp .ok .cv { color: var(--ink); }
.cmp th.grp { text-align: center; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; border-bottom: 0; padding-bottom: 0; }
.cmp-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); margin: 8px 0 0; }
.cmp-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- drawers ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface); z-index: 90;
  border-left: 1px solid var(--line); box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slidein .28s var(--ease);
}
.detail-drawer { width: min(620px, 100vw); z-index: 95; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(10, 10, 10, .28); z-index: 94; animation: fade .2s; backdrop-filter: blur(2px); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 630; line-height: 1.35; letter-spacing: -0.01em; }
.drawer-kicker { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.drawer-body { overflow-y: auto; padding: 16px 20px 28px; flex: 1; }
.d-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.d-stats .stat { min-width: 0; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.chat-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 80; display: inline-flex; align-items: center; gap: 9px; height: 46px; padding: 0 16px 0 14px;
  border-radius: 999px; border: 0; background: var(--ink); color: var(--surface); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-3);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.chat-fab:hover { transform: translateY(-2px); }
.chat-fab svg { width: 18px; height: 18px; color: color-mix(in oklab, var(--brand) 55%, #fff); }
.chat-fab kbd { font: 600 11px var(--mono); padding: 2px 6px; border-radius: 5px; background: rgba(255,255,255,.14); color: inherit; opacity: .85; }
:root[data-theme="dark"] .chat-fab kbd { background: rgba(0,0,0,.12); }
.chat-head-l { display: flex; gap: 10px; align-items: center; }
.chat-head-r { display: flex; gap: 2px; }
.chat-orb { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), color-mix(in oklab, var(--brand) 40%, var(--s7))); }
.chat-orb svg { width: 18px; height: 18px; }
.chat-scope { padding: 8px 20px; font-size: 12px; color: var(--ink-3); border-bottom: 1px solid var(--line); background: var(--surface-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chat-scope svg { width: 13px; height: 13px; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { max-width: 100%; font-size: 13.5px; line-height: 1.6; }
.msg.user { align-self: flex-end; max-width: 86%; background: var(--ink); color: var(--surface); padding: 9px 13px; border-radius: 14px 14px 4px 14px; }
.msg.bot { align-self: stretch; color: var(--ink); }
.msg.bot .md > *:first-child { margin-top: 0; }
.msg.bot .md > *:last-child { margin-bottom: 0; }
.msg .tool { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3); margin: 2px 0 8px; }
.msg .tool svg { width: 13px; height: 13px; }
.msg .tool.run svg { animation: spin 1s linear infinite; }
.msg .err { color: var(--crit-ink); background: var(--crit-bg); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.chat-note { font-size: 12px; color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; display: flex; gap: 8px; line-height: 1.45; }
.chat-note svg { width: 14px; height: 14px; margin-top: 2px; color: var(--info-ink); }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.sugg button { text-align: left; border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 7px 10px; font-size: 12.5px; color: var(--ink-2); line-height: 1.35; transition: all .15s; }
.sugg button:hover { border-color: var(--brand-line); color: var(--brand-ink); background: var(--brand-softer); }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; max-height: 140px; min-height: 42px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); outline: none; line-height: 1.45; font-size: 13.5px; }
.chat-form textarea:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }
.send-btn { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--ink); color: var(--surface); display: grid; place-items: center; flex: none; transition: opacity .15s, transform .1s; }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn svg { width: 18px; height: 18px; }

/* markdown */
.md p { margin: 0 0 10px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md strong { font-weight: 640; }
.md code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.md a { color: var(--brand-ink); text-underline-offset: 3px; }
.md h3, .md h4 { margin: 12px 0 6px; font-size: 14px; font-weight: 640; }
.md table { border-collapse: collapse; width: 100%; margin: 6px 0 12px; font-size: 12.5px; display: block; overflow-x: auto; }
.md th, .md td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.md th { color: var(--ink-3); font-weight: 560; font-size: 11.5px; white-space: nowrap; }
.md td.r, .md th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* tooltip & toast */
.tooltip { position: fixed; z-index: 200; max-width: 300px; padding: 9px 11px; border-radius: 9px; background: var(--ink); color: var(--surface); font-size: 12.5px; line-height: 1.45; pointer-events: none; box-shadow: var(--shadow-2); animation: fade .12s; }
.tooltip b { font-weight: 650; }
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 210; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 13.5px; box-shadow: var(--shadow-3); animation: rise .25s var(--ease); max-width: min(560px, 92vw); }
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.ok svg { color: #5fd35f; } .toast.err svg { color: #ff8a8a; } .toast.info svg { color: #86b6ef; }

.foot { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); display: flex; gap: 14px; flex-wrap: wrap; justify-content: space-between; }

/* view toggle */
.vt { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-3); gap: 2px; }
.vt button { height: 26px; width: 30px; border: 0; background: none; border-radius: 6px; display: grid; place-items: center; color: var(--ink-3); }
.vt button svg { width: 15px; height: 15px; }
.vt button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.social-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
.profiles { list-style: none; margin: 0; padding: 0 20px 18px; }
.profiles li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.profiles .rank { width: 18px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.profiles .pn { flex: 1; min-width: 0; }
.profiles .pn > a, .profiles .pn > span { display: flex; max-width: 100%; }
.profiles .pn small { display: block; }
.profiles .pn small { color: var(--ink-3); font-size: 11.5px; }
.profiles .pc { font-variant-numeric: tabular-nums; font-weight: 600; }
.sub-h { font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); padding: 4px 20px 6px; }

/* ---------- animations ---------- */
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein { from { transform: translateX(24px); } to { transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .content { padding: 24px 24px 120px; }
  .topbar { padding: 12px 24px 10px; }
  .span-7, .span-5 { grid-column: span 12; }
  .q-cols { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 0 auto 0; height: auto; max-height: 88vh; border-right: 0; border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-3); transform: translateY(-105%); transition: transform .3s var(--ease); border-radius: 0 0 var(--r-xl) var(--r-xl); z-index: 120;
  }
  .sidebar.open { transform: none; }
  .icon-btn.sb-close { display: inline-grid; }
  .sb-scrim { position: fixed; inset: 0; background: rgba(10,10,10,.3); z-index: 110; }
  .nav-link.active::before { display: none; }
  .icon-btn.menu-btn { display: inline-grid; margin-left: -6px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .q-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html { scroll-padding-top: 210px; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .content { padding: 16px 16px 110px; }
  .topbar { padding: 10px 16px 8px; }
  .tb-row1 { margin-bottom: 8px; }
  .tb-title h1 { font-size: 16.5px; }
  .tb-actions .btn span { display: none; }
  .tb-actions .btn { width: 36px; padding: 0; }
  .tb-row2, .tb-row3 { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
  .tb-row2::-webkit-scrollbar, .tb-row3::-webkit-scrollbar { display: none; }
  .period { flex-wrap: nowrap; }
  .filters { flex-wrap: nowrap; }
  .search { margin-left: 0; }
  .search input, .search input:focus { width: 170px; }
  .active-filters { display: none !important; }
  .pop { position: fixed; left: 12px !important; right: 12px; top: auto !important; bottom: 12px; width: auto; max-height: 70vh; }
  .kpis { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .kpi { min-height: 0; }
  .ai-card { padding: 20px 18px; }
  .ai-headline { font-size: 19px; }
  .ai-actions { margin-left: 0; width: 100%; }
  .ai-actions .btn { flex: 1; }
  .insights, .rec-list { grid-template-columns: minmax(0, 1fr); }
  .grid { gap: 14px; }
  .card-head { padding: 16px 16px 4px; flex-wrap: wrap; }
  .card-body { padding: 8px 12px 14px; }
  .ask-btn span { display: none; }
  .legend { padding: 4px 16px 0; }
  .q-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 8px 16px 14px; }
  .q-cols { padding: 0 16px 16px; }
  .q-value { margin: 0 16px 16px; }
  .tbl-toolbar { padding: 0 16px 12px; }
  .tbl-search input { width: 100%; }
  .tbl-search { flex: 1; }
  .gantt { grid-template-columns: 170px repeat(var(--weeks), var(--wk)); }
  .gantt-wrap { padding: 0 16px 16px; }
  .chat-fab { right: 16px; bottom: 16px; height: 48px; width: 48px; padding: 0; justify-content: center; }
  .chat-fab span, .chat-fab kbd { display: none; }
  .drawer, .detail-drawer { width: 100vw; border-left: 0; }
  .d-stats { grid-template-columns: repeat(2, 1fr); }
  .section-head h2 { font-size: 18px; }
  html { scroll-padding-top: 170px; }
}

@media print {
  .sidebar, .topbar, .chat-fab, .card-tools, .ai-actions { display: none !important; }
  .app { display: block; }
  .card { break-inside: avoid; box-shadow: none; }
}
@media (forced-colors: active) {
  .g-mark, .kpi-split span, .barcell .bar { forced-color-adjust: none; }
}

/* bloki wewnątrz .card-body nie dublują poziomego odstępu */
.card-body > .sch-stats, .card-body > .gantt-wrap, .card-body > .legend, .card-body > .q-stats, .card-body > .q-cols,
.card-body > .profiles, .card-body > .sub-h, .card-body > .pager, .card-body > .table-wrap { padding-left: 0; padding-right: 0; }
.card-body > .q-value { margin-left: 0; margin-right: 0; }
.card-body > .q-sub, .card-body > .cmp-legend { padding-left: 0 !important; padding-right: 0 !important; }
.card-body > .table-wrap.cmp-wrap { padding: 0 0 6px !important; }
#card-pubs .table-wrap { padding: 0 10px; }
#card-pubs .title-cell .tt { font-weight: 500; font-size: 12.5px; }
@media (max-width: 760px) {
  .ai-actions { flex-wrap: wrap; }
  .ai-actions > .btn, .ai-actions > .tip-wrap { flex: 1 1 150px; }
  .ai-actions > .tip-wrap .btn { width: 100%; }
}
@media (max-width: 760px) {
  .t .title-cell { min-width: 210px; }
  .t .title-cell .ts > span:not(.chip) { display: none; }
}
@media (max-width: 1560px) {
  .tb-actions .btn-ghost span { display: none; }
  .tb-actions .btn-ghost { width: 36px; padding: 0; }
}

/* =====================================================================
   KONTO I DOSTĘP — menu użytkownika, modale, formularze, panel admina, logowanie
   ===================================================================== */
.btn-danger { background: var(--crit); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.16) inset, 0 4px 14px -6px var(--crit); }
.btn-danger:hover:not(:disabled) { background: color-mix(in oklab, var(--crit) 86%, #000); }
a.btn { text-decoration: none; }
.btn-block { width: 100%; }
.btn-lg { height: 44px; font-size: 14.5px; border-radius: 12px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .7s linear infinite; flex: none; opacity: .8; }
.cl-opt, .role-card, .switch-row { font-weight: 400 !important; }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand-ink); font-size: 12.5px; font-weight: 560; text-underline-offset: 3px; }
.link-btn:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- user block (sidebar) ---------- */
.user-block { position: relative; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 2px; }
.user-current {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); border: 1px solid transparent;
  background: none; text-align: left; transition: background .15s, border-color .15s;
}
.user-current:hover { background: var(--hover); }
.user-current[aria-expanded="true"] { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-1); }
.user-av { border-radius: 50%; }
.user-role { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 60; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-3); padding: 6px; animation: pop .16s var(--ease);
}
.um-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; min-width: 0; }
.um-name { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.um-mail { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.um-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; text-align: left; color: var(--ink-2); font-weight: 520; }
.um-item svg { width: 16px; height: 16px; color: var(--ink-3); }
.um-item:hover, .um-item:focus-visible { background: var(--hover); color: var(--ink); outline-offset: -2px; }
.um-item.danger:hover, .um-item.danger:focus-visible { background: var(--crit-bg); color: var(--crit-ink); }
.um-item.danger:hover svg, .um-item.danger:focus-visible svg { color: var(--crit-ink); }
.um-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* ---------- modal ---------- */
body.modal-open { overflow: hidden; }
.modal-layer { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 24px 16px; }
.modal-layer.leaving { opacity: 0; transition: opacity .15s; }
.modal-scrim { position: absolute; inset: 0; background: rgba(10, 10, 10, .38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .2s; }
.modal {
  position: relative; width: 100%; max-height: min(880px, calc(100vh - 48px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-3); animation: rise .22s var(--ease); overflow: hidden;
}
.modal-sm { max-width: 440px; } .modal-md { max-width: 520px; } .modal-lg { max-width: 680px; } .modal-xl { max-width: 1160px; height: min(820px, calc(100vh - 48px)); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.015em; line-height: 1.3; }
.modal-kicker { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-titles { min-width: 0; }
.modal-body { padding: 4px 22px 22px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
.confirm-body { display: flex; gap: 14px; align-items: flex-start; }
.confirm-body p { margin: 0 0 8px; color: var(--ink-2); line-height: 1.55; }
.confirm-body p:last-child { margin-bottom: 0; }
.confirm-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--crit-bg); color: var(--crit-ink); flex: none; }
.confirm-ic svg { width: 20px; height: 20px; }

/* ---------- formularze ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-h { display: flex; align-items: center; gap: 8px; margin: 4px 0 -2px; font-size: 14px; font-weight: 640; }
.form-h svg { width: 16px; height: 16px; color: var(--brand); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field > label, .field-top > label, .field legend, .field-label { font-size: 13px; font-weight: 580; color: var(--ink); padding: 0; }
.field legend { margin-bottom: 8px; }
.field input[type="email"], .field input[type="text"], .field input[type="password"], .copy-box input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface);
  outline: none; font-size: 14px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: var(--ink-3); opacity: .8; }
.field input:focus, .copy-box input:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input:disabled { background: var(--surface-3); color: var(--ink-3); cursor: not-allowed; }
.field input[aria-invalid="true"] { border-color: color-mix(in oklab, var(--crit) 60%, transparent); box-shadow: 0 0 0 3px var(--crit-bg); }
.field-hint { font-size: 12px; color: var(--ink-3); min-height: 1em; display: flex; align-items: center; gap: 5px; }
.field-hint svg { width: 13px; height: 13px; }
.field-aux { font-size: 12px; }
.tone-ok, .tone-s3, .tone-s4 { color: var(--good-ink) !important; }
.tone-bad, .tone-s1 { color: var(--crit-ink) !important; }
.tone-s2 { color: var(--warn-ink) !important; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 8px; border: 0; background: none; color: var(--ink-3); display: grid; place-items: center; }
.pw-toggle:hover { background: var(--hover); color: var(--ink); }
.pw-toggle svg { width: 17px; height: 17px; }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.pw-meter i { height: 4px; border-radius: 2px; background: var(--surface-3); transition: background .2s; }
.pw-meter.s1 i:nth-child(-n+1) { background: var(--crit); }
.pw-meter.s2 i:nth-child(-n+2) { background: var(--warn); }
.pw-meter.s3 i:nth-child(-n+3) { background: var(--good); }
.pw-meter.s4 i { background: var(--good); }
.form-error { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--crit-bg); color: var(--crit-ink); font-size: 13px; line-height: 1.45; border: 1px solid color-mix(in oklab, var(--crit) 22%, transparent); }
.form-error svg { width: 16px; height: 16px; margin-top: 1px; }
.form-note { display: flex; gap: 9px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.form-note svg { width: 15px; height: 15px; margin-top: 2px; color: var(--info-ink); }
.form-note strong { color: var(--ink); font-weight: 620; }

/* przełącznik */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sw-title { font-weight: 600; font-size: 13.5px; }
.sw-sub { font-size: 12px; color: var(--ink-3); line-height: 1.45; font-weight: 400; }
.switch { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--line-2); position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(16px); }
.setpw { gap: 12px; }

/* role */
.role-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 620; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.role-badge.r-superuser { background: color-mix(in oklab, var(--s7) 14%, transparent); color: color-mix(in oklab, var(--s7) 80%, var(--ink)); }
.role-badge.r-admin { background: var(--info-bg); color: var(--info-ink); }
.role-badge.r-staff { background: color-mix(in oklab, var(--s3) 13%, transparent); color: color-mix(in oklab, var(--s3) 62%, var(--ink)); }
.role-badge.r-client { background: color-mix(in oklab, var(--s2) 12%, transparent); color: color-mix(in oklab, var(--s2) 70%, var(--ink)); }
.role-field { border: 0; }
.role-field:disabled .role-cards { opacity: .6; }
.role-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.role-card { position: relative; display: block; cursor: pointer; }
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.rc-body { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); transition: border-color .15s, box-shadow .15s, background .15s; }
.role-card:hover .rc-body { border-color: var(--ink-3); }
.role-card input:checked + .rc-body { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--brand-softer); }
.role-card input:focus-visible + .rc-body { outline: 2px solid var(--focus); outline-offset: 2px; }
.rc-top { display: flex; align-items: center; justify-content: space-between; }
.rc-check { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; color: transparent; transition: all .15s; }
.rc-check svg { width: 12px; height: 12px; }
.role-card input:checked + .rc-body .rc-check { background: var(--brand); border-color: var(--brand); color: #fff; }
.rc-desc { font-size: 12px; color: var(--ink-3); line-height: 1.45; }

/* klienci */
.cl-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }
.cl-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.cl-chip.all { background: var(--brand-soft); color: var(--brand-ink); font-weight: 560; }
.cl-chip.more { background: none; border: 1px dashed var(--line-2); color: var(--ink-3); }
.cl-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 248px; overflow-y: auto; padding: 2px; }
.cl-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; min-width: 0; }
.cl-opt:hover { border-color: var(--line-2); background: var(--surface-2); }
.cl-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cl-opt .co-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cl-opt .co-name { font-weight: 560; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-opt .co-ind { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-opt .box { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2); display: grid; place-items: center; color: transparent; flex: none; transition: all .15s; }
.cl-opt .box svg { width: 12px; height: 12px; }
.cl-opt:has(input:checked) { border-color: var(--brand-line); background: var(--brand-softer); }
.cl-opt:has(input:checked) .box { background: var(--brand); border-color: var(--brand); color: #fff; }
.cl-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.all-clients { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--brand-softer); border: 1px solid var(--brand-line); font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.all-clients svg { width: 18px; height: 18px; color: var(--brand-ink); margin-top: 1px; }
.all-clients strong { display: block; color: var(--ink); font-size: 13.5px; margin-bottom: 1px; }

/* ---------- moje konto ---------- */
.acct-card { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.acct-av { width: 46px; height: 46px; border-radius: 50%; font-size: 15px; }
.acct-id { flex: 1; min-width: 0; }
.acct-name { font-weight: 640; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-mail { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 18px; }
.acct-meta div { min-width: 0; }
.acct-meta dt { font-size: 11.5px; color: var(--ink-3); font-weight: 560; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.acct-meta dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; }
.modal-body .form { padding-top: 16px; border-top: 1px solid var(--line); }
.modal-body > .form:first-child { padding-top: 4px; border-top: 0; }

/* ---------- link zaproszenia ---------- */
.invite-ok { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 6px 0 18px; }
.invite-ok p { margin: 0; color: var(--ink-2); }
.invite-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--good-bg); color: var(--good-ink); }
.invite-ic svg { width: 26px; height: 26px; }
.copy-box { display: flex; gap: 8px; margin: 6px 0 14px; }
.copy-box input { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); min-width: 0; }
.copy-box .btn { height: 42px; flex: none; }
.btn.copied { background: var(--good); color: #fff; }

/* ---------- panel użytkowników ---------- */
.modal-users .modal-body { padding: 0; display: flex; flex-direction: column; }
.adm-tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); flex: none; }
.adm-tabs [role="tab"] { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border: 0; background: none; color: var(--ink-3); font-weight: 560; position: relative; border-radius: 8px 8px 0 0; }
.adm-tabs [role="tab"] svg { width: 16px; height: 16px; }
.adm-tabs [role="tab"]:hover { color: var(--ink); }
.adm-tabs [role="tab"][aria-selected="true"] { color: var(--ink); }
.adm-tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.tab-count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--surface-3); color: var(--ink-2); font-size: 11px; font-weight: 650; display: grid; place-items: center; }
.tab-count:empty { display: none; }
.adm-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.adm-toolbar { display: flex; align-items: center; gap: 10px; padding: 16px 22px 10px; flex-wrap: wrap; }
.adm-toolbar .grow { flex: 1; }
.adm-search input { width: 300px; height: 36px; border-radius: 10px; padding-left: 32px; }
.adm-search svg { top: 11px; left: 11px; }
.adm-seg button { height: 28px; padding: 0 10px; font-size: 12.5px; }
.seg-n { color: var(--ink-3); font-variant-numeric: tabular-nums; margin-left: 2px; }
.adm-stats { display: flex; gap: 18px; padding: 0 22px 10px; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.adm-stats span { display: inline-flex; align-items: center; gap: 7px; }
.adm-stats b { color: var(--ink); font-weight: 620; font-variant-numeric: tabular-nums; }
.sdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sdot.on { background: var(--good); } .sdot.pending { background: var(--warn); } .sdot.off { background: var(--ink-3); opacity: .6; }
.adm-table { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 12px; border-top: 1px solid var(--line); }
.adm-table .table-wrap { overflow: visible; }
.adm-table .t th { top: 0; padding-top: 12px; }
.adm-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 60px 20px; color: var(--ink-3); }
.adm-foot { padding: 12px 10px 4px; font-size: 12px; color: var(--ink-3); }
.ut td { padding: 11px 10px; }
.u-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.u-cell .avatar { border-radius: 50%; }
.u-id { min-width: 0; }
.u-name { font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-mail { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.you { display: inline-flex; height: 17px; padding: 0 5px; border-radius: 4px; background: var(--brand-soft); color: var(--brand-ink); font-size: 10.5px; font-weight: 650; vertical-align: 1px; }
.ut tr.inactive td > * { opacity: .55; }
.ut tr.inactive td:last-child > * { opacity: 1; }
.st-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.st-badge i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.st-badge.st-on i { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.st-badge.st-pending { color: var(--warn-ink); } .st-badge.st-pending i { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.st-badge.st-off { color: var(--ink-3); } .st-badge.st-off i { background: var(--ink-3); }
.row-acts { display: inline-flex; gap: 2px; justify-content: flex-end; }
.row-act { width: 30px; height: 30px; }
.row-act svg { width: 15px; height: 15px; }
.row-act.danger:hover { background: var(--crit-bg); color: var(--crit-ink); }
.row-act.on { color: var(--good-ink); }
.row-na { font-size: 12px; padding-right: 8px; }
.act-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 580; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); }
.act-badge.t-info { background: var(--info-bg); color: var(--info-ink); }
.act-badge.t-good { background: var(--good-bg); color: var(--good-ink); }
.act-badge.t-crit { background: var(--crit-bg); color: var(--crit-ink); }
.act-badge.t-warn { background: var(--warn-bg); color: var(--warn-ink); }
.act-badge.t-brand { background: var(--brand-soft); color: var(--brand-ink); }
.act-detail { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- strona logowania ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; position: relative; overflow-x: hidden; }
.auth-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 520px at 12% -10%, color-mix(in oklab, var(--brand) 14%, transparent), transparent 60%),
    radial-gradient(800px 480px at 100% 110%, color-mix(in oklab, var(--s7) 10%, transparent), transparent 60%);
}
.auth-pulse { position: absolute; left: 0; right: 0; top: 50%; width: 100%; height: 240px; transform: translateY(-50%); color: var(--brand); opacity: .12; }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 2; width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 12px; background: color-mix(in oklab, var(--surface) 70%, transparent); border: 1px solid var(--line); }
.auth-shell { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 48px 16px; }
.auth-card {
  width: 100%; max-width: 420px; padding: 32px 32px 28px; border-radius: 22px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-3), 0 0 0 6px color-mix(in oklab, var(--surface) 40%, transparent);
  animation: rise .35s var(--ease);
}
.auth-card.shake { animation: shake .4s var(--ease); }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-logo { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 0 0 1px var(--line-2), 0 6px 18px -8px rgba(0,0,0,.5); }
.auth-brand-name { font-weight: 680; font-size: 17px; letter-spacing: -0.015em; }
.auth-brand-sub { font-size: 12.5px; color: var(--ink-3); }
.auth-title { margin: 0 0 6px; font-size: 24px; font-weight: 680; letter-spacing: -0.02em; line-height: 1.2; }
.auth-lead { margin: 0 0 22px; color: var(--ink-2); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.auth-lead strong { color: var(--ink); font-weight: 620; }
.auth-kicker { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.auth-kicker svg { width: 13px; height: 13px; }
.auth-view .form { gap: 14px; }
.auth-view .btn-block { margin-top: 6px; }
.auth-hint { margin: 18px 0 0; font-size: 12.5px; color: var(--ink-3); text-align: center; line-height: 1.5; }
.auth-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px 0 30px; color: var(--ink-3); }
.auth-center { text-align: center; }
.auth-badge-ic { width: 56px; height: 56px; border-radius: 18px; display: inline-grid; place-items: center; background: var(--warn-bg); color: var(--warn-ink); margin: 4px 0 14px; }
.auth-badge-ic svg { width: 26px; height: 26px; }
.pw-checks { list-style: none; margin: -2px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-3); }
.pw-checks li { display: inline-flex; align-items: center; gap: 6px; transition: color .15s; }
.pw-checks svg { width: 14px; height: 14px; }
.pw-checks li.ok { color: var(--good-ink); }
.pw-checks li.bad { color: var(--crit-ink); }
.auth-foot { max-width: 400px; font-size: 12.5px; color: var(--ink-3); text-align: center; line-height: 1.55; text-wrap: balance; }
.auth-foot svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; }

/* ---------- responsywność: konto ---------- */
@media (max-width: 900px) {
  .modal-xl { height: calc(100vh - 32px); }
  .adm-search { flex: 1 1 220px; }
  .adm-search input { width: 100%; }
}
@media (max-width: 760px) {
  .modal-layer { padding: 0; place-items: end center; }
  .modal { max-height: calc(100dvh - 24px); border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; }
  .modal-xl { height: calc(100dvh - 24px); }
  .modal-head { padding: 16px 16px 12px; }
  .modal-body { padding: 4px 16px 18px; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .form-grid, .role-cards, .cl-pick, .acct-meta { grid-template-columns: minmax(0, 1fr); }
  .adm-tabs { padding: 0 10px; }
  .adm-toolbar { padding: 12px 16px 8px; }
  .adm-toolbar .grow { display: none; }
  .adm-toolbar #usrAdd { flex: 1 1 100%; }
  .adm-seg { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .adm-stats { padding: 0 16px 10px; gap: 6px 14px; }
  .adm-table { padding: 0 12px 12px; }
  /* tabele jako karty */
  .ut thead, .at thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ut, .ut tbody, .at, .at tbody { display: block; }
  .ut tr, .at tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
  .ut tbody tr:hover, .at tbody tr:hover { background: none; }
  .ut td, .at td { display: block; padding: 0; border: 0 !important; min-width: 0; }
  .ut td:first-child { grid-column: 1 / -1; }
  .ut td:last-child { grid-column: 1 / -1; }
  .ut td[data-label="Rola"] { order: 1; }
  .ut td[data-label="Status"] { order: 2; justify-self: end; align-self: center; }
  .ut td[data-label="Klienci"] { order: 3; }
  .ut td[data-label="Ostatnie logowanie"] { order: 4; }
  .ut td:last-child { order: 5; }
  .ut td[data-label="Klienci"], .ut td[data-label="Ostatnie logowanie"] { grid-column: 1 / -1; font-size: 12.5px; }
  .ut td[data-label="Ostatnie logowanie"]::before { content: "Ostatnie logowanie: "; color: var(--ink-3); }
  .ut .row-acts { justify-content: flex-start; gap: 4px; }
  .ut .row-act { border: 1px solid var(--line); width: 36px; height: 36px; }
  .u-mail { max-width: none; }
  .at tr { gap: 4px 10px; }
  .at td[data-label="Akcja"] { grid-column: 1 / -1; order: -3; margin-bottom: 2px; }
  .at td[data-label="Kto"] { grid-column: 1 / -1; order: -2; font-weight: 560; }
  .at td[data-label="Cel"] { grid-column: 1 / -1; order: -1; font-size: 12.5px; }
  .at td[data-label="Kto"]::before { content: "Kto: "; color: var(--ink-3); font-weight: 400; }
  .at td[data-label="Cel"]::before { content: "Cel: "; color: var(--ink-3); }
  .at td[data-label="Czas"] { font-size: 12px; color: var(--ink-3); }
  .at td[data-label="IP"] { text-align: right; color: var(--ink-3); }
  .act-detail { white-space: normal; }
  .auth-card { padding: 26px 22px 22px; border-radius: 20px; }
  .auth-title { font-size: 22px; }
  .auth-shell { justify-content: flex-start; padding-top: 72px; }
  .auth-pulse { display: none; }
}
