/* SND Document Creator Stylesheet */
:root {
  color-scheme: only light !important;
  forced-color-adjust: none !important;

  --primary: #c81e2b;
  --primary-dark: #991b1b;
  --primary-light: #fee2e2;
  --accent: #d97706;
  --dark: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  
  /* Document Spacing Variables (Dynamically adjusted by Auto-Fit) */
  --doc-scale: 1.0;
  --section-gap: 12px;
  --table-cell-padding: 7px 10px;
  --font-base-size: 13px;
  --logo-height: 60px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  color-scheme: only light !important;
  forced-color-adjust: none !important;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #0f172a;
  color: #334155;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ================= Top Navigation Bar ================= */
.app-header {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  color: white;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-shrink: 0;
  z-index: 50;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-img {
  height: 34px;
  width: auto;
  object-fit: contain;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

.brand-subtitle {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 400;
}

/* Doc Type Switcher Tabs */
.doc-type-tabs {
  display: flex;
  background: #0f172a;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #334155;
}

.tab-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(200, 30, 43, 0.4);
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: #059669;
  color: white;
}

.btn-success:hover {
  background: #047857;
}

.btn-secondary {
  background: #334155;
  color: #e2e8f0;
  border-color: #475569;
}

.btn-secondary:hover {
  background: #475569;
  color: white;
}

.btn-outline {
  background: transparent;
  color: #cbd5e1;
  border-color: #475569;
}

.btn-outline:hover {
  background: #334155;
  color: white;
}

/* ================= Main App Layout ================= */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Left Form Editor Sidebar */
.editor-sidebar {
  width: 480px;
  min-width: 420px;
  max-width: 550px;
  background: #1e293b;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  color: #e2e8f0;
}

.sidebar-header {
  padding: 12px 16px;
  background: #182234;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-loader-select {
  padding: 5px 10px;
  background: #0f172a;
  border: 1px solid #475569;
  color: #f1f5f9;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}

.editor-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #64748b #0f172a;
}

/* Custom Scrollbar for Editor Sidebar */
.editor-scroll-area::-webkit-scrollbar {
  width: 8px;
}
.editor-scroll-area::-webkit-scrollbar-track {
  background: #0f172a;
}
.editor-scroll-area::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}
.editor-scroll-area::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* Accordion Form Cards */
.form-card {
  flex-shrink: 0;
  background: #182234;
  border: 1px solid #334155;
  border-radius: 8px;
  overflow: visible;
}

.form-card-header {
  padding: 10px 14px;
  background: #232e42;
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.form-card-header:hover {
  background: #28354c;
}

.form-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-col-sm {
  flex: 0 0 100px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

input[type="text"],
input[type="date"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 7px 10px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f8fafc;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(200, 30, 43, 0.2);
}

textarea {
  resize: vertical;
  min-height: 55px;
  font-family: inherit;
}

/* Item Builder Rows */
.item-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.item-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.item-delete-btn {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 4px;
}

.item-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Sub-Breakdown Section */
.breakdown-box {
  background: #182234;
  border: 1px dashed #475569;
  border-radius: 6px;
  padding: 8px;
  margin-top: 4px;
}

.breakdown-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.breakdown-row input {
  padding: 5px 8px;
  font-size: 12px;
}

/* ================= Right Preview Area ================= */
.preview-container {
  flex: 1;
  background: #0b1120;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Preview Floating Toolbar */
.preview-toolbar {
  padding: 8px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.optimizer-panel {
  display: flex;
  align-items: center;
  gap: 12px;
}

.optimizer-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.optimizer-badge.fit-green {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.optimizer-badge.fit-orange {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.optimizer-badge.fit-red {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
}

.switch-label input {
  cursor: pointer;
}

.density-group {
  display: flex;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 2px;
}

.density-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 4px;
}

.density-btn.active {
  background: #334155;
  color: #fff;
}

.scale-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #94a3b8;
}

.scale-control input[type="range"] {
  width: 75px;
  cursor: pointer;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Preview Scroll Stage */
.preview-stage {
  flex: 1;
  overflow: auto;
  padding: 25px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #334155 !important; /* Neutral dark slate so white sheet pops */
  color-scheme: only light !important;
  forced-color-adjust: none !important;
}

/* ================= The A4 Printable Sheet ================= */
.a4-document-wrapper {
  position: relative;
  transition: transform 0.2s ease;
  transform-origin: top center;
  color-scheme: only light !important;
  forced-color-adjust: none !important;
  isolation: isolate;
}

.a4-sheet {
  width: 210mm;
  min-height: 297mm;
  background-color: #ffffff !important;
  background-image: linear-gradient(#ffffff, #ffffff) !important;
  background: #ffffff linear-gradient(#ffffff, #ffffff) !important;
  color: #0f172a !important;
  color-scheme: only light !important;
  forced-color-adjust: none !important;
  padding: 12mm 15mm;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
  position: relative;
  box-sizing: border-box;
  font-size: var(--font-base-size);
  line-height: 1.35;
  display: flex;
  flex-direction: column;
}

.a4-sheet,
.a4-sheet *,
.a4-sheet table,
.a4-sheet tr,
.a4-sheet th,
.a4-sheet td,
.a4-sheet div,
.a4-sheet span,
.a4-sheet p {
  color-scheme: only light !important;
  forced-color-adjust: none !important;
}

/* Direct inversion shield for browser-forced dark mode flags */
.dark-mode-inverter {
  filter: invert(1) hue-rotate(180deg) !important;
  -webkit-filter: invert(1) hue-rotate(180deg) !important;
}

.dark-mode-inverter .doc-logo-img {
  filter: invert(1) hue-rotate(180deg) !important;
  -webkit-filter: invert(1) hue-rotate(180deg) !important;
}

/* Page 1 Cutoff Indicator Line */
.page-limit-line {
  position: absolute;
  top: 297mm;
  left: -20px;
  right: -20px;
  border-top: 2px dashed #ef4444;
  pointer-events: none;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.page-limit-badge {
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  position: relative;
  top: -10px;
}

/* Document Header Layout */
.doc-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: var(--section-gap);
  border-bottom: 2px solid #0f172a;
  padding-bottom: 10px;
}

.company-brand-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 60%;
}

.doc-logo-img {
  height: var(--logo-height);
  max-height: 72px;
  width: auto;
  object-fit: contain;
  align-self: flex-start;
  margin-bottom: 4px;
}

.company-name-heading {
  font-size: 17px;
  font-weight: 800;
  color: #991b1b;
  letter-spacing: 0.5px;
  line-height: 1.15;
}

.company-info-text {
  font-size: 11px;
  color: #334155;
  line-height: 1.3;
}

.doc-meta-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  min-width: 35%;
}

.doc-title-badge {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #0f172a;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 4px 12px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  display: inline-block;
}

.doc-title-badge.badge-quo {
  color: #b91c1c;
  border-color: #fca5a5;
  background: #fef2f2;
}

.doc-title-badge.badge-inv {
  color: #1e3a8a;
  border-color: #93c5fd;
  background: #eff6ff;
}

.doc-title-badge.badge-do {
  color: #065f46;
  border-color: #6ee7b7;
  background: #ecfdf5;
}

.meta-details-table {
  font-size: 11.5px;
  line-height: 1.4;
  text-align: right;
}

.meta-details-table td {
  padding: 1px 4px;
}

.meta-label {
  font-weight: 600;
  color: #64748b;
}

.meta-value {
  font-weight: 700;
  color: #0f172a;
}

/* Recipient Box (Customer / Deliver To) */
.recipient-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--section-gap);
  gap: 20px;
}

.recipient-box {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 8px 12px;
}

.recipient-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 2px;
}

.recipient-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 3px;
}

.recipient-address {
  font-size: 11.5px;
  color: #334155;
  white-space: pre-line;
  line-height: 1.35;
}

/* Greeting and RE: Subject Banner */
.intro-text {
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.subject-banner {
  background: #f1f5f9;
  border-left: 4px solid var(--primary);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: var(--section-gap);
  line-height: 1.3;
}

/* Line Items Table */
.items-table-wrapper {
  margin-bottom: var(--section-gap);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.items-table th {
  background: #1e293b;
  color: #ffffff;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.5px;
  padding: 6px 8px;
  border: 1px solid #1e293b;
  text-align: left;
}

.items-table th.th-right {
  text-align: right;
}

.items-table th.th-center {
  text-align: center;
}

.items-table td {
  padding: var(--table-cell-padding);
  border: 1px solid #cbd5e1;
  vertical-align: top;
  line-height: 1.35;
}

.items-table td.td-center {
  text-align: center;
}

.items-table td.td-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.item-main-title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 3px;
}

.item-bullet-list {
  list-style: none;
  padding-left: 0;
  margin: 3px 0;
}

.item-bullet-list li {
  position: relative;
  padding-left: 14px;
  margin-bottom: 2px;
  color: #334155;
}

.item-bullet-list li::before {
  content: "•";
  position: absolute;
  left: 3px;
  color: #64748b;
  font-weight: bold;
}

/* Multi-bullet sub-item styling in items-table */
.items-table tr.item-parent-row td {
  border-bottom: none !important;
}

.items-table tr.item-sub-row td {
  border-top: none !important;
  border-bottom: none !important;
}

.items-table tr.item-sub-last td {
  border-bottom: 1px solid #cbd5e1 !important;
}

.sub-bullet-line,
.desc-bullet-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding-left: 8px;
  color: #1e293b;
  margin: 1.5px 0;
}

.sub-bullet-dot,
.desc-bullet-dot {
  color: #475569;
  font-weight: bold;
  flex-shrink: 0;
  line-height: 1.35;
}

.sub-bullet-text,
.desc-bullet-text {
  flex: 1;
  line-height: 1.35;
  word-break: break-word;
}

.desc-text-line {
  line-height: 1.4;
  color: #1e293b;
  word-break: break-word;
}

.desc-empty-spacer {
  height: 8px;
  line-height: 8px;
}

.item-empty-cell {
  background: transparent;
}

/* ================= Modal Windows (Customer Book & Documents) ================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-container {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  color: #e2e8f0;
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  background: #182234;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close-btn:hover {
  color: #fff;
  background: #334155;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 12px;
}

.customer-item-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 0.15s ease;
}

.customer-item-card:hover {
  border-color: #475569;
}

.cust-item-title {
  font-weight: 700;
  color: #f8fafc;
  font-size: 13px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cust-item-code-badge {
  display: inline-block;
  background: #0284c7;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.cust-item-address {
  font-size: 11.5px;
  color: #94a3b8;
  white-space: pre-line;
  line-height: 1.35;
}

.document-item-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.doc-item-num {
  font-weight: 700;
  color: #f8fafc;
  font-size: 13.5px;
}

.doc-item-meta {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 2px;
}

.item-description-text {
  white-space: pre-wrap;
  font-size: 11.5px;
  line-height: 1.4;
  color: #1e293b;
  word-break: break-word;
}


.empty-table-prompt {
  text-align: center;
  padding: 30px 10px;
  color: #94a3b8;
  font-style: italic;
  font-size: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
}

/* Total Section & Discount */
.discount-row-highlight td {
  background: #f8fafc;
  font-weight: 800;
  font-size: 13px;
  color: #0f172a;
  border-top: 2px solid #0f172a;
  border-bottom: 1px solid #cbd5e1;
  padding: var(--table-cell-padding);
}

.discount-amount-large {
  font-size: 14px;
  color: #0f172a;
  font-weight: 800;
}

.total-row-highlight td {
  background: #f8fafc;
  font-weight: 800;
  font-size: 13px;
  color: #0f172a;
  border-top: 2px solid #0f172a;
  border-bottom: 2px solid #0f172a;
  padding: var(--table-cell-padding);
}

.discount-row-highlight + .total-row-highlight td {
  border-top: 1px solid #cbd5e1;
}

.total-amount-large {
  font-size: 14px;
  color: #0f172a;
  font-weight: 800;
}

.do-total-qty {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  padding: 6px 10px;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
}

.sheet-compact .do-total-qty {
  font-size: 12px;
  padding: 4px 6px;
}

.sheet-ultra-compact .do-total-qty {
  font-size: 11px;
  padding: 3px 4px;
}

/* Footer Section */
.doc-footer-area {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.confirmation-note {
  font-size: 11px;
  color: #334155;
  line-height: 1.35;
  font-style: italic;
  border-top: 1px solid #e2e8f0;
  padding-top: 6px;
  margin-bottom: 4px;
}

/* Signatures & Bank Details */
.footer-cols {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.bank-info-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.4;
  min-width: 250px;
}

.bank-info-title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.signature-block {
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11.5px;
}

.sig-content-row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.sig-left-col {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
}

.sig-chop-col {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 2px;
}

.signature-space {
  height: 42px;
  display: flex;
  align-items: flex-end;
  position: relative;
}

.doc-signature-img {
  height: 40px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 2px;
  pointer-events: none;
}

.doc-chop-img {
  height: 110px;
  width: auto;
  max-width: 270px;
  object-fit: contain;
  opacity: 0.95;
  mix-blend-mode: multiply;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.03));
}

.signature-line {
  border-bottom: 1px dashed #94a3b8;
  width: 100%;
  margin-bottom: 4px;
}

.signatory-name {
  font-weight: 700;
  color: #0f172a;
}

.signatory-title {
  color: #64748b;
  font-size: 10.5px;
}

/* Dual DO Signature Blocks */
.do-signatures-grid {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 10px;
}

.do-sig-col {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 8px 12px;
  background: #f8fafc;
  font-size: 11px;
}

.do-sig-title {
  font-weight: 700;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
  margin-bottom: 6px;
}

/* ================= Dynamic Density Classes ================= */
.sheet-compact {
  --section-gap: 8px;
  --table-cell-padding: 4px 6px;
  --font-base-size: 12px;
  --logo-height: 50px;
  padding: 10mm 12mm;
}

.sheet-compact .signature-space {
  height: 32px;
}

.sheet-compact .doc-signature-img {
  height: 30px;
}

.sheet-compact .doc-chop-img {
  height: 88px;
  max-width: 220px;
}

.sheet-compact .doc-title-badge {
  font-size: 17px;
  margin-bottom: 4px;
  padding: 2px 8px;
}

.sheet-ultra-compact {
  --section-gap: 5px;
  --table-cell-padding: 3px 5px;
  --font-base-size: 11px;
  --logo-height: 42px;
  padding: 8mm 10mm;
}

.sheet-ultra-compact .signature-space {
  height: 24px;
}

.sheet-ultra-compact .doc-signature-img {
  height: 24px;
}

.sheet-ultra-compact .doc-chop-img {
  height: 70px;
  max-width: 175px;
}

.sheet-spacious {
  --section-gap: 16px;
  --table-cell-padding: 8px 10px;
  --font-base-size: 13.5px;
  --logo-height: 68px;
  padding: 14mm 16mm;
}

/* ================= Print Stylesheet ================= */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  body {
    background: white !important;
    color: black !important;
    height: auto !important;
    overflow: visible !important;
  }
  
  .app-header,
  .editor-sidebar,
  .preview-toolbar,
  .page-limit-line,
  .no-print {
    display: none !important;
  }
  
  .app-container,
  .preview-container,
  .preview-stage {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    display: block !important;
  }
  
  .a4-document-wrapper {
    transform: none !important;
  }
  
  .a4-sheet {
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto !important;
  }

  /* Clean multi-page handling if content genuinely exceeds 1 page */
  tr, .item-card, .nested-breakdown-table {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .doc-footer-area, .bank-info-box, .signature-block, .do-signatures-grid {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .doc-signature-img, .doc-chop-img, .doc-sign-chop-img {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* ================= Google Drive Integration Toast & UI ================= */
.gdrive-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  border: 1px solid #38bdf8;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 12px 16px;
  color: #f8fafc;
  z-index: 9999;
  min-width: 320px;
  max-width: 480px;
  font-family: inherit;
  animation: slideUpToast 0.25s ease-out;
}

@keyframes slideUpToast {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast-icon {
  font-size: 20px;
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
  color: #38bdf8;
}

.toast-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  word-break: break-all;
}

.toast-action-btn {
  background: #0284c7;
  color: white !important;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-block;
  transition: background 0.15s;
}

.toast-action-btn:hover {
  background: #0369a1;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
  padding: 2px;
  margin-left: 4px;
}

.toast-close-btn:hover {
  color: #f1f5f9;
}

.pulse-dot {
  animation: pulseAnim 2s infinite;
}

@keyframes pulseAnim {
  0% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0.6; transform: scale(0.9); }
}

/* Floating Text Selection Bubble for Bold */
.floating-format-bubble {
  position: fixed;
  z-index: 100000;
  display: flex;
  align-items: center;
  background: #091322;
  border: 1px solid #38bdf8;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 12px rgba(56, 189, 248, 0.35);
  border-radius: 20px;
  padding: 3px 6px;
  transform: translate(-50%, -100%);
  user-select: none;
  pointer-events: auto;
}

.floating-format-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: #38bdf8 transparent transparent transparent;
}

.floating-bold-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.floating-bold-btn:hover {
  background: #0284c7;
  color: #ffffff;
}

.floating-bold-btn:active {
  background: #0369a1;
}

/* ================= Top Main Navigation ================= */
.app-main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #0f172a;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #334155;
}

.nav-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.nav-tab-btn:hover {
  color: #f8fafc;
  background: #1e293b;
}

.nav-tab-btn.active {
  color: #ffffff;
  background: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.nav-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 10px;
  background: #334155;
  color: #94a3b8;
  line-height: 1.2;
}

.nav-tab-btn.active .nav-count-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* ================= Full Page Views ================= */
.page-view {
  width: 100%;
}

.full-page-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: #0b1120;
  color: #e2e8f0;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* ================= Dedicated Documents Page Styles ================= */
.docs-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.docs-header-info {
  display: flex;
  flex-direction: column;
  min-width: 170px;
}

.docs-header-title {
  font-size: 17px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.docs-header-subtitle {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Prominent Global Search Bar */
.docs-global-search-wrapper {
  flex: 1;
  max-width: 620px;
  position: relative;
  display: flex;
  align-items: center;
}

.docs-search-icon {
  position: absolute;
  left: 14px;
  font-size: 14px;
  color: #64748b;
  pointer-events: none;
  z-index: 2;
}

.docs-search-input {
  width: 100%;
  padding: 9px 38px 9px 46px;
  font-size: 13px;
  color: #f8fafc;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  outline: none;
  transition: all 0.2s ease;
}

.docs-search-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
  background: #090e17;
}

.docs-search-clear-btn {
  position: absolute;
  right: 12px;
  background: #334155;
  color: #94a3b8;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.docs-search-clear-btn:hover {
  background: #475569;
  color: white;
}

.docs-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Explorer Body Split */
.docs-explorer-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Folder Navigation Sidebar */
.docs-folder-sidebar {
  width: 270px;
  min-width: 240px;
  max-width: 320px;
  background: #182234;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px 10px;
  flex-shrink: 0;
}

.folder-section-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 8px 10px 4px 10px;
  text-transform: uppercase;
}

.folder-section-header {
  margin-top: 12px;
  padding: 4px 10px 2px 10px;
}

.btn-folder-add {
  background: transparent;
  border: none;
  color: #38bdf8;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-folder-add:hover {
  background: #334155;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 12.5px;
  transition: all 0.15s ease;
  user-select: none;
  margin-bottom: 2px;
}

.folder-item:hover {
  background: #1e293b;
  color: #f8fafc;
}

.folder-item.active {
  background: #0284c7;
  color: #ffffff;
  font-weight: 600;
}

.folder-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.folder-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: #334155;
  color: #94a3b8;
}

.folder-item.active .folder-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.folder-badge.badge-quo { color: #f87171; }
.folder-badge.badge-inv { color: #60a5fa; }
.folder-badge.badge-do  { color: #34d399; }

/* Right Content Area */
.docs-content-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: #0f172a;
}

.docs-content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: #131c2e;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.docs-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #94a3b8;
}

.breadcrumb-root { color: #cbd5e1; font-weight: 600; cursor: pointer; }
.breadcrumb-separator { color: #475569; }
.breadcrumb-active { color: #38bdf8; font-weight: 700; }

.docs-count-pill {
  font-size: 11px;
  background: #1e293b;
  padding: 2px 8px;
  border-radius: 12px;
  color: #94a3b8;
  border: 1px solid #334155;
}

.docs-toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-mode-toggle {
  display: flex;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
}

.view-toggle-btn {
  background: #1e293b;
  color: #94a3b8;
  border: none;
  padding: 5px 9px;
  font-size: 13px;
  cursor: pointer;
}

.view-toggle-btn.active {
  background: #0284c7;
  color: white;
}

/* Global Search Banner */
.docs-search-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: #1e293b;
  border-bottom: 1px solid #38bdf8;
  font-size: 12px;
  color: #e2e8f0;
}

/* Scroll Area for Documents */
.docs-list-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* Documents Table Styling */
.docs-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #1e293b;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #334155;
}

.docs-data-table th {
  background: #182234;
  color: #94a3b8;
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #334155;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.docs-data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #273549;
  color: #cbd5e1;
  vertical-align: middle;
}

.docs-data-table tr:hover td {
  background: #243248;
}

.docs-data-table tr:last-child td {
  border-bottom: none;
}

/* Document Item Specific Components */
.doc-badge-quo {
  background: #ef4444;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
}

.doc-badge-inv {
  background: #3b82f6;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
}

.doc-badge-do {
  background: #10b981;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
}

.doc-code-badge {
  background: #334155;
  color: #38bdf8;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 4px;
}

.doc-subject-preview {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 3px;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-items-preview {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Grid View */
.docs-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.doc-card-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s, border-color 0.15s;
}

.doc-card-box:hover {
  border-color: #38bdf8;
  transform: translateY(-1px);
}

.doc-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.doc-card-num {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.doc-card-body {
  font-size: 12px;
  color: #cbd5e1;
}

.doc-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #334155;
  padding-top: 10px;
  margin-top: auto;
}

/* Search Term Highlight */
mark.search-highlight {
  background: #fef08a;
  color: #0f172a;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 700;
}

/* Summary Footer Bar */
.docs-summary-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: #182234;
  border-top: 1px solid #334155;
  font-size: 12px;
  color: #cbd5e1;
  flex-shrink: 0;
}

/* ================= Dedicated Customer Page Styles ================= */
.cust-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

.cust-header-info {
  display: flex;
  flex-direction: column;
}

.cust-header-title {
  font-size: 17px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cust-header-subtitle {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.cust-search-wrapper {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}

.cust-search-input {
  width: 100%;
  padding: 9px 14px 9px 46px;
  font-size: 13px;
  color: #f8fafc;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  outline: none;
}

.cust-search-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.cust-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cust-count-badge-top {
  background: #0f172a;
  border: 1px solid #334155;
  color: #38bdf8;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
}

.cust-page-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.cust-form-sidebar {
  width: 380px;
  min-width: 340px;
  max-width: 420px;
  background: #182234;
  border-right: 1px solid #334155;
  padding: 18px;
  overflow-y: auto;
  flex-shrink: 0;
}

.cust-form-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 16px;
}

.cust-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #334155;
}

.cust-directory-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px;
  background: #0f172a;
}

.cust-directory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.cust-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.cust-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.15s ease;
}

.cust-card:hover {
  border-color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.cust-card-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.cust-card-name {
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
}

.cust-card-address {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
  white-space: pre-line;
}

.cust-card-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}

.cust-contact-tag {
  background: #0f172a;
  border: 1px solid #334155;
  padding: 2px 8px;
  border-radius: 4px;
  color: #cbd5e1;
}

.cust-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #334155;
  padding-top: 10px;
  margin-top: auto;
}
