/* ミツモリ現場 — callAI 準拠テーマ（ライト・フラット・ミント×インディゴ／パープル不使用）
 * callAI fullview の配色トークンをそのまま採用。
 */
:root {
  --bg: #fafaf8;
  --panel: #ffffff;
  --line: #e8e4dd;
  --text: #292827;
  --muted: #73706d;
  --primary: #1b1938;
  --primary-600: #322f5c;
  --accent: #b8e0d2;
  --accent-deep: #8ec9b3;
  --accent-soft: #eef6f2;
  --danger: #b5433a;
  --ok: #3f7d68;
  --input-bg: #ffffff;
  --button-fg: #ffffff;
  --warn: #b26a00;
  --warn-bg: #fdf6ea;

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

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

* { 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; }

/* 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; }

/* ===== フォーム ===== */
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(142,201,179,.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='%2373706d' 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); }

.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; }
.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; }

.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; }

.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;
  transition: background .15s;
}
.btn .ms { font-size: 17px; }
.btn:hover { background: var(--primary-600); }
.btn:active { opacity: .9; }
.btn.secondary { background: var(--panel); color: var(--primary); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--accent-soft); border-color: var(--accent-deep); }
.btn.tonal { background: var(--accent-soft); color: var(--ok); border: 1px solid var(--accent-deep); }
.btn.tonal:hover { background: #e4f0ea; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.btn.ghost:hover { background: var(--accent-soft); border-color: var(--accent-deep); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: none; padding: 5px 8px; }
.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); }

.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; }

.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 .15s, background .15s;
}
.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(27,25,56,.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; }
table.est th, table.est td { padding: 8px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px; vertical-align: middle; color: var(--text); }
table.est th { 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; }
table.est tbody tr { transition: background .12s; }
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; }
table.master th, table.master td { padding: 8px 7px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--text); }
table.master th { 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;
}

/* ===== 見積書（白い紙面） ===== */
.sheet-wrap { background: #ece9e3; 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; }

@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; }
  .sheet { box-shadow: none; width: auto; min-height: auto; padding: 8mm 6mm; }
  .no-print { display: none !important; }
}
