/* ==========================================================================
   QuoteStudio Pro — Designer, Minimal, Responsive Quotation Studio
   ========================================================================== */

:root {
  --bg-app: #f3f5f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --accent: #0ea5e9;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-paper: 0 20px 50px rgba(15, 23, 42, 0.14);

  /* Quotation Theme Variables (dynamically updated by user) */
  --q-accent: #5e72e4;
  --q-header-tint: #e8ecfa;
  --q-photo-height: 125px;
  --q-font-scale: 1;
  --app-font-scale: 1;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Overall App Font Scale */
.studio-topbar,
.quotes-sidebar,
.editor-pane {
  zoom: var(--app-font-scale, 1);
}
   ========================================================================== */
.studio-topbar {
  height: 58px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

.brand-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  background: #eef2ff;
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 4px;
}

.save-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.save-indicator .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.save-indicator.saving .status-dot {
  background: var(--warning);
}

.view-switcher {
  display: flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.view-tab {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-tab.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.font-size-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 4px;
}

.dropdown-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn svg, .icon-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-accent {
  background: #0284c7;
  color: #fff;
}
.btn-accent:hover { background: #0369a1; }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-subtle); }

.btn-ghost {
  background: transparent;
  color: var(--text-main);
}
.btn-ghost:hover { background: var(--bg-subtle); }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-subtle); }

.icon-btn-sm {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  cursor: pointer;
  font-weight: 700;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.btn-link.danger { color: var(--danger); }

.mobile-only { display: none; }

/* ==========================================================================
   3-Pane Studio Workspace
   ========================================================================== */
.studio-workspace {
  display: grid;
  grid-template-columns: 280px minmax(340px, 430px) 1fr;
  height: calc(100vh - 58px);
  height: calc(100dvh - 58px);
  overflow: hidden;
}

@media (min-width: 961px) {
  .studio-workspace[data-view="editor"] {
    grid-template-columns: 280px 1fr;
  }
  .studio-workspace[data-view="editor"] .preview-pane { display: none; }

  .studio-workspace[data-view="preview"] {
    grid-template-columns: 280px 1fr;
  }
  .studio-workspace[data-view="preview"] .editor-pane { display: none; }
}

/* Left Sidebar */
.quotes-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.count-pill {
  background: #eef2ff;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.sidebar-controls {
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 28px 0 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  background: var(--bg-subtle);
  outline: none;
}
.search-box input:focus {
  border-color: var(--primary);
  background: #fff;
}

.clear-btn {
  position: absolute;
  right: 6px;
  border: none;
  background: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.filter-row select {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 0 6px;
  background: var(--bg-surface);
  color: var(--text-main);
}

.quotes-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quote-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.15s ease;
}

.quote-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.quote-card.active {
  border-color: var(--primary);
  background: #f5f7ff;
}

.qc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.qc-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.qc-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}
.qc-status.approved { background: #dcfce7; color: #166534; }
.qc-status.sent { background: #dbeafe; color: #1e40af; }
.qc-status.draft { background: #fef3c7; color: #92400e; }

.qc-client {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.qc-total {
  font-weight: 700;
  color: var(--text-main);
}

.qc-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.qc-actions button {
  flex: 1;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}
.qc-actions button:hover { background: var(--bg-subtle); }
.qc-actions button.del:hover { color: var(--danger); border-color: #fecaca; background: #fef2f2; }

/* ==========================================================================
   Center Editor Pane
   ========================================================================== */
.editor-pane {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.editor-tabs {
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  gap: 2px;
  overflow-x: auto;
}

.etab {
  border: none;
  background: none;
  padding: 12px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.etab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.editor-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.epanel { display: none; flex-direction: column; gap: 14px; }
.epanel.active { display: flex; }

.card-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 10px;
}
.form-grid.two-col { grid-template-columns: 1fr 1fr; }
.form-grid.three-col { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }

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

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select,
.status-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: #fff;
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.field input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}

.compact-num {
  margin-top: 4px;
  height: 28px;
  font-size: 12px !important;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
}

.hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.upload-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--bg-subtle);
  text-align: center;
}

.upload-preview-box {
  min-height: 54px;
  max-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-muted);
  width: 100%;
}

.upload-preview-box img {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
}

/* Items Editor */
.items-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.items-toolbar h3 { margin: 0; font-size: 14px; }

.items-editor-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-editor-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 999px;
}

.item-card-btns {
  display: flex;
  gap: 4px;
}

.item-card-btns button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  cursor: pointer;
}
.item-card-btns button.del:hover { color: var(--danger); border-color: #fecaca; }

.item-photo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-thumb {
  width: 76px;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
}

.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Terms Editor */
.terms-editor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.term-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.term-row textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
}

.term-row button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 5px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--danger);
}

/* ==========================================================================
   Right Preview Pane & Scaled A4 Sheet
   ========================================================================== */
.preview-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: #e5e9f2;
}

.preview-toolbar {
  height: 40px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.preview-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-hd {
  background: #ecfdf5;
  color: #047857;
  font-weight: 700;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #a7f3d0;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-viewport {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.paper-scale-wrapper {
  width: 794px;
  transform-origin: top left;
  transition: transform 0.12s ease;
  flex-shrink: 0;
}

/* ==========================================================================
   THE A4 QUOTATION SHEET (Exact 210mm x 297mm = 794px x 1123px at 96 DPI)
   ========================================================================== */
.quotation-sheet {
  width: 794px; /* Exact 210mm at 96dpi */
  min-height: 1123px; /* Exact 297mm at 96dpi (1:1.4142 A4 ratio) */
  background: #ffffff;
  box-shadow: var(--shadow-paper);
  color: #111827;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: visible;
}

/* Auto-Fit Compact Mode when content slightly exceeds 1 A4 page */
.quotation-sheet.compact-fit .q-header {
  padding: 12px 24px;
  min-height: 76px;
}
.quotation-sheet.compact-fit .q-body {
  padding: 10px 24px 14px;
  gap: 9px;
}
.quotation-sheet.compact-fit .q-meta-col {
  padding: 6px 10px;
  gap: 5px;
}
.quotation-sheet.compact-fit .q-table td {
  padding: 6px 8px;
  font-size: 12px;
}
.quotation-sheet.compact-fit .q-table th {
  padding: 6px 8px;
  font-size: 12px;
}
.quotation-sheet.compact-fit .q-item-photo {
  max-height: calc(var(--q-photo-height) * 0.72);
}
.quotation-sheet.compact-fit .q-brand-strip-wrap {
  padding: 4px 8px;
}
.quotation-sheet.compact-fit .q-terms-col,
.quotation-sheet.compact-fit .q-bank-col {
  padding: 8px 12px;
}
.quotation-sheet.compact-fit .q-terms-list {
  gap: 3px;
  font-size: 9.8px;
  line-height: 1.3;
}
.quotation-sheet.compact-fit .q-qr-card img {
  width: 92px;
  height: 92px;
}

.a4-page-guide {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed rgba(79, 70, 229, 0.45);
  pointer-events: none;
  z-index: 10;
}

.a4-page-guide span {
  position: absolute;
  right: 8px;
  top: -11px;
  background: #4f46e5;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
}

/* Header Banner with subtle vertical striped/gradient tint like PDF */
.q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 26px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.45) 0px,
      rgba(255, 255, 255, 0.45) 14px,
      rgba(255, 255, 255, 0) 14px,
      rgba(255, 255, 255, 0) 28px
    ),
    linear-gradient(135deg, #ffffff 0%, var(--q-header-tint) 65%, #dfe5f8 100%);
  border-bottom: 1px solid #d7def2;
  min-height: 98px;
}

.q-logo-slot {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.q-logo-slot img {
  display: block;
  max-width: 100%;
  cursor: pointer;
}

.q-logo-placeholder {
  border: 1.5px dashed #94a3b8;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 12px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
}

.q-company-contact {
  text-align: right;
  font-size: calc(12px * var(--q-font-scale, 1));
  line-height: 1.42;
  color: #1e293b;
  font-weight: 500;
  max-width: 340px;
}

.q-address {
  white-space: pre-line;
}

.q-website {
  text-decoration: underline;
  font-weight: 600;
}

.q-body {
  padding: 16px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

/* Metadata 3-Column Grid */
.q-meta-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  border: 1.25px solid #1e293b;
  background: #fff;
}

.q-meta-col {
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.q-meta-col + .q-meta-col {
  border-left: 1.25px solid #1e293b;
}

.q-meta-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: calc(12.5px * var(--q-font-scale, 1));
}

.q-meta-row.vertical {
  flex-direction: column;
  gap: 3px;
}

.q-meta-label {
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
}

.q-meta-val {
  font-weight: 500;
  color: #1e293b;
  min-width: 60px;
  word-break: break-word;
}

/* Items Table */
.q-table {
  width: 100%;
  border-collapse: collapse;
  border: 1.25px solid #1e293b;
  table-layout: fixed;
}

.q-table thead tr {
  background: var(--q-accent);
  color: #ffffff;
}

.q-table th {
  padding: 9px 10px;
  font-size: calc(13px * var(--q-font-scale, 1));
  font-weight: 700;
  text-align: center;
  border: 1.25px solid #1e293b;
}

.q-table th.col-img { width: 22%; }
.q-table th.col-desc { width: 29%; text-align: left; }
.q-table th.col-nos { width: 8%; }
.q-table th.col-qty { width: 10%; }
.q-table th.col-unit { width: 10%; }
.q-table th.col-price { width: 10%; }
.q-table th.col-total { width: 11%; }

.q-table td {
  border: 1.25px solid #1e293b;
  padding: 10px;
  vertical-align: top;
  font-size: calc(13px * var(--q-font-scale, 1));
  color: #0f172a;
}

.q-td-img {
  text-align: center;
  vertical-align: middle !important;
  padding: 7px !important;
}

.q-item-photo {
  max-width: 100%;
  max-height: var(--q-photo-height);
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto;
  cursor: pointer;
}

.q-item-no-photo {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #94a3b8;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
}
.q-item-no-photo:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f8fafc;
}

.q-td-total {
  position: relative;
  text-align: center;
  font-weight: 700;
  font-size: 13.5px;
}

.q-row-del-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #fecaca;
  background: #fff;
  color: var(--danger);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.q-table tbody tr:hover .q-row-del-btn {
  opacity: 1;
}

.q-inline-add-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.q-inline-add-btn {
  background: #f1f5f9;
  border: 1px dashed #94a3b8;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.q-inline-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eef2ff;
}

.q-td-desc {
  font-weight: 600;
  line-height: 1.45;
  white-space: pre-line;
}

.q-td-num {
  text-align: center;
  font-weight: 600;
  font-size: 13.5px;
}

.q-dim-sub {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  line-height: 1.3;
}

.q-inline-unit-select {
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 2px;
}
.q-inline-unit-select:hover, .q-inline-unit-select:focus {
  border-color: #cbd5e1;
  background: #f8fafc;
  outline: none;
}

.q-td-total {
  text-align: center;
  font-weight: 700;
  font-size: 13.5px;
}

.q-table tfoot td {
  padding: 8px 10px;
  font-size: 13.5px;
  font-weight: 700;
}

.q-total-label {
  text-align: right;
  color: var(--q-accent);
  padding-right: 16px !important;
}

.q-total-val {
  text-align: center;
  color: var(--q-accent);
  font-size: 14.5px !important;
}

/* Quotation Description / Note Box */
.q-note-box {
  border: 1.25px solid #1e293b;
  background: #f8fafc;
  padding: 8px 12px;
  font-size: calc(12px * var(--q-font-scale, 1));
  line-height: 1.42;
  color: #1e293b;
}
.q-note-box.is-empty {
  border-style: dashed;
  border-color: #cbd5e1;
  background: #ffffff;
}
.q-note-title {
  font-weight: 700;
  color: #0f172a;
  display: inline-block;
  margin-bottom: 2px;
}
.q-note-text {
  white-space: pre-line;
  min-height: 18px;
}
.q-note-text:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  font-style: italic;
}

/* Brand Strip PNG */
.q-brand-strip-wrap {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.q-brand-strip-wrap img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  cursor: pointer;
}

.q-strip-placeholder {
  font-size: 11.5px;
  color: #94a3b8;
  padding: 14px;
  cursor: pointer;
}

/* Bottom 2-Column Section */
.q-bottom-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  border: 1.25px solid #1e293b;
  background: #fff;
}

.q-terms-col, .q-bank-col {
  padding: 12px 14px;
}

.q-bank-col {
  border-left: 1.25px solid #1e293b;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.q-bottom-grid h4 {
  margin: 0 0 8px;
  font-size: calc(13.5px * var(--q-font-scale, 1));
  font-weight: 700;
  color: #0f172a;
}

.q-terms-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: calc(10.5px * var(--q-font-scale, 1));
  line-height: 1.38;
  color: #1e293b;
}

.q-bank-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: calc(12px * var(--q-font-scale, 1));
}

.q-bank-line {
  display: flex;
  gap: 6px;
}

.q-pay-sign-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.q-qr-card {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #fff;
}

.q-qr-card img {
  width: 112px;
  height: 112px;
  display: block;
  image-rendering: pixelated;
  cursor: pointer;
}

.q-scan-label {
  font-size: 9px;
  font-weight: 700;
  margin-top: 4px;
}

.q-upi-id {
  font-size: 8.5px;
  color: #334155;
  margin-top: 1px;
}

.q-sign-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  min-height: 90px;
}

.q-sign-img-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 4px;
}

.q-sign-img-wrap img {
  display: block;
  max-width: 100%;
  cursor: pointer;
}

.q-sign-line {
  width: 100%;
  border-top: 1px solid #334155;
  padding-top: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #1e293b;
}

.editable-inline {
  outline: none;
  border-radius: 3px;
  transition: background 0.12s ease;
}
.editable-inline:hover {
  background: rgba(79, 70, 229, 0.06);
}
.editable-inline:focus {
  background: rgba(79, 70, 229, 0.1);
  box-shadow: 0 0 0 1.5px rgba(79, 70, 229, 0.45);
}

/* Live Preview Interactive Resize Handles (.no-print) */
.q-resizable {
  position: relative;
}

.q-resize-handle {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 13px;
  height: 13px;
  background: #4f46e5;
  border: 2px solid #ffffff;
  border-radius: 3px;
  cursor: nwse-resize;
  opacity: 0.45;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 15;
  touch-action: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.q-resizable:hover > .q-resize-handle,
.q-resize-handle:hover,
.q-resize-handle:active {
  opacity: 1;
  transform: scale(1.15);
}

.q-table th,
.q-table td {
  position: relative;
}

.q-col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 9px;
  cursor: col-resize;
  z-index: 14;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-col-resizer::after {
  content: '';
  width: 2px;
  height: 55%;
  background: rgba(79, 70, 229, 0.25);
  border-radius: 2px;
  transition: background 0.15s ease, width 0.15s ease;
}
.q-table th .q-col-resizer::after {
  background: rgba(255, 255, 255, 0.55);
}
.q-col-resizer:hover::after,
.q-col-resizer:active::after {
  width: 3px;
  height: 90%;
  background: #4f46e5;
}

.q-row-resizer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 9px;
  cursor: row-resize;
  z-index: 14;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-row-resizer::after {
  content: '';
  height: 2px;
  width: 36px;
  background: rgba(79, 70, 229, 0.28);
  border-radius: 2px;
  transition: background 0.15s ease, width 0.15s ease;
}
.q-row-resizer:hover::after,
.q-row-resizer:active::after {
  height: 3px;
  width: 75%;
  background: #4f46e5;
}

.q-h-resizer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 8px;
  cursor: row-resize;
  z-index: 12;
  touch-action: none;
}
.q-h-resizer:hover {
  background: rgba(79, 70, 229, 0.25);
}

.q-v-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 12;
  touch-action: none;
}
.q-v-resizer:hover {
  background: rgba(79, 70, 229, 0.25);
}

@media (pointer: coarse) {
  .q-resize-handle {
    opacity: 0.75;
    width: 16px;
    height: 16px;
  }
}

/* ==========================================================================
   Modals & Toasts
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 15px; }

.modal-body {
  padding: 18px;
  font-size: 13.5px;
  line-height: 1.55;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-btn {
  justify-content: center;
}

.deploy-steps {
  padding-left: 18px;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsive Breakpoints (TV / 4K / Desktop / Laptop / Tablet / Mobile)
   ========================================================================== */

/* 4K & Large TV Displays (>= 2400px) */
@media (min-width: 2400px) {
  .studio-topbar { height: 68px; padding: 0 28px; }
  .brand-title { font-size: 19px; }
  .studio-workspace {
    grid-template-columns: 360px 540px 1fr;
    height: calc(100vh - 68px);
    height: calc(100dvh - 68px);
  }
  .btn { height: 40px; font-size: 14.5px; padding: 0 16px; }
  .etab { font-size: 14px; padding: 14px 14px; }
  .field label { font-size: 13px; }
  .field input, .field textarea, .field select { font-size: 14.5px; padding: 9px 11px; }
}

/* Large Desktops & QHD Monitors (1600px - 2399px) */
@media (min-width: 1600px) and (max-width: 2399px) {
  .studio-workspace {
    grid-template-columns: 310px 470px 1fr;
  }
}

/* Compact Laptops & Small Desktops (961px - 1180px) */
@media (max-width: 1180px) {
  .studio-workspace {
    grid-template-columns: 235px 355px 1fr;
  }
}

/* Tablets & Mobile (<= 960px) */
/* Mobile & Tablet Bottom Action Dock (hidden on desktop) */
.mobile-action-bar {
  display: none;
}

@media (max-width: 960px) {
  .mobile-only { display: inline-flex; }
  .view-tab[data-view="split"] { display: none; }

  /* Keep topbar clean on mobile/tablet; move New/Save/Print/PDF/Word/Share to bottom dock */
  .topbar-actions .font-size-pill,
  .topbar-actions #btnNewQuote,
  .topbar-actions #btnSaveQuote,
  .topbar-actions .dropdown-group {
    display: none;
  }

  .studio-workspace,
  .studio-workspace[data-view="split"],
  .studio-workspace[data-view="editor"],
  .studio-workspace[data-view="preview"] {
    grid-template-columns: 1fr;
    position: relative;
    height: calc(100vh - 58px - 58px);
    height: calc(100dvh - 58px - 58px);
  }

  .mobile-action-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    z-index: 45;
  }

  .mab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-main);
    border-radius: 8px;
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
    padding: 2px;
  }
  .mab-btn svg {
    width: 16px;
    height: 16px;
  }
  .mab-btn.mab-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }
  .mab-btn.mab-accent {
    background: #0284c7;
    border-color: #0284c7;
    color: #fff;
  }
  .mab-btn.mab-share {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
  }

  .studio-workspace[data-view="split"] .editor-pane { display: none; }
  .studio-workspace[data-view="editor"] .preview-pane { display: none; }
  .studio-workspace[data-view="preview"] .editor-pane { display: none; }

  .quotes-sidebar {
    position: fixed;
    top: 58px;
    left: 0;
    bottom: 0;
    width: 310px;
    max-width: 88vw;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
  }
  .quotes-sidebar.open {
    transform: translateX(0);
  }
}

/* Phones & Small Tablets (<= 640px) */
@media (max-width: 640px) {
  .studio-topbar {
    padding: 0 8px;
    gap: 6px;
    height: 54px;
  }
  .studio-workspace,
  .studio-workspace[data-view="split"],
  .studio-workspace[data-view="editor"],
  .studio-workspace[data-view="preview"] {
    height: calc(100vh - 54px - 58px);
    height: calc(100dvh - 54px - 58px);
  }
  .quotes-sidebar { top: 54px; }
  .save-indicator, .btn-label { display: none; }
  .topbar-actions {
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .dropdown-group { padding-left: 4px; gap: 4px; }
  .btn { padding: 0 9px; height: 34px; }
  .preview-toolbar {
    padding: 0 10px;
    height: auto;
    min-height: 38px;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .preview-viewport { padding: 10px 6px; }
  .form-grid.two-col, .form-grid.three-col {
    grid-template-columns: 1fr;
  }
  .span-2 { grid-column: span 1; }
  .editor-scroll { padding: 10px; }
  .toast-container { left: 12px; right: 12px; bottom: 68px; }
}

/* Extra Small Phones (<= 420px) */
@media (max-width: 420px) {
  .brand-badge { display: none; }
  .brand-title { font-size: 13.5px; }
  .view-tab { padding: 4px 8px; font-size: 11.5px; }
  .icon-btn { width: 30px; height: 30px; }
  .btn { height: 30px; padding: 0 7px; }
}

/* Touch Devices: Comfortable Tap Targets & Prevent iOS Zoom */
@media (pointer: coarse) {
  .field input[type="text"],
  .field input[type="number"],
  .field textarea,
  .field select {
    font-size: 16px;
    min-height: 40px;
  }
  .etab { padding: 12px 12px; }
}

/* Short Landscape Viewports (Phones/Tablets in Landscape) */
@media (max-height: 520px) and (orientation: landscape) {
  .studio-topbar { height: 48px; }
  .studio-workspace {
    height: calc(100vh - 48px);
    height: calc(100dvh - 48px);
  }
  .quotes-sidebar { top: 48px; }
}

/* ==========================================================================
   Ultra-High-Resolution Print & Native Vector PDF
   ========================================================================== */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  .q-inline-unit-select {
    appearance: none;
    -webkit-appearance: none;
    border: none !important;
    background: transparent !important;
    padding: 0;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body {
    background: #fff !important;
    height: auto !important;
    overflow: visible !important;
  }

  .no-print {
    display: none !important;
  }

  .studio-workspace,
  .preview-pane,
  .preview-viewport,
  .paper-scale-wrapper {
    display: block !important;
    height: auto !important;
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    transform: none !important;
  }

  .quotation-sheet {
    width: 210mm !important;
    min-height: 297mm !important;
    box-shadow: none !important;
    margin: 0 auto !important;
  }

  .quotation-sheet img {
    image-rendering: high-quality;
  }

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

  .q-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .q-note-box.is-empty {
    display: none !important;
  }

  .q-bottom-grid, .q-brand-strip-wrap, .q-meta-grid, .q-header, .q-note-box {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
