:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --visit: #0d9488;
  --other: #7c3aed;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #b45309;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; font-size: 1rem; cursor: pointer; }
input, select { font-family: inherit; font-size: 1rem; }
a { color: var(--primary); }

/* ---------- レイアウト ---------- */
.header {
  position: sticky; top: 0; z-index: 20;
  background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  box-shadow: var(--shadow);
}
.header .brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.header .spacer { flex: 1; }
.header .who { color: var(--muted); font-size: .9rem; }
.nav {
  position: sticky; top: 53px; z-index: 15; background: var(--card);
  border-bottom: 1px solid var(--line); display: flex; gap: 4px;
  padding: 6px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.nav button {
  border: none; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; white-space: nowrap; font-weight: 600;
}
.nav button.active { background: #eef2ff; color: var(--primary); }
.container { max-width: 920px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1180px; }

/* ---------- 部品 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; }
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.right { text-align: right; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }

.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 10px; font-weight: 600;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); border-color: #f3c2c2; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); padding: 6px 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.visit { background: #ccfbf1; color: #0f766e; }
.badge.other { background: #ede9fe; color: #6d28d9; }
.badge.open { background: #fef3c7; color: #92400e; }
.badge.closed { background: #e5e7eb; color: #374151; }
.badge.applied { background: #dcfce7; color: #166534; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: .92rem; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
tr.total td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--line); }

/* ---------- ログイン ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.4rem; margin: 0 0 4px; text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }

/* ---------- 打刻画面 ---------- */
.bigclock { text-align: center; padding: 6px 0 14px; }
.bigclock .time { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.bigclock .date { color: var(--muted); }
.punch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .punch-grid { grid-template-columns: 1fr; } }
.punch {
  border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center;
}
.punch.visit { border-color: #99f6e4; }
.punch.other { border-color: #ddd6fe; }
.punch h3 { font-size: 1.15rem; margin-bottom: 4px; }
.punch .status { font-size: .9rem; min-height: 22px; margin-bottom: 12px; }
.punch .status.on { color: var(--visit); font-weight: 700; }
.punch.other .status.on { color: var(--other); }
.punch-btn {
  width: 100%; padding: 20px; font-size: 1.3rem; font-weight: 800; border-radius: 12px;
  border: none; color: #fff;
}
.punch-btn.in.visit { background: var(--visit); }
.punch-btn.in.other { background: var(--other); }
.punch-btn.out { background: var(--danger); }
.punch-btn:active { transform: translateY(1px); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .k { font-size: .8rem; color: var(--muted); }
.kpi .v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .v.money { color: var(--primary); }

/* ---------- モーダル ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal { background: var(--card); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 460px; box-shadow: 0 20px 40px rgba(0,0,0,.2); max-height: 90vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 12px 20px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 100; max-width: 90vw; font-weight: 600;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }

/* ---------- 明細印刷 ---------- */
.slip { max-width: 640px; margin: 0 auto; }
.slip .slip-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 16px; }
.slip .slip-total { font-size: 1.6rem; font-weight: 800; text-align: right; }
@media print {
  .header, .nav, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; }
  .container { padding: 0; }
}
.empty { text-align: center; color: var(--muted); padding: 30px; }
.note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 14px; border-radius: 10px; font-size: .9rem; }

/* ---------- サービス項目 / 件数入力 ---------- */
.grp-title { font-weight: 800; color: var(--visit); margin: 16px 0 6px; padding-bottom: 4px; border-bottom: 2px solid #ccfbf1; }
.cat-list { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.cat-row:last-child { border-bottom: none; }
.cat-name { flex: 1; font-size: .92rem; }
.cat-price { color: var(--muted); font-size: .82rem; }
.cnt-input { width: 74px; text-align: right; padding: 8px 10px; }
.hm-wrap { display: flex; align-items: center; gap: 4px; }
.hm-input { width: 52px; }
.hm-l { font-size: .8rem; color: var(--muted); }
.cat-amt { width: 92px; text-align: right; font-variant-numeric: tabular-nums; color: var(--primary); font-weight: 700; }
.day-total { text-align: right; font-size: 1.2rem; font-weight: 800; margin-top: 12px; }
.day-total span { color: var(--primary); }
.price-input { width: 140px; text-align: right; padding: 8px 10px; }
tr.grp td { background: #f0fdfa; font-weight: 700; color: #0f766e; }
