/* Panel feedów – jasny, prosty, whitesmoke. */
:root {
    --bg: #f5f5f5;
    --card: #ffffff;
    --line: #e4e4e7;
    --text: #1f2328;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --ok: #15803d;      --ok-bg: #dcfce7;
    --warn: #a16207;    --warn-bg: #fef3c7;
    --err: #b91c1c;     --err-bg: #fee2e2;
    --grey-bg: #f0f0f2;
    --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; font-weight: 650; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 6px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.danger-text { color: var(--err); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 60px; }

/* Górny pasek */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); font-size: 17px; }
.brand span { font-weight: 400; color: var(--muted); }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 18px; flex-wrap: wrap; }
.top nav a { color: var(--text); }
.top nav a.muted { color: var(--muted); }

/* Nagłówek strony */
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Karty */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.cards .card { margin-bottom: 0; }
.cards + form { margin-top: 16px; }
.narrow { max-width: 760px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.stack > * + * { margin-top: 12px; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 12px; color: var(--muted); }
.stats b { color: var(--text); }
.stat-warn, .stat-warn b { color: var(--warn); }

/* Przyciski */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--card); color: var(--text); font: inherit; font-size: 14px;
    cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--grey-bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--err); border-color: #fecaca; }
.btn.danger:hover { background: var(--err-bg); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Formularze */
label { display: block; font-weight: 550; font-size: 13.5px; }
input, select, textarea {
    display: block; width: 100%; margin-top: 4px;
    padding: 8px 10px; border: 1px solid #d4d4d8; border-radius: 8px;
    background: #fff; color: var(--text); font: inherit; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
textarea { resize: vertical; }
input[type=checkbox] { display: inline-block; width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: var(--accent); }
input[type=file] { padding: 6px; background: var(--bg); }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.input-row { display: flex; gap: 8px; margin-top: 4px; }
.input-row input { margin-top: 0; }
.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.counter { font-size: 12px; color: var(--muted); font-weight: 400; float: right; }
.counter.over { color: var(--warn); font-weight: 600; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 260px; }

/* Pola do kopiowania */
.copy { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.copy-label { flex: 0 0 auto; min-width: 54px; font-size: 13px; color: var(--muted); }
.copy-label { min-width: 120px; }
.copy input { margin: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--muted); background: var(--bg); min-width: 0; }

/* Komunikaty */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: var(--ok-bg); border-color: #bbf7d0; color: #14532d; }
.flash-warn { background: var(--warn-bg); border-color: #fde68a; color: #713f12; }
.flash-err { background: var(--err-bg); border-color: #fecaca; color: #7f1d1d; }

/* Plakietki */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 550; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-muted { background: var(--grey-bg); color: var(--muted); }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.pbg-ok { color: var(--ok); }
.pbg-err { color: var(--err); }
.pbg-warn { color: var(--warn); }

/* Zakładki */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--text); }
.tabs a span { color: var(--muted); font-size: 13px; }
.tabs a.active { background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--card); }

/* Tabele */
.table-card { padding: 0; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.items th, .items td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.items th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafafa; }
.items tr:last-child td { border-bottom: 0; }
.items tbody tr:hover { background: #fafafa; }
.items tr.inactive .title { color: var(--muted); text-decoration: line-through; }
.items .check { width: 36px; padding-right: 0; }
.items .film { min-width: 260px; }
.items .title { font-weight: 600; color: var(--text); }
.items .ext { margin-left: 4px; font-size: 13px; }
.thumb { width: 104px; }
.thumb img { display: block; width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--grey-bg); }
.no-img { display: flex; align-items: center; justify-content: center; width: 96px; height: 54px; border-radius: 6px; background: var(--err-bg); color: var(--err); font-size: 12px; }
.problems { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12.5px; }
.problems li { padding-left: 14px; position: relative; margin-top: 2px; }
.problems li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 6px; height: 6px; border-radius: 50%; }
.p-error { color: var(--err); } .p-error::before { background: var(--err); }
.p-warn { color: var(--warn); } .p-warn::before { background: #eab308; }
.p-info { color: var(--muted); } .p-info::before { background: #a1a1aa; }
.mini { font-size: 13.5px; }
.mini th, .mini td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.raw { font-size: 12.5px; }
.raw th, .raw td { padding: 6px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; vertical-align: top; }
.raw th { background: #fafafa; font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }
.raw .cell { max-width: 320px; max-height: 6.2em; overflow: hidden; }
.section-title { padding: 16px 16px 0; margin: 0; }
.table-card .hint, .table-card > .form-actions { padding: 0 16px; }
.table-card > .form-actions { padding-bottom: 16px; }

/* Postęp pobierania z PBG */
.progress { position: relative; flex: 1 1 200px; height: 26px; background: var(--grey-bg); border-radius: 6px; overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: #bfdbfe; transition: width .2s; }
.progress-text { position: relative; display: block; padding: 3px 10px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Formularz filmu */
.item-form { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.item-form > .card { margin-bottom: 0; }
.item-form .side .card { margin-bottom: 16px; }
.item-form .form-actions { grid-column: 1 / -1; margin-top: 0; }
.image-preview img { display: block; width: 100%; border-radius: 8px; background: var(--grey-bg); }
.image-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pick { padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font: inherit; font-size: 11px; color: var(--muted); text-align: center; }
.pick img { display: block; width: 100%; height: 56px; object-fit: cover; border-radius: 5px; margin-bottom: 3px; }
.pick:hover, .pick.selected { border-color: var(--accent); color: var(--accent); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.preview-text { background: var(--bg); border-radius: 8px; padding: 10px; margin: 0; }
.delete-form { margin-top: 24px; }
.danger-zone { border-color: #fecaca; }
.help p { margin: 0 0 10px; }

.sort-hint { color: var(--accent); font-weight: 700; }

/* Obrazek: źródło vs adres w feedzie */
.feed-image { background: var(--bg); border-radius: 8px; padding: 10px; }
.feed-image .copy { margin-top: 6px; }
.feed-image p { margin: 4px 0 0; }
.origin-pbg { color: var(--ok); }
.origin-own { color: var(--accent); }
.origin-none { color: var(--err); }
.thumb-origin { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
.thumb img.sq { width: 64px; height: 64px; }
.square-preview { display: block; width: 160px; height: 160px; border-radius: 6px; margin: 6px 0 2px; }

/* Rozwijane karty (np. „Dodaj filmy z linków”) */
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "+"; display: inline-block; width: 18px; color: var(--accent); font-weight: 700; }
details.card[open] > summary::before { content: "−"; }
details.card[open] > summary { margin-bottom: 12px; }

/* Logowanie */
.login { max-width: 360px; margin: 60px auto; }
.login h1 { margin-bottom: 16px; }

@media (max-width: 900px) {
    .item-form { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .copy { flex-wrap: wrap; }
    .copy-label { width: 100%; }
    .copy input { flex: 1 1 0; }
    .input-row { flex-wrap: wrap; }
    h1 { font-size: 21px; }
}
.feed-image .copy-label { display: none; }
