/* myRemDe - warstwa wizualna panelu */

:root {
  --bg:        #0f1115;
  --bg-soft:   #151922;
  --card:      #171b24;
  --card-2:    #1d222d;
  --line:      #262c3a;
  --line-soft: #1f2531;
  --text:      #e6e9ef;
  --muted:     #8d97a8;
  --dim:       #616b7d;
  --accent:    #38bdf8;
  --accent-dk: #0ea5e9;
  --ok:        #34d399;
  --warn:      #fbbf24;
  --danger:    #f87171;
  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0; }
p  { margin: 0 0 12px; }
code { font-family: var(--mono); font-size: .92em; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny  { font-size: 11.5px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.danger { color: var(--danger); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 58px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  background: linear-gradient(140deg, var(--accent), #6366f1);
}
.topbar nav { display: flex; gap: 4px; margin-right: auto; }
.topbar nav a {
  color: var(--muted); padding: 6px 12px; border-radius: 8px; font-size: 14px;
}
.topbar nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.topbar nav a.is-active { background: var(--card-2); color: var(--text); }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------ wybor jezyka */
.lang-menu { position: relative; font-size: 12.5px; }
.lang-menu summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: 8px; color: var(--muted); font-weight: 600; letter-spacing: .03em;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover, .lang-menu[open] summary { background: var(--card-2); color: var(--text); }
.lang-icon {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 1.5px solid currentColor; position: relative;
}
.lang-icon::before, .lang-icon::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
}
.lang-icon::before { border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: scaleX(.45); }
.lang-icon::after  { border-top: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: scaleY(.45); }
.lang-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; min-width: 150px; box-shadow: var(--shadow);
}
.lang-list a {
  display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); font-size: 13.5px; font-weight: 400;
}
.lang-list a:hover { background: var(--card); text-decoration: none; }
.lang-list a.is-active { color: var(--accent); }
.auth-lang { display: flex; justify-content: center; margin-top: 14px; }
.auth-lang .lang-list { right: auto; left: 50%; transform: translateX(-50%); }

.app-main { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head p { margin: 0; }
.back { color: var(--muted); font-size: 13px; display: inline-block; margin-bottom: 6px; }

/* ------------------------------------------------------------------ karty */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

/* ---------------------------------------------------------------- przyciski */
.btn {
  --btn-bg: var(--card-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--btn-bg); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 15px; border-radius: var(--radius-sm);
  cursor: pointer; transition: filter .12s, background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.18); text-decoration: none; }
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-primary { --btn-bg: var(--accent-dk); border-color: transparent; color: #04121c; font-weight: 600; }
.btn-secondary { --btn-bg: transparent; border-color: var(--line); }
.btn-ghost { --btn-bg: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card-2); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 4px 9px; font-size: 16px; line-height: 1; }
.btn-block { width: 100%; }
.linklike {
  background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0;
}
.linklike:hover { text-decoration: underline; }

/* ------------------------------------------------------------------- pola */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font: inherit; font-size: 14px; resize: vertical; min-height: 80px;
}
.field textarea:focus { outline: none; border-color: var(--accent); }
.field input, .field select {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent-dk);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--muted); margin: 4px 0 18px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent-dk); flex: none; }

/* ------------------------------------------------------------------ alerty */
.alert { padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: rgba(248,113,113,.09); border-color: rgba(248,113,113,.35); color: #fca5a5; }
.alert-ok    { background: rgba(52,211,153,.09);  border-color: rgba(52,211,153,.32); color: #6ee7b7; }
.alert-warn  { background: rgba(251,191,36,.09);  border-color: rgba(251,191,36,.32); color: #fcd34d; }

/* ------------------------------------------------------------ ekrany logowania */
body.auth { display: grid; place-items: center; padding: 24px; }
.auth-main { width: 100%; max-width: 400px; }
.auth-card { box-shadow: var(--shadow); padding: 32px 28px; margin: 0; }
.auth-card h1 { text-align: center; font-size: 21px; margin-bottom: 6px; }
.auth-card > .muted { text-align: center; margin-bottom: 22px; font-size: 13.5px; }
.auth-logo {
  width: 46px; height: 46px; margin: 0 auto 16px; border-radius: 13px;
  background: linear-gradient(140deg, var(--accent), #6366f1);
  position: relative;
}
.auth-logo::after {
  content: ''; position: absolute; inset: 13px 11px 15px; border: 2px solid rgba(255,255,255,.92); border-radius: 3px;
}
.auth-logo-mail::after {
  inset: 15px 11px; border-radius: 2px;
  background: linear-gradient(135deg, transparent 46%, rgba(255,255,255,.92) 46%, rgba(255,255,255,.92) 54%, transparent 54%);
}
.center-card { max-width: 420px; margin: 60px auto; text-align: center; }

/* pola na kod 2FA */
.code-input { display: flex; gap: 8px; justify-content: center; margin: 6px 0 18px; }
.code-input input {
  width: 46px; height: 56px; text-align: center; font-family: var(--mono);
  font-size: 24px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.code-input input:focus { border-color: var(--accent-dk); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
.code-input input.filled { border-color: #35506b; }

/* ------------------------------------------------------------ lista urzadzen */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* --- grupy (kategorie), tagi, komentarze ------------------------------- */
.device-group { margin-bottom: 28px; }
.device-group[hidden] { display: none; }
.group-title {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 15px; font-weight: 600;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.group-count {
  font-size: 11.5px; font-weight: 500; color: var(--dim); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
}
.tag-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 10px; }
.tag-filter > span { min-width: 72px; }
.tag-filter + .tag-filter { margin-top: 0; }
.tag-filter:last-of-type { margin-bottom: 22px; }
.group-title { cursor: pointer; }
.group-title:hover { color: var(--accent); }
.tag {
  display: inline-block; background: var(--card); border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-size: 12px; line-height: 1; padding: 5px 9px; border-radius: 999px; cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.tag:hover { color: var(--text); border-color: var(--accent); }
.tag.is-active { background: var(--accent); border-color: var(--accent); color: #06202d; font-weight: 600; }
.pick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: -8px 0 12px; }
.pick-row .tag { font-size: 11.5px; }
.device-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 0; }
.device-tags .tag { background: var(--card-2); }
.device-notes {
  margin: -4px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--muted);
  border-left: 3px solid var(--line); padding: 2px 0 2px 10px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.device[hidden] { display: none; }

/* --- przeciaganie (kolejnosc) ------------------------------------------- */
.drag-handle {
  cursor: grab; color: var(--dim); font-size: 15px; line-height: 1; user-select: none;
  padding: 2px 3px; border-radius: 5px; flex: none;
}
.drag-handle:hover { color: var(--text); background: var(--card-2); }
.drag-handle:active { cursor: grabbing; }
.group-title .drag-handle { font-size: 14px; }
.group-toggle {
  margin-left: auto; background: none; border: 1px solid transparent; color: var(--dim); font: inherit;
  font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 5px; cursor: pointer; flex: none;
  transition: transform .15s, color .12s;
}
.group-toggle:hover { color: var(--text); background: var(--card-2); }
.device-group.is-collapsed .group-toggle { transform: rotate(-90deg); }
.device-group.is-collapsed .device-grid { display: none; }
.device-group.is-collapsed { margin-bottom: 16px; }
.is-dragging { opacity: .45; outline: 2px dashed var(--accent); outline-offset: 2px; }

/* --- widok listy: ten sam HTML karty ulozony w jeden wiersz --------------- */
.head-actions { display: flex; align-items: center; gap: 10px; }
.view-switch .seg-btn { padding: 6px 11px; font-size: 12.5px; }
body.view-list .device-grid { display: flex; flex-direction: column; gap: 6px; }
body.view-list .device {
  flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 9px 14px;
}
body.view-list .device header { width: 230px; flex: none; }
body.view-list .device-meta {
  display: flex; flex-wrap: wrap; gap: 3px 18px; flex: 1 1 320px; min-width: 0; font-size: 12.5px;
}
body.view-list .device-meta > div { justify-content: flex-start; gap: 5px; min-width: 0; }
body.view-list .device-meta dt::after { content: ':'; }
body.view-list .device-meta dd { text-align: left; max-width: 300px; }
body.view-list .device-tags { margin: 0; flex: none; }
body.view-list .device-notes, body.view-list .standby-note { display: none; }
body.view-list .device footer { margin: 0; flex: none; flex-direction: row; align-items: center; gap: 6px; }
body.view-list .device footer .btn { padding: 6px 11px; font-size: 13px; }
body.view-list .device footer .btn-block { width: auto; display: inline-flex; }
body.view-list .split-actions { display: flex; gap: 6px; }
body.view-list .split-actions .btn { flex: none; }
body.view-list .btn-pop { padding: 6px 7px; }
@media (max-width: 900px) {
  body.view-list .device header { width: 100%; }
  body.view-list .device footer { width: 100%; }
}
.device { margin: 0; display: flex; flex-direction: column; gap: 14px; }
.device header { display: flex; align-items: center; gap: 10px; }
.device-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device.is-pending { border-style: dashed; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dim); }
.dot-online  { background: var(--ok);   box-shadow: 0 0 0 3px rgba(52,211,153,.16); }
.dot-offline { background: var(--dim); }
.dot-pending { background: var(--warn); box-shadow: 0 0 0 3px rgba(251,191,36,.14); }
/* Czuwanie: urzadzenie jest osiagalne, ale pelny klient jest wylaczony. */
.dot-standby { background: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,.16); }

.device-meta { margin: 0; display: grid; gap: 7px; font-size: 13px; }
.device-meta > div { display: flex; justify-content: space-between; gap: 12px; min-width: 0; }
.device-meta dt { color: var(--dim); flex: none; }
/* min-width: 0 pozwala elementowi flex zmniejszyc sie ponizej szerokosci tresci -
   bez tego dlugie opisy systemu wystawaly poza karte. */
.device-meta dd { margin: 0; min-width: 0; text-align: right; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-meta dd[title] { cursor: help; }
.device footer { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.device footer > .btn:not(.btn-block) { flex: 1; }
.device footer:has(> .btn:not(.btn-block) + .btn) { flex-direction: row; }
.split-actions { display: flex; gap: 8px; }
.split-actions .btn { flex: 1; }

.standby-note {
  margin: 0; padding: 9px 11px; font-size: 12.5px; line-height: 1.5;
  color: #a5b4fc; background: rgba(129,140,248,.08);
  border: 1px solid rgba(129,140,248,.22); border-radius: var(--radius-sm);
}

#standby-options { transition: opacity .15s; }
#standby-options .field { margin-bottom: 6px; }
#standby-options .tiny { margin: 0 0 14px; }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; min-width: 190px; box-shadow: var(--shadow);
}
.menu-list button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: var(--text); font: inherit; font-size: 13.5px; padding: 7px 10px;
  border-radius: 6px; cursor: pointer;
}
.menu-list button:hover { background: var(--card); }

.empty { text-align: center; padding: 46px 24px; }
.empty h2 { margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.empty-art {
  width: 64px; height: 44px; margin: 0 auto 18px; border-radius: 8px;
  border: 2px dashed var(--line); position: relative;
}
.empty-art::after {
  content: ''; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 2px; background: var(--line);
}

/* ------------------------------------------------------------------ modal */
.modal {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: var(--radius); padding: 24px; width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(4,6,10,.66); backdrop-filter: blur(2px); }
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.enroll-result { margin-top: 8px; }
.enroll-code {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.enroll-code code { font-size: 17px; letter-spacing: 2px; color: var(--accent); flex: 1; word-break: break-all; }

/* ------------------------------------------------------------- instalacja */
.install-step { display: flex; gap: 16px; align-items: flex-start; }
.step-no {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
  background: var(--card-2); border: 1px solid var(--line); color: var(--accent);
}
.step-body { flex: 1; min-width: 0; }
.cmd {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  overflow-x: auto; white-space: pre; margin: 10px 0; position: relative; color: #cbd5e1;
}
.cmd[data-copyable] { cursor: pointer; }
.cmd[data-copyable]:hover { border-color: #35506b; }
.tabs { display: flex; gap: 4px; margin: 12px 0 4px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; padding: 7px 12px; cursor: pointer; margin-bottom: -1px;
}
.tab.is-active { color: var(--text); border-bottom-color: var(--accent-dk); }
.tab-panel { display: none; padding-top: 12px; }
.tab-panel.is-active { display: block; }
.dl-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; font-size: 13.5px; }
.dl-list li { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 9px; padding: 9px 12px; }
.wait-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); margin: 10px 0; }

/* ------------------------------------------------------------------ tabele */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; color: var(--dim); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.kv { display: grid; gap: 8px; margin: 0; font-size: 14px; }
.kv > div { display: flex; gap: 14px; }
.kv dt { color: var(--dim); min-width: 90px; }
.kv dd { margin: 0; }

/* ------------------------------------------------------- ekran zdalny */
body.app:has(.remote) { overflow: hidden; }
/* Ekran sesji zajmuje cale okno; gorna belka strony chowa sie, bo inaczej
   zaslania pasek narzedzi sesji (oba siedza na gorze, belka ma wyzszy z-index). */
body.app:has(.remote) .topbar { display: none; }
.remote { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #08090c; }
.remote-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px; min-height: 50px; flex: none; flex-wrap: wrap;
  background: var(--bg-soft); border-bottom: 1px solid var(--line); z-index: 10;
}
.remote-bar .back { margin: 0; font-size: 18px; color: var(--muted); }
.remote-title { font-weight: 600; font-size: 14px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg-btn {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px;
  padding: 5px 14px; border-radius: 7px; cursor: pointer;
}
.seg-btn.is-active { background: var(--card-2); color: var(--text); }
.conn-state { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); margin-right: auto; }
.remote-tools { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.remote-tools .btn { white-space: nowrap; }
/* Przycisk "w nowym oknie" obok Pulpit/Konsola na liscie urzadzen. */
.btn-pop { padding: 7px 9px; font-size: 13px; line-height: 1; }
.split-actions .btn-pop, footer .btn-pop { flex: none; }

.remote-stage { flex: 1; position: relative; overflow: hidden; }
.stage-view { position: absolute; inset: 0; display: none; }
.stage-view.is-active { display: block; }

.screen-wrap { width: 100%; height: 100%; display: grid; place-items: center; background: #08090c; position: relative; }
#screen { max-width: 100%; max-height: 100%; display: block; outline: none; image-rendering: auto; cursor: none; }
#screen.show-cursor { cursor: default; }
/* Kursor rysowany nad obrazem w miejscu, gdzie wyslano wskaznik. Zdalny pulpit w
   trybie kiosku zwykle ukrywa wlasny kursor, wiec bez tego nie widac, gdzie sie klika. */
.remote-cursor {
  position: absolute; left: 0; top: 0; width: 22px; height: 30px; pointer-events: none; z-index: 5;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 30'><path d='M2 1.5 L2 22 L7.2 17.2 L10.8 26 L14.6 24.4 L11 15.8 L18 15.8 Z' fill='%23ffffff' stroke='%23000000' stroke-width='1.6' stroke-linejoin='round'/></svg>") no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.7));
  will-change: transform;
}
.remote-cursor[hidden] { display: none; }
.screen-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; gap: 14px;
  align-content: center; background: rgba(8,9,12,.86); color: var(--muted); font-size: 14px; text-align: center; padding: 24px;
}
.screen-overlay[hidden] { display: none; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.term-wrap { width: 100%; height: 100%; padding: 8px 4px 4px 10px; background: #0b0d11; }

.stats-panel, .keys-panel {
  position: absolute; top: 58px; right: 14px; z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow); font-size: 13px; min-width: 220px;
}
.stats-panel h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); }
.stats-panel dl { margin: 0; display: grid; gap: 6px; }
.stats-panel dl > div { display: flex; justify-content: space-between; gap: 16px; }
.stats-panel dt { color: var(--dim); }
.stats-panel dd { margin: 0; font-family: var(--mono); font-size: 12px; }
.stats-panel p { margin: 10px 0 0; }
.keys-panel { padding: 0; min-width: 0; overflow: hidden; }
.keys-head {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; cursor: move;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); user-select: none;
}
.keys-head span { margin-right: auto; }
.keys-collapse {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 15px; line-height: 1;
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer;
}
.keys-collapse:hover { background: var(--card-2); color: var(--text); }
.keys-body { display: grid; gap: 5px; padding: 0 10px 10px; }
.keys-body button {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 8px; cursor: pointer; text-align: left;
}
.keys-body button:hover { filter: brightness(1.2); }
/* Zwiniety: zostaje tylko waski pasek z naglowkiem. */
.keys-panel.is-collapsed .keys-body { display: none; }
.keys-panel.is-collapsed .keys-head { padding-right: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow);
  z-index: 100; animation: toast-in .18s ease-out;
}
.toast.is-error { border-color: rgba(248,113,113,.4); color: #fca5a5; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .topbar nav a { padding: 6px 9px; }
  .topbar-user > span { display: none; }
  .app-main { padding: 20px 14px 48px; }
  .device-grid { grid-template-columns: 1fr; }
  .remote-bar { gap: 8px; padding: 6px 8px; }
  .remote-title { display: none; }
  .install-step { flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ---------------------------------------------------------- administracja */
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; margin-left: 6px; vertical-align: middle; border: 1px solid; }
.badge-warn { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.35); color: #fcd34d; }
.badge-info { background: rgba(14,165,233,.12); border-color: rgba(14,165,233,.35); color: #7dd3fc; }
.badge-ok   { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.32); color: #6ee7b7; }
.subnav { display: flex; gap: 4px; margin: 0 0 18px; flex-wrap: wrap; }
.subnav a { padding: 7px 12px; border-radius: var(--radius-sm); color: var(--muted); font-size: 13.5px; }
.subnav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.subnav a.is-active { background: var(--card-2); color: var(--text); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--dim); }
.version-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.table-wrap { overflow-x: auto; }
.select-sm { font-size: 13px; padding: 4px 8px; border-radius: var(--radius-sm); background: var(--card-2); color: var(--text); border: 1px solid var(--line-soft); }
tr.is-inactive td { opacity: .55; }
.form-inline-col { display: grid; gap: 10px; max-width: 420px; }
code.pw { font-size: 15px; padding: 2px 6px; background: var(--card-2); border-radius: 4px; user-select: all; }

.badge-btn { cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; line-height: 1.5; }
.badge-btn:hover { filter: brightness(1.2); }
.modal-wide { width: min(680px, 94vw); }
.help-block { margin-top: 14px; }
.help-block h3 { font-size: 14px; margin: 0 0 6px; }
.help-block .cmd { white-space: pre; overflow-x: auto; }

.perm-box { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: var(--card-2); }
.perm-box h3 { font-size: 14px; margin: 0 0 8px; }
.perm-steps { margin: 8px 0 10px 18px; font-size: 13.5px; color: var(--muted); display: grid; gap: 6px; }
.perm-steps strong, .perm-steps code { color: var(--text); }
.perm-box kbd { font-family: inherit; font-size: 12px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); color: var(--text); }
