/* Styl konsoli – przeniesiony z makiety docs/konsola/panel.html (BT FATIX) */

:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --border: #d9ded7;
  --text: #1c2420;
  --muted: #5b6660;
  --accent: #2d5b4e;
  --accent-hover: #234a3f;
  --accent-ink: #ffffff;
  --accent-soft: #e2ece7;
  --ok: #2b7a4b;      --ok-bg: #e3f1e8;
  --warn: #8f5d00;    --warn-bg: #fbf0d9;
  --grace: #a3480f;   --grace-bg: #fbe6d8;
  --bad: #ad2a22;     --bad-bg: #f8e1df;
  --idle: #5f636b;    --idle-bg: #e8e9ec;
  --info: #285c86;    --info-bg: #e1ecf5;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 2px 8px rgba(20, 30, 25, .04);
  --radius: 8px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131815;
    --surface: #1b211e;
    --surface-2: #222a26;
    --border: #323b36;
    --text: #e3e8e4;
    --muted: #9aa69f;
    --accent: #7fb8a5;
    --accent-hover: #95c8b6;
    --accent-ink: #0f1a16;
    --accent-soft: #24352e;
    --ok: #7fcf9c;      --ok-bg: #1f3428;
    --warn: #e6bd6a;    --warn-bg: #3a2f17;
    --grace: #f0a070;   --grace-bg: #3d2618;
    --bad: #f08c84;     --bad-bg: #3e1f1d;
    --idle: #b2b6bd;    --idle-bg: #2a2d32;
    --info: #8fbbe0;    --info-bg: #1c2c3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  overflow-x: hidden;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 600; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* górny pasek */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner, .wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.topbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-mark { width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .8rem; font-family: var(--mono); }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--muted); flex-wrap: wrap; }
.who b { color: var(--text); font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .78rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }

/* granica danych */
.boundary { background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.boundary .wrap { display: flex; gap: 10px; align-items: flex-start; padding-top: 10px; padding-bottom: 10px; font-size: .88rem; }
.boundary svg { flex: none; margin-top: 2px; color: var(--accent); }

/* nawigacja */
nav.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 14px; }
nav.tabs a {
  text-decoration: none; color: var(--muted); padding: 8px 14px; border-radius: 6px; font-weight: 500; font-size: .92rem;
}
nav.tabs a:hover { background: var(--surface-2); color: var(--text); }
nav.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); }

main { padding-top: 16px; padding-bottom: 48px; }
.view[hidden] { display: none; }
.view-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }

/* panele */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .panel + .panel { margin-top: 0; }
.span-2 { grid-column: 1 / -1; }

/* kafelki stanów */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
/* lista instancji: 6 stanów (makieta miała 5) – jeden rząd na szerokim ekranie; węższe – reguły @media niżej */
.tiles.tiles-states { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; text-align: left;
  font: inherit; color: inherit; cursor: pointer; box-shadow: var(--shadow); min-width: 0;
}
.tile:hover { border-color: var(--accent); }
.tile[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: -1px; }
/* pojedynczy kafelek poza siatką (licznik objętych instancji w Aktualizacjach) – wcześniej ściśnięty w <p> */
.tile-count { display: inline-block; min-width: 160px; margin-bottom: 12px; }
.tile .n { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; display: block; }
.tile .l { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* filtry i formularze */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .field .lbl { font-size: .8rem; color: var(--muted); font-weight: 500; }
.filters .field { flex: 1 1 160px; }
.filters .field.grow { flex: 2 1 220px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.radio-list { display: flex; flex-direction: column; gap: 6px; }
.radio-list label, .check { display: flex; gap: 8px; align-items: flex-start; font-size: .92rem; color: var(--text); font-weight: 400; }
.radio-list input, .check input { width: auto; margin-top: 4px; }

/* przyciski */
.btn {
  font: inherit; font-size: .9rem; font-weight: 500; border-radius: 6px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* tabele */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: .8rem; }
.nowrap { white-space: nowrap; }
.list-table { min-width: 1100px; }
.list-table .col-name { min-width: 200px; }
.list-table .col-upd { min-width: 170px; }
.audit-table { min-width: 860px; }
.hist-table { min-width: 560px; }
.camp-table { min-width: 720px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* etykiety stanu */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 500; white-space: nowrap; }
.s-active  { color: var(--ok);    background: var(--ok-bg); }
.s-expiring{ color: var(--warn);  background: var(--warn-bg); }
.s-grace   { color: var(--grace); background: var(--grace-bg); }
.s-suspended { color: var(--bad); background: var(--bad-bg); }
.s-silent  { color: var(--idle);  background: var(--idle-bg); }
.s-info    { color: var(--info);  background: var(--info-bg); }
.d-active { background: var(--ok); } .d-expiring { background: var(--warn); } .d-grace { background: var(--grace); }
.d-suspended { background: var(--bad); } .d-silent { background: var(--idle); }
.hb-ok { color: var(--ok); } .hb-late { color: var(--warn); } .hb-lost { color: var(--bad); }

/* karta instancji */
.back { display: inline-block; margin-bottom: 10px; font-size: .88rem; }
.inst-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.inst-head h1 { overflow-wrap: anywhere; }
.inst-head .meta { color: var(--muted); font-size: .9rem; margin-top: 4px; overflow-wrap: anywhere; }
dl.kv { display: grid; grid-template-columns: minmax(120px, 42%) minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: .9rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 4px; max-width: 220px; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.meter.full > span { background: var(--warn); }
pre.payload {
  margin: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-family: var(--mono);
  font-size: .8rem; line-height: 1.5; overflow: auto; max-height: 360px; max-width: 100%;
}
.note { font-size: .84rem; color: var(--muted); margin: 10px 0 0; }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 12px; border-radius: 0 6px 6px 0; font-size: .88rem; }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); }

/* aktualizacje */
.upd-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.count-box { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.count-box .big { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips .chip { white-space: normal; overflow-wrap: anywhere; }
.chip.excluded { text-decoration: line-through; opacity: .7; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; font-size: .85rem; border: 0; background: var(--surface); color: var(--muted); padding: 5px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.preview { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.preview .bar { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; background: var(--warn-bg); color: var(--text); font-size: .9rem; }
.preview .bar svg { flex: none; margin-top: 3px; color: var(--warn); }
.preview .cap { padding: 6px 12px; font-size: .76rem; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--border); }
.select-list { max-height: 210px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.select-list[hidden] { display: none; }

/* okno dialogowe */
dialog {
  border: 1px solid var(--border); border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(15, 22, 19, .45); }
.dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; overflow-wrap: anywhere; }
.dlg-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.x { border: 0; background: none; font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }

/* komunikat po akcji */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 8px; font-size: .88rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

footer { color: var(--muted); font-size: .8rem; padding: 0 20px 28px; max-width: 1280px; margin: 0 auto; }

@media (max-width: 1080px) {
  .tiles, .tiles.tiles-states { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .upd-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .topbar-inner, .wrap { padding-left: 16px; padding-right: 16px; }
  footer { padding-left: 16px; padding-right: 16px; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .tiles, .tiles.tiles-states { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  td .badge { white-space: normal; } /* długi stan („Wygasła (tylko odczyt)”) nie wychodzi poza ekran telefonu */
  .tile .n { font-size: 1.3rem; }
  .who { margin-left: 0; width: 100%; }
  nav.tabs a { padding: 7px 10px; }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  dl.kv dd { margin-bottom: 8px; }
  .panel { padding: 14px; }
}

/* konsola – dodatki do makiety (CSP bez stylów w atrybutach) */
.narrow { max-width: 420px; margin: 24px auto; }
.callout { margin-bottom: 12px; }
.secret-block { white-space: pre; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.inline { display: inline; }
.hb-pre { white-space: pre-wrap; word-break: break-all; }
.narrow-wide { max-width: 720px; }
.panel form + form { margin-top: 16px; }
.qr-box { width: 200px; max-width: 100%; margin: 12px 0; background: #fff; padding: 6px; border-radius: 6px; }
