/* ウリカフェ 勤怠 — 打刻画面（iPad横向き据え置き） */

[hidden] { display: none !important; }

:root {
  /* iPadの設定がダークでも打刻画面は明るいまま出す（入力欄が黒くなるのを防ぐ） */
  color-scheme: light;

  --bg: #f1f5f9;
  --fg: #0f172a;
  --card: #ffffff;
  --border: #dbe2ea;
  --muted: #526078;
  --primary: #0f172a;
  --on-primary: #ffffff;
  --working: #0d7d72;
  --working-bg: #e6f4f2;
  --break: #a35a09;
  --break-bg: #fdf1e1;
  --done: #64748b;
  --done-bg: #eef1f5;
  --danger: #c81e1e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- 画面全体 ---------- */

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 18px 28px 14px;
}

.shop {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .02em;
}

.today {
  font-size: 15px;
  color: var(--muted);
}

.clock {
  margin-left: auto;
  font-size: 46px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1;
}

.clock .sec {
  font-size: 24px;
  color: var(--muted);
  font-weight: 500;
}

.offline-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 28px 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fdf1e1;
  color: #7c4408;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- スタッフのタイル ---------- */

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  /* 押しやすさ優先で大きめに。ただし高さいっぱいに伸ばすと、少人数のとき縦長の板になる。
     1段は200pxまで（10人＝3段でiPad横向き1画面に収まる）。入りきらなければ132pxを下限に縦スクロール。 */
  grid-auto-rows: minmax(132px, 200px);
  gap: 14px;
  padding: 4px 28px 28px;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 20px 20px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .08s ease, box-shadow .08s ease;
}

.tile:active {
  transform: scale(.98);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.tile .name {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .01em;
}

.tile .role {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.tile .foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  background: var(--done-bg);
  color: var(--muted);
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.tile[data-status="working"] .badge { background: var(--working-bg); color: var(--working); }
.tile[data-status="break"] .badge { background: var(--break-bg); color: var(--break); }
.tile[data-status="done"] .badge { background: var(--done-bg); color: var(--done); }
.tile[data-status="off"] .badge { background: #eef1f5; color: #64748b; }

.tile[data-status="working"] { border-color: #b9ded9; }
.tile[data-status="break"] { border-color: #f0d5ac; }

.elapsed {
  margin-left: auto;
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.pin-missing {
  font-size: 12px;
  font-weight: 700;
  color: #a35a09;
}

/* ---------- 重ねて出すパネル ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.panel {
  width: min(560px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--card);
  border-radius: 18px;
  padding: 26px 28px 24px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .3);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.panel-head .who {
  font-size: 26px;
  font-weight: 700;
}

/* 選ぶ画面を飛ばしてテンキーに来るので、何を記録するかをここで大きく見せる */
.panel-act {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 2px;
}
.panel-act.clock_in,
.panel-act.break_end { color: var(--working); }
.panel-act.break_start { color: var(--break); }

.panel-sub {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 20px;
}

.back {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

.back:active { background: #eef1f5; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 700;
  background: var(--primary);
  color: var(--on-primary);
}

.action:active { opacity: .85; }
.action[data-kind="clock_out"] { background: #1f4f8b; }
.action[data-kind="break_start"] { background: #ffffff; color: var(--break); border: 2px solid #f0d5ac; }
.action[data-kind="break_end"] { background: var(--working); }
.action .hint {
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
  opacity: .75;
}

/* ---------- テンキー ---------- */

.dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 8px 0 20px;
}

.dots i {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #c3ccd8;
}

.dots i.on { background: var(--primary); border-color: var(--primary); }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.key {
  height: 68px;
  border-radius: 12px;
  background: #eef1f5;
  font-size: 27px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.key:active { background: #dde3ec; }
.key.wide { font-size: 17px; font-weight: 700; }
.key.ghost { background: transparent; }

.msg {
  min-height: 24px;
  margin: 14px 2px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--danger);
  text-align: center;
}

.msg.info { color: var(--muted); }

/* ---------- 完了画面 ---------- */

.done-panel { text-align: center; }

.done-mark {
  width: 76px;
  height: 76px;
  margin: 4px auto 14px;
  border-radius: 50%;
  background: var(--working-bg);
  color: var(--working);
  display: grid;
  place-items: center;
}

.done-title { font-size: 30px; font-weight: 700; }

.done-time {
  font-size: 44px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 2px;
}

.done-note { font-size: 15px; color: var(--muted); }

.done-foot {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.btn-ghost {
  flex: 1;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 16px;
  font-weight: 650;
  color: var(--muted);
}

.btn-primary {
  flex: 1;
  padding: 15px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 16px;
  font-weight: 700;
}

/* ---------- 端末の登録 ---------- */

.setup {
  max-width: 460px;
  margin: auto;
  padding: 34px 30px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}

.setup h1 { font-size: 22px; margin: 0 0 8px; }
.setup p { color: var(--muted); font-size: 15px; margin: 0 0 22px; }

.setup-note {
  font-size: 13px !important;
  line-height: 1.65;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f1f5f9;
}

.setup input {
  width: 100%;
  padding: 16px;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .18em;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  text-transform: uppercase;
}

.setup input:focus { outline: none; border-color: var(--primary); }
.setup button { width: 100%; margin-top: 14px; }

video.cam { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* スタッフ0人のとき。何も出ないと壊れているように見える */
.grid-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 120px 16px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}
.grid-empty b { color: var(--fg); font-size: 20px; }
