:root {
  --bg: #f3f5fa; --card: #fff; --text: #172036; --muted: #62708f; --line: #dde3f0; --head: #0f1a35;
  --accent: #2563eb; --accent-soft: #e6eefe; --green: #1fae5b; --red: #dc3a43; --amber: #e8a317;
  --weekend: #eef1f8; --today: #fff6d6; --shadow: 0 1px 2px rgba(15, 26, 53, .06), 0 4px 16px rgba(15, 26, 53, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1222; --card: #121c33; --text: #e8eeff; --muted: #94a3c8; --line: #243256; --head: #070d1a;
    --accent: #5b9bff; --accent-soft: #1b2a4e; --weekend: #172444; --today: #3a3314; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

/* ---------- logowanie ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); background: var(--card); padding: 32px; border-radius: 16px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.login p { margin: 0; color: var(--muted); }

/* ---------- układ ---------- */
.topbar { background: var(--head); color: #fff; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.brand span { color: #6fa4ff; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: #b8c5e6; padding: 8px 14px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: rgba(255, 255, 255, .08); }
.nav a.active { background: rgba(111, 164, 255, .2); color: #fff; }
.who { display: flex; align-items: center; gap: 12px; color: #b8c5e6; font-size: 14px; white-space: nowrap; }
.who button { background: transparent; border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 8px; padding: 5px 12px; cursor: pointer; }
.who button:hover { background: rgba(255, 255, 255, .1); }
main { padding: 20px; max-width: 1500px; margin: 0 auto; }
h2 { margin: 0 0 4px; font-size: 22px; }
.sub { color: var(--muted); margin-bottom: 16px; }

.card { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; border: 1px solid var(--line); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

/* ---------- formularze ---------- */
input, select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-weight: 600; min-height: 38px; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--red); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.seg { display: inline-flex; background: var(--accent-soft); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 16px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.err { color: var(--red); min-height: 1.4em; }

/* ---------- tabele ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--accent-soft); }
.tbl tr.off td { color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(220, 58, 67, .18); vertical-align: middle; }
.dot.in { background: var(--green); box-shadow: 0 0 0 3px rgba(31, 174, 91, .2); }
.dot.stale { background: var(--amber); box-shadow: 0 0 0 3px rgba(232, 163, 23, .22); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.tag.red { background: rgba(220, 58, 67, .12); color: var(--red); }
.tag.green { background: rgba(31, 174, 91, .14); color: var(--green); }
.muted { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- siatka roczna ---------- */
.year-nav { display: flex; align-items: center; gap: 8px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.grid th, .grid td { border: 1px solid var(--line); padding: 5px 3px; text-align: center; min-width: 38px; }
.grid th { background: var(--accent-soft); color: var(--muted); font-weight: 600; }
.grid td.m { text-align: left; font-weight: 700; padding: 6px 10px; cursor: pointer; background: var(--accent-soft); color: var(--accent); white-space: nowrap; min-width: 110px; }
.grid td.m:hover { text-decoration: underline; }
.grid td.we, .grid th.we { background: var(--weekend); }
.grid td.none { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--line) 4px 5px); }
.grid td.today { background: var(--today); font-weight: 700; }
.grid td.open { color: var(--amber); font-weight: 700; }
.grid td.sum { font-weight: 700; background: var(--accent-soft); min-width: 64px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5, 10, 25, .55); display: grid; place-items: center; padding: 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--card); border-radius: 16px; padding: 22px; width: min(560px, 100%); max-height: 94vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal.wide { width: min(760px, 100%); }
.modal h3 { margin: 0 0 14px; font-size: 19px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .f { display: grid; gap: 4px; }
.form .f.full { grid-column: 1 / -1; }
.form label.lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.form .chk { display: flex; align-items: center; gap: 8px; }
.form .multi { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.form .multi label { display: flex; align-items: center; gap: 6px; }
.form .hint { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; grid-column: 1 / -1; }
.pinrow { display: flex; gap: 8px; }
.pinrow input { flex: 1; }
.thumb { height: 34px; background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; vertical-align: middle; }
.bigimg { max-width: 100%; border-radius: 10px; display: block; margin: 0 auto; background: #fff; }
.keybox { background: var(--accent-soft); border-radius: 10px; padding: 12px; word-break: break-all; font-family: Consolas, monospace; user-select: all; }

@media (max-width: 720px) { .form { grid-template-columns: 1fr; } main { padding: 12px; } .topbar { gap: 10px; padding: 0 10px; } .who span { display: none; } }
@media print {
  .topbar, .toolbar, .btn { display: none !important; }
  body { background: #fff; color: #000; } .card { box-shadow: none; border: 0; }
}
