:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #64717f;
  --line: #d9e1e7;
  --accent: #176b87;
  --accent-dark: #0f5269;
  --gold: #b68a18;
  --soft: #e8f4f7;
  --danger: #a2422f;
  --danger-soft: #fff7f5;
  --shadow: 0 14px 36px rgba(23, 33, 43, 0.08);
  --paper-shadow: 0 18px 50px rgba(23, 33, 43, 0.16);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 0;
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Meiryo", "Yu Gothic UI", "Yu Gothic", sans-serif;
  font-feature-settings: "palt";
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
  font-family: inherit;
}

button,
label[for],
summary {
  cursor: pointer;
}

button,
.file-button {
  transition: transform 220ms var(--ease-spring), border-color 220ms var(--ease), background-color 220ms var(--ease), color 220ms var(--ease), box-shadow 220ms var(--ease);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

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

h1,
h2,
h3,
p,
dl {
  margin-top: 0;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.35;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.header-actions,
.preview-toolbar-actions,
.row-add-actions,
.data-actions > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.primary-button,
.ghost-button,
.danger-button,
.text-button,
.file-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 16px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.ghost-button,
.file-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover:not(:disabled),
.file-button:hover {
  border-color: #9ccada;
  color: var(--accent-dark);
  transform: translateY(-1px);
}

.danger-button {
  background: #fff;
  border-color: #d9b2aa;
  color: var(--danger);
}

.danger-button:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: #bc6f60;
}

.text-button {
  min-height: 36px;
  padding: 6px 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.small-button {
  min-height: 38px;
  padding: 7px 12px;
  font-size: 13px;
}

.privacy-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 24px;
  background: var(--soft);
  border-bottom: 1px solid rgba(23, 107, 135, 0.18);
  color: var(--accent-dark);
  font-size: 13px;
}

.privacy-banner > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.privacy-banner strong {
  white-space: nowrap;
}

.privacy-banner details {
  position: relative;
  flex: 0 0 auto;
}

.privacy-banner summary {
  font-weight: 800;
}

.privacy-banner details p {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: min(420px, calc(100vw - 32px));
  margin: 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  line-height: 1.65;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(540px, 3fr) minmax(450px, 2fr);
  min-width: 0;
  align-items: start;
}

.editor-pane {
  display: grid;
  min-width: 0;
  gap: 16px;
  padding: 28px clamp(18px, 2.4vw, 36px) 64px;
}

.editor-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.editor-heading h1 {
  margin-bottom: 8px;
  font-size: clamp(26px, 2.5vw, 38px);
  line-height: 1.2;
}

.editor-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.save-state {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #edf4f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.save-state.is-saved,
.save-state[data-state="saved"] {
  background: #edf7f1;
  color: #276b45;
}

.save-state.is-error,
.save-state[data-state="error"] {
  background: var(--danger-soft);
  color: var(--danger);
}

.validation-summary {
  padding: 14px 16px;
  background: #fff8e8;
  border: 1px solid #e8ca82;
  border-radius: 8px;
  color: #72540b;
}

.validation-summary strong {
  display: block;
  margin-bottom: 4px;
}

.validation-summary ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

.editor-card,
.data-actions {
  min-width: 0;
  margin: 0;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor-card legend {
  max-width: calc(100% - 16px);
  padding: 0 8px;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
}

.editor-card legend span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  margin-right: 6px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}

.form-grid {
  display: grid;
  min-width: 0;
  gap: 14px;
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span,
.inline-field > span {
  min-width: 0;
}

.field em {
  color: var(--danger);
  font-size: 11px;
  font-style: normal;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #9aa6b1;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.file-button:focus-within,
summary:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--soft);
  outline-offset: 1px;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"],
.is-invalid {
  border-color: var(--danger);
}

.template-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.compact-field {
  width: min(100%, 340px);
}

.helper-text {
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.rows-editor {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.row-card,
.item-row,
.section-row,
.item-editor,
.section-editor {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.row-card,
.item-editor,
.section-editor {
  padding: 12px;
}

.row-card:focus-within,
.item-editor:focus-within,
.section-editor:focus-within {
  border-color: #9ccada;
  box-shadow: 0 0 0 3px rgba(232, 244, 247, 0.9);
}

.row-main,
.row-header,
.section-row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.row-fields,
.item-fields {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(150px, 2fr) minmax(120px, 1.35fr) minmax(90px, 0.8fr) 84px 78px 112px 82px 112px;
  gap: 8px;
  align-items: end;
}

.row-fields label,
.item-fields label,
.row-label {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.row-amount {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  min-width: 0;
  max-width: 100%;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
}

.row-actions button,
.icon-button {
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
}

.row-actions button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  border-color: #9ccada;
  color: var(--accent-dark);
}

.row-actions .delete-button:hover:not(:disabled),
.icon-button.delete-button:hover:not(:disabled),
[data-action="delete"]:hover:not(:disabled) {
  border-color: #d9b2aa;
  background: var(--danger-soft);
  color: var(--danger);
}

.section-row,
.section-editor {
  background: var(--soft);
  border-color: rgba(23, 107, 135, 0.22);
}

.section-row input,
.section-editor input {
  font-weight: 800;
}

.row-add-actions {
  margin-top: 12px;
}

.notice-box {
  margin-bottom: 14px;
  padding: 14px;
  background: #fffaf0;
  border: 1px solid rgba(182, 138, 24, 0.32);
  border-radius: 8px;
}

.notice-box strong {
  color: #72540b;
}

.notice-box p {
  margin: 4px 0 0;
  color: #6f6550;
  font-size: 13px;
}

.additions-editor {
  display: grid;
  gap: 8px;
}

.addition-row {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(150px, 1.2fr) minmax(110px, 0.85fr) minmax(104px, 0.75fr) minmax(130px, 0.9fr) minmax(150px, 1fr);
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.toggle-field {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.toggle-field input[type="checkbox"] {
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.base-label {
  display: flex;
  min-height: 44px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.inline-field {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.inline-field > span {
  grid-column: 1 / -1;
}

.inline-field b {
  color: var(--muted);
  font-weight: 700;
}

.discount-box {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(200px, 2fr) minmax(150px, 1fr) minmax(120px, 0.8fr);
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid rgba(23, 107, 135, 0.22);
  border-radius: 8px;
}

.discount-box p {
  align-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.rounding-grid {
  margin-top: 14px;
}

.image-field input[type="file"] {
  padding: 7px;
  font-size: 12px;
}

.image-field input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.data-actions h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.data-actions p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.preview-pane {
  position: sticky;
  top: 70px;
  display: flex;
  min-width: 0;
  height: calc(100vh - 70px);
  height: calc(100dvh - 70px);
  flex-direction: column;
  overflow: hidden;
  background: #e9eef1;
  border-left: 1px solid var(--line);
}

.preview-toolbar {
  position: relative;
  z-index: 3;
  display: flex;
  min-height: 62px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.preview-toolbar strong,
.preview-toolbar span {
  display: block;
}

.preview-toolbar span {
  color: var(--muted);
  font-size: 11px;
}

.design-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.design-picker span {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.design-picker select {
  min-height: 36px;
  max-width: 146px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 28px 6px 9px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.paper-wrap {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  justify-content: center;
  overflow: auto;
  padding: 20px;
  overscroll-behavior: contain;
}

.quote-paper {
  position: relative;
  width: 210mm;
  min-width: 210mm;
  min-height: 297mm;
  align-self: flex-start;
  padding: 12mm;
  transform: scale(var(--paper-scale, 1));
  transform-origin: top center;
  background: #fff;
  box-shadow: var(--paper-shadow);
  color: #17212b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Meiryo", "Yu Gothic UI", "Yu Gothic", sans-serif;
  font-feature-settings: "palt";
  font-size: 9.5pt;
  line-height: 1.45;
}

/* 帳票デザインの差分は印刷対象の紙面だけへ適用する。 */
.quote-paper[data-design="formal"] {
  color: #202a33;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

.quote-paper[data-design="formal"] .quote-title-block > p {
  color: #202a33;
  letter-spacing: 0.16em;
}

.quote-paper[data-design="formal"] .quote-title-block h2,
.quote-paper[data-design="formal"] .grand-total-box {
  border-color: #202a33;
}

.quote-paper[data-design="formal"] .preview-muted,
.quote-paper[data-design="formal"] .quote-meta-list dt,
.quote-paper[data-design="formal"] .project-meta dt {
  color: #58636d;
}

.quote-paper[data-design="formal"] .project-meta,
.quote-paper[data-design="formal"] .project-meta div {
  border-color: #89929a;
}

.quote-paper[data-design="formal"] .project-meta dt,
.quote-paper[data-design="formal"] .quote-table th {
  background: #eceff1;
}

.quote-paper[data-design="formal"] .quote-table th,
.quote-paper[data-design="formal"] .quote-table td {
  border-color: #7d8790;
}

.quote-paper[data-design="formal"] .quote-table .section-line td,
.quote-paper[data-design="formal"] .quote-table .section-row td,
.quote-paper[data-design="formal"] .quote-table tr.is-section td {
  background: #e6e9eb;
  color: #202a33;
}

.quote-paper[data-design="formal"] .breakdown-card,
.quote-paper[data-design="formal"] .notes-block {
  background: #fafafa;
  border-color: #a9b0b6;
}

.quote-paper[data-design="formal"] .totals-card dl div:last-child {
  border-color: #202a33;
}

.quote-paper[data-design="construction"] {
  color: #3b2a1d;
}

.quote-paper[data-design="construction"] .quote-title-block > p {
  color: #a25b17;
  letter-spacing: 0.18em;
}

.quote-paper[data-design="construction"] .quote-title-block h2,
.quote-paper[data-design="construction"] .grand-total-box {
  border-color: #a25b17;
}

.quote-paper[data-design="construction"] .quote-meta-list dt,
.quote-paper[data-design="construction"] .project-meta dt {
  color: #7c5a3b;
}

.quote-paper[data-design="construction"] .project-meta,
.quote-paper[data-design="construction"] .project-meta div {
  border-color: #c69a6d;
}

.quote-paper[data-design="construction"] .project-meta dt,
.quote-paper[data-design="construction"] .quote-table th {
  background: #fff1df;
}

.quote-paper[data-design="construction"] .quote-table th,
.quote-paper[data-design="construction"] .quote-table td {
  border-color: #b88655;
}

.quote-paper[data-design="construction"] .quote-table .section-line td,
.quote-paper[data-design="construction"] .quote-table .section-row td,
.quote-paper[data-design="construction"] .quote-table tr.is-section td {
  background: #ffe8c7;
  color: #87470d;
}

.quote-paper[data-design="construction"] .grand-total-box strong {
  color: #87470d;
}

.quote-paper[data-design="construction"] .breakdown-card,
.quote-paper[data-design="construction"] .notes-block {
  background: #fffaf4;
  border-color: #d7b084;
}

.quote-paper[data-design="construction"] .totals-card dl div:last-child {
  border-color: #a25b17;
}

.quote-paper h2,
.quote-paper h3,
.quote-paper p,
.quote-paper dl {
  margin-top: 0;
}

.quote-header {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(64mm, 0.82fr);
  gap: 10mm;
  align-items: start;
  min-height: 45mm;
}

.quote-title-block > p {
  margin-bottom: 8mm;
  font-size: 20pt;
  font-weight: 800;
  letter-spacing: 0.22em;
  line-height: 1.2;
  text-align: center;
}

.quote-title-block h2 {
  min-height: 10mm;
  margin: 0;
  padding: 0 2mm 2mm;
  border-bottom: 1px solid #17212b;
  font-size: 14pt;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.preview-muted {
  color: #4f5d69;
}

.quote-title-block .preview-muted {
  padding: 2mm;
  font-size: 8.5pt;
}

.issuer-block {
  position: relative;
  min-height: 40mm;
  padding-top: 3mm;
  padding-right: 20mm;
  overflow-wrap: anywhere;
  font-size: 8.5pt;
}

.issuer-block strong {
  display: block;
  margin-bottom: 1.5mm;
  font-size: 11pt;
}

.issuer-block p {
  margin-bottom: 0.5mm;
}

.preview-logo {
  display: block;
  max-width: 45mm;
  max-height: 14mm;
  margin-bottom: 2mm;
  object-fit: contain;
  object-position: left center;
}

.preview-seal {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18mm;
  height: 18mm;
  object-fit: contain;
}

.multiline {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.quote-overview {
  margin-top: 4mm;
}

.quote-meta-list {
  display: flex;
  justify-content: flex-end;
  gap: 5mm;
  margin: 0 0 4mm;
}

.quote-meta-list div {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2mm;
}

.quote-meta-list dt,
.project-meta dt {
  color: #50606c;
  font-weight: 700;
}

.quote-meta-list dd,
.project-meta dd {
  margin: 0;
}

.quote-greeting {
  margin-bottom: 3mm;
}

.project-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 4mm;
  border-top: 1px solid #9aa6b1;
  border-left: 1px solid #9aa6b1;
}

.project-meta div {
  display: grid;
  grid-template-columns: 20mm minmax(0, 1fr);
  min-height: 7mm;
  border-right: 1px solid #9aa6b1;
  border-bottom: 1px solid #9aa6b1;
}

.project-meta dt,
.project-meta dd {
  padding: 1.5mm 2mm;
}

.project-meta dt {
  background: #f1f4f6;
}

.project-meta dd {
  overflow-wrap: anywhere;
}

.grand-total-box {
  display: flex;
  min-height: 14mm;
  align-items: center;
  justify-content: space-between;
  gap: 8mm;
  padding: 2mm 4mm;
  border-top: 2px solid var(--accent-dark);
  border-bottom: 2px solid var(--accent-dark);
}

.grand-total-box span {
  font-size: 10pt;
  font-weight: 700;
}

.grand-total-box strong {
  font-size: 19pt;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.quote-detail {
  margin-top: 7mm;
}

.quote-detail h3,
.quote-summary h3,
.notes-block h3 {
  margin-bottom: 2mm;
  font-size: 10pt;
}

.quote-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 8pt;
}

.quote-table th,
.quote-table td {
  min-width: 0;
  padding: 1.4mm 1.2mm;
  border: 1px solid #8997a2;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.quote-table th {
  background: #edf2f4;
  font-weight: 800;
  text-align: center;
}

.quote-table .col-no {
  width: 8mm;
}

.quote-table .col-num {
  width: 13mm;
}

.quote-table .col-money {
  width: 21mm;
}

.quote-table th:nth-child(3) {
  width: 17mm;
}

.quote-table th:nth-child(5) {
  width: 12mm;
}

.quote-table th:nth-child(7) {
  width: 10mm;
}

.quote-table td:nth-child(1),
.quote-table td:nth-child(3),
.quote-table td:nth-child(4),
.quote-table td:nth-child(5),
.quote-table td:nth-child(7) {
  text-align: center;
}

.quote-table td:nth-child(6),
.quote-table td:nth-child(8) {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.quote-table .section-line td,
.quote-table .section-row td,
.quote-table tr.is-section td {
  padding: 1.5mm 2mm;
  background: #e8f4f7;
  color: var(--accent-dark);
  font-weight: 800;
  text-align: left;
}

.quote-table .item-spec,
.quote-table small {
  display: block;
  color: #566572;
  font-size: 7.3pt;
}

.quote-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68mm;
  gap: 8mm;
  align-items: start;
  margin-top: 6mm;
}

.breakdown-card {
  padding: 3mm;
  background: #f8fafb;
  border: 1px solid #c6d0d7;
}

.breakdown-card dl,
.totals-card dl {
  margin: 0;
}

.breakdown-card dl div,
.totals-card dl div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4mm;
  padding: 1.2mm 0;
  border-bottom: 1px solid #dde3e7;
}

.breakdown-card dl div:last-child,
.totals-card dl div:last-child {
  border-bottom: 0;
}

.breakdown-card dt,
.totals-card dt {
  min-width: 0;
}

.breakdown-card dd,
.totals-card dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.breakdown-card .breakdown-note,
.breakdown-card p {
  margin: 2mm 0 0;
  color: #566572;
  font-size: 7.2pt;
}

.totals-card {
  font-size: 8.5pt;
}

.totals-card .total-row,
.totals-card dl div:last-child {
  margin-top: 1mm;
  padding-top: 2mm;
  border-top: 2px solid #17212b;
  font-size: 11pt;
  font-weight: 800;
}

.totals-card .discount-row {
  color: var(--danger);
}

.notes-block {
  margin-top: 7mm;
  padding: 3mm;
  border: 1px solid #c6d0d7;
}

.notes-block p {
  min-height: 14mm;
  margin-bottom: 0;
  font-size: 8pt;
}

.quote-footer {
  margin-top: 6mm;
  padding-top: 2mm;
  border-top: 1px solid #d5dde2;
  color: #65737f;
  font-size: 6.8pt;
  text-align: center;
}

.quote-footer p {
  margin-bottom: 0.5mm;
}

.mobile-action-bar {
  display: none;
}

.mobile-only {
  display: none;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  max-width: min(420px, calc(100vw - 32px));
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #17212b;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(23, 33, 43, 0.24);
  color: #fff;
  font-size: 13px;
}

.toast button {
  min-height: 36px;
  margin-left: auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  padding: 6px 10px;
  background: transparent;
  color: #fff;
  font-weight: 800;
}

@media (max-width: 1240px) and (min-width: 901px) {
  .app-shell {
    grid-template-columns: minmax(0, 1.2fr) minmax(390px, 0.8fr);
  }

  .editor-pane {
    padding-right: 20px;
    padding-left: 20px;
  }

  .row-fields,
  .item-fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .row-fields > :first-child,
  .item-fields > :first-child {
    grid-column: span 2;
  }

  .addition-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .addition-row .toggle-field,
  .addition-row .base-label {
    grid-column: span 1;
  }

  .discount-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  html {
    scroll-padding-bottom: 104px;
  }

  body.preview-open,
  body.is-preview-open {
    overflow: hidden;
  }

  .site-header {
    min-height: 62px;
    padding: 10px 14px;
  }

  .header-actions {
    display: none;
  }

  .privacy-banner {
    display: block;
    padding: 10px 14px;
  }

  .privacy-banner > div {
    display: grid;
    gap: 1px;
  }

  .privacy-banner details {
    margin-top: 4px;
  }

  .privacy-banner details p {
    position: static;
    width: auto;
    margin-top: 8px;
    box-shadow: none;
  }

  .app-shell {
    display: block;
  }

  .editor-pane {
    gap: 12px;
    padding: 20px 14px 118px;
  }

  .editor-heading {
    display: grid;
    gap: 10px;
  }

  .editor-heading h1 {
    font-size: 27px;
  }

  .save-state {
    width: max-content;
  }

  .editor-card,
  .data-actions {
    padding: 16px 14px;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  input,
  select,
  textarea,
  button,
  .file-button {
    font-size: 16px;
  }

  .field,
  .inline-field,
  .row-fields label,
  .item-fields label,
  .row-label {
    font-size: 13px;
  }

  .template-bar,
  .row-add-actions,
  .data-actions > div {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .compact-field {
    width: 100%;
  }

  .row-card,
  .item-editor,
  .section-editor {
    padding: 12px 10px;
  }

  .row-main,
  .row-header,
  .section-row-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .row-fields,
  .item-fields {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .row-fields > :first-child,
  .item-fields > :first-child,
  .row-fields > :nth-child(2),
  .item-fields > :nth-child(2) {
    grid-column: 1 / -1;
  }

  .row-amount {
    justify-content: flex-start;
  }

  .addition-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 10px;
  }

  .addition-row .toggle-field,
  .addition-row .base-label {
    grid-column: span 1;
  }

  .addition-row > span:empty {
    display: none;
  }

  .discount-box {
    grid-template-columns: 1fr 1fr;
  }

  .discount-box p {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .preview-pane {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-left: 0;
  }

  .preview-pane.is-mobile-open,
  .preview-pane.is-open,
  .preview-pane[data-open="true"],
  body.preview-open .preview-pane,
  body.is-preview-open .preview-pane {
    display: flex;
  }

  .preview-toolbar {
    min-height: 64px;
    padding: 9px 12px;
  }

  .preview-toolbar .primary-button {
    padding-right: 10px;
    padding-left: 10px;
  }

  .mobile-only {
    display: inline-flex;
  }

  .paper-wrap {
    justify-content: center;
    padding: 14px;
  }

  .mobile-action-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 28px rgba(23, 33, 43, 0.1);
    backdrop-filter: blur(10px);
  }

  .mobile-action-bar > div {
    display: grid;
    min-width: 0;
    line-height: 1.25;
  }

  .mobile-action-bar span,
  .mobile-action-bar small {
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-action-bar strong {
    overflow: hidden;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-action-bar button {
    min-height: 48px;
    padding: 8px 11px;
    font-size: 13px;
  }

  .toast {
    right: 12px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    left: 12px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand strong {
    font-size: 15px;
  }

  .editor-pane {
    padding-right: 10px;
    padding-left: 10px;
  }

  .editor-card,
  .data-actions {
    padding-right: 10px;
    padding-left: 10px;
  }

  .addition-row,
  .discount-box {
    grid-template-columns: 1fr;
  }

  .addition-row .toggle-field,
  .addition-row .base-label,
  .discount-box p {
    grid-column: auto;
    grid-row: auto;
  }

  .base-label {
    min-height: 28px;
  }

  .row-fields,
  .item-fields {
    grid-template-columns: 1fr;
  }

  .row-main,
  .row-header,
  .section-row-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .row-fields > *,
  .item-fields > * {
    grid-column: auto !important;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .mobile-action-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 5px;
  }

  .mobile-action-bar button {
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
    font-size: 12px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  html,
  body {
    width: auto;
    min-width: 0;
    height: auto;
    margin: 0;
    overflow: visible;
    background: #fff;
    color: #000;
  }

  .no-print,
  .site-header,
  .privacy-banner,
  .editor-pane,
  .preview-toolbar,
  .mobile-action-bar,
  .toast {
    display: none !important;
  }

  .app-shell,
  .preview-pane,
  .paper-wrap {
    position: static;
    display: block !important;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: #fff;
    border: 0;
  }

  .quote-paper {
    width: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    transform: none !important;
    background: #fff;
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .quote-table {
    page-break-inside: auto;
  }

  .quote-table thead {
    display: table-header-group;
  }

  .quote-table tfoot {
    display: table-footer-group;
  }

  .quote-table tr,
  .quote-table th,
  .quote-table td,
  .quote-summary,
  .breakdown-card,
  .totals-card,
  .notes-block,
  .quote-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .quote-footer {
    break-before: avoid;
    page-break-before: avoid;
  }
}

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