:root {
  --brand: #0a6ebd;
  --brand-dark: #084e87;
  --sun: #ffb703;
  --bg: #f3f6fa;
  --card: #ffffff;
  --text: #1f2a37;
  --muted: #6b7280;
  --border: #e5e9f0;
  --green: #1aa260;
  --green-bg: #e6f6ee;
  --amber: #d98800;
  --amber-bg: #fff4e0;
  --blue-bg: #e7f1fb;
  --red: #d64545;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); }

/* ---------- Logowanie ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  width: 100%;
  max-width: 380px;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(8, 78, 135, 0.35);
}
.brand {
  text-align: center;
  margin-bottom: 26px;
}
.brand .logo {
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0.5px;
  color: var(--brand);
}
.brand .logo .sun { color: var(--sun); }
.brand .tagline { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- Layout aplikacji ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .logo { font-weight: 800; font-size: 18px; color: var(--brand); }
.topbar .logo .sun { color: var(--sun); }
.topbar .user-box { display: flex; align-items: center; gap: 14px; }
.topbar .user-name { font-weight: 600; }
.topbar .role-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  background: var(--blue-bg); color: var(--brand-dark);
  padding: 2px 8px; border-radius: 20px;
}
.container { max-width: 1080px; margin: 0 auto; padding: 24px; }

/* ---------- Zakladki ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  background: transparent; border: 1px solid transparent;
  padding: 8px 16px; border-radius: 10px; font-weight: 600; color: var(--muted);
}
.tab.active { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }

/* ---------- Karty / siatki ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border-radius: 14px; padding: 18px 20px;
  box-shadow: var(--shadow); border-left: 4px solid var(--brand);
}
.stat-card.to_pay { border-left-color: var(--amber); }
.stat-card.future { border-left-color: var(--brand); }
.stat-card.paid { border-left-color: var(--green); }
.stat-card .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat-card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel {
  background: var(--card); border-radius: 14px; padding: 22px;
  box-shadow: var(--shadow); margin-bottom: 22px;
}
.panel h2 { margin: 0 0 16px; font-size: 17px; }
.panel h2 .hint { font-weight: 400; font-size: 13px; color: var(--muted); }

/* ---------- Formularze ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select {
  font-family: inherit; font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text);
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10,110,189,0.12); }

.btn {
  background: var(--brand); color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 15px;
}
.btn:hover { background: var(--brand-dark); }
.btn.full { width: 100%; }
.btn.secondary { background: #eef2f7; color: var(--text); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.green { background: var(--green); }
.btn.green:hover { background: #158a52; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #f0caca; }
.btn.danger:hover { background: #fdeeee; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Tabele ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; font-weight: 700; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: right; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.badge.to_pay { background: var(--amber-bg); color: var(--amber); }
.badge.future { background: var(--blue-bg); color: var(--brand-dark); }
.badge.paid { background: var(--green-bg); color: var(--green); }

.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- Komunikaty ---------- */
.msg { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; display: none; }
.msg.show { display: block; }
.msg.error { background: #fdeeee; color: var(--red); }
.msg.success { background: var(--green-bg); color: var(--green); }

.muted { color: var(--muted); }
.right { text-align: right; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Progi prowizji ---------- */
.tier-panel { border-top: 4px solid var(--sun); }
.tier-table tbody tr td:last-child { color: var(--brand-dark); }

/* ---------- Motywator (postęp do progów) ---------- */
.motivator { background: linear-gradient(135deg, #ffffff 0%, #f1f8ff 100%); border: 1px solid #d7e8fb; }
.moti-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.moti-stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.moti-stat .big { font-size: 24px; font-weight: 800; margin-top: 2px; }
.moti-stat .big.up { color: var(--green); }
.moti-hint { margin: 14px 0 0; font-size: 14px; background: #fff8e6; border: 1px solid #ffe2a8; padding: 10px 14px; border-radius: 10px; }

.tier-bars { display: flex; flex-direction: column; gap: 14px; }
.tier-bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.tier-bar-head .ok { color: var(--green); font-weight: 700; }
.progress { height: 12px; background: #e7eef6; border-radius: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--brand) 0%, var(--sun) 100%); border-radius: 8px; transition: width .4s ease; }
.progress-fill.done { background: var(--green); }

/* ---------- Banner managera ---------- */
.readonly-banner {
  background: #fff4e0; border: 1px solid #ffd98a; color: #8a5a00;
  padding: 10px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px;
}

/* ---------- Logo ---------- */
.login-logo { max-width: 230px; height: auto; display: block; margin: 0 auto 6px; }
.topbar-logo { height: 38px; width: auto; }
.terms-logo { max-width: 240px; height: auto; display: block; margin: 0 auto 10px; }

/* logo marki w wierszu tabeli — stale, jednakowe wymiary dla kazdego logo */
.op-logo { width: 42px; height: 42px; object-fit: contain; vertical-align: middle; display: block; border-radius: 6px; background: #fff; }

/* badge touroperatora */
.tour-badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px;
  background: #eef2f7; color: var(--brand-dark); white-space: nowrap; }

/* male pola edycji w wierszu (stawka/prog biura) */
input.mini { display: inline-block; width: auto; padding: 5px 8px; font-size: 13px; }
.office-only { transition: opacity .15s; }

/* ---------- Operator (kolory wierszy opcjonalnie) ---------- */
.bonus-panel { border-top: 4px solid var(--sun); }
.bonus-row { display: grid; grid-template-columns: minmax(180px, 1fr) 2fr; gap: 22px; align-items: center; }
.bonus-count .suitcases { font-size: 26px; letter-spacing: 2px; }
.bonus-count .big { font-size: 24px; font-weight: 800; }
.bonus-progress .tier-bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }

/* ---------- Wymagany prog (cel) ---------- */
.target-panel { border-top: 4px solid var(--brand); }
.target-panel.met { border-top-color: var(--green); background: linear-gradient(135deg, #ffffff 0%, #ecfaf1 100%); }
.target-panel.todo { background: linear-gradient(135deg, #ffffff 0%, #fff7ec 100%); }
.target-panel.none { border-top-color: var(--muted); }

/* checkboxy ról przy bonusie */
.check-row { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.chk input { width: auto; }

/* ---------- Regulamin: brama akceptacji ---------- */
.terms-gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); padding: 20px;
}
.terms-card {
  background: #fff; width: 100%; max-width: 760px; border-radius: 16px; padding: 28px 30px;
  box-shadow: 0 20px 50px rgba(8, 78, 135, 0.35);
}
.terms-scroll {
  max-height: 46vh; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 10px; padding: 18px 22px; background: #fcfdfe; font-size: 13.5px; line-height: 1.6;
}
.terms-readonly { max-height: 60vh; }
.terms-scroll h4 { margin: 18px 0 6px; color: var(--brand-dark); }
.terms-scroll ol { margin: 4px 0 4px; padding-left: 22px; }
.terms-scroll li { margin-bottom: 5px; }
.terms-parties { background: #f1f8ff; border: 1px solid #d7e8fb; padding: 12px 14px; border-radius: 10px; }
.terms-check { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; font-size: 14px; cursor: pointer; }
.terms-check input { width: auto; margin-top: 3px; }
.terms-actions { display: flex; gap: 10px; }
.terms-actions .btn { flex: 0 0 auto; }

/* ---------- MODUŁ SZKOLEŃ ---------- */
/* baner przypominający */
.training-banner {
  max-width: 1080px; margin: 16px auto -8px; padding: 12px 18px;
  background: linear-gradient(135deg, #eef6ff 0%, #fff7e6 100%);
  border: 1px solid #cfe3fb; border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.training-banner .tb-text { font-size: 14px; }
.training-banner .tb-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* pod-zakładki */
.subtabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.subtab { background: #eef2f7; border: 1px solid transparent; padding: 7px 14px; border-radius: 20px;
  font-weight: 600; color: var(--muted); font-size: 14px; }
.subtab.active { background: var(--brand); color: #fff; }

/* ankieta / quiz */
.quiz-panel { max-width: 760px; margin: 0 auto; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; }
.quiz-progress { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.quiz-q { font-size: 20px; margin: 4px 0 4px; line-height: 1.4; }
.quiz-hint { font-size: 13px; margin: 0 0 16px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  background: #fff; border: 2px solid var(--border); border-radius: 12px; padding: 14px 16px;
  font-size: 15px; color: var(--text); transition: border-color .12s, background .12s;
}
.quiz-option:hover:not(.locked) { border-color: var(--brand); background: #f7fbff; }
.quiz-option .qo-key {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: #eef2f7;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: var(--brand-dark);
}
.quiz-option.sel { border-color: var(--brand); background: var(--blue-bg); }
.quiz-option.sel .qo-key { background: var(--brand); color: #fff; }
.quiz-option.locked { cursor: default; }
.quiz-option.correct { border-color: var(--green); background: var(--green-bg); }
.quiz-option.correct .qo-key { background: var(--green); color: #fff; }
.quiz-option.wrong { border-color: var(--red); background: #fdeeee; }
.quiz-option.wrong .qo-key { background: var(--red); color: #fff; }
.quiz-actions { margin-top: 18px; }
.quiz-explain { margin-top: 16px; padding: 14px 16px; border-radius: 12px; font-size: 14px; }
.quiz-explain.ok { background: var(--green-bg); border: 1px solid #b6e6cd; }
.quiz-explain.bad { background: #fdeeee; border: 1px solid #f3c9c9; }
.quiz-explain .qe-head { font-weight: 800; margin-bottom: 6px; }
.quiz-explain .qe-why { color: var(--text); }

.quiz-done { max-width: 620px; margin: 0 auto; text-align: center; }
.quiz-done .qd-emoji { font-size: 48px; }
.quiz-done h2 { margin: 6px 0; }
.quiz-done .qd-score { font-size: 18px; }

/* baza wiedzy */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 8px; }
.kb-card { text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow); transition: transform .1s, border-color .1s; }
.kb-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.kb-card .kb-title { font-weight: 800; font-size: 15px; color: var(--brand-dark); margin-bottom: 6px; }
.kb-card .kb-sum { font-size: 13px; color: var(--muted); margin-bottom: 12px; min-height: 34px; }
.kb-card .kb-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }

.kb-body { font-size: 15px; line-height: 1.65; }
.kb-body h3 { color: var(--brand-dark); margin: 22px 0 8px; font-size: 17px; }
.kb-body h4 { color: var(--brand-dark); margin: 16px 0 6px; font-size: 15px; }
.kb-body ul, .kb-body ol { padding-left: 22px; margin: 8px 0; }
.kb-body li { margin-bottom: 5px; }
.kb-body blockquote { margin: 12px 0; padding: 10px 16px; background: #f1f8ff; border-left: 4px solid var(--brand);
  border-radius: 8px; color: var(--text); }
.kb-body table { margin: 12px 0; }
.kb-foot { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }

.weak-pill { display: inline-block; background: var(--amber-bg); color: var(--amber); font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 8px; margin: 2px 2px 0 0; }

/* grywalizacja */
.qd-gami { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.gami-item { background: #f6f9fd; border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; min-width: 110px; }
.gami-item .gami-val { font-size: 20px; font-weight: 800; color: var(--brand-dark); }
.gami-item .gami-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.qd-streak { font-weight: 700; color: var(--amber); }
.gami-card { background: linear-gradient(135deg, #ffffff 0%, #f1f8ff 100%); border: 1px solid #d7e8fb; }
.gami-card .qd-gami { justify-content: flex-start; }
.gami-next { margin-top: 6px; }

tr.me-row { background: #fff8e6 !important; }
tr.me-row td { font-weight: 600; }
.rank-cell { font-size: 16px; font-weight: 800; }

@media (max-width: 600px) {
  .container { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .training-banner { margin: 14px; }
}

/* ====== MODUL REZERWACJI / OBECNOSCI ====== */
.stage-head { margin: 18px 0 8px; font-size: 15px; }
.stage-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px 18px; margin-bottom: 14px;
}
.stage-row { display: flex; flex-direction: column; gap: 4px; }
.stage-label { font-size: 13px; color: var(--text); }
.stage-weight {
  display: inline-block; background: var(--blue-bg); color: var(--brand-dark);
  border-radius: 6px; padding: 0 6px; font-size: 12px; font-weight: 600; margin-left: 4px;
}
.pct-badge {
  display: inline-block; background: var(--green-bg); color: var(--green);
  border-radius: 6px; padding: 1px 8px; font-weight: 700; font-size: 13px;
}
.stage-edit { border-collapse: collapse; margin-bottom: 8px; }
.stage-edit td { padding: 4px 10px 4px 0; }
.stage-edit input { width: 80px; }
.ok-text { color: var(--green); }
.warn-text { color: var(--red); }

/* Siatka obecnosci */
.att-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.att-table th, .att-table td {
  border: 1px solid var(--border); padding: 6px 8px; text-align: center; white-space: nowrap;
}
.att-table .sticky { position: sticky; left: 0; background: var(--card); text-align: left; font-weight: 600; }
.att-table td[data-edit] { cursor: pointer; }
.att-table td[data-edit]:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
.h-ok { background: var(--green-bg); color: var(--green); font-weight: 600; }
.h-warn { background: var(--amber-bg); color: var(--amber); font-weight: 600; }
.h-low { background: #fdeaea; color: var(--red); font-weight: 600; }
.h-none { background: var(--bg); color: var(--muted); }
.att-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.year-nav { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.leg { display: inline-block; border-radius: 4px; padding: 0 6px; margin-right: 4px; }
.btn.tiny { padding: 3px 10px; font-size: 12px; }

/* Raporty Trello */
.trello-branch { padding: 4px 0; font-size: 14px; }
.trello-unmatched { padding: 6px 0; border-bottom: 1px solid var(--border); }
.trello-unmatched:last-child { border-bottom: none; }

/* Plany Trello (zadania per osoba) */
.plan-task { border:1px solid var(--border); border-radius:10px; padding:10px 12px; margin:8px 0; background:var(--card); }
.plan-head { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:4px; }
.plan-branch { margin:6px 0; padding-left:8px; border-left:3px solid var(--border); }
.plan-branch .say { background:var(--blue-bg); border-radius:6px; padding:6px 8px; margin-top:3px; font-size:13px; }
.plan-sms { margin-top:6px; background:var(--green-bg); border-radius:6px; padding:6px 8px; font-size:13px; }
.plan-script { margin-top:6px; }
.plan-script summary { cursor:pointer; color:var(--brand); font-size:13px; font-weight:600; }
