/* Reset & base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif; font-size: 14px; color: #222; background: #f5f7fa; }
a { color: #2a6cb0; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px 0; }
h2 { font-size: 16px; margin: 0 0 8px 0; }
h3 { font-size: 14px; margin: 0 0 6px 0; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 100; height: 48px; background: #2c3e50; color: #fff; display: flex; align-items: center; padding: 0 12px; gap: 12px; }
.topbar .brand { color: #fff; font-weight: bold; font-size: 19px; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }
.topbar .user-menu { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.topbar .user-menu a { color: #cde4ff; }
.topbar .user-label { color: #bbb; }
.plan-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; background: #1971c2; color: #fff; vertical-align: middle; }
.burger { display: none; background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 48px); }
.sidebar { width: 180px; background: #34495e; padding: 8px 0; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar a { display: block; padding: 10px 16px; color: #dfe6ed; font-size: 13px; border-left: 3px solid transparent; }
.sidebar a:hover { background: #2c3e50; color: #fff; border-left-color: #4a90e2; text-decoration: none; }
.sidebar-footer { margin-top: auto; padding: 12px 16px 8px; border-top: 1px solid #2c3e50; }
.sidebar-footer a { display: inline; padding: 0; font-size: 11px; color: #8899aa; border: none; }
.sidebar-footer a:hover { background: none; color: #ccc; border: none; }
.sidebar-section { padding: 14px 16px 4px; font-size: 10px; color: #7f95a8; letter-spacing: 1.5px; }
.content { flex: 1; padding: 16px; max-width: 1400px; min-width: 0; /* 子のwide tableで親が伸びないように */ }

/* Mobile */
@media (max-width: 768px) {
  .burger { display: block; }
  .sidebar {
    position: fixed; top: 48px; left: 0;
    height: calc(100vh - 48px);
    width: 220px;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 110;
    box-shadow: 2px 0 12px rgba(0,0,0,0.2);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  /* サイドバー展開時の背景オーバーレイ */
  .sidebar-backdrop {
    display: none;
    position: fixed; top: 48px; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 100;
  }
  .sidebar.open + .sidebar-backdrop,
  body.sb-open .sidebar-backdrop { display: block; }
  .topbar .user-label { display: none; }
  .content { padding: 10px; }
  h1 { font-size: 18px; }
}

/* Flash messages */
.flash { padding: 10px 14px; border-radius: 4px; margin-bottom: 10px; }
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.flash-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* Auth page */
.auth-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #2c3e50; padding: 20px; }
.auth-card { background: #fff; padding: 28px; border-radius: 8px; min-width: 320px; max-width: 400px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.auth-card h1 { text-align: center; margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; }
.auth-form input { padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* actions 内の削除/再構築フォームは箱を持たせず中のボタンを直接 flex アイテムにする
   （モバイルの .actions .btn { flex:1 } を form 包みボタンにも効かせるため）。
   テンプレート側で style="display:inline" を付けるとこれが負けるので付けないこと */
.page-header .actions form { display: contents; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.section-head h2 { margin: 0; }

/* Buttons */
/* font-family: inherit がないと <button> はブラウザ既定(Arial/MSゴシック系)になり
   <a class="btn"> と字形・幅・ベースラインがズレる。vertical-align はインライン文脈での1pxズレ対策 */
.btn { display: inline-block; padding: 7px 14px; border: 1px solid #bbb; background: #fff; color: #333; border-radius: 4px; cursor: pointer; font-family: inherit; font-size: 13px; text-decoration: none; line-height: 1.3; vertical-align: middle; }
.btn:hover { background: #f0f0f0; text-decoration: none; }
.btn-primary { background: #2c7be5; color: #fff; border-color: #2c7be5; }
.btn-primary:hover { background: #1a62c7; color: #fff; }
.btn-danger { background: #e0534f; color: #fff; border-color: #e0534f; }
.btn-danger:hover { background: #c63431; color: #fff; }
.btn-small, .btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-sm.active { background: #1976d2; color: #fff; border-color: #1976d2; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; padding: 10px; background: #fff; border-radius: 4px; border: 1px solid #e1e5eb; }
.toolbar input[type=text], .toolbar select, .toolbar input[type=date], .toolbar input[type=number] { padding: 6px 10px; border: 1px solid #ccc; border-radius: 3px; }
.toolbar .inline { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
/* JS 有効時は冗長な「検索」ボタンを隠す（自動送信のため） */
.js-on .toolbar > button[type=submit].btn:not(.btn-primary):not(.btn-danger) { display: none; }

/* Cards */
.card { background: #fff; padding: 16px; border-radius: 6px; border: 1px solid #e1e5eb; margin-bottom: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card.link { transition: box-shadow 0.2s; }
.card.link:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); text-decoration: none; color: inherit; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; padding: 12px; border-radius: 6px; border: 1px solid #e1e5eb; }
.kpi-label { font-size: 11px; color: #666; margin-bottom: 4px; }
.kpi-value { font-size: 18px; font-weight: bold; color: #2c3e50; }
a.kpi { display: block; color: inherit; }
a.kpi:hover { border-color: #4a90e2; text-decoration: none; }
/* 画面の役割宣言（h1 / page-header 直下の1行） */
.page-desc { font-size: 12px; color: #888; margin: -4px 0 14px; line-height: 1.6; }
/* ダッシュボード「今月のやること」ステップ */
.todo-step { flex: 1 1 150px; min-width: 140px; border: 1px solid #e1e5eb; border-radius: 6px; padding: 8px 10px; font-size: 12px; color: #2c3e50; display: block; }
.todo-step:hover { border-color: #4a90e2; text-decoration: none; }
.todo-step.done { background: #f2f9f2; border-color: #bcd9bc; }
.todo-num { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: #4a90e2; color: #fff; text-align: center; line-height: 18px; font-size: 11px; margin-right: 6px; }
.todo-step.done .todo-num { background: #57a957; }
.todo-state { display: block; margin-top: 4px; color: #888; font-size: 11px; }

/* Tables */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid #e1e5eb; border-radius: 4px; -webkit-overflow-scrolling: touch; }
table.data {
  /* セル内で折り返さず、必要に応じて横スクロール（width:100% は使わない）*/
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid #eaecef;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;     /* デフォルトは改行禁止 */
}
table.data thead th { background: #f7f9fc; font-weight: 600; color: #555; position: sticky; top: 0; }
table.data tfoot th { background: #f7f9fc; font-weight: bold; }
table.data tr:hover { background: #f9fbfd; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .small { font-size: 11px; color: #666; }
table.data .neg { color: #c0392b; }
table.data .total { background: #f0f5fb; font-weight: bold; }
/* 固定1列目は背景を明示する（inherit だと行が無色のとき透明になり、横スクロールで下の列が透けて文字が重なる） */
table.data.pivot th:first-child, table.data.pivot td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
table.data.pivot thead th:first-child, table.data.pivot tfoot th:first-child { background: #f7f9fc; z-index: 2; }
table.data.pivot tbody tr:hover td:first-child { background: #f9fbfd; }
/* 折り返しを許可するセル（住所・メモなど）*/
table.data td.wrap, table.data td.address, table.data .pre {
  white-space: normal;
  word-break: break-word;
  max-width: 280px;
}

/* インラインセル編集（明細一覧などで使用） */
table.data td .inline-edit,
.inline-edit {
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  width: 100%;
  min-width: 0;
  color: #222;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  appearance: auto;
}
table.data td .inline-edit:hover { background: #fff; border-color: #d1d5db; }
table.data td .inline-edit:focus {
  outline: none;
  background: #fff;
  border-color: #2c7be5;
  box-shadow: 0 0 0 2px rgba(44,123,229,0.15);
}
table.data td input.inline-edit { padding: 4px 6px; }
table.data td.cell-edit { padding: 4px 6px; }

/* 状態バッジ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-review { background: #ffe4d6; color: #9a3412; }
.badge-draft { background: #e5e7eb; color: #374151; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* インライン編集セレクトを薄くしたい列向け */
table.data tbody tr.row-unclassified { background: #fffbeb !important; }
table.data tbody tr.row-review { background: #fff7ed !important; }
table.data tbody tr.row-confirmed { background: #f0fdf4 !important; }

/* ソート可能ヘッダ */
table.data thead th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px;
}
table.data thead th.sortable:hover { background: #eaeff5; }
table.data thead th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #aaa;
}
table.data thead th.sort-asc::after { content: '▲'; color: #2c7be5; font-size: 9px; }
table.data thead th.sort-desc::after { content: '▼'; color: #2c7be5; font-size: 9px; }

/* KV */
dl.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
dl.kv dt { color: #666; font-weight: normal; }
dl.kv dd { margin: 0; }
dl.kv dd.pre { white-space: pre-wrap; }

@media (max-width: 640px) {
  dl.kv { grid-template-columns: 110px 1fr; font-size: 12px; }
}

/* Forms */
.form-card { background: #fff; padding: 16px; border-radius: 6px; border: 1px solid #e1e5eb; }
.form-card fieldset { border: 1px solid #e1e5eb; padding: 10px; margin: 0 0 12px 0; border-radius: 4px; }
.form-card legend { padding: 0 6px; font-size: 13px; font-weight: bold; color: #2c3e50; }
.form-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin-bottom: 10px; }
.form-card label > span { color: #555; font-size: 12px; }
.form-card input, .form-card select, .form-card textarea { padding: 7px 10px; border: 1px solid #ccc; border-radius: 3px; font-size: 13px; font-family: inherit; }
.form-card label.inline { flex-direction: row; align-items: center; gap: 6px; }
.form-card label.inline input[type=checkbox] { width: auto; margin: 0; }
.grid-form fieldset { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 14px; }
.grid-form label.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 12px; }

.inline-form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.inline-form input, .inline-form select { padding: 5px 8px; border: 1px solid #ccc; border-radius: 3px; font-size: 12px; }

/* Tags */
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: #eee; color: #555; margin-right: 3px; }
.tag.active, .tag.success { background: #d4edda; color: #155724; }
.tag.vacant, .tag.warning { background: #fff3cd; color: #856404; }
.tag.sold, .tag.failed, .tag.expired { background: #f8d7da; color: #721c24; }
.tag.partial { background: #d1ecf1; color: #0c5460; }
.tag.admin { background: #2c3e50; color: #fff; }
.tag.owner { background: #2c7be5; color: #fff; }
.tag.viewer { background: #95a5a6; color: #fff; }
.tag.ok { background: #d4edda; color: #155724; }
.tag.neg { background: #f8d7da; color: #721c24; }
.tag.muted { background: #eee; color: #888; }

/* 部屋行の入居/空室ハイライト */
table.data tr.row-occ { background: #f3faf4; }
table.data tr.row-vac { background: #fff5f5; }
table.data tr.row-occ:hover { background: #e8f5ea; }
table.data tr.row-vac:hover { background: #fdecec; }

/* Tabs */
.tabs { display: flex; gap: 2px; background: #fff; border-radius: 4px; padding: 4px; margin-bottom: 10px; overflow-x: auto; white-space: nowrap; }
.tabs a { padding: 6px 14px; font-size: 13px; color: #555; border-radius: 3px; }
.tabs a:hover { background: #f0f5fb; text-decoration: none; }
.tabs a.active { background: #4a90e2; color: #fff; }

.muted { color: #888; }
.neg { color: #c0392b; }
.pre { white-space: pre-wrap; }

/* Dropzone */
.dropzone { border: 2px dashed #bbb; padding: 24px; text-align: center; border-radius: 6px; cursor: pointer; background: #fafbfc; color: #666; transition: all 0.15s; }
.dropzone:hover, .dropzone.drag { border-color: #2c7be5; background: #f0f7ff; color: #2c7be5; }

.upload-row { padding: 8px 12px; margin: 6px 0; border-radius: 4px; background: #f5f7fa; font-size: 13px; }
.upload-row.ok { background: #d4edda; color: #155724; }
.upload-row.err { background: #f8d7da; color: #721c24; }

pre.log { background: #f5f7fa; padding: 10px; border: 1px solid #e1e5eb; border-radius: 4px; overflow: auto; max-height: 400px; font-size: 11px; }

/* Modal */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-content { background: #fff; padding: 20px; border-radius: 6px; max-width: 900px; width: 100%; max-height: 85vh; overflow: auto; position: relative; }

/* × は「スクロールしても常に見える」こと。
   .modal-content は overflow:auto なので、中に position:absolute で置くと
   中身と一緒に上へ流れて消える（スマホは全画面＝必ずスクロールするので実質詰む）。
   sticky + float:right なら箱の中に留まりつつ、後続テキストの邪魔もしない。
   ヘッダ内に置くため position:static を直書きしている画面（dashboard 等）は
   そのまま動く（下の .close 側の指定だけが効く）。 */
.modal-content .close {
  position: sticky; top: 0;              /* スクロールしても白い箱の上端に吸い付く */
  float: right;
  z-index: 5;
  margin: -20px -20px 0 8px;             /* padding を食って角に寄せる */
  padding: 10px 16px;                    /* タップ標的を 44px 級に */
  line-height: 1;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  background: #fff;
  border-bottom-left-radius: 8px;
  -webkit-tap-highlight-color: rgba(0,0,0,.1);
}
.modal-content .close:hover { color: #333; }
/* ヘッダ行の中に置く運用（position:static を直書き）の画面向け。
   float/margin の打ち消しは style 属性より詳細度を上げないと効かないので
   :not() で明示的に外す */
.modal-content .close[style*="static"] { float: none; margin: 0; padding: 4px 10px; }
/* その「ヘッダ行」自体も固定する。report_cash_flow / report_property_summary /
   loan_schedule は .modal-content 側が overflow:auto なので、position:static に
   しただけではヘッダごと流れて × が消えていた（実測: スクロール後 top=-1345px）。
   box-shadow は .modal-content の padding 帯を白で塞ぐためのもの（ぼかし0の白帯）。
   :has() 非対応ブラウザではこのルールごと無視される＝従来の挙動に戻るだけ。 */
.modal-content > div:has(> .close[style*="static"]) {
  position: sticky; top: 0; z-index: 4;
  background: #fff;
  box-shadow: 0 -24px 0 #fff;
}

/* ============================================================
   スマホ最適化（640px以下）
   タッチターゲット拡大／グリッド縮約／表は横スクロール
   ============================================================ */
@media (max-width: 640px) {
  body { font-size: 14px; }
  h1 { font-size: 17px; }
  h2 { font-size: 15px; }

  /* タッチ用に上下のヒット領域を確保 */
  .btn { padding: 9px 14px; font-size: 14px; min-height: 38px; }
  .btn-small { padding: 6px 10px; font-size: 12px; min-height: 30px; }

  /* リンク間隔（誤タップ防止） */
  .sidebar a { padding: 12px 16px; font-size: 14px; }

  /* ページヘッダ: 縦積み・全幅ボタン */
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .actions { width: 100%; }
  .page-header .actions .btn { flex: 1 1 auto; text-align: center; }

  /* カードグリッド: 1列 */
  .card-grid { grid-template-columns: 1fr; }
  .card { padding: 12px; }

  /* KPI: 2列（小さな画面でちょうど見やすい） */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 10px 8px; }
  .kpi-value { font-size: 16px; word-break: break-all; }

  /* 入力ツールバー: 1行ずつ・全幅 */
  .toolbar { flex-direction: column; align-items: stretch; padding: 8px; }
  .toolbar > label, .toolbar > input, .toolbar > select, .toolbar > .btn { width: 100%; }
  .toolbar input[type=text], .toolbar input[type=date],
  .toolbar input[type=number], .toolbar input[type=month],
  .toolbar select { width: 100%; padding: 9px 10px; font-size: 14px; }
  .toolbar .inline { width: auto; }
  .toolbar > label { display: flex; flex-direction: column; gap: 4px; }

  /* フォーム: 1列＋大きめ入力 */
  .form-card { padding: 12px; }
  .grid-form fieldset { grid-template-columns: 1fr; gap: 8px 0; }
  .form-card input, .form-card select, .form-card textarea { padding: 9px 10px; font-size: 14px; min-height: 38px; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; text-align: center; }

  /* 説明用 dl: ブロック表示 */
  dl.kv { display: block; }
  dl.kv dt { color: #888; font-size: 11px; margin-top: 8px; }
  dl.kv dd { margin: 2px 0 0 0; }

  /* テーブル: スマホでは文字を少し小さく */
  table.data { font-size: 12px; }
  table.data th, table.data td { padding: 6px 10px; }
  table.data td.wrap, table.data td.address, table.data .pre { max-width: 200px; }
  /* dl.kv の中の住所など長文 */
  dl.kv dd { word-break: break-word; }

  /* タブ: 横スクロールのまま、タップ対応で大きめ */
  .tabs { padding: 4px 6px; gap: 4px; }
  .tabs a { padding: 8px 14px; font-size: 13px; }

  /* インラインフォーム（金利追加・返済追加など） */
  .inline-form { gap: 6px; }
  .inline-form input, .inline-form select { padding: 8px 10px; font-size: 13px; min-height: 36px; flex: 1 1 calc(50% - 8px); }
  .inline-form .btn { width: 100%; }

  /* モーダル全画面化。
     100vh はアドレスバーの分だけ画面より大きくなり、上端（＝×のある場所）が
     ブラウザのバーの裏に潜る。100dvh は実際に見えている高さなので潜らない。
     dvh 非対応ブラウザ向けに 100vh を先に置いてフォールバックさせる。 */
  .modal { padding: 0; }
  .modal-content {
    max-height: 100vh; height: 100vh;
    max-height: 100dvh; height: 100dvh;
    border-radius: 0;
    padding: 14px;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  /* padding が 14px になるぶん × の食い込み量も合わせる */
  .modal-content .close {
    margin: calc(-14px - env(safe-area-inset-top)) -14px 0 8px;
    padding: 12px 18px;                  /* 指で押せる大きさを確保 */
    font-size: 26px;
  }

  /* ダッシュボードのチャート高さ */
  #chart { max-height: 280px; }

  /* プロフィールシート: 列幅を縮め、ラベルを折り返す */
  table.matrix col.label-col { width: 110px !important; }
  table.matrix col.total-col { width: 80px !important; }
  table.matrix col.prop-col  { width: 100px !important; }
  table.matrix { font-size: 10.5px; }
  table.matrix th, table.matrix td { padding: 4px 5px; }

  /* ドロップゾーン */
  .dropzone { padding: 16px 12px; font-size: 13px; }

  /* ユーザーメニューの整理 */
  .topbar { padding: 0 8px; gap: 8px; }
  .topbar .brand { font-size: 15px; }
  .topbar .user-menu { gap: 8px; font-size: 12px; }
  .topbar .user-menu a { padding: 4px 0; }

  /* フラッシュ通知 */
  .flash { padding: 10px 12px; font-size: 13px; }
}

/* 超小型（〜380px = iPhone SE 縦） */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 18px; }
  .topbar .user-menu .user-label { display: none; }
}

/* ── 共通アラート / バッジ（AssetHub 系画面で使用） ── */
.alert { border-radius: 6px; padding: 8px 14px; margin-bottom: 12px; font-size: 13px; }
.alert-info   { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-warn   { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; }
.alert-danger { background: #fdecea; border: 1px solid #f5b7b1; color: #922b21; }
.tag-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag-linked { background: #dbeafe; color: #1e40af; }
.tag-ok     { background: #dcfce7; color: #166534; }
.tag-warn   { background: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.tag-danger { background: #fde2e1; color: #c0392b; border: 1px solid #f5b7b1; }
/* サブナビの未処理件数バッジ */
.nav-badge { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: #d97706; color: #fff; font-size: 10px; font-weight: 700; text-align: center; }
/* リンクバッジ内の解除ボタン */
.unlink-btn { background: none; border: none; color: #b91c1c; cursor: pointer; font-size: 11px; font-weight: 700; padding: 0 2px; margin-left: 2px; }
.unlink-btn:hover { color: #7f1d1d; }

/* ── 弥生風コンボ（combo.js Bパターン: button + hidden select）共通スタイル ── */
.combo-wrap   { position: relative; width: 100%; display: flex; align-items: center; }
.combo-hidden { display: none !important; }
.combo-btn {
  -webkit-appearance: none; appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 8px 5px;
  padding: 4px 22px 4px 8px; border: 1.5px solid #d0d7de; border-radius: 5px;
  font-size: 12px; font-family: inherit; cursor: pointer;
  width: 100%; height: 28px; box-sizing: border-box;
  color: #24292f; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color .15s, box-shadow .15s;
}
.combo-btn:hover:not(:disabled) { border-color: #9ba3ab; }
.combo-btn:focus:not(:disabled) { outline: none; border-color: #1976d2; box-shadow: 0 0 0 3px rgba(25,118,210,.15); }
.combo-btn:disabled { opacity: 0.35; cursor: default; }
.combo-btn.unset-value { color: #9ca3af; }
.combo-btn.common-value { color: #0a5d2b; background-color: #ecfdf5; border-color: #86efac; font-weight: 500; }

/* ============================================================
   空室分析（/vacancies/analytics）
   全パネルが1つのフィルタ状態に連動するクライアント集計画面
   ============================================================ */

/* ── フィルタバー（画面上部に固定・全パネル共通） ── */
.vac-filterbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px;
  background: #fff; border: 1px solid #e1e5eb; border-radius: 6px;
  padding: 10px 12px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.vac-filterbar label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #666; }
.vac-filterbar label.inline { flex-direction: row; align-items: center; gap: 5px; font-size: 12px; color: #333; padding-bottom: 5px; }
.vac-filterbar select, .vac-filterbar input[type=month], .vac-filterbar input[type=number] {
  font: inherit; font-size: 12px; padding: 4px 6px;
  border: 1px solid #d0d7de; border-radius: 4px; background: #fff; min-height: 28px;
}
.vac-filterbar select[multiple] { min-height: 62px; min-width: 150px; }
.vac-filterbar .spacer { flex: 1 1 auto; }

/* 適用中の絞り込みチップ（グラフクリックによるドリルダウンを含む） */
.vac-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.vac-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
  border-radius: 12px; padding: 2px 6px 2px 10px; white-space: nowrap;
}
.vac-chip button { background: none; border: none; color: #1e40af; cursor: pointer; font-size: 13px; line-height: 1; padding: 0 3px; }
.vac-chip button:hover { color: #7f1d1d; }

/* ── チャート共通ラッパ（高さ固定・#chart は使わない） ── */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box.tall { height: 340px; }

/* ヒストグラムと箱ひげの2段組。min-width:0 が無いと 1fr トラックが canvas の
   固有幅より縮まず、ページ全体が横スクロールしてしまう */
.vac-dist-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.vac-dist-grid > div { min-width: 0; }

/* パネル内のタブ（軸切替。.tabs のボタン版） */
.tabs button {
  padding: 6px 14px; font-size: 13px; color: #555; border-radius: 3px;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.tabs button:hover { background: #f0f5fb; }
.tabs button.active { background: #4a90e2; color: #fff; }

/* ── 占有ヒートマップ（物件-部屋 × 年月） ── */
.vac-heatmap-wrap { overflow: auto; max-height: 620px; border: 1px solid #e1e5eb; border-radius: 4px; background: #fff; }
table.vac-heatmap { border-collapse: separate; border-spacing: 0; font-size: 11px; width: max-content; }
table.vac-heatmap th, table.vac-heatmap td { padding: 0; margin: 0; }

/* 左の固定列: 物件/部屋 + 成績3列（入居月数・空室月数・想定家賃） */
table.vac-heatmap .vac-fix {
  position: sticky; z-index: 2; background: #fff;
  white-space: nowrap; font-weight: 400; height: 18px; line-height: 18px;
}
table.vac-heatmap .vac-rowhead {
  left: 0; min-width: 170px; max-width: 170px;
  padding: 0 8px; text-align: left; overflow: hidden; text-overflow: ellipsis;
}
table.vac-heatmap .m1 { left: 170px; min-width: 46px; max-width: 46px; }
table.vac-heatmap .m2 { left: 216px; min-width: 46px; max-width: 46px; }
table.vac-heatmap .m3 { left: 262px; min-width: 86px; max-width: 86px; border-right: 1px solid #d0d7de; }
table.vac-heatmap .m1, table.vac-heatmap .m2, table.vac-heatmap .m3 {
  padding: 0 6px; text-align: right; font-variant-numeric: tabular-nums; color: #555;
}
table.vac-heatmap tr.vac-prop-row .vac-fix { font-weight: 600; background: #f7f9fc; height: 22px; line-height: 22px; }
table.vac-heatmap tr.vac-prop-row .vac-rowhead { cursor: pointer; }
table.vac-heatmap tr.vac-prop-row:hover .vac-fix { background: #eaeff5; }
table.vac-heatmap tr.vac-room-row .vac-rowhead { padding-left: 22px; color: #555; }
.vac-caret { display: inline-block; width: 11px; color: #888; font-size: 9px; }

/* 年ヘッダ（年ごとに colspan でまとめる。1セル13px に絶対配置で載せると
   隣の sticky セルの背景に上から塗り潰されて読めなくなるため） */
table.vac-heatmap thead th {
  position: sticky; top: 0; z-index: 3; background: #f7f9fc;
  height: 20px; font-size: 11px; color: #444; font-weight: 600;
  border-bottom: 1px solid #d0d7de; white-space: nowrap; text-align: center;
}
table.vac-heatmap thead th.vac-fix { z-index: 4; background: #f7f9fc; font-size: 11px; }
table.vac-heatmap thead th.vac-rowhead { text-align: left; }
table.vac-heatmap thead th.vac-year { border-left: 1px solid #c8d0d8; }

/* セル */
.vac-cell { width: 13px; min-width: 13px; border-right: 1px solid #fff; border-bottom: 1px solid #fff; }
tr.vac-prop-row .vac-cell { height: 22px; }
tr.vac-room-row .vac-cell { height: 18px; }
.vac-cell.na  { background: #f2f4f6; }
.vac-cell.occ { background: #a9d9b4; }
/* 空室はその期間の長さで濃くする（1〜2ヶ月→6ヶ月超） */
.vac-cell.vac1 { background: #fde0c2; }
.vac-cell.vac2 { background: #fbc48f; }
.vac-cell.vac3 { background: #f6a06a; }
.vac-cell.vac4 { background: #ec7a5c; }
.vac-cell.vac5 { background: #d94f4f; }
.vac-cell.vac1, .vac-cell.vac2, .vac-cell.vac3, .vac-cell.vac4, .vac-cell.vac5 { cursor: pointer; }
.vac-cell.yearmark { border-left: 1px solid #c8d0d8; }
.vac-cell.hit { outline: 2px solid #1f2937; outline-offset: -2px; }

.vac-legend { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 11px; color: #666; margin: 8px 0 0; }
.vac-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 4px; }

/* ── 分布ミニバー（軸別サマリ表の各行に出す積み上げ横バー） ── */
.vac-minibar { display: flex; width: 108px; height: 11px; border-radius: 2px; overflow: hidden; background: #f2f4f6; }
.vac-minibar span { display: block; height: 100%; }

/* 注意を引きたいセル / グラフから飛んできた行のハイライト */
table.data .warn-cell { background: #fff4e0; }
table.data tr.hit-row, table.data tr.hit-row:hover { background: #fef3c7; }

/* ── 箱ひげ／散布図で件数が少ない軸の注記 ── */
.vac-thin { color: #b45309; }

@media (max-width: 640px) {
  .vac-filterbar { position: static; flex-direction: column; align-items: stretch; }
  .vac-filterbar label { width: 100%; }
  .vac-filterbar select, .vac-filterbar input { width: 100%; }
  .vac-dist-grid { grid-template-columns: 1fr; }
  .chart-box { height: 220px; }
  .chart-box.tall { height: 300px; }
  /* 固定列を 348px 積むと 375px の画面が埋まって月が1つも見えないので、
     部屋名だけ固定し、成績3列は一緒にスクロールさせる */
  table.vac-heatmap .vac-rowhead { min-width: 112px; max-width: 112px; }
  table.vac-heatmap .m1, table.vac-heatmap .m2 { position: static; min-width: 34px; max-width: 34px; }
  table.vac-heatmap .m3 { position: static; min-width: 60px; max-width: 60px; }
  .vac-heatmap-wrap { max-height: 420px; }
}

/* ══════════════════════════════════════════════════════════════
   プラン・課金まわり（2026-08）
   原則: ロックした機能は隠さず「見せて」誘導する。
   ══════════════════════════════════════════════════════════════ */

/* ── プラン選択カード ── */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: start; margin: 8px 0 24px; }
.plan-card { position: relative; background: #fff; border: 1px solid #e1e5eb; border-radius: 10px; padding: 22px 20px 20px; display: flex; flex-direction: column; }
/* 特定プランを推す強調（featured）は廃止（2026-08-12）。
   目立たせるのは「今どのプランか」＝ .current だけにする。 */
.plan-card.current { border: 2px solid #2b8a3e; background: #f4fbf6; }
.plan-ribbon { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: #2b8a3e; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: 11px; white-space: nowrap; }
.plan-name { font-size: 17px; font-weight: 700; color: #2c3e50; margin: 2px 0 2px; }
.plan-tagline { font-size: 12px; color: #6b7684; min-height: 2.6em; line-height: 1.3; margin-bottom: 10px; }
.plan-price { font-size: 30px; font-weight: 700; color: #2c3e50; line-height: 1.1; }
.plan-price small { font-size: 13px; font-weight: 400; color: #6b7684; }
.plan-price-sub { font-size: 11px; color: #6b7684; min-height: 1.4em; margin-top: 3px; }
.plan-feats { list-style: none; padding: 0; margin: 14px 0 18px; font-size: 12.5px; color: #495057; flex: 1; }
.plan-feats li { padding: 4px 0 4px 20px; position: relative; line-height: 1.45; }
.plan-feats li::before { content: '✓'; position: absolute; left: 0; color: #2b8a3e; font-weight: 700; }
.plan-feats li.no { color: #adb5bd; }
.plan-feats li.no::before { content: '—'; color: #ced4da; }
.plan-card .btn { width: 100%; text-align: center; box-sizing: border-box; }

/* 月額 / 年額の切替 */
.cycle-toggle { display: inline-flex; border: 1px solid #d0d7de; border-radius: 999px; overflow: hidden; background: #fff; font-size: 12.5px; }
.cycle-toggle a { padding: 6px 16px; color: #495057; text-decoration: none; }
.cycle-toggle a.on { background: #2c7be5; color: #fff; font-weight: 600; }
.cycle-save { font-size: 12px; color: #2b8a3e; font-weight: 600; margin-left: 10px; }

/* 機能比較表 */
.plan-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.plan-table th, .plan-table td { border: 1px solid #e1e5eb; padding: 9px 12px; text-align: center; }
.plan-table th:first-child, .plan-table td:first-child { text-align: left; white-space: normal; }
.plan-table thead th { background: #f7f9fc; font-weight: 700; color: #2c3e50; }
.plan-table thead th.current { background: #eaf7ee; color: #1f6f33; }
.plan-table thead th.current small { display: block; font-size: 10px; font-weight: 400; margin-top: 2px; }
.plan-table tbody tr:hover { background: #fafbfc; }
.plan-table .grp td { background: #f7f9fc; font-weight: 700; color: #495057; text-align: left; }
.plan-table .yes { color: #2b8a3e; font-weight: 700; }
.plan-table .no { color: #ced4da; }

/* ── ロック表示（機能が使えない時にその場に出す）── */
.lock-card { background: linear-gradient(180deg, #fff 0%, #f8fafd 100%); border: 1.5px dashed #b9c6d8; border-radius: 10px; padding: 22px 24px; text-align: center; margin: 12px 0; }
.lock-card h3 { margin: 0 0 6px; font-size: 16px; color: #2c3e50; }
.lock-card h3::before { content: '🔒'; margin-right: 6px; }
.lock-card p { margin: 0 auto 14px; font-size: 13px; color: #6b7684; line-height: 1.7; max-width: 620px; }
.lock-card .plan-need { display: inline-block; background: #e7f1fd; color: #1a62c7; font-size: 11.5px; font-weight: 700; padding: 2px 10px; border-radius: 10px; margin-bottom: 10px; }
.lock-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #8a94a6; }
.lock-inline::before { content: '🔒'; }
/* ぼかしたプレビュー（中身は見せるが読めない＝価値を伝えてから誘導する） */
.lock-blur { position: relative; }
.lock-blur > .lock-blur-body { filter: blur(4px); pointer-events: none; user-select: none; opacity: 0.55; }
.lock-blur > .lock-blur-over { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* トライアル残日数バナー */
.trial-bar { background: #e7f1fd; border: 1px solid #a8c8ee; border-radius: 6px; padding: 9px 16px; margin-bottom: 12px; font-size: 13px; color: #1a4e8a; }
.trial-bar a { font-weight: 700; }

/* ── アプリ内フィードバック ── */
.fb-fab { position: fixed; right: 18px; bottom: 18px; z-index: 900; background: #2c3e50; color: #fff; border: none; border-radius: 999px; padding: 10px 18px; font-family: inherit; font-size: 13px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.22); }
.fb-fab:hover { background: #1b2b3a; }
.fb-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.42); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.fb-modal { background: #fff; border-radius: 10px; padding: 22px; width: 100%; max-width: 460px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.fb-modal h3 { margin: 0 0 4px; font-size: 16px; color: #2c3e50; }
.fb-modal p.hint { margin: 0 0 14px; font-size: 12px; color: #6b7684; line-height: 1.6; }
.fb-modal label { display: block; font-size: 12px; color: #495057; margin: 10px 0 4px; }
.fb-modal select, .fb-modal textarea, .fb-modal input[type=text] { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; font-size: 13px; }
.fb-modal textarea { min-height: 110px; resize: vertical; }
.fb-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.fb-done { text-align: center; padding: 18px 4px; font-size: 14px; color: #2b8a3e; }

/* ── 取込失敗 → フォーマット対応の依頼 ── */
.fmt-req { border: 1.5px solid #ffc9c9; background: #fff5f5; border-radius: 8px; padding: 16px 18px; margin-top: 12px; }
.fmt-req h4 { margin: 0 0 6px; font-size: 14px; color: #c92a2a; }
.fmt-req p { margin: 0 0 12px; font-size: 12.5px; color: #6b7684; line-height: 1.7; }
.fmt-req input[type=text], .fmt-req textarea { width: 100%; box-sizing: border-box; padding: 7px 10px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; font-size: 13px; margin-bottom: 8px; }

@media (max-width: 640px) {
  .plan-grid { grid-template-columns: 1fr; }
  .plan-price { font-size: 26px; }
  .fb-fab { right: 12px; bottom: 12px; padding: 9px 14px; font-size: 12px; }
}

@media print {
  .fb-fab, .fb-backdrop { display: none !important; }
}
