/* Abrys Charakterystyka – wygląd jak Abrys Projekty: motyw ciemny (domyślny) – czarne tło, biały tekst, Calibri;
   jasny: [data-theme="light"]. Tokeny kolorów przeniesione z projekty.abrysarchitekci.com. */
:root {
  color-scheme: dark;
  --bg: #000000; --surface: #0e0e0e; --surface-2: #161616; --surface-3: #1e1e1e; --sunken: #0a0a0a;
  --border: #262626; --border-strong: #3a3a3a; --hover-border: #555555;
  --text: #ffffff; --text-2: #d6d6d6; --muted: #8f8f8f; --placeholder: #666666; --primary-hover: #d9d9d9;
  --focus: rgba(255, 255, 255, .25); --shadow: rgba(0, 0, 0, .8);
  --danger: #ff6b5e; --danger-bg: rgba(255, 107, 94, .13);
  --warn: #f2b24c; --warn-bg: rgba(242, 178, 76, .13);
  --ok: #5fd08a; --ok-bg: rgba(95, 208, 138, .12);
  --info: #7fb2ff; --info-bg: rgba(127, 178, 255, .12);
  --bar: #d6d6d6;
  --radius: 8px;
  font-family: Calibri, Carlito, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f2f2f2; --surface-3: #e8e8e8; --sunken: #f7f7f7;
  --border: #e0e0e0; --border-strong: #bdbdbd; --hover-border: #8a8a8a;
  --text: #000000; --text-2: #262626; --muted: #666666; --placeholder: #9a9a9a; --primary-hover: #333333;
  --focus: rgba(0, 0, 0, .2); --shadow: rgba(0, 0, 0, .18);
  --danger: #c4291d; --danger-bg: rgba(196, 41, 29, .09);
  --warn: #9a5b00; --warn-bg: rgba(154, 91, 0, .1);
  --ok: #17803f; --ok-bg: rgba(23, 128, 63, .1);
  --info: #1d5bb8; --info-bg: rgba(29, 91, 184, .09);
  --bar: #262626;
}
:root[data-theme="light"] .logo-img { filter: invert(1); }

* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; line-height: 1.4; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: .01em; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 12.5px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
p { margin: 0 0 8px; }
small, .maly, .muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
::selection { background: var(--text); color: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- logo ---------- */
.logo-img { display: block; max-width: 100%; height: auto; }
.logo-text { font-weight: 700; letter-spacing: .28em; font-size: 22px; color: var(--text); }
.brand-sub { display: block; font-size: 11.5px; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }

/* ---------- logowanie ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .logo-img { max-width: 240px; max-height: 90px; margin: 0 auto; }
.login-brand .logo-text { font-size: 34px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 13px; color: var(--text-2); }
.login-note { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.form-error { color: var(--danger); font-size: 14px; }
.form-error:empty { display: none; }

/* ---------- układ ---------- */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 26px 22px 24px; text-decoration: none; }
.brand .logo-img { max-width: 150px; max-height: 46px; }
#nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px; flex: 1; overflow-y: auto; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 6px; color: var(--muted); font-weight: 700; text-decoration: none; position: relative; }
#nav a:hover { color: var(--text); background: var(--surface-2); }
#nav a.active { color: var(--text); background: var(--surface-3); }
#nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; background: var(--text); border-radius: 0 3px 3px 0; }
#nav a .licznik { margin-left: auto; font-weight: 400; font-size: 13px; }
#nav svg { width: 18px; height: 18px; flex: none; }
#nav .nav-sep { height: 1px; background: var(--border); margin: 10px 6px; }
#nav .nav-tytul { padding: 4px 12px 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { padding: 16px 18px; border-top: 1px solid var(--border); }
.me { display: flex; gap: 10px; align-items: center; }
.me b { display: block; font-weight: 700; }
.me small { color: var(--muted); }
.side-links { display: flex; gap: 16px; margin-top: 12px; font-size: 13.5px; flex-wrap: wrap; }
.side-links a { color: var(--muted); text-decoration: none; }
.side-links a:hover { color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--text); color: var(--bg); display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700; flex: none; }
main { padding: 30px 36px 80px; min-width: 0; max-width: 1520px; }
main:focus { outline: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions select { width: auto; max-width: 260px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters input[type=search] { max-width: 330px; }
.filters select { width: auto; max-width: 260px; }

/* ---------- przyciski ---------- */
.btn, button.glowny, button.male, button.dodaj {
  border: 1px solid var(--border-strong); background: transparent; color: var(--text); padding: 7px 14px; border-radius: 6px;
  font: inherit; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn:hover, button.male:hover { background: var(--surface-3); border-color: var(--hover-border); }
.btn.primary, button.glowny { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover, button.glowny:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 94, .4); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm, button.male { padding: 3px 9px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn:disabled, button:disabled { opacity: .5; cursor: default; }
button.dodaj { border-style: dashed; color: var(--text-2); margin-top: 8px; font-weight: 700; }
button.dodaj:hover { border-color: var(--hover-border); color: var(--text); }
button.usun { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 8px; border-radius: 6px; }
button.usun:hover { background: var(--danger-bg); color: var(--danger); }
label.btn { cursor: pointer; }

/* ---------- formularze ---------- */
input[type="text"], input[type="search"], input[type="password"], input:not([type]), select, textarea {
  font: inherit; color: var(--text); border: 1px solid var(--border-strong); border-radius: 6px; padding: 7px 10px;
  background: var(--sunken); width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--text); }
select option { background: var(--surface); color: var(--text); }
textarea { resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--text); }
input.zle { border-color: var(--danger); background: var(--danger-bg); }
.siatka { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.pole { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.pole.szer { grid-column: 1 / -1; }
.pole .etyk { font-size: 13px; font-weight: 700; color: var(--text-2); }
.pole .wej { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pole .jedn { color: var(--muted); font-size: 13px; white-space: nowrap; }
.pole.check { flex-direction: row; align-items: flex-start; gap: 8px; padding-top: 22px; cursor: pointer; color: var(--text-2); }
.pole.check input { flex: none; margin: 2px 0 0; }
.tab-lub { display: flex; gap: 6px; width: 100%; min-width: 0; }
.tab-lub select { flex: 1; }
.tab-lub input { width: 96px; flex: none; }

/* ---------- karty ---------- */
.karta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.karta > h2:first-child { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.info { background: var(--surface-2); border-left: 3px solid var(--border-strong); padding: 9px 13px; border-radius: 4px; margin: 6px 0 14px; font-size: 14px; color: var(--text-2); }
.info.uwaga { background: var(--warn-bg); border-color: var(--warn); }
.info.zle { background: var(--danger-bg); border-color: var(--danger); white-space: pre-wrap; }
.info.ok { background: var(--ok-bg); border-color: var(--ok); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- odznaki ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.zle { background: var(--danger-bg); color: var(--danger); }
.chip.uwaga { background: var(--warn-bg); color: var(--warn); }
.chip.neutral { background: var(--surface-3); color: var(--text-2); }
.chip.info { background: var(--info-bg); color: var(--info); }
.wsk { font-variant-numeric: tabular-nums; }

/* ---------- tabele ---------- */
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table.lista th, table.wyniki th { text-align: left; font-weight: 700; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  padding: 11px 12px; border-bottom: 1px solid var(--border); background: var(--sunken); white-space: nowrap; }
table.lista td, table.wyniki td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.lista tbody tr:last-child td, table.wyniki tbody tr:last-child td { border-bottom: 0; }
table.lista td small { display: block; }
table.lista tbody tr[data-open] { cursor: pointer; }
table.lista tbody tr[data-open]:hover { background: var(--surface-2); }
.karta.flush { padding: 0; overflow: hidden; }
table.edycja th { font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: left; padding: 4px; white-space: nowrap; }
table.edycja td { padding: 3px 4px; vertical-align: middle; }
table.edycja td input[type="text"] { min-width: 70px; }
table.edycja td.szeroka input, table.edycja td.szeroka select { min-width: 170px; }
table.edycja td.akcje { width: 1%; white-space: nowrap; }
table.edycja tbody tr { border-top: 1px solid var(--border); }

/* ---------- pozycje rozwijane ---------- */
details.pozycja { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--surface); }
details.pozycja > summary { list-style: none; cursor: pointer; padding: 9px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
details.pozycja > summary::-webkit-details-marker { display: none; }
details.pozycja > summary::before { content: "›"; color: var(--muted); font-size: 18px; line-height: 1; transition: transform .15s; }
details.pozycja[open] > summary::before { transform: rotate(90deg); }
details.pozycja > summary:hover { background: var(--surface-2); }
details.pozycja > summary .nazwa { font-weight: 700; }
details.pozycja > summary .opis { color: var(--muted); font-size: 14px; }
details.pozycja > summary .prawo { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--text-2); }
details.pozycja > .wnetrze { padding: 6px 14px 14px; border-top: 1px solid var(--border); }
details.pozycja details.pozycja { background: var(--sunken); }

/* ---------- wyniki ---------- */
.kafle { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kafel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 18px; }
.kafel .etyk { color: var(--muted); font-size: 14px; }
.kafel .wart { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.kafel .jedn { font-size: 13px; color: var(--muted); }
.kafel.glowny { border-color: var(--hover-border); }
.kafel.zle .wart { color: var(--danger); }
.pasek { position: relative; height: 8px; background: var(--surface-3); border-radius: 4px; min-width: 120px; }
.pasek > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--bar); }
.pasek > span.zle { background: var(--danger); }
.pasek > i { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--warn); }
.raport { font-size: 14px; }
.raport table { margin: 8px 0 14px; font-size: 13px; }
.raport th, .raport td { border: 1px solid var(--border); padding: 4px 7px; text-align: left; }
.raport th { background: var(--sunken); color: var(--muted); }
.raport td.p { text-align: right; font-variant-numeric: tabular-nums; }
.raport h1 { font-size: 20px; margin-top: 8px; }
.raport h2 { font-size: 16px; margin-top: 20px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.raport h3 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 14px; }
.raport blockquote { margin: 6px 0; padding: 6px 10px; background: var(--warn-bg); border-left: 3px solid var(--warn); }
.raport hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
textarea.json { font: 12.5px/1.45 "Cascadia Mono", Consolas, monospace; min-height: 60vh; }

/* ---------- stan zapisu ---------- */
.zapis { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.zapis::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.zapis.trwa::before { background: var(--warn); }
.zapis.blad::before { background: var(--danger); }

/* ---------- motyw, komunikaty ---------- */
.theme-toggle { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer;
  display: grid; place-items: center; padding: 0; box-shadow: 0 2px 10px var(--shadow); }
.theme-toggle:hover { border-color: var(--text); }
.theme-toggle svg { width: 20px; height: 20px; }
#toasts { position: fixed; bottom: 72px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); font-weight: 700; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 24px var(--shadow); animation: tin .2s ease-out; max-width: 420px; }
.toast.err { background: var(--danger); color: var(--bg); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsywność ---------- */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 16px 16px 10px; }
  #nav { flex-direction: row; flex-wrap: wrap; padding: 4px 8px 10px; }
  #nav .nav-sep, #nav .nav-tytul { display: none; }
  #nav a.active::before { display: none; }
  .side-foot { display: none; }
  main { padding: 18px 16px 80px; }
  .kafel .wart { font-size: 26px; }
}
@media print {
  :root { color-scheme: light; }
  html, body, .karta, .kafel, th, td { background: #fff !important; color: #000 !important; }
  .sidebar, .actions, .filters, #toasts, .theme-toggle { display: none !important; }
  #app { display: block; }
  main { padding: 0; }
}

/* lista pogrupowana wg projektów z Abrys Projekty */
table.lista.grupy tr.grupa td { background: var(--surface-2); border-bottom: 1px solid var(--border); padding-top: 12px; }
table.lista.grupy tr.grupa.pusta { cursor: pointer; }
table.lista.grupy tr.grupa.pusta td { background: transparent; }
table.lista.grupy tr.grupa.pusta:hover td { background: var(--surface-2); }
table.lista.grupy tr.podrzedny td:first-child { padding-left: 32px; }
.grupa-tyt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grupa-tyt .numer { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.lista td .btn.sm + .btn.sm, table.lista td a.btn.sm { margin-left: 4px; }
table.lista.grupy td.num { white-space: nowrap; }
table.lista.grupy tr.grupa td:nth-child(2) { white-space: nowrap; }
