/* ================================================
   QRec スタイル
   深緑×蛍光ライムの「タイムレコーダー」トーン
   ================================================ */
:root {
  --bg:        #10221c;
  --bg-card:   #182f27;
  --line:      #2a4a3e;
  --text:      #e8f2ec;
  --text-dim:  #8fae9f;
  --accent:    #a3e635;
  --accent-dk: #65a30d;
  --danger:    #f87171;
  --warn:      #fbbf24;
  --radius:    14px;
  --font: "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* HTMLの hidden 属性は UAスタイルの display:none で効くが、
   .display-body の display:flex や .btn の display:block のような
   作者スタイルに上書きされて無効になる。属性を常に優先させる。 */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wrap {
  width: 100%;
  max-width: 440px;
  padding: 24px 20px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---- ヘッダー ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.brand h1 {
  font-size: 20px;
  letter-spacing: 0.06em;
}
.brand .dot { color: var(--accent); }
.brand small { color: var(--text-dim); font-size: 12px; }
.brand-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

/* ---- 会社ロゴ（管理画面から登録・推奨 400×100） ---- */
.company-logo {
  display: block;
  max-width: min(400px, 100%);
  max-height: 100px;
  height: auto;
  margin: 0 auto 20px;
}

/* ---- PWA案内バー ---- */
/* ブラウザからインストール済みPWAを起動する標準APIは存在しないため、
   このバーは「追加」か「ホーム画面から開いてください」の案内に留まる。 */
.pwa-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.pwa-bar img { border-radius: 9px; flex: 0 0 auto; }
.pwa-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pwa-bar-text strong { font-size: 14px; }
.pwa-bar-text span { font-size: 12px; color: var(--text-dim); }
.pwa-bar .btn { width: auto; flex: 0 0 auto; padding: 10px 16px; font-size: 14px; }
@media (min-width: 720px) {
  .pwa-bar { left: auto; right: 20px; bottom: 20px; max-width: 420px; }
}

/* ---- カード ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 16px;
}

/* ---- フォーム ---- */
label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 16px;
}
input:focus { outline: 2px solid var(--accent-dk); border-color: transparent; }

/* ---- 入力欄の右にボタンを並べる（パスワード生成など） ---- */
.input-with-btn { display: flex; gap: 10px; align-items: stretch; margin-bottom: 16px; }
.input-with-btn input { margin-bottom: 0; flex: 1; min-width: 0; }
.input-with-btn .btn { width: auto; flex: 0 0 auto; padding: 0 18px; font-size: 14px; margin: 0; }

/* ---- ボタン ---- */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.06s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #14260c; }
.btn-ghost   { background: transparent; color: var(--text-dim); border: 1px solid var(--line); }
.btn + .btn  { margin-top: 12px; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---- 打刻種別ボタン ---- */
.punch-select { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.punch-select .btn { font-size: 18px; padding: 22px 0; margin: 0; }
.btn-out { background: var(--bg); color: var(--text); border: 2px solid var(--accent-dk); }

/* 休憩は出退勤より従属的な操作なので、一段控えめに見せる */
.punch-select-break { margin-top: 12px; }
.punch-select-break .btn { font-size: 15px; padding: 15px 0; }

.punch-hint {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
  text-align: center;
}

/* ---- 本日の打刻タイムライン ---- */
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.timeline { list-style: none; }
.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
}
.timeline-label { flex: 1; font-size: 14px; }
.timeline-item.is-flagged .timeline-time { color: var(--warn); }

/* ---- ステータス表示 ---- */
.status {
  text-align: center;
  padding: 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-top: 14px;
  line-height: 1.7;
}
.status.info    { background: rgba(163, 230, 53, 0.08); color: var(--accent); }
.status.error   { background: rgba(248, 113, 113, 0.1);  color: var(--danger); }
.status.warn    { background: rgba(251, 191, 36, 0.1);   color: var(--warn); }
.status.ready   {
  background: rgba(163, 230, 53, 0.12);
  color: var(--accent);
  border: 1px dashed var(--accent-dk);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: 0.65; } }
@media (prefers-reduced-motion: reduce) {
  .status.ready { animation: none; }
}

/* ---- スキャナ ---- */
#scanner-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}
#scanner-box video { width: 100%; height: 100%; object-fit: cover; }
#scanner-box .frame {
  position: absolute;
  inset: 14%;
  border: 2px solid var(--accent);
  border-radius: 12px;
  pointer-events: none;
  opacity: 0.85;
}

/* ---- 完了画面 ---- */
.done-mark {
  font-size: 64px;
  text-align: center;
  margin: 28px 0 8px;
  color: var(--accent);
}
.done-title { text-align: center; font-size: 22px; font-weight: 700; }
.done-time  { text-align: center; color: var(--text-dim); margin-top: 8px; font-variant-numeric: tabular-nums; }

/* ---- QR表示端末の画面 ---- */
/* 離れた場所から読み取る画面なので、横幅制限(.wrap の 440px)を解除して
   画面いっぱいを使い、要素を縦中央に集める。 */
.display-body {
  max-width: min(900px, 94vw);
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
}
#qr-canvas-wrap {
  background: #fff;
  border-radius: 20px;
  padding: clamp(16px, 2.4vw, 28px);
  display: inline-block;
  margin: clamp(16px, 3vh, 32px) auto;
  line-height: 0;
}
/* 遠くから見える必要があるため数字を大きく取る。
   ラベルは上に逃がす。巨大な数字とベースラインを揃えると不自然に沈むため。 */
.qr-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.qr-timer-label { font-size: clamp(14px, 1.9vw, 20px); }
.qr-timer-count { display: flex; align-items: baseline; gap: 8px; }
.qr-timer-unit  { font-size: clamp(18px, 2.6vw, 28px); }
.qr-remain {
  font-size: clamp(52px, 9vw, 112px);
  font-weight: 700;
  line-height: 1.05;
  color: var(--accent);
  /* 桁数が変わっても左右に揺れないよう最小幅を確保する */
  min-width: 1.15em;
  text-align: center;
}
/* flexカラム内で margin:auto を使うと幅が内容依存になり、
   中身が width:% のためゼロに潰れる。明示的に幅を持たせる。 */
.qr-bar {
  width: min(420px, 76vw);
  align-self: center;
  height: 10px;
  background: var(--line);
  border-radius: 5px;
  margin-top: 18px;
  overflow: hidden;
}
.qr-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 1s linear;
}
.display-clock {
  font-size: clamp(38px, 7vw, 84px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.display-date {
  color: var(--text-dim);
  font-size: clamp(13px, 1.8vw, 20px);
  margin-bottom: 6px;
}
/* この画面は縦中央揃えにしたいので、footer を下端に押し付けない */
.display-body .footer-note { margin-top: clamp(20px, 4vh, 40px); }

.footer-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: auto;
  padding-top: 24px;
}

/* ================================================
   管理画面
   PCを主体に設計し、スマホではボトムナビのアプリライク表示に切り替える。
   ================================================ */
.wrap-admin {
  max-width: 1100px;
  padding: 0 0 40px;
}

/* ---- 上部バー ---- */
.admin-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(16, 34, 28, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.admin-head .brand { margin: 0; }
.admin-head-right { display: flex; align-items: center; gap: 14px; }
.who { font-size: 12px; color: var(--text-dim); }
.who-name { font-size: 13px; font-weight: 700; color: var(--text); }
.link-plain { color: var(--accent); text-decoration: none; font-size: 13px; }
/* ヘッダー内に置くので、通常のボタン（幅100%）より小さくする */
.btn-logout { width: auto; padding: 8px 14px; font-size: 13px; margin: 0; flex: 0 0 auto; }
/* ヘッダーの店舗切替。狭い画面でも名前が読める最小幅を確保する */
.store-switch {
  width: auto;
  min-width: 130px;
  padding: 8px 12px;
  font-size: 13px;
  flex: 0 0 auto;
}
.link-plain:hover { text-decoration: underline; }

/* ---- ナビ ---- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---- サブメニュー（タブの中の切り替え） ---- */
.subtabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
}
.subtab {
  padding: 9px 16px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.subtab:hover { color: var(--text); }
.subtab[aria-selected="true"] { background: var(--accent-dk); color: var(--bg); }

/* ---- 階層の表示（店舗 › ロケーション › 端末） ---- */
/* 3つとも同じ名前になりがちなので、どの層の話かを常に示す */
.hierarchy {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-card);
}
.hier-item { display: flex; align-items: baseline; gap: 7px; }
.hier-label {
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(143, 174, 159, 0.14);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
}
.hier-item b { font-size: 14px; }
.hier-arrow { color: var(--text-dim); font-size: 16px; }

/* 概念の説明。用語が紛らわしい画面に置く */
.note-box {
  padding: 12px 16px;
  margin-bottom: 14px;
  border-left: 3px solid var(--accent-dk);
  border-radius: 0 8px 8px 0;
  background: rgba(163, 230, 53, 0.06);
  font-size: 12px;
  line-height: 1.9;
  color: var(--text-dim);
}

/* サブメニューの件数バッジ（承認待ちなど） */
.subtab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--warn);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

/* ---- 作業対象の表示（店舗・月） ---- */
/* シフトは店舗ごとなので、どの店を編集しているかが常に見えている必要がある */
.ctx-bar {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-bottom: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-card);
}
.ctx-item { display: flex; flex-direction: column; gap: 4px; }
.ctx-grow { flex: 1 1 200px; align-self: center; }
.ctx-label { font-size: 11px; color: var(--text-dim); font-weight: 700; }
.ctx-value { font-size: 17px; font-weight: 700; color: var(--accent); line-height: 1.9; }
.ctx-value.ctx-unset { color: var(--warn); }
.ctx-bar input[type="month"] { width: auto; min-width: 160px; margin: 0; }
.ctx-bar .btn { flex: 0 0 auto; }
.ctx-bar p { font-size: 12px; color: var(--text-dim); margin: 0; }

/* 店舗が1つのときは選ばせず、名前だけを出す */
.store-label {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(163, 230, 53, 0.10);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-body { padding: 0 20px; }

/* ---- セクション見出し ---- */
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.sec-head h2 { font-size: 17px; font-weight: 700; }
.sec-head p  { font-size: 12px; color: var(--text-dim); }

/* ---- 一覧をPCでは複数列に ---- */
/* minmax(0, 1fr) にしないとトラックの最小幅が min-content になり、
   nowrap な表示URLがカードを画面外まで押し広げてしまう。 */
.grid-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
@media (min-width: 860px) {
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- 一覧アイテム ---- */
.item {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.item-title { font-size: 16px; font-weight: 700; }
.item-meta {
  min-width: 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.9;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.item-meta code {
  color: var(--text);
  background: var(--bg);
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 11px;
  user-select: all;
  /* 表示URLは長いので折り返さず省略する。取得は「URLをコピー」で行う。 */
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.item-actions .btn { width: auto; flex: none; padding: 9px 13px; font-size: 13px; margin: 0; }

/* ---- バッジ ---- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-on    { background: rgba(163, 230, 53, 0.14); color: var(--accent); }
.badge-off   { background: rgba(143, 174, 159, 0.14); color: var(--text-dim); }
.badge-admin { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.badge-display { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }
.badge-sysadmin { background: rgba(167, 139, 250, 0.18); color: #c4b5fd; }
.badge-editor { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.badge-pending { background: rgba(251, 191, 36, 0.2); color: var(--warn); }
.badge-warn  { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.badge-danger{ background: rgba(248, 113, 113, 0.14); color: var(--danger); }

/* ---- フォーム ---- */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { flex: 1 1 160px; min-width: 0; }
.form-row input, .form-row select { margin-bottom: 0; }
.form-row .btn { width: auto; flex: 0 0 auto; padding: 13px 22px; margin: 0; }
input[type="number"], input[type="email"], input[type="month"], select, textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
select:focus, textarea:focus, input[type="number"]:focus, input[type="email"]:focus {
  outline: 2px solid var(--accent-dk);
  border-color: transparent;
}

/* ---- ファイル選択 ---- */
input[type="file"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---- ロゴのプレビュー ---- */
/* 透過PNGが多いので、暗い背景に埋もれないよう明るい面に載せて確認させる */
.logo-preview {
  background: #f4f7f4;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}
.logo-preview img { max-width: 400px; max-height: 100px; width: auto; height: auto; }

/* ---- インライン編集フォーム ---- */
.edit-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---- 発行された認証情報の表示 ---- */
.secret-box {
  background: var(--bg);
  border: 1px dashed var(--accent-dk);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.9;
  word-break: break-word;
}
.secret-box code { color: var(--accent); font-size: 14px; user-select: all; }

/* ---- 数値カード（集計の要約） ---- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.stat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.stat-value {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-value.tone-ok   { color: var(--accent); }
.stat-value.tone-warn { color: var(--warn); }
.stat-value.tone-danger { color: var(--danger); }
/* 予実の差など、表のセルでも同じ色分けを使う */
td.tone-warn { color: var(--warn); font-weight: 700; }
.stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* 在場一覧は名前と状態だけなので詰めて並べる */
.item-compact { padding: 12px 14px; }
.item-compact .item-head { margin-bottom: 0; }

/* ---- 端末の承認待ち画面 ---- */
/* 離れた場所から「まだ使えない」と分かる必要があるので、
   確認コードは大きく出す。 */
.pending-mark  { font-size: clamp(48px, 8vw, 72px); margin-bottom: 8px; }
.pending-title {
  font-size: clamp(20px, 3.2vw, 30px);
  font-weight: 700;
  margin-bottom: 12px;
}
.pending-lead {
  color: var(--text-dim);
  font-size: clamp(13px, 1.7vw, 17px);
  line-height: 1.9;
  margin-bottom: clamp(20px, 3vh, 32px);
}
.pending-code {
  background: var(--bg-card);
  border: 1px dashed var(--accent-dk);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 28px) clamp(24px, 5vw, 48px);
}
.pending-code-label { font-size: 12px; color: var(--text-dim); }
.pending-code-value {
  font-size: clamp(40px, 8vw, 88px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin: 6px 0 10px;
}

/* ---- カード内のメモ ---- */
.memo {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--line);
  background: var(--bg);
  font-size: 12px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text);
}
.memo b { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.memo-shift { border-left-color: var(--accent-dk); }
/* 管理者メモは本人にも編集者にも出ないので、見た目でも区別する */
.memo-admin { border-left-color: var(--warn); }

/* ---- 権限のチェックリスト ---- */
.perm-list { list-style: none; }
.perm-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.perm-item:last-child { border-bottom: none; }
.perm-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.perm-item-body { flex: 1; min-width: 0; }
.perm-item-label { font-size: 14px; font-weight: 700; }
.perm-item-note { font-size: 12px; color: var(--text-dim); margin-top: 4px; line-height: 1.6; }

/* ---- シフト表のセル内の名前 ---- */
.chip {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px 3px 2px 0;
  border-radius: 999px;
  background: rgba(163, 230, 53, 0.12);
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.chip i { font-style: normal; opacity: 0.6; font-size: 10px; margin-left: 3px; }
.chip-name { cursor: pointer; }
/* 枠と違う時間で入っている割当。パッと見で気づけるよう枠線を付ける */
.chip-ov { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.chip-time {
  margin-left: 4px;
  padding: 0 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: none;
  color: inherit;
  opacity: 0.55;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
}
.chip-time:hover { opacity: 1; }
.chip-add {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px dashed var(--line);
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.chip-add:hover { color: var(--accent); border-color: var(--accent-dk); }

/* ---- カレンダー：日ごとの枠 ---- */
/* 枠は日によって違うので列を固定できない。日を1行にして枠を横に並べる */
/* table.log は白背景の表を詰めて見せるため white-space:nowrap を効かせているが、
   カレンダーのセルは中の枠を折り返して積む必要がある。継承したままだと
   セルが横に伸び続け、右の集計列に文字が重なる。 */
table.log.cal { min-width: 880px; }
table.log.cal td { vertical-align: top; }
table.log.cal td.num { white-space: nowrap; text-align: right; width: 56px; }
.cal-date { white-space: nowrap; width: 110px; }
.cal-slots { white-space: normal; min-width: 420px; }
/* 枠の追加は必ず改行してから置く。枠の直後に続けると行末で重なる */
.cal-slots .ds-add { display: block; margin-top: 4px; }

.dayslot {
  display: inline-block;
  vertical-align: top;
  min-width: 190px;
  max-width: 320px;
  margin: 0 8px 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.dayslot.is-short { border-color: var(--warn); }
.dayslot-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.dayslot-head b { font-size: 13px; }
.dayslot-head .who { font-size: 11px; }
.dayslot-body { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }

/* 表の中に置く小さな操作。btn だと大きすぎて枠が埋まる */
.lnk-sm {
  padding: 1px 5px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
}
.lnk-sm:hover { color: var(--accent); }
.lnk-danger:hover { color: var(--danger); }

/* 割当数 / 必要人数。必要人数は日ごとに変えられる */
.cell-need {
  display: inline-block;
  margin: 2px 0 0 3px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--text-dim);
  font-size: 11px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cell-need:hover { color: var(--text); border-color: var(--text-dim); }
/* 人数が足りない日 */
.cell-need.is-short { color: var(--warn); border-color: var(--warn); font-weight: 700; }
/* この日だけ人数を変えてある枠。目安と違うことが分かるようにする */
.cell-need.is-custom { border-style: dashed; border-width: 2px; }

/* ---- 実績表の打刻 ---- */
.punch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 4px 2px 0;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
}
.punch b { font-weight: 700; }
.punch i { font-style: normal; font-size: 10px; opacity: 0.7; }
.punch i.need { color: var(--warn); opacity: 1; font-weight: 700; }
/* 取り消した打刻。消さずに残すので、効いていないことが分かる見た目にする */
.punch.is-void { opacity: 0.45; text-decoration: line-through; }
.punch.is-unapproved { border-color: var(--warn); }

/* 一時除外の行。対象外だと一目で分かるようにする */
table.log tr.row-off td { opacity: 0.45; }

/* 土日は背景を変えて月のリズムが見えるようにする */
table.log tr.row-weekend td:first-child { color: var(--warn); }

/* ---- 表 ---- */
.table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table.log { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
table.log th, table.log td { padding: 11px 14px; text-align: left; }
table.log thead th {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
table.log tbody tr { border-bottom: 1px solid var(--line); }
table.log tbody tr:last-child { border-bottom: none; }
table.log td { font-variant-numeric: tabular-nums; }
table.log tr.row-suspicious { background: rgba(248, 113, 113, 0.06); }
table.log tr.row-pending    { background: rgba(251, 191, 36, 0.06); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.counts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 32px 0; }

/* ================================================
   スマホ: ボトムナビでアプリライクに
   ================================================ */
@media (max-width: 719px) {
  .wrap-admin { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .admin-head { padding: 12px 16px; }
  .admin-head .brand h1 { font-size: 17px; }
  .admin-head .brand small { display: none; }
  .admin-body { padding: 0 16px; }

  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    margin: 0;
    background: rgba(16, 34, 28, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    border-bottom: none;
  }
  .tab {
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 8px 2px;
    border-bottom: none;
    border-radius: 10px;
    font-size: 11px;
  }
  .tab[aria-selected="true"] {
    border-bottom-color: transparent;
    background: rgba(163, 230, 53, 0.1);
  }
  .tab-icon { width: 22px; height: 22px; }

  /* PWA案内バーがボトムナビに重ならないよう持ち上げる */
  .pwa-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }

  .item-actions .btn { flex: 1 1 calc(50% - 4px); }

  /* 送信ボタンは最後の入力欄と同居させず、独立した行で幅いっぱいに置く */
  .form-row .btn { flex: 1 1 100%; width: 100%; }
}


/* ================= 入力ダイアログ =================
   prompt() の代わり。項目ごとに入力欄を分け、誤りはその場に出す。 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.6);
}
body.modal-open { overflow: hidden; }
.modal {
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-x {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-x:hover { color: var(--text); }
.modal-body { padding: 18px; }
.modal-desc { font-size: 12px; color: var(--text-dim); line-height: 1.8; margin-bottom: 14px; }
.modal-fields { display: flex; flex-wrap: wrap; gap: 14px; }
.modal-field { flex: 1 1 100%; min-width: 0; }
.modal-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.modal-field label .req {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(251, 191, 36, 0.16);
  color: var(--warn);
  font-size: 10px;
}
.modal-field input, .modal-field select, .modal-field textarea { margin: 0; width: 100%; }
.modal-field.has-error input,
.modal-field.has-error select,
.modal-field.has-error textarea { border-color: var(--danger); }
.modal-static { font-size: 14px; font-weight: 700; padding: 6px 0; }
.modal-hint { margin-top: 6px; font-size: 11px; color: var(--text-dim); line-height: 1.7; }
.field-error { margin-top: 6px; font-size: 12px; color: var(--danger); font-weight: 700; }
.modal-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--danger);
  background: rgba(248, 113, 113, 0.10);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.7;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 0 0 auto; width: auto; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---- 表の中で直接編集する打刻 ---- */
.punch-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 6px 2px 0;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.punch-edit.is-dirty { border-color: var(--accent); background: rgba(163, 230, 53, 0.06); }
.punch-edit.is-error { border-color: var(--danger); }
.punch-edit select, .punch-edit input {
  margin: 0;
  padding: 3px 6px;
  font-size: 12px;
  width: auto;
}
.punch-edit select { min-width: 88px; }
.punch-edit input[type="time"] { width: 96px; }
.punch-edit .pe-flag { font-size: 10px; color: var(--text-dim); }
.punch-edit .pe-flag.need { color: var(--warn); font-weight: 700; }
.cell-error { margin-top: 4px; font-size: 11px; color: var(--danger); font-weight: 700; }


/* 打ち忘れの案内。打刻ボタンより先に目に入る必要がある */
.alert-card {
  border-color: var(--warn);
  background: rgba(251, 191, 36, 0.07);
}
.alert-card .card-title { color: var(--warn); }
.alert-card .timeline { margin-top: 10px; }


/* ================= 月間一覧（スタッフ×日付） =================
   31日ぶんを横に並べるので、1列は略称が入る最小幅に固定する。
   氏名の列だけは先頭に貼り付けて、右にスクロールしても誰の行か分かるようにする。 */
table.log.grid { min-width: 900px; font-size: 12px; }
table.log.grid th, table.log.grid td { padding: 5px 4px; text-align: center; }
.grid-name {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 118px;
  padding-left: 12px !important;
  text-align: left !important;
  background: var(--bg-card);
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
thead .grid-name { z-index: 3; }
.grid-name .who { display: block; font-size: 10px; }
.grid-day { min-width: 30px; font-size: 11px; line-height: 1.3; }
.grid-day .who { font-size: 9px; }
.grid-cell {
  min-width: 30px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}
.grid-cell.is-on { background: rgba(163, 230, 53, 0.12); color: var(--accent); }
.grid-day.is-weekend, .grid-cell.is-weekend { background: rgba(251, 191, 36, 0.05); }
.grid-cell.is-on.is-weekend { background: rgba(163, 230, 53, 0.14); }
table.log.grid tr.is-me .grid-name,
table.log.grid tr.is-me td { background: rgba(163, 230, 53, 0.06); }
table.log.grid tr.is-me .grid-name { font-weight: 700; color: var(--accent); }
table.log.grid tr.grid-total td { border-top: 1px solid var(--line); color: var(--text-dim); }


/* パスワードの条件。満たしたものから緑にして、何が足りないかを示す */
.rule-list { list-style: none; margin-top: 12px; }
.rule-list li {
  padding: 3px 0 3px 22px;
  position: relative;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
}
.rule-list li::before {
  content: "・";
  position: absolute;
  left: 4px;
}
.rule-list li.is-ok { color: var(--accent); }
.rule-list li.is-ok::before { content: "✓"; }
.rule-list li.is-ng { color: var(--danger); }
.rule-list li.is-ng::before { content: "×"; }


/* ================= 画面に固定する通知 =================
   もとは本文の先頭に出していたため、下のほうで操作すると見えず、
   scrollIntoView で画面を上へ飛ばしていた。表の中で保存や取消をするたびに
   位置が飛ぶのは操作にならないので、その場に留めて通知だけを浮かせる。 */
#global-status.status {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 120;
  margin: 0;
  width: max-content;
  max-width: min(90vw, 34rem);
  padding: 12px 20px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toast-in .18s ease-out;
}
#global-status.status.info  { background: var(--bg-card); border-color: var(--accent-dk); }
#global-status.status.ok    { background: var(--bg-card); border-color: var(--accent-dk); color: var(--accent); }
#global-status.status.error { background: var(--bg-card); border-color: var(--danger); }
#global-status.status.warn  { background: var(--bg-card); border-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) {
  #global-status.status { animation: none; }
}


/* 案の作成でのやりとり。何を頼んだかを見失わないために残す */
.chat-log { list-style: none; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-log li {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.8;
  background: var(--bg-input);
  border: 1px solid var(--line);
}
.chat-log li b {
  display: block;
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.chat-log li.chat-me { border-color: var(--accent-dk); }
.chat-log li.chat-me b { color: var(--accent); }

/* 案の一覧で、人数が足りない日を示す */
.grid-cell.is-short { color: var(--warn); font-weight: 700; }


/* 業務量の濃淡。数字の羅列だと繁閑の山が読めない */
.grid-cell.wl-l1 { background: rgba(163, 230, 53, 0.07); color: var(--text-dim); }
.grid-cell.wl-l2 { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.grid-cell.wl-l3 { background: rgba(248, 113, 113, 0.16); color: var(--danger); font-weight: 700; }


/* 作り直しで変わった箇所。AIは指示外の日も動かすことがあるので必ず示す */
.grid-cell.is-changed { box-shadow: inset 0 0 0 2px var(--warn); }


/* 読み取り結果の確認欄。その場で直せるようにする */
.wl-cell {
  width: 52px;
  margin: 0;
  padding: 3px 4px;
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}


/* 月間一覧を直接いじれることを見た目で示す */
.grid-cell.is-editable { cursor: pointer; }
.grid-cell.is-editable:hover { outline: 2px solid var(--accent-dk); outline-offset: -2px; }
/* 枠と違う時間の割当。ひと目で区別できるようにする */
.grid-cell.is-custom-time { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
