/* ==========================================================================
   APNE EVENTS - QUOTATION & INVOICE MAKER
   Bootstrap 5 + Custom Responsive Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,400&family=Inter:wght@300;400;500;600;700;800&family=Montserrat:wght@400;600;700;800;900&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap');

:root {
  --bg-app: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #334155;
  --bg-input: #0f172a;
  --border-color: #334155;
  --primary: #e11d48;
  --primary-hover: #be123c;
  --primary-light: rgba(225, 29, 72, 0.15);
  --success: #10b981;
  --whatsapp: #25d366;
  --whatsapp-hover: #20ba5a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-md: 0 6px 16px rgba(0,0,0,0.3);
  --shadow-sheet: 0 10px 40px rgba(0,0,0,0.5);
}

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

html, body {
  height: 100%;
}

body.app-body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==========================================================================
   NAVBAR
   ========================================================================== */
.app-navbar {
  background-color: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-color);
  min-height: 58px;
  padding-top: 0;
  padding-bottom: 0;
}

.brand-logo-mini {
  width: 40px;
  height: 32px;
  display: flex;
  align-items: center;
}
.brand-logo-mini img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-name {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  line-height: 1.1;
}
.brand-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Custom Buttons */
.btn-app-primary {
  background-color: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 7px 14px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.btn-app-primary:hover {
  background-color: var(--primary-hover);
  color: #fff;
  transform: translateY(-1px);
}
.btn-app-secondary {
  background-color: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 7px 14px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-app-secondary:hover {
  background-color: #475569;
  color: #fff;
}
.btn-whatsapp {
  background-color: var(--whatsapp);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 7px 14px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.btn-whatsapp:hover {
  background-color: var(--whatsapp-hover);
  color: #fff;
  transform: translateY(-1px);
}

/* Off-canvas mobile menu */
.app-offcanvas {
  background-color: var(--bg-surface) !important;
  color: var(--text-main) !important;
  max-width: 280px;
}

/* ==========================================================================
   STATS BAR (Mobile)
   ========================================================================== */
.stats-bar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 6px 0;
}

.stat-pill-mob {
  padding: 4px 6px;
  border-right: 1px solid var(--border-color);
}
.stat-pill-mob:last-child { border-right: none; }
.stat-pill-mob .stat-lbl {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  display: block;
}
.stat-pill-mob .stat-val {
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  display: block;
}
.stat-pill-mob.highlight-pill .stat-lbl { color: #f43f5e; }
.stat-pill-mob.highlight-pill .stat-val { color: #fb7185; }

/* ==========================================================================
   MOBILE TABS
   ========================================================================== */
.mobile-tabs {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.app-tabs {
  border-bottom: none !important;
}

.app-tabs .nav-link {
  background-color: transparent !important;
  color: var(--text-muted) !important;
  border: none !important;
  border-radius: 0 !important;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 2px solid transparent !important;
  transition: all 0.2s;
}
.app-tabs .nav-link.active {
  color: var(--primary) !important;
  border-bottom: 2px solid var(--primary) !important;
}
.app-tabs .nav-link:hover:not(.active) {
  color: var(--text-main) !important;
}

.preview-toolbar-mob {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   MAIN WORKSPACE
   ========================================================================== */
.workspace-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Mobile pane */
.editor-scroll {
  min-height: 100%;
}

.preview-scroll {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Desktop split */
.desktop-split {
  height: calc(100vh - 58px - 40px); /* nav + footer */
}

/* Left Editor Pane */
.editor-pane {
  width: 460px;
  min-width: 360px;
  max-width: 540px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.pane-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.live-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.live-badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.pane-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

/* Summary Stats (Desktop) */
.summary-stats-card {
  display: flex;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  flex-shrink: 0;
}
.stat-pill {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.stat-pill.highlight {
  background: rgba(225, 29, 72, 0.15);
  border-color: rgba(225, 29, 72, 0.4);
}
.stat-lbl {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.stat-pill.highlight .stat-lbl { color: #f43f5e; }
.stat-val {
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  margin-top: 2px;
}
.stat-pill.highlight .stat-val { color: #fb7185; }

/* Right Preview Pane */
.preview-pane {
  flex: 1;
  background-color: #0b0f19;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-toolbar {
  height: 46px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.preview-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}
#zoom-level, #zoom-level-mob {
  min-width: 40px;
  text-align: center;
  font-weight: 600;
}

.btn-icon {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s;
}
.btn-icon:hover { background: #475569; }

/* PDF Viewport */
.pdf-container-viewport {
  flex: 1;
  overflow: auto;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background-image: radial-gradient(#1e293b 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Mobile PDF viewport */
#preview-viewport-mob {
  min-height: calc(100vh - 180px);
}

/* ==========================================================================
   FORM STYLES
   ========================================================================== */
.editor-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: rgba(15, 23, 42, 0.4);
}

.form-section legend {
  padding: 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  gap: 8px;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0.6rem;
}
.form-group:last-child { margin-bottom: 0; }

.form-label-sm {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
}

.req { color: var(--primary); }

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon-wrapper .form-control {
  padding-left: 32px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
  background-color: var(--bg-input);
  color: var(--text-main);
}
.form-control option {
  background-color: var(--bg-surface);
}

.select-sm {
  font-size: 0.75rem;
  padding: 5px 8px;
}

/* Items editor table */
.items-table-wrapper {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  -webkit-overflow-scrolling: touch;
}

.items-editor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 360px;
}

.items-editor-table th {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  padding: 6px 6px;
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
.items-editor-table td {
  padding: 4px 5px;
  border-top: 1px solid var(--border-color);
}
.items-editor-table input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
}
.items-editor-table input:focus {
  border-color: var(--primary);
  outline: none;
}

.item-row-total {
  font-weight: 600;
  text-align: right;
  display: block;
  padding-right: 2px;
  white-space: nowrap;
}

.btn-outline-dashed {
  background: transparent;
  border: 1.5px dashed var(--border-color);
  color: var(--text-muted);
  justify-content: center;
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s;
}
.btn-outline-dashed:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* GST Toggle */
.gst-toggle-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.gst-toggle-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.switch-container {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch-container input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-surface-elevated);
  transition: .3s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }
.switch-label { display: flex; flex-direction: column; }
.switch-label strong { font-size: 0.82rem; }
.switch-label .subtext { font-size: 0.7rem; color: var(--text-muted); }
.gst-config-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Terms Editor */
.terms-editor-panel {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
}

/* Unlisted Item Hint */
.unlisted-item-hint {
  font-size: 0.68rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  margin-top: 3px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.1);
  width: fit-content;
}
.unlisted-item-hint:hover { background: rgba(56, 189, 248, 0.2); }

/* Row Action Buttons */
.row-actions-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.btn-row-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 3px;
  font-size: 0.7rem;
  transition: all 0.15s;
}
.btn-row-action:hover {
  background: var(--bg-surface-elevated);
  color: #fff;
}
.btn-row-action.delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* Template Chips */
.template-picker-section { overflow: hidden; }
.template-badge {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(225, 29, 72, 0.3);
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.template-chips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 0.5rem;
}
.template-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.74rem;
  font-weight: 600;
  text-align: left;
  transition: all 0.2s;
}
.template-chip:hover {
  background: #475569;
  border-color: #64748b;
}
.template-chip.active {
  background: rgba(225, 29, 72, 0.15);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 1px var(--primary);
}
.chip-preview-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-classic  { background: #c01d24; }
.dot-modern   { background: #0284c7; }
.dot-crimson  { background: #991b1b; }
.dot-gold     { background: #d97706; }
.dot-slate    { background: #1e3a8a; }
.dot-emerald  { background: #059669; }

/* ==========================================================================
   A4 DOCUMENT SHEET (Pixel-Perfect PDF Preview)
   ========================================================================== */
.pdf-sheet.a4-page {
  width: 210mm;
  min-height: 295mm;
  max-width: 210mm;
  height: 296mm;
  background-color: #ffffff;
  color: #111111;
  box-shadow: var(--shadow-sheet);
  position: relative;
  box-sizing: border-box;
  transform-origin: top center;
  transition: transform 0.15s ease-out;
  padding: 13mm 16mm 13mm 16mm;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  page-break-inside: avoid !important;
  page-break-after: avoid !important;
  break-inside: avoid !important;
  break-after: avoid !important;
}

/* Watermark */
.sheet-watermark {
  position: absolute;
  top: 46%; left: 50%;
  transform: translate(-50%, -50%);
  width: 62%;
  opacity: 0.06;
  pointer-events: none;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet-watermark img {
  width: 100%; height: auto; object-fit: contain;
}

.sheet-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Header */
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 12px;
}
.header-logo-container {
  width: 210px; height: 95px;
  display: flex; align-items: flex-end;
}
.brand-logo-img {
  width: auto; max-width: 100%; height: 100%;
  object-fit: contain; object-position: left bottom;
}
.header-contact-container {
  font-family: 'Montserrat', 'Inter', sans-serif;
  font-size: 15px; color: #222222;
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 4px;
}
.contact-label { font-weight: 500; }
.contact-val { font-weight: 600; letter-spacing: 0.5px; }

/* Divider */
.sheet-divider-line {
  height: 1.5px;
  background-color: #4b5563;
  width: 100%;
  margin-bottom: 18px;
}

/* Meta */
.sheet-meta-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-family: 'Montserrat', 'Inter', sans-serif;
  margin-bottom: 24px;
}
.meta-left { display: flex; flex-direction: column; gap: 4px; }
.meta-title { font-size: 14.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: #2b2b2b; }
.meta-party-name { font-size: 15px; font-weight: 600; color: #111111; }
.meta-party-phone { font-size: 13px; font-weight: 600; color: #374151; letter-spacing: 0.2px; margin-top: 1px; }
.meta-right { font-size: 14.5px; color: #2b2b2b; display: flex; align-items: baseline; gap: 6px; }
.meta-date-label { font-weight: 500; }
.meta-date-val { font-weight: 600; text-transform: uppercase; }

/* City Headline */
.sheet-city-section { margin-bottom: 18px; }
.city-headline {
  font-family: 'Montserrat', sans-serif;
  font-size: 26px; font-weight: 800;
  color: #000000; letter-spacing: 0.2px;
}

/* Items Table */
.sheet-table-section { margin-bottom: 14px; }
.quotation-table { width: 100%; border-collapse: collapse; font-family: 'Montserrat', 'Inter', sans-serif; }
.table-head-row { border-top: 2px solid #000000; border-bottom: 2px solid #000000; }
.quotation-table th { padding: 10px 8px; font-size: 13.5px; font-weight: 800; color: #000000; letter-spacing: 0.6px; text-transform: uppercase; }
.th-name { text-align: left; width: 48%; }
.th-price { text-align: center; width: 18%; }
.th-qty { text-align: center; width: 14%; }
.th-total { text-align: right; width: 20%; padding-right: 10px; }
.table-data-row { border-bottom: 1px solid #111111; }
.quotation-table td { padding: 12px 8px; font-size: 13px; font-weight: 700; color: #111111; }
.td-name { text-align: left; }
.td-price { text-align: center; }
.td-qty { text-align: center; }
.td-total { text-align: right; padding-right: 10px; }

/* Calculations */
.sheet-calculations-section {
  display: flex; flex-direction: column; align-items: flex-end;
  width: 100%; font-family: 'Montserrat', 'Inter', sans-serif;
  margin-bottom: auto;
}
.calc-row {
  display: flex; justify-content: flex-end; align-items: baseline;
  width: 100%; padding: 4px 0;
}
.calc-label { font-size: 14px; font-weight: 700; color: #111111; text-align: left; flex: 1; }
.calc-value { font-size: 14px; font-weight: 800; color: #000000; text-align: right; width: 140px; padding-right: 10px; }
.single-day-row { padding: 3px 0; margin-bottom: 2px; }
.single-day-row .calc-label { font-size: 13px; font-weight: 600; color: #4b5563; }
.single-day-row .single-day-val { font-size: 13.5px; font-weight: 700; color: #374151; }
.subtotal-row { border-top: 2px solid #000000; border-bottom: 2px solid #000000; padding: 8px 0; margin-top: 4px; margin-bottom: 6px; }
.subtotal-row .calc-value { font-size: 15px; font-weight: 900; }
.gst-row { padding: 3px 0; }
.gst-row .calc-label { font-size: 13px; font-weight: 600; color: #374151; }
.gst-row .calc-value { font-size: 13px; font-weight: 700; }
.discount-row { padding: 4px 0; margin-bottom: 4px; }
.discount-row .calc-label { font-size: 14px; font-weight: 700; color: #111111; }
.discount-val { font-size: 14px; font-weight: 800; }
.grand-total-row { border-top: 2px solid #000000; border-bottom: 2px solid #000000; padding: 8px 0; margin-top: 4px; }
.grand-label { font-size: 15px; font-weight: 800; color: #000000; }
.grand-val { font-size: 16px; font-weight: 900; color: #000000; }

/* Footer */
.sheet-footer {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding-top: 40px; margin-top: 30px;
}
.footer-signatory { display: flex; flex-direction: column; align-items: center; min-width: 180px; }
.sign-name { font-family: 'Cormorant Garamond', 'Playfair Display', Georgia, serif; font-size: 24px; font-weight: 700; color: #1a1a1a; letter-spacing: 0.5px; margin-bottom: 4px; }
.sign-divider { width: 160px; height: 1.5px; background-color: #222222; margin-bottom: 6px; }
.sign-role { font-family: 'Montserrat', 'Inter', sans-serif; font-size: 12.5px; font-style: italic; font-weight: 500; color: #333333; }
.footer-thanks { text-align: right; }
.thanks-text { font-family: 'Montserrat', 'Impact', sans-serif; font-size: 24px; font-weight: 900; color: #000000; letter-spacing: 0.8px; }

/* Terms */
.sheet-terms-section { margin-top: 14px; padding-top: 10px; border-top: 1px dashed #d1d5db; font-family: 'Inter', sans-serif; font-size: 11px; color: #4b5563; line-height: 1.4; }
.terms-title { font-weight: 700; font-size: 11.5px; color: #111111; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.3px; }
.terms-content { white-space: pre-line; }

/* Reionx credit */
.sheet-dev-credit {
  margin-top: 22px; padding-top: 8px; text-align: center;
  font-family: 'Inter', sans-serif; font-size: 10px; color: #9ca3af;
  letter-spacing: 0.3px; border-top: 1px dotted #e5e7eb;
}
.sheet-dev-credit span { display: inline-flex; align-items: center; gap: 4px; }
.reionx-credit-link { color: #4b5563; text-decoration: none; font-weight: 700; transition: color 0.2s; }
.reionx-credit-link:hover { color: #dc2626; text-decoration: underline; }

/* ==========================================================================
   DOCUMENT THEMES
   ========================================================================== */
.pdf-sheet.theme-modern-minimalist .sheet-divider-line {
  background: linear-gradient(90deg, var(--doc-accent, #0284c7), transparent); height: 2px;
}
.pdf-sheet.theme-modern-minimalist .meta-title { color: var(--doc-accent, #0284c7); letter-spacing: 1.5px; }
.pdf-sheet.theme-modern-minimalist .table-head-row { background: #f1f5f9; border-top: none; border-bottom: 2px solid var(--doc-accent, #0284c7); }
.pdf-sheet.theme-modern-minimalist .quotation-table th { padding: 8px 10px; font-size: 12px; color: #334155; font-weight: 700; }
.pdf-sheet.theme-modern-minimalist .table-data-row { border-bottom: 1px solid #e2e8f0; }
.pdf-sheet.theme-modern-minimalist .table-data-row:nth-child(even) { background-color: #f8fafc; }
.pdf-sheet.theme-modern-minimalist .subtotal-row { border-top: 1px solid #cbd5e1; border-bottom: 1px solid #cbd5e1; }
.pdf-sheet.theme-modern-minimalist .grand-total-row { background: #f8fafc; border: 1px solid #cbd5e1; border-left: 4px solid var(--doc-accent, #0284c7); padding: 10px 12px; border-radius: 4px; }

.pdf-sheet.theme-crimson-luxury { border-top: 6px solid var(--doc-accent, #991b1b); }
.pdf-sheet.theme-crimson-luxury .city-headline { color: var(--doc-accent, #991b1b); border-left: 4px solid var(--doc-accent, #991b1b); padding-left: 10px; }
.pdf-sheet.theme-crimson-luxury .table-head-row { background: #7f1d1d; border: none; }
.pdf-sheet.theme-crimson-luxury .quotation-table th { color: #ffffff; padding: 10px 8px; }
.pdf-sheet.theme-crimson-luxury .table-data-row { border-bottom: 1px solid #fee2e2; }
.pdf-sheet.theme-crimson-luxury .grand-total-row { background: #fef2f2; border: 2px solid #b91c1c; padding: 10px 12px; }
.pdf-sheet.theme-crimson-luxury .grand-label, .pdf-sheet.theme-crimson-luxury .grand-val { color: #991b1b; }

.pdf-sheet.theme-royal-gold { border: 1px solid #fef3c7; border-top: 6px solid #d97706; }
.pdf-sheet.theme-royal-gold .city-headline { font-family: 'Playfair Display', serif; color: #78350f; letter-spacing: 1px; }
.pdf-sheet.theme-royal-gold .sheet-divider-line { background: #d97706; height: 2px; }
.pdf-sheet.theme-royal-gold .table-head-row { border-top: 2px solid #d97706; border-bottom: 2px solid #d97706; }
.pdf-sheet.theme-royal-gold .quotation-table th { color: #78350f; font-weight: 800; }
.pdf-sheet.theme-royal-gold .table-data-row { border-bottom: 1px solid #fde68a; }
.pdf-sheet.theme-royal-gold .grand-total-row { border-top: 2px solid #d97706; border-bottom: 2px double #d97706; background: #fffbeb; padding: 10px 12px; }
.pdf-sheet.theme-royal-gold .grand-label, .pdf-sheet.theme-royal-gold .grand-val { color: #92400e; }

.pdf-sheet.theme-corporate-slate { border-top: 6px solid #1e3a8a; }
.pdf-sheet.theme-corporate-slate .table-head-row { background: #1e3a8a; border: none; }
.pdf-sheet.theme-corporate-slate .quotation-table th { color: #ffffff; padding: 10px 8px; }
.pdf-sheet.theme-corporate-slate .table-data-row:nth-child(even) { background: #f8fafc; }
.pdf-sheet.theme-corporate-slate .grand-total-row { background: #eff6ff; border-top: 2px solid #1e3a8a; border-bottom: 2px solid #1e3a8a; padding: 10px 12px; }

.pdf-sheet.theme-emerald-prestige { border-top: 6px solid #065f46; }
.pdf-sheet.theme-emerald-prestige .sheet-divider-line { background: #059669; height: 2px; }
.pdf-sheet.theme-emerald-prestige .city-headline { color: #065f46; }
.pdf-sheet.theme-emerald-prestige .table-head-row { background: #065f46; border: none; }
.pdf-sheet.theme-emerald-prestige .quotation-table th { color: #ffffff; }
.pdf-sheet.theme-emerald-prestige .table-data-row { border-bottom: 1px solid #d1fae5; }
.pdf-sheet.theme-emerald-prestige .grand-total-row { background: #ecfdf5; border: 1px solid #10b981; border-left: 4px solid #059669; padding: 10px 12px; }

/* Typography */
.font-montserrat { font-family: 'Montserrat', sans-serif !important; }
.font-serif { font-family: 'Playfair Display', 'Cormorant Garamond', Georgia, serif !important; }
.font-modern { font-family: 'Inter', system-ui, sans-serif !important; }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; margin: 0; }
.btn-close-modal { background: transparent; border: none; font-size: 1.4rem; color: var(--text-muted); cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 0.875rem 1.25rem; border-top: 1px solid var(--border-color); display: flex; justify-content: space-between; flex-shrink: 0; }

/* Catalog Grid */
.catalog-manager-toolbar { display: flex; gap: 10px; margin-bottom: 1rem; }
.search-box { flex: 1; position: relative; display: flex; align-items: center; }
.search-box i { position: absolute; left: 10px; color: var(--text-muted); font-size: 0.82rem; }
.search-box input { padding-left: 34px; }
.catalog-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}
.catalog-item-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; flex-direction: column;
  justify-content: space-between; gap: 6px;
  transition: all 0.2s;
}
.catalog-item-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.catalog-item-name { font-weight: 700; font-size: 0.82rem; color: #f8fafc; }
.catalog-category-tag { font-size: 0.62rem; padding: 2px 5px; background: var(--bg-surface-elevated); border-radius: 4px; color: var(--text-muted); white-space: nowrap; }
.card-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.catalog-item-price { font-size: 0.88rem; font-weight: 800; color: #10b981; }
.card-actions { display: flex; align-items: center; gap: 4px; }
.btn-sm { padding: 4px 8px; font-size: 0.74rem; }
.btn-edit-icon { background: transparent; border: none; color: #38bdf8; cursor: pointer; padding: 5px; border-radius: 4px; transition: all 0.2s; display: inline-flex; align-items: center; }
.btn-edit-icon:hover { background: rgba(56, 189, 248, 0.2); }
.btn-danger-icon { background: transparent; border: none; color: #ef4444; cursor: pointer; padding: 5px; border-radius: 4px; transition: all 0.2s; display: inline-flex; align-items: center; }
.btn-danger-icon:hover { background: rgba(239, 68, 68, 0.2); }

/* Database Status Button & Banner */
.db-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.db-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background-color: #f59e0b; /* yellow for local */
  box-shadow: 0 0 6px #f59e0b;
}
.db-status-dot.connected {
  background-color: #10b981; /* green for connected */
  box-shadow: 0 0 6px #10b981;
}
.db-status-dot.error {
  background-color: #ef4444; /* red for error */
  box-shadow: 0 0 6px #ef4444;
}

.db-status-banner {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
}
.form-hint {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* History */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center;
  transition: border-color 0.2s;
}
.history-item:hover { border-color: var(--primary); }
.history-info strong { font-size: 0.88rem; display: block; }
.history-info span { font-size: 0.72rem; color: var(--text-muted); }
.history-actions { display: flex; gap: 6px; }

/* ==========================================================================
   TOASTS
   ========================================================================== */
.toast-container {
  position: fixed; bottom: 20px; right: 16px;
  z-index: 3000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 9px;
  font-size: 0.82rem;
  animation: slideIn 0.3s ease-out;
  max-width: 340px;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--primary); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   APP FOOTER
   ========================================================================== */
.app-global-footer {
  height: 38px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.app-footer-inner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.app-reionx-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.app-reionx-link:hover { text-decoration: underline; }
.app-footer-sep { color: var(--border-color); }

/* ==========================================================================
   UTILITY
   ========================================================================== */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }

/* ==========================================================================
   PRINT (Pixel-perfect A4)
   ========================================================================== */
@media print {
  .app-navbar, .stats-bar, .mobile-tabs, .editor-pane,
  .preview-toolbar, .preview-toolbar-mob, .app-global-footer,
  .toast-container, .modal-backdrop, #mobileMenu {
    display: none !important;
  }
  body { background: white; }
  .workspace-main, .desktop-split, .preview-pane,
  .pdf-container-viewport {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    height: auto !important;
    overflow: visible !important;
  }
  .pdf-sheet.a4-page {
    width: 210mm;
    min-height: 297mm;
    box-shadow: none !important;
    transform: none !important;
    margin: 0 !important;
    padding: 16mm 18mm 18mm 18mm !important;
    page-break-after: avoid;
  }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 991.98px) {
  /* Stack layout on mobile, tabs handle switching */
  .workspace-main {
    display: flex !important;
    flex-direction: column;
    height: calc(100vh - 58px - 37px - 43px); /* nav + stats + tabs */
  }

  .tab-content {
    flex: 1;
    overflow: hidden;
  }

  .tab-pane.show.active {
    overflow-y: auto;
    height: 100%;
  }

  /* Mobile PDF preview scales to fit screen cleanly */
  .pdf-container-viewport {
    padding: 10px 4px 60px 4px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  #preview-viewport-mob {
    min-height: calc(100vh - 180px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }

  #preview-viewport-mob .pdf-sheet.a4-page {
    transform-origin: top center;
    margin: 0 auto;
    flex-shrink: 0;
  }

  .modal-card {
    max-height: 90vh;
    margin: 0;
  }

  .catalog-items-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    max-height: 280px;
  }

  .template-chips-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 575.98px) {
  .template-chips-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .catalog-items-grid {
    grid-template-columns: 1fr 1fr;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Make items table scrollable on small phones */
  .items-table-wrapper {
    overflow-x: auto;
  }

  .form-section { padding: 0.75rem; }

  .toast-container { bottom: 16px; right: 12px; }
}
