:root {
  --bg: #0a0406;
  --panel: #13090d;
  --raised: #1a0d12;
  --line: #2b161d;
  --red: #b3002f;
  --red-hi: #d4184a;
  --pink: #ff4d7e;
  --leaf: #7bc51f;
  --text: #f5e9ec;
  --muted: #a58b93;
  --side: 268px;
  --side-c: 78px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(900px 500px at 8% -10%, rgba(179, 0, 47, .16), transparent 60%),
    radial-gradient(700px 400px at 100% 110%, rgba(179, 0, 47, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif; margin: 0; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--raised); font-weight: 600; transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease);
}
.btn:hover { background: #231219; border-color: #3a1d27; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--red-hi), var(--red)); border-color: #e0305f55; box-shadow: 0 8px 28px -10px rgba(212, 24, 74, .7); }
.btn.primary:hover { background: linear-gradient(180deg, #e32657, #c10a38); }
.btn.danger { background: #2a0a14; border-color: #5a1226; color: #ff8aa6; }
.btn.danger:hover { background: #3a0e1c; }
.btn.sm { padding: 8px 14px; border-radius: 10px; font-size: 14px; }

/* ---------- logowanie ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.auth::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 260px;
  background: url(/assets/banner.png) center / cover; opacity: .55;
  -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent);
}
.auth-card {
  position: relative; width: min(440px, 100%); background: rgba(19, 9, 13, .88); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 22px; padding: 38px 34px 30px; text-align: center;
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, .9);
  animation: rise .6s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-logo { width: 92px; height: 92px; margin: 0 auto 14px; filter: drop-shadow(0 12px 28px rgba(212, 24, 74, .55)); }
.auth-card h1 { font-size: 34px; }
.auth-card p { color: var(--muted); margin: 8px 0 0; }
.auth-card .btn { width: 100%; margin-top: 26px; padding: 14px 18px; }
.auth-card .hint { font-size: 13px; margin-top: 16px; }
.alert { margin-top: 20px; padding: 12px 14px; border-radius: 12px; background: #2a0a14; border: 1px solid #5a1226; color: #ffb0c3; text-align: left; font-size: 14px; }
.who-mini { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; font-weight: 600; }
.who-mini img { width: 32px; height: 32px; border-radius: 50%; }
.code-boxes { display: flex; gap: 10px; justify-content: center; margin-top: 26px; }
.code-boxes input {
  width: 52px; height: 62px; text-align: center; font-size: 26px; font-weight: 700; font-family: "Bricolage Grotesque", sans-serif;
  background: var(--raised); border: 1px solid var(--line); border-radius: 14px; color: var(--text); caret-color: var(--pink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.code-boxes input:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 77, 126, .15); }
.code-boxes.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.meta-line { display: flex; justify-content: space-between; margin-top: 18px; color: var(--muted); font-size: 14px; }
.meta-line b { color: var(--text); font-variant-numeric: tabular-nums; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; margin-top: 16px; padding: 4px; }
.link-btn:hover { color: var(--text); }

/* ---------- uklad panelu ---------- */
.shell { height: 100%; display: grid; grid-template-columns: var(--side) 1fr; transition: grid-template-columns .3s var(--ease); }
.shell.collapsed { grid-template-columns: var(--side-c) 1fr; }
.shell.no-anim, .shell.no-anim * { transition: none !important; }
.side {
  background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 16px 14px; min-width: 0; overflow: hidden;
}
.label { max-width: 190px; overflow: hidden; white-space: nowrap; opacity: 1; transition: max-width .3s var(--ease), opacity .2s var(--ease); }
.collapsed .label { max-width: 0; opacity: 0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 18px; min-height: 64px; }
.brand img { width: 40px; height: 40px; flex: none; }
.brand .label { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 22px; }
.brand .grow { flex: 1; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); flex: none; transition: color .15s, background .15s, transform .3s var(--ease); }
.icon-btn:hover { color: var(--text); background: var(--raised); }
.collapsed .collapse-btn { transform: rotate(180deg); }
.collapsed .brand { flex-direction: column; padding-bottom: 10px; }
.collapsed .brand .grow { display: none; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 15px; border-radius: 12px; color: var(--muted);
  border: 0; background: none; width: 100%; text-align: left; position: relative; font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-item:hover { background: var(--raised); color: var(--text); }
.nav-item.active { color: var(--text); background: linear-gradient(90deg, rgba(212, 24, 74, .22), rgba(212, 24, 74, .04)); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--pink); }
.me { display: flex; align-items: center; gap: 12px; padding: 14px 8px 10px; border-top: 1px solid var(--line); }
.me img { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--raised); }
.me strong { display: block; font-weight: 600; text-overflow: ellipsis; overflow: hidden; }
.logout { color: #ff8aa6; }
.logout:hover { background: #2a0a14; color: #ffb0c3; }

.content { overflow-y: auto; padding: 28px clamp(16px, 3vw, 40px) 48px; min-width: 0; }
.page { max-width: 980px; margin: 0 auto; }
.page-head {
  display: flex; align-items: center; gap: 20px; padding: 24px 28px; border-radius: 20px; border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(10, 4, 6, .94) 20%, rgba(10, 4, 6, .35)), url(/assets/banner.png) center / cover;
}
.page-head img { width: 62px; height: 62px; filter: drop-shadow(0 8px 20px rgba(212, 24, 74, .5)); }
.page-head h1 { font-size: 30px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; }
.search { flex: 1; position: relative; }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 12px 14px 12px 44px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font: inherit; }
.search input:focus { outline: none; border-color: var(--pink); }
.count { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* ---------- listy ---------- */
.list { margin-top: 12px; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); }
.toolbar + .list { margin-top: 0; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; min-height: 66px; }
.list .row:nth-child(even) { background: var(--raised); }
.row img.av { width: 42px; height: 42px; border-radius: 50%; flex: none; background: var(--raised); }
.row .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.row .grow { flex: 1; min-width: 0; }
.row .when { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; }
.badge { padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge.in { color: var(--leaf); background: rgba(123, 197, 31, .12); }
.badge.out { color: #ff8aa6; background: rgba(255, 77, 126, .12); }
.badge.bot { color: var(--muted); background: #ffffff10; margin-left: 8px; font-size: 11px; padding: 2px 8px; vertical-align: 2px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.more-note { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 1, 3, .72); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(660px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 50px 100px -30px #000; animation: pop .25s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head { display: flex; align-items: center; gap: 16px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.modal-head img { width: 64px; height: 64px; border-radius: 50%; }
.modal-head h2 { font-size: 22px; }
.modal-body { padding: 8px 24px 4px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 6px 16px; padding: 11px 0; border-bottom: 1px solid #ffffff0b; align-items: start; }
.kv:last-child { border: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; }
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.modal-foot { padding: 18px 24px 22px; border-top: 1px solid var(--line); display: grid; gap: 14px; }
.foot-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.foot-actions .push { margin-left: auto; }
.panel-inline { background: var(--raised); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 10px; animation: pop .2s var(--ease); }
.panel-inline .fields { display: flex; flex-wrap: wrap; gap: 10px; }
.field { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); font: inherit; min-width: 0; }
.field:focus { outline: none; border-color: var(--pink); }
select.field { cursor: pointer; }
.fields .grow { flex: 1; min-width: 160px; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 46px; height: 26px; border-radius: 999px; background: #2b1a20; border: 1px solid var(--line); position: relative; transition: background .2s var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .2s var(--ease), background .2s var(--ease); }
.switch input:checked + .track { background: var(--red); }
.switch input:checked + .track::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--pink); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

/* ---------- toasty ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 100; }
.toast { background: var(--raised); border: 1px solid var(--line); border-left: 3px solid var(--leaf); border-radius: 12px; padding: 12px 16px; max-width: 360px; box-shadow: 0 20px 40px -20px #000; animation: rise .3s var(--ease); }
.toast.err { border-left-color: var(--pink); }
.skeleton { height: 66px; background: linear-gradient(90deg, var(--panel), var(--raised), var(--panel)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 760px) {
  .shell { grid-template-columns: var(--side-c) 1fr; }
  .shell:not(.collapsed) { grid-template-columns: var(--side) 1fr; }
  .kv { grid-template-columns: 1fr; }
  .row .when { display: none; }
  .page-head { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
