/**
 * style.css … くるまログ 見た目(スマホ優先。900px 以上で 左=入力 / 右=履歴 の 2 列)
 *
 * プロジェクト構成:
 *   - public/index.html (構造)
 *   - public/app.js     (ロジック)
 *   - public/style.css  (このファイル)
 *
 * 設計メモ:
 *   - 画面の切り替えは body[data-tab]、距離欄の出し分けは body[data-mode] で CSS だけで行う。
 *     JS が要素を消したり作ったりしないので、フォームの入力途中の値が消えない。
 *   - 色は 藍(#1f3a5f)+ 朱(#c8412b)。Store のプロモ画像と同じ組み合わせ。
 *
 * v1.0.0 の変更点:
 *   - 初版
 *
 * @author  Dark_Koji
 * @file    style.css
 * @version 1.0.0
 * @date    2026-09-16
 */

:root {
  --navy: #1f3a5f;
  --vermilion: #c8412b;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1e232a;
  --muted: #6b7280;
  --line: #dfe3e8;
  --ok: #2e7d32;
  --soon: #d97706;
  --over: #c62828;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0 0 8px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; margin-top: 20px; color: var(--muted); }
small { color: var(--muted); font-weight: normal; font-size: 12px; }
a { color: var(--navy); }
[hidden] { display: none !important; }

/* ===== ヘッダー・タブ ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--navy); color: #fff;
}
.topbar h1 { font-size: 18px; white-space: nowrap; margin: 0; }
.topbar select {
  flex: 1; min-width: 0; margin: 0;
  font-size: 16px; padding: 8px 10px;
  border: none; border-radius: 8px; background: #fff; color: var(--text);
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border: none; background: none;
  font-size: 20px; color: var(--muted);
}
.tabs button span { font-size: 11px; }
.tabs button.active { color: var(--navy); font-weight: 700; }

/* ===== パネルの出し分け ===== */
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.panel { display: none; }
body[data-tab="fuel"] #panel-fuel,
body[data-tab="maint"] #panel-maint,
body[data-tab="history"] #panel-history,
body[data-tab="vehicles"] #panel-vehicles { display: block; }
body:not([data-mode="odometer"]) .f-odometer { display: none !important; }
body:not([data-mode="trip"]) .f-trip { display: none !important; }

/* ===== フォーム ===== */
form { background: var(--card); border-radius: var(--radius); padding: 12px 16px 16px; }
label { display: block; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
input, select {
  display: block; width: 100%; margin-top: 4px;
  font-size: 18px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--navy); outline-offset: 0; border-color: var(--navy); }
label.check { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--text); margin-top: 14px; }
label.check input { display: inline-block; width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--navy); font-size: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 14px 0 0; padding: 4px 12px 12px; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.quick { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.quick button {
  font-size: 13px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--navy);
}
.actions { display: flex; gap: 10px; margin-top: 16px; }
button { font-family: inherit; cursor: pointer; }
button.primary {
  flex: 1; font-size: 18px; font-weight: 700; padding: 14px;
  border: none; border-radius: var(--radius); background: var(--navy); color: #fff;
}
button.primary:disabled { background: #9aa4b2; cursor: not-allowed; }
button.ghost {
  flex: 1; font-size: 15px; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--muted);
}
.hint { font-size: 13px; color: var(--muted); margin: 6px 0; }
.hint.warn { color: var(--over); }

#category-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 12px; }
#category-form input, #category-form select { margin: 0; font-size: 15px; padding: 9px; }
#category-form button { padding: 10px 14px; border: none; border-radius: 8px; background: var(--navy); color: #fff; font-size: 15px; }

/* ===== 履歴 ===== */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.chart-box { position: relative; height: 240px; background: var(--card); border-radius: var(--radius); padding: 10px; margin-top: 12px; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14px; white-space: nowrap; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
th { font-weight: 600; color: var(--muted); font-size: 12px; }
th:first-child, td.l { text-align: left; }
tr:last-child td { border-bottom: none; }
.ops { text-align: right; white-space: nowrap; }
.ops button {
  font-size: 13px; padding: 5px 10px; margin-left: 4px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--navy);
}
.ops button.danger { color: var(--over); }

/* ===== 次回の目安 ===== */
.due-list { display: grid; gap: 8px; }
.due { background: var(--card); border-radius: var(--radius); padding: 10px 14px; border-left: 5px solid var(--ok); }
.due.soon { border-left-color: var(--soon); }
.due.overdue { border-left-color: var(--over); }
.due-head { display: flex; justify-content: space-between; align-items: center; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--ok); color: #fff; }
.due.soon .badge { background: var(--soon); }
.due.overdue .badge { background: var(--over); }

/* ===== 車両・項目 ===== */
.vehicle-list { display: grid; gap: 8px; margin-bottom: 16px; }
.vehicle { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--card); border-radius: var(--radius); padding: 10px 14px; }
.vehicle.inactive { opacity: .6; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 14px; }
.chip button { border: none; background: none; color: var(--muted); font-size: 16px; padding: 0 6px; }

/* ===== 通知 ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: 90vw; padding: 10px 18px; border-radius: 999px;
  background: #2b2f36; color: #fff; font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
.toast.error { background: var(--over); }

/* ===== PC(900px 以上): 左=入力 / 右=履歴 ===== */
@media (min-width: 900px) {
  body { padding-bottom: 24px; }
  .tabs { position: static; border-top: none; border-bottom: 1px solid var(--line); justify-content: flex-start; padding: 0 16px; }
  .tabs button { flex: 0 0 auto; flex-direction: row; gap: 6px; padding: 12px 18px; font-size: 16px; }
  .tabs button span { font-size: 15px; }
  .tabs button[data-tab="history"] { display: none; }
  main { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 24px; align-items: start; }
  #panel-fuel, #panel-maint, #panel-vehicles { grid-column: 1; grid-row: 1; }
  #panel-history { display: block; grid-column: 2; grid-row: 1; }
  body[data-tab="history"] #panel-fuel { display: block; }
  .cards { grid-template-columns: repeat(4, 1fr); }
  .toast { bottom: 24px; }
}
