/* apt-wifi — panel. Bez zewnętrznych zasobów (CSP: tylko 'self'). */
:root {
  --bg: #f4f5f7; --surface: #ffffff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #2f6fed; --accent-ink: #ffffff; --ok: #1f9d55; --ok-bg: #e6f6ec; --bad: #d64545; --bad-bg: #fdecec;
  --warn: #b7791f; --warn-bg: #fdf4e3; --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --surface: #1b1f29; --text: #e7eaf0; --muted: #949cad; --line: #2a303d;
    --accent: #5b8cff; --ok: #3fbf74; --ok-bg: #16301f; --bad: #ef6b6b; --bad-bg: #3a1c1f;
    --warn: #e0a64a; --warn-bg: #3a2e18; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
h1 { font-size: 1.5rem; margin: 0 0 .35rem; }
h2 { font-size: 1.08rem; margin: 0 0 .8rem; }
h3 { font-size: .8rem; margin: 0 0 .6rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar nav { display: flex; align-items: center; gap: 1rem; }
.who { color: var(--muted); }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.brand.big { font-size: 1.45rem; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; position: relative;
  background: linear-gradient(135deg, var(--accent), #7aa5ff); }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border: 2px solid #fff; border-bottom-color: transparent;
  border-left-color: transparent; border-radius: 50%; transform: rotate(-45deg); }

.page { max-width: 1180px; margin: 0 auto; padding: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem 1.35rem; margin-bottom: 1.1rem; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.1rem; margin-bottom: 1.1rem; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.grid .card { margin: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; margin-bottom: 1.1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.2rem; }
.tile-num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.tile-label { color: var(--muted); }
.tile.ok .tile-num { color: var(--ok); }
.tile.bad { border-color: var(--bad); background: var(--bad-bg); }
.tile.bad .tile-num { color: var(--bad); }

.btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: .5rem .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.warn { color: var(--warn); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: .3rem .65rem; font-size: .9em; }
.btn.wide { width: 100%; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

input, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .7rem; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form label, .login label { display: block; margin-bottom: .8rem; color: var(--muted); font-size: .9em; }
.form label input, .form label textarea, .login label input { display: block; width: 100%; margin-top: .25rem; color: var(--text); font-size: 1rem; }
.pw { display: flex; gap: .4rem; margin-top: .25rem; }
.pw input { margin: 0 !important; flex: 1; }

.flash { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: var(--ok-bg); border-color: var(--ok); }
.flash-error { background: var(--bad-bg); border-color: var(--bad); }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; vertical-align: middle; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.status { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status.on { color: var(--ok); } .status.on i { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.status.off { color: var(--bad); } .status.off i { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.status small { font-weight: 400; color: var(--muted); margin-left: .2rem; }
.status.big { font-size: 1rem; }

.meter { display: inline-block; width: 64px; height: 7px; border-radius: 4px; background: var(--line); vertical-align: middle; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); }
.meter.low span { background: var(--bad); }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.list-head h2 { margin: 0; }
.list-tools { display: flex; gap: .6rem; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { font: inherit; border: 0; background: var(--surface); color: var(--muted); padding: .42rem .8rem; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
#search { min-width: 220px; }

table.routers { width: 100%; border-collapse: collapse; }
.routers th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.routers td { padding: .75rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.routers tr.row { cursor: pointer; }
.routers tr.row:hover td { background: var(--bg); }
.routers tr.is-offline td { background: color-mix(in srgb, var(--bad-bg) 55%, transparent); }
.routers .num { text-align: right; }
.lokal { display: flex; flex-direction: column; color: var(--text); }
.lokal-id { font-weight: 700; }
.lokal-name { color: var(--muted); font-size: .9em; }
.empty { color: var(--muted); padding: 1.5rem 0 .5rem; text-align: center; }
.foot { text-align: center; font-size: .85em; }

.pending { border-color: var(--warn); }
.pending-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .75rem 0; border-top: 1px solid var(--line); }
.pending-info { flex: 1 1 300px; display: flex; flex-direction: column; gap: .15rem; }

.back { display: inline-block; margin-bottom: .8rem; }
.head-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.head-name { font-weight: 400; color: var(--muted); font-size: 1.1rem; margin-left: .3rem; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.offline-note { margin: .9rem 0 0; padding: .7rem .9rem; border-radius: 8px; background: var(--bad-bg); }

.stat dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem .9rem; margin: 0; }
.stat dt { color: var(--muted); }
.stat dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.stat dd:has(.meter), .routers td[data-f="mem"] { white-space: nowrap; }
.stat .meter { width: 48px; }

.clients { width: 100%; border-collapse: collapse; }
.clients th, .clients td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); }
.clients th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sig { font-weight: 600; } .sig.good { color: var(--ok); } .sig.mid { color: var(--warn); } .sig.weak { color: var(--bad); }
.log { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .8rem; max-height: 420px;
  overflow: auto; font-size: .8rem; white-space: pre-wrap; margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .45rem 0 .45rem 1.1rem; border-bottom: 1px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: 0; top: .9rem; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.timeline li.online::before { background: var(--ok); } .timeline li.offline::before { background: var(--bad); }
.timeline .t { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .3rem; }

.danger { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }

.login { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(380px, 100%); }
.login-card .muted { margin-top: .2rem; }

@media (max-width: 760px) {
  .page { padding: 1rem; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .routers thead { display: none; }
  .routers, .routers tbody, .routers tr, .routers td { display: block; width: 100%; }
  .routers tr.row { border: 1px solid var(--line); border-radius: 10px; margin-bottom: .7rem; overflow: hidden; }
  .routers td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .4rem .8rem; text-align: right; }
  .routers td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .routers td:first-child { padding-top: .7rem; }
  .routers td:first-child::before { content: none; }
  .lokal { text-align: left; }
  .grid.two { grid-template-columns: 1fr; }
}
