/* ゲンチョウPro — ネイビー×アンバーのブランドテーマ（ライト・フラット）
 * 提案資料・デモと同じ配色トークンを使う。構造は基盤テーマのまま、色だけを差し替えている。
 */
:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --line: #e3e7ef;
  --text: #232a38;
  --muted: #6b7386;
  --primary: #1f2a44;
  --primary-600: #2e3d63;
  --accent: #f2ce96;
  --accent-deep: #c9862a;
  --accent-soft: #fdf4e6;
  --danger: #b5433a;
  --ok: #2e7d5b;
  --input-bg: #ffffff;
  --button-fg: #ffffff;
  --warn: #b26a00;
  --warn-bg: #fdf6ea;

  /* callAI 互換エイリアス（既存クラス流用のため） */
  --surface: var(--panel);
  --surface-2: #eef1f7;
  --surface-3: #e4e9f2;
  --text-2: var(--muted);
  --text-3: #9aa2b2;
  --on-primary: var(--button-fg);
  --outline: var(--line);
  --outline-strong: #ccd3e0;

  --radius: 9px;
  --radius-sm: 7px;
  --nav-h: 62px;

  /* モーション規律（UIは短く・ease-out基調・transform/opacityのみ動かす） */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-press: 140ms;   /* ボタン押下 */
  --dur-hover: 150ms;   /* ホバー・色変化 */
  --dur-view: 200ms;    /* 画面遷移の入場 */

  /* セクション色（淡い寒色系。カードの帯と左ボーダーで区画を見せる） */
  --sec-blue: #4a7dbb;  --sec-blue-bg: #eef4fb;   /* 案件・顧客情報 */
  --sec-teal: #3aa08c;  --sec-teal-bg: #e9f5f1;   /* 部屋・明細・共有 */
  --sec-green: #55875f; --sec-green-bg: #eef5ec;  /* 金額・単価 */
  --sec-slate: #67748a; --sec-slate-bg: #f0f2f6;  /* 写真・自社情報・データ */
}

/* ===== ダークテーマ（チャコール×アンバー） ===== */
[data-theme="dark"] {
  --bg: #12151c;
  --panel: #1a1f29;
  --line: #2b3342;
  --text: #e8eaee;
  --muted: #9aa3b2;
  --primary: #e8a13d;
  --primary-600: #f0b25c;
  --accent: #e8a13d;
  --accent-deep: #c9862a;
  --accent-soft: rgba(232, 161, 61, .12);
  --danger: #f08a8a;
  --ok: #7fd6bb;
  --input-bg: #141821;
  --button-fg: #10141b;
  --warn: #e0c48a;
  --warn-bg: rgba(224, 196, 138, .12);
  --surface-2: #222835;
  --surface-3: #2a303e;
  --text-3: #6c7686;
  --outline-strong: #3a4353;

  --sec-blue: #6ea3dd;  --sec-blue-bg: rgba(110, 163, 221, .10);
  --sec-teal: #54beA6;  --sec-teal-bg: rgba(84, 190, 166, .10);
  --sec-green: #86bd8e; --sec-green-bg: rgba(134, 189, 142, .10);
  --sec-slate: #93a0b4; --sec-slate-bg: rgba(147, 160, 180, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
/* 既定のリンク色（#0000EE）はダーク背景でほぼ読めないため、テーマの色に揃える。
 * .btn を当てたリンク（サンプルシートを開く等）は .btn 側の色を優先する。 */
a:not(.btn) { color: var(--ok); text-underline-offset: 2px; }
/* 白い紙面（見積書・請求書）の中だけは印刷物としてダークテーマの影響を受けない */
.sheet a { color: #111; }

/* Material Symbols（callAIは最小限。ここではナビ/ボタンの補助アイコンに限定） */
.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal; font-style: normal; line-height: 1;
  font-size: 20px; text-transform: none; display: inline-block; white-space: nowrap;
  direction: ltr; vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased;
}
.ms.fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
/* 最後の砦: 何らかの理由でアイコンフォントが使えなかったとき、
 * 「description」等のリガチャ前の文字を見せずに隠す（ラベルは別途出ているので意味は通る）。
 * このクラスは app.js が font load の失敗を検知したときだけ body に付く。 */
body.no-icon-font .ms { display: none; }

/* ===== フォーム ===== */
input, select, textarea {
  font-family: inherit; font-size: 16px; /* iOSズーム防止 */
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--accent-deep); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px rgba(201,134,42,.28);
}
input[type="number"] { text-align: right; }
input[type="checkbox"] { width: auto; accent-color: var(--primary); transform: scale(1.15); }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7386' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 32px;
}

/* ===== レイアウト ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--panel); color: var(--text);
  height: 54px; padding: 0 8px 0 18px;
  display: flex; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--line);
}
/* callAI ロゴはセリフ体 */
.topbar .brand {
  font-family: "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-weight: 700; font-size: 20px; color: var(--primary);
  cursor: pointer; white-space: nowrap; display: flex; align-items: baseline; gap: 8px;
}
.topbar .brand small { font-family: -apple-system, "Noto Sans JP", sans-serif; font-weight: 400; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.topbar .spacer { flex: 1; }
.topbar .top-nav { display: none; align-items: center; gap: 2px; }
.topbar .top-nav button {
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 7px 13px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  border-radius: var(--radius-sm); transition: color .15s, background .15s, border-color .15s;
}
.topbar .top-nav button:hover { color: var(--text); border-color: var(--line); }
.topbar .top-nav button.active { color: var(--primary); background: var(--accent-soft); border-color: var(--accent-deep); }
.theme-toggle {
  background: none; border: 1px solid var(--line); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  transition: border-color var(--dur-hover) ease, color var(--dur-hover) ease;
}
.theme-toggle .ms { font-size: 18px; }
@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover { border-color: var(--accent-deep); color: var(--text); }
}

.main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 28px); }

/* ボトムナビ（選択=accent-soft ＋ primary） */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: var(--nav-h); background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 3px;
  padding: 0 6px calc(env(safe-area-inset-bottom));
}
.bottom-nav button {
  flex: 1; background: none; border: none; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 44px; border-radius: var(--radius-sm); transition: background .15s, color .15s;
}
.bottom-nav button .ms { font-size: 21px; }
.bottom-nav button .pill { display: contents; }
.bottom-nav button .lbl { font-size: 10.5px; font-weight: 600; }
.bottom-nav button.active { background: var(--accent-soft); color: var(--primary); }
.bottom-nav button.active .ms { color: var(--accent-deep); font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.bottom-nav button:disabled { opacity: .4; }

@media (min-width: 900px) {
  .topbar .top-nav { display: flex; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 32px; }
}

/* ===== 汎用 ===== */
.card {
  background: var(--panel); border-radius: var(--radius);
  border: 1px solid var(--line); padding: 15px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 11px; font-size: 14px; font-weight: 700; color: var(--text); }
.card h2 .sub { font-weight: 400; color: var(--muted); font-size: 11.5px; margin-left: 8px; }

/* セクション色つきカード: 左ボーダー＋見出し帯で区画を見せる */
.card[class*="sec-"] { border-left-width: 3px; border-left-style: solid; }
.card[class*="sec-"] > h2 {
  margin: -15px -15px 13px; padding: 11px 15px;
  border-radius: 0 7px 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
}
.card[class*="sec-"] > h2::before { content: ""; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; }
.card.sec-blue  { border-left-color: var(--sec-blue); }
.card.sec-blue  > h2 { background: var(--sec-blue-bg); }
.card.sec-blue  > h2::before { background: var(--sec-blue); }
.card.sec-teal  { border-left-color: var(--sec-teal); }
.card.sec-teal  > h2 { background: var(--sec-teal-bg); }
.card.sec-teal  > h2::before { background: var(--sec-teal); }
.card.sec-green { border-left-color: var(--sec-green); }
.card.sec-green > h2 { background: var(--sec-green-bg); }
.card.sec-green > h2::before { background: var(--sec-green); }
.card.sec-slate { border-left-color: var(--sec-slate); }
.card.sec-slate > h2 { background: var(--sec-slate-bg); }
.card.sec-slate > h2::before { background: var(--sec-slate); }
/* 部屋カード（h2なし）は左ボーダー＋部屋名行の帯 */
.card.room-card { border-left: 3px solid var(--sec-teal); }
.card.room-card .room-head {
  background: var(--sec-teal-bg); margin: -15px -15px 13px; padding: 10px 15px;
  border-radius: 0 7px 0 0;
}
.section-title { display: flex; align-items: center; gap: 7px; margin: 18px 2px 10px; font-size: 14px; font-weight: 700; color: var(--text); }
.section-title .ms { color: var(--accent-deep); }
.section-title .muted { font-weight: 400; }
.section-title .st-label { white-space: nowrap; }

/* 未導入の会社向け 申込導線（ログイン画面） */
.signup-cta { margin-top: 18px; padding: 14px 16px; background: var(--accent-soft);
              border: 1px solid var(--accent); border-radius: 9px; }
.signup-cta b { font-size: 13.5px; color: var(--primary); }
.signup-cta p { margin: 4px 0 10px; font-size: 12.5px; }
.signup-cta .btn { display: inline-block; text-decoration: none; }

.page-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.page-title h1 { font-size: 18px; font-weight: 700; margin: 0; color: var(--primary); }
.page-title .crumb { color: var(--muted); font-size: 12.5px; cursor: pointer; }
.page-title .crumb:hover { color: var(--accent-deep); text-decoration: underline; }

/* callAI 準拠：ツールバー検索窓 */
.toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.toolbar .row1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type="search"] {
  flex: 1; min-width: 200px; -webkit-appearance: none; appearance: none;
  background: var(--input-bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; padding: 9px 12px; font-size: 16px; font-family: inherit;
}
.toolbar input[type="search"]:focus { outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px rgba(201,134,42,.28); }
.toolbar .mini {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px; color: var(--primary);
  cursor: pointer; padding: 8px 13px; font-size: 12px; font-weight: 600;
}
.toolbar .mini:hover { border-color: var(--accent-deep); }
.toolbar .hits { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* callAI 準拠：PRO バッジ */
.badge-pro {
  display: inline-block; background: var(--accent); color: var(--primary);
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 3px;
  letter-spacing: .04em; vertical-align: middle; line-height: 1.5;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: var(--button-fg); border: none; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;   /* 「削除」が縦2文字に折り返すのを防ぐ */
  transition: background var(--dur-hover) ease, border-color var(--dur-hover) ease,
              color var(--dur-hover) ease, transform var(--dur-press) var(--ease-out);
}
.btn .ms { font-size: 17px; }
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--panel); color: var(--primary); border: 1px solid var(--line); }
.btn.tonal { background: var(--accent-soft); color: var(--ok); border: 1px solid var(--accent-deep); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: none; padding: 5px 8px; }
/* ホバーはマウス環境のみ（タッチ端末の偽ホバー防止） */
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--primary-600); }
  .btn.secondary:hover { background: var(--accent-soft); border-color: var(--accent-deep); }
  .btn.tonal:hover { background: #e4f0ea; }
  .btn.ghost:hover { background: var(--accent-soft); border-color: var(--accent-deep); color: var(--text); }
  .btn.danger:hover { background: rgba(181,67,58,.08); }
}
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn.small .ms { font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
  background: var(--accent-soft); border: 1px solid var(--accent-deep); color: var(--ok);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.survey { background: var(--warn-bg); border-color: #e6cfa0; color: var(--warn); }
.chip.draft { background: var(--accent-soft); border-color: var(--accent-deep); color: var(--muted); }
.chip.submitted { background: var(--accent-soft); border-color: var(--accent-deep); color: var(--ok); }
.chip.ordered { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.invoiced { background: var(--surface-2); border-color: var(--outline-strong); color: var(--muted); }

/* 社内のみ表示の印（原価・粗利） */
.tag-internal {
  display: inline-block; background: var(--surface-2); border: 1px solid var(--outline-strong);
  color: var(--muted); font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 3px;
  letter-spacing: .04em; margin-right: 6px; vertical-align: middle;
}
.totals-box .trow.internal { color: var(--muted); }
table.est td.sell { font-weight: 700; white-space: nowrap; }

.muted { color: var(--muted); font-size: 12px; }
.right { text-align: right; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }

.field { margin-bottom: 11px; }
.field label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.field-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; }

.empty {
  text-align: center; color: var(--muted); padding: 38px 12px;
  border: 1px dashed var(--outline-strong); border-radius: var(--radius); background: var(--panel);
}
.empty .ms { font-size: 42px; color: var(--text-3); display: block; margin: 0 auto 8px; }

/* ===== 案件一覧（callAI カード） ===== */
.deck-item {
  display: flex; gap: 13px; padding: 15px; cursor: pointer; align-items: flex-start;
  transition: border-color var(--dur-hover) ease, background var(--dur-hover) ease,
              transform var(--dur-press) var(--ease-out);
}
.deck-item:active { transform: scale(.99); }
@media (hover: hover) and (pointer: fine) {
  .deck-item:hover { border-color: var(--accent-deep); background: var(--accent-soft); }
}
.deck-lead {
  width: 42px; height: 42px; border-radius: 8px; flex: 0 0 auto;
  background: var(--accent-soft); border: 1px solid var(--accent-deep); color: var(--ok);
  display: flex; align-items: center; justify-content: center;
}
.deck-lead .ms { font-size: 23px; }
.deck-body { flex: 1; min-width: 0; }
.deck-top { display: flex; align-items: center; gap: 8px; }
.deck-top .name { font-weight: 700; font-size: 14px; color: var(--text); flex: 1; min-width: 0; }
.deck-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.deck-foot { display: flex; align-items: baseline; justify-content: space-between; margin-top: 9px; gap: 8px; }
.deck-foot .total { font-size: 18px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.deck-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ===== 現調入力 ===== */
.room-card .room-head { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; }
.room-card .room-head input { font-weight: 700; font-size: 15px; }
.surface-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.surface-row .sur-name { font-size: 12.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.surface-row .sur-qty { font-size: 12px; color: var(--ok); white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.surface-row.off select { opacity: .4; pointer-events: none; }
.surface-row.off .sur-qty { opacity: .4; color: var(--muted); }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 9px; }
.photo-item { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.photo-item img { width: 100%; height: 82px; object-fit: cover; display: block; }
.photo-item .tag {
  position: absolute; top: 5px; left: 5px; font-size: 10px; font-weight: 700;
  background: rgba(31,42,68,.82); color: #fff; padding: 2px 8px; border-radius: 999px;
}
.photo-item .del {
  position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.5); color: #fff;
  border: none; border-radius: 999px; width: 22px; height: 22px; cursor: pointer;
  font-size: 12px; line-height: 1; display: flex; align-items: center; justify-content: center;
}

/* 概算スティッキーバー */
.est-bar {
  position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 40;
  background: var(--panel); color: var(--text);
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  border-top: 1px solid var(--line);
}
.est-bar .label { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.est-bar .value { font-size: 21px; font-weight: 800; color: var(--ok); font-variant-numeric: tabular-nums; }
.est-bar .btn { margin-left: auto; }
@media (min-width: 900px) {
  .est-bar { bottom: 0; left: auto; right: 24px; width: 420px; border: 1px solid var(--line); border-bottom: none; border-radius: 10px 10px 0 0; }
}

/* ===== 見積編集（データテーブル） ===== */
table.est { width: 100%; border-collapse: collapse; font-size: 12px; }
table.est td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text); }
table.est th { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; background: var(--bg); white-space: nowrap; position: sticky; top: 0; z-index: 2; }
table.est tbody tr { transition: background var(--dur-hover) ease; }
@media (hover: hover) and (pointer: fine) {
  table.est tbody tr:hover { background: var(--accent-soft); }
}
table.est td.num, table.est th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.est td input { padding: 6px 8px; font-size: 12.5px; }
table.est td input.qty { width: 78px; }
table.est td input.price { width: 94px; }
table.est .src { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
table.est .overridden input { border-color: var(--warn); background: var(--warn-bg); }
.reset-link { color: var(--warn); font-size: 10.5px; cursor: pointer; border: none; background: none; padding: 2px; font-weight: 700; }
.table-scroll { overflow-x: auto; margin: 0 -4px; }

.totals-box { max-width: 400px; margin-left: auto; }
.totals-box .trow { display: flex; justify-content: space-between; align-items: center; padding: 7px 4px; font-size: 13px; }
.totals-box .trow.grand { border-top: 2px solid var(--outline-strong); margin-top: 8px; padding-top: 11px; font-size: 18px; font-weight: 800; color: var(--primary); }
.totals-box .trow.grand span:last-child { color: var(--ok); }
.totals-box .inline-input { width: 108px; }

/* ===== マスタ ===== */
table.master { width: 100%; border-collapse: collapse; font-size: 12px; }
table.master td { padding: 6px 10px; border-bottom: 1px solid var(--line); color: var(--text); }
table.master th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; background: var(--bg); text-align: left; white-space: nowrap; }
table.master td input { padding: 6px 8px; font-size: 12.5px; }
table.master td .price { width: 96px; }
table.master td .unit { width: 64px; }
.cat-head td {
  background: var(--accent-soft); color: var(--ok); font-size: 11.5px; font-weight: 700;
  padding: 7px 10px; border-radius: 6px;
}

/* ===== 協力会社への見積依頼 ===== */
.req-table td { vertical-align: middle; }
.req-table td small { display: block; font-size: 10.5px; }
.req-overdue td { background: var(--warn-bg); }
.req-late { color: var(--danger); font-weight: 700; }
.req-alert {
  background: var(--warn-bg); color: var(--warn); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 0 0 12px; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.link { color: var(--ok); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.nowrap { white-space: nowrap; }

/* 依頼書の紙面 */
.req-scope { margin: 14px 0; border: 1px solid #ccc; border-radius: 4px; overflow: hidden; }
.req-scope .req-label { background: #f2f2f2; padding: 5px 10px; font-size: 11px; font-weight: 700; }
.req-scope .req-body { padding: 10px; font-size: 12.5px; white-space: pre-wrap; }
table.req-rooms { width: 100%; border-collapse: collapse; margin-top: 12px; }
table.req-rooms th, table.req-rooms td { border: 1px solid #ccc; padding: 6px 9px; font-size: 11.5px; text-align: left; }
table.req-rooms th { background: #f2f2f2; }
.req-note { font-size: 10.5px; color: #555; margin: 6px 0 0; }
.req-imgs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.req-fig { margin: 0; width: 30%; }
.req-fig img { width: 100%; border: 1px solid #ccc; display: block; }
.req-fig figcaption { font-size: 10px; color: #555; margin-top: 3px; }
.req-answer { margin-top: 18px; border-top: 2px solid #333; padding-top: 12px; }
.req-answer .req-label { font-size: 11px; font-weight: 700; }
.req-blank { border-bottom: 1px solid #333; height: 26px; margin-top: 4px; font-size: 13px; }

/* ===== 写真の受信待ち・未共有 ===== */
.photo-item.photo-pending {
  min-height: 82px;                       /* 画像が無いので枠が潰れないよう高さを揃える */
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px dashed var(--outline-strong);
}
.photo-item .ph-note { font-size: 11px; color: var(--muted); }
.photo-item .ph-warn {
  position: absolute; left: 4px; bottom: 4px;
  background: var(--warn-bg); color: var(--warn);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
}

/* ===== 分類（カテゴリ）管理 ===== */
.cat-manage { border-top: 1px dashed var(--line); padding-top: 14px; }
.cat-manage h3 { margin: 0 0 4px; font-size: 13px; color: var(--text); }
.cat-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel); overflow: hidden;
}
.cat-chip .cat-name {
  background: none; border: 0; padding: 5px 4px 5px 12px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--text);
}
.cat-chip .cat-name:hover { color: var(--accent-deep); text-decoration: underline; }
.cat-chip .cat-n {
  font-size: 10.5px; color: var(--muted); background: var(--surface-2);
  border-radius: 999px; padding: 1px 7px; margin: 0 6px;
}
.cat-chip .cat-x {
  background: none; border: 0; border-left: 1px solid var(--line);
  padding: 5px 9px; cursor: pointer; color: var(--muted); font-size: 11px; line-height: 1;
}
.cat-chip .cat-x:hover:not(:disabled) { background: var(--warn-bg); color: var(--danger); }
.cat-chip .cat-x:disabled { opacity: .35; cursor: not-allowed; }

/* ===== 見積書（白い紙面） ===== */
.sheet-wrap { background: #e4e9f2; padding: 18px 6px; border-radius: var(--radius); }
.sheet {
  background: #fff; width: 210mm; max-width: 100%; min-height: 250mm;
  margin: 0 auto; padding: 16mm 14mm; box-shadow: 0 8px 26px rgba(27,25,56,.18);
  color: #111; font-size: 12.5px;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Sans JP", serif;
}
.sheet h1.doc-title { text-align: center; font-size: 26px; letter-spacing: .5em; margin: 0 0 18px; padding-left: .5em; font-weight: 700; }
.sheet .doc-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.sheet .to .client { font-size: 17px; font-weight: 700; border-bottom: 2px solid #111; padding: 0 24px 4px 2px; margin-bottom: 6px; }
.sheet .from { text-align: left; font-size: 12px; line-height: 1.6; }
.sheet .from .co { font-size: 14px; font-weight: 700; }
.sheet .grand-box {
  display: flex; align-items: baseline; gap: 14px; border: 2px solid #111;
  padding: 8px 16px; margin: 12px 0 16px; width: fit-content;
}
.sheet .grand-box .lbl { font-size: 13px; font-weight: 700; }
.sheet .grand-box .val { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sheet table.lines { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.sheet table.lines th, .sheet table.lines td { border: 1px solid #333; padding: 5px 7px; font-size: 12px; color: #111; }
.sheet table.lines th { background: #eef0f4; font-weight: 700; }
.sheet table.lines td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet .sheet-totals { width: 260px; margin-left: auto; }
.sheet .sheet-totals .trow { display: flex; justify-content: space-between; padding: 3px 6px; font-size: 12.5px; }
.sheet .sheet-totals .trow.grand { border-top: 1.5px solid #111; font-weight: 800; font-size: 14px; padding-top: 6px; }
.sheet .notes { margin-top: 16px; font-size: 11.5px; color: #333; white-space: pre-wrap; }
.sheet .notes .h { font-weight: 700; margin-bottom: 2px; }

.print-actions { display: flex; gap: 10px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }

/* ===== 画面遷移の入場（ルート変更時のみ・編集時の再描画では動かさない） ===== */
@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.main.view-enter > * { animation: view-in var(--dur-view) var(--ease-out) backwards; }
.main.view-enter > *:nth-child(2) { animation-delay: 30ms; }
.main.view-enter > *:nth-child(3) { animation-delay: 60ms; }
.main.view-enter > *:nth-child(4) { animation-delay: 90ms; }
.main.view-enter > *:nth-child(5) { animation-delay: 120ms; }
.main.view-enter > *:nth-child(n+6) { animation-delay: 150ms; }

/* ===== フォーカスリング（キーボード操作時のみ） ===== */
.btn:focus-visible, .bottom-nav button:focus-visible, .top-nav button:focus-visible,
.reset-link:focus-visible, .toolbar .mini:focus-visible {
  outline: 2px solid var(--accent-deep); outline-offset: 2px;
}
.btn:focus:not(:focus-visible) { outline: none; }

/* ===== 細部 ===== */
::selection { background: var(--accent); color: var(--primary); }
h1, h2, .deck-top .name, .page-title h1 { font-feature-settings: "palt"; }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--outline-strong); border-radius: 999px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }

/* ===== トースト（同期成功などの非ブロッキング通知） ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  z-index: 90; max-width: min(92vw, 480px);
  background: var(--primary); color: #fff;
  padding: 10px 16px; border-radius: 9px; font-size: 13px; line-height: 1.5;
  box-shadow: 0 8px 24px rgba(27,25,56,.28);
  opacity: 0; transform: translateX(-50%) translateY(10px) scale(.97);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.toast.hide { opacity: 0; transform: translateX(-50%) translateY(6px) scale(.98); transition-duration: 160ms; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ===== 使い方ガイド（図解モック） ===== */
.guide-flow { display: flex; align-items: stretch; gap: 6px; justify-content: space-between; }
.gf-step {
  flex: 1; text-align: center; padding: 12px 6px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); position: relative;
}
.gf-step .ms { font-size: 26px; color: var(--accent-deep); display: block; margin: 2px auto 4px; }
.gf-no {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.gf-t { font-size: 13px; font-weight: 700; color: var(--text); }
.gf-s { font-size: 11px; color: var(--muted); }
.gf-arrow { display: flex; align-items: center; color: var(--accent-deep); }
.gf-arrow .ms { animation: gf-nudge 1.8s var(--ease-in-out) infinite; }
@keyframes gf-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }

.guide-step h2 { display: flex; align-items: center; gap: 8px; }
.g-badge {
  background: var(--primary); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; letter-spacing: .04em; white-space: nowrap;
}
.guide-grid { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: center; }
@media (max-width: 640px) { .guide-grid { grid-template-columns: 1fr; justify-items: center; } }
.guide-list { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.9; }
.guide-list b { color: var(--primary); }
.guide-list li + li { margin-top: 4px; }

/* --- モック共通 --- */
.mock-phone, .mock-rate, .mock-sheet, .mock-sync { user-select: none; }

/* STEP1: スマホ現調モック（7秒ループ：タップ→数値→自動計算→概算） */
.mock-phone {
  width: 220px; border: 2px solid var(--outline-strong); border-radius: 18px;
  background: var(--bg); overflow: hidden; box-shadow: 0 6px 20px rgba(27,25,56,.10);
}
.mp-head { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; text-align: center; padding: 6px; }
.mp-room { padding: 10px; }
.mp-label { font-size: 11px; font-weight: 700; margin-bottom: 6px; }
.mp-fields { display: flex; gap: 6px; margin-bottom: 8px; }
.mp-field {
  flex: 1; position: relative; background: #fff; border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 6px; font-size: 10px; color: var(--muted); min-height: 34px;
}
.mp-field .mp-v { display: block; font-size: 13px; font-weight: 700; color: var(--text); opacity: 0; }
.tap-dot {
  position: absolute; right: 4px; bottom: 4px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-deep); opacity: 0;
}
.mp-field.f1 .mp-v { animation: mpv1 7s infinite; } .mp-field.f1 .tap-dot { animation: mpd1 7s infinite; }
.mp-field.f2 .mp-v { animation: mpv2 7s infinite; } .mp-field.f2 .tap-dot { animation: mpd2 7s infinite; }
.mp-field.f3 .mp-v { animation: mpv3 7s infinite; } .mp-field.f3 .tap-dot { animation: mpd3 7s infinite; }
@keyframes mpv1 { 0%, 8% { opacity: 0; } 11%, 93% { opacity: 1; } 97%, 100% { opacity: 0; } }
@keyframes mpv2 { 0%, 20% { opacity: 0; } 23%, 93% { opacity: 1; } 97%, 100% { opacity: 0; } }
@keyframes mpv3 { 0%, 32% { opacity: 0; } 35%, 93% { opacity: 1; } 97%, 100% { opacity: 0; } }
@keyframes mpd1 { 3% { opacity: 0; transform: scale(.6); } 6% { opacity: .9; transform: scale(1); } 10%, 100% { opacity: 0; } }
@keyframes mpd2 { 0%, 15% { opacity: 0; transform: scale(.6); } 18% { opacity: .9; transform: scale(1); } 22%, 100% { opacity: 0; } }
@keyframes mpd3 { 0%, 27% { opacity: 0; transform: scale(.6); } 30% { opacity: .9; transform: scale(1); } 34%, 100% { opacity: 0; } }
.mp-row {
  display: flex; justify-content: space-between; font-size: 11px; color: var(--muted);
  padding: 4px 2px; border-top: 1px solid var(--line); opacity: 0;
}
.mp-row b { color: var(--ok); font-variant-numeric: tabular-nums; }
.mp-row.r1 { animation: mprow1 7s infinite; }
.mp-row.r2 { animation: mprow2 7s infinite; }
.mp-row.r3 { animation: mprow3 7s infinite; }
@keyframes mprow1 { 0%, 42% { opacity: 0; transform: translateY(3px); } 46%, 93% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; } }
@keyframes mprow2 { 0%, 48% { opacity: 0; transform: translateY(3px); } 52%, 93% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; } }
@keyframes mprow3 { 0%, 54% { opacity: 0; transform: translateY(3px); } 58%, 93% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; } }
.mp-estbar {
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 7px 10px; display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: var(--muted);
}
.mp-amount { font-size: 15px; font-weight: 800; color: var(--ok); font-variant-numeric: tabular-nums; opacity: 0; animation: mpamt 7s infinite; }
@keyframes mpamt { 0%, 62% { opacity: 0; transform: scale(.92); } 68%, 93% { opacity: 1; transform: scale(1); } 97%, 100% { opacity: 0; } }

/* STEP2: 掛け率モック（4.5秒ループ） */
.mock-rate {
  width: 240px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); padding: 14px;
}
.mr-cust { font-size: 11.5px; font-weight: 700; margin-bottom: 10px; }
.mr-cust .ms { font-size: 16px; color: var(--accent-deep); }
.mr-calc { display: flex; align-items: center; gap: 8px; justify-content: center; }
.mr-tag {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
  text-align: center; font-size: 10px; color: var(--muted);
}
.mr-tag b { display: block; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.mr-tag.sell { border-color: var(--accent-deep); background: var(--accent-soft); }
.mr-tag.sell b { color: var(--ok); }
.mr-x { font-size: 12px; font-weight: 700; color: var(--primary); animation: mrx 4.5s infinite; }
@keyframes mrx { 0%, 20% { opacity: .35; transform: scale(1); } 32%, 46% { opacity: 1; transform: scale(1.12); } 58%, 100% { opacity: .35; transform: scale(1); } }
.mr-sell { display: inline-block; opacity: 0; animation: mrsell 4.5s infinite; }
@keyframes mrsell { 0%, 46% { opacity: 0; transform: translateY(4px); } 56%, 94% { opacity: 1; transform: none; } 98%, 100% { opacity: 0; } }
.mr-note { text-align: center; font-size: 10.5px; color: var(--muted); margin-top: 8px; }

/* STEP3: 見積書モック（6秒ループ：紙が滑り込み→印刷ボタンが光る） */
.mock-sheet { width: 220px; text-align: center; }
.msh-paper {
  background: #fff; border: 1px solid var(--outline-strong); border-radius: 4px;
  padding: 14px 16px 12px; box-shadow: 0 6px 18px rgba(27,25,56,.12);
  animation: mshin 6s var(--ease-out) infinite;
}
@keyframes mshin { 0% { opacity: 0; transform: translateY(10px); } 8%, 94% { opacity: 1; transform: none; } 98%, 100% { opacity: 0; } }
.msh-title { font-size: 13px; font-weight: 700; letter-spacing: .3em; padding-left: .3em; margin-bottom: 10px; }
.msh-line { height: 5px; background: var(--surface-3); border-radius: 3px; margin: 6px auto; }
.msh-line.w60 { width: 60%; } .msh-line.w70 { width: 70%; } .msh-line.w80 { width: 80%; }
.msh-total { font-size: 13px; font-weight: 800; margin-top: 10px; font-variant-numeric: tabular-nums; }
.msh-btn {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 12px;
  background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 700;
  padding: 7px 14px; border-radius: 7px; animation: mshglow 2.2s ease-in-out infinite;
}
.msh-btn .ms { font-size: 15px; }
@keyframes mshglow { 0%, 100% { box-shadow: 0 0 0 0 rgba(201,134,42,.55); } 55% { box-shadow: 0 0 0 8px rgba(201,134,42,0); } }

/* 共有: マスタ同期モック（3秒ループ：シート→点が流れる→端末が受信） */
.mock-sync { width: 240px; display: flex; align-items: center; gap: 8px; }
.msy-sheet {
  flex: 0 0 auto; text-align: center; background: var(--accent-soft); border: 1px solid var(--accent-deep);
  border-radius: 10px; padding: 10px 12px; font-size: 10.5px; font-weight: 700; color: var(--ok);
}
.msy-sheet .ms { display: block; font-size: 22px; margin-bottom: 2px; }
.msy-sheet small { display: block; font-weight: 400; color: var(--muted); font-size: 9px; }
.msy-line { flex: 1; height: 2px; background: var(--line); position: relative; border-radius: 2px; }
.msy-dot {
  position: absolute; top: -3px; left: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-deep); animation: msydot 3s var(--ease-in-out) infinite;
}
@keyframes msydot { 0% { left: 0; opacity: 0; } 12% { opacity: 1; } 78% { left: calc(100% - 8px); opacity: 1; } 92%, 100% { left: calc(100% - 8px); opacity: 0; } }
.msy-devices { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; }
.msy-dev {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  width: 34px; height: 30px; display: flex; align-items: center; justify-content: center;
}
.msy-dev .ms { font-size: 17px; color: var(--muted); }
.msy-dev.d1 { animation: msydev 3s infinite; }
.msy-dev.d2 { animation: msydev 3s .12s infinite; }
.msy-dev.d3 { animation: msydev 3s .24s infinite; }
@keyframes msydev { 0%, 72% { border-color: var(--line); transform: scale(1); } 80% { border-color: var(--accent-deep); transform: scale(1.08); } 92%, 100% { border-color: var(--line); transform: scale(1); } }

/* 役割別・FAQ */
.guide-roles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .guide-roles { grid-template-columns: 1fr; } }
.g-role { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--bg); }
.g-role .ms { font-size: 22px; color: var(--accent-deep); display: block; margin-bottom: 4px; }
.g-role b { display: block; font-size: 13px; margin-bottom: 4px; }
.g-role p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.g-faq { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 8px; background: var(--bg); }
.g-faq summary { font-size: 13px; font-weight: 700; cursor: pointer; color: var(--text); }
.g-faq p { margin: 8px 0 2px; font-size: 12.5px; color: var(--muted); line-height: 1.8; }

/* ===== オンボーディング・ガイドツアー ===== */
/* 背景は必ず不透明にする（sticky なので下の内容が透けると読めなくなる）。
 * --accent-soft はダークテーマでは半透明のため、--panel の上に重ねて色味だけ乗せる。 */
.tour-banner {
  position: sticky; top: 54px; z-index: 45;
  background-color: var(--panel);
  background-image: linear-gradient(var(--accent-soft), var(--accent-soft));
  border-bottom: 2px solid var(--accent-deep);
  color: var(--text); padding: 9px 12px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: center;
}
/* 狭い画面: 1行目=段/文言/✕、2行目=次へボタン（全幅） */
.tour-banner .t-step { grid-area: 1 / 1 / 2 / 2; }
.tour-banner .t-msg  { grid-area: 1 / 2 / 2 / 3; }
.tour-banner .t-close{ grid-area: 1 / 3 / 2 / 4; }
.tour-banner .btn    { grid-area: 2 / 1 / 3 / 4; width: 100%; }
@media (min-width: 720px) {
  .tour-banner { grid-template-columns: auto 1fr auto auto; }
  .tour-banner .btn     { grid-area: 1 / 3 / 2 / 4; width: auto; justify-self: end; }
  .tour-banner .t-close { grid-area: 1 / 4 / 2 / 5; }
}
.tour-banner .t-step {
  background: var(--ok); color: var(--panel); font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto;
}
.tour-banner .t-msg { font-size: 12.5px; line-height: 1.55; }
.tour-banner .t-msg b { color: var(--ok); }
.tour-banner .t-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 4px 6px; flex: 0 0 auto;
}
.tour-banner .t-close:hover { color: var(--text); }

/* 初回ウェルカム */
.welcome-card { border-left: 3px solid var(--accent-deep); }
.welcome-card h2 { display: flex; align-items: center; gap: 8px; }
.welcome-card .w-lead { font-size: 13px; color: var(--muted); line-height: 1.8; margin: 0 0 12px; }
.welcome-card .w-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 光る対象（クリック/注目を促す）
 * position は指定しない。以前 position:relative を持っていたため、
 * 後勝ちで .est-bar の position:fixed を打ち消し、ツアー中だけ
 * 「画面下の概算金額バー」が流し込みに落ちて見えなくなっていた。 */
.tour-glow { animation: tourPulse 1.8s ease-in-out infinite; border-radius: 10px; }
@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 179, 156, .55); }
  50%      { box-shadow: 0 0 0 8px rgba(79, 179, 156, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .tour-glow { animation: none; box-shadow: 0 0 0 2px var(--accent-deep); }
}

/* 横スクロールのヒントは狭い画面のときだけ出す（既定は非表示） */
.scroll-hint { display: none; font-size: 11.5px; color: var(--muted); margin: 0 0 6px; }
.doc-actions { display: flex; gap: 8px; }
.field-customer { min-width: 200px; max-width: 280px; }

/* ===== 狭い画面（スマホ）での可読性補正 =====
 * 現場はスマホが主。表が押し潰れて1文字ずつ折り返す・紙面が潰れる、を防ぐ。 */
@media screen and (max-width: 719px) {

  /* 見積編集の明細: 横スクロールする表をやめ、1行=1カードにする */
  .card table.est { min-width: 0; }
  .table-scroll.est-scroll { overflow-x: visible; margin: 0; }
  table.est thead { display: none; }
  table.est, table.est tbody, table.est tr, table.est td { display: block; width: 100%; }
  table.est tbody tr {
    border: 1px solid var(--outline); border-radius: var(--radius-sm);
    background: var(--panel); padding: 11px 12px; margin-bottom: 10px;
  }
  table.est tbody tr:hover { background: var(--panel); }
  table.est td {
    border: none; padding: 5px 0; text-align: left;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
  }
  table.est td::before {
    content: attr(data-l); flex: 0 0 auto;
    font-size: 11px; font-weight: 700; color: var(--muted);
  }
  table.est td.cell-name {
    display: block; padding: 0 0 8px;
    border-bottom: 1px dashed var(--outline); margin-bottom: 6px;
    font-size: 14px; font-weight: 700; color: var(--text);
  }
  table.est td.cell-name::before { content: none; }
  table.est td.cell-unit { display: none; }            /* 単位は「数量（m²）」に含めた */
  table.est td input.qty, table.est td input.price { width: 120px; text-align: right; }
  table.est td.amount { font-size: 16px; font-weight: 800; color: var(--ok); }
  table.est td.cell-del { padding-top: 8px; }
  table.est td.cell-del::before { content: none; }
  table.est td.cell-del:empty { display: none; }
  table.est td.cell-del .btn::after { content: 'この行を削除'; font-size: 12px; }
  table.est td[colspan] { display: block; }
  table.est td[colspan]::before { content: none; }

  /* マスタ表: 列を潰さず横スクロールさせる（項目名が1文字ずつ折り返すのを防ぐ） */
  table.master { min-width: 540px; }
  .scroll-hint { display: block; }

  /* 見積書・請求書プレビュー: A4の余白のままだと本文が240pxしか残らない */
  .sheet-wrap { padding: 10px 8px; }
  .sheet { padding: 20px 15px; min-height: 0; font-size: 12px; }
  .sheet h1.doc-title { font-size: 20px; letter-spacing: .3em; margin-bottom: 14px; }
  .sheet .doc-head { flex-direction: column; gap: 12px; }
  .sheet .to .client { font-size: 15px; padding: 0 6px 4px 2px; }
  .sheet .from { font-size: 11.5px; }
  .sheet .sheet-totals { width: 100%; }
  .sheet table.lines th, .sheet table.lines td { padding: 4px 5px; font-size: 11px; }

  /* 2カラムのフィールドは縦積み（「未選択（掛け率」で切れていた） */
  .field-grid { grid-template-columns: 1fr; }

  /* 帳票ボタン（見積書・請求書）は2つで1行を分け合う。
     以前は「見積書」だけステータスの右に残り、「請求書」が次行に落ちていた。 */
  .doc-actions { flex: 1 0 100%; }
  .doc-actions .btn { flex: 1 1 0; }

  /* 顧客名は途中で切れると別の顧客と見分けがつかないので全幅 */
  .field-customer { flex: 1 0 100%; max-width: none; }

  /* 見出しと説明文が横並びのまま折り返して噛み合っていたので縦積みに */
  .section-title { flex-wrap: wrap; align-items: baseline; gap: 4px 7px; }
  .section-title .muted { flex: 1 0 100%; margin-left: 27px; }

  /* 仕上げの選択: 1行に詰めると「量産クロス貼替（材」で切れて単価が読めない。
     1行目=チェック＋部位＋数量 / 2行目=仕上げと単価を全幅、の2段に。 */
  .surface-row { grid-template-columns: 1fr auto; gap: 8px 10px; }
  .surface-row .sur-name  { grid-area: 1 / 1 / 2 / 2; font-size: 13.5px; }
  .surface-row .sur-qty   { grid-area: 1 / 2 / 2 / 3; }
  .surface-row > select   { grid-area: 2 / 1 / 3 / 3; width: 100%; }
  /* 追加項目の行は「品名（select）が先・操作が後」の順に見せる */
  .surface-row.extra-row > select      { grid-area: 1 / 1 / 2 / 3; }
  .surface-row.extra-row > .btn.danger { grid-area: 2 / 1 / 3 / 2; justify-self: start; }
  .surface-row.extra-row > input.qty   { grid-area: 2 / 2 / 3 / 3; justify-self: end; width: 110px !important; }
  /* 「量」の矢印ぶん余白を詰めて、単価まで表示しきる */
  .surface-row > select { padding-left: 9px; padding-right: 26px; background-position: right 6px center; }

  /* iOS Safari は 16px 未満の入力にフォーカスすると勝手にズームする */
  .room-card .room-head input { font-size: 16px; }
}

/* ===== ダークテーマの部品補正 ===== */
[data-theme="dark"] body, body[data-theme] { background: var(--bg); }
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}
[data-theme="dark"] .badge-pro { color: #10141b; }
[data-theme="dark"] .toast { color: #10141b; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
[data-theme="dark"] .sheet-wrap { background: #0d1016; }
[data-theme="dark"] .mp-field, [data-theme="dark"] .mr-tag, [data-theme="dark"] .msy-dev { background: var(--panel); }
[data-theme="dark"] ::selection { background: var(--accent-deep); color: #10141b; }
[data-theme="dark"] .mock-phone { box-shadow: 0 6px 20px rgba(0,0,0,.4); }
/* 見積書・請求書の紙面は常に白（印刷物のプレビューのため） */
[data-theme="dark"] .sheet { background: #fff; color: #111; }

/* ===== reduced-motion: 位置移動は消し、色・不透明度は残す ===== */
@media (prefers-reduced-motion: reduce) {
  .main.view-enter > * { animation: none; }
  .btn:active, .deck-item:active { transform: none; }
  .toast, .toast.show, .toast.hide { transition: opacity 160ms ease; transform: translateX(-50%); }
  /* ガイドのモックは動かさず完成形を静止表示 */
  .mp-field .mp-v, .mp-row, .mp-amount, .mr-sell, .msh-paper { animation: none; opacity: 1; transform: none; }
  .tap-dot, .msy-dot { animation: none; opacity: 0; }
  .gf-arrow .ms, .mr-x, .msh-btn, .msy-dev { animation: none; }
  .mr-x { opacity: 1; }
}

/* 用紙の余白をゼロにする。
 * ブラウザは日付・URL・ページ番号といったヘッダー/フッターを「用紙の余白部分」に描くため、
 * 余白が無ければ印刷設定の「ヘッダーとフッター」にチェックが入っていても印字されない。
 * そのぶんの余白は .sheet の padding で内側に確保する（下の @media print 参照）。
 * ※印刷ダイアログで「余白」を既定から「最小」「カスタム」に変えた場合はブラウザ側が優先され、
 *   ヘッダー/フッターが復活する。その場合は「余白：デフォルト」に戻す。 */
@page {
  size: A4;
  margin: 0;
}

@media print {
  body { background: #fff; }
  .topbar, .bottom-nav, .print-actions, .est-bar { display: none !important; }
  .main { max-width: none; padding: 0; }
  .sheet-wrap { background: none; padding: 0; border-radius: 0; }
  /* @page の余白をゼロにしたぶん、紙面の余白はここで確保する */
  .sheet { box-shadow: none; width: auto; min-height: auto; padding: 14mm 12mm; }
  .no-print { display: none !important; }
}

/* ===== 承認 ===== */
.apv-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.apv-badge {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  padding: 3px 11px; border-radius: 999px; white-space: nowrap;
}
.apv-draft    { background: var(--surface-2); color: var(--muted); }
.apv-pending  { background: var(--warn-bg);   color: var(--warn); }
.apv-approved { background: var(--accent-soft); color: var(--ok); }
.apv-rejected { background: #fbeeed;          color: var(--danger); }
[data-theme="dark"] .apv-rejected { background: rgba(240,138,138,.14); }
.apv-lock {
  background: var(--warn-bg); color: var(--warn); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 12px 0 0; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.apv-opt {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-top: 10px; cursor: pointer;
}
.apv-opt:hover { border-color: var(--accent-deep); }
.apv-opt input { width: auto; margin-top: 3px; accent-color: var(--primary); }
.apv-opt span { display: block; font-size: 13px; }
.apv-opt small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; font-weight: 400; }

/* ===== 組織管理 ===== */
.org-add { border-top: 1px dashed var(--line); padding-top: 14px; }
.org-add h3 { margin: 0; font-size: 13px; }
.org-off td { opacity: .5; }
.org-active { display: flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.org-active input { width: auto; }
table.est td small.muted { display: block; font-size: 10.5px; }

/* ===== デモ用の役割選択 ===== */
.demo-roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.demo-role {
  text-align: left; background: var(--panel); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 13px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color .15s, background .15s;
}
.demo-role:hover { border-color: var(--accent-deep); background: var(--accent-soft); }
.demo-role.on { border-color: var(--primary); background: var(--accent-soft); }
.demo-role .dr-role { font-size: 13.5px; font-weight: 700; color: var(--primary); }
.demo-role .dr-name { font-size: 11.5px; color: var(--muted); }
.demo-role .dr-can { font-size: 11px; color: var(--text-2); margin-top: 3px; line-height: 1.5; }

.role-chip {
  background: var(--accent-soft); border: 1px solid var(--accent-deep); color: var(--primary);
  border-radius: 999px; padding: 4px 11px; font-size: 11.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap; flex: 0 0 auto;
}
.role-chip:hover { background: var(--accent); }

/* ===== スマホの「メニュー」シート ===== */
.more-backdrop {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(20, 24, 33, .38);
}
.more-sheet {
  position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 56;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 28px rgba(31, 42, 68, .18);
  max-height: 70vh; overflow: auto;
}
.more-role {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; color: var(--primary);
  background: var(--accent-soft); border-radius: var(--radius-sm);
  padding: 9px 12px; margin: 4px 4px 8px;
}
.more-role .ms { font-size: 17px; }
.more-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; border-radius: var(--radius-sm);
  padding: 13px 14px; cursor: pointer; text-align: left;
  font-size: 14px; font-weight: 600; color: var(--text);
}
.more-item .ms { color: var(--muted); font-size: 21px; }
.more-item span { flex: 1; }
.more-item:hover, .more-item.on { background: var(--accent-soft); color: var(--primary); }
.more-item.on .ms { color: var(--accent-deep); }
.more-badge {
  flex: 0 0 auto; background: var(--warn-bg); color: var(--warn);
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
}
/* 下部ナビの「メニュー」に付く未処理件数 */
.bottom-nav button { position: relative; }
.nav-dot {
  position: absolute; top: 2px; right: 50%; transform: translateX(18px);
  background: var(--warn); color: #fff; font-size: 9.5px; font-weight: 700;
  min-width: 15px; height: 15px; line-height: 15px; text-align: center;
  border-radius: 999px; padding: 0 4px;
}
