/* 完成版 ステージ1 — お試し版の見た目を踏襲（ダーク基調・カード型・下部5タブ） */
:root {
  --bg: #0d1512;
  --surface: #1a2420;
  --surface2: #232f2a;
  --text: #f2f5f3;
  --muted: #b9c6c0;
  --border: #43554d;
  --accent: #35c99e;
  --accent-dark: #0b3d2e;
  --danger: #ff8a7a;
  --warn-bg: #4a3a12;
  --warn-text: #ffd97a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
main { max-width: 640px; margin: 0 auto; padding: 12px 12px 96px; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 17px; margin: 0 0 6px; }
.small { font-size: 14px; color: var(--muted); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.banner {
  background: var(--warn-bg); color: var(--warn-text);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; margin-bottom: 10px;
}
.big { font-size: 30px; font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
button, .btn {
  min-height: 44px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #06281c; font-weight: 700; min-height: 52px; }
button.danger { color: var(--danger); }
button:disabled { opacity: .45; }
button.small-btn { min-height: 44px; padding: 4px 12px; font-size: 14px; }
input, select, textarea {
  width: 100%; height: 48px; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 16px;
}
/* iOS Safari の日付・時刻欄は固有幅が優先されるため外観をリセットして指定を効かせる */
input[type="date"], input[type="time"] {
  -webkit-appearance: none; appearance: none; max-width: 100%;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value { text-align: center; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--surface2); border-radius: 10px; padding: 8px 10px; }
.metric .k { font-size: 14px; color: var(--muted); }
.metric .v { font-size: 20px; font-weight: 700; }
.bar { height: 12px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }
.msg { font-size: 14px; margin-top: 8px; min-height: 1.2em; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border: 1px solid var(--border); padding: 4px 6px; text-align: right; }
th { background: var(--surface2); text-align: center; }
td:first-child, th:first-child { text-align: left; }
details.card summary { cursor: pointer; font-size: 17px; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.list-item { border-top: 1px solid var(--border); padding: 8px 0; }
.list-item:first-child { border-top: none; }
/* 乗車地の区別グループ（統計タブ） */
.pgroup-head { width: 100%; justify-content: space-between; margin-top: 8px; }
.pgroup-head .pgname { font-weight: 700; text-align: left; }
.pgroup-head .num { text-align: right; }
.pgroup-body { padding-left: 14px; }
.pdetail .num { text-align: right; }
a.link-row {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 44px; padding: 6px 2px; color: var(--text); text-decoration: none;
  border-top: 1px solid var(--border);
}
a.link-row:first-of-type { border-top: none; }

/* 下部タブバー */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; min-height: 56px; border: none; border-radius: 0; background: transparent;
  flex-direction: column; gap: 0; font-size: 14px; color: var(--muted); padding: 4px 0;
}
.tabbar button.active { background: var(--accent); color: #06281c; font-weight: 700; }
.tabbar .ico { font-size: 18px; line-height: 1.2; }

/* その他メニュー */
.menu-row {
  display: block; width: 100%; text-align: left; margin-bottom: 8px; min-height: 56px;
}
.menu-row .t { font-size: 17px; font-weight: 700; display: block; }
.menu-row .d { font-size: 14px; color: var(--muted); display: block; }
button.primary .d, button.active .d { color: inherit; }

/* 認証画面 */
.auth-wrap { max-width: 420px; margin: 8vh auto 0; padding: 0 12px; }
.hidden { display: none !important; }
canvas.preview { width: 100%; max-width: 360px; border: 1px solid var(--border); border-radius: 10px; }
.badge-delay {
  background: var(--warn-bg); color: var(--warn-text);
  border-radius: 8px; padding: 2px 10px; font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; min-height: 32px;
}
.badge-ok {
  background: var(--surface2); color: var(--muted);
  border-radius: 8px; padding: 2px 10px; font-size: 14px;
  display: inline-flex; align-items: center; min-height: 32px;
}
.badge-unknown {
  background: transparent; color: var(--muted); border: 1px dashed var(--border);
  border-radius: 8px; padding: 2px 10px; font-size: 14px;
  display: inline-flex; align-items: center; min-height: 32px;
}
.warn-text { color: var(--warn-text); }
.scan-raw {
  white-space: pre-wrap; word-break: break-all;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; margin-top: 8px;
}
.seg { display: flex; gap: 6px; margin-bottom: 8px; }
.seg button { flex: 1; }
.seg button.active { background: var(--accent); color: #06281c; font-weight: 700; border-color: var(--accent); }

/* 今日の材料まとめ */
.summary-group { margin-top: 10px; }
.summary-group:first-child { margin-top: 2px; }
.summary-group .g-title { font-size: 14px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.summary-line { padding: 3px 0; }

/* 出番カレンダー */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 13px; color: var(--muted); padding: 2px 0; }
.cal-cell {
  min-height: 52px; border: 1px solid var(--border); border-radius: 8px;
  padding: 3px 4px; font-size: 13px; background: var(--surface2);
}
.cal-cell .d { font-weight: 700; font-size: 14px; }
.cal-cell .amt { color: var(--muted); font-size: 12px; }
.cal-cell.worked { background: var(--accent-dark); border-color: var(--accent); }
.cal-cell.leave { background: #17324a; border-color: #3d6a94; }
.cal-cell.in-period { box-shadow: inset 0 0 0 2px rgba(53, 201, 158, .35); }
.cal-cell.today { outline: 2px solid var(--text); outline-offset: -2px; }
.cal-cell.future { opacity: .55; }
.cal-cell .closing { color: var(--warn-text); font-size: 12px; font-weight: 700; }
.cal-cell .tag { font-size: 12px; color: var(--muted); }
.cal-cell.worked .tag, .cal-cell.leave .tag { color: var(--text); }

/* 乗務中表示の休憩・つけ待ちタイマー */
.drive-break { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 4px; }
.drive-break-status { font-size: 28px; font-weight: 700; margin: 6px 0 10px; min-height: 1.3em; }
.drive-break input { text-align: center; font-size: 18px; }

/* 帰庫逆算の乗務中表示（停車中に一目で読める大きさ。主要数字は48px以上） */
.drive-view {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg); color: var(--text);
  overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.drive-inner { max-width: 640px; margin: 0 auto; text-align: center; }
.drive-label { font-size: 20px; color: var(--muted); margin-top: 26px; }
.drive-clock { font-size: clamp(56px, 17vw, 96px); font-weight: 700; line-height: 1.1; }
.drive-big { font-size: clamp(48px, 14vw, 72px); font-weight: 700; line-height: 1.15; }
.drive-note { font-size: 18px; color: var(--muted); margin: 22px 0; min-height: 1.4em; }
.drive-over { color: var(--danger); }
.drive-view button { min-height: 56px; font-size: 18px; }
