/* Ciemne szkło w stylu LightService: poświata w tle, pigułki, fioletowy gradient. */
:root {
  color-scheme: dark;
  --page: #0c0f16; --surface: rgb(30 33 41 / .72); --surface2: rgb(42 45 55 / .85); --surface3: rgb(55 59 70 / .96);
  --line: rgb(210 218 235 / .08); --line2: rgb(210 218 235 / .15);
  --strong: #eef3ff; --text: #c3cfe6; --muted: #8593b0;
  --violet: #9d7bff; --violet-soft: rgb(123 77 255 / .17); --series: #9085e9;
  --good: #3ddc97; --warn: #f2c36b; --bad: #ff6b81;
  --shadow: 0 18px 50px rgb(0 0 0 / .38), inset 0 1px 0 rgb(225 230 240 / .07);
  --r: 18px; --ease: cubic-bezier(.2,.8,.2,1);
  font: 14px/1.5 "Inter", -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--text); }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% -8%, rgb(123 77 255 / .20), transparent 70%),
    radial-gradient(800px 520px at 100% 4%, rgb(47 107 255 / .15), transparent 70%),
    radial-gradient(700px 500px at 60% 110%, rgb(61 220 151 / .06), transparent 70%);
}
[hidden] { display: none !important; }
::selection { background: rgb(123 77 255 / .4); }
h1, h2 { color: var(--strong); margin: 0; font-weight: 650; }
h1 { font-size: 1.75rem; letter-spacing: -.025em; }
h2 { font-size: 1.02rem; }
b, strong, code { color: var(--strong); }
a { color: inherit; }
svg.icon { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.muted { color: var(--muted); margin: 2px 0 16px; font-size: .88rem; }

button, input, select, textarea, .button {
  font: inherit; color: var(--text); background: var(--surface2); border: 1px solid var(--line2);
  border-radius: 12px; min-height: 38px; padding: 0 15px; outline: none;
}
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 999px;
  cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none;
  transition: background .2s, color .2s, border-color .2s, transform .25s var(--ease), box-shadow .25s;
}
button:hover, .button:hover { background: var(--surface3); color: var(--strong); transform: translateY(-1px); }
button:active { transform: scale(.97); }
button.primary {
  background: linear-gradient(135deg, #a98bff, #7b4dff 55%, #5a2fd6); border-color: transparent; color: #fff; font-weight: 650;
  box-shadow: 0 8px 26px rgb(123 77 255 / .34), inset 0 1px 0 rgb(255 255 255 / .3);
}
button.primary:hover { box-shadow: 0 12px 34px rgb(123 77 255 / .48), inset 0 1px 0 rgb(255 255 255 / .35); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface2); color: var(--strong); }
button.danger { color: var(--bad); background: rgb(255 77 106 / .1); border-color: rgb(255 77 106 / .28); }
button.danger:hover { background: rgb(255 77 106 / .22); color: #fff; }
input:focus, select:focus, textarea:focus { border-color: rgb(157 123 255 / .6); box-shadow: 0 0 0 3px var(--violet-soft); }
select option { background: #161a24; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
label { display: grid; gap: 6px; font-weight: 550; color: var(--strong); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(160%); padding: 20px; min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--strong); font-weight: 700; font-size: 1.02rem; }
.brand span {
  font: 700 .85rem ui-monospace, monospace; color: #fff; border-radius: 9px; padding: 4px 7px;
  background: linear-gradient(135deg, #a98bff, #5a2fd6); box-shadow: 0 4px 16px rgb(123 77 255 / .45);
}

#loginView { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
#login { width: min(370px, 100%); display: grid; gap: 16px; padding: 34px; border-radius: 24px; }
#login .primary { min-height: 44px; margin-top: 6px; }

#app { --side: 232px; padding-left: var(--side); }
#app.collapsed { --side: 76px; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 10; width: var(--side); display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px; background: rgb(18 21 29 / .72); border-right: 1px solid var(--line); backdrop-filter: blur(18px) saturate(160%);
}
.sidebar .brand { padding: 2px 8px 22px; }
.brand em { font-style: normal; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
nav a, .sidebar > button {
  display: flex; align-items: center; justify-content: flex-start; gap: 12px; min-height: 42px; padding: 0 14px; border-radius: 14px;
  text-decoration: none; white-space: nowrap; color: var(--muted); font-weight: 550; transition: color .2s, background .2s;
}
.sidebar > button:hover { transform: none; }
nav a:hover { color: var(--strong); background: var(--surface2); }
nav a[aria-current] { color: var(--strong); background: var(--violet-soft); box-shadow: inset 0 0 0 1px rgb(157 123 255 / .35); }
nav a[aria-current] .icon { color: var(--violet); }
nav b { margin-left: auto; font-size: .72rem; background: var(--line); border-radius: 999px; padding: 0 7px; }
nav b:empty { display: none; }

@media (min-width: 901px) {
  .collapsed .sidebar span, .collapsed .brand em, .collapsed nav b { display: none; }
  .collapsed .brand span { display: inline; }
  .collapsed .sidebar .brand { justify-content: center; padding-inline: 0; }
  .collapsed nav a, .collapsed .sidebar > button { justify-content: center; padding: 0; }
  .collapsed #collapse .icon { rotate: 180deg; }
}

#app > main { max-width: 1280px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 36px) 70px; }
main > header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.tools, .actions, .bar, .chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tools .muted { margin: 0 6px 0 0; }
.bar { margin-bottom: 14px; }
.bar input { min-width: min(300px, 100%); border-radius: 999px; }
.chips { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; }
.chips button { min-height: 30px; padding: 0 12px; font-size: .84rem; background: transparent; border-color: transparent; color: var(--muted); }
.chips button:hover { color: var(--strong); transform: none; }
.chips button[aria-pressed=true] { background: var(--violet-soft); color: var(--strong); border-color: rgb(157 123 255 / .4); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { --tone: var(--violet); position: relative; overflow: hidden; transition: transform .3s var(--ease), border-color .3s; }
.kpi:hover { transform: translateY(-3px); border-color: var(--line2); }
.kpi:nth-child(2) { --tone: var(--good); }
.kpi:nth-child(3) { --tone: #5b9dff; }
.kpi:nth-child(4) { --tone: var(--warn); }
.kpi::after { content: ""; position: absolute; right: -45px; top: -55px; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(var(--tone), transparent 70%); opacity: .2; pointer-events: none; }
.kpi .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 550; }
.kpi .label .icon { color: var(--tone); }
.kpi strong { display: block; font-size: 2.4rem; line-height: 1.15; letter-spacing: -.035em; margin-top: 8px; }
.kpi small { display: block; color: var(--muted); }
.spark { position: absolute; right: 16px; bottom: 16px; width: 86px; height: 30px; fill: none; stroke: var(--tone); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a.kpi { display: block; color: inherit; text-decoration: none; cursor: pointer; }
a.kpi::before { content: "→"; position: absolute; right: 16px; top: 18px; color: var(--muted); opacity: 0; translate: -6px; transition: opacity .2s, translate .3s var(--ease); }
a.kpi:hover::before, a.kpi:focus-visible::before { opacity: 1; translate: 0; }
.row-button { flex: 1; display: flex; justify-content: space-between; gap: 12px; min-width: 0; min-height: 30px; margin: 0 -8px; padding: 0 8px; background: none; border: 0; border-radius: 10px; font-weight: 400; text-align: left; }
.row-button:hover { background: var(--violet-soft); transform: none; }
.row-button span { overflow: hidden; text-overflow: ellipsis; }
.links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.more.bad { color: var(--bad); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }

.columns { display: flex; align-items: flex-end; gap: 2px; height: 150px; border-bottom: 1px solid var(--line2); }
.column { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 6px 6px 0 0; }
.column i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #b3a8ff, var(--series) 35%, #6a5fd0); }
.column:hover { background: var(--violet-soft); }
.column:hover i { filter: brightness(1.2); }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .76rem; margin-top: 8px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 12px; align-items: center; padding: 6px 0; }
.hbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar div { background: var(--line); border-radius: 999px; overflow: hidden; }
.hbar i { display: block; height: 8px; min-width: 3px; border-radius: 999px; background: linear-gradient(90deg, #6a5fd0, var(--series)); }
.hbar b { font-variant-numeric: tabular-nums; }
details.data { margin-top: 10px; color: var(--muted); font-size: .84rem; }
details.data summary { cursor: pointer; }
details.data table { margin-top: 6px; }

.table { padding: 6px 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .2s; }
tbody tr:hover { background: rgb(210 218 235 / .035); }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--violet-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td small { display: block; color: var(--muted); }
.link-button { border: 0; background: none; padding: 0; min-height: 0; border-radius: 4px; color: var(--strong); font-weight: 600; text-align: left; }
.link-button:hover { background: none; color: var(--violet); transform: none; }

.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person > div { min-width: 0; }
.avatar {
  --h: 260; flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #fff; background: linear-gradient(135deg, hsl(var(--h) 70% 62%), hsl(calc(var(--h) + 40) 65% 40%));
}

.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 10px; font-size: .76rem; font-weight: 700; white-space: nowrap; background: color-mix(in srgb, currentColor 14%, transparent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.empty { color: var(--muted); padding: 26px 4px; text-align: center; }
.list { list-style: none; margin: 10px 0 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list small { color: var(--muted); white-space: nowrap; }
.list .link-button { overflow: hidden; text-overflow: ellipsis; }
.more { display: inline-block; margin-top: 12px; font-size: .86rem; color: var(--violet); text-decoration: none; }

dialog { border: 1px solid var(--line2); border-radius: 22px; background: rgb(26 29 38 / .96); color: var(--text); padding: 26px; width: min(420px, 94vw); box-shadow: 0 30px 80px rgb(0 0 0 / .6); }
dialog::backdrop { background: rgb(5 7 12 / .6); backdrop-filter: blur(5px); }
dialog form { display: grid; gap: 14px; }
dialog .actions { justify-content: flex-end; }
dialog.drawer { margin: 10px 10px 10px auto; height: calc(100dvh - 20px); max-height: calc(100dvh - 20px); width: min(470px, calc(100vw - 20px)); overflow-y: auto; }
.drawer h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 26px 0 6px; }
.drawer .top { display: flex; justify-content: space-between; gap: 12px; align-items: start; overflow-wrap: anywhere; }
.drawer .actions { justify-content: flex-start; }
.code { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid rgb(157 123 255 / .35); background: var(--violet-soft); border-radius: 16px; padding: 12px 16px; margin-top: 18px; }
.code code { font-size: 1.3rem; letter-spacing: .14em; }
.code + .actions { margin-top: 10px; }
.drawer input[type=number] { width: 90px; }

#toast { position: fixed; inset: auto auto 24px 50%; translate: -50%; margin: 0; padding: 0; border: 0; background: none; overflow: visible; }
#toast:popover-open { display: grid; gap: 8px; }
#toast p { margin: 0; padding: 11px 20px; border-radius: 999px; background: var(--surface3); border: 1px solid var(--line2); color: var(--strong); box-shadow: var(--shadow); }
#toast p.bad { background: #b52a45; color: #fff; }
#tip { position: fixed; pointer-events: none; background: var(--surface3); border: 1px solid var(--line2); color: var(--strong); padding: 6px 11px; border-radius: 10px; font-size: .82rem; z-index: 20; white-space: nowrap; box-shadow: var(--shadow); }

@media (max-width: 900px) {
  #app { padding-left: 0; }
  /* bez backdrop-filter: inaczej pasek byłby punktem odniesienia dla fixed i dolne menu wylądowałoby u góry */
  .sidebar { position: sticky; inset: 0 0 auto; width: auto; height: 60px; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 16px; border-right: 0; border-bottom: 1px solid var(--line); backdrop-filter: none; background: rgb(12 15 22 / .95); }
  .sidebar .brand { padding: 0; }
  #collapse { display: none !important; }
  nav {
    flex-direction: row; position: fixed; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 10; justify-content: space-between;
    padding: 6px; border-radius: 22px; background: rgb(26 29 38 / .97); border: 1px solid var(--line2); box-shadow: var(--shadow);
  }
  nav a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 2px; border-radius: 16px; font-size: .68rem; }
  nav b { display: none; }
  #app > main { padding-bottom: 110px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi strong { font-size: 2rem; }
  .spark { display: none; }
  #toast { bottom: 96px; }
}
@media (max-width: 700px), (pointer: coarse) { input, select, textarea { font-size: 16px; } }
@media (prefers-reduced-motion: no-preference) {
  [data-view] .card, #login { animation: rise .45s var(--ease) backwards; }
  [data-view] .card:nth-child(2) { animation-delay: .05s; }
  [data-view] .card:nth-child(3) { animation-delay: .1s; }
  [data-view] .card:nth-child(4) { animation-delay: .15s; }
  dialog[open] { animation: rise .25s var(--ease); }
  dialog.drawer[open] { animation: slide .3s var(--ease); }
  @keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } }
  @keyframes slide { from { opacity: 0; transform: translateX(40px); } }
}

.set-code { display: flex; gap: 8px; margin-top: 10px; }
.set-code input { flex: 1; min-width: 0; text-transform: uppercase; }
.set-code input::placeholder { text-transform: none; }
.note { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes { display: grid; gap: 8px; justify-items: start; }
.notes textarea { width: 100%; resize: vertical; border-radius: 14px; padding: 10px 14px; line-height: 1.5; }
.daily { margin-top: 16px; }
