/* ============================================================
   訪問介護ソエルテ タイムカード
   デザイン方針: Notionのようなシンプルで洗練されたトーン。
   白地・墨色の文字・細いヘアライン・小さめの角丸・装飾なし。
   カード型にするのは打刻ボタンだけ。アイコンは使わない。
   彩色はミント1点(状態の点・完了チェックのみ)。
   ============================================================ */

:root {
  --ink: #26251f;
  --ink-soft: #47463f;
  --muted: #8a887f;
  --faint: #bcbab1;
  --line: #e9e8e2;
  --hover: #f4f3ef;
  --bg: #ffffff;
  --card: #ffffff;

  --accent: #2bdf9f;
  --accent-strong: #0eb181;
  --accent-deep: #0b8f66;
  --accent-50: #eefcf6;

  --danger: #b65f52;

  --radius: 10px;

  --font-sans: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", Meiryo, system-ui, sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "BIZ UDMincho", "Noto Serif JP", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink-soft); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

/* ============ ワードマーク(ロゴタイプのみセリフ) ============ */

.wordmark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.wordmark .wm-dot { color: var(--accent-strong); }

.brand-sub {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0;
}

/* ============ ボタン ============ */

.btn {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 13px 20px;
  font-size: 0.98rem;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.02em;
  cursor: pointer;
  color: #fff;
  background: var(--ink);
  transition: opacity 0.15s ease, transform 0.06s ease, background 0.15s ease;
  text-align: center;
  text-decoration: none;
}

.btn:hover { opacity: 0.85; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.btn-sm {
  display: inline-block;
  width: auto;
  padding: 7px 16px;
  font-size: 0.88rem;
  border-radius: 8px;
}

.btn-outline {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}

.btn-outline:hover { opacity: 1; background: var(--hover); }

.btn-danger { background: var(--danger); }

.btn-secondary {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 600;
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}

.inline-form { display: inline; }

/* ============ 状態表示(点+文字) ============ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.badge-working { color: var(--accent-deep); }
.badge-working::before { background: var(--accent-strong); }
.badge-break { color: var(--ink-soft); }
.badge-break::before { background: transparent; border: 1.5px solid var(--ink-soft); width: 5px; height: 5px; }
.badge-done { color: var(--ink-soft); }
.badge-done::before { background: var(--ink); }

.tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.tag-active { color: var(--accent-deep); background: var(--accent-50); border-color: transparent; }
.tag-inactive { color: var(--faint); }
.tag-edited { border-style: dashed; color: var(--ink-soft); }
.tag-auto { color: var(--danger); border-color: var(--danger); }

.flash {
  padding: 10px 14px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--card);
}

.flash-error { border-left-color: var(--danger); color: var(--danger); }

.error-text { color: var(--danger); font-weight: 700; }
.warn-text { color: var(--danger); font-size: 0.88rem; }

/* ============ スタッフ用画面 ============ */

.punch-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 22px 24px 0;
}

.app-brand { text-decoration: none; }

.top-link, .logout-link {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}

.top-link:hover, .logout-link:hover { color: var(--ink); border-bottom-color: var(--ink); }

.punch-main {
  flex: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 8px 24px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 名前と状態 */
.who-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 0 4px;
  border-bottom: 1px solid var(--line);
}

.who-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding-bottom: 10px;
}

.who-name .name-suffix {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
}

/* 時刻(カードにしない・地の上にそのまま) */
.clock-block {
  text-align: center;
  padding: 40px 0 8px;
}

#clock-time {
  font-weight: 300;
  font-size: clamp(3.4rem, 18vw, 4.2rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.clock-date-line {
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 10px;
}

.today-line {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin: 2px 0 28px;
}

/* 打刻ボタン(唯一のカード型要素。出勤⇄退勤で切り替わる) */
.punch-btn {
  padding: 19px 20px;
  font-size: 1.12rem;
  font-weight: 700;
  border-radius: 12px;
  letter-spacing: 0.06em;
}

.punch-btn.swap { animation: btn-swap 0.35s ease; }

@keyframes btn-swap {
  0% { transform: scale(0.97); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

/* 出勤/退勤で打刻ボタンの色を分け、状態をひと目で分かるようにする */
.punch-btn.is-in { background: var(--accent-strong); }  /* 出勤する = ミント(スタート) */
.punch-btn.is-out { background: var(--danger); }        /* 退勤する = テラコッタ(終了) */
.punch-btn.is-back { background: var(--ink); }          /* 勤務にもどる = 既定 */

/* 勤務中(出勤済み)は時刻表示を緑にして「いま出勤中」を明示する */
body[data-state="working"] #clock-time { color: var(--accent-deep); }

/* 行リンク(細いヘアラインの行) */
.row-link {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 4px;
  margin-top: 26px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s ease;
}

.row-link:first-of-type { border-top: 1px solid var(--line); }

.row-link:hover { background: var(--hover); }

.row-text { flex: 1; line-height: 1.55; }

.row-text strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
}

.row-text small {
  color: var(--muted);
  font-size: 0.8rem;
}

.row-arrow {
  font-size: 1.1rem;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.row-link:hover .row-arrow { transform: translateX(3px); color: var(--ink); }

/* トースト */
.message {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 412px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(38, 37, 31, 0.22);
  z-index: 10;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.message.error { background: var(--danger); }

.punch-footer {
  text-align: center;
  padding: 14px;
  font-size: 0.8rem;
}

.punch-footer a { color: var(--faint); text-decoration: none; }
.punch-footer a:hover { color: var(--muted); }

/* 打刻完了アニメーション */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.97);
  animation: cel-fade 0.25s ease;
}

.celebrate.leaving { animation: cel-out 0.35s ease forwards; pointer-events: none; }

.celebrate-inner { text-align: center; animation: cel-up 0.4s ease; }

.cel-check {
  width: 80px;
  height: 80px;
  margin: 0 auto 18px;
  display: block;
}

.cel-check circle {
  stroke: var(--accent);
  stroke-width: 1.6;
  fill: none;
  stroke-dasharray: 167;
  stroke-dashoffset: 167;
  transform: rotate(-90deg);
  transform-origin: center;
  animation: cel-stroke 0.55s ease forwards 0.05s;
}

.cel-check path {
  stroke: var(--accent-strong);
  stroke-width: 2.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 46;
  stroke-dashoffset: 46;
  animation: cel-stroke 0.35s ease forwards 0.5s;
}

.celebrate-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.celebrate-sub {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.88rem;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

@keyframes cel-stroke { to { stroke-dashoffset: 0; } }
@keyframes cel-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cel-out { to { opacity: 0; } }
@keyframes cel-up {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* スタッフログイン */
.login-form label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 16px 0 5px;
}

.login-form input {
  width: 100%;
  padding: 11px 12px;
  font-size: 1.05rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  background: var(--card);
}

.login-form input:focus {
  outline: none;
  border-color: var(--ink);
}

/* 本人履歴 */
.page-head { padding: 16px 0 8px; }

.page-sub {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.history-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 14px;
}

.history-nav a {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}

.history-nav a:hover { color: var(--ink); border-bottom-color: var(--ink); }

/* 月間サマリー(細いヘアラインの帯) */
.summary-chips {
  display: flex;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 10px 0 18px;
}

.chip {
  flex: 1;
  padding: 12px 14px;
  border-left: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.chip:first-child { border-left: none; }

.chip strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

table.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.history th, table.history td {
  padding: 8px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

table.history th {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

table.history td.num, table.history th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.history tr.empty-day td { color: #cfcdc4; }
table.history tr.today-row td { background: var(--accent-50); }
table.history tfoot td { font-weight: 700; }
table.history a { text-decoration: none; font-weight: 600; color: var(--ink); }
table.history tbody tr:hover td { background: var(--hover); }
table.history tr.today-row:hover td { background: var(--accent-50); }

/* 打刻タイムライン(履歴詳細で使用) */
.punch-list {
  list-style: none;
  margin: 8px 0 2px;
  padding: 0;
}

.punch-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 4px;
  font-size: 0.95rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}

.punch-list li:last-child { border-bottom: none; }

.punch-list li span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 14px;
  margin-bottom: 14px;
  background: var(--card);
}

/* ============ 管理画面 ============ */

.admin-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 10px 20px;
}

.admin-nav .brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

.admin-nav .brand .wordmark { font-size: 1.1rem; }

.admin-nav .brand .nav-label {
  font-size: 0.74rem;
  color: var(--muted);
}

.admin-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}

.admin-links a, .admin-links .linklike {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.admin-links a:hover, .admin-links .linklike:hover { background: var(--hover); }
.admin-links a.active { background: var(--hover); color: var(--ink); }

.admin-main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 20px 48px;
}

.admin-main h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 4px 0 18px;
}

.admin-main h2 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 30px 0 10px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.toolbar form { display: flex; align-items: center; gap: 6px; }

.toolbar input, .toolbar select {
  padding: 6px 10px;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  background: var(--card);
}

.toolbar input:focus, .toolbar select:focus {
  outline: none;
  border-color: var(--ink);
}

.table-scroll { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

table.data th, table.data td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

table.data th {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  border-top: 1px solid var(--line);
}

table.data tbody tr:hover td { background: var(--hover); }
table.data tr.today-row td { background: var(--accent-50); }
table.data tr.today-row:hover td { background: var(--accent-50); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; border-top: 1px solid var(--line); }

/* 曜日: 日曜のみ赤、土曜はグレー */
.wd-sat, .wd-sat a { color: var(--muted); }
.wd-sun, .wd-sun a { color: var(--danger); }

/* フォーム */
.form-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  max-width: 540px;
  background: var(--card);
}

.form-card label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 14px 0 5px;
}

.form-card label:first-of-type { margin-top: 0; }

.form-card input[type="text"],
.form-card input[type="password"],
.form-card input[type="number"],
.form-card input[type="date"],
.form-card input[type="time"],
.form-card select {
  width: 100%;
  padding: 9px 12px;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  background: var(--card);
}

.form-card input:focus, .form-card select:focus {
  outline: none;
  border-color: var(--ink);
}

.form-card .checkbox-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.form-card .checkbox-label input { margin-right: 8px; accent-color: var(--ink); }

.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* APIキー表示 */
.key-box {
  background: var(--ink);
  color: #eceae2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  padding: 14px 16px;
  border-radius: 10px;
  word-break: break-all;
  user-select: all;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink-soft);
  background: var(--hover);
}

pre.code-block {
  background: var(--ink);
  color: #eceae2;
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

pre.code-block code { background: none; border: none; color: inherit; padding: 0; }

/* ログイン */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 10px 4px;
}

.login-brand {
  text-align: center;
  margin-bottom: 22px;
}

.login-brand .wordmark { font-size: 1.6rem; }

.login-card h1 {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 22px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--muted);
  margin: -18px 0 22px;
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  table.data { font-size: 0.84rem; }
  table.data th, table.data td { padding: 7px 8px; }
  .admin-main { padding: 18px 14px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
