:root {
  --bg: #f2f6fb;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #5d6b7c;
  --line: #d2dce8;
  --head: #e4edf8;
  --accent: #1f5fa8;
  --accent-ink: #ffffff;
  --stamp: #c8302c;
  --warn: #b5651d;
  --zebra: #f8fbfe;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
header.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--accent); color: var(--accent-ink);
}
header.bar h1 { font-size: 17px; margin: 0; font-weight: 600; }
header.bar button { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.6); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--accent); }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%; padding: 9px 10px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button {
  font-family: inherit; font-size: 14px; padding: 8px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button.ghost { background: #fff; color: var(--accent); }
button.danger { background: #fff; color: #a33; border-color: #d9b0b0; }
button:disabled { opacity: .4; cursor: not-allowed; }

.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.msg { min-height: 1.4em; font-size: 13px; margin-top: 8px; }
.msg.err { color: #b00020; }
.msg.ok { color: var(--accent); }

/* ログイン */
.login-wrap { max-width: 400px; margin: 48px auto; padding: 0 16px; }
.login-wrap h1 { text-align: center; font-size: 22px; color: var(--accent); margin-bottom: 20px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 14px; border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; }
.tabs button { border: 0; border-radius: 0; background: #fff; color: var(--accent); padding: 10px; }
.tabs button.active { background: var(--accent); color: #fff; }
.login-wrap form > div { margin-bottom: 12px; }
.login-wrap form button[type=submit] { width: 100%; padding: 11px; font-size: 15px; }

/* エクセル風の表 */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input { max-width: 240px; }
.sheet-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
table.sheet { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 14px; }
.sheet th, .sheet td { border: 1px solid var(--line); padding: 6px 10px; white-space: nowrap; }
.sheet thead th { background: var(--head); position: sticky; top: 0; font-weight: 600; text-align: center; }
.sheet tbody tr:nth-child(even) td { background: var(--zebra); }
.sheet tbody tr:hover td { background: #eaf2fc; }
.sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.c { text-align: center; }
.sheet td.rem { font-weight: 700; text-align: center; }
.sheet td.rem.zero { color: var(--muted); }
.sheet td.rem.low { color: var(--warn); }
.sheet td.empty { color: var(--muted); text-align: center; }
.sheet td.actions { display: flex; gap: 6px; }
.sheet td.actions button { padding: 4px 10px; font-size: 13px; }
.sheet .pin { font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.sheet .pin-note { font-size: 11px; color: var(--muted); line-height: 1.3; }
.sheet td.used-dates { white-space: normal; min-width: 120px; max-width: 220px; font-size: 13px; font-variant-numeric: tabular-nums; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(420px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: rgba(20, 40, 70, .35); }
dialog h2 { font-size: 15px; color: var(--accent); }
.sheet tfoot td { background: var(--head); font-weight: 600; }

.dots { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 220px; white-space: normal; }
.dot { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--line); }
.dot.on { background: var(--stamp); border-color: var(--stamp); }
button.dot { padding: 0; cursor: pointer; }
button.dot.on:hover { background: #fff; outline: 2px solid var(--stamp); outline-offset: 1px; }
@media (pointer: coarse) { .dot { width: 20px; height: 20px; } .dots { gap: 6px; } }

/* 患者画面 */
.hello { font-size: 18px; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.big { font-size: 42px; font-weight: 700; color: var(--accent); line-height: 1; }
.big small { font-size: 16px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.big.zero { color: var(--muted); }
.stamp-card { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 8px; margin-top: 14px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cell {
  width: 100%; aspect-ratio: 1; border: 1.5px dashed var(--line); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.cell .n { font-size: 14px; }
/* 菅整体院のハンコ。押すたびに少し傾きを変えて本物っぽく */
.cell.on { border: 0; color: var(--stamp); transform: rotate(var(--r, -6deg)); }
.cell.on svg { width: 100%; height: 100%; opacity: .9; }
.slot .date { font-size: 11px; color: var(--muted); min-height: 1.3em; }
.meta { color: var(--muted); font-size: 13px; margin-top: 10px; }

.hidden { display: none !important; }
