/*
 * 建物管理報告（仮称） 画面の見た目
 * ℹ️ 土台の最小限のデザイン。見た目の仕上げは Codex の担当（AGENTS.md の範囲）。
 */
:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #dde2e8;
  --primary: #1f5f8b;
  --primary-d: #184b6e;
  --accent: #c25e00;
  --ok: #2e7d32;
  --ok-bg: #e7f4e8;
  --watch: #8a6d00;
  --watch-bg: #fff6d6;
  --fix: #b3261e;
  --fix-bg: #fdeceb;
  --info-bg: #e8f1f8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px; line-height: 1.7;
}
a { color: var(--primary); }
h1 { font-size: 1.45rem; margin: .2em 0 .6em; line-height: 1.4; }
h2 { font-size: 1.12rem; margin: 0 0 .7em; }
h3 { font-size: 1rem; margin: 1.2em 0 .4em; }

/* 上部バー */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand-sub { font-size: .72rem; font-weight: 600; background: var(--primary); color: #fff; border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); padding: 4px 10px; border-radius: 6px; }
.nav a.on, .nav a:hover { background: var(--info-bg); color: var(--primary); }
.who { margin-left: auto; font-size: .88rem; color: var(--muted); }

.main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.k-owner .main, .k-guest .main { max-width: 900px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 40px; }
.env-badge { background: #ffe9c7; color: #7a4a00; border-radius: 6px; padding: 4px 10px; font-size: .82rem; display: inline-block; margin: 0 0 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin: 0 0 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.crumb { font-size: .85rem; color: var(--muted); margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.num { text-align: right; }
.count { font-size: .85rem; color: var(--muted); font-weight: 400; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 3px 0; }

/* お知らせ */
.flash { border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; }
.flash-ok { background: var(--ok-bg); color: #1b5e20; }
.flash-error { background: var(--fix-bg); color: var(--fix); }
.flash-info { background: var(--info-bg); color: var(--primary-d); }

/* ボタン */
.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 16px; font-size: .95rem; cursor: pointer; text-decoration: none; line-height: 1.4; }
.btn:hover { background: #f0f3f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.93); background: var(--accent); }
.btn-danger { color: var(--fix); border-color: #f0b8b4; }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn-block { display: block; width: 100%; }
.btn-link { background: none; border: 0; color: var(--primary); text-decoration: underline; cursor: pointer; font-size: .9rem; padding: 0; }
button:disabled { opacity: .6; cursor: wait; }

/* フォーム */
.form .field { display: block; margin: 0 0 14px; }
.form .field > span, .form legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.form .field small { font-weight: 400; color: var(--muted); }
fieldset.field { border: 0; padding: 0; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=month], select, textarea {
  width: 100%; border: 1px solid #c7ced6; border-radius: 6px; padding: 8px 10px; font: inherit; background: #fff;
}
textarea { resize: vertical; min-height: 2.4em; }
.field-short input { width: 8em; }
.req { font-style: normal; font-size: .72rem; background: var(--fix); color: #fff; border-radius: 3px; padding: 0 5px; margin-left: 4px; }
.check { display: block; margin: 4px 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(245,246,248,.95); padding: 10px 0; border-top: 1px solid var(--line); z-index: 5; }
.form-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.form-inline input[type=month] { width: auto; }
.inline { display: inline; }
.grid2, .grid3, .grid4 { display: grid; gap: 0 14px; }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr 1fr; } }

/* 表 */
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 8px; text-align: left; vertical-align: top; }
.tbl th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #fafbfc; }
.tbl-edit td { padding: 6px 4px; }
.tbl-edit input, .tbl-edit select, .tbl-edit textarea { padding: 5px 7px; }
.c-cat { white-space: nowrap; color: var(--muted); font-size: .85rem; }
.c-radios { white-space: nowrap; }
.radio { display: inline-block; margin: 0 2px 2px 0; padding: 1px 7px 1px 3px; border-radius: 5px; border: 1px solid var(--line); font-size: .83rem; cursor: pointer; }
.radio input { margin: 0 3px 0 0; vertical-align: -1px; }
.st-pick.st-ok:has(input:checked) { background: var(--ok-bg); border-color: var(--ok); }
.st-pick.st-watch:has(input:checked) { background: var(--watch-bg); border-color: var(--watch); }
.st-pick.st-fix:has(input:checked) { background: var(--fix-bg); border-color: var(--fix); }
.st-pick.st-na:has(input:checked) { background: #eceff2; border-color: #9aa5b1; }
.row-new td { background: #fbfcfd; }
.row-fix td { background: #fff8f7; }
@media (max-width: 760px) {
  .tbl-edit thead { display: none; }
  .tbl-edit tr { display: block; border-bottom: 2px solid var(--line); padding: 6px 0; }
  .tbl-edit td { display: block; border: 0; }
}

/* 印 */
.tag { display: inline-block; font-size: .75rem; border-radius: 999px; padding: 0 9px; background: #eceff2; color: #4a5561; white-space: nowrap; vertical-align: 1px; }
.tag-ok, .tag-active { background: var(--ok-bg); color: var(--ok); }
.tag-warn, .tag-invited { background: var(--watch-bg); color: var(--watch); }
.tag-new { background: var(--fix); color: #fff; }
.tag-none, .tag-stopped { background: #eceff2; color: #4a5561; }
.tag-consult { background: #fbe3cf; color: var(--accent); }
.st { display: inline-block; font-size: .8rem; font-weight: 700; border-radius: 5px; padding: 1px 8px; white-space: nowrap; }
.st-ok { background: var(--ok-bg); color: var(--ok); }
.st-watch { background: var(--watch-bg); color: var(--watch); }
.st-fix { background: var(--fix-bg); color: var(--fix); }
.st-na, .st-none { background: #eceff2; color: #6b7785; }
.rp { display: inline-block; font-size: .8rem; font-weight: 700; border-radius: 5px; padding: 1px 8px; white-space: nowrap; }
.rp-done { background: var(--ok-bg); color: var(--ok); }
.rp-doing { background: var(--info-bg); color: var(--primary); }
.rp-consult { background: #fbe3cf; color: var(--accent); }
.tabs { display: flex; gap: 6px; margin: 0 0 12px; }
.tabs a { text-decoration: none; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: #fff; font-size: .88rem; }
.tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 報告書 */
.report { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 22px 24px; margin: 0 0 16px; }
.card-preview .report { border: 0; padding: 0; margin: 0; }
.preview-label { font-size: .8rem; color: var(--muted); border-bottom: 1px dashed var(--line); padding-bottom: 6px; margin: 0 0 14px; }
.report-head { border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: 18px; }
.report-building { margin: 0; color: var(--primary); font-weight: 700; }
.report-head h1 { margin: .1em 0 .4em; }
.report-meta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; font-size: .9rem; }
.report-meta div { display: flex; gap: 6px; }
.report-meta dt { color: var(--muted); }
.report-meta dd { margin: 0; }
.report-alert { background: #fff7ef; border: 1px solid #f3c79c; border-radius: 8px; padding: 12px 16px; margin: 0 0 18px; }
.report-alert h2 { color: var(--accent); font-size: 1rem; margin-bottom: .4em; }
.report-alert ul { margin: 0; padding-left: 1.2em; }
.report-sec { margin: 0 0 22px; }
.report-sec h2 { border-left: 4px solid var(--primary); padding-left: 8px; }
.report-text { margin: 0; }
.kv { margin: 0; }
.kv > div { display: flex; gap: 12px; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.kv dt { width: 6em; flex-shrink: 0; color: var(--muted); }
.kv dd { margin: 0; }
.kv-row { display: flex; flex-wrap: wrap; gap: 4px 28px; }
.kv-row > div { border: 0; }
.kv-row dt { width: auto; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.thumb { margin: 0; width: 132px; }
.thumbs-lg .thumb { width: 200px; }
.thumb img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); display: block; }
.thumb figcaption { font-size: .78rem; color: var(--muted); line-height: 1.4; margin-top: 2px; }

/* 社内: 写真の一覧 */
.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.photo-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fafbfc; }
.photo-item img { width: 100%; height: 150px; object-fit: cover; border-radius: 5px; display: block; margin-bottom: 6px; }
.photo-form select, .photo-form input { margin-bottom: 6px; font-size: .85rem; }
.upload-form { border-bottom: 1px solid var(--line); padding-bottom: 8px; }

/* やりとり */
.msgs { list-style: none; padding: 0; margin: 0 0 16px; }
.msg { border-radius: 10px; padding: 10px 14px; margin: 0 0 10px; max-width: 85%; }
.msg-owner { background: #eef4fa; }
.msg-staff { background: #f2f7ee; margin-left: auto; }
.k-owner .msg-owner { margin-left: auto; }
.k-owner .msg-staff { margin-left: 0; }
.msg-head { display: flex; gap: 10px; align-items: center; font-size: .8rem; color: var(--muted); }
.msg-who { font-weight: 700; color: var(--text); }
.msg-body { margin-top: 3px; }

/* 家主さん: 一覧 */
.report-list { list-style: none; padding: 0; margin: 0; }
.report-link { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 12px 10px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.report-link:hover { background: #f7f9fb; }
.report-link.is-unread .rl-title { font-weight: 700; }
.rl-title { flex: 1 1 260px; }
.rl-meta { font-size: .85rem; color: var(--muted); }
.rl-tags { display: flex; gap: 4px; }

/* ログイン */
.auth { max-width: 440px; margin: 24px auto; }
.auth-links { text-align: center; margin: 12px 0; }
.code-input { font-size: 1.5rem; letter-spacing: .3em; text-align: center; }
.print-btn { text-align: right; margin: -8px 0 8px; }

@media (max-width: 600px) {
  .card, .report { padding: 14px 14px; }
  .tbl-items thead { display: none; }
  .tbl-items tr { display: block; border-bottom: 1px solid var(--line); padding: 6px 0; }
  .tbl-items td { display: inline-block; border: 0; padding: 2px 6px 2px 0; }
  .tbl-items td.c-com { display: block; }
  .msg { max-width: 100%; }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .topbar, .footer, .no-print, .env-badge, .flash { display: none !important; }
  .main { max-width: none; padding: 0; }
  .report { border: 0; padding: 0; }
  .thumb { width: 110px; break-inside: avoid; }
  .report-sec { break-inside: auto; }
  .tbl tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
