/* KeiManage Driver PWA（Phase 4B・2026-08-28）
   スマホ片手操作前提：大きなタップ領域・視認性の高いコントラスト */

:root {
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: env(safe-area-inset-bottom);
}

#app { max-width: 560px; margin: 0 auto; padding: 12px 14px 40px; }
.boot { text-align: center; color: var(--muted); padding: 60px 0; }

/* ── ヘッダー ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px 14px;
}
.topbar .brand { font-size: 17px; font-weight: 700; color: var(--blue); }
.topbar .brand small { font-weight: 600; color: var(--muted); font-size: 12px; margin-left: 6px; }
.topbar .who { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.4; }

.back-row { margin-bottom: 10px; }
.back-link {
  display: inline-block; color: var(--blue); text-decoration: none;
  font-size: 15px; font-weight: 600; padding: 8px 10px 8px 0;
}

/* ── カード ── */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}
.card h2 { font-size: 17px; margin-bottom: 10px; }
.card h3 { font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
.card .desc { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

/* ── 状態バッジ ── */
.status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-block; font-size: 13px; font-weight: 700;
  border-radius: 999px; padding: 4px 12px;
}
.badge.done { background: #d1fae5; color: #065f46; }
.badge.todo { background: #fef3c7; color: #92400e; }
.badge.st-pending { background: #fef3c7; color: #92400e; }
.badge.st-approved { background: #dbeafe; color: #1e40af; }
.badge.st-paid { background: #d1fae5; color: #065f46; }
.badge.st-rejected { background: #fee2e2; color: #991b1b; }

/* ── ホームのメニューグリッド ── */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 104px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--text);
  font-size: 15px; font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}
.menu-btn .icon { font-size: 30px; line-height: 1; }
.menu-btn:active { background: #eff6ff; }
.menu-btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; grid-column: 1 / -1; min-height: 84px; }
.menu-btn.primary:active { background: var(--blue-dark); }

/* ── フォーム ── */
label.field { display: block; margin-bottom: 14px; }
label.field .lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
label.field .req { color: var(--err); margin-left: 4px; font-size: 11px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time],
input[type=month], input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; font-size: 16px; /* iOSズーム防止に16px以上 */
  padding: 13px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text); -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
textarea { min-height: 76px; resize: vertical; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; }
.check-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--blue); }
.check-row span { font-size: 15px; }

.seg { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 72px; padding: 12px 6px; font-size: 15px; font-weight: 700;
  border: 1.5px solid var(--line); background: #fff; color: var(--text); border-radius: 10px;
}
.seg button.on { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ── ボタン ── */
.btn {
  display: block; width: 100%; text-align: center;
  background: var(--blue); color: #fff; border: none; border-radius: 12px;
  font-size: 17px; font-weight: 700; padding: 16px; cursor: pointer;
  text-decoration: none;
}
.btn:active { background: var(--blue-dark); }
.btn[disabled] { opacity: .5; }
.btn.ghost { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn.danger { background: #fff; color: var(--err); border: 1.5px solid var(--err); }
.btn.sm { font-size: 14px; padding: 11px; border-radius: 10px; }
.btn + .btn { margin-top: 10px; }

/* ── リスト ── */
.list { list-style: none; }
.list li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.list li:last-child { border-bottom: none; }
.list .main { flex: 1; min-width: 0; }
.list .main .t { font-weight: 700; }
.list .main .s { font-size: 12px; color: var(--muted); }
.list .amt { font-weight: 700; white-space: nowrap; }

.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; }
.kv.total .v { font-size: 18px; color: var(--blue); }

.note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0; }
.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: 12px; font-size: 13px; margin-bottom: 12px; white-space: pre-wrap; }

/* ── テナント選択 ── */
.tenant-btn {
  display: block; width: 100%; text-align: left;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 10px; font-size: 16px; font-weight: 700; cursor: pointer;
}
.tenant-btn small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.tenant-btn.on { border-color: var(--blue); background: #eff6ff; }

/* ── トースト ── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #0f172a; color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 999px; padding: 12px 22px; max-width: 88vw;
  z-index: 50; transition: opacity .25s;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
.toast.hidden { opacity: 0; pointer-events: none; }

/* ── ログイン ── */
.login-wrap { padding-top: 8vh; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .mark { font-size: 40px; }
.login-logo h1 { font-size: 22px; color: var(--blue); }
.login-logo p { font-size: 13px; color: var(--muted); }
