:root {
  color-scheme: light;
  --ink: #12233f;
  --muted: #5e6d82;
  --paper: #f5f7fa;
  --white: #fff;
  --line: #d7dee8;
  --blue: #1266e3;
  --blue-dark: #0b4fb4;
  --cyan: #19b7c9;
  --amber: #b86400;
  --shadow: 0 18px 60px rgba(17, 38, 73, .11);
  font-family: "LINE Seed JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 76px; padding: 14px clamp(20px, 5vw, 72px);
  background: var(--white); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; color: white; background: var(--blue); font: 800 22px/1 "LINE Seed JP", sans-serif; transform: skew(-8deg); }
.brand b, .brand small { display: block; }
.brand b { font: 800 16px/1 "LINE Seed JP", sans-serif; letter-spacing: .08em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .12em; }

.workspace { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 120px; }
.page-heading { display: grid; grid-template-columns: 1fr minmax(280px, .45fr); gap: 48px; align-items: end; margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.page-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); line-height: 1.25; }
.page-heading p { margin: 9px 0 0; color: var(--muted); font-size: 14px; }
.eyebrow { margin: 0 0 12px; color: var(--blue); font: 700 11px/1.4 "LINE Seed JP", sans-serif; letter-spacing: .18em; }
.quote-toolbar h1 { margin: 0; font-family: "LINE Seed JP", sans-serif; }
.progress { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; padding: 0; list-style: none; }
.progress::before { content: ""; position: absolute; top: 15px; right: 12%; left: 12%; height: 3px; background: var(--line); }
.progress li { z-index: 1; display: grid; justify-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.progress span { display: grid; place-items: center; width: 32px; height: 32px; border: 2px solid var(--line); border-radius: 50%; background: var(--paper); font: 700 12px/1 "LINE Seed JP", sans-serif; }
.progress .is-current { color: var(--blue); font-weight: 700; }
.progress .is-current span { color: #fff; border-color: var(--blue); background: var(--blue); box-shadow: 0 0 0 6px rgba(18, 102, 227, .12); }

#estimate-form { display: grid; gap: 24px; }
.form-section { padding: clamp(24px, 4vw, 48px); border: 1px solid var(--line); border-radius: 4px; background: var(--white); box-shadow: 0 8px 30px rgba(17, 38, 73, .04); }
.section-heading { display: flex; align-items: center; gap: 18px; margin-bottom: 30px; }
.section-heading > span { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 auto; color: var(--blue); border: 1px solid rgba(18, 102, 227, .35); border-radius: 50%; font-weight: 700; }
.section-heading p { margin: 0 0 4px; color: var(--blue); font: 700 10px/1 "LINE Seed JP", sans-serif; letter-spacing: .16em; }
.section-heading h2 { margin: 0; font-size: 22px; }
.section-lead { margin: -14px 0 30px 66px; color: var(--muted); font-size: 14px; }
.field-grid { display: grid; gap: 22px 18px; }
.three-columns { grid-template-columns: 1fr 1fr .5fr; }
.two-columns { grid-template-columns: 1fr 1fr; }
.field.wide { grid-column: span 2; }
.field { display: grid; gap: 8px; color: #34435a; font-size: 13px; font-weight: 700; }
.required { width: fit-content; padding: 2px 6px; color: #a23535; border-radius: 2px; background: #fff0f0; font-size: 10px; }
input, select, textarea { width: 100%; color: var(--ink); border: 1px solid #c8d1de; border-radius: 3px; background: #fff; transition: border-color .15s, box-shadow .15s; }
input, select { min-height: 46px; padding: 10px 12px; }
textarea { padding: 12px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid rgba(25, 183, 201, .42); outline-offset: 2px; border-color: var(--cyan); }

.item-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.item-card { overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #fbfcfe; transition: border-color .18s, box-shadow .18s; }
.item-card.is-selected { border-color: var(--blue); box-shadow: inset 4px 0 0 var(--blue); }
.item-toggle { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; min-height: 82px; padding: 16px 18px; cursor: pointer; }
.item-toggle input { width: 21px; min-height: 21px; accent-color: var(--blue); }
.item-toggle small, .item-toggle b { display: block; }
.item-toggle small { margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.item-toggle b { font-size: 15px; }
.tax-badge { padding: 4px 7px; border-radius: 2px; font-size: 10px; font-style: normal; font-weight: 700; }
.taxable { color: var(--blue-dark); background: #e8f1ff; }
.non-taxable { color: var(--amber); background: #fff0df; }
.item-details { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 18px; border-top: 1px solid var(--line); background: #f3f7fc; }
.item-card.is-selected .item-details { display: grid; }
.mini-field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.mini-field input, .mini-field select { min-height: 40px; background: #fff; font-size: 13px; }
.form-error { margin: 18px 0 0; padding: 12px 15px; color: #a23535; border-left: 4px solid #c74343; background: #fff0f0; font-weight: 700; }
.global-error { position: sticky; top: 10px; z-index: 5; margin: 0; box-shadow: 0 8px 24px rgba(162, 53, 53, .14); }

.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choice { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--blue); background: #f2f7ff; box-shadow: inset 4px 0 0 var(--blue); }
.choice input { width: 20px; min-height: 20px; accent-color: var(--blue); }
.choice b, .choice small { display: block; }
.choice small { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; }
.notes-field { margin-top: 24px; }

.form-total { position: sticky; bottom: 16px; z-index: 4; display: grid; grid-template-columns: repeat(5, minmax(86px, 1fr)) auto auto; gap: 16px; align-items: center; padding: 20px 22px; color: white; background: var(--ink); box-shadow: 0 16px 50px rgba(18, 35, 63, .24); }
.form-total small, .form-total strong { display: block; }
.form-total small { margin-bottom: 4px; color: #aebbd0; font-size: 10px; }
.form-total strong { font-family: "LINE Seed JP", sans-serif; font-size: 16px; font-variant-numeric: tabular-nums; }
.form-total .grand strong { color: #79e0eb; font-size: 22px; }
.primary-button, .secondary-button, .text-button { min-height: 46px; border: 0; border-radius: 3px; font-weight: 700; }
.primary-button { padding: 12px 20px; color: white; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.text-button { padding: 10px 8px; color: #cbd5e5; background: transparent; font-size: 12px; }
.secondary-button { padding: 12px 20px; color: var(--ink); border: 1px solid var(--line); background: white; }

.quote-view { min-height: 100vh; padding: 42px 20px 100px; }
.quote-toolbar { display: grid; grid-template-columns: 1fr 280px auto; gap: 28px; align-items: end; width: min(1040px, 100%); margin: 0 auto 28px; }
.quote-progress { width: 280px; }
.quote-toolbar h1 { font-size: 36px; }
.toolbar-actions { display: flex; gap: 10px; }
.quote-pages { display: grid; gap: 36px; }
.quote-sheet { position: relative; width: min(210mm, 100%); min-height: 297mm; margin: 0 auto; padding: 18mm 17mm 14mm; background: white; box-shadow: var(--shadow); }
.quote-masthead { display: grid; grid-template-columns: 1fr auto; gap: 30px; padding-bottom: 22px; border-bottom: 4px solid var(--ink); }
.quote-kicker { margin: 0 0 5px; color: var(--blue); font: 800 10px/1 "LINE Seed JP", sans-serif; letter-spacing: .18em; }
.quote-masthead h2 { margin: 0; font-size: 31px; letter-spacing: .18em; }
.mock-notice { margin: 10px 0 0; color: var(--amber); font-size: 10px; font-weight: 700; }
.quote-masthead dl { display: grid; grid-template-columns: auto auto; align-content: start; gap: 5px 18px; margin: 0; font-size: 10px; }
.quote-masthead dt { color: var(--muted); }
.quote-masthead dd { margin: 0; text-align: right; font-family: "LINE Seed JP", sans-serif; font-variant-numeric: tabular-nums; }
.quote-parties { display: grid; grid-template-columns: 1.2fr .8fr; gap: 42px; min-height: 150px; padding: 28px 0; }
.quote-label { margin: 0 0 8px !important; color: var(--muted); font-size: 9px !important; font-weight: 700; letter-spacing: .1em; }
.quote-parties h3 { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--ink); font-size: 19px; }
.quote-parties p { margin: 5px 0; white-space: pre-line; font-size: 11px; }
.recipient-name { font-weight: 700; }
.issuer-block { padding-left: 18px; border-left: 1px solid var(--line); }
.quote-total-band { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 20px; color: white; background: var(--ink); }
.quote-total-band span { font-size: 12px; }
.quote-total-band strong { font: 700 25px/1 "LINE Seed JP", sans-serif; font-variant-numeric: tabular-nums; }
.quote-table { width: 100%; margin-top: 28px; border-collapse: collapse; table-layout: fixed; font-size: 10px; }
.quote-table th { padding: 10px 8px; color: var(--muted); border-bottom: 1px solid var(--ink); text-align: right; font-size: 9px; }
.quote-table th:first-child { width: 42%; text-align: left; }
.quote-table td { padding: 12px 8px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.quote-table td:first-child { text-align: left; font-weight: 700; }
.quote-summary { width: 48%; margin: 18px 0 0 auto; }
.quote-summary > div { display: flex; justify-content: space-between; padding: 6px 8px; font-size: 10px; }
.quote-summary > div:last-child { margin-top: 5px; padding-top: 10px; border-top: 2px solid var(--ink); font-size: 13px; }
.quote-summary span:last-child, .quote-summary strong { font-family: "LINE Seed JP", sans-serif; font-variant-numeric: tabular-nums; }
.quote-sheet-footer { position: absolute; right: 17mm; bottom: 12mm; left: 17mm; display: flex; align-items: end; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); }
.quote-sheet-footer p { max-width: 145mm; margin: 3px 0; white-space: pre-line; font-size: 9px; }
.quote-sheet-footer small { color: var(--muted); font: 9px/1 "LINE Seed JP", sans-serif; font-variant-numeric: tabular-nums; }
.quote-sheet.is-dense { height: 297mm; min-height: 297mm; padding: 11mm 14mm 9mm; }
.quote-sheet.is-dense .quote-masthead { padding-bottom: 12px; }
.quote-sheet.is-dense .quote-masthead h2 { font-size: 27px; }
.quote-sheet.is-dense .quote-parties { min-height: 104px; padding: 15px 0; }
.quote-sheet.is-dense .quote-total-band { padding: 11px 16px; }
.quote-sheet.is-dense .quote-table { margin-top: 14px; font-size: 8px; }
.quote-sheet.is-dense .quote-table th { padding: 6px; font-size: 8px; }
.quote-sheet.is-dense .quote-table td { padding: 6px; }
.quote-sheet.is-dense .quote-summary { margin-top: 8px; }
.quote-sheet.is-dense .quote-summary > div { padding: 3px 6px; font-size: 8px; }
.quote-sheet.is-dense .quote-summary > div:last-child { margin-top: 2px; padding-top: 6px; font-size: 11px; }
.quote-sheet.is-dense .quote-sheet-footer { right: 14mm; bottom: 7mm; left: 14mm; padding-top: 7px; }
.app-footer { padding: 28px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; font: 10px/1 "LINE Seed JP", sans-serif; letter-spacing: .12em; }

@media (max-width: 860px) {
  .page-heading { grid-template-columns: 1fr; gap: 22px; }
  .progress { max-width: 420px; }
  .three-columns, .two-columns { grid-template-columns: 1fr 1fr; }
  .field.wide { grid-column: 1 / -1; }
  .item-list { grid-template-columns: 1fr; }
  .form-total { position: static; grid-template-columns: 1fr 1fr 1fr; }
  .form-total .primary-button { grid-column: span 2; }
  .quote-toolbar { grid-template-columns: 1fr auto; }
  .quote-progress { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 600px) {
  .workspace { width: min(100% - 24px, 1180px); padding-top: 38px; }
  .page-heading h1 { font-size: 30px; }
  .form-section { padding: 22px 18px; }
  .section-heading { gap: 12px; }
  .section-heading > span { width: 40px; height: 40px; }
  .section-lead { margin-left: 0; }
  .three-columns, .two-columns, .choice-row { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .item-details { grid-template-columns: 1fr; }
  .form-total { grid-template-columns: 1fr 1fr; gap: 16px; }
  .form-total .grand { grid-column: 1 / -1; }
  .form-total .primary-button, .form-total .text-button { grid-column: 1 / -1; }
  .quote-toolbar { display: flex; align-items: stretch; flex-direction: column; gap: 18px; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .quote-view { padding-inline: 8px; }
  .quote-sheet { min-height: 0; padding: 28px 20px 90px; }
  .quote-sheet.is-dense { height: auto; min-height: 0; padding: 28px 20px 90px; overflow: visible; }
  .quote-masthead, .quote-parties { grid-template-columns: 1fr; }
  .quote-parties { gap: 20px; }
  .issuer-block { padding: 18px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .quote-table { font-size: 8px; }
  .quote-table th, .quote-table td { padding-inline: 4px; }
  .quote-summary { width: 100%; }
  .quote-sheet-footer { right: 20px; bottom: 20px; left: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@page { size: A4 portrait; margin: 0; }
@media print {
  html, body { width: 210mm; margin: 0; background: #fff; }
  .no-print, #form-view { display: none !important; }
  #quote-view { display: block !important; padding: 0; }
  .quote-pages { display: block; }
  .quote-sheet { width: 210mm; min-height: 297mm; margin: 0; box-shadow: none; break-after: page; page-break-after: always; }
  .quote-sheet:last-child { break-after: auto; page-break-after: auto; }
}
