:root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --ink: #1c2430;
    --muted: #6a7686;
    --line: #e2e6ec;
    --accent: #2f6fed;
    --ok: #1a7f45;
    --err: #c0392b;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .6rem; }
pre {
    background: #10151d; color: #e6edf5; padding: .7rem .9rem;
    border-radius: var(--radius); overflow-x: auto; font-size: .85rem;
}
code { font-size: .9em; }
small { display: block; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.small { font-size: .82rem; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--err); font-weight: 600; }
.empty { color: var(--muted); padding: 1.2rem 0; }

/* układ */
.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    background: var(--panel); border-bottom: 1px solid var(--line);
    padding: .7rem 1.25rem; flex-wrap: wrap;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: .2rem 0; }
.topbar nav a.is-active { color: var(--ink); border-bottom: 2px solid var(--accent); }
.topbar__user { margin-left: auto; display: flex; gap: .8rem; align-items: center; color: var(--muted); font-size: .9rem; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.auth-body { display: grid; place-items: center; min-height: 100vh; }
.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.75rem; width: min(420px, 92vw);
}
.card--wide { width: min(680px, 94vw); margin: 2rem auto; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.page-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* formularze */
label { display: block; margin: .75rem 0; font-size: .88rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select, textarea {
    display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem;
    border: 1px solid var(--line); border-radius: 6px; background: #fff;
    font: inherit; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.checkbox { display: flex; align-items: center; gap: .5rem; color: var(--ink); }
.checkbox input { width: auto; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }
.form-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; margin: 1.25rem 0;
}
.form-card.danger { border-color: #f0c9c4; }
.inline { display: inline; }
.inline-form { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.inline-form input { width: auto; margin: 0; }

.btn {
    display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent);
    padding: .45rem .9rem; border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn--danger { background: var(--err); border-color: var(--err); }
.link-muted {
    background: none; border: 0; padding: 0; color: var(--muted);
    cursor: pointer; font: inherit; text-decoration: underline;
}
.link-danger { color: var(--err); }

/* komunikaty */
.alert { padding: .7rem .9rem; border-radius: var(--radius); margin: 0 0 1rem; border: 1px solid var(--line); background: var(--panel); }
.alert--ok { border-color: #b9e2c8; background: #f0fbf4; color: #14562f; }
.alert--error { border-color: #f2c4bd; background: #fdf3f2; color: #8c2b1f; }
.alert--info { border-color: #c7d8fb; background: #f2f6ff; color: #1b3f8f; }
.warn { color: var(--err); }

/* kafelki */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin: 1.25rem 0 .5rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.tile__value { display: block; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile__label { color: var(--muted); font-size: .8rem; }

/* tabele */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; }
.table th { background: #fafbfc; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-muted td { opacity: .55; }
.table .url { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: .75rem; justify-content: flex-end; }
.table-scroll { overflow-x: auto; }
.table--matrix td, .table--matrix th { white-space: nowrap; }
.cell--top3 { background: #e6f7ec; font-weight: 600; }
.cell--top10 { background: #f2f8ff; }
.cell--none { color: var(--muted); }
.cell--empty { background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 4px, #f2f4f7 4px, #f2f4f7 8px); }

.badge { display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .75rem; background: #eef1f5; color: var(--muted); }
.badge--ok { background: #e6f7ec; color: var(--ok); }
.badge--error { background: #fdecea; color: var(--err); }

.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1rem 0; }
#chart { width: 100%; max-width: 100%; display: block; }

@media (max-width: 640px) {
    .page-head { flex-direction: column; }
    .table .url { max-width: 160px; }
}
