/* =========================================================
   マンション管理システム  共通スタイル（index.html / admin.html）
   制作・運営: 旗二でじたる
   - 値と考え方の出どころは ../app.css（Claude Design のデザインシステム）
   - 既存のクラス名に当てている（対応表: ../デザイン引き継ぎ.md）
   - 文字は rem / em のみ・ボタンや枠は min-height + padding・nowrap なし
   ========================================================= */

:root {
  /* --- 色 --- */
  --main: #2b5f8e;        /* 紺青。白地で 6.6:1 */
  --main-dark: #1f4a70;   /* 押した時・薄青地の上の文字・役員ページの header */
  --main-light: #e4edf5;  /* 選択中・返事の吹き出し */
  --green: #276d45;       /* 完了・入金済・確認済み */
  --green-light: #e6f3ea;
  --red: #b8352a;         /* 緊急・未納・未対応 */
  --red-light: #fdecea;
  --amber: #8f5d0e;       /* 期限間近・気づき（文字用） */
  --amber-band: #e0a43a;  /* 気づきカードの帯（文字は載せない） */
  --amber-light: #fdf3e0;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --text: #26313b;        /* 白地で 12.9:1 */
  --gray: #5d656d;        /* 補足文字。背景色の上でも 5.6:1 */
  --line: #d3dae1;        /* 区切り線 */
  --line-strong: #8d99a5; /* 入力欄・選択肢の枠 */
  --focus: #f2b705;

  /* --- 文字 --- */
  --font: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --fs-resident: 1.125rem;
  --fs-admin: 1.063rem;
  --fs-sm: .889em;
  --fs-h2: 1.222em;
  --fs-h1: 1.444em;
  --fs-num: 2em;
  --lh: 1.7;
  --lh-tight: 1.4;

  /* --- 余白 --- */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem;

  /* --- 角丸・影・タップ領域 --- */
  --r-card: 14px; --r-btn: 12px; --r-input: 10px; --r-tag: 999px;
  --shadow: 0 1px 2px rgba(20,40,60,.06), 0 2px 10px rgba(20,40,60,.07);
  --tap: 44px;
  --tap-main: 52px;
}

/* --- 土台 --- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs-resident); line-height: var(--lh); color: var(--text); background: var(--bg);
  overflow-wrap: break-word; word-break: break-word; line-break: strict; padding-bottom: var(--sp-8); }
body.admin { font-size: var(--fs-admin); }
main { max-width: 860px; margin: 0 auto; padding: var(--sp-4) min(var(--sp-4), 16px) 0; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); margin: 0 0 var(--sp-3); font-weight: 700; }
h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); margin: 0 0 var(--sp-3); font-weight: 700; }
h3 { font-size: 1em; line-height: var(--lh-tight); margin: var(--sp-4) 0 var(--sp-2); font-weight: 700; }
h3:first-child { margin-top: 0; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--main); text-underline-offset: .18em; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* --- 画面の上下 --- */
header { background: var(--main); color: #fff; padding: var(--sp-3) var(--sp-4); text-align: center; font-weight: 700; line-height: var(--lh-tight); }
header h1 { font-size: 1.25em; margin: 0; }
header small { display: block; font-size: var(--fs-sm); font-weight: 400; opacity: .92; }
footer { padding: var(--sp-6) var(--sp-4) var(--sp-8); text-align: center; color: var(--gray); font-size: var(--fs-sm); }

/* --- もどる --- */
.back { display: inline-flex; align-items: center; gap: .3em; min-height: var(--tap); padding: .3em .9em .3em .6em; margin: 0 0 var(--sp-3);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-btn); background: var(--surface); color: var(--main); font-weight: 700; line-height: var(--lh-tight); text-decoration: none; cursor: pointer; }

/* --- カード --- */
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--sp-5) min(var(--sp-5), 20px); margin: 0 0 var(--sp-4); }
.card > h2:last-child, .card > p:last-child { margin-bottom: 0; }

/* --- ボタン（幅は自動。.full で 100%） --- */
.btn { display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--sp-2); min-height: var(--tap-main); padding: .7em 1em; margin: 0;
  border: 2px solid var(--main); border-radius: var(--r-btn); background: var(--main); color: #fff; font-weight: 700; line-height: var(--lh-tight); text-align: center; text-decoration: none; cursor: pointer; }
.btn.full { display: flex; width: 100%; }
.btn:active { background: var(--main-dark); border-color: var(--main-dark); }
.btn-line { background: var(--surface); color: var(--main); }
.btn-line:active { background: var(--main-light); color: var(--main-dark); }
.btn-line.on { background: var(--main-light); color: var(--main-dark); border-color: var(--main-dark); }
.btn-green { background: var(--green); border-color: var(--green); }
.btn-green:active { background: #1f5636; border-color: #1f5636; }
.btn-red { background: var(--surface); color: var(--red); border-color: var(--red); }
.btn-red:active { background: var(--red-light); }
.btn-red.solid { background: var(--red); color: #fff; }
.btn-sm { min-height: var(--tap); padding: .35em .9em; font-size: var(--fs-sm); border-width: 1.5px; }
.btn:disabled, .btn[aria-disabled="true"] { background: #e4e8ec; border-color: #e4e8ec; color: var(--gray); cursor: not-allowed; }
.btn small { display: block; width: 100%; font-size: var(--fs-sm); font-weight: 400; }
.btns { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.btns .btn { flex: 1 1 9em; }

/* --- 並べ方 --- */
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-3); }
.row.spread { justify-content: space-between; }
.row.spread > b { order: -1; flex: 1 1 100%; text-align: center; line-height: var(--lh-tight); }
.grow { flex: 1 1 10em; min-width: 0; }

/* --- タイル（住民のホーム / 役員のメニュー） --- */
.tiles, .menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 8.5em), 1fr)); gap: var(--sp-3); }
.tile, .menu button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1); min-height: 6.4em; padding: var(--sp-4) var(--sp-3);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow); color: var(--text); font-weight: 700; line-height: var(--lh-tight); text-align: center; text-decoration: none; cursor: pointer; }
.tile:active, .menu button:active { background: var(--main-light); border-color: var(--main); }
.tile .ic, .menu .ic { font-size: 1.7em; line-height: 1.2; }
.badge { position: absolute; top: .45em; right: .45em; min-width: 1.7em; padding: .05em .45em; border-radius: var(--r-tag); background: var(--red); color: #fff; font-size: .8em; font-weight: 700; line-height: 1.5; text-align: center; }

/* --- 選択肢（ウィザード・施設） --- */
.choice { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: var(--sp-3); row-gap: var(--sp-1); width: 100%; min-height: var(--tap-main); padding: .8em 1em; margin: 0 0 var(--sp-3);
  background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--r-btn); color: var(--text); font-weight: 700; line-height: var(--lh-tight); text-align: left; cursor: pointer; }
.choice::before { content: ""; flex: none; width: 1.15em; height: 1.15em; border: 2px solid var(--line-strong); border-radius: 50%; background: #fff; }
.choice.on { border-color: var(--main); background: var(--main-light); color: var(--main-dark); }
.choice.on::before { border-color: var(--main); background: var(--main); box-shadow: inset 0 0 0 .2em #fff; }
.choice.multi::before { border-radius: 5px; }
.choice.multi.on::before { content: "✔"; display: grid; place-items: center; color: #fff; box-shadow: none; font-size: .9em; line-height: 1; }
.choice small { grid-column: 2; font-weight: 400; color: var(--gray); font-size: var(--fs-sm); }
.choice:disabled { background: #eceff2; border-color: var(--line); color: var(--gray); cursor: not-allowed; }
.choice:disabled::before { border-color: var(--line); background: #eceff2; }
.seg { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.seg .choice { flex: 1 1 6em; width: auto; margin: 0; }

/* --- 一覧行 --- */
.item { display: block; position: relative; padding: var(--sp-4) 0; border-top: 1px solid var(--line); color: var(--text); }
.item:first-child { border-top: 0; padding-top: var(--sp-1); }
.item b { line-height: var(--lh-tight); }
.item.link { cursor: pointer; padding-right: 1.6em; }
.item.link::after { content: "›"; position: absolute; right: .2em; top: 50%; transform: translateY(-50%); color: var(--gray); font-size: 1.5em; line-height: 1; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); margin-top: var(--sp-1); color: var(--gray); font-size: var(--fs-sm); line-height: var(--lh-tight); }
.meta .tag { font-size: 1em; }
.meta .red { color: var(--red); font-weight: 700; }

/* --- タグ --- */
.tag { display: inline-flex; align-items: center; gap: .25em; padding: .1em .65em; border-radius: var(--r-tag); background: var(--main-light); color: var(--main-dark); font-size: var(--fs-sm); font-weight: 700; line-height: 1.5; vertical-align: middle; }
.tag.red { background: var(--red-light); color: var(--red); }
.tag.green { background: var(--green-light); color: var(--green); }
.tag.gray { background: #e6e9ec; color: var(--gray); }
.tag.amber { background: var(--amber-light); color: var(--amber); }

/* --- 返事の吹き出し --- */
.reply { margin: var(--sp-3) 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--main-light); border-radius: 4px var(--r-card) var(--r-card) var(--r-card); line-height: var(--lh); }
.reply .who { display: block; color: var(--main-dark); font-size: var(--fs-sm); font-weight: 700; }

/* --- 確認行（ウィザードの確認・管理費） --- */
.ck { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.ck:first-child { border-top: 0; }
.ck .cl { flex: 1 1 100%; color: var(--gray); font-size: var(--fs-sm); line-height: var(--lh-tight); }
.ck .cv { flex: 1 1 8em; font-weight: 700; line-height: var(--lh-tight); }
.ck .cv.pre { white-space: pre-wrap; }

/* --- ウィザードの進み具合 --- */
.step { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-1) var(--sp-3); margin: 0 0 var(--sp-2); color: var(--main-dark); font-weight: 700; line-height: var(--lh-tight); }
.bar { height: .5em; margin: 0 0 var(--sp-5); border-radius: var(--r-tag); background: var(--main-light); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--main); border-radius: var(--r-tag); }

/* --- 完了画面 --- */
.done { text-align: center; padding: var(--sp-4) 0; }
.done .done-ic { display: inline-grid; place-items: center; width: 3.2em; height: 3.2em; margin: 0 0 var(--sp-3); border-radius: 50%; background: var(--green); color: #fff; font-size: 1.4em; font-weight: 700; line-height: 1; }
.done h2 { color: var(--green); }

/* --- 数字 --- */
.money { font-size: var(--fs-num); font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.money.red { color: var(--red); }
.money.green { color: var(--green); }
.counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10em), 1fr)); gap: var(--sp-2); margin: 0 0 var(--sp-3); }
.counts div { min-width: 0; padding: var(--sp-3) var(--sp-2); border-radius: 10px; background: var(--bg); color: var(--gray); font-size: var(--fs-sm); line-height: var(--lh-tight); text-align: center; }
.counts b { display: block; color: var(--text); font-size: 1.8em; line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; word-break: normal; }
.counts .red b { color: var(--red); }
.counts .green b { color: var(--green); }

/* --- 文字の部品 --- */
.hint { color: var(--gray); font-size: var(--fs-sm); line-height: var(--lh); }
p.hint { margin: 0 0 var(--sp-3); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.err { color: var(--red); font-weight: 700; margin-top: var(--sp-2); min-height: 1.5em; line-height: var(--lh-tight); }
.err:not(:empty), .errbox { padding: var(--sp-3) var(--sp-4); border-radius: 10px; background: var(--red-light); }
.ok { color: var(--green); font-weight: 700; }
p.ok, div.ok { padding: var(--sp-3) var(--sp-4); margin: var(--sp-3) 0; border-radius: 10px; background: var(--green-light); line-height: var(--lh-tight); }
.late { color: var(--red); font-weight: 700; }

/* --- 入力欄 --- */
.fg { margin: 0 0 var(--sp-4); }
.flabel { display: block; margin: 0 0 var(--sp-2); font-weight: 700; line-height: var(--lh-tight); }
input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input[type="password"], input[type="date"], input[type="month"], select, textarea {
  display: block; width: 100%; max-width: 100%; min-width: 0; min-height: var(--tap-main); padding: .6em .8em; border: 2px solid var(--line-strong); border-radius: var(--r-input); background: #fff; color: var(--text); line-height: var(--lh-tight); }
textarea { min-height: 7em; line-height: var(--lh); resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--main); }
input[type="file"] { display: block; width: 100%; min-height: var(--tap); padding: .4em 0; }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); margin: 0 var(--sp-4) 0 0; font-weight: 700; cursor: pointer; }
.check input { flex: none; width: 1.35em; height: 1.35em; margin: 0; accent-color: var(--main); }

/* --- 表 --- */
.twrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); line-height: var(--lh-tight); font-variant-numeric: tabular-nums; }
th, td { padding: .65em .5em; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; overflow-wrap: normal; word-break: keep-all; } /* 表は詰めずに .twrap で横スクロール */
th { background: var(--bg); color: var(--gray); font-weight: 700; }
td.r, th.r { text-align: right; min-width: 5.5em; }
table input[type="text"], table input[type="number"], table input[type="date"], table select { min-height: var(--tap); padding: .35em .5em; font-size: 1em; margin: 0 0 var(--sp-1); }
table .btn-sm { margin: 0; }

/* --- 折りたたみ --- */
details { margin: var(--sp-3) 0 0; border: 1.5px solid var(--line); border-radius: var(--r-btn); background: var(--surface); padding: 0 1em; }
summary { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: var(--tap); padding: .55em 0; margin: 0 -1em; padding-left: 1em; padding-right: 1em; color: var(--main); font-weight: 700; line-height: var(--lh-tight); cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "＋"; flex: none; }
details[open] summary::after { content: "－"; }
details[open] { padding-bottom: 1em; }

/* --- 写真 --- */
.photo { display: block; max-width: 100%; border-radius: 10px; margin-top: var(--sp-2); }
.photo.thumb { max-height: 7em; width: auto; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5em, 1fr)); gap: var(--sp-2); }
.ph { display: grid; place-items: center; aspect-ratio: 1 / 1; border-radius: 10px; background: #dde3e9; color: var(--gray); font-size: var(--fs-sm); text-align: center; }

/* --- カレンダーの凡例 --- */
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin: var(--sp-2) 0 var(--sp-3); color: var(--gray); font-size: var(--fs-sm); }

/* --- トースト --- */
#toast { display: none; position: fixed; bottom: var(--sp-8); left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: .8em 1.4em; border-radius: var(--r-tag); font-size: var(--fs-sm); z-index: 100; max-width: 90%; text-align: center; }
