:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1d2433; --muted: #667085; --line: #e3e6eb;
  --accent: #2753a6; --accent-2: #e9effa; --ok: #1f8a4c; --warn: #b7791f; --bad: #c0392b;
  --ok-bg: #e5f5ec; --warn-bg: #fdf3dc; --bad-bg: #fbe7e5; --radius: 8px;
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 1rem; font-weight: 650; }
h2 { font-size: 1.12rem; margin: 1.6rem 0 .7rem; font-weight: 650; }
h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; }
.muted { color: var(--muted); }
small, .small { font-size: .85rem; }

/* układ */
.layout { display: flex; min-height: 100vh; }
.side { width: 220px; flex: none; background: #17233b; color: #cfd8e8; padding: 1rem .7rem; position: sticky;
  top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; font-weight: 700; font-size: 1.05rem; padding: .2rem .6rem 1rem; line-height: 1.25; }
.side .brand small { display: block; font-weight: 400; color: #8fa0bd; font-size: .78rem; margin-top: .2rem; }
.side nav a { display: block; color: #cfd8e8; padding: .42rem .65rem; border-radius: 6px; margin: 1px 0; }
.side nav a:hover { background: #22324f; text-decoration: none; color: #fff; }
.side nav a.on { background: #2b4170; color: #fff; }
.side .sec { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #7e8fae;
  margin: 1rem .65rem .3rem; }
.side .who { border-top: 1px solid #2b3956; margin-top: 1rem; padding: .8rem .65rem 0; font-size: .85rem; }
.side .who a { color: #9fb4da; }
main { flex: 1; padding: 1.4rem 1.8rem 3rem; min-width: 0; }

/* elementy */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem;
  margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.stats { display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem;
  min-width: 130px; }
.stat b { display: block; font-size: 1.45rem; font-weight: 650; }
.stat span { color: var(--muted); font-size: .82rem; }
.stat.bad b { color: var(--bad); } .stat.ok b { color: var(--ok); }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); text-align: left;
  vertical-align: top; }
table.list th { background: #f0f2f5; font-weight: 600; font-size: .85rem; color: #475467; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; }

.btn, button { display: inline-block; font: inherit; padding: .45rem .9rem; border-radius: 6px; cursor: pointer;
  border: 1px solid #cfd5de; background: #fff; color: var(--ink); text-decoration: none; line-height: 1.3; }
.btn:hover, button:hover { background: #f2f4f7; text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover, button.primary:hover { background: #1f4589; }
.btn.danger, button.danger { color: var(--bad); border-color: #e9b8b2; }
.btn.small, button.small { padding: .2rem .55rem; font-size: .85rem; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .spacer { flex: 1; }

form.f label { display: block; font-weight: 600; font-size: .88rem; margin: .8rem 0 .25rem; }
input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
  font: inherit; padding: .42rem .55rem; border: 1px solid #cfd5de; border-radius: 6px; background: #fff;
  width: 100%; max-width: 480px; }
textarea { max-width: 100%; }
input[type=number] { max-width: 120px; }
input[type=color] { width: 46px; height: 32px; border: 1px solid #cfd5de; border-radius: 6px; padding: 2px; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.row > div { min-width: 120px; }
.hint { color: var(--muted); font-size: .83rem; margin-top: .2rem; }
.checks { display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.checks label { font-weight: 400 !important; margin: 0 !important; display: flex !important; gap: .3rem;
  align-items: center; font-size: .9rem; }
.groupbox { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; margin-bottom: .4rem; background: #fcfcfd; }
.groupbox b { display: inline-block; min-width: 2.5rem; }

.flash { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .6rem; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #b5e0c6; }
.flash.error { background: var(--bad-bg); border-color: #efc0ba; }
.flash.info { background: var(--accent-2); border-color: #c8d6f0; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; background: #eef0f3;
  color: #475467; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
ul.warn { margin: .3rem 0; padding-left: 1.2rem; } ul.warn li { margin: .2rem 0; }

/* siatka dostępności */
table.avail { border-collapse: collapse; user-select: none; }
table.avail th, table.avail td { border: 1px solid var(--line); padding: 0; text-align: center; font-size: .8rem; }
table.avail th { padding: .25rem .4rem; background: #f0f2f5; font-weight: 600; }
table.avail td.c { width: 46px; height: 26px; cursor: pointer; }
table.avail td.c[data-v="0"] { background: #e9f6ee; }
table.avail td.c[data-v="1"] { background: #fdf0cf; }
table.avail td.c[data-v="2"] { background: #f6cbc5; }
table.avail td.c[data-v="1"]::after { content: "?"; color: var(--warn); }
table.avail td.c[data-v="2"]::after { content: "✕"; color: var(--bad); }
.legend { display: flex; gap: 1rem; font-size: .82rem; margin: .4rem 0; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: .3rem;
  border: 1px solid #0001; }

/* plan */
.planwrap { display: flex; gap: 1rem; align-items: flex-start; }
.planmain { flex: 1; min-width: 0; overflow-x: auto; }
.planside { width: 290px; flex: none; position: sticky; top: 1rem; }
table.tt { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); }
table.tt th { background: #f0f2f5; font-size: .85rem; padding: .4rem; font-weight: 600; border-bottom: 1px solid var(--line); }
table.tt th.hour { width: 74px; text-align: left; font-weight: 500; color: var(--muted); font-size: .78rem; line-height: 1.2; }
table.tt th.hour b { color: var(--ink); font-size: .95rem; display: block; }
table.tt td { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 3px; vertical-align: top;
  height: 58px; transition: background .12s; }
table.tt tr:last-child td { border-bottom: 0; }
td.slot { position: relative; }
.cell { display: flex; gap: 3px; height: 100%; }
.lc { flex: 1; min-width: 0; border-radius: 5px; padding: 3px 5px; font-size: .78rem; line-height: 1.22;
  border: 1px solid #0000001a; cursor: default; overflow: hidden; position: relative; }
.lc .s { font-weight: 700; font-size: .86rem; }
.lc .t, .lc .r, .lc .g { color: #344054; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.lc.cont { opacity: .55; border-style: dashed; }
.lc.conflict { outline: 2px solid var(--bad); outline-offset: -2px; }
.lc .lock { position: absolute; right: 3px; top: 2px; font-size: .7rem; }
.editable .lc:not(.cont) { cursor: grab; }
.editable .lc.sel { box-shadow: 0 0 0 2px var(--accent); }
.lc.dragging { opacity: .35; }
td.slot.ok-best { background: #c9ecd6 !important; }
td.slot.ok { background: #e6f5ec !important; }
td.slot.meh { background: #fbf1d8 !important; }
td.slot.bad { background: #fadcd8 !important; }
td.slot.cur { box-shadow: inset 0 0 0 2px var(--accent); }
td.slot.over { box-shadow: inset 0 0 0 3px var(--accent); }
td.slot .dl { position: absolute; right: 3px; bottom: 1px; font-size: .68rem; color: #475467; pointer-events: none; }
.tray { min-height: 60px; border: 2px dashed #cdd3dc; border-radius: var(--radius); padding: .4rem; display: flex;
  flex-wrap: wrap; gap: .3rem; background: #fff; }
.tray .lc { flex: 0 0 auto; width: 120px; }
.tray.over { border-color: var(--accent); background: var(--accent-2); }
.detail h3 { margin-top: 0; }
.detail .opt { display: flex; justify-content: space-between; padding: .3rem .4rem; border-radius: 5px; cursor: pointer;
  font-size: .86rem; }
.detail .opt:hover { background: var(--accent-2); }
.progress { height: 8px; background: #e6e9ee; border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .5s; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff;
  padding: .6rem 1rem; border-radius: 8px; z-index: 50; max-width: 90vw; box-shadow: 0 6px 24px #0003; }
.toast.bad { background: #8f2a1f; }
.entity-tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .8rem; }
.entity-tabs a { padding: .25rem .6rem; border-radius: 6px; background: #fff; border: 1px solid var(--line);
  font-size: .87rem; color: var(--ink); }
.entity-tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid #cfd5de; border-radius: 6px; overflow: hidden; }
.seg a { padding: .4rem .8rem; color: var(--ink); border-right: 1px solid #cfd5de; background: #fff; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }

/* przegląd szkoły */
table.ov { border-collapse: collapse; font-size: .7rem; background: #fff; }
table.ov th, table.ov td { border: 1px solid var(--line); padding: 1px 2px; text-align: center; white-space: nowrap; }
table.ov td.cls { font-weight: 700; font-size: .8rem; padding: 2px 6px; }
table.ov th.day { background: #e9eef7; font-size: .8rem; }
table.ov td div { border-radius: 3px; padding: 0 2px; margin: 1px 0; }
table.ov .daysep { border-left: 2px solid #8a97ab; }

/* logowanie */
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 380px; }
.login h1 { text-align: center; }

.ai-out { background: #fbfcfe; border: 1px solid #d8e1f1; border-radius: var(--radius); padding: .4rem 1.2rem; }
.creds td { font-family: ui-monospace, Consolas, monospace; }

@media (max-width: 900px) {
  .layout { flex-direction: column; } .side { width: 100%; height: auto; position: static; }
  .planwrap { flex-direction: column; } .planside { width: 100%; position: static; }
  main { padding: 1rem; }
}

/* wydruk */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 11px; }
  .side, .noprint, .toolbar, .flash { display: none !important; }
  main { padding: 0; }
  .page { page-break-after: always; break-after: page; }
  .page:last-child { page-break-after: auto; }
  table.tt td { height: auto; min-height: 40px; }
  .lc { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.ov div, td.slot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lc.conflict { outline: 0; }
}
.page { margin-bottom: 2rem; }
.page-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--ink);
  margin-bottom: .5rem; padding-bottom: .2rem; }
.page-head h2 { margin: 0; font-size: 1.35rem; }
.print table.tt td { height: 52px; }

.dragmode #ttwrap .lc:not(.dragging) { opacity: .4; }
