/* 見積シミュレーター */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --accent: #08733D;
  --tint: color-mix(in srgb, var(--accent) 8%, #fff);
  --tint-2: color-mix(in srgb, var(--accent) 17%, #fff);
  --edge: color-mix(in srgb, var(--accent) 32%, #fff);
  --deep: color-mix(in srgb, var(--accent) 40%, #0a0f0c);
  --gold: #D5A92C;
  --gold-soft: #F1DC9B;
  --ink: #1D2622;
  --ink-2: #3A4640;
  --muted: #6A746F;
  --line: #E1E5E2;
  --line-2: #CDD4D0;
  --bg: color-mix(in srgb, var(--accent) 3%, #F5F6F3);
  --card: #fff;
  --danger: #B64D3B;
  --danger-tint: #FBEDEA;
  --blue: #2B5C9A;
  --blue-tint: #EAF1FB;
  --r: 14px;
  --r-sm: 10px;
  --shadow-1: 0 1px 2px rgba(15, 30, 22, .05), 0 2px 8px rgba(15, 30, 22, .04);
  --shadow-2: 0 2px 6px rgba(15, 30, 22, .06), 0 14px 34px rgba(15, 30, 22, .10);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "YuGothic", "Meiryo", system-ui, sans-serif;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-weight: 400; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 上のバー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-mark .bm-bg { fill: var(--deep); }
.brand-text { min-width: 0; }
.brand-name { display: block; font-weight: 700; font-size: 15px; line-height: 1.25; letter-spacing: .02em; }
.brand-no { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 2px; }
.tbtn {
  display: flex; align-items: center; gap: 6px;
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 12px; border-radius: 10px;
  color: var(--ink-2); font-size: 14px; font-weight: 600;
}
.tbtn:hover { background: var(--tint); color: var(--accent); }
@media (max-width: 560px) {
  .tbtn { flex-direction: column; gap: 1px; padding: 5px 9px; font-size: 10.5px; }
  .tbtn .ic { width: 21px; height: 21px; }
}

/* ---------- レイアウト ---------- */
.layout {
  max-width: 1120px; margin: 0 auto;
  padding: 16px 16px calc(132px + env(safe-area-inset-bottom));
  display: grid; gap: 20px;
}
.col-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; padding: 24px 24px 56px; align-items: start; }
  .col-side { position: sticky; top: 84px; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }

/* ---------- アコーディオンの共通 ---------- */
.acc-body {
  display: grid; grid-template-rows: 0fr; visibility: hidden;
  transition: grid-template-rows .32s var(--ease), visibility 0s linear .32s;
}
.open > .acc-body {
  grid-template-rows: 1fr; visibility: visible;
  transition: grid-template-rows .32s var(--ease), visibility 0s;
}
.acc-inner { overflow: hidden; min-height: 0; }
.chev { color: var(--muted); transition: transform .3s var(--ease); }
.open > .acc-head .chev, .open > .item-head .chev { transform: rotate(180deg); }

/* ---------- 入力欄 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-width: 0; height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: #fff; font-size: 16px;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; line-height: 1.6; resize: vertical; }
select {
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236A746F' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type=date] { line-height: 42px; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input[type=search] { padding-left: 14px; }
input::placeholder, textarea::placeholder { color: #A3ABA7; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input.center { text-align: center; }
.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent) !important; }
.shake { animation: shake .36s; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

.input-group { display: flex; gap: 8px; }
.input-group select { width: 92px; flex: none; }
.yen-input, .suffix-input { position: relative; }
.yen-input .yen {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 700; pointer-events: none;
}
.yen-input input { padding-left: 28px !important; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.suffix-input span {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 600; pointer-events: none;
}
.suffix-input input { padding-right: 34px !important; text-align: right; }

/* 区分（一括・月額） */
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 11px;
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 6px 16px; border-radius: 8px;
  font-size: 13.5px; font-weight: 700; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg input:checked + span { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input[value=monthly]:checked + span { color: var(--blue); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* チェックボックス */
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.chk input {
  -webkit-appearance: none; appearance: none; margin: 0;
  width: 21px; height: 21px; flex: none; cursor: pointer;
  border: 1.5px solid var(--line-2); border-radius: 6px; background: #fff;
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.chk input::after {
  content: ""; width: 10px; height: 5.5px;
  border: 2.2px solid #fff; border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px); opacity: 0;
}
.chk input:checked { background: var(--accent); border-color: var(--accent); }
.chk input:checked::after { opacity: 1; }
.chk input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chk.danger input:checked { background: var(--danger); border-color: var(--danger); }
.chk.danger input:checked + span { color: var(--danger); }
.chk.light { color: rgba(255, 255, 255, .85); font-weight: 600; font-size: 13px; }
.chk.light input { background: transparent; border-color: rgba(255, 255, 255, .4); }
.chk.light input:checked { background: var(--gold); border-color: var(--gold); }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-size: 15px; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 62%, #000); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.gold { background: var(--gold); color: #241B04; }
.btn.gold:hover { background: color-mix(in srgb, var(--gold) 90%, #000); }
.btn.ghost { background: #fff; border-color: var(--line-2); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--edge); background: var(--tint); }
.btn.sm { height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.link-btn {
  border: 0; background: none; cursor: pointer;
  padding: 6px; color: var(--accent); font-size: 13px; font-weight: 700;
}
.link-btn.danger { color: var(--danger); }
.icon-btn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border: 0; background: transparent; border-radius: 10px; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--tint); }

/* ---------- 見積情報 ---------- */
.info-head {
  width: 100%; min-height: 56px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border: 0; background: none; cursor: pointer; text-align: left;
}
.info-label {
  flex: none; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent); background: var(--tint); padding: 3px 8px; border-radius: 6px;
}
.info-summary { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-summary.placeholder { color: var(--muted); font-weight: 400; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px 16px 18px; }
.span-2 { grid-column: 1 / -1; }

/* ---------- 見積項目 ---------- */
.items-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; padding: 0 2px; min-height: 32px; }
.sec-title { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; line-height: 20px; min-width: 22px; text-align: center; padding: 0 7px; border-radius: 99px; background: var(--deep); color: #fff; }
.items-tools { display: flex; gap: 2px; }

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-1); overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
  scroll-margin: 90px 0 150px;
}
.item.open { border-color: var(--edge); box-shadow: var(--shadow-2); }
.item-head {
  width: 100%; min-height: 62px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 11px 12px 11px 14px; border: 0; background: none; cursor: pointer; text-align: left;
}
.item-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r); }
.item-no {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--tint); color: var(--accent); font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.item.open .item-no { background: var(--accent); color: #fff; }
.item-main { min-width: 0; }
.item-name {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  font-weight: 700; line-height: 1.4; word-break: break-all;
}
.item-sub { display: flex; align-items: center; gap: 6px; margin-top: 1px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.sub-text { overflow: hidden; text-overflow: ellipsis; }
.tag { flex: none; font-size: 10.5px; font-weight: 800; line-height: 18px; padding: 0 6px; border-radius: 5px; }
.tag.monthly { background: var(--blue-tint); color: var(--blue); }
.tag.discount { background: var(--danger-tint); color: var(--danger); }
.item-amt { font-size: 16.5px; font-weight: 800; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-amt small { font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 1px; }
.item-amt.neg { color: var(--danger); }

.item-edit { margin: 0 14px; padding: 14px 0 14px; border-top: 1px dashed var(--line-2); }
.edit-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.c-name, .c-opts, .c-memo { grid-column: 1 / -1; }
.c-price { grid-column: span 5; }
.c-qty { grid-column: span 3; }
.c-unit { grid-column: span 4; }
.c-opts { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 36px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 9px; background: #fff; cursor: pointer;
  font-size: 12.5px; font-weight: 700; color: var(--ink-2); white-space: nowrap;
}
.mini.sq { width: 36px; padding: 0; }
.mini .ic { width: 16px; height: 16px; }
.mini:hover:not(:disabled) { border-color: var(--edge); background: var(--tint); color: var(--accent); }
.mini:disabled { opacity: .38; cursor: default; }
.mini.danger { margin-left: auto; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, #fff); }
.mini.danger:hover { background: var(--danger-tint); color: var(--danger); border-color: var(--danger); }

@keyframes itemIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes flash { 0%, 30% { background: var(--tint-2); } 100% { background: transparent; } }
@keyframes itemOut { to { opacity: 0; transform: translateX(28px); } }
.item.is-new { animation: itemIn .5s var(--ease) both; }
.item.is-new .item-head { animation: flash 1.6s ease-out; }
.item.is-leaving { animation: itemOut .22s ease-in forwards; pointer-events: none; }
.item.is-moved .item-head { animation: flash 1s ease-out; }

/* 空のとき */
.empty {
  text-align: center; padding: 26px 20px 22px;
  border: 1.5px dashed var(--line-2); border-radius: var(--r);
  color: var(--muted); background: color-mix(in srgb, #fff 55%, transparent);
}
.empty-art { width: 112px; height: auto; display: block; margin: 0 auto; }
.empty-art .ea1 { fill: var(--tint-2); }
.empty-art .ea2 { fill: var(--tint); }
.empty-art .ea3 { fill: color-mix(in srgb, var(--accent) 4%, #fff); stroke: var(--line); }
.empty-title { margin: 12px 0 4px; font-weight: 800; color: var(--ink); }
.empty-text { margin: 0 0 14px; font-size: 13.5px; }

/* ---------- 追加フォーム ---------- */
.add {
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
  border: 1.5px dashed var(--edge);
  background: linear-gradient(180deg, var(--tint) 0%, #fff 64%);
}
.add-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14.5px; }
.add-badge { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--accent); color: #fff; }
.add-badge .ic { width: 15px; height: 15px; stroke-width: 2.8; }
.add-row { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, .75fr) minmax(0, .9fr); gap: 10px; }
.add-opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.add-submit { width: 100%; height: 52px; font-size: 16px; }
.add-submit .ic { stroke-width: 2.6; }
.presets {
  display: flex; align-items: center; gap: 8px; overflow-x: auto;
  margin: 0 -16px; padding: 2px 16px; scrollbar-width: none;
}
.presets::-webkit-scrollbar { display: none; }
.preset-label { flex: none; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.preset-hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line-2); background: #fff; cursor: pointer;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.chip b { color: var(--accent); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--edge); background: var(--tint); }
.chip:active { transform: scale(.97); }

.privacy {
  display: flex; align-items: flex-start; justify-content: center; gap: 6px;
  margin: 4px 0 0; padding: 0 8px; font-size: 12px; line-height: 1.6; color: var(--muted); text-align: left;
}
.privacy .ic { width: 14px; height: 14px; margin-top: 2px; }

/* ---------- 合計（スマホは下の帯） ---------- */
.summary {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--deep); color: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 32px rgba(0, 0, 0, .18);
  padding-bottom: env(safe-area-inset-bottom);
}
.sum-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; }
.sum-toggle {
  flex: 1; min-width: 0; padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label chev" "total chev" "mini chev";
  border: 0; background: none; color: inherit; text-align: left; cursor: pointer;
}
.sum-label { grid-area: label; font-size: 11.5px; font-weight: 700; color: rgba(255, 255, 255, .7); letter-spacing: .04em; }
.sum-total {
  grid-area: total; justify-self: start; position: relative;
  font-size: 27px; font-weight: 800; line-height: 1.2; letter-spacing: .01em; white-space: nowrap;
  transform-origin: left center;
}
.sum-total.bump { animation: bump .42s var(--ease); }
@keyframes bump { 40% { transform: scale(1.07); } }
.sum-mini { grid-area: mini; font-size: 12.5px; font-weight: 700; color: var(--gold-soft); }
.sum-mini:empty { display: none; }
.sum-toggle .chev { grid-area: chev; align-self: center; color: rgba(255, 255, 255, .6); transform: rotate(180deg); }
.summary.open .sum-toggle .chev { transform: none; }
.sum-doc { flex: none; height: 48px; padding: 0 16px; }
.delta {
  position: absolute; left: 16px; bottom: calc(100% + 10px); z-index: 1;
  padding: 6px 13px; border-radius: 99px;
  background: var(--gold); color: #241B04; box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
  font-size: 14px; font-weight: 800; white-space: nowrap; opacity: 0; pointer-events: none;
}
.delta.neg { background: #FBE3DD; color: var(--danger); }
.delta.show { animation: deltaUp 1.5s var(--ease); }
@keyframes deltaUp {
  0% { opacity: 0; transform: translateY(10px); }
  14% { opacity: 1; transform: none; }
  70% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-12px); }
}
.sum-detail { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.summary.open .sum-detail { grid-template-rows: 1fr; }
.sum-inner { overflow: hidden; min-height: 0; }
.sum-scroll { max-height: 62vh; max-height: min(62dvh, 560px); overflow: auto; padding: 0 16px 16px; overscroll-behavior: contain; }

.bd { border-top: 1px solid rgba(255, 255, 255, .13); padding: 12px 2px; }
.bd-title { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; font-weight: 800; letter-spacing: .06em; color: var(--gold-soft); }
.bd-title span:last-child { color: rgba(255, 255, 255, .55); font-weight: 600; letter-spacing: 0; }
.bd-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14px; color: rgba(255, 255, 255, .82); }
.bd-row.total { margin-top: 4px; padding-top: 8px; border-top: 1px dashed rgba(255, 255, 255, .2); font-size: 16px; font-weight: 800; color: #fff; }
.bd-row.sub { font-size: 12.5px; color: rgba(255, 255, 255, .6); }
.bd-empty { padding: 14px 2px; border-top: 1px solid rgba(255, 255, 255, .13); font-size: 13px; color: rgba(255, 255, 255, .6); }

.sim { margin: 2px 0 14px; padding: 12px 14px 14px; border-radius: 14px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); }
.sim-head { font-size: 12px; font-weight: 800; letter-spacing: .06em; color: var(--gold-soft); }
.sim-ctrl { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 8px 0 6px; }
.sim-months { font-size: 13px; font-weight: 700; color: rgba(255, 255, 255, .8); }
.sim-months strong { font-size: 24px; color: #fff; margin-right: 2px; }
.step {
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: #fff; font-size: 18px; font-weight: 700;
}
.step:hover { background: rgba(255, 255, 255, .08); }
.sim-quick { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.sim-quick button {
  height: 28px; padding: 0 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .2); background: transparent; color: rgba(255, 255, 255, .8); font-size: 12px; font-weight: 700;
}
.sim-quick button[aria-pressed=true] { background: var(--gold); border-color: var(--gold); color: #241B04; }
.sim-result { text-align: center; font-size: 12.5px; color: rgba(255, 255, 255, .72); margin-bottom: 10px; }
.sim-result strong { display: block; font-size: 22px; color: var(--gold); letter-spacing: .01em; }
.sum-actions { display: flex; flex-direction: column; gap: 8px; }
.btn.line-light { height: 42px; padding: 0 10px; font-size: 13.5px; background: transparent; border-color: rgba(255, 255, 255, .28); color: #fff; }
.btn.line-light:hover { background: rgba(255, 255, 255, .08); }
.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(8, 14, 11, .42); opacity: 0; pointer-events: none; transition: opacity .25s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

@media (min-width: 900px) {
  .summary { position: relative; border-radius: 20px; box-shadow: var(--shadow-2); padding: 0; }
  .delta { left: auto; right: 20px; bottom: auto; top: 18px; }
  .sum-bar { padding: 20px 22px 8px; }
  .sum-toggle { cursor: default; pointer-events: none; }
  .sum-toggle .chev, .sum-doc { display: none; }
  .sum-total { font-size: 34px; }
  .sum-detail { grid-template-rows: 1fr; }
  .sum-scroll { max-height: none; overflow: visible; padding: 0 22px 22px; }
  .scrim { display: none; }
}

/* ---------- 下から出るシート（一覧・設定） ---------- */
dialog.sheet {
  width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh;
  margin: auto auto 0; padding: 0; border: 0;
  border-radius: 20px 20px 0 0; background: var(--bg); color: var(--ink);
  box-shadow: var(--shadow-2); overflow: hidden;
  flex-direction: column;
}
dialog.sheet[open] { display: flex; animation: sheetUp .32s var(--ease); }
dialog::backdrop { background: rgba(8, 14, 11, .45); }
@keyframes sheetUp { from { transform: translateY(48px); opacity: 0; } }
@media (min-width: 700px) {
  dialog.sheet { margin: auto; max-width: 640px; max-height: 86vh; border-radius: 20px; }
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; background: var(--card); border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 16px; }
.sheet-body {
  overflow: auto; padding: 16px; padding-bottom: calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain;
}
.sheet-note { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

.est-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.est { display: flex; align-items: stretch; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.est.current { border-color: var(--edge); box-shadow: 0 0 0 3px var(--tint); }
.est-open {
  flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 12px;
  padding: 12px 14px; border: 0; background: none; text-align: left; cursor: pointer;
}
.est-open:hover { background: var(--tint); }
.est-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-meta { grid-column: 1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-amt { grid-column: 2; grid-row: 1 / 3; align-self: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.est-amt small { font-size: 11px; color: var(--muted); }
.badge-now { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 5px; background: var(--accent); color: #fff; font-size: 10.5px; line-height: 18px; vertical-align: 2px; }
.est-acts { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.est-acts button { flex: 1; min-width: 58px; padding: 0 12px; border: 0; background: none; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.est-acts button + button { border-top: 1px solid var(--line); }
.est-acts button:hover { background: var(--tint); }
.est-acts .del { color: var(--danger); }
.est-acts .del:hover { background: var(--danger-tint); }
.est-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13.5px; }

.set-sec { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.set-sec h3 { margin: 0 0 2px; font-size: 14.5px; }
.set-sec .desc { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stamp-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stamp-preview {
  width: 64px; height: 64px; flex: none; display: grid; place-items: center; overflow: hidden;
  border: 1.5px dashed var(--line-2); border-radius: 12px; background: #fff; font-size: 11px; color: var(--muted);
}
.stamp-preview img { max-width: 100%; max-height: 100%; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; cursor: pointer; padding: 0; font-size: 11px; font-weight: 700; color: var(--muted); }
.swatch i { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line-2); display: block; }
.swatch[aria-pressed=true] i { box-shadow: 0 0 0 2.5px var(--ink); }
.swatch[aria-pressed=true] { color: var(--ink); }
.swatch.custom i { background: conic-gradient(#e0533d, #e8b93a, #4caf6a, #3b82c4, #8a55c9, #e0533d); position: relative; }
.swatch.custom input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preset-manage { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.preset-manage li { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.preset-manage .pm-name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset-manage .pm-amt { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.preset-manage .pm-empty { justify-content: center; color: var(--muted); font-size: 13px; border-style: dashed; }

/* ---------- お知らせ ---------- */
.toast {
  position: fixed; inset: auto; left: 50%; bottom: calc(112px + env(safe-area-inset-bottom));
  margin: 0; border: 0; overflow: visible;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); width: max-content;
  padding: 10px 10px 10px 16px; border-radius: 12px;
  background: #1C2420; color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s var(--ease);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast span { padding: 4px 0; }
.toast button { flex: none; border: 0; border-radius: 8px; padding: 6px 10px; background: rgba(255, 255, 255, .12); color: var(--gold-soft); font-weight: 800; cursor: pointer; }
@media (min-width: 900px) { .toast { bottom: 32px; } }

/* ---------- 見積書プレビュー ---------- */
.preview { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #3B413E; }
.pv-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--deep); color: #fff;
}
.pv-title { flex: 1; text-align: center; font-weight: 800; font-size: 15px; letter-spacing: .1em; }
.btn.ghost-light { height: 40px; padding: 0 12px 0 8px; font-size: 14px; background: transparent; border-color: rgba(255, 255, 255, .28); color: #fff; }
.pv-bar .btn.gold { height: 40px; padding: 0 14px; font-size: 14px; }
.pv-hint { margin: 0; padding: 8px 16px; font-size: 12px; line-height: 1.6; color: rgba(255, 255, 255, .78); text-align: center; background: rgba(0, 0, 0, .18); }
.pv-hint button { border: 0; background: none; color: var(--gold-soft); font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0 2px; font-size: inherit; }
.pv-stage { flex: 1; overflow: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.pv-sizer { position: relative; margin: 0 auto; }

/* 見積書の本体（A4） */
.doc {
  position: absolute; top: 0; left: 0;
  width: 210mm; min-height: 297mm;
  padding: 16mm 15mm 14mm;
  background: #fff; color: #1A1A1A;
  font-family: var(--font); font-size: 9.5pt; line-height: 1.55;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  transform-origin: top left;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.doc-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8mm; padding-bottom: 3.5mm; margin-bottom: 7mm; border-bottom: 2px solid var(--deep); }
.doc-title { margin: 0; font-family: var(--serif); font-size: 22pt; font-weight: 600; letter-spacing: .55em; line-height: 1.2; color: #111; }
.doc-meta { margin: 0; display: grid; grid-template-columns: auto auto; gap: .5mm 4mm; font-size: 9pt; }
.doc-meta dt { color: #666; }
.doc-meta dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.doc-top { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10mm; margin-bottom: 4mm; }
.to-name { display: flex; align-items: baseline; justify-content: space-between; gap: 4mm; padding-bottom: 1.5mm; border-bottom: 1px solid #333; font-size: 14pt; font-weight: 700; line-height: 1.35; }
.to-name .hon { flex: none; font-size: 11pt; font-weight: 600; }
.doc-lead { margin: 3mm 0 3mm; font-size: 9.5pt; }
.doc-cond { margin: 0 0 4mm; display: grid; grid-template-columns: 17mm minmax(0, 1fr); gap: .8mm 0; font-size: 9.5pt; }
.doc-cond dt { color: #555; }
.doc-cond dd { margin: 0; }
.doc-total {
  display: flex; align-items: center; justify-content: space-between; gap: 4mm;
  padding: 3mm 4mm; border: 1px solid var(--edge); border-left: 4px solid var(--accent); border-radius: 1.5mm;
  background: var(--tint);
}
.doc-total span { font-size: 10pt; font-weight: 700; }
.doc-total strong { font-size: 18pt; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-total-sub { margin-top: 1.8mm; text-align: right; font-size: 9.5pt; }
.doc-total-sub b { font-size: 11pt; font-variant-numeric: tabular-nums; }
.doc-from { position: relative; padding-top: 1mm; font-size: 8.8pt; line-height: 1.75; }
.from-name { margin-bottom: 1mm; font-size: 12pt; font-weight: 700; line-height: 1.4; padding-right: 16mm; }
.doc-from .stamp { position: absolute; right: 0; top: -1mm; width: 21mm; height: 21mm; object-fit: contain; mix-blend-mode: multiply; }
.doc-sec { margin-top: 6mm; }
.doc-sec h2 { margin: 0 0 2mm; padding-left: 2.5mm; border-left: 3px solid var(--accent); font-size: 10.5pt; line-height: 1.3; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 9.2pt; }
.doc-table col.w-no { width: 9mm; }
.doc-table col.w-qty { width: 20mm; }
.doc-table col.w-price { width: 25mm; }
.doc-table col.w-amt { width: 28mm; }
.doc-table th { padding: 1.8mm 2.2mm; background: var(--deep); color: #fff; font-weight: 600; font-size: 8.8pt; text-align: center; }
.doc-table td { padding: 2mm 2.2mm; border-bottom: 1px solid #DDD; vertical-align: top; }
.doc-table tbody.rows tr:nth-child(even) td { background: #F8FAF9; }
.doc-table tr { break-inside: avoid; }
.doc-table td.c { text-align: center; color: #666; }
.doc-table td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-table td.q { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-table .memo { display: block; margin-top: .4mm; font-size: 7.8pt; color: #666; white-space: pre-wrap; }
.doc-table .neg { color: var(--danger); }
.doc-table tbody.sums td { padding: 1.4mm 2.2mm; border: 0; }
.doc-table tbody.sums tr:first-child td { padding-top: 2.4mm; }
.doc-table tbody.sums .fl { text-align: right; color: #444; }
.doc-table tbody.sums tr.grand td { font-weight: 800; font-size: 10.5pt; }
.doc-table tbody.sums tr.grand td.fl, .doc-table tbody.sums tr.grand td.n { border-top: 1.5px solid #333; }
.doc-table tbody.sums tr.note td { font-size: 8.5pt; color: #666; }
.doc-sim {
  margin-top: 5mm; padding: 2.6mm 4mm; border: 1px dashed #BBB; border-radius: 1.5mm;
  display: flex; align-items: center; justify-content: space-between; gap: 4mm; flex-wrap: wrap; font-size: 9pt;
}
.doc-sim b { font-size: 11pt; font-variant-numeric: tabular-nums; }
.doc-note { margin-top: 6mm; break-inside: avoid; }
.doc-note h2 { margin: 0 0 1.5mm; font-size: 9.5pt; color: #444; }
.doc-note .box { padding: 2.6mm 4mm; border: 1px solid #CCC; border-radius: 1.5mm; white-space: pre-wrap; font-size: 8.8pt; line-height: 1.7; }
.doc-end { margin-top: 5mm; text-align: right; font-size: 9pt; color: #555; }

/* ---------- 印刷・PDF ---------- */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#preview) { display: none !important; }
  #preview { display: block !important; position: static; background: #fff; }
  .pv-bar, .pv-hint { display: none !important; }
  .pv-stage { padding: 0; overflow: visible; }
  .pv-sizer { width: auto !important; height: auto !important; }
  .doc {
    position: static; transform: none !important; box-shadow: none;
    min-height: 0; margin: 0;
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
