:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e5e9;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #3b6ef5;
  --primary-d: #2f59cc;
  --green: #34a853;
  --warn: #f5a623;
  --danger: #d33;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ---- Topbar ---- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 12px;
  max-width: 1200px; margin: 0 auto; padding: 10px 20px;
}
.brand { font-weight: 700; font-size: 15px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumb .sep { opacity: .5; }
.spacer { flex: 1; }
.me { color: var(--muted); font-size: 13px; }

/* ---- Layout ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 80px; }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-head .spacer { flex: 1; }
.section-title { font-size: 15px; margin: 30px 0 12px; color: var(--muted); font-weight: 700; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); padding: 8px 14px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { border-color: #c9ced6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef0f3; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); }
.btn-big { padding: 13px 26px; font-size: 15px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; pointer-events: none; }

/* ---- Cards grid（一覧） ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; box-shadow: var(--shadow); cursor: pointer; position: relative;
  transition: transform .08s ease, box-shadow .08s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.card h3 { margin: 0 0 4px; font-size: 15px; padding-right: 20px; }
.card .meta { color: var(--muted); font-size: 12px; }
.card .price-line { margin-top: 8px; font-size: 13px; }
.card .price-line b { font-size: 16px; }
.card .corner-del {
  position: absolute; top: 8px; right: 8px; opacity: 0;
  border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 16px;
}
.card:hover .corner-del { opacity: 1; }
.card .card-actions { margin-top: 10px; display: flex; gap: 6px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef0f3; color: var(--muted); }
.badge.b-share { background: #e7efff; color: var(--primary); }
.badge.b-submitted { background: #e3f3e6; color: #1d7c36; }
.badge.b-template { background: #fdf3e3; color: #a06a00; }

.empty { color: var(--muted); padding: 40px; text-align: center; background: var(--panel); border: 1px dashed var(--border); border-radius: 12px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--panel); padding: 36px; border-radius: 16px; box-shadow: var(--shadow); width: 320px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--primary); }
.field .hint-s { color: var(--muted); font-size: 11px; margin-top: 3px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; white-space: pre-wrap; }

/* ---- 詳細レイアウト ---- */
.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .detail-layout { grid-template-columns: 1fr; } }
.side-col { position: sticky; top: 64px; }
@media (max-width: 960px) { .side-col { position: static; } }

/* ---- タブ ---- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tabs button {
  border: none; background: none; cursor: pointer;
  padding: 10px 18px; font-size: 14px; font-weight: 700; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- 編集タブ：項目カード ---- */
.item-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.item-card .ic-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); background: #fafbfc; flex-wrap: wrap;
}
.item-card .ic-head b { font-size: 14px; }
.item-card .ic-desc { color: var(--muted); font-size: 12px; padding: 8px 14px 0; white-space: pre-wrap; }
.type-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: #e7efff; color: var(--primary); flex-shrink: 0; }
.type-badge.t-multi { background: #e3f3e6; color: #1d7c36; }
.type-badge.t-number { background: #fdf3e3; color: #a06a00; }
.cond-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #f3e8ff; color: #7c3aed; }
.req-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #fdecec; color: var(--danger); }

.row-actions { margin-left: auto; display: flex; gap: 2px; align-items: center; }
.mini-btn {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 13px; padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.mini-btn:hover { background: #eef0f3; color: var(--text); }
.mini-btn[disabled] { opacity: .25; pointer-events: none; }

.choice-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.choice-row:last-child { border-bottom: none; }
.choice-row .cr-main { flex: 1; min-width: 0; }
.choice-row .cr-label { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.choice-row .cr-desc { color: var(--muted); font-size: 12px; white-space: pre-wrap; }
.choice-row .cr-price { font-weight: 700; white-space: nowrap; }
.choice-row .cr-price small { color: var(--muted); font-weight: 400; }
.ic-foot { padding: 10px 14px; }
.number-conf { color: var(--muted); font-size: 12px; padding: 10px 14px; }

/* ---- 入力フォーム（シミュレーション / 共有ページ共通） ---- */
.q-item { margin-bottom: 26px; }
.q-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.q-item-head h3 { font-size: 16px; margin: 0; }
.req { font-size: 11px; font-weight: 700; color: #fff; background: var(--danger); border-radius: 4px; padding: 1px 7px; }
.q-item-desc { color: var(--muted); font-size: 13px; margin: 0 0 10px; white-space: pre-wrap; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }

.choice-card {
  background: var(--panel); border: 2px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; display: flex; gap: 10px; position: relative;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.choice-card:hover { border-color: #b9c6ee; }
.choice-card.sel { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.choice-grid .choice-card { flex-direction: column; }
.choice-card .cc-check {
  width: 20px; height: 20px; flex-shrink: 0; border: 2px solid #c9ced6; background: #fff;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.choice-card .cc-check.radio { border-radius: 50%; }
.choice-card .cc-check.check { border-radius: 5px; }
.choice-card.sel .cc-check { border-color: var(--primary); background: var(--primary); }
.choice-card.sel .cc-check::after { content: ''; }
.choice-card.sel .cc-check.radio::after { width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.choice-card.sel .cc-check.check::after {
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-top: -2px;
}
.choice-grid .choice-card .cc-check { position: absolute; top: 12px; right: 12px; margin: 0; }
.cc-main { flex: 1; min-width: 0; }
.cc-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding-right: 26px; }
.choice-list .cc-top { padding-right: 0; }
.cc-label { font-weight: 700; font-size: 14px; }
.cc-price { font-weight: 700; font-size: 16px; color: var(--primary); white-space: nowrap; }
.cc-price small { font-size: 11px; color: var(--muted); font-weight: 600; }
.choice-list .cc-price { margin-left: auto; }
.cc-days { display: inline-block; font-size: 11px; color: var(--muted); background: #eef0f3; border-radius: 4px; padding: 0 6px; margin-top: 4px; }
.cc-desc { color: var(--muted); font-size: 12px; margin-top: 6px; white-space: pre-wrap; }

.choice-card.included { cursor: default; background: #f6f8f6; border-style: dashed; }
.choice-card.included:hover { border-color: var(--border); }
.choice-card.included .cc-label, .choice-card.included .cc-desc { color: #8a958c; }
.inc-badge { font-size: 11px; font-weight: 700; color: #1d7c36; background: #e3f3e6; border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.included-note {
  background: #f0f7f1; border: 1px dashed #bcd9c2; color: #1d7c36;
  border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 26px;
}

/* 数量入力 */
.qty-box { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 2px solid var(--border); border-radius: 12px; padding: 12px 14px; flex-wrap: wrap; }
.qty-box.active { border-color: var(--primary); }
.qty-stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.qty-stepper button {
  width: 36px; height: 36px; border: none; background: #f4f5f7; font-size: 18px; cursor: pointer; color: var(--text);
}
.qty-stepper button:hover { background: #e8eaee; }
.qty-stepper input {
  width: 56px; height: 36px; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  text-align: center; font-size: 15px; font-weight: 700; font-family: inherit;
}
.qty-stepper input:focus { outline: none; }
.qty-unit { color: var(--muted); font-size: 13px; }
.qty-amount { margin-left: auto; font-weight: 700; font-size: 15px; color: var(--primary); white-space: nowrap; }
.qty-amount small { color: var(--muted); font-weight: 400; font-size: 11px; }

/* ---- 合計サマリーパネル ---- */
.summary-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
}
.summary-panel .sp-head { padding: 13px 16px; border-bottom: 1px solid var(--border); font-weight: 700; background: #fafbfc; }
.summary-panel .sp-body { padding: 14px 16px; }
.sum-warn { background: #fdf3e3; color: #a06a00; font-size: 12px; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.sum-line { display: flex; gap: 10px; font-size: 13px; padding: 3px 0; }
.sum-line .sl-label { flex: 1; min-width: 0; }
.sum-line .sl-amount { white-space: nowrap; font-weight: 600; }
.sum-line.muted-line { color: var(--muted); font-size: 12px; }
.sum-divider { border-top: 1px solid var(--border); margin: 10px 0; }
.sum-subtotal { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 2px 0; }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 15px; padding: 6px 0 2px; }
.sum-total .st-amount { font-size: 22px; color: var(--primary); }
.sum-month { background: #f5f9f5; border: 1px solid #d7ead9; border-radius: 8px; padding: 8px 12px; margin-top: 10px; }
.sum-month .sum-total .st-amount { font-size: 18px; color: #1d7c36; }
.sum-days { display: flex; justify-content: space-between; margin-top: 12px; background: #eef0f3; border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 600; }
.sum-included { margin-top: 12px; font-size: 12px; color: #1d7c36; }
.sum-included div { padding: 1px 0; }
.sum-note { color: var(--muted); font-size: 11px; margin-top: 12px; }

/* ---- 共有ページ ---- */
.share-body { background: var(--bg); }
.share-wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px 120px; }
.share-hero { padding: 34px 0 6px; }
.share-hero .sh-company { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.share-hero h1 { font-size: 22px; margin: 4px 0 14px; line-height: 1.4; }
.share-greeting {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 16px 20px; font-size: 13.5px; white-space: pre-wrap; margin-bottom: 26px;
}
.share-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 960px) { .share-grid { grid-template-columns: 1fr; } }

.client-fields { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; margin-top: 6px; }
.client-fields h3 { font-size: 14px; margin: 0 0 10px; }
.share-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.submit-banner { background: #e3f3e6; color: #1d7c36; border-radius: 10px; padding: 12px 16px; font-size: 13px; font-weight: 600; margin-top: 14px; }

#mobileBar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--panel); border-top: 1px solid var(--border);
  padding: 10px 16px; align-items: center; gap: 12px;
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
#mobileBar .mb-total { font-weight: 700; font-size: 17px; color: var(--primary); }
#mobileBar .mb-sub { color: var(--muted); font-size: 11px; }
@media (max-width: 960px) {
  #mobileBar { display: flex; }
  .share-wrap { padding-bottom: 160px; }
}

/* ---- Modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--panel); border-radius: 14px; padding: 24px; width: 440px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal h2 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.checklist { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-height: 160px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.inline-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.inline-check input { margin: 0; flex: none; }

.share-url-row { display: flex; gap: 8px; margin: 8px 0 4px; }
.share-url-row input { flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; color: var(--muted); }

/* ---- メッセージボックス ---- */
.msg-box { background: #fffbe8; border: 1px solid #f3e3a0; border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; }
.msg-box .mb-head { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.msg-box .mb-body { font-size: 13px; white-space: pre-wrap; }
.msg-box .mb-date { color: var(--muted); font-size: 11px; margin-top: 6px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(31,36,48,.92); color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 20px; border-radius: 999px; z-index: 200; pointer-events: none;
  opacity: 0; transition: opacity .25s ease;
}
.toast.show { opacity: 1; }

/* ---- nav links ---- */
.navlink { font-size: 13px; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.navlink:hover { background: #eef0f3; color: var(--text); }

.muted { color: var(--muted); }

/* ===========================================================================
   印刷（御見積書） — #printArea のみ印刷する
   =========================================================================== */
#printArea { display: none; }

.q-doc { font-size: 12px; color: #1f2430; }
.q-doc .qd-title { text-align: center; font-size: 24px; letter-spacing: .35em; margin: 0 0 24px; font-weight: 700; }
.q-doc .qd-cols { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.q-doc .qd-client { font-size: 16px; font-weight: 700; border-bottom: 2px solid #1f2430; padding: 0 30px 4px 2px; align-self: flex-start; }
.q-doc .qd-meta { text-align: right; font-size: 12px; line-height: 1.7; }
.q-doc .qd-company { font-size: 14px; font-weight: 700; }
.q-doc .qd-subject { margin: 4px 0 14px; font-size: 13px; }
.q-doc .qd-grand {
  display: inline-block; border: 2px solid #1f2430; padding: 8px 26px; margin-bottom: 18px;
  font-size: 14px; font-weight: 700;
}
.q-doc .qd-grand b { font-size: 20px; margin-left: 14px; }
.q-doc .qd-grand small { font-weight: 400; margin-left: 10px; color: #555; }
.q-doc h3 { font-size: 13px; margin: 18px 0 6px; border-left: 4px solid #3b6ef5; padding-left: 8px; }
.q-doc table { width: 100%; border-collapse: collapse; }
.q-doc th, .q-doc td { border: 1px solid #c8ccd2; padding: 6px 9px; text-align: left; vertical-align: top; }
.q-doc th { background: #f0f2f5; font-size: 11px; }
.q-doc td.amount, .q-doc th.amount { text-align: right; white-space: nowrap; width: 110px; }
.q-doc td.detail { color: #555; font-size: 11px; }
.q-doc tfoot td { border: 1px solid #c8ccd2; font-weight: 600; }
.q-doc tfoot tr.total td { background: #f0f2f5; font-size: 13px; font-weight: 700; }
.q-doc .qd-days { margin-top: 14px; font-size: 12px; }
.q-doc .qd-notes { margin-top: 16px; font-size: 11px; color: #555; line-height: 1.8; }
.q-doc .qd-notes li { margin-left: 1.2em; }

@media print {
  body { background: #fff !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  @page { size: A4; margin: 14mm 12mm; }
}
