:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --text: #1c1b19;
    --muted: #6b6860;
    --border: #e4e1da;
    --accent: #1d4ed8;
    --accent-ink: #ffffff;
    --error-bg: #fdecea;
    --error-text: #9b1c1c;
    --success-bg: #e8f5ec;
    --success-text: #1f6b3a;
    --radius: 8px;
    --sidebar: 220px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; margin-bottom: 12px; }
.muted { color: var(--muted); }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 16px; height: 16px; border: 4px solid var(--accent); border-radius: 50%; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { padding: 7px 10px; border-radius: 6px; color: var(--text); }
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.is-active { background: var(--bg); font-weight: 600; }
.nav-link.is-disabled { color: var(--muted); opacity: .6; cursor: default; }
.nav-link.is-disabled:hover { background: none; }
.sidebar-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; padding: 0 10px; }

.content { flex: 1; min-width: 0; padding: 24px 32px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* komponenty */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-label { color: var(--muted); font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.flash { padding: 10px 14px; border-radius: 6px; }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-success { background: var(--success-bg); color: var(--success-text); }

.btn { display: inline-block; padding: 8px 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .7; cursor: progress; }

label { font-weight: 600; }
input[type=text], input[type=search], input[type=date], input[type=password], input[type=number], input[type=email], textarea, select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--surface);
}
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }

h3 { font-size: 14px; margin: 20px 0 8px; }
.prewrap { white-space: pre-wrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: inline-flex; align-items: center; gap: 12px; white-space: nowrap; }
td.actions { display: table-cell; text-align: right; }
td.actions > * { margin-left: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.empty { text-align: center; padding: 32px; }

/* zakładki */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--bg); font-size: 12px; text-align: center; }

/* tabele */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.card:not(.table-wrap) > .table { margin: 0 -20px; width: calc(100% + 40px); }

/* statusy */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-banned { background: var(--error-bg); color: var(--error-text); }
.badge-logged_out, .badge-warning { background: #fdf3dc; color: #7a5300; }
.badge-new { background: #e7eefb; color: #1e4b9b; }

/* formularze */
.form-layout { display: flex; flex-direction: column; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field-checkbox { justify-content: flex-end; }
.help { color: var(--muted); font-size: 12px; }
.form-errors { margin: 0; padding: 0; list-style: none; color: var(--error-text); font-size: 13px; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--error-text); }
.form-actions { display: flex; gap: 8px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.choice-group { border: 0; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px 18px; width: 100%; }
.choice-group legend { font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 4px; width: 100%; }
.inline-form { display: inline; margin: 0; }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); }
.btn-link:hover { text-decoration: underline; }
.btn-danger { color: var(--error-text); }
.btn.btn-danger:not(.btn-link) { border-color: var(--error-text); }
.keyword-form { display: grid; grid-template-columns: 2fr 1fr 2fr auto; gap: 0 16px; align-items: start; }
.keyword-form .field:last-child { padding-top: 22px; }

/* wątki */
.thread { padding: 12px 0; border-top: 1px solid var(--border); }
.thread:first-of-type { border-top: 0; padding-top: 0; }
.thread p { margin: 6px 0 0; }
.thread-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thread-head .actions { margin-left: auto; }
.thread.is-inactive { opacity: .6; }

.nowrap { white-space: nowrap; }
.small { font-size: 12px; word-break: break-all; }
.badge-check-ok { background: var(--success-bg); color: var(--success-text); }
.badge-check-banned { background: var(--error-bg); color: var(--error-text); }
.badge-check-logged_out { background: #fdf3dc; color: #7a5300; }
.page-head h1 .muted { font-weight: 400; }

/* noVNC */
.vnc-card { display: flex; flex-direction: column; gap: 12px; }
.vnc-card .section-head p { margin: 0; max-width: 70ch; }
.vnc-frame { width: 100%; aspect-ratio: 16 / 10; border: 1px solid var(--border); border-radius: 6px; background: #1c1b19; }

/* treści */
.filters { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.content-list { display: flex; flex-direction: column; gap: 12px; }
.post { display: flex; flex-direction: column; gap: 10px; }
.post-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.post-head .badge:last-child { margin-left: auto; }
.post-text { margin: 0; }
.post-media { display: flex; gap: 8px; flex-wrap: wrap; }
.post-media img { width: 120px; height: 120px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); }
.post-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.post-verdict { padding: 8px 12px; border-radius: 6px; background: var(--bg); }
.post-verdict.is-error { background: var(--error-bg); color: var(--error-text); }
.post .actions { flex-wrap: wrap; }
.badge-platform { background: #1c1b19; color: #fff; }
.badge-content-accepted, .badge-run-succeeded { background: var(--success-bg); color: var(--success-text); }
.badge-content-rejected, .badge-run-failed { background: var(--error-bg); color: var(--error-text); }
.badge-content-candidate, .badge-run-running { background: #e7eefb; color: #1e4b9b; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; }
.search-form { display: flex; gap: 8px; }
.search-form select { width: auto; }
.stat-link { display: block; color: inherit; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.stat-card { color: inherit; }
.stat-card:hover { text-decoration: none; border-color: var(--accent); }
.stat-link:hover { text-decoration: none; border-color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* komentarze */
.generator { display: flex; flex-direction: column; gap: 8px; }
.generator p { margin: 0; }
.generator-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.generator-form label { display: flex; flex-direction: column; gap: 4px; }
.generator-form input[type=number] { width: 100px; }
.tabs-small .tab { padding: 6px 12px; font-size: 13px; }
.comment { display: flex; flex-direction: column; gap: 10px; }
.comment-post { margin: 0; padding: 8px 12px; border-left: 3px solid var(--border); background: var(--bg); border-radius: 0 6px 6px 0; font-size: 13px; }
.comment-post a { margin-left: 6px; }
.comment-text { margin: 0; font-size: 15px; }
.badge-comment-draft { background: #e7eefb; color: #1e4b9b; }
.badge-comment-generating, .badge-comment-queued, .badge-comment-publishing { background: #fdf3dc; color: #7a5300; }
.badge-comment-published { background: var(--success-bg); color: var(--success-text); }
.badge-comment-generation_failed, .badge-comment-failed { background: var(--error-bg); color: var(--error-text); }

.login-credentials { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.login-credentials details { display: inline-flex; gap: 8px; }
.login-credentials summary { cursor: pointer; color: var(--accent); }

.badge-stance-agree { background: var(--success-bg); color: var(--success-text); }
.badge-stance-disagree { background: #f3e8ff; color: #6b21a8; }

/* powiadomienia */
.nav-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav-counter { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--error-text); color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
.notifications { list-style: none; margin: 0; padding: 0; }
.notification { padding: 12px 0; border-top: 1px solid var(--border); }
.notification:first-child { border-top: 0; padding-top: 0; }
.notification p { margin: 6px 0; }
.notification.is-read { opacity: .6; }
.badge-notification-account_logged_out, .badge-notification-proxy_problem { background: #fdf3dc; color: #7a5300; }
.badge-notification-account_banned { background: var(--error-bg); color: var(--error-text); }

.add-url-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; }
.add-url-form label { display: flex; flex-direction: column; gap: 4px; }
.add-url-form label.checkbox { flex-direction: row; padding-bottom: 8px; }
.add-url-input { flex: 1 1 320px; }

/* instrukcja */
.help { display: flex; flex-direction: column; gap: 20px; max-width: 900px; }
.help h2 { font-size: 18px; }
.help p, .help li { line-height: 1.6; }
.help section { scroll-margin-top: 16px; }
.callout { padding: 12px 16px; border-left: 4px solid var(--accent); background: #eff6ff; border-radius: 0 6px 6px 0; }
.ui { display: inline-block; padding: 0 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--text); }
a.ui:hover { text-decoration: none; border-color: var(--accent); }
.steps, .flow, .toc { padding-left: 22px; }
.steps li, .flow li { margin-bottom: 6px; }
.checklist { padding-left: 20px; }
.checklist li { margin-bottom: 4px; }
.toc { columns: 2; column-gap: 32px; }
.progress-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.progress-list li { display: flex; align-items: center; gap: 10px; }
.progress-mark { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--muted); border: 1px solid var(--border); flex-shrink: 0; }
.progress-list li.is-done .progress-mark { background: var(--success-bg); color: var(--success-text); border-color: transparent; }
.progress-list li.is-done > a:first-of-type { color: var(--muted); }
.progress-list li.is-next .progress-mark { background: var(--accent); color: #fff; border-color: transparent; }
.progress-list li.is-next > a:first-of-type { font-weight: 700; }
.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; }
@media (max-width: 760px) {
    .toc { columns: 1; }
    .glossary { grid-template-columns: 1fr; }
    .glossary dd { margin-bottom: 8px; }
}

/* logowanie */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login-card .brand { margin-bottom: 8px; }
.login-card .btn { margin-top: 8px; }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--border); gap: 12px; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .content { padding: 16px; }
    .keyword-form { grid-template-columns: 1fr; }
    .keyword-form .field:last-child { padding-top: 0; }
}
.report-summary { display: flex; flex-direction: column; gap: 10px; }
.code-sample { margin: 8px 0 12px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; overflow-x: auto; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.bulk-bar select { width: auto; min-width: 240px; max-width: 100%; }
.filters input[type=search] { min-width: 260px; }
.check-col { width: 32px; }
.campaign-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }
.badge-campaign { background: #e7eefb; color: #1e4b9b; }
.badge-campaign.is-inactive { background: var(--bg); color: var(--muted); }
.badge-campaign:hover { text-decoration: none; filter: brightness(.96); }
.picker-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.picker-toolbar input[type=search] { flex: 1 1 260px; }
.picker-group { font-size: 14px; margin: 14px 0 6px; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 16px; max-height: 420px; overflow-y: auto; }
.picker-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; font-weight: 400; cursor: pointer; }
.picker-item:hover { background: var(--bg); }
.picker-item[hidden] { display: none; }
.picker-name { font-weight: 600; }
.small-text { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
