/* 医療費ログ — 緑系テーマ */
:root {
  --green: #2f9e77;
  --green-dark: #17614a;
  --green-pale: #e5f4ee;
  --ink: #22302b;
  --muted: #6c7a74;
  --line: #d9e6df;
  --bg: #eef6f2;
  --card: #ffffff;
  --danger: #d64545;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--green-dark); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.app-title { font-size: 19px; font-weight: 700; }

main { padding: 12px 12px 92px; max-width: 640px; margin: 0 auto; }
.view { animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.card-head h2 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 8px 0 0; }

.row-between { display: flex; align-items: center; justify-content: space-between; }
.row-gap { display: flex; gap: 8px; margin-top: 10px; }
.grow { flex: 1; }
.year-label { font-size: 14px; color: var(--muted); }
.year-select {
  font-size: 16px; font-weight: 700; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; background: #fff;
  margin-left: 6px;
}
.cat-select {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px; background: #fff; max-width: 45%;
}
.text-input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 10px; background: #fff; color: var(--ink);
}
.text-input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }

.chip-row { display: flex; gap: 8px; margin-top: 10px; }
.chip-row.wrap { flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 6px 14px; font-size: 14px;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }

.add-btn {
  width: 100%; margin-top: 12px; padding: 11px;
  background: var(--green-pale); color: var(--green-dark);
  border: 1.5px dashed var(--green); border-radius: 11px; font-weight: 700; font-size: 15px;
}
.primary-btn {
  background: var(--green); color: #fff; border: none; border-radius: 11px;
  padding: 12px 18px; font-weight: 700; font-size: 15px;
}
.primary-btn:disabled { opacity: .5; }
.primary-btn.block { width: 100%; margin-top: 6px; }
.sub-btn {
  background: #fff; color: var(--green-dark); border: 1.5px solid var(--green);
  border-radius: 11px; padding: 11px 16px; font-weight: 700; font-size: 14px;
}
.sub-btn.block { width: 100%; margin-top: 14px; }
.link-btn { background: none; border: none; color: var(--muted); text-decoration: underline; margin-top: 10px; }

.empty-note { color: var(--muted); text-align: center; padding: 18px 0 6px; font-size: 14px; }

/* 記録リスト */
.rec {
  display: flex; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line);
  cursor: pointer; align-items: flex-start;
}
.rec:last-child { border-bottom: none; }
.rec-main { flex: 1; min-width: 0; }
.rec-provider { font-weight: 700; font-size: 15px; word-break: break-all; }
.rec-product { font-size: 13px; color: var(--ink); margin-top: 1px; }
.rec-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; align-items: center; }
.rec-date { color: var(--muted); font-size: 12.5px; margin-right: 2px; }
.rec-amounts { text-align: right; white-space: nowrap; }
.rec-amount { font-weight: 700; font-size: 15px; }
.rec-net { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tag {
  font-size: 11.5px; border-radius: 999px; padding: 2px 8px; font-weight: 700;
}
.tag-person-m { background: #dceefb; color: #14507e; }
.tag-person-t { background: #fdf0d3; color: #7a5b00; }
.tag-cat { background: var(--green-pale); color: var(--green-dark); }
.tag-self { background: #ffe3d9; color: #a03d14; }

/* 集計 */
.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.total-box { background: var(--green-pale); border-radius: 11px; padding: 10px 12px; }
.total-box .t-label { font-size: 12px; color: var(--green-dark); font-weight: 700; }
.total-box .t-value { font-size: 19px; font-weight: 800; margin-top: 2px; }
.total-box.wide { grid-column: 1 / -1; }
.trial-row {
  display: flex; justify-content: space-between; align-items: center;
  border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 12px; margin-top: 8px;
}
.trial-row.winner { border-color: var(--green); background: var(--green-pale); }
.trial-name { font-weight: 700; font-size: 14.5px; }
.trial-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.trial-value { font-weight: 800; font-size: 17px; white-space: nowrap; }
.winner-badge {
  background: var(--green); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: 2px;
}
.year-info-view { margin-top: 10px; font-size: 13.5px; color: var(--ink); line-height: 1.7; }
.warn-box {
  margin-top: 10px; background: #fdf3e3; border: 1px solid #eec27f; color: #7a5200;
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.6; white-space: pre-line;
}

/* 設定などのフィールド */
.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--green-dark); margin-bottom: 5px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.check-row { display: flex; gap: 9px; align-items: flex-start; margin-top: 14px; font-size: 14px; line-height: 1.5; }
.check-row input { width: 20px; height: 20px; accent-color: var(--green); margin-top: 1px; flex: none; }

/* タブバー */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; padding: 8px 0 7px;
  font-size: 19px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tab span { font-size: 11px; font-weight: 700; }
.tab.active { color: var(--green-dark); }

/* ゲート（起動・ログイン） */
.gate {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate[hidden] { display: none; }
.gate-card {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 28px 22px; text-align: center; max-width: 340px; width: 100%;
}
.gate-icon { font-size: 44px; }
.gate-title { font-size: 20px; font-weight: 800; margin: 8px 0 4px; }
.gate-note { color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.gate-error { color: var(--danger); font-size: 13.5px; min-height: 1em; }
.google-btn { display: flex; justify-content: center; margin: 14px 0 4px; }

/* シート */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(20, 35, 29, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: rise .18s ease;
}
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h3 { margin: 0; font-size: 17px; }
.sheet-head-right { display: flex; align-items: center; gap: 8px; }
.close-btn {
  background: var(--green-pale); border: none; border-radius: 999px;
  width: 34px; height: 34px; font-size: 15px; color: var(--green-dark);
}
.trash-btn {
  background: none; border: none; border-radius: 999px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.arm-btn {
  background: var(--danger); color: #fff; border: none; border-radius: 999px;
  padding: 7px 12px; font-size: 13px; font-weight: 700;
}
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .primary-btn { flex: 1; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 60;
  background: var(--green-dark); color: #fff; border-radius: 999px;
  padding: 10px 18px; font-size: 14px; font-weight: 700; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  max-width: 88vw; text-align: center;
}
