:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1d2330; --muted: #6b7280; --line: #dde1e7;
  --accent: #2f5fd0; --accent-ink: #fff;
  --fri: #fdf6e8; --we: #fbe3d6; --hol: #f7c6c8;
  --hard: #c62828; --hard-bg: #fde8e8; --soft: #b26a00; --soft-bg: #fff3dc; --info: #6b7280;
  --sel: #fff59d; --ok: #1b7f3b;
  --vacation: #5c6bc0; --negative: #c62828; --negative-soft: #e57373; --positive: #2e7d32; --positive-soft: #81c784;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1c2028; --ink: #e6e8ec; --muted: #9aa3b2; --line: #2e3440;
    --accent: #6b8fff; --accent-ink: #0b0d10;
    --fri: #2a2618; --we: #3a2620; --hol: #4a2225;
    --hard: #ff6b6b; --hard-bg: #3d1c1c; --soft: #ffb74d; --soft-bg: #3a2c12; --info: #9aa3b2;
    --sel: #5c5418; --ok: #66bb6a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, "Segoe UI", sans-serif; }
button, .btn, select, input { font: inherit; color: inherit; }
button, .btn { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px;
  cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; }
h3 { margin: 14px 0 6px; font-size: 15px; }
h3 small { font-weight: normal; color: var(--muted); }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12.5px; margin: 6px 0 10px; }

.top { display: flex; gap: 18px; align-items: center; padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
.tabs button { border: none; background: none; padding: 6px 12px; border-radius: 6px; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); }
.month { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--line); }
.badge.final { background: var(--ok); color: #fff; }
main { padding: 12px 16px 40px; }
.tab { display: none; }
.tab.on { display: block; }
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.sep { width: 10px; }
.busy { color: var(--accent); font-weight: 600; }

/* planner */
.planner { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .planner { grid-template-columns: 1fr; } }
.gridwrap { overflow-x: auto; }
table.grid { border-collapse: collapse; background: var(--panel); width: 100%; }
.grid th, .grid td { border: 1px solid var(--line); padding: 3px 6px; text-align: left; white-space: nowrap; }
.grid th { background: var(--panel); }
.grid td.day { width: 74px; font-variant-numeric: tabular-nums; }
.grid td.day small { color: var(--muted); }
.grid tr.fri td { background: var(--fri); }
.grid tr.sat td, .grid tr.sun td { background: var(--we); font-weight: 600; }
.grid tr.hol td { background: var(--hol); font-weight: 600; }
.grid td.cell { cursor: pointer; min-width: 112px; position: relative; }
.grid td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.grid td.na { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--line) 6px 7px) !important; cursor: default; }
.grid td.v-hard { box-shadow: inset 0 0 0 2px var(--hard); }
.grid td.v-soft { box-shadow: inset 0 0 0 2px var(--soft); }
.grid td.selp { background: var(--sel) !important; }
.grid td.empty::after { content: "—"; color: var(--muted); }
.lock { font-size: 11px; opacity: .75; margin-left: 3px; }
.reqmark { font-size: 11px; margin-left: 4px; }
.daymarks { font-size: 11px; margin-left: 4px; }
.grid tr.selday td.day { outline: 2px dashed var(--accent); outline-offset: -2px; }

.side { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px 10px;
  position: sticky; top: 60px; max-height: calc(100vh - 80px); overflow: auto; }
.grp { margin-top: 8px; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.doc { display: grid; grid-template-columns: 24px 1fr 52px 24px 24px 24px 24px; gap: 2px; align-items: center;
  padding: 2px 4px; border-radius: 5px; cursor: pointer; font-variant-numeric: tabular-nums; }
.doc:hover { background: var(--bg); }
.doc.on { background: var(--sel); }
.doc.inactive { opacity: .5; }
.doc .rk { color: var(--muted); font-size: 11px; }
.doc .n { text-align: right; }
.doc .z { color: var(--muted); }
.doc .over { color: var(--hard); font-weight: 700; }
.doc .under { color: var(--soft); }
.doc .we { font-weight: 600; text-align: center; }
.doc.head { cursor: default; color: var(--muted); font-size: 11px; }
.doc.head:hover { background: none; }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
@media (max-width: 1000px) { .panels { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px 12px 10px; }
.v { padding: 3px 6px; border-radius: 4px; margin: 2px 0; cursor: pointer; }
.v.hard { background: var(--hard-bg); color: var(--hard); }
.v.soft { background: var(--soft-bg); color: var(--soft); }
.v.info { color: var(--info); }
.ok { color: var(--ok); }
details summary { cursor: pointer; color: var(--muted); margin-top: 6px; }

/* picker */
.picker { position: absolute; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); width: 360px; max-height: 440px; display: flex; flex-direction: column; }
.picker .ph { padding: 8px; border-bottom: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }
.picker .ph input { flex: 1; min-width: 120px; }
.picker .pl { overflow: auto; }
.picker .pi { padding: 4px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.picker .pi:hover { background: var(--bg); }
.picker .pi .w { font-size: 11.5px; color: var(--soft); text-align: right; }
.picker .pi.good .w { color: var(--ok); }
.picker .pi.blocked { opacity: .55; }
.picker .pi.blocked .w { color: var(--hard); }
.picker .pi.cur { font-weight: 700; }

/* requests */
.matrixwrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: 6px; }
table.matrix { border-collapse: collapse; background: var(--panel); user-select: none; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 0; text-align: center; font-size: 12px; }
.matrix thead th { position: sticky; top: 0; background: var(--panel); z-index: 2; padding: 2px; min-width: 26px; }
.matrix th.nm { position: sticky; left: 0; background: var(--panel); z-index: 1; text-align: left; padding: 2px 8px;
  white-space: nowrap; font-weight: normal; }
.matrix thead th.nm { z-index: 3; }
.matrix td { width: 26px; height: 22px; cursor: crosshair; font-weight: 700; }
.matrix .c-fri { background: var(--fri); } .matrix .c-sat, .matrix .c-sun { background: var(--we); } .matrix .c-hol { background: var(--hol); }
.matrix td.vacation { background: var(--vacation); color: #fff; }
.matrix td.negative { background: var(--negative); color: #fff; }
.matrix td.negative-soft { background: var(--negative-soft); color: #fff; }
.matrix td.positive { background: var(--positive); color: #fff; }
.matrix td.positive-soft { background: var(--positive-soft); color: #fff; }
.matrix td.negative_strong-soft { background: var(--negative); color: #fff; }
.matrix tr.grp th { text-align: left; padding: 4px 8px; background: var(--bg); position: sticky; left: 0; }
#brushes button.on { outline: 2px solid var(--accent); }
.b-vacation { border-left: 6px solid var(--vacation) !important; } .b-negative { border-left: 6px solid var(--negative) !important; }
.b-negative-soft { border-left: 6px solid var(--negative-soft) !important; } .b-positive { border-left: 6px solid var(--positive) !important; }
.b-positive-soft { border-left: 6px solid var(--positive-soft) !important; } .b-negative_strong-soft { border-left: 6px solid var(--negative) !important; }

table.list { border-collapse: collapse; background: var(--panel); }
.list th, .list td { border: 1px solid var(--line); padding: 3px 6px; text-align: left; }
.list th { background: var(--bg); font-weight: 600; }
.list input[type=number] { width: 64px; }
.list tr.inactive td { opacity: .55; }

/* rules */
.rules { display: flex; flex-direction: column; gap: 6px; }
.rule { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  display: grid; grid-template-columns: 26px 230px 1fr auto; gap: 8px; align-items: start; }
.rule.off { opacity: .5; }
.rule .t { font-weight: 600; }
.rule .d { font-size: 12px; color: var(--muted); }
.rule .ps { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.rule .ps label { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; }
.rule .ps input[type=number] { width: 60px; }
.rule .ctl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.rule .ctl input.w { width: 60px; }
.rule .note { width: 100%; margin-top: 4px; font-size: 12px; }
.chips { display: inline-flex; gap: 2px; }
.chip { padding: 1px 6px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 12px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.kindtag { font-size: 11px; padding: 1px 6px; border-radius: 8px; }
.kindtag.hard { background: var(--hard-bg); color: var(--hard); }
.kindtag.soft { background: var(--soft-bg); color: var(--soft); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 16px; border-radius: 8px; z-index: 30; max-width: 80vw; }
.toast.err { background: var(--hard); color: #fff; }

@media print {
  .top, .toolbar, .side, .panels, .hint { display: none !important; }
  main { padding: 0; }
  .tab { display: none !important; }
  #planner { display: block !important; }
  .planner { display: block; }
  .grid td.v-hard, .grid td.v-soft { box-shadow: none; }
  .lock, .reqmark, .daymarks { display: none; }
  .grid th { position: static; }
  body { background: #fff; color: #000; }
}

[hidden] { display: none !important; }
.list td { white-space: nowrap; }
.list td button { padding: 1px 7px; }
.docswrap { overflow-x: auto; }
.list.docs td { vertical-align: middle; }
.list.docs input.n { width: 54px; }
.list.docs input.nm { width: 120px; }
.list.docs input.note { width: 180px; }
.chip.star { font-weight: 700; }
.chip.day { min-width: 30px; text-align: center; }
.chip.day.s1 { background: var(--positive); color: #fff; border-color: var(--positive); }
.chip.day.s2 { background: var(--negative-soft); color: #fff; border-color: var(--negative-soft); }
.chip.day.s3 { background: var(--negative); color: #fff; border-color: var(--negative); }
.pairs { display: inline-flex; gap: 3px; flex-wrap: wrap; align-items: center; max-width: 260px; }
.pairs .chip b { cursor: pointer; }
.chip.with_yes { background: var(--positive); border-color: var(--positive); color: #fff; }
.chip.with_no { background: var(--negative); border-color: var(--negative); color: #fff; }
select.addpair { width: 42px; padding: 0 2px; }
.ver { font-weight: normal; font-size: 12px; color: var(--muted); margin-left: 4px; }
.update { margin-left: 8px; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600;
  background: var(--positive); color: #fff; text-decoration: none; }
.update:hover { filter: brightness(1.1); }
.data { display: flex; gap: 6px; align-items: center; }
#saveAll.dirty { background: var(--soft); border-color: var(--soft); color: #fff; }

/* ---------- login, accounts (server mode) ---------- */
body.loginpage { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.loginbox { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px 22px;
  width: 100%; max-width: 360px; display: grid; gap: 12px; }
.loginbox h1 { margin: 0 0 6px; font-size: 22px; display: flex; gap: 10px; align-items: center; }
.loginbox h1 img { width: 32px; height: 32px; }
.loginbox label, .pwform label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.loginbox input, .pwform input { font-size: 16px; padding: 8px 10px; color: var(--ink); }
.loginbox button { padding: 9px; font-size: 15px; }
.err { color: var(--hard); margin: 0; }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); max-width: 92vw; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.pwform { display: grid; gap: 10px; min-width: min(320px, 80vw); }
.who { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.warnbar { background: var(--soft-bg); color: var(--soft); border: 1px solid var(--soft); border-radius: 8px;
  padding: 6px 10px; margin: 0 0 10px; }

/* ---------- physician's page ---------- */
body.doctor main { max-width: 900px; margin: 0 auto; }
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.weekdays .wd { display: grid; gap: 2px; padding: 8px 4px; text-align: center; }
.weekdays .wd small { color: var(--muted); font-size: 11.5px; }
.wd.chci, .cald.chci, button.b-chci.on { background: var(--positive); color: #fff; border-color: var(--positive); }
.wd.nechci, .cald.nechci, button.b-nechci.on { background: var(--negative-soft); color: #fff; border-color: var(--negative-soft); }
.cald.dovolena, button.b-dovolena.on { background: var(--vacation); color: #fff; border-color: var(--vacation); }
.wd.chci small, .wd.nechci small { color: #fff; }
.wd.never { opacity: .6; }
#months button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; user-select: none; touch-action: none; }
.cal.ro { touch-action: auto; }
.calh { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.cald { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; min-height: 58px; padding: 4px 5px;
  cursor: pointer; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.cal.ro .cald { cursor: default; opacity: .75; }
.cald.k-fri { background: var(--fri); }
.cald.k-sat, .cald.k-sun { background: var(--we); }
.cald.k-hol { background: var(--hol); }
.cald .dn { font-weight: 700; font-variant-numeric: tabular-nums; }
.cald .st { font-size: 12px; font-weight: 600; }
.cald .wdhint, .cald .hol { font-size: 10.5px; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.cald.chci .hol, .cald.nechci .hol, .cald.dovolena .hol { color: #fff; }
.lockrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 4px; }
.locked { color: var(--ok); font-weight: 600; }
.grid.ro td { cursor: default; }
.grid td.selp, .grid.ro td.selp { background: var(--sel) !important; font-weight: 700; }
@media (max-width: 600px) {
  .top { gap: 8px; padding: 8px; }
  .who { margin-left: 0; }
  .cald { min-height: 46px; padding: 3px; }
  .cald .st { font-size: 0; } .cald .st::first-letter { font-size: 15px; }
  .cald .wdhint, .cald .hol { display: none; }
}

/* ---------- admin: users, locks ---------- */
.lockmark { cursor: pointer; margin-left: 4px; }
table.users td, table.users th { padding: 4px 8px; }
/* the chosen wish wins over the weekend / holiday tint */
.cal .cald.chci { background: var(--positive); color: #fff; border-color: var(--positive); }
.cal .cald.nechci { background: var(--negative-soft); color: #fff; border-color: var(--negative-soft); }
.cal .cald.dovolena { background: var(--vacation); color: #fff; border-color: var(--vacation); }
.cal .cald.chci .wdhint, .cal .cald.nechci .wdhint, .cal .cald.dovolena .wdhint { color: #fff; }

/* 0.15 */
.monthtitle { font-size: 30px; margin: 4px 0 10px; letter-spacing: .2px; }
.list.docs tr.dragrow { cursor: grab; }
.list.docs tr.dragging { opacity: .4; }
.list.docs tr.dropto td { border-top: 3px solid var(--accent); }
.list.docs td.grip { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; cursor: grab; }
.chip.off { opacity: .3; cursor: not-allowed; }
table.users td.st { font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend .lg { padding: 1px 7px; border-radius: 5px; color: #fff; font-size: 12.5px; }
.legend .lg.chci { background: var(--positive); } .legend .lg.nechci { background: var(--negative-soft); }
.legend .lg.dovolena { background: var(--vacation); }
table.users td.mail input { width: 190px; }
table.users td.mail input.missing { border-color: var(--soft); }
.loginbox a { color: var(--accent); }
form.smtp { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 12px; max-width: 1100px; }
form.smtp label { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); }
form.smtp .toolbar { grid-column: 1 / -1; }
