/* ========================================
   PC Quote Tool — Mobile First
   Breakpoints: base = mobile / 768px+ = tablet / 1024px+ = desktop
   ======================================== */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #1d1d1f;
  --text-sub: #6e6e73;
  --text-hint: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-light: #e8f2ff;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --red: #c00;
  --orange: #f59e0b;
  --green: #10b981;
  --topbar-h: 48px;
  --mobile-action-h: 64px;
  --transition: 0.2s ease;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 4px 12px rgba(0,0,0,.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; overscroll-behavior: none; }

body {
  font-family: 'Noto Sans JP', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ========== Topbar ========== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 100;
  gap: 8px;
}
.topbar-left { flex: 0 0 auto; }
.topbar-center { flex: 1 1 auto; display: flex; justify-content: center; }
.topbar-right { flex: 0 0 auto; display: flex; gap: 6px; }

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.view-switcher {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.view-switch-btn {
  padding: 6px 14px;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  min-width: 64px;
  font-family: inherit;
}
.view-switch-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.mode-toggle, .btn-fullscreen {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  min-height: 36px;
}
.mode-toggle.on {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}
.mode-toggle-text { font-size: 11px; }

/* ========== Layout ========== */
.app-layout {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
}

.panel-left, .panel-right, .panel-profit {
  width: 100%;
  height: calc(100vh - var(--topbar-h));
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.panel-right { background: var(--surface-alt); }
.panel-profit { background: #fefdf8; border-left: 1px solid var(--border-light); }

/* モバイル: 基本は入力のみ表示、トグルで切替 */
.panel-right { display: none; }
.panel-profit { display: none; }
body.show-preview .panel-left { display: none; }
body.show-preview .panel-right { display: flex; }
body.show-profit .panel-left { display: none; }
body.show-profit .panel-profit { display: flex; }

body.mobile-view .panel-scroll,
body.mobile-view .preview-scroll {
  padding-bottom: var(--mobile-action-h);
}

/* 客先モードでは右パネル(利益)を非表示 */
body.client-mode .panel-profit { display: none !important; }
body.client-mode .view-switch-btn.for-profit { display: none !important; }

/* 全画面プレビュー */
body.fullscreen-preview .topbar-left,
body.fullscreen-preview .topbar-center,
body.fullscreen-preview .mode-toggle,
body.fullscreen-preview .btn-fullscreen,
body.fullscreen-preview .panel-left,
body.fullscreen-preview .panel-profit,
body.fullscreen-preview .mobile-actions { display: none !important; }
body.fullscreen-preview .panel-right { display: flex !important; }

/* ========== Panel (form) ========== */
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}
.panel-header { margin-bottom: 12px; }

.data-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-alt);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-sub);
}
.data-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-status.live { color: var(--green); font-weight: 600; }

.btn-reload {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.btn-reload:active { transform: scale(0.95); }

.loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 8px;
  background: var(--accent-light);
  border-radius: 6px;
  font-size: 12px;
  color: var(--accent);
}
.loading-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--accent-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Form sections ========== */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.form-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.step-badge {
  width: 22px; height: 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.ai-badge { background: linear-gradient(135deg, #a855f7, #0ea5e9); width: 28px; }

.form-field { margin-bottom: 10px; }
.form-field:last-child { margin-bottom: 0; }
.form-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 4px;
}

/* ========== Inputs ========== */
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* iOS auto-zoom prevention */
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: var(--transition);
  min-height: 44px;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.input-sm {
  padding: 8px 10px;
  font-size: 14px;
  min-height: 38px;
}
.input-price { text-align: right; }
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236e6e73' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.textarea { min-height: 60px; resize: vertical; }

/* PCタイプ */
.pc-type-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pc-type-btn {
  padding: 12px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  transition: var(--transition);
  font-family: inherit;
  min-height: 48px;
}
.pc-type-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.desktop-sub-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.desktop-sub-btn {
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  transition: var(--transition);
  font-family: inherit;
  min-height: 40px;
}
.desktop-sub-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* ========== AI section ========== */
.ai-budget-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
}
.ai-budget-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  margin: 0;
  flex-shrink: 0;
}
.ai-budget-row .input-sm { flex: 1; min-width: 80px; }
.ai-budget-row .unit { font-size: 11px; color: var(--text-sub); flex-shrink: 0; }

.btn-ai {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #a855f7, #0ea5e9);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  min-height: 46px;
}
.btn-ai:active { transform: scale(0.98); }

.ai-results { margin-top: 12px; }
.ai-card-placeholder {
  padding: 16px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-sub);
  text-align: center;
  line-height: 1.6;
}

/* ========== Tier Swiper ========== */
.tier-header {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 10px;
  text-align: center;
}
.tier-header strong { color: var(--text); }

.tier-swiper {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.tier-deck-viewport {
  flex: 1;
  overflow: hidden;
  border-radius: var(--radius);
}
.tier-deck {
  display: flex;
  gap: 12px;
  transition: transform 0.35s cubic-bezier(.2,.9,.3,1);
  will-change: transform;
}
.tier-card {
  flex: 0 0 100%;
  background: #fff;
  border: 2px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  transition: var(--transition);
  opacity: 0.5;
  transform: scale(0.95);
}
.tier-card.active {
  opacity: 1;
  transform: scale(1);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.tier-card.tier-ume.active { border-color: #a16207; }
.tier-card.tier-take.active { border-color: #16a34a; }
.tier-card.tier-matsu.active { border-color: #dc2626; }

.tier-card-inner { display: flex; flex-direction: column; gap: 8px; }
.tier-badge {
  align-self: flex-start;
  padding: 4px 12px;
  background: var(--surface-alt);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}
.tier-ume .tier-badge { background: #fef3c7; color: #92400e; }
.tier-take .tier-badge { background: #d1fae5; color: #065f46; }
.tier-matsu .tier-badge { background: #fee2e2; color: #991b1b; }

.tier-price {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.tier-experience {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.5;
}
.tier-parts {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tier-part-line {
  display: flex;
  font-size: 12px;
  gap: 8px;
  align-items: baseline;
}
.tier-part-label {
  flex: 0 0 34px;
  color: var(--text-hint);
  font-weight: 600;
  font-size: 10px;
}
.tier-part-val {
  flex: 1;
  color: var(--text);
  word-break: break-all;
}

.tier-nav-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  align-self: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.tier-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.tier-nav-btn:not(:disabled):active { background: var(--accent-light); }

.tier-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}
.tier-dot {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  min-width: 44px;
}
.tier-dot.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-tier-apply {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  min-height: 46px;
}
.btn-tier-apply:active { transform: scale(0.98); }
.btn-tier-apply.applied { background: var(--green); }

/* ========== Parts list ========== */
.parts-list { display: flex; flex-direction: column; gap: 8px; }
.part-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 8px;
  align-items: flex-start;
}
.part-badge {
  padding: 8px 6px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-sub);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.part-select-wrap { display: flex; flex-direction: column; gap: 6px; }
.part-custom { display: flex; gap: 6px; }
.part-custom input { flex: 1; }
.part-custom .input-price { flex: 0 0 110px; }
.part-price-display {
  font-size: 12px;
  color: var(--text-hint);
  text-align: right;
}

.extra-parts-section { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-light); }
.extra-parts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.btn-add-extra {
  padding: 4px 10px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.extra-row {
  display: grid;
  grid-template-columns: 1fr 100px 36px;
  gap: 6px;
  margin-bottom: 6px;
}
.btn-remove-extra {
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 4px;
  color: #c00;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
}

/* ========== Slim model ========== */
.slim-model-detail {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
.slim-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}
.slim-detail-model { font-size: 13px; font-weight: 700; }
.slim-detail-price { font-size: 15px; font-weight: 800; color: var(--accent); }
.slim-detail-parts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}
.slim-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  gap: 8px;
}
.slim-detail-label { color: var(--text-sub); font-weight: 600; flex-shrink: 0; }
.slim-detail-val { color: var(--text); text-align: right; word-break: break-all; }

/* ========== Profit box (hidden in client mode) ========== */
.profit-box {
  margin-top: 12px;
  padding: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
}
.profit-box-title {
  font-size: 11px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 8px;
}
.profit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
}
.profit-row label { color: var(--text-sub); font-weight: 500; }
.profit-value { font-weight: 700; color: var(--text); }

body.client-mode .profit-box { display: none; }

/* ========== Pricing fields (右パネル価格) ========== */
.pricing-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.pricing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pricing-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  flex-shrink: 0;
  min-width: 68px;
}
.pricing-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: flex-end;
}
.pricing-input-group .input-sm { width: 90px; }
.pricing-input-group .unit { font-size: 11px; color: var(--text-sub); }

/* 特別値引きボックス */
.discount-box {
  margin-top: 12px;
  padding: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}
.discount-box-title {
  font-size: 11px;
  font-weight: 700;
  color: #991b1b;
  margin-bottom: 8px;
}
body.client-mode .discount-box { display: none; }

/* ========== Form actions (desktop only) ========== */
.form-actions { display: none; gap: 8px; margin-top: 16px; }
.btn-primary, .btn-ghost {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  transition: var(--transition);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border);
  flex: 0 0 auto;
  padding: 12px 18px;
}

/* ========== Mobile sticky actions ========== */
.mobile-actions {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-action-h);
  background: #fff;
  border-top: 1px solid var(--border-light);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  z-index: 99;
  box-shadow: 0 -2px 8px rgba(0,0,0,.04);
}
.mobile-action-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  border: none;
}
.mobile-action-pdf {
  background: var(--accent);
  color: #fff;
}
.mobile-action-btn:active { transform: scale(0.98); }
.mobile-action-btn:disabled { opacity: 0.6; }

/* ========== Preview (right) ========== */
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.preview-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}
.btn-exit-fullscreen {
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-sub);
  font-family: inherit;
}
.preview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-alt);
}

/* ========== Quote paper ========== */
/* プレビュー領域に収まるようにJSで scale を動的設定する */
.preview-scale-wrap {
  transform-origin: top center;
  margin: 0 auto;
  width: 210mm;
  /* scale は app.js が動的に設定 */
}
.quote-paper {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  box-shadow: var(--shadow);
}

.q {
  padding: 12mm 14mm 10mm;
  background: #fff;
  min-height: 297mm;
  position: relative;
  font-size: 9.5pt;
  color: #1f2937;
  font-feature-settings: "palt" 1;
  box-sizing: border-box;
}

/* ---- Header ---- */
.q-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6mm;
  margin-bottom: 4mm;
}
.q-header-left { flex: 0 0 auto; padding-top: 1mm; }
.q-header-center { flex: 1; text-align: center; }
.q-header-right { flex: 0 0 auto; padding-top: 1mm; }

.q-logo-img { height: 34px; }
.q-title {
  font-size: 24pt;
  font-weight: 700;
  letter-spacing: 0.5em;
  padding-left: 0.5em;
  color: #111827;
  display: inline-block;
}

.q-date {
  display: flex;
  align-items: baseline;
  gap: 6pt;
  font-size: 9.5pt;
  color: #374151;
  white-space: nowrap;
}
.q-date-label { color: #6b7280; }
.q-date-val { font-weight: 600; }

/* ---- Body row (顧客+合計 / 自社+印) ---- */
.q-body-row {
  display: flex;
  gap: 8mm;
  margin-bottom: 5mm;
  align-items: flex-start;
}
.q-body-left {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  gap: 4mm;
}
.q-body-right {
  flex: 1;
  display: flex;
  gap: 5mm;
  align-items: flex-start;
  justify-content: flex-end;
}

.q-customer-row {
  display: flex;
  align-items: flex-end;
  gap: 4pt;
  padding-bottom: 1.5mm;
  border-bottom: 1.5px solid #111827;
}
.q-customer-text {
  font-size: 14pt;
  font-weight: 700;
  flex: 1;
  line-height: 1.4;
  min-height: 18pt;
}
.q-sama { font-size: 13pt; font-weight: 600; color: #111827; }

.q-total-box {
  display: flex;
  align-items: baseline;
  gap: 3mm;
  padding: 3mm 4mm;
  background: #f9fafb;
  border-left: 4px solid #0ea5e9;
  border-radius: 2px;
}
.q-total-lbl {
  font-size: 9.5pt;
  font-weight: 700;
  color: #374151;
  letter-spacing: 0.1em;
}
.q-total-amt {
  font-size: 20pt;
  font-weight: 800;
  color: #0c4a6e;
  letter-spacing: -0.01em;
  flex: 1;
  text-align: right;
}
.q-total-sfx {
  font-size: 8.5pt;
  color: #6b7280;
}

.q-company-info {
  font-size: 8.5pt;
  line-height: 1.6;
  color: #374151;
}
.q-company-name {
  font-size: 10pt;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1mm;
}
.q-stamp-area {
  flex: 0 0 auto;
}
.q-stamp-img {
  width: 64px;
  height: 64px;
  opacity: 0.85;
}

/* ---- Breakdown table ---- */
.q-bd {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4mm;
  font-size: 9pt;
}
.q-bd th {
  background: #111827;
  color: #fff;
  padding: 2mm 3mm;
  text-align: left;
  font-weight: 600;
  font-size: 8.5pt;
  letter-spacing: 0.05em;
}
.q-bd th.c-qty, .q-bd th.c-unit, .q-bd th.c-amt { text-align: right; }
.q-bd td {
  padding: 2mm 3mm;
  border-bottom: 1px solid #e5e7eb;
}
.q-bd .c-item { text-align: left; }
.q-bd .c-qty, .q-bd .c-unit, .q-bd .c-amt { text-align: right; font-variant-numeric: tabular-nums; }
.q-bd .discount-row td { color: #dc2626; }
.q-bd .sum-row td {
  background: #f9fafb;
  font-weight: 700;
  border-top: 1.5px solid #111827;
  border-bottom: 1.5px solid #111827;
  font-size: 9.5pt;
}

/* ---- Spec table ---- */
.q-sp {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4mm;
  font-size: 8.5pt;
  border: 1px solid #d1d5db;
}
.q-sp td {
  padding: 1.3mm 2.5mm;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  line-height: 1.45;
}
.q-sp tr:last-child td { border-bottom: none; }
.q-sp .sl {
  background: #f3f4f6;
  font-weight: 600;
  width: 26mm;
  font-size: 8pt;
  color: #374151;
  border-right: 1px solid #e5e7eb;
}
.q-sp .sv { word-break: break-all; color: #111827; }
.q-sp .other-cell { min-height: 10mm; white-space: pre-wrap; }

/* ---- Price summary ---- */
.q-price-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4mm;
}
.q-ps {
  width: 80mm;
  border-collapse: collapse;
  font-size: 9.5pt;
}
.q-ps td {
  padding: 1.5mm 3mm;
  border-bottom: 1px solid #e5e7eb;
  font-variant-numeric: tabular-nums;
}
.q-ps .pl { text-align: left; color: #374151; }
.q-ps .pv { text-align: right; font-weight: 600; }
.q-ps .discount-row td { color: #dc2626; }
.q-ps .grand-row td {
  font-size: 11pt;
  font-weight: 800;
  color: #0c4a6e;
  background: #f0f9ff;
  border-top: 2px solid #0c4a6e;
  border-bottom: 2px solid #0c4a6e;
  padding: 2.5mm 3mm;
}

/* ---- Notes ---- */
.q-notes {
  padding: 3mm 4mm;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 2px;
  font-size: 8pt;
  line-height: 1.65;
  color: #4b5563;
}
.q-notes-title {
  font-weight: 700;
  color: #111827;
  font-size: 8.5pt;
  margin-bottom: 1mm;
  letter-spacing: 0.05em;
}
.q-notes-body { white-space: pre-wrap; }

/* ========== Tablet (768px+) — 2カラム: 入力 / プレビュー ========== */
@media (min-width: 768px) {
  .topbar { padding: 0 20px; }
  .topbar-title { font-size: 16px; }
  .view-switcher { display: none; }

  .app-layout { flex-direction: row; }
  .panel-left, .panel-right {
    display: flex !important;
    height: calc(100vh - var(--topbar-h));
  }
  .panel-left {
    width: 400px;
    min-width: 400px;
    border-right: 1px solid var(--border-light);
  }
  .panel-right { flex: 1; min-width: 0; }
  /* 右パネル(利益)はまだ表示しない (タブレット域) */
  .panel-profit { display: none; }

  body.fullscreen-preview .panel-left { display: none !important; }
  body.fullscreen-preview .panel-right { flex: 1; }

  .form-actions { display: flex; }
  .mobile-actions { display: none !important; }

  .quote-paper { transform: none; margin-bottom: 0; }
}

/* ========== Desktop (1280px+) — 3カラム: 入力 / プレビュー / 利益 ========== */
@media (min-width: 1280px) {
  .panel-left { width: 420px; min-width: 420px; }
  .panel-profit {
    display: flex !important;
    width: 320px;
    min-width: 320px;
    height: calc(100vh - var(--topbar-h));
  }
  body.client-mode .panel-profit { display: none !important; }
  body.fullscreen-preview .panel-profit { display: none !important; }

  .tier-card { padding: 20px; }
  .tier-price { font-size: 28px; }
}

/* ========== Print ========== */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff; margin: 0; padding: 0; overflow: visible; }
  .topbar, .panel-left, .preview-toolbar, .mobile-actions { display: none !important; }
  .app-layout { position: static; top: 0; display: block; }
  .panel-right { width: 100%; height: auto; overflow: visible; display: block !important; background: #fff; }
  .preview-scroll { padding: 0; overflow: visible; }
  .quote-paper {
    box-shadow: none;
    width: 210mm;
    min-height: 297mm;
    transform: none !important;
    margin: 0 !important;
    page-break-inside: avoid;
  }
}
