:root {
  --navy: #1f3a5f;
  --navy-light: #e8eef6;
  --green: #1e8e3e;
  --green-dark: #166c2f;
  --orange: #e8710a;
  --orange-dark: #b85a06;
  --admin: #4a3f75;
  --gray: #6b7280;
  --border: #d6dbe3;
  --bg: #f4f6f9;
  --white: #ffffff;
  --text: #1f2933;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Meiryo", "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

/* ヘッダー・タブ */
.app-header {
  background: var(--navy);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; flex-direction: column; }
.brand-title { font-size: 22px; font-weight: bold; }
.brand-sub { font-size: 13px; opacity: 0.85; }
/* ヘッダーのボタン（管理者ログイン／ログアウト） */
.header-btn {
  background: rgba(255, 255, 255, 0.15);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.header-btn:hover { background: rgba(255, 255, 255, 0.28); }
.header-btn[hidden] { display: none; }

/* 画面 */
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 8px; }
.view { display: none; }
.view.active { display: block; }
.screen { display: none; }
.screen.active { display: block; }

/* カード（PIN・本人画面・完了・ログイン） */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 20px;
  max-width: 560px;
  margin: 0 auto;
}
.center-card { text-align: center; }
.card-name { font-size: 20px; color: var(--gray); }
.card-name strong { font-size: 28px; color: var(--text); }
.card-name.center { text-align: center; }
.card-lead { margin: 6px 0 14px; }
.small-note { font-size: 13px; color: var(--gray); margin: 14px 0 0; }
.form-error { color: #c62828; font-weight: bold; min-height: 1.6em; margin: 8px 0; }
.btn-back {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: var(--white);
  color: var(--navy);
  border: 2px solid var(--navy);
  border-radius: 10px;
  padding: 12px;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}
.btn-back:hover { background: var(--navy-light); }

/* PIN入力 */
.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 8px 0 4px; }
.pin-dots span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--navy);
}
.pin-dots span.filled { background: var(--navy); }
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 340px;
  margin: 8px auto 0;
}
.keypad button {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 0;
  font-size: 28px;
  font-weight: bold;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.keypad button:hover { background: #d5e0ee; }
.keypad .key-sub { font-size: 15px; color: var(--gray); }

/* 本人用打刻画面 */
.punch-status { text-align: center; font-size: 22px; font-weight: bold; margin: 6px 0 14px; }
.status-none { color: var(--gray); }
.status-working { color: var(--green-dark); }
.status-done { color: var(--orange-dark); }

/* 打刻完了 */
.done-mark {
  width: 64px;
  height: 64px;
  line-height: 64px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  font-size: 36px;
  font-weight: bold;
}
.done-message { font-size: 26px; font-weight: bold; }
.done-detail { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px 28px; margin: 14px 0 6px; }
.done-countdown { color: var(--gray); margin: 10px 0 0; }

/* 管理者ログイン */
.login-card { max-width: 440px; }
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: 15px; color: var(--gray); }
.form-row input {
  font-size: 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}
.btn-login {
  display: block;
  width: 100%;
  background: var(--admin);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}
.btn-login:hover { opacity: 0.92; }
.panel { display: none; }
.panel.active { display: block; }

/* 利用者区分の見出し */
.role-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  color: var(--white);
}
.role-employee { background: var(--green); }
.role-admin { background: var(--admin); }
.role-tag {
  background: var(--white);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 18px;
  font-weight: bold;
  white-space: nowrap;
}
.role-employee .role-tag { color: var(--green-dark); }
.role-admin .role-tag { color: var(--admin); }
.role-title { font-size: 24px; font-weight: bold; line-height: 1.3; }
.role-desc { font-size: 14px; opacity: 0.92; }

/* 管理者用画面内のタブ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 3px solid var(--admin);
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  max-width: 260px;
  background: #e4e1ee;
  color: var(--admin);
  border: none;
  border-radius: 8px 8px 0 0;
  padding: 12px 8px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}
.tab.active { background: var(--admin); color: var(--white); }

/* 時計 */
.clock-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  padding: 16px;
  margin-bottom: 20px;
}
.clock-date { font-size: 20px; color: var(--gray); }
.clock-time {
  font-size: 56px;
  font-weight: bold;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.step-title { font-size: 20px; margin: 8px 0 12px; }

/* 社員選択 */
.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.emp-btn {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.emp-btn:hover { border-color: var(--navy); background: var(--navy-light); }
.emp-name { display: block; font-size: 20px; font-weight: bold; }
.emp-meta { display: block; font-size: 13px; color: var(--gray); }

/* 本人の記録・打刻ボタン */
.my-today {
  background: var(--navy-light);
  border-radius: 10px;
  padding: 10px 16px 12px;
  margin-bottom: 16px;
}
.my-today-title { font-size: 14px; color: var(--gray); text-align: center; }
.my-today-row { display: flex; justify-content: center; gap: 12px 28px; flex-wrap: wrap; }
.my-today-item { display: flex; flex-direction: column; align-items: center; }
.my-today-label { font-size: 13px; color: var(--gray); }
.my-today-value { font-size: 22px; font-weight: bold; font-variant-numeric: tabular-nums; }
.action-buttons { display: flex; gap: 16px; }
.btn-punch {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 28px 0;
  font-size: 36px;
  font-weight: bold;
  color: var(--white);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.2em;
}
.btn-in { background: var(--green); }
.btn-in:hover:not(:disabled) { background: var(--green-dark); }
.btn-out { background: var(--orange); }
.btn-out:hover:not(:disabled) { background: var(--orange-dark); }
.btn-punch:disabled { background: #cfd5dd; color: #f4f6f9; cursor: not-allowed; }

/* ツールバー */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.toolbar label { display: flex; flex-direction: column; font-size: 14px; color: var(--gray); }
.toolbar select {
  font-size: 17px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 170px;
  font-family: inherit;
  background: var(--white);
}
.btn-csv {
  margin-left: auto;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}
.btn-csv:hover { opacity: 0.9; }
.note { color: var(--gray); font-size: 14px; margin: 10px 0 6px; }

/* テーブル */
.table-wrap {
  overflow-x: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 12px;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th,
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.data-table th { background: var(--navy-light); font-size: 15px; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tfoot td { font-weight: bold; background: #fafbfc; border-top: 2px solid var(--border); border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .empty { text-align: center; color: var(--gray); padding: 24px; }
.working-text { color: var(--green-dark); font-weight: bold; }
.bar-col { width: 35%; }
.bar {
  height: 16px;
  border-radius: 4px;
  background: var(--navy);
  min-width: 2px;
}

/* フッター */
.app-footer {
  max-width: 1100px;
  margin: 24px auto 32px;
  padding: 0 16px;
  font-size: 13px;
  color: var(--gray);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-footer p { margin: 0; }
.demo-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--gray);
}
.btn-reset {
  background: var(--white);
  color: var(--gray);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn-reset:hover { color: var(--text); border-color: var(--gray); }

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--white);
  padding: 16px 28px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .brand-title { font-size: 18px; }
  .header-btn { font-size: 14px; padding: 8px 10px; }
  .keypad button { padding: 12px 0; font-size: 24px; }
  .role-title { font-size: 20px; }
  .tab { font-size: 15px; padding: 12px 4px; }
  .clock-time { font-size: 42px; }
  .btn-punch { font-size: 28px; padding: 22px 0; }
  .btn-csv { margin-left: 0; width: 100%; }
  .toolbar select { min-width: 140px; }
}
