:root {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #2d6cdf;
  --accent-ink: #ffffff;
  --danger: #c0392b;
  --ok: #1e874b;
  --warn: #b7791f;
  --like: #e8546b;
  --skip: #5b7fa6;
}
* { box-sizing: border-box; }
/* 画像が原寸で表示されて横幅を突き破り、ページ全体が縮小されるのを防ぐ全体ガード */
img { max-width: 100%; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 40;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}
.brand { font-weight: 700; font-size: 16px; color: var(--ink); white-space: nowrap; }
.mainnav { display: flex; gap: 18px; flex: 1; }
.mainnav a { white-space: nowrap; }
.badge { background: var(--accent); color: #fff; border-radius: 4px; padding: 1px 6px; font-size: 11px; }
.inline { display: inline; margin: 0; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 15px; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* アイコンボタン（ハンバーガー / アカウント） */
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--ink); flex: 0 0 auto; padding: 0;
}
.icon-btn:hover { background: #f4f5f7; }
.hb { display: none; }

/* アカウントメニュー（右上） */
.acct-wrap { position: relative; margin-left: auto; }
.acct-menu {
  position: absolute; right: 0; top: 46px; min-width: 210px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.12);
  padding: 8px; display: none; z-index: 60;
}
.acct-menu.open { display: block; }
.acct-name { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.acct-item {
  display: block; width: 100%; text-align: left; padding: 11px 10px; border: 0; background: none;
  border-radius: 8px; font-size: 15px; color: var(--ink); cursor: pointer; text-decoration: none;
}
.acct-item:hover { background: #f4f5f7; text-decoration: none; }

/* ドロワー背景。sticky な .topbar がスタッキングコンテキストを作るため、
   その子である .mainnav(ドロワー) が上に出られるよう topbar(z:40) より下に置く。 */
.nav-back { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: none; z-index: 35; }
.nav-back.open { display: block; }

/* ===== レシート撮影（端末の純正カメラを使う） ===== */
.shots-strip {
  display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 0; max-width: 480px; margin: 0 auto;
}
.shot { position: relative; flex: 0 0 auto; }
.shot img, .shot .shot-pdf {
  width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block;
}
.shot .shot-pdf { display: flex; align-items: center; justify-content: center; background: #f4f5f7; color: var(--muted); font-weight: 700; font-size: 12px; }
.shot .shot-x {
  position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--danger); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
}
.cam-big {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 480px; margin: 0 auto; padding: 20px; font-size: 17px; font-weight: 700;
}

/* ===== モーダル（重複確認など） ===== */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 70;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-back.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 22px; max-width: 420px; width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.2); max-height: 84vh; overflow: auto;
}
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.modal-warn { color: var(--warn); font-weight: 700; }
.modal-list { margin: 12px 0; padding: 0; list-style: none; }
.modal-list li {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 8px; font-size: 14px; background: #fafbfc;
}
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.modal-actions .btn { width: 100%; text-align: center; }

/* ===== アプリ風タイル ===== */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px; border: 1px solid var(--line); border-radius: 16px;
  background: #fff; color: var(--ink); text-decoration: none; min-height: 108px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.tile:hover { background: #fafbfc; text-decoration: none; }
.tile-ico { font-size: 26px; line-height: 1; }
.tile-t { font-weight: 700; font-size: 15px; }
.tile-s { font-size: 12px; color: var(--muted); }
.tile-primary { grid-column: 1 / -1; background: var(--accent); border-color: var(--accent); color: #fff; }
.tile-primary:hover { background: #245ac0; }
.tile-primary .tile-s { color: rgba(255,255,255,.85); }
.tile-badge {
  position: absolute; top: 12px; right: 12px; background: var(--like); color: #fff;
  border-radius: 999px; min-width: 22px; height: 22px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.sec-title { font-size: 12px; color: var(--muted); font-weight: 700; margin: 22px 0 8px; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }
.narrow { max-width: 420px; }

h1 { font-size: 20px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 24px 0 12px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 22px; margin-bottom: 18px;
}
.card-narrow { max-width: 420px; margin: 48px auto; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(45,108,223,.35); border-color: var(--accent); }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 6px; padding: 10px 18px; font-size: 14px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: #245ac0; text-decoration: none; }
.btn-sub { background: #eef1f6; color: var(--ink); }
.btn-sub:hover { background: #e2e7ef; }
.btn-danger { background: var(--danger); }
.row-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.flash-success { background: #e6f5ec; color: var(--ok); border: 1px solid #bfe6cd; }
.flash-error { background: #fcecea; color: var(--danger); border: 1px solid #f2c6c0; }
.flash-info { background: #eaf1fc; color: var(--accent); border: 1px solid #c6d9f6; }

/* ===== スワイプ確認（レビュー） ===== */
.rv-stage { position: relative; max-width: 420px; margin: 0 auto; height: 52vh; min-height: 320px; max-height: 560px; }
.rv-card {
  position: absolute; inset: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
  display: flex; flex-direction: column;
  touch-action: pan-y; user-select: none;
}
.rv-photo { flex: 1 1 auto; background: #f2f3f5; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.rv-photo img { width: 100%; height: 100%; object-fit: contain; }
.rv-photo .rv-pdf { color: var(--muted); font-weight: 700; font-size: 20px; }
.rv-info { flex: 0 0 auto; padding: 14px 16px; border-top: 1px solid var(--line); }
.rv-label { font-size: 18px; font-weight: 700; }
.rv-amount { font-size: 24px; font-weight: 800; }
.rv-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rv-warn { color: var(--warn); font-size: 12px; margin-top: 6px; }
/* スワイプ時のスタンプ */
.rv-stamp {
  position: absolute; top: 24px; padding: 8px 14px; border-radius: 10px;
  font-weight: 800; font-size: 20px; color: #fff; opacity: 0; pointer-events: none;
}
.rv-stamp-ok { right: 20px; background: var(--ok); transform: rotate(12deg); }
.rv-stamp-ng { left: 20px; background: var(--skip); transform: rotate(-12deg); }
.rv-actions { display: flex; gap: 14px; justify-content: center; margin: 18px 0 0; }
.rv-btn {
  width: 62px; height: 62px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: 24px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.rv-btn-ok { color: var(--ok); }
.rv-btn-ng { color: var(--skip); }
.rv-hint { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.rv-count { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* ===== 行リスト（基本情報スタイル） ===== */
.list-rows { border-top: 1px solid var(--line); }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 15px 4px; background: none; border: 0; border-bottom: 1px solid var(--line);
  font-size: 15px; color: var(--ink); text-align: left; cursor: pointer;
}
.list-row:hover { background: #fafbfc; }
.list-row .lr-label { font-weight: 700; }
.list-row .lr-value { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.list-row .lr-value.is-empty { color: #b0b6bf; }
.list-row .lr-chev { color: #c3c8cf; }

/* ===== ボトムシート ===== */
.sheet-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.28); display: none; z-index: 50;
}
.sheet-back.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; z-index: 51;
  border-radius: 14px 14px 0 0; padding: 12px 16px 24px; transform: translateY(100%);
  transition: transform .18s ease-out; max-height: 80vh; overflow: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 12px; }
.sheet-title { font-weight: 700; }
.sheet-cancel { background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; }
.sheet-ok {
  background: var(--like); color: #fff; border: 0; border-radius: 20px;
  padding: 8px 22px; font-size: 15px; cursor: pointer;
}
.sheet-opt {
  display: block; width: 100%; text-align: left; padding: 13px 10px; border: 0;
  border-bottom: 1px solid var(--line); background: none; font-size: 15px; cursor: pointer; border-radius: 8px;
}
.sheet-opt:hover { background: #f4f5f7; }
.sheet-opt.sel { background: #f0f4fd; font-weight: 700; }
.sheet-group { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; font-weight: 700; }

/* モバイル: ヘッダーを折り返して読みやすく（縦つぶれ防止） */
@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 8px 12px; }
  .brand { font-size: 15px; }
  .hb { display: flex; }
  /* ナビは左からのドロワーに */
  .mainnav {
    position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 50;
    background: #fff; border-right: 1px solid var(--line);
    flex-direction: column; gap: 0; padding: 16px 10px;
    transform: translateX(-100%); transition: transform .2s ease-out;
    box-shadow: 0 0 30px rgba(0,0,0,.12);
  }
  .mainnav.open { transform: translateX(0); }
  .mainnav a {
    display: block; padding: 14px 12px; border-radius: 10px;
    font-size: 16px; color: var(--ink);
  }
  .mainnav a:hover { background: #f4f5f7; text-decoration: none; }
  .container { padding: 14px 14px 40px; }
  h1 { font-size: 18px; margin-bottom: 12px; }
  .btn { padding: 11px 16px; }
  /* 確認画面: ✓/✎ ボタンまで1画面に収める */
  .rv-stage { height: 46vh; }
  .rv-btn { width: 56px; height: 56px; }
  .rv-actions { margin-top: 14px; }
  .rv-hint { font-size: 12px; margin-top: 8px; }
}

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfc; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tablewrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
