:root {
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #efede7;
  --border: #dddad2;
  --text: #1c1b19;
  --text-2: #52514e;
  --muted: #7a7872;
  --accent: #1f5f3f;          /* zieleń lampy bankierskiej z obrazka */
  --accent-ink: #ffffff;
  --series-invite: #2a78d6;
  --series-letter: #eb6834;
  --series-publish: #1baf7a;
  --good: #1d7a3a;
  --warning: #a86b00;
  --serious: #c2410c;
  --critical: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--series-invite); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
[hidden] { display: none !important; }

/* ---------- górny pasek ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--text); color: #fff;
}
header.top .brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
header.top .brand small { font-weight: 400; opacity: .7; margin-left: .4rem; }
nav.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
nav.tabs button {
  background: transparent; color: #d8d6cf; border: 0; padding: .45rem .8rem; border-radius: 7px; cursor: pointer; font: inherit;
}
nav.tabs button.active { background: #fff; color: var(--text); font-weight: 600; }
nav.tabs button:hover:not(.active) { background: rgba(255, 255, 255, .1); }
header.top .right { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .85rem; }
header.top .right a { color: #d8d6cf; }
.hermes-dot { display: inline-flex; align-items: center; gap: .35rem; }
.hermes-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.hermes-dot.ok::before { background: #3ecf7a; }
.hermes-dot.bad::before { background: #ff6b5e; }

main { padding: 1.25rem; max-width: 1500px; margin: 0 auto; }
section.tab { display: grid; gap: 1rem; }

/* ---------- karty ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- tablica kontrolna ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.dash-side { position: sticky; top: 70px; display: grid; gap: 1rem; }
.hero { padding: .75rem; text-align: center; }
.hero img { width: 100%; height: auto; display: block; }
.hero .caption { font-size: .85rem; color: var(--text-2); margin-top: .35rem; }
@media (max-width: 1000px) {
  .dash { grid-template-columns: 1fr; }
  .dash-side { position: static; grid-row: 1; grid-template-columns: 160px 1fr; }
}
@media (max-width: 520px) { .dash-side { grid-template-columns: 1fr; } .hero img { max-width: 220px; margin: 0 auto; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-2); font-size: .85rem; display: flex; align-items: center; gap: .4rem; }
.kpi .value { font-size: 1.9rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: .9rem; font-weight: 400; color: var(--muted); }
.kpi .bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: .5rem; overflow: hidden; }
.kpi .bar span { display: block; height: 100%; border-radius: 2px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

.chart-box { position: relative; height: 260px; }
.alerts { display: grid; gap: .4rem; }
.alert { display: flex; gap: .5rem; align-items: flex-start; padding: .5rem .7rem; border-radius: 8px; background: var(--surface-2); font-size: .9rem; }
.alert .ico { font-weight: 700; flex: none; }
.alert.critical { background: #fdeceb; } .alert.critical .ico { color: var(--critical); }
.alert.serious { background: #fdf0e7; } .alert.serious .ico { color: var(--serious); }
.alert.warning { background: #fdf6e3; } .alert.warning .ico { color: var(--warning); }
.alert.ok { background: #e9f5ec; } .alert.ok .ico { color: var(--good); }

/* ---------- tabele ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.day-sep td { border-top: 2px solid var(--border); }
td .clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.msg summary { cursor: pointer; color: var(--text-2); }
details.msg pre { white-space: pre-wrap; font-family: inherit; background: var(--surface-2); padding: .6rem; border-radius: 6px; margin: .4rem 0 0; }

.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.pill.wykonane, .pill.wyslano { background: #e3f3e7; color: var(--good); }
.pill.czesciowo { background: #fdf3dc; color: var(--warning); }
.pill.blad { background: #fde5e3; color: var(--critical); }
.pill.brak_wykonawcy { background: #fde9dc; color: var(--serious); }
.pill.w_toku { background: #e4eefb; color: #1f5fae; }
.kind-tag { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }

/* ---------- formularze ---------- */
input, select, textarea, button { font: inherit; }
input[type=text], input[type=number], input[type=time], input[type=password], select, textarea {
  border: 1px solid var(--border); border-radius: 7px; padding: .35rem .5rem; background: #fff; color: var(--text); max-width: 100%;
}
textarea { width: 100%; min-height: 260px; resize: vertical; line-height: 1.45; }
button, .btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 7px; padding: .4rem .8rem; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-block;
}
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: transparent; color: var(--critical); border: 1px solid #f0c4c0; }
button.link { background: none; color: var(--series-invite); padding: 0; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.field { display: grid; gap: .25rem; }
.field > span { font-size: .8rem; color: var(--text-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; align-items: end; }
.hint { font-size: .85rem; color: var(--muted); }
.toast { position: fixed; bottom: 1rem; right: 1rem; background: var(--text); color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; }

/* ---------- prompty ---------- */
.prompts { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1rem; }
@media (max-width: 800px) { .prompts { grid-template-columns: 1fr; } }
.prompt-list { display: grid; gap: .35rem; align-content: start; }
.prompt-list button { text-align: left; background: var(--surface-2); color: var(--text); border: 1px solid transparent; white-space: normal; }
.prompt-list button.active { border-color: var(--accent); background: #fff; }
.prompt-list .def { font-size: .75rem; color: var(--good); display: block; }

/* ---------- magazyn ---------- */
.series-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem; }
.series-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; background: #fff; display: grid; gap: .5rem; }
.series-card .next { display: flex; gap: .6rem; align-items: center; }
.series-card .next img { width: 72px; height: 48px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }
.tile { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.tile.off { opacity: .45; }
.tile .thumb { aspect-ratio: 16 / 9; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.tile .thumb img, .tile .thumb video { width: 100%; height: 100%; object-fit: cover; }
.tile .meta { padding: .5rem .6rem; display: grid; gap: .3rem; font-size: .85rem; }
.tile .meta .txt { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile.next-up { outline: 2px solid var(--series-publish); }

dialog { border: 0; border-radius: var(--radius); padding: 1.2rem; max-width: min(760px, 94vw); width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog img { max-width: 100%; border-radius: 6px; }

/* ---------- logowanie ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; width: min(360px, 100%); display: grid; gap: .6rem; text-align: center; box-shadow: var(--shadow); }
.login-card img { width: 180px; margin: 0 auto; }
.login-card input { width: 100%; padding: .55rem .7rem; }
.login-card .err { color: var(--critical); margin: 0; min-height: 1em; }

/* ---------- kalendarz publikacji (jak GitHub, jeden odcień) ---------- */
.cal-wrap { overflow-x: auto; padding-bottom: .25rem; }
.cal { display: inline-grid; grid-template-columns: auto; gap: 4px; font-size: .78rem; color: var(--text-2); }
.cal-months { display: grid; grid-auto-flow: column; grid-auto-columns: 20px; gap: 4px; margin-left: 30px; height: 1.1em; }
.cal-months span { white-space: nowrap; overflow: visible; }
.cal-body { display: flex; gap: 6px; }
.cal-days { display: grid; grid-template-rows: repeat(7, 20px); gap: 4px; width: 24px; }
.cal-days span { line-height: 20px; }
.cal-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 20px); grid-auto-columns: 20px; gap: 4px; }
.cal-cell { width: 20px; height: 20px; border-radius: 4px; background: #e8e6e0; }
.cal-cell.pub { background: #1d7a3a; }
.cal-cell.plan { background: transparent; box-shadow: inset 0 0 0 2px #1d7a3a; }
.cal-cell.future { background: #f1efea; }
.cal-cell.today { outline: 2px solid var(--text); outline-offset: 1px; }
.cal-cell.empty { visibility: hidden; }
.cal-legend { display: flex; gap: 1rem; align-items: center; margin-top: .5rem; font-size: .8rem; color: var(--text-2); flex-wrap: wrap; }
.cal-legend .cal-cell { display: inline-block; vertical-align: middle; margin-right: .3rem; width: 14px; height: 14px; }
.cal-tip { position: fixed; z-index: 60; background: var(--text); color: #fff; padding: .4rem .6rem; border-radius: 6px; font-size: .8rem; pointer-events: none; max-width: 260px; }

/* ---------- do załatwienia (pod obrazkiem) ---------- */
.todo-head { margin: .9rem 0 .4rem; font-weight: 600; font-size: .9rem; }
.todo { display: grid; gap: .4rem; }
.todo-item { display: grid; gap: .15rem; text-align: left; background: #fff; color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--series-letter); border-radius: 8px; padding: .5rem .65rem; white-space: normal; cursor: pointer; }
.todo-item.publish { border-left-color: var(--series-publish); }
.todo-item.run { border-left-color: var(--serious); }
.todo-item:hover { background: var(--surface-2); }
.todo-item .t { font-weight: 600; font-size: .88rem; }
.todo-item .s { font-size: .8rem; color: var(--text-2); }
.todo-item .act { font-size: .8rem; color: var(--accent); font-weight: 600; }

/* ---------- CRM ---------- */
.badge { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .2rem; border-radius: 999px; background: var(--critical);
  color: #fff; font-size: .75rem; font-weight: 700; line-height: 1.35em; text-align: center; }
.todo-item.reply { border-left-color: var(--critical); }
.prio { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.prio.wysoki { background: #fde5e3; color: var(--critical); }
.prio.sredni { background: #fdf3dc; color: var(--warning); }
.prio.niski { background: var(--surface-2); color: var(--text-2); }
.msg-card { border: 1px solid var(--border); border-left: 4px solid var(--critical); border-radius: 8px; padding: .7rem .8rem; background: #fff; display: grid; gap: .35rem; }
.msg-card.sredni { border-left-color: var(--warning); } .msg-card.niski { border-left-color: var(--border); }
.msg-card blockquote { margin: 0; padding: .5rem .7rem; background: var(--surface-2); border-radius: 6px; white-space: pre-wrap; }
.msg-list { display: grid; gap: .6rem; }
.timeline { display: grid; gap: .3rem; font-size: .85rem; border-left: 2px solid var(--border); padding-left: .7rem; margin: .4rem 0; }
