﻿/* ================================================================
   PAGE 1 — アップロード画面
   ================================================================ */

.upload-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 3.5rem 2rem;
}

@media screen and (max-width: 600px) {
  .upload-wrap {
    padding: 2rem 1.2rem;
  }
}

.upload-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  line-height: 1.4;
  color: var(--heading);
}

@media screen and (max-width: 600px) {
  .upload-title {
    font-size: 26px;
  }
}

.upload-sub {
  font-size: 17px;
  color: var(--muted);
  margin-bottom: 2.5rem;
  line-height: 1.8;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone.error {
  border-color: var(--danger);
  background: #FEF0EF;
  animation: shake 0.4s;
}

.drop-zone.loaded {
  border-style: solid;
  border-color: var(--accent-mid);
  background: var(--accent-light);
}

@media screen and (max-width: 600px) {
  .drop-zone {
    padding: 2rem 1rem;
  }
}

.format-error-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: #FEF0EF;
  color: var(--danger);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  display: none;
}

.drop-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  background: var(--bg);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-icon-svg {
  width: 32px;
  height: 32px;
  stroke: var(--muted);
}

.drop-title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 10px;
}

.drop-title-br {
  display: none;
}

@media screen and (max-width: 600px) {
  .drop-title-br {
    display: block;
  }
}

.drop-sub {
  font-size: 15px;
  color: var(--muted);
}

.file-selected {
  margin-top: 16px;
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-size: 14px;
  color: var(--accent-mid);
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--accent-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
  animation: pop-in 0.25s ease-out;
  box-sizing: border-box;
}

.file-selected[hidden] {
  display: none !important;
}

.file-selected-name {
  flex: 1;
  min-width: 0;
  text-align: left;
  line-height: 1.5;
  word-break: break-word;
  white-space: normal;
}

.file-selected-clear {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.file-selected-clear:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--danger);
}

.file-selected .ok-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--accent-mid);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

/* CTA ボタン（くん色・濃 専用） */
.btn-primary {
  width: 100%;
  margin-top: 24px;
  padding: 20px;
  background: var(--cta);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s;
  font-family: inherit;
}

.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-primary:not(:disabled):hover {
  background: var(--cta-hover);
}

.reading-state {
  text-align: center;
  padding: 1.5rem;
  display: none;
}

.reading-state-text {
  font-size: 17px;
  color: var(--muted);
  margin-top: 14px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

.myformat-banner {
  padding: 20px 24px;
  margin-bottom: 28px;
  background: #FFFBF3;
  border: 2px solid var(--cta-badge);
  border-radius: var(--radius-lg);
  text-align: center;
}

.myformat-banner-checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.myformat-status-item {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
}

@media screen and (max-width: 600px) {
  .myformat-status-item {
    font-size: 15px;
  }
}

.myformat-status-item--done {
  background: #ECFDF3;
  border: 1px solid var(--success);
  color: #166534;
  font-weight: 500;
}

.myformat-status-item--pending {
  background: #FFF8EB;
  border: 1px solid var(--cta-badge);
  color: #7A4A10;
}

.myformat-banner-hint {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

@media screen and (max-width: 600px) {
  .myformat-banner-hint {
    font-size: 15px;
  }
}

.myformat-banner-btn {
  display: inline-block;
  padding: 12px 28px;
  background: var(--cta);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.myformat-banner-btn:hover {
  background: var(--cta-hover);
}

/* ================================================================
   PAGE 2 — 読み取り結果確認
   ================================================================ */

.review-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 60px);
}

.review-step-guide {
  margin-bottom: 0;
}

.review-step-guide--mobile {
  display: none;
}

.review-mobile-bar,
.margin-mobile-bar {
  display: none;
}

.review-mobile-bar[hidden],
.margin-mobile-bar[hidden] {
  display: none !important;
}

@media screen and (max-width: 900px) {
  .review-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    box-sizing: border-box;
    overflow: hidden;
  }

  #page-review .review-layout {
    padding-bottom: 0;
  }

  #page-review .review-layout.review-mobile--pdf {
    height: calc(100vh - 60px - var(--mobile-bar-h));
    height: calc(100dvh - 60px - var(--mobile-bar-h));
  }

  #page-review .edit-panel > .edit-header,
  .workflow-header-band .workflow-header {
    padding: 4px 16px;
  }

  .workflow-header-band {
    --workflow-sticky-h: 48px;
  }

  .workflow-header-band .workflow-header {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    z-index: 90;
    box-sizing: border-box;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    min-height: var(--workflow-sticky-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  .workflow-header-band .workflow-header-title {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--heading);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .workflow-header-band-inner {
    padding-top: var(--workflow-sticky-h);
  }

  #margin-mobile-bar:not([hidden]) {
    display: flex !important;
    flex-direction: column;
    gap: 4px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    padding: 4px 8px calc(4px + var(--safe-bottom));
    height: calc(var(--margin-mobile-bar-h) + var(--safe-bottom));
    max-height: calc(var(--margin-mobile-bar-h) + var(--safe-bottom));
    box-sizing: border-box;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  #margin-mobile-bar .margin-mobile-bar-title {
    margin: 0;
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.04em;
    color: var(--accent);
    text-align: center;
  }

  #margin-mobile-bar .margin-mobile-bar-toggles {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    flex: 1 1 auto;
    min-height: 0;
    gap: 6px;
    width: 100%;
  }

  #margin-mobile-bar .margin-preview-toggle {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 4px 6px !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
    min-height: 0 !important;
    height: auto !important;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
  }

  #margin-mobile-bar .margin-preview-toggle.is-active {
    background: #C0392B;
    border-color: #C0392B;
    color: #fff;
    font-weight: 700;
  }

  #page-review .page-sub--review {
    display: none;
  }

  #page-review .edit-header-title,
  .workflow-header-title {
    font-size: 14px;
  }

  #page-review .edit-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #page-review .review-step-guide {
    flex: 0 0 auto;
    padding: 12px 20px 0;
    margin: 0;
  }

  #page-review .review-step-guide--desktop {
    display: none;
  }

  #page-review .edit-body .review-step-guide--mobile {
    display: block;
    padding: 0;
    margin: 0 0 12px;
  }

  #page-review .edit-body {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 20px calc(20px + var(--mobile-bar-h));
  }

  #page-review .edit-footer {
    position: static;
    padding: 20px 0 0;
    background: transparent;
    border-top: none;
  }

  #page-review .edit-footer .btn-confirm {
    margin-bottom: var(--safe-bottom);
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
  }

  #page-review .review-pdf-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  #page-review .review-layout.review-mobile--pdf .edit-panel {
    flex: 0 0 auto;
  }

  #page-review .review-layout.review-mobile--pdf .review-pdf-panel {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  #page-review .review-layout.review-mobile--pdf .edit-body {
    display: none !important;
  }

  #page-review .review-layout.review-mobile--pdf #pdf-viewport {
    padding: 12px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #page-review .review-layout.review-mobile--pdf .pdf-canvas-stage.is-touch-zoomed {
    will-change: transform;
  }

  .review-mobile-bar:not([hidden]) {
    display: flex;
    align-items: stretch;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    min-height: var(--mobile-bar-h);
    padding: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  .review-mobile-bar-btn {
    flex: 1;
    width: 100%;
    min-height: var(--mobile-bar-h);
    margin: 0;
    padding: 0 12px;
    border: none;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
  }

  .review-mobile-bar-btn.is-active {
    background: #C0392B;
    color: #fff;
  }

  .review-mobile-bar-btn:not(.is-active):active {
    background: #dce8f4;
  }

  #page-margin.page-margin--preview-open #margin-workflow-header-band {
    display: none;
  }

  #page-margin .margin-work-preview .margin-preview-toggles {
    display: none;
  }

  #page-margin .margin-layout {
    padding-bottom: calc(var(--margin-mobile-bar-h) + var(--safe-bottom));
    box-sizing: border-box;
  }

  #page-basic .basic-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    box-sizing: border-box;
    overflow: hidden;
  }

  #page-basic .basic-layout.basic-mobile--pdf {
    height: calc(100vh - 60px - var(--mobile-bar-h));
    height: calc(100dvh - 60px - var(--mobile-bar-h));
  }

  #page-basic .basic-form-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #page-basic .basic-wrap {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1.25rem 1.5rem calc(4rem + var(--mobile-bar-h));
    max-width: none;
    margin: 0;
  }

  #page-basic .basic-pdf-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  #page-basic .basic-layout.basic-mobile--pdf .basic-form-panel {
    flex: 0 0 auto;
  }

  #page-basic .basic-layout.basic-mobile--pdf .basic-pdf-panel {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  #page-basic .basic-layout.basic-mobile--pdf .basic-wrap {
    display: none !important;
  }

  #page-basic .basic-layout.basic-mobile--pdf #basic-pdf-viewport {
    padding: 12px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #page-basic .basic-layout.basic-mobile--pdf #basic-pdf-canvas-stage.is-touch-zoomed {
    will-change: transform;
  }
}

@media screen and (min-width: 901px) {
  #page-review .review-step-guide {
    padding: 16px 24px 0;
    margin: 0;
  }

  #page-review .edit-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    margin: 16px -24px -20px;
  }
}

.edit-panel {
  background: var(--bg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.edit-header,
.workflow-header {
  background: transparent;
  border-bottom: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: static;
  top: auto;
  z-index: auto;
}

.workflow-header-band {
  position: static;
  top: auto;
  z-index: auto;
  background: transparent;
  border-bottom: none;
}

.workflow-header-band-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
}

.workflow-header-band .workflow-header {
  position: sticky;
  top: 60px;
  z-index: 90;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding: 16px 24px;
  box-sizing: border-box;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.workflow-page-intro {
  margin-bottom: 0;
}

.workflow-page-intro .page-title {
  margin-bottom: 6px;
}

.workflow-page-intro .page-sub {
  margin: 0 0 1.5rem;
}

#page-review .edit-panel > .edit-header {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding: 16px 24px;
  box-sizing: border-box;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

#page-review .page-sub--review {
  margin: 0 0 12px;
  padding: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.edit-panel .edit-header,
.margin-edit-panel > .workflow-header {
  top: auto;
}

.edit-header-title,
.workflow-header-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: var(--heading);
  line-height: 1.35;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-header-band .workflow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.step-pills {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.step-pill {
  height: 6px;
  width: 24px;
  border-radius: 3px;
  background: var(--border);
}

.step-pill.active {
  background: var(--accent);
}

.step-pill.step-pill--done {
  background: var(--accent);
  opacity: 0.35;
}

.step-pill.step-pill--complete.active {
  background: #22A06B;
  opacity: 1;
}

@media screen and (max-width: 468px) {
  .step-pill {
    width: 18px;
  }
}

.edit-body {
  padding: 20px 24px;
  flex: 1;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.section-label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  font-weight: 500;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

@media screen and (min-width: 801px) {
  .field-grid--quote {
    grid-template-areas:
      "client date"
      "subject valid"
      "subject quoteno";
  }

  .field-grid--quote .field-group:nth-child(1) { grid-area: client; }
  .field-grid--quote .field-group:nth-child(2) { grid-area: date; }
  .field-grid--quote .field-group:nth-child(3) { grid-area: subject; }
  .field-grid--quote .field-group:nth-child(4) { grid-area: valid; }
  .field-grid--quote .field-group--quoteno { grid-area: quoteno; }
}

@media screen and (max-width: 800px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-grid--quote {
    grid-template-areas: none;
  }
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group-label {
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
}

.review-field-input {
  height: 42px;
  padding: 0 12px;
  font-size: 15px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  width: 100%;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.review-field-input:focus {
  border-color: var(--accent);
  background: #fff;
}

.review-field-input.is-readonly {
  color: var(--accent);
  background: var(--accent-light);
  border-color: transparent;
}

.review-field-textarea {
  height: auto;
  min-height: 42px;
  padding: 8px 12px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
}

.review-field-textarea--subject {
  box-sizing: border-box;
  width: 100%;
  height: calc(34px + 6em);
  min-height: calc(34px + 6em);
  max-height: calc(34px + 6em);
  padding: 16px 12px;
  line-height: 2;
  resize: none;
  overflow: hidden;
  field-sizing: fixed;
}

.review-field-textarea--remarks {
  box-sizing: border-box;
  width: 100%;
  min-height: 200px;
  height: 200px;
  padding: 12px;
  line-height: 1.65;
  resize: vertical;
  overflow: auto;
}

#page-basic .review-field-textarea.review-field-textarea--remarks {
  min-height: 200px;
  height: 200px;
  max-height: none;
  resize: vertical;
}

.remarks-source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.remarks-source-option {
  flex: 1 1 220px;
  min-width: min(100%, 220px);
  cursor: pointer;
}

.remarks-source-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.remarks-source-option-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.remarks-source-option:hover .remarks-source-option-body {
  border-color: var(--accent-mid);
}

.remarks-source-option:has(.remarks-source-radio:checked) .remarks-source-option-body {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(232, 112, 42, 0.12);
}

.remarks-source-option-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #cbd5e0;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.15s;
}

.remarks-source-option:has(.remarks-source-radio:checked) .remarks-source-option-dot {
  border-color: var(--accent);
}

.remarks-source-option:has(.remarks-source-radio:checked) .remarks-source-option-dot::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.remarks-source-option-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.45;
}

.remarks-preset-picker {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  margin-bottom: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease;
}

.remarks-preset-picker.is-visible {
  max-height: 80px;
  opacity: 1;
  margin-top: 0;
  margin-bottom: 16px;
}

.remarks-preset-picker select {
  width: 100%;
}

.client-field-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.client-field-name {
  flex: 0 0 70%;
  width: 70%;
  min-width: 0;
}

.client-suffix-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.client-suffix-select {
  width: 100%;
  padding: 0 8px;
  cursor: pointer;
}

.client-suffix-custom {
  width: 100%;
}

.field-input-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.items-head {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) var(--verify-col-qty, 64px) var(--verify-col-unit, 56px) var(--verify-col-price, 100px) var(--verify-col-amount, 80px) 36px;
  gap: 8px;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.items-head-nums {
  display: contents;
}

.items-head-drag {
  width: 28px;
}

.item-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) var(--verify-col-qty, 64px) var(--verify-col-unit, 56px) var(--verify-col-price, 100px) var(--verify-col-amount, 80px) 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.item-row--text {
  grid-template-columns: 28px 1fr 36px;
}

.item-row--text > .item-drag-handle,
.item-row--blank > .item-drag-handle {
  grid-column: 1;
  grid-row: 1;
}

.item-row--text > .btn-del,
.item-row--blank > .btn-del {
  grid-column: 3;
  grid-row: 1;
}

.item-row--blank > .item-row-blank-label {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.item-row--group .item-row-input--text {
  font-weight: 700;
}

.item-row--blank {
  grid-template-columns: 28px 1fr 36px;
  min-height: 32px;
}

.item-row-blank-label {
  font-size: 13px;
  color: var(--muted);
}

.item-row--dragging {
  opacity: 0.45;
}

.item-row--drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.item-row-nums {
  display: contents;
}

.item-row-nums .item-row-input,
.item-row-nums .item-row-num-display {
  min-width: 0;
  box-sizing: border-box;
}

@media screen and (max-width: 900px) {
  .items-head {
    display: none;
  }

  #page-basic #items-list .item-row {
    background: var(--accent-light);
    border-radius: 8px;
    padding: 8px 6px;
    margin-bottom: 10px;
    box-sizing: border-box;
  }

  #page-basic #items-list .item-row:last-child {
    margin-bottom: 0;
  }

  .item-row:not(.item-row--text):not(.item-row--blank) {
    grid-template-columns: 28px 1fr 36px;
    grid-template-rows: auto auto;
    gap: 6px;
    align-items: stretch;
  }

  .item-row:not(.item-row--text):not(.item-row--blank) > .item-drag-handle {
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: start;
  }

  .item-row:not(.item-row--text):not(.item-row--blank) > .item-row-input:first-of-type {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .item-row:not(.item-row--text):not(.item-row--blank) > .btn-del {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: start;
  }

  .item-row-nums {
    display: grid;
    grid-column: 2 / 4;
    grid-row: 2;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    min-width: 0;
    margin-top: 2px;
    padding: 8px 0 0;
    background: transparent;
    border-top: 1px solid rgba(26, 79, 122, 0.14);
    border-radius: 0;
    box-sizing: border-box;
  }

  .item-row-nums .item-row-input,
  .item-row-nums .item-row-num-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    text-align: center;
    font-size: 13px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .item-row-nums .item-row-input::before,
  .item-row-nums .item-row-num-display::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    line-height: 1.3;
    white-space: nowrap;
  }

  .item-row-nums .item-row-input--qty,
  .item-row-nums .item-row-input--price {
    text-align: center;
  }

  .item-row-nums .item-row-num-display {
    color: var(--text);
    padding-right: 0;
  }

  .item-row--text,
  .item-row--blank {
    gap: 6px;
  }
}

@media screen and (min-width: 901px) {
  #page-basic .section-card:has(#items-list) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #page-basic .items-head,
  #page-basic .item-row:not(.item-row--text):not(.item-row--blank) {
    min-width: var(--items-grid-min-width, 516px);
    grid-template-columns:
      28px
      minmax(96px, 1fr)
      minmax(72px, var(--verify-col-qty, 72px))
      minmax(72px, var(--verify-col-unit, 72px))
      minmax(92px, var(--verify-col-price, 92px))
      minmax(92px, var(--verify-col-amount, 92px))
      36px;
  }

  #page-basic .item-row-nums .item-row-input,
  #page-basic .item-row-nums .item-row-num-display {
    min-width: unset;
    width: 100%;
  }

  #page-basic .item-row-nums .item-row-input--qty {
    min-width: 72px;
  }

  #page-basic .item-row-nums .item-row-input--unit {
    min-width: 72px;
    max-width: 72px;
    flex-shrink: 0;
    padding-left: 6px;
    padding-right: 6px;
  }

  #page-basic .item-row-nums .item-row-input--price {
    min-width: 92px;
  }

  #page-basic .item-row-nums .amount-cell {
    min-width: 92px;
  }
}

.item-drag-handle {
  width: 28px;
  height: 40px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.item-drag-handle:active {
  cursor: grabbing;
}

.item-drag-icon {
  display: block;
  width: 10px;
  height: 14px;
  background:
    radial-gradient(circle, var(--muted) 1.5px, transparent 1.6px) 0 0 / 10px 7px repeat;
}

.item-row-input--qty,
.item-row-input--unit,
.item-row-input--price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.item-row-input--unit {
  text-align: center;
}

.item-row-input--text {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.items-add-actions--multi {
  grid-template-columns: repeat(2, 1fr);
}

@media screen and (min-width: 640px) {
  .items-add-actions--multi {
    grid-template-columns: repeat(4, 1fr);
  }
}

.items-add-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media screen and (max-width: 600px) {
  .items-add-actions {
    grid-template-columns: 1fr;
  }
}

.items-head-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.btn-add-row--text {
  margin-top: 0;
}

.item-row-input {
  font-size: 14px;
  height: 40px;
}

.amount-cell {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  padding-right: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-del {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-del:hover {
  background: #FEF0EF;
  border-color: #F5C6C3;
  color: var(--danger);
}

.btn-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  width: 100%;
  margin-top: 10px;
  font-family: inherit;
  font-weight: 500;
}

.btn-add-row:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.edit-footer {
  padding: 20px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}

.btn-confirm {
  width: 100%;
  padding: 16px;
  background: var(--cta);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-confirm:hover {
  background: var(--cta-hover);
}

.btn-confirm:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-confirm--inline {
  width: auto;
  flex: 1;
  min-width: 200px;
}

@media screen and (max-width: 900px) {
  .action-row .btn-confirm,
  .action-row .btn-back,
  .action-row .btn-secondary,
  .edit-footer .btn-confirm {
    margin-bottom: var(--safe-bottom);
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
  }
}

.step-guide {
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 16px;
}

.step-guide-footer {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 12px;
}

.verify-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}

@media screen and (max-width: 800px) {
  .verify-grid {
    grid-template-columns: 1fr;
  }
}

.verify-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.verify-field--full {
  grid-column: 1 / -1;
}

.verify-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.verify-value {
  font-size: 15px;
  color: var(--text);
  padding: 10px 12px;
  background: var(--accent-light);
  border-radius: 8px;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.verify-value--multiline {
  align-items: flex-start;
  white-space: pre-line;
  line-height: 1.5;
  word-break: break-all;
}

.verify-items-table {
  --verify-col-qty: 64px;
  --verify-col-unit: 56px;
  --verify-col-price: 100px;
  --verify-col-amount: 80px;
}

.verify-items-head,
.verify-item-row:not(.verify-item-row--text):not(.verify-item-row--blank) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--verify-col-qty) var(--verify-col-unit) var(--verify-col-price) var(--verify-col-amount);
  column-gap: 12px;
  align-items: start;
}

.verify-items-head {
  padding: 0 4px 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.verify-item-row {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.verify-item-nums {
  display: contents;
}

.verify-item-row--text {
  display: block;
  grid-template-columns: none;
}

.verify-item-row--group {
  padding-top: 12px;
  border-bottom: none;
}

.verify-item-row--subtext {
  padding-top: 2px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--border);
}

.verify-item-row--blank {
  min-height: 16px;
  padding: 4px;
  border-bottom: none;
}

.verify-item-row:last-child {
  border-bottom: none;
}

.verify-item-name {
  word-break: break-word;
  text-align: left;
  min-width: 0;
}

.verify-item-name--group {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.verify-item-name--subtext {
  font-weight: 400;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  padding-left: 8px;
}

.verify-item-blank {
  display: block;
  min-height: 12px;
}

.verify-item-num {
  text-align: right;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.verify-col-num {
  text-align: right;
  white-space: nowrap;
}

.items-head-label--desc {
  text-align: left;
}

@media screen and (max-width: 900px) {
  .verify-items-head {
    display: none;
  }

  .verify-item-row:not(.verify-item-row--text):not(.verify-item-row--blank) {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
    padding: 10px 4px;
  }

  .verify-item-row:not(.verify-item-row--text):not(.verify-item-row--blank) .verify-item-name {
    font-weight: 600;
    line-height: 1.55;
    word-break: break-word;
  }

  .verify-item-nums {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    padding: 8px 6px;
    background: var(--accent-light);
    border-radius: 8px;
    box-sizing: border-box;
  }

  .verify-item-nums .verify-item-num {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    text-align: center;
    font-size: 13px;
    color: var(--text);
    min-width: 0;
    word-break: break-word;
  }

  .verify-item-nums .verify-item-num::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    line-height: 1.3;
    white-space: nowrap;
  }
}

.verify-empty {
  font-size: 14px;
  color: var(--muted);
  padding: 8px 4px;
  margin: 0;
}

.verify-remarks-value {
  font-size: 15px;
  color: var(--text);
  padding: 10px 12px;
  background: var(--accent-light);
  border-radius: 8px;
  min-height: 42px;
  margin: 0;
  white-space: pre-line;
  line-height: 1.6;
  word-break: break-word;
}

.verify-remarks-value--empty {
  color: var(--muted);
}

.verify-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
  cursor: pointer;
}

.verify-check-input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.basic-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 4rem;
}

@media screen and (min-width: 901px) {
  #page-basic .workflow-header-band-inner,
  #page-basic .workflow-header-band .workflow-header,
  #page-basic .basic-wrap {
    max-width: 1024px;
  }

  #page-basic .basic-wrap {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

#page-basic .basic-pdf-panel {
  display: none;
}

@media screen and (max-width: 900px) {
  .workflow-page-intro .page-title {
    font-size: 22px;
  }

  .workflow-page-intro .page-sub {
    margin-bottom: 1.25rem;
  }
}

@media screen and (max-width: 600px) {
  #page-basic .workflow-page-intro .page-sub,
  #page-margin .workflow-page-intro .page-sub,
  #page-pdf-preview .workflow-page-intro .page-sub,
  #page-complete .workflow-page-intro .page-sub {
    margin-bottom: 1rem;
  }
}

@media screen and (max-width: 600px) {
  #page-basic .basic-wrap {
    padding: 1.5rem 8px calc(3rem + var(--mobile-bar-h));
  }

  #page-basic .section-card {
    padding-left: 8px;
    padding-right: 8px;
  }

  #page-review .edit-body {
    padding-left: 8px;
    padding-right: 8px;
  }

  #page-review .section-card {
    padding-left: 8px;
    padding-right: 8px;
  }
}

.basic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.basic-header .page-title {
  margin-bottom: 0;
}

.pdf-panel {
  background: #272725;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.zoom-val {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
  min-width: 44px;
  text-align: center;
}

.zoom-val-wrap {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  min-width: 44px;
}

.zoom-val-input {
  width: 3.2em;
  padding: 2px 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-family: inherit;
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}

.zoom-val-input::-webkit-outer-spin-button,
.zoom-val-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.zoom-val-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.14);
}

.zoom-val-suffix {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1;
}

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

.zoom-loupe-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.zoom-loupe-label-input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

@media screen and (max-width: 900px) {
  .panel-header {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 10px 12px;
  }

  .panel-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .zoom-controls {
    flex: 0 0 auto;
    flex-shrink: 0;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
  }

  .zoom-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
    flex-shrink: 0;
  }

  .zoom-val-wrap {
    flex-shrink: 0;
    min-width: 0;
  }

  .zoom-val-input {
    width: 2.8em;
    font-size: 12px;
    padding: 2px 3px;
  }

  .zoom-val-suffix {
    font-size: 12px;
  }

  .zoom-loupe-label {
    margin-left: 4px;
    gap: 4px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .zoom-loupe-label-input {
    width: 14px;
    height: 14px;
  }
}

.pdf-viewport {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
}

.pdf-viewport.pdf-loupe-active {
  cursor: none;
}

.pdf-viewport.pdf-loupe-active #pdf-canvas {
  cursor: none;
}

.pdf-loupe {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 8px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  pointer-events: none;
  z-index: 20;
  background: #fff;
}

.pdf-loupe[hidden] {
  display: none;
}

#pdf-loupe-canvas {
  display: block;
  width: 200px;
  height: 200px;
}

#pdf-canvas {
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

/* ================================================================
   PAGE 3 — マージン設定
   ================================================================ */

.margin-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 4rem;
}

.margin-layout {
  min-height: calc(100vh - 60px);
}

.margin-layout.margin-layout--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 60px);
}

.margin-edit-panel {
  overflow-y: auto;
  min-width: 0;
}

.margin-layout.margin-layout--split .margin-wrap {
  max-width: none;
  margin: 0;
}

.margin-work-preview {
  margin-bottom: 24px;
  padding: 18px 20px;
  background: #EEF4FB;
  border: 1.5px solid #C5D9F0;
  border-radius: var(--radius-lg);
}

.margin-work-preview-title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.margin-work-preview-lead {
  margin: 0 0 14px;
  font-size: 13px;
  color: #4B5563;
  line-height: 1.65;
}

.margin-work-preview-lead--mobile {
  display: none;
}

@media screen and (max-width: 900px) {
  .margin-work-preview-lead--desktop {
    display: none;
  }

  .margin-work-preview-lead--mobile {
    display: block;
  }
}

.margin-preview-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.margin-preview-toggle {
  flex: 1 1 calc(50% - 5px);
  min-width: 140px;
}

.margin-preview-toggle.is-active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.margin-final-output {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--border);
}

.margin-final-output-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--heading);
}

.margin-final-output-lead {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
}

.margin-side-panel[hidden] {
  display: none !important;
}

#margin-pdf-viewport {
  display: block;
  overflow: auto;
  padding: 20px;
  position: relative;
}

.margin-side-preview-slot {
  width: 100%;
  box-sizing: border-box;
}

#margin-source-view {
  text-align: center;
}

.margin-side-preview-slot[hidden] {
  display: none !important;
}

#margin-source-canvas {
  display: inline-block;
  vertical-align: top;
  max-width: 100%;
  height: auto;
}

.margin-output-page-wrap,
.pdf-preview-page-wrap {
  position: relative;
  margin-left: auto;
  margin-right: auto;
}

.margin-output-stage-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.margin-output-stage {
  margin: 0 auto;
  transform-origin: top center;
}

.margin-output-stage .pdf-preview-doc {
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

@media screen and (max-width: 900px) {
  .margin-layout.margin-layout--split {
    grid-template-columns: 1fr;
    grid-template-rows: unset;
    height: auto;
    min-height: calc(100vh - 60px);
  }

  .margin-layout.margin-layout--split .margin-side-panel {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: calc(var(--margin-mobile-bar-h) + var(--safe-bottom));
    z-index: 115;
    min-height: 0;
    overflow: hidden;
    background: #272725;
    border-left: none;
  }

  .margin-layout.margin-layout--split .margin-side-panel .panel-header {
    flex: 0 0 auto;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    gap: 8px;
    padding: 10px 12px;
  }

  .margin-layout.margin-layout--split .margin-side-panel .panel-label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .margin-layout.margin-layout--split .margin-side-panel .zoom-controls {
    flex: 0 0 auto;
    flex-shrink: 0;
  }

  .margin-layout.margin-layout--split .margin-side-panel #margin-pdf-viewport {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
  }
}

@media screen and (max-width: 600px) {
  .margin-wrap {
    padding: 1.5rem 1rem 3rem;
  }
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--heading);
}

.page-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 2rem;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.mode-tab {
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 15px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.m-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}

@media screen and (max-width: 600px) {
  .m-card {
    padding: 16px;
  }
}

.m-card-title {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
  font-weight: 500;
}

.global-rate-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.rate-big {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.rate-big-input {
  width: 100px;
  font-size: 36px;
  font-weight: 300;
  text-align: center;
  height: 56px;
  border-radius: 10px;
}

.rate-big-unit {
  font-size: 24px;
  color: var(--muted);
  font-weight: 300;
}

.rate-desc {
  font-size: 15px;
  color: var(--muted);
}

.ba-head {
  display: grid;
  grid-template-columns: 1fr 130px 30px 1fr 36px;
  gap: 8px;
  padding: 0 4px 12px;
  border-bottom: 1px solid var(--border);
}

@media screen and (max-width: 800px) {
  .ba-head {
    grid-template-columns: 1fr 100px 20px 100px 36px;
  }
}

.ba-head-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-align: right;
}

.ba-head-label--first {
  text-align: left;
}

.ba-row {
  display: grid;
  grid-template-columns: 1fr 130px 30px 1fr 36px;
  gap: 8px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--bg);
}

.ba-row--text {
  grid-template-columns: 1fr;
  border-bottom: 1px solid var(--border);
  padding: 14px 4px;
}

.ba-row--group {
  padding-top: 16px;
  border-bottom: none;
}

.ba-row--subtext {
  padding: 4px 4px 8px;
  border-bottom: 1px dashed var(--border);
}

.ba-row--blank {
  min-height: 16px;
  padding: 4px;
  border-bottom: none;
}

.ba-name--group {
  font-weight: 700;
  line-height: 1.8;
  text-align: left;
}

.ba-name--subtext {
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  text-align: left;
  padding-left: 8px;
}

.ba-mobile-label {
  display: none;
}

.ba-side-label {
  display: none;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.ba-before-wrap,
.ba-after-wrap {
  text-align: right;
}

.ba-after-wrap--item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
}

.ba-after-price {
  font-size: 15px;
  color: var(--accent);
  font-weight: 700;
  min-width: 88px;
  text-align: right;
}

.ba-arrow-mobile {
  display: none;
}

.ba-row-spacer {
  display: none;
}

@media screen and (max-width: 800px) {
  .ba-head {
    display: none;
  }

  .ba-row {
    display: block;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
  }

  #page-margin #ba-rows .ba-row:not(.ba-row--text):not(.ba-row--blank) {
    background: var(--accent-light);
    border-radius: 8px;
    padding: 12px 10px;
    margin-bottom: 10px;
    border-bottom: none;
    box-sizing: border-box;
  }

  #page-margin #ba-rows .ba-row:not(.ba-row--text):not(.ba-row--blank) .ba-name {
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(24, 95, 165, 0.16);
  }

  #page-margin #ba-rows .ba-row:not(.ba-row--text):not(.ba-row--blank) .ba-before-wrap,
  #page-margin #ba-rows .ba-row:not(.ba-row--text):not(.ba-row--blank) .ba-after-wrap,
  #page-margin #ba-rows .ba-row:not(.ba-row--text):not(.ba-row--blank) .ba-after-wrap--item {
    margin-bottom: 4px;
  }

  #page-margin #ba-rows .ba-row:not(.ba-row--text):not(.ba-row--blank) .ba-arrow {
    padding: 6px 0;
  }

  .ba-row--text {
    padding: 12px 0;
  }

  .ba-name {
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    line-height: 1.8;
    margin-bottom: 12px;
    word-break: break-word;
  }

  .ba-before-wrap,
  .ba-after-wrap,
  .ba-after-wrap--item {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    margin-bottom: 6px;
    text-align: left;
    gap: 8px;
  }

  .ba-side-label {
    display: inline-block;
    min-width: 80px;
    flex-shrink: 0;
  }

  .ba-arrow {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
    color: var(--accent);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
  }

  .ba-arrow-desktop {
    display: none;
  }

  .ba-arrow-mobile {
    display: inline;
  }

  .ba-after-wrap--item .ba-after-price {
    min-width: auto;
    flex: 1;
    text-align: left;
  }

  .ba-after-wrap .ba-after-price {
    min-width: auto;
    flex: 1;
    text-align: left;
  }

  .ba-before {
    text-align: left;
  }

  .ba-after-wrap--item .ba-rate,
  .ba-after-wrap .ba-rate {
    margin-left: auto;
    flex-shrink: 0;
  }
}

@media screen and (min-width: 801px) {
  .ba-after-wrap--item .ba-side-label,
  .ba-after-wrap .ba-side-label {
    display: none;
  }
}

.ba-name {
  font-size: 14px;
  font-weight: 500;
}

.ba-before {
  font-size: 15px;
  color: var(--muted);
  text-align: right;
}

.ba-arrow {
  text-align: center;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

.ba-after {
  font-size: 15px;
  color: var(--accent);
  font-weight: 700;
  text-align: right;
}

.ba-rate {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.ba-rate-input {
  width: 64px;
  font-size: 14px;
  height: 36px;
  text-align: center;
}

.ba-rate-unit {
  font-size: 13px;
  color: var(--muted);
}

.totals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

@media screen and (max-width: 800px) {
  .totals-grid {
    grid-template-columns: 1fr;
  }
}

.total-box {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
}

.total-box .tl {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.total-box .ta {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.02em;
}

.total-box .ta.green {
  color: var(--success);
  font-weight: 700;
}

.total-box .ts {
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.8;
}

#profit-area {
  display: flex;
  justify-content: flex-start;
}

.profit-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 24px;
  margin-top: 16px;
  border: 1px solid rgba(24, 95, 165, 0.2);
  flex-wrap: wrap;
}

.profit-chip-label,
.profit-chip-value {
  display: inline;
}

.margin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 0;
}

.margin-actions-excel {
  grid-column: 1;
  grid-row: 1;
}

.margin-actions-pdf {
  grid-column: 2;
  grid-row: 1;
}

.margin-actions-back {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  text-align: center;
  justify-content: center;
}

.margin-actions .btn-excel,
.margin-actions .btn-preview,
.margin-actions .btn-back {
  width: 100%;
  min-width: 0;
}

@media screen and (max-width: 800px) {
  #profit-area {
    justify-content: center;
  }

  .profit-chip {
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 100%;
    gap: 4px;
    line-height: 1.5;
  }

  .profit-chip-label,
  .profit-chip-value {
    display: block;
  }

  .margin-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .margin-actions-pdf {
    order: 1;
  }

  .margin-actions-excel {
    order: 2;
  }

  .margin-actions-back {
    order: 3;
  }
}

.pdf-preview-wrap {
  max-width: 900px;
}

.pdf-preview-viewport {
  overflow: auto;
  padding: 8px 0 16px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  min-height: 320px;
}

.pdf-preview-stage {
  margin: 0 auto;
  transform-origin: top left;
}

.pdf-preview-doc {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  display: block;
  overflow: visible;
}

.pdf-preview-actions {
  margin-top: 20px;
}

@media screen and (max-width: 900px) {
  .pdf-preview-viewport {
    padding: 4px 0 8px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .pdf-preview-stage.is-touch-zoomed {
    will-change: transform;
  }

  .pdf-preview-actions {
    margin-top: 16px;
  }
}

/* ================================================================
   完了画面
   ================================================================ */

.complete-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.complete-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
}

.complete-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  color: var(--heading);
}

.complete-lead {
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}

.complete-tip-card {
  text-align: left;
  background: #EEF4FB;
  border: 1.5px solid #C5D9F0;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 28px;
}

.complete-tip-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.complete-tip-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  color: #1F2937;
}

.complete-tip-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.complete-tip-link:hover {
  text-decoration: underline;
}

.complete-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
  text-align: center;
}

.complete-actions-section {
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}

.complete-actions-section:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.complete-actions-heading {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.complete-actions-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.complete-action-btn {
  width: 100%;
  min-width: 0;
}

.complete-actions-section--next {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.complete-action-btn--primary {
  padding-top: 18px;
  padding-bottom: 18px;
  font-size: 17px;
}

.complete-actions-link {
  margin: 0;
  padding: 6px 8px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  align-self: center;
}

.complete-actions-link:hover {
  color: var(--accent-mid);
}

@media screen and (max-width: 480px) {
  .complete-actions-pair {
    grid-template-columns: 1fr;
  }
}
