:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --line: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
  --doc-header-bg: transparent;
  --doc-header-text: #1d1d1f;
  --doc-drop-border: rgba(0, 113, 227, 0.25);
  --doc-drop-bg: rgba(0, 113, 227, 0.03);
}

* { box-sizing: border-box; }
body.quote-app {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.35s ease;
}

body.quote-app[data-theme="white"] { --bg: #f5f5f7; }
body.quote-app[data-theme="brand"] {
  --bg: #eef1f4;
  background-image: url("/photo/mobilebuttonbackground.jpeg?v=3");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}
body.quote-app[data-theme="linen"] { --bg: #f3efe8; }
body.quote-app[data-theme="slate"] { --bg: #dce1e8; }
body.quote-app[data-theme="ivory"] { --bg: #f7f3ea; }

.hidden { display: none !important; }

.quote-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.quote-topbar h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.quote-topbar-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.quote-no { font-size: 0.78rem; color: var(--muted); background: #f2f2f7; padding: 0.2rem 0.55rem; border-radius: 999px; }
.back-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.topbar-nav-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
  background: rgba(0, 113, 227, 0.08);
}
.topbar-nav-link:hover { background: rgba(0, 113, 227, 0.14); text-decoration: none; }
.quote-topbar-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; }
.icon-tool {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #374151;
}
.icon-tool:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-tool:not(:disabled):hover { background: #f3f4f6; }
.icon-tool.icon-tool-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.icon-tool.icon-tool-primary:hover { background: #1d4ed8; }
.icon-tool.icon-tool-accent { background: #111827; color: #fff; border-color: #111827; }
.icon-tool.icon-tool-accent:hover { background: #374151; }
.icon-tool.active { background: #fef3c7; border-color: #f59e0b; }
a.icon-tool { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.icon-inline { width: 30px; height: 30px; font-size: 0.95rem; margin-right: 0.2rem; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.48rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.accent { background: #111827; color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn.tiny { padding: 0.2rem 0.45rem; font-size: 0.75rem; }
.pill-select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.42rem 0.55rem;
  font-size: 0.82rem;
  background: #fff;
}

.quote-workspace {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: 1rem;
  padding: 0 1rem 1rem;
  height: calc(100vh - 64px);
  min-height: 0;
  overflow: hidden;
}

.catalog-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head h2 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.panel-hint { margin: 0 0 0.65rem; font-size: 0.72rem; color: var(--muted); line-height: 1.4; }
#catalogSearch {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}
.catalog-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  align-content: start;
  padding: 0.15rem;
}
.catalog-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.4rem;
  background: #fafafa;
  cursor: grab;
  transition: transform 0.12s, box-shadow 0.12s;
}
.catalog-card:hover { transform: none; box-shadow: none; }
.catalog-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}
.catalog-card .cc-id { font-size: 0.62rem; color: var(--muted); font-weight: 600; }
.catalog-card .cc-title { font-size: 0.68rem; font-weight: 600; margin-top: 0.15rem; line-height: 1.2; }
.catalog-card .cc-sub { font-size: 0.62rem; color: var(--muted); }

.quote-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.quote-document {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: none;
  transition: border-color 0.35s, box-shadow 0.35s;
  display: flex;
  flex-direction: column;
}
.quote-frozen-block {
  flex-shrink: 0;
  padding: 0 1.25rem;
  padding-top: 1.25rem;
}
.quote-grid-scroll {
  flex: 1;
  min-height: 420px;
  overflow: auto;
  padding: 0 1rem 1rem;
}
.quote-frozen-footer {
  flex-shrink: 0;
  margin: 0 1.25rem 1rem;
}

.quote-document.theme-white {
  border-color: #e5e7eb;
  box-shadow: none;
  background: #fff;
}
.quote-document.theme-white .quote-doc-header {
  background: #fff;
  color: #1d1d1f;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  margin: 0 -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.quote-document.theme-white .logo-upload-btn {
  border-color: #d1d5db;
  background: #f9fafb;
  color: #374151;
}
.quote-document.theme-white .quote-drop-zone {
  border-color: #d1d5db;
  background: #fafafa;
}

.quote-document.theme-brand {
  border-color: #cbd5e1;
  background: #fff url("/photo/mobilebuttonbackground.jpeg?v=3") center center / cover no-repeat;
}
.quote-document.theme-brand .quote-doc-header {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  color: #1d1d1f;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  margin: 0 -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.quote-document.theme-brand .logo-upload-btn {
  border-color: #d1d5db;
  background: #fff;
  color: #374151;
}
.quote-document.theme-brand .quote-drop-zone {
  border-color: rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.88);
}
.quote-document.theme-brand .quote-grid-wrap {
  background: rgba(255,255,255,0.96);
}


.quote-document.theme-linen {
  border-color: #d4c4b0;
  box-shadow: 0 12px 40px rgba(139, 115, 85, 0.12);
}
.quote-document.theme-linen .quote-doc-header {
  background: linear-gradient(135deg, #8b7355 0%, #a89078 100%);
  color: #fff;
  margin: 0 -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.quote-document.theme-linen .quote-doc-header .header-input,
.quote-document.theme-linen .quote-doc-header .header-note { color: #fff; }
.quote-document.theme-linen .quote-doc-header .header-note::placeholder,
.quote-document.theme-linen .quote-doc-header .header-input::placeholder { color: rgba(255,255,255,0.65); }
.quote-document.theme-linen .quote-doc-header .header-meta { color: rgba(255,255,255,0.85); }
.quote-document.theme-linen .quote-drop-zone {
  border-color: #c4b5a0;
  background: #faf8f5;
}

.quote-document.theme-slate {
  border-color: #94a3b8;
  box-shadow: 0 12px 40px rgba(30, 41, 59, 0.18);
}
.quote-document.theme-slate .quote-doc-header {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #f8fafc;
  margin: 0 -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.quote-document.theme-slate .quote-doc-header .header-input,
.quote-document.theme-slate .quote-doc-header .header-note { color: #f8fafc; }
.quote-document.theme-slate .quote-doc-header .header-input::placeholder,
.quote-document.theme-slate .quote-doc-header .header-note::placeholder { color: rgba(248,250,252,0.55); }
.quote-document.theme-slate .quote-doc-header .header-meta { color: rgba(248,250,252,0.8); }
.quote-document.theme-slate .quote-drop-zone {
  border-color: #64748b;
  background: #f1f5f9;
}

.quote-document.theme-ivory {
  border-color: #d4af37;
  box-shadow: 0 12px 40px rgba(180, 140, 40, 0.14);
}
.quote-document.theme-ivory .quote-doc-header {
  background: linear-gradient(135deg, #b8860b 0%, #d4af37 55%, #f0e6c8 100%);
  color: #3d2f0a;
  margin: 0 -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.quote-document.theme-ivory .quote-doc-header .header-meta { color: #5c4a12; }
.quote-document.theme-ivory .quote-drop-zone {
  border-color: #d4af37;
  background: #fffef8;
}

.quote-doc-header {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) minmax(150px, auto) minmax(130px, auto);
  gap: 1rem;
  align-items: start;
  padding-bottom: 1rem;
  margin-bottom: 0;
  border-bottom: none;
}
.banner-to-col { display: flex; flex-direction: column; gap: 0.5rem; }
.banner-to-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #c45c26;
}
.banner-quote-col { text-align: right; }
.quote-sheet-title {
  margin: 0 0 0.5rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #c45c26;
}
.quote-meta-list { display: flex; flex-direction: column; gap: 0.35rem; }
.quote-meta-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.82rem;
}
.quote-meta-row > span:first-child {
  color: #c45c26;
  font-weight: 600;
  text-align: left;
}
.quote-meta-row .banner-input,
.quote-no-display {
  text-align: right;
  font-size: 0.88rem;
}
.quote-no-display { font-weight: 700; color: #111827; }
.banner-settings-col { font-size: 0.78rem; }
.quote-client-banner {
  padding: 1.1rem 1.25rem 1rem;
  margin: 0 -1.25rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
}
.quote-document.theme-white .quote-client-banner {
  background: #fff;
}
.client-banner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
}
.banner-field { display: flex; flex-direction: column; gap: 0.2rem; }
.banner-field-wide { grid-column: 1 / -1; }
.banner-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.banner-input {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font-size: 0.92rem;
  background: #fff;
  color: #111827;
  width: 100%;
}
.banner-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.banner-meta-col { align-self: start; }

.quote-summary {
  margin: 0 1.25rem 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fafafa 0%, #fff 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.summary-rows { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.65rem; }
.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #4b5563;
}
.summary-grand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.65rem 0 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}
.summary-grand strong { font-size: 1.15rem; color: #111827; }
.trade-terms {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
}
.terms-edit-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
  width: 100%;
}
.terms-textarea {
  width: 100%;
  min-height: 4.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  font-size: 0.88rem;
  font-family: inherit;
  resize: vertical;
  line-height: 1.45;
}
.terms-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}
.terms-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.term-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 0.82rem;
  cursor: pointer;
}
.term-chip:has(input:checked) {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.tabulator-row.quote-surcharge-row {
  background: #fffbeb !important;
}
.tabulator-row.quote-surcharge-row .tabulator-cell {
  border-top: 2px solid #fcd34d;
}
.quote-document > .quote-frozen-footer {
  margin-top: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.logo-zone { display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-start; flex-shrink: 0; }
.logo-stage {
  position: relative;
  width: 148px;
  min-height: 76px;
  border: 1px dashed rgba(128, 128, 128, 0.45);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.35);
}
.quote-document.theme-white .logo-stage {
  border-color: #d1d5db;
  background: #f9fafb;
}
.quote-logo {
  position: absolute;
  left: var(--logo-x, 6px);
  top: var(--logo-y, 6px);
  width: calc(120px * var(--logo-scale, 1));
  height: auto;
  max-height: calc(80px * var(--logo-scale, 1));
  object-fit: contain;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  padding: 4px;
  cursor: grab;
  z-index: 2;
  touch-action: none;
  user-select: none;
}
.quote-logo.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.quote-logo.dragging { cursor: grabbing; z-index: 5; }
.logo-resize-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  right: 4px;
  bottom: 28px;
  border-radius: 4px;
  background: #2563eb;
  border: 2px solid #fff;
  cursor: nwse-resize;
  z-index: 5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.logo-resize-handle.hidden { display: none !important; }
.logo-scale-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.68rem;
  color: inherit;
  max-width: 148px;
}
.logo-scale-wrap input[type="range"] { width: 100%; }
.logo-scale-wrap.hidden { display: none !important; }
.logo-upload-btn {
  position: absolute;
  left: 6px;
  bottom: 6px;
  z-index: 4;
  border: 1px dashed rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
  color: inherit;
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  cursor: pointer;
}
.theme-ivory .logo-upload-btn {
  border-color: rgba(61,47,10,0.35);
  background: rgba(255,255,255,0.4);
}
.header-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 1rem;
  padding: 0.25rem 0;
  outline: none;
}
.header-input.title { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.header-input:focus, .header-note:focus { background: rgba(255, 255, 255, 0.12); border-radius: 8px; }
.header-note {
  width: 100%;
  border: none;
  resize: vertical;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}
.header-meta {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.78rem;
}
.header-meta label { display: flex; flex-direction: column; gap: 0.2rem; }

.quote-drop-zone {
  border: 2px dashed var(--doc-drop-border, rgba(0, 113, 227, 0.25));
  border-radius: 12px;
  padding: 0.65rem;
  margin-bottom: 0.75rem;
  min-height: 72px;
  background: var(--doc-drop-bg, rgba(0, 113, 227, 0.03));
}
.drop-hint { margin: 0 0 0.5rem; font-size: 0.72rem; color: var(--muted); text-align: center; }
.quote-line-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 48px;
}
.quote-line-card {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: grab;
  font-size: 0.72rem;
}
.quote-line-card img { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; }

.quote-grid-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-height: 400px;
}
.tabulator { border: none; font-size: 0.85rem; min-width: 100%; width: 100%; }
.tabulator .tabulator-row .tabulator-cell { padding: 8px 10px; }
.tabulator .tabulator-col { min-width: 64px; }
#quoteGrid .tabulator-row.tabulator-moving {
  display: none !important;
}
#quoteGrid .tabulator-row.tabulator-row-placeholder {
  display: inline-flex !important;
  min-height: 50px !important;
  opacity: 1 !important;
  background: #eff6ff !important;
  border-top: 2px solid #3b82f6 !important;
  border-bottom: none !important;
  box-shadow: none !important;
}
#quoteGrid .tabulator-row.tabulator-row-moving {
  background: #f8fafc !important;
  border-top: 1px solid #e2e8f0 !important;
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: none !important;
}
.logo-gallery-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.25rem;
}
.logo-gallery-select { width: 100%; max-width: 200px; margin-bottom: 0.35rem; }
.logo-gallery-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.tabulator .tabulator-header { background: #f5f5f7; border-bottom: 1px solid var(--line); }
.tabulator .tabulator-cell { cursor: text; }
.tabulator-row.tabulator-selectable:hover { background: #f0f7ff !important; }

.library-wrap { display: inline-flex; flex-direction: column; gap: 0.15rem; font-size: 0.72rem; color: var(--muted); margin-left: 0.35rem; }
.library-label { font-weight: 600; color: #374151; }
.library-hint { font-size: 0.72rem; color: var(--muted); max-width: 140px; line-height: 1.3; }

.quote-grid-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  padding: 0.5rem 1.25rem 0.35rem;
}
.grid-toolbar-hint { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

/* Draft-only staging (hidden in PDF) */
body.pdf-export .draft-only,
body.pdf-export .trash-zone,
body.pdf-export .quote-grid-toolbar,
body.pdf-export .quote-summary { display: none !important; }

body.pdf-export .quote-grid-scroll {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}
body.pdf-export .quote-grid-wrap,
body.pdf-export .tabulator,
body.pdf-export .tabulator-tableholder {
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}
body.pdf-export #quoteDocument {
  overflow: visible !important;
  height: auto !important;
}
body.pdf-export .quote-doc-header .header-meta { display: none !important; }

/* Sharper product images in PDF (screen uses 40px; export rasterizes larger) */
body.pdf-export .tabulator-cell img {
  width: 80px !important;
  height: 80px !important;
  max-width: 80px !important;
  max-height: 80px !important;
  object-fit: contain !important;
  image-rendering: auto;
}
body.pdf-export .logo-stage {
  border: none;
  background: transparent;
  min-height: 0;
}
body.pdf-export .logo-upload-btn { display: none !important; }
body.pdf-export .quote-logo {
  max-width: 200px !important;
  max-height: 90px !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: none !important;
}
body.pdf-export .quote-logo.hidden {
  display: none !important;
}
body.pdf-export #quoteDocument {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Full-width MOQ / text rows */
.tabulator-row.quote-text-row .tabulator-cell { display: none !important; }
.tabulator-row.quote-text-row .tabulator-cell.tabulator-cell-span {
  display: flex !important;
  align-items: center;
  flex: 1 1 100% !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 2.2rem;
  padding: 0.35rem 0.5rem !important;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: pre-wrap;
}
.tabulator-row.quote-text-row { background: #f8fafc !important; }
.text-row-editor {
  width: 100%;
  min-height: 2.5rem;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  resize: vertical;
}

.trash-zone {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 110px;
  height: 110px;
  border-radius: 20px;
  border: 2px dashed #ef4444;
  background: rgba(254, 226, 226, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #b91c1c;
  font-size: 0.72rem;
  z-index: 40;
  transition: transform 0.15s, background 0.15s;
}
.trash-zone.sortable-drag-over { transform: scale(1.05); background: #fecaca; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 100;
}
.toast.error { background: #b91c1c; }

.quote-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: 480px;
  width: calc(100% - 2rem);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.quote-dialog::backdrop { background: rgba(0,0,0,0.35); }
.quote-dialog form { padding: 1.25rem; }
.quote-dialog h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.dialog-hint { margin: 0 0 1rem; font-size: 0.78rem; color: var(--muted); }
.column-manager-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 320px; overflow-y: auto; margin-bottom: 0.75rem; }
.column-manager-row {
  display: grid;
  grid-template-columns: auto 1fr 1fr auto auto auto;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.78rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}
.column-manager-row input { border: 1px solid var(--line); border-radius: 6px; padding: 0.3rem 0.45rem; font-size: 0.78rem; }
.column-manager-row .col-key { color: var(--muted); font-size: 0.7rem; min-width: 4rem; }
.column-manager-row button { border: none; background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 0.2rem 0.45rem; }
.column-manager-row button.danger { color: #b91c1c; }
.add-field-row { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.add-field-row input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.55rem; }
.custom-field-list { list-style: none; padding: 0; margin: 0 0 1rem; font-size: 0.8rem; }
.custom-field-list li { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.custom-field-list button { background: none; border: none; color: #b91c1c; cursor: pointer; font-size: 0.75rem; }
.pdf-preview-panel .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

.pdf-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}
.pdf-preview-modal.hidden {
  display: none !important;
}
.pdf-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  cursor: pointer;
}
.pdf-preview-panel {
  position: relative;
  z-index: 1;
  width: min(99vw, 920px);
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: none;
  overflow: hidden;
}
.pdf-preview-head { padding: 1rem 1.25rem 0.5rem; }
.pdf-preview-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.dialog-close-x {
  border: none;
  background: #f3f4f6;
  color: #374151;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.dialog-close-x:hover { background: #e5e7eb; }
.pdf-margin-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 0 1.25rem 0.75rem;
  font-size: 0.8rem;
}
.pdf-margin-bar label { display: flex; align-items: center; gap: 0.35rem; }
.pdf-margin-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  margin-right: 0.25rem;
}
.pdf-margin-bar input {
  width: 3.2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.35rem;
}
.pdf-zoom-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 10rem;
}
.pdf-zoom-label input[type="range"] { width: 6rem; }
.pdf-preview-size-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}
.pdf-preview-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  max-height: calc(96vh - 140px);
  background: #fff;
  padding: 0.75rem 1rem 1.25rem;
}
.pdf-preview-paper {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  margin: 0 auto;
  background: #e5e7eb;
  box-shadow: none;
  border: none;
  overflow: auto;
}
.pdf-preview-paper .pdf-export-clone {
  width: 794px;
  max-width: 794px;
  margin: 0 auto;
  flex-shrink: 0;
}
body.pdf-preview-open { overflow: hidden; }
.pdf-export-clone {
  width: 100%;
  min-height: auto;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: #111827;
}
.pdf-export-clone.quote-document {
  border-radius: 0 !important;
  overflow: visible !important;
}
.pdf-export-clone .pdf-clone-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #e5e7eb;
  align-items: start;
}
.pdf-clone-logo-col .pdf-clone-logo {
  object-fit: contain;
  max-width: 200px;
  max-height: 100px;
}
.pdf-clone-client .pdf-client-line {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.pdf-clone-client .pdf-k {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-right: 0.35rem;
}
.pdf-clone-client .pdf-client-sub { margin: 0.25rem 0 0; font-size: 0.82rem; color: #4b5563; }
.pdf-section-title {
  margin: 1rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}
.pdf-surcharge-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-bottom: 0.75rem;
}
.pdf-surcharge-table th,
.pdf-surcharge-table td {
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.45rem;
}
.pdf-surcharge-table th { background: #fffbeb; }
.pdf-surcharge-table .sur-desc { font-weight: 500; }
.pdf-surcharge-table .num,
.pdf-quote-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pdf-quote-table tfoot .label { text-align: right; font-weight: 600; color: #374151; }
.pdf-subtotal-row td { background: #f9fafb; }
.pdf-summary-block {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 2px solid #111827;
}
.pdf-grand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}
.pdf-grand strong { font-size: 1.2rem; }
.pdf-terms { font-size: 0.82rem; color: #374151; margin-bottom: 0.35rem; }
.pdf-footnote { font-size: 0.78rem; color: #6b7280; margin: 0.35rem 0 0; }
.pdf-quote-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.pdf-quote-table th,
.pdf-quote-table td {
  border: 1px solid #d1d5db;
  padding: 0.35rem 0.45rem;
  vertical-align: middle;
  text-align: left;
}
.pdf-quote-table th { background: #f3f4f6; font-weight: 600; }
.pdf-quote-table tr.text-row td {
  font-weight: 500;
  background: #f8fafc;
}
.pdf-quote-table .pdf-cell-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
}
.pdf-loading { padding: 2rem; text-align: center; color: #6b7280; }

.pdf-pro-quote {
  --pdf-accent: #c45c26;
  padding: 0;
  font-size: 0.82rem;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}
.pdf-pro-quote.pdf-balanced {
  font-size: 11pt;
  line-height: 1.35;
}
.pdf-pro-sheet {
  padding: 8mm 3mm 6mm;
  border: none;
  max-width: none;
  width: 100%;
  margin: 0;
}
.pdf-pro-logo { margin-bottom: 0.65rem; }
.pdf-pro-logo-img { object-fit: contain; max-height: 88px; }
.pdf-pro-quote.pdf-balanced .pdf-pro-top { margin-bottom: 0.85rem; }
.pdf-pro-quote.pdf-balanced .pdf-pro-quote-title { font-size: 1.85rem; }
.pdf-pro-quote.pdf-balanced .pdf-pro-customer { font-size: 1.12rem; }
.pdf-pro-quote.pdf-balanced .pdf-pro-lines thead th {
  padding: 0.35rem 0.45rem;
  font-size: 9.5pt;
}
.pdf-pro-quote.pdf-balanced .pdf-pro-lines td {
  padding: 0.35rem 0.45rem;
  font-size: 10pt;
}
.pdf-pro-quote.pdf-balanced .pdf-line-img {
  width: 58px;
  height: 58px;
}
.pdf-pro-quote.pdf-balanced .pdf-pro-footer {
  margin-top: 0.65rem;
  font-size: 9.5pt;
}
.pdf-pro-k {
  color: var(--pdf-accent);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pdf-pro-customer {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.2rem 0 0.15rem;
}
.pdf-pro-contact,
.pdf-pro-brand {
  font-size: 0.8rem;
  color: #374151;
  margin-top: 0.15rem;
}
.pdf-pro-quote-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--pdf-accent);
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
  line-height: 1.1;
}
.pdf-pro-meta .pdf-pro-k { text-align: left; }
.pdf-pro-lines {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}
.pdf-pro-lines thead th {
  background: var(--pdf-accent);
  color: #fff;
  font-weight: 600;
  padding: 0.45rem 0.55rem;
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
.pdf-pro-lines thead th.col-money-h { text-align: right; }
.pdf-pro-lines td {
  border-bottom: 1px solid #e8e0d8;
  padding: 0.4rem 0.55rem;
  vertical-align: top;
}
.pdf-pro-lines .col-img { text-align: center; vertical-align: middle; }
.pdf-line-img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.pdf-pro-lines .col-desc {
  text-align: left;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.pdf-pro-lines .col-money { text-align: right; white-space: nowrap; }
.pdf-pro-lines .col-money { text-align: right; font-variant-numeric: tabular-nums; }
.pdf-pro-terms-body { margin: 0.35rem 0 0.5rem; line-height: 1.5; color: #374151; }
.pdf-pro-price-term { margin: 0.2rem 0; color: #4b5563; font-size: 0.8rem; }
.pdf-pro-empty { text-align: center; color: #9ca3af; padding: 1rem !important; }
.pdf-pro-totals {
  margin-left: auto;
  width: min(100%, 14rem);
  margin-bottom: 1.25rem;
}
.pdf-pro-total-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
  font-variant-numeric: tabular-nums;
}
.pdf-pro-total-row .pdf-pro-k { text-transform: none; font-size: 0.8rem; }
.pdf-pro-grand {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 2px solid var(--pdf-accent);
  font-weight: 700;
}
.pdf-pro-grand strong { font-size: 1.05rem; }
.pdf-pro-footer { margin-top: 0.5rem; }
.pdf-pro-footer > .pdf-pro-k { margin-bottom: 0.35rem; }
.pdf-pro-footer p { margin: 0.25rem 0; color: #374151; line-height: 1.45; }
.pdf-pro-thanks { margin-top: 0.35rem !important; font-weight: 600; }
.pdf-pro-terms-line { margin: 0.15rem 0; font-size: inherit; }
.pdf-pro-terms-gap { margin-top: 3.2rem; }
.pdf-pro-note { font-size: 0.78rem; color: #6b7280; }

.pdf-bg-layer {
  background: #fff url("/photo/mobilebuttonbackground.jpeg?v=3") center center / cover no-repeat;
  pointer-events: none;
}
.pdf-export-clone.pdf-pro-quote.theme-brand .pdf-pro-sheet,
.pdf-export-clone.pdf-pro-quote.theme-brand-mobile .pdf-pro-sheet {
  background: transparent;
}
.pdf-pro-quote.pdf-compact.pdf-balanced {
  font-size: 9pt;
  line-height: 1.28;
}
.pdf-pro-quote.pdf-compact .pdf-pro-top { margin-bottom: 0.55rem; }
.pdf-pro-quote.pdf-compact .pdf-pro-quote-title { font-size: 1.45rem; margin-bottom: 0.25rem; }
.pdf-pro-quote.pdf-compact .pdf-pro-lines td,
.pdf-pro-quote.pdf-compact .pdf-pro-lines thead th {
  padding: 0.28rem 0.4rem;
  font-size: 8.5pt;
}
.pdf-pro-quote.pdf-compact .pdf-line-img {
  width: 44px;
  height: 44px;
}
.pdf-pro-quote.pdf-compact .pdf-pro-footer { margin-top: 0.35rem; }
.pdf-pro-quote.pdf-compact .pdf-pro-terms-gap { margin-top: 2rem; }
.pdf-pro-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38%;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
  align-items: start;
}
.pdf-pro-quote-head {
  text-align: right;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.pdf-pro-meta {
  display: grid;
  grid-template-columns: minmax(4.5rem, 42%) minmax(0, 1fr);
  gap: 0.2rem 0.35rem;
  margin-bottom: 0.2rem;
  text-align: right;
  font-size: 0.92em;
}
.pdf-pro-lines col.w-desc { width: 58%; }
.pdf-pro-lines col.w-price { width: 29%; }
.pdf-pro-lines col.w-photo { width: 13%; }

body.quote-records-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body.quote-records-page .quote-topbar {
  flex-shrink: 0;
}
.quote-records-page-panel {
  margin: 0.5rem 0.75rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.records-page-hint {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}
.topbar-text-btn {
  padding: 0.35rem 0.65rem !important;
  font-size: 0.78rem !important;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.records-count {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}
.quote-records-grid {
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.quote-records-grid .tabulator {
  border: none;
  font-size: 0.82rem;
}
.quote-records-grid .tabulator-header {
  background: #f5f5f7;
  border-bottom: 1px solid var(--line);
}
.quote-records-grid .tabulator-col {
  border-right: 1px solid var(--line);
}
.quote-records-grid .tabulator-row {
  border-bottom: 1px solid var(--line);
}
.quote-records-grid .tabulator-row:nth-child(even) {
  background: #fafafa;
}
.quote-records-grid .tabulator-row:hover {
  background: #f0f7ff !important;
}
.quote-records-grid .tabulator-cell {
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  padding: 6px 8px;
}
.records-cell-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  background: #f9fafb;
}
.records-desc-cell {
  display: block;
  line-height: 1.35;
  word-break: break-word;
}
.records-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.records-action-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
}
.records-action-btn:hover { background: #f3f4f6; }
.records-action-pdf {
  background: #111827;
  color: #fff;
  border-color: #111827;
}
.records-action-pdf:hover { background: #374151; }
.records-no-pdf {
  font-size: 0.68rem;
  color: #9ca3af;
}

.quote-records-panel {
  margin: 0 0.75rem 0.5rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.quote-records-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.quote-records-toolbar h2 {
  margin: 0;
  font-size: 0.95rem;
  margin-right: 0.35rem;
}
.records-month-label {
  font-size: 0.72rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.records-search { min-width: 220px; flex: 1; }
.quote-records-wrap {
  overflow: auto;
  max-height: 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.quote-records-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  table-layout: fixed;
  font-size: 0.8rem;
}
.quote-records-table th,
.quote-records-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.quote-records-table th:last-child,
.quote-records-table td:last-child { border-right: none; }
.quote-records-table th {
  background: #f3f4f6;
  font-weight: 600;
  color: #374151;
  position: sticky;
  top: 0;
  z-index: 1;
}
.quote-records-table .col-desc {
  word-break: break-word;
  overflow-wrap: anywhere;
}
.quote-records-table .col-actions {
  white-space: nowrap;
  width: 8.5rem;
}
.quote-records-table .col-actions .btn { margin-right: 0.25rem; }
.quote-record-row { cursor: pointer; }
.quote-record-row:hover { background: #f0f7ff; }
.quote-record-row.quote-record-active { background: #eff6ff; }
.quote-records-empty {
  text-align: center;
  color: var(--muted);
  padding: 1rem !important;
}

@media (max-width: 960px) {
  .quote-workspace { grid-template-columns: 1fr; }
  .catalog-panel { max-height: 280px; }
  .quote-doc-header { grid-template-columns: 1fr; }
}
