/* Akira整備工場 業務管理システム - 落ち着いた業務アプリ風UI（スマホファースト） */
:root {
  --navy: #1e3a5f;
  --navy-dark: #162c49;
  --accent: #2f6fb4;
  --bg: #eef1f5;
  --card: #ffffff;
  --line: #d8dee6;
  --text: #24303c;
  --muted: #6b7788;
  --danger: #b3261e;
  --warn-bg: #fdecea;
  --warn30: #c62828;
  --warn60: #e65100;
  --warn90: #f9a825;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* 体験版バナー（akira-taikenのみ表示） */
.taiken-banner {
  background: #fff3cd; color: #6b5200; border-bottom: 1px solid #e6d28a;
  font-size: 12px; font-weight: 600; padding: 8px 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  text-align: center; position: sticky; top: 0; z-index: 11;
}
.taiken-banner button {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  border: 1px solid #c9a94a; background: #fff; color: #6b5200; cursor: pointer;
}
@media print { .taiken-banner { display: none !important; } }

/* ヘッダー */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 0 12px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.app-header .inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-height: 52px; padding: 6px 0;
}
.app-header .brand {
  font-weight: 700; font-size: 15px; color: #fff; text-decoration: none;
  letter-spacing: .02em; margin-right: auto;
}
.app-header .brand small { font-weight: 400; opacity: .75; margin-left: 6px; font-size: 11px; }
.app-nav { display: flex; gap: 4px; }
.app-nav a {
  color: #d7e1ee; text-decoration: none; font-size: 13px;
  padding: 6px 10px; border-radius: 6px;
}
.app-nav a.active, .app-nav a:hover { background: var(--navy-dark); color: #fff; }

main { max-width: 960px; margin: 0 auto; padding: 16px 12px 64px; }

/* 見出し・ツールバー */
.page-title { font-size: 18px; font-weight: 700; margin: 4px 0 12px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .search-box { flex: 1; min-width: 200px; position: relative; }
.toolbar .search-box input {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}
.result-count { font-size: 12px; color: var(--muted); margin: 0 0 8px 2px; }

/* カード・リスト */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; margin-bottom: 12px;
}
.card h2 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 0 0 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; text-decoration: none; color: var(--text);
}
.list-item:active { background: #f4f7fb; }
.list-item .row1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.list-item .name { font-weight: 700; font-size: 15px; }
.list-item .sub { color: var(--muted); font-size: 12px; }
.list-item .row2 { display: flex; gap: 10px; margin-top: 2px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; font-size: 13px; }

/* バッジ（車検満了） */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; color: #fff; vertical-align: middle;
}
.badge.expired { background: #7b1c15; }
.badge.d30 { background: var(--warn30); }
.badge.d60 { background: var(--warn60); }
.badge.d90 { background: var(--warn90); color: #4b3800; }
.badge.ok { background: #9aa6b5; }

/* 定義リスト（詳細画面） */
.dl { display: grid; grid-template-columns: 8.5em 1fr; gap: 6px 10px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.dl dd { margin: 0; word-break: break-all; }

/* フォーム */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .wide { grid-column: 1 / -1; } }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field label .req { color: var(--danger); margin-left: 3px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
.field textarea { min-height: 72px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
}
.hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none; -webkit-appearance: none;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:active { background: var(--navy-dark); }
.btn-sub { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e5b6b3; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 16px; }
.btn-row .btn { flex: 1; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ホームのメニュー */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 640px) { .menu-grid { grid-template-columns: repeat(4, 1fr); } }
.menu-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 12px; text-align: center; text-decoration: none; color: var(--text);
}
.menu-card .icon { font-size: 28px; }
.menu-card .label { font-weight: 700; font-size: 14px; margin-top: 6px; }
.menu-card .count { font-size: 12px; color: var(--muted); margin-top: 2px; }
.menu-card.disabled { opacity: .45; pointer-events: none; }
.menu-card.disabled .count { font-size: 11px; }

/* トースト */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(30,40,52,.95); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .25s; z-index: 100; max-width: 90%;
}
#toast.show { opacity: 1; }

/* エラー表示 */
.error-box {
  background: var(--warn-bg); color: var(--danger); border: 1px solid #e5b6b3;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
  display: none;
}
.error-box.show { display: block; }

a.tel-link { color: var(--accent); text-decoration: none; font-weight: 600; }

/* 車検満了ダッシュボード */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 6px; text-align: center;
}
.stat .num { font-size: 22px; font-weight: 800; line-height: 1.2; }
.stat .lbl { font-size: 11px; color: var(--muted); }
.stat.expired .num { color: #7b1c15; }
.stat.d30 .num { color: var(--warn30); }
.stat.d60 .num { color: var(--warn60); }
.stat.d90 .num { color: #b28704; }
.action-row { display: flex; gap: 6px; margin-top: 8px; }
.mini-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 8px 4px;
  border: 1px solid var(--line); border-radius: 8px; background: #f7f9fc; color: var(--navy);
  text-decoration: none; cursor: pointer; -webkit-appearance: none;
}
.mini-btn:active { background: #e9eef5; }

/* モーダル */
.modal-back {
  position: fixed; inset: 0; background: rgba(20, 28, 38, .55); z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-back.show { display: flex; }
.modal {
  background: var(--card); border-radius: 14px 14px 0 0; width: 100%; max-width: 640px;
  padding: 16px; max-height: 85vh; overflow-y: auto;
}
@media (min-width: 640px) { .modal-back.show { align-items: center; } .modal { border-radius: 14px; } }
.modal h3 { margin: 0 0 10px; font-size: 15px; }
.modal textarea {
  width: 100%; min-height: 180px; font-size: 14px; line-height: 1.7;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; resize: vertical;
}
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 8px; }

/* 明細テーブル（伝票・セットメニュー） */
.items-wrap { overflow-x: auto; }
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.items-table th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 600;
  padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.items-table td { padding: 4px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.items-table input, .items-table select { width: 100%; padding: 8px 8px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.items-table .num { text-align: right; }
.items-table input.num { text-align: right; }
.items-table .del-btn { background: none; border: none; color: var(--danger); font-size: 16px;
  cursor: pointer; padding: 6px; }
.totals-box { background: #f4f7fb; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-top: 12px; max-width: 380px; margin-left: auto; }
.totals-box .trow { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.totals-box .trow.grand { border-top: 2px solid var(--navy); margin-top: 6px; padding-top: 8px;
  font-size: 17px; font-weight: 800; }
.status-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 10px;
  border-radius: 999px; vertical-align: middle; }
.status-badge.estimate { background: #e7edf5; color: #40536b; }
.status-badge.issued { background: #fff3cd; color: #8a6d00; }
.status-badge.paid { background: #d9efdd; color: #1e6b34; }

/* A4印刷様式（伝票・合計請求書） */
.print-sheet { background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 20px; margin-top: 16px; }
.print-sheet h1 { font-size: 22px; text-align: center; letter-spacing: .5em; margin: 0 0 16px;
  border-bottom: 3px double #333; padding-bottom: 8px; }
.print-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; margin-bottom: 12px; }
.print-head .right { text-align: right; }
.print-cust { border: 1px solid #999; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.print-cust .cname { font-size: 16px; font-weight: 700; }
.print-items { width: 100%; border-collapse: collapse; font-size: 12px; }
.print-items th, .print-items td { border: 1px solid #999; padding: 6px 8px; }
.print-items th { background: #f0f0f0; font-weight: 600; }
.print-items td.num { text-align: right; }
.print-totals { margin-top: 10px; margin-left: auto; width: 240px; font-size: 13px; }
.print-totals table { width: 100%; border-collapse: collapse; }
.print-totals td { border: 1px solid #999; padding: 5px 8px; }
.print-totals .grand td { font-weight: 800; background: #f0f0f0; }
.print-note { font-size: 11px; color: #444; margin-top: 12px; }
@media print {
  body { background: #fff; }
  .app-header, .no-print, #toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .print-sheet { border: none; border-radius: 0; padding: 0; margin: 0; }
  @page { size: A4 portrait; margin: 14mm; }
}
.section-head h2 { font-size: 15px; margin: 0; }
.footer-note { text-align: center; font-size: 11px; color: var(--muted); margin-top: 32px; }
