:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1d2421;
  --muted: #6b736f;
  --line: #e3e0d9;
  --brand: #1f5f4a;
  --brand-2: #2b7a60;
  --accent: #f2b84b;
  --danger: #b4412f;
  --sick: #c2563e;
  --vacation: #3a74b8;
  --dayoff: #8a7a52;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; -webkit-text-size-adjust: 100%; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .75rem; }
.err { color: var(--danger); }

/* ---------- layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 1rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.wrap.wide { max-width: 1180px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.row { display: flex; align-items: center; gap: .75rem; }
.row.between { justify-content: space-between; flex-wrap: wrap; }
.row.wrap-gap { flex-wrap: wrap; margin: .75rem 0; }
.grow { flex: 1; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2, .grid3 { display: grid; gap: .75rem; align-items: end; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.nowrap { white-space: nowrap; }

/* ---------- top bar & tabs ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .8rem 1rem; padding-top: max(.8rem, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.brand { font-weight: 700; letter-spacing: .01em; }
.who { font-size: .85rem; opacity: .85; }
.topbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.tabs { display: flex; gap: .25rem; padding: 0 1rem; background: var(--brand); overflow-x: auto; }
.tabs button {
  border: 0; background: none; color: rgba(255,255,255,.75); padding: .7rem .9rem; font: inherit;
  cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
input, select {
  font: inherit; color: var(--ink); padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; min-width: 0; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; border-color: transparent; }
input.num { width: 5.5rem; }
label.check, label.switch { flex-direction: row; align-items: center; gap: .4rem; color: var(--ink); }
label.check input, label.switch input { width: auto; }

.btn {
  font: inherit; font-weight: 600; padding: .65rem 1rem; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .65rem; font-size: .85rem; }
.btn.big { padding: .9rem 1.2rem; font-size: 1.05rem; }
.link { background: none; border: 0; color: var(--brand-2); cursor: pointer; font: inherit; padding: 0; margin-top: .75rem; text-decoration: underline; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; padding: .25rem .5rem; }
.icon-btn:hover { color: var(--danger); }

details.fold summary { cursor: pointer; font-weight: 600; list-style: none; }
details.fold summary::before { content: '＋ '; color: var(--brand-2); }
details.fold[open] summary::before { content: '－ '; }
details.fold[open] summary { margin-bottom: .9rem; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card.login { width: 100%; max-width: 380px; display: grid; gap: .9rem; }

/* ---------- status ---------- */
.status { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; padding: .3rem .75rem; border-radius: 999px; }
.status.on { background: #e1f1e9; color: var(--brand); }
.status.off { background: #eeece7; color: var(--muted); margin-bottom: .9rem; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: #b9b6ae; display: inline-block; flex: none; }
.status.on .dot, .dot.on { background: #2fae6e; box-shadow: 0 0 0 4px rgba(47,174,110,.18); }
.dot.sick { background: var(--sick); } .dot.vacation { background: var(--vacation); } .dot.dayoff { background: var(--dayoff); }
.big-time { font-size: 2rem; font-weight: 700; margin: .6rem 0 0; font-variant-numeric: tabular-nums; }
#endForm { align-items: end; margin-top: .75rem; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: .5rem; }
.stats > div { background: var(--bg); border-radius: 10px; padding: .7rem .8rem; display: flex; flex-direction: column; }
.stats b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stats span { font-size: .78rem; color: var(--muted); }
.stats.big > div { background: var(--card); border: 1px solid var(--line); }
.stats.big b { font-size: 2rem; color: var(--brand); }

/* ---------- people list ---------- */
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.people li:last-child { border-bottom: 0; }
.push { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -.2rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; padding: .5rem .45rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .5rem .45rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--ink); }
.r { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8f7f3; }
tr.abs td:nth-child(2) { font-weight: 600; }
tr.abs.sick td:nth-child(2) { color: var(--sick); }
tr.abs.vacation td:nth-child(2) { color: var(--vacation); }
tr.abs.dayoff td:nth-child(2) { color: var(--dayoff); }
table.edit input, table.edit select { padding: .35rem .45rem; font-size: .88rem; }
table.edit input[type="date"] { min-width: 8.5rem; }
table.edit tr.new td { background: #f6faf8; }
.note { font-size: .78rem; color: var(--muted); }
.badge { display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: #e1f1e9; color: var(--brand); font-weight: 600; }
.badge.warn { background: #fbecd0; color: #8a5a00; }
.pause-tool { flex-wrap: wrap; background: var(--bg); padding: .6rem .8rem; border-radius: 10px; margin: .5rem 0 1rem; font-size: .9rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 150%);
  background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: 12px;
  max-width: calc(100% - 2rem); transition: transform .25s, visibility .25s; z-index: 10; font-size: .95rem;
  visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.error { background: var(--danger); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .grid3, .grid2, .cols { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  #endForm { flex-direction: column; align-items: stretch; }
  .big-time { font-size: 1.7rem; }
}

/* ---------- print (report) ---------- */
#print { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  #app, #toast { display: none !important; }
  #print { display: block; color: #000; font-size: 10.5pt; }
  .p-page { page-break-after: always; }
  .p-page:last-child { page-break-after: auto; }
  .p-head { display: flex; justify-content: space-between; font-size: 9pt; color: #444; margin-bottom: 6mm; }
  #print h1 { font-size: 15pt; margin-bottom: 5mm; }
  #print h2 { font-size: 13pt; margin-bottom: 4mm; }
  .p-table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .p-table th, .p-table td { border: 1px solid #999; padding: 1.6mm 2mm; color: #000; }
  .p-table th { background: #eee; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .p-table tfoot td { border-top: 2px solid #000; }
  .p-warn { color: #a00; font-weight: 600; }
  .p-note { font-size: 9pt; color: #444; }
  .p-sign { display: flex; gap: 20mm; margin-top: 18mm; }
  .p-sign div { flex: 1; border-top: 1px solid #000; padding-top: 1.5mm; font-size: 9pt; }
}
