:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e5e9;
  --text: #1c1f24;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --error: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --border: #2b2f37;
    --text: #e8eaed;
    --muted: #9aa0a9;
    --accent: #4f8cff;
    --accent-soft: #1d2a44;
    --accent-text: #0b1220;
    --ok: #34d399;
    --error: #f87171;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0 0 12px; font-size: 1rem; }

.muted { margin: 4px 0 0; color: var(--muted); }
.small { font-size: .8rem; }

.card, .tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover { border-color: var(--muted); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }

/* --- strona główna: karta dokumentu --- */

.landing {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.doc-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 24px;
  display: grid;
  justify-items: center;
  text-align: center;
}

.doc-card h1 { font-size: 1.4rem; }

.doc-card .actions {
  justify-content: center;
  margin-top: 20px;
}

.doc-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 68px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .05em;
}

/* --- strona główna: podgląd PDF --- */

.viewer {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 1.15rem; }

.pdf-frame {
  flex: 1;
  min-height: 0;
}

.pdf-frame object {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.fallback {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  height: 100%;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
}

.fallback p { margin: 0; }

/* --- panel /admin --- */

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: grid;
  gap: 16px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: .8rem;
  color: var(--muted);
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status.online { color: var(--ok); }
.status.offline { color: var(--error); }

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-label { color: var(--muted); font-size: .9rem; }

.tile-value {
  font-size: 2.6rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

.tile-sub { color: var(--muted); font-size: .85rem; }
.tile-sub b { color: var(--text); font-variant-numeric: tabular-nums; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: .85rem; }
tbody tr:last-child td { border-bottom: none; }
td.zero { color: var(--muted); }

@media (max-width: 560px) {
  .container { padding-top: 20px; }
  .tiles { grid-template-columns: 1fr; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; text-align: center; }
}
