:root {
  --primary: #ed1462;
  --primary-dark: #c40f50;
  --secondary: #c3a384;
  --bg: #ffffff;
  --surface: #fff5f7;
  --text: #231f20;
  --muted: #7a6e6b;
  --line: #eadfdc;
  --ok: #1f7a4d;
  --ok-bg: #e7f5ee;
  --err: #b3261e;
  --err-bg: #fdecea;
  --in: #1f7a4d;
  --radius: 10px;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  color: var(--text);
  line-height: 1.6;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); }
a { color: var(--primary-dark); }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h1 small { font-size: 0.9rem; color: var(--muted); font-weight: normal; margin-left: 0.5rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
code { font-size: 0.85em; }
.muted { color: var(--muted); }

/* ---------- chrome ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem;
  padding: 0.6rem 1rem; background: var(--bg); border-bottom: 3px solid var(--primary);
}
.topbar .brand { font-weight: 800; color: var(--primary); text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; flex: 1; }
.topbar nav a { text-decoration: none; color: var(--text); padding: 0.15rem 0; }
.topbar nav a.active { color: var(--primary); border-bottom: 2px solid var(--primary); }
.topbar .who { display: flex; gap: 0.75rem; align-items: center; color: var(--muted); font-size: 0.9rem; }
.topbar.slim { justify-content: space-between; }
.topbar form { margin: 0; }
main { padding: 1rem; max-width: 1100px; margin: 0 auto; }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 480px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; margin-bottom: 1rem; }

/* ---------- forms ---------- */
.stack { display: grid; gap: 0.9rem; }
.stack label { display: grid; gap: 0.25rem; font-weight: 600; font-size: 0.95rem; }
.stack small { font-weight: normal; color: var(--muted); }
form.inline { display: inline-flex; gap: 0.5rem; align-items: center; margin: 0; flex-wrap: wrap; }
input, select { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid #cfc3bf; border-radius: 6px; background: #fff; min-width: 0; }
button, .button {
  font: inherit; display: inline-block; padding: 0.45rem 0.9rem; border-radius: 6px; cursor: pointer;
  border: 1px solid #cfc3bf; background: #fff; color: var(--text); text-decoration: none;
}
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--primary-dark); }
button.link { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.void input { width: 12rem; }

.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin: 0 0 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.badge { display: inline-block; font-size: 0.75rem; padding: 0.05rem 0.45rem; border-radius: 99px; background: #eee; color: var(--muted); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: #ccc; margin-right: 0.4rem; }
.dot.in { background: var(--in); }
ul.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 0.4rem 0.55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface); font-weight: 600; white-space: nowrap; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.detail { font-size: 0.8rem; color: var(--muted); word-break: break-all; }
tr.sun td:nth-child(2) { color: var(--err); }
tr.sat td:nth-child(2) { color: #2457a6; }
tr.issue td { background: var(--err-bg); }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td:nth-child(5), tr.voided td:nth-child(6) { text-decoration: none; }
tr.inactive td { color: var(--muted); }
table.month td.notes { font-size: 0.8rem; color: var(--err); }
tfoot th, tfoot td { border-top: 2px solid var(--text); }
.month-nav { display: flex; gap: 0.5rem; align-items: center; }

/* ---------- kiosk ---------- */
body.kiosk { background: var(--bg); user-select: none; -webkit-user-select: none; }
body.kiosk main { max-width: none; }
.kiosk-head { text-align: center; margin: 0.5rem 0 1.25rem; }
.clock { font-size: clamp(2.5rem, 8vw, 4.5rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.clock small { display: block; font-size: 0.3em; font-weight: 600; color: var(--muted); }
.hint { color: var(--muted); font-size: 1.1rem; margin: 0.5rem 0; }
.empty { text-align: center; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.9rem; }
.tile {
  display: grid; gap: 0.15rem; padding: 1.1rem 0.8rem; min-height: 7rem; border-radius: 14px;
  border: 2px solid var(--line); background: var(--surface); text-align: center; align-content: center;
}
.tile:active { transform: scale(0.98); }
.tile-name { font-size: 1.5rem; font-weight: 700; }
.tile-kana { font-size: 0.85rem; color: var(--muted); }
.tile-status { font-size: 0.9rem; min-height: 1.3em; color: var(--in); font-weight: 600; }
.tile.is-in { border-color: var(--in); background: var(--ok-bg); }

dialog#pin { border: 0; border-radius: 18px; padding: 1.5rem; width: min(440px, 94vw); box-shadow: 0 20px 60px rgb(0 0 0 / 0.25); }
dialog#pin::backdrop { background: rgb(35 31 32 / 0.55); }
.pin-form { display: grid; gap: 0.75rem; text-align: center; }
.pin-form h2 { font-size: 1.6rem; margin: 0; }
.pin-form .hint { font-size: 0.95rem; margin: 0; }
.dots { display: flex; justify-content: center; gap: 1rem; margin: 0.25rem 0; }
.dots i { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--muted); }
.dots i.on { background: var(--text); border-color: var(--text); }
.pin-error { color: var(--err); font-weight: 600; min-height: 1.6em; margin: 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.keypad button { font-size: 1.7rem; padding: 0.7rem 0; border-radius: 12px; background: var(--surface); border-color: var(--line); }
.keypad button.muted { font-size: 1rem; color: var(--muted); }
.punch-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.25rem; }
.punch { font-size: 1.4rem; font-weight: 800; padding: 1rem 0; border-radius: 12px; color: #fff; border: 0; }
.punch.in { background: var(--in); }
.punch.out { background: var(--primary); }
.punch:disabled { opacity: 0.35; cursor: default; }
.punch.suggest { outline: 4px solid rgb(0 0 0 / 0.15); outline-offset: 2px; }
.close { background: none; border: 0; color: var(--muted); text-decoration: underline; }

.result {
  position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 2rem;
  background: var(--ok-bg); color: var(--ok); z-index: 10;
}
.result[hidden] { display: none; }
.result.err { background: var(--err-bg); color: var(--err); }
#result-main { font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 800; margin: 0; }
#result-sub { font-size: clamp(1.2rem, 4vw, 2rem); margin: 0.5rem 0 0; font-variant-numeric: tabular-nums; }

/* ---------- print ---------- */
.print-page { background: #fff; padding: 1rem; margin-bottom: 1rem; }
.print-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.5rem; }
.print-head h1 { margin: 0; }
.print-head dl { display: grid; grid-template-columns: auto auto; gap: 0 0.75rem; margin: 0; }
.print-head dt { color: var(--muted); }
.print-head dd { margin: 0; font-weight: 700; }
.sign { display: flex; }
.sign span { width: 5.5rem; height: 5.5rem; border: 1px solid var(--text); font-size: 0.75rem; text-align: center; padding-top: 0.2rem; }
.sign span + span { border-left: 0; }
.print-foot { margin-top: 0.5rem; font-size: 0.75rem; color: var(--muted); }

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: #fff; }
  .topbar, .no-print, .flash { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-page { padding: 0; margin: 0; break-after: page; }
  .print-page:last-child { break-after: auto; }
  table.month { font-size: 9.5pt; }
  table.month th, table.month td { padding: 1.2mm 2mm; }
  tr.issue td { background: none; }
  th { background: #f2f2f2; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
