/* Rdzeń – ELEMENTY: nagłówki, przyciski, pola, karty, KPI, tabele (na telefonie jako karty), szuflada, komunikaty.
   Kalibra i Kwerenda (Dziennik i Galeria mają własne). Ładować po rdzen.css. */
a:hover { text-decoration: underline; }
.num, td.n, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); }
.ok-t { color: var(--ok); } .bad-t { color: var(--bad); }
.grow { flex: 1; min-width: 0; }
.only-mobile { display: none !important; }
.only-mobile-inline { display: none; }
a:hover { text-decoration: underline; }

/* --- nagłówki stron --- */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.ph h1 { margin: 0; font: 600 32px/1.05 var(--cond); letter-spacing: .005em; word-break: break-word; }
.ph .kicker { color: var(--muted); font-size: 13.5px; margin-bottom: 4px; }
.ph .sub { margin-top: 4px; color: var(--muted); }
.ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }
h2.sec { font: 600 15.5px/1.3 var(--font); margin: 0; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.sec-head .muted { font-size: 13px; }
.group-title { font: 600 15px var(--font); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }

/* --- kontrolki --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none !important; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--nav-bg); border-color: var(--nav-bg); color: #fff; }
.btn.primary:hover { background: var(--nav-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn.icon { width: 36px; padding: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--surface-3); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--link); cursor: pointer; font-weight: 500; }
.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], input[type=email], select {
  height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); min-width: 0; }
textarea { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); }
.field input { font-size: 16px; height: 42px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters .grow { flex: 1 1 220px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 14px; cursor: pointer; }

/* --- karty, siatki, KPI --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-width: 0; }
.card-pad { padding: 16px; }
.stack { display: grid; gap: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-eq { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 15px; min-width: 0; }
.kpi .lbl { color: var(--muted); font-size: 13.5px; }
.kpi .val { font: 600 40px/1.05 var(--cond); font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .val small { font-size: 22px; color: var(--muted); font-weight: 500; }
.kpi .foot { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kpi.accent { background: var(--nav-bg); border-color: var(--nav-bg); color: var(--nav-ink); }
.kpi.accent .lbl, .kpi.accent .foot, .kpi.accent .val small { color: var(--nav-muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { display: grid; gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
  text-decoration: none !important; transition: border-color .15s; cursor: pointer; text-align: left; }
.tile:hover { border-color: var(--accent); }
.tile .name { font: 600 21px/1.1 var(--cond); display: flex; align-items: center; gap: 8px; }
.tile .name svg { color: var(--accent); width: 18px; height: 18px; }
.tile .row { display: flex; justify-content: space-between; color: var(--muted); font-size: 13.5px; gap: 8px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* --- tabela danych (na telefonie jako karty: td data-m = title | sub | aside | full | label | hide) --- */
.dt-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
.dt th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; }
.dt th.r, .dt td.r { text-align: right; }
.dt th.c, .dt td.c { text-align: center; }
.dt td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr.click { cursor: pointer; }
.dt tbody tr.click:hover td { background: var(--surface-2); }
.dt td.strong { font-weight: 600; }
.dt td.nowrap, .dt th.nowrap { white-space: nowrap; }
.dt td.code { font-family: var(--mono); font-size: 12.5px; }
.dt .sort { cursor: pointer; user-select: none; }
.dt .sort:hover { color: var(--ink); }
.dt th.mcol, .dt td.mcol { display: none; }
.dt-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line-2);
  color: var(--muted); font-size: 13.5px; }
.empty { padding: 38px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.err-box { padding: 12px 14px; background: var(--bad-soft); color: var(--bad); border-radius: 10px; }
.err-box pre { white-space: pre-wrap; margin: 6px 0 0; font: 12.5px/1.45 var(--mono); color: var(--ink-2); }
.note { padding: 11px 14px; background: var(--info-soft); border-radius: 10px; font-size: 14px; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.warn { background: var(--warn-soft); }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3), var(--line-2), var(--surface-3)); background-size: 200% 100%;
  animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button .cnt, .tabs .cnt { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* --- szuflada (szczegóły z boku) --- */
.drawer { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 25, .42); display: flex; justify-content: flex-end; }
.drawer-panel { width: min(560px, 100%); height: 100%; background: var(--bg); display: flex; flex-direction: column; animation: slide .2s ease-out;
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, .4); }
.drawer-panel.wide { width: min(900px, 100%); }
@keyframes slide { from { transform: translateX(30px); opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .drawer-panel { animation: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line);
  padding-top: calc(16px + env(safe-area-inset-top)); }
.drawer-head h2 { margin: 0; font: 600 22px/1.15 var(--cond); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { overflow: auto; padding: 16px 18px 30px; display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
.drawer-body > * { flex-shrink: 0; }
table.rec { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rec td { padding: 7px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
table.rec td:first-child { color: var(--muted); width: 40%; padding-right: 12px; overflow-wrap: anywhere; }
table.rec td:last-child { overflow-wrap: anywhere; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; background: var(--ink); color: #fff;
  padding: 11px 16px; border-radius: 10px; max-width: 90vw; }
.toast.bad { background: var(--bad); }

/* --- responsywność --- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .only-mobile { display: inline-grid !important; }
  .only-mobile-inline { display: inline; }
  .only-desktop { display: none !important; }
  .toast { bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); }
  .ph h1 { font-size: 28px; }
  .grid-eq { grid-template-columns: minmax(0, 1fr); }
  .kpi .val { font-size: 32px; }
  input[type=text], input[type=search], input[type=password], input[type=number], input[type=email], select, textarea { font-size: 16px; }
  /* tabele jako karty */
  table.dt.cards thead { display: none; }
  table.dt.cards, table.dt.cards tbody, table.dt.cards tr, table.dt.cards td { display: block; width: 100%; }
  table.dt.cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
  table.dt.cards tbody tr:last-child { border-bottom: 0; }
  table.dt.cards td { padding: 0; border: 0; text-align: left !important; }
  table.dt.cards td.mcol { display: block; }
  table.dt.cards td[data-m="title"] { grid-column: 1; font-weight: 600; font-size: 15px; }
  table.dt.cards td[data-m="aside"] { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right !important; }
  table.dt.cards td[data-m="sub"] { grid-column: 1; color: var(--muted); font-size: 13px; }
  table.dt.cards td[data-m="full"] { grid-column: 1 / -1; margin-top: 4px; }
  table.dt.cards td[data-m="hide"] { display: none; }
  table.dt.cards td[data-m="label"]::before { content: attr(data-label) ": "; color: var(--muted); }
  table.dt.cards td[data-m="label"] { grid-column: 1 / -1; font-size: 13px; }
}
@media (max-width: 520px) {
  .kpis { gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .val { font-size: 28px; }
  .filters { gap: 8px; }
}
