:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --text: #18202f;
    --muted: #687385;
    --primary: #ffb703;
    --primary-dark: #d98d00;
    --line: #dce2ea;
    --online: #0c9f62;
    --offline: #d7263d;
    --timeout: #f59e0b;
    --shadow: 0 10px 30px rgba(22, 32, 55, 0.08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 64px;
    background: #111827;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 24px;
    box-shadow: var(--shadow);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.2px;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 40px; height: 40px; }
.login-logo { width: 72px; height: 72px; margin-bottom: 10px; }
.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}
.topbar nav a {
    color: #f9fafb;
    background: rgba(255,255,255,0.08);
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 14px;
}
.topbar nav a:hover { background: rgba(255,255,255,0.16); text-decoration: none; }
.danger-link { background: rgba(239,68,68,0.22)!important; }
.container { max-width: 1250px; margin: 24px auto; padding: 0 16px; }
.footer { text-align: center; color: var(--muted); padding: 30px 16px; font-size: 13px; }
h1 { margin-top: 0; font-size: clamp(28px, 4vw, 42px); }
h2 { margin-top: 0; }
.panel, .auth-card, .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.panel { padding: 20px; margin: 18px 0; }
.auth-card {
    max-width: 420px;
    margin: 60px auto;
    padding: 28px;
    text-align: center;
}
form label { display: block; text-align: left; font-weight: 700; margin: 10px 0 6px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}
textarea { min-height: 80px; }
button {
    border: 0;
    border-radius: 12px;
    padding: 11px 16px;
    background: var(--primary);
    color: #111827;
    font-weight: 800;
    cursor: pointer;
    margin-top: 12px;
}
button:hover { background: var(--primary-dark); color: #fff; }
button.danger { background: #ef4444; color: #fff; }
.grid-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}
.grid-form .full { grid-column: 1 / -1; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 4px; }
.inline-form input { min-width: 170px; }
.cards {
    display: grid;
    grid-template-columns: repeat(6, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.card { padding: 18px; }
.card span { color: var(--muted); display: block; font-size: 13px; margin-bottom: 8px; }
.card strong { display: block; font-size: 24px; }
.card.online { border-color: rgba(12,159,98,.35); }
.card.offline { border-color: rgba(215,38,61,.35); }
.status {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}
.status.ONLINE { background: rgba(12,159,98,.12); color: var(--online); }
.status.OFFLINE { background: rgba(215,38,61,.12); color: var(--offline); }
.status.TIMEOUT { background: rgba(245,158,11,.14); color: var(--timeout); }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.list { display: grid; gap: 10px; }
.list-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}
.list-item:hover { text-decoration: none; border-color: var(--primary); }
.muted { color: var(--muted); }
.token-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: #111827;
    color: #fff;
    padding: 14px;
    border-radius: 12px;
    overflow-wrap: anywhere;
    margin: 12px 0;
}
.alert { padding: 12px; border-radius: 12px; margin: 12px 0; text-align: left; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.success { background: #dcfce7; color: #166534; }
pre {
    overflow-x: auto;
    background: #111827;
    color: #f9fafb;
    padding: 14px;
    border-radius: 12px;
}
.hive-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.hive-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    background: #fff;
}
.hive-card h3 { margin: 0 0 8px; }
.hive-card p { margin: 5px 0; color: var(--muted); }
@media (max-width: 950px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .cards { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
    .grid-form { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .cards { grid-template-columns: 1fr; }
    .topbar { padding: 10px 14px; }
    .topbar nav a { font-size: 13px; padding: 7px 8px; }
}

/* Aktualizacja v2 — zakładki, mniejsze wykresy i historia w osobnej karcie */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.tab-button { margin: 0; background: #ffffff; border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.tab-button.active { background: var(--primary); border-color: var(--primary); color: #111827; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.chart-grid-small { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.chart-card h3 { margin: 0 0 8px; font-size: 16px; }
.measurement-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.measurement-grid div { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fff; }
.measurement-grid span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.measurement-grid strong { font-size: 18px; }
.compact-table th, .compact-table td { padding: 8px 8px; font-size: 13px; }
details.panel summary { cursor: pointer; font-weight: 800; }
