:root {
  --bg: #f5f6f8;
  --card: #fff;
  --ink: #14161a;
  --muted: #6b7280;
  --line: #e3e6ec;
  --accent: #2f6fed;
  --ok: #1f9d55;
  --warn: #b45309;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 12px 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.muted { color: var(--muted); }
.err { background: #fde8e8; color: #9b1c1c; padding: 10px; border-radius: 10px; margin: 8px 0; }

/* ---------- шапка ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 0 6px;
  position: relative;
}
.mtitle { flex: 1; text-align: center; font-size: 19px; font-weight: 650; }
.nav, .burger {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; line-height: 1;
  color: var(--ink); text-decoration: none;
  background: none; border: 0; border-radius: 10px; cursor: pointer;
}
.nav:active, .burger:active { background: #e9ecf2; }
.menu {
  position: absolute; right: 0; top: 52px; z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20, 22, 26, .12);
  display: flex; flex-direction: column; min-width: 220px; overflow: hidden;
}
.menu a { padding: 13px 16px; text-decoration: none; color: var(--ink); }
.menu a + a { border-top: 1px solid var(--line); }
.menu a:active { background: #f0f2f6; }

/* ---------- переключатель план/факт ---------- */
.layers {
  display: flex; gap: 4px; padding: 4px;
  background: #e7eaf0; border-radius: 12px; margin-bottom: 12px;
}
.seg {
  flex: 1; text-align: center; padding: 9px; border-radius: 9px;
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px;
}
.seg.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* ---------- итоги ---------- */
.totals { display: flex; gap: 8px; }
.tcard {
  flex: 1; background: var(--card); border-radius: var(--radius); padding: 12px;
  border-left: 4px solid var(--c);
}
.tname { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.tmain { font-size: 15px; }
.tmain b { font-size: 20px; }
.tmoney { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.3px; }
.tsub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.debt {
  margin-top: 8px; padding: 9px 12px; background: #fff5e6; color: var(--warn);
  border-radius: 10px; font-size: 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.hint {
  margin-top: 8px; padding: 9px 12px; background: #eaf1ff; color: #1d4ed8;
  border-radius: 10px; font-size: 14px;
}
.hint.ok { background: #e9f7ef; color: var(--ok); }

/* ---------- календарь ---------- */
.wd {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin: 14px 0 4px; font-size: 12px; color: var(--muted); text-align: center;
}
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cellwrap { display: block; }

.cell {
  width: 100%; min-height: 58px; position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 3px 2px 4px; cursor: pointer; font: inherit; color: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.cell.empty { background: none; border: 0; min-height: 0; }
.cell.weekend { background: #fbfaf7; }
.cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cell.future { opacity: .95; }
.cell:active { background: #eef1f7; }
.cell .num { font-size: 12px; color: var(--muted); align-self: flex-start; padding-left: 4px; }
.cell.today .num { color: var(--accent); font-weight: 700; }

.chips { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0 3px; }
.chip {
  display: block; font-size: 13px; font-weight: 700; line-height: 20px;
  border-radius: 6px; color: #fff; background: var(--c); text-align: center;
}
.chip i { font-style: normal; font-weight: 500; opacity: .85; }
.chip.ghost { background: none; color: var(--c); border: 1px dashed var(--c); line-height: 18px; }
.chip.k-sick, .chip.k-vacation { background: #eceff4; color: var(--muted); }
.cover { position: absolute; right: 3px; top: 2px; font-size: 11px; color: var(--warn); }

.legend {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px;
  font-size: 12px; color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 4px; }
.sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.sw.work { background: var(--accent); }
.sw.ghost { border: 1px dashed var(--accent); }
.sw.soft { background: var(--accent); opacity: .72; }
.sw.sick, .sw.vac { background: #eceff4; border: 1px solid var(--line); }

/* ---------- кнопки ---------- */
.actions { display: flex; gap: 8px; margin-top: 16px; }
.btn {
  flex: 1; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600;
  text-align: center; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:active { filter: brightness(.96); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; }

/* ---------- шторка ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }
.sheet-bg { position: absolute; inset: 0; background: rgba(20, 22, 26, .45); }
.sheet-card {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 14px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); } }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.sheet-head b { font-size: 19px; }
.q { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.who { display: flex; gap: 8px; flex-wrap: wrap; }
.who .opt {
  flex: 1; min-width: 70px; padding: 15px 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font: inherit; font-weight: 600;
  cursor: pointer; color: var(--ink);
}
.who .opt.on { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); color: #fff; }
.special { display: flex; flex-direction: column; gap: 8px; }
.sprow { display: flex; align-items: center; gap: 8px; }
.sprow .nm { flex: 0 0 34%; font-size: 14px; }
.sprow .opt { flex: 1; padding: 11px 6px; font-size: 14px; border-radius: 10px; }
.hist { margin-top: 14px; font-size: 12px; color: var(--muted); }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ---------- отчёт ---------- */
.paper {
  background: var(--card); border-radius: var(--radius); padding: 16px; margin-top: 12px;
}
.paper h1 { font-size: 20px; margin: 0 0 2px; }
.paper h2 { font-size: 16px; margin: 20px 0 8px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: right; font-size: 11px; color: var(--muted); font-weight: 600;
  padding: 6px 4px; border-bottom: 1px solid var(--line);
}
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { padding: 8px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.tbl.small td, .tbl.small th { padding: 5px 3px; font-size: 13px; }
.tbl tr.we td { background: #fbfaf7; }
.tbl td.c { text-align: center; }
.tbl td.nm { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.addform { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.addform input, .addform select {
  flex: 1 1 46%; padding: 11px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: var(--card); color: var(--ink);
}
.addform .btn { flex: 1 1 100%; }

/* ---------- настройки ---------- */
form.paper label { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
form.paper input, form.paper select {
  display: block; width: 100%; padding: 11px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 10px; font: inherit;
  background: var(--card); color: var(--ink);
}
form.paper input[type=color] { padding: 4px; height: 44px; }
.row { display: flex; gap: 8px; }
.row .sm { flex: 1; }
.opset { border: 0; border-left: 4px solid var(--c); padding: 4px 0 10px 12px; margin: 14px 0; }
.rates { font-size: 12px; margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- вход ---------- */
.login { max-width: 320px; margin: 12vh auto 0; text-align: center; }
.logo { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.pin {
  width: 100%; text-align: center; font-size: 30px; letter-spacing: 12px;
  padding: 14px; margin: 16px 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
}
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  padding: 18px; font-size: 22px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.keypad .ok { background: var(--accent); color: #fff; border-color: var(--accent); }

/* display:flex у .sheet и .menu перебивает атрибут hidden — возвращаем его силу. */
[hidden] { display: none !important; }

.tag { font-size: 12px; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.tag.ok { background: #e9f7ef; color: var(--ok); }
.tag.late { background: #fde8e8; color: #9b1c1c; }
.tag.wait { background: #fff5e6; color: var(--warn); }
.chip.soft { opacity: .72; }

@media print {
  body { max-width: none; background: #fff; }
  .noprint, .top, .actions { display: none !important; }
  .paper { box-shadow: none; padding: 0; }
}

/* Кто поставил отметку: правит любой, но подпись остаётся. */
.byrow { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.byrow .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sheet.ro .who, .sheet.ro .special { pointer-events: none; opacity: .6; }
.chk { flex-direction: row; align-items: center; gap: 6px; }
.opset.add { border-style: dashed; }

/* Смену закрыло третье лицо — не оператор пары. */
.chip.other {
  --c: #94a3b8;
  font-style: italic;
}
label.full { display: block; margin-top: 8px; }
label.full input { width: 100%; }
.btn.danger { color: #b42318; border-color: #f0c4bd; }

/* Переключатель месяцев: стрелки плюс список — чтобы не тыкать до нужного. */
.mnav { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.mpick {
  flex: 1; min-width: 0; font: inherit; font-weight: 600; font-size: 17px;
  text-align: center; border: 1px solid transparent; border-radius: 10px;
  background: transparent; padding: 4px 8px; color: inherit;
}
.mpick:focus { outline: none; border-color: #d5dae3; background: #fff; }
.nav.off { opacity: .25; }

/* Пояснения к полям: интерфейс должен объяснять себя сам. */
.hintline {
  display: block; margin-top: 4px; font-size: 12px; line-height: 1.4;
  color: #6b7280; font-weight: 400;
}
p.hintline { margin: 4px 0 12px; }
label.chk {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  margin-top: 10px; font-weight: 500;
}
label.chk input { width: 18px; height: 18px; flex: none; }
.opset.gone { opacity: .55; }
