/* ==========================================================================
   TESSUX DIGITAL - AUTOMATED INVOICE GENERATOR & SYSTEM
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, Menlo, monospace;

  /* App Theme (Dark Slate UI) */
  --bg-app: #0b0f19;
  --bg-panel: #111827;
  --bg-card: #1f2937;
  --bg-card-hover: #263345;
  --bg-input: #0f172a;
  --border-color: #374151;
  --border-subtle: #1e293b;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-primary: #111827;
  --accent-blue: #3b82f6;
  --accent-indigo: #6366f1;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  /* Current Active Invoice Theme Color */
  --inv-theme: #111827;
  --inv-theme-light: #f3f4f6;
  --inv-theme-dark: #000000;
  --inv-theme-contrast: #ffffff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.25), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
  --shadow-paper: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.08);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   TOP NAVIGATION BAR
   ========================================================================== */
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-logo-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #ffffff;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-info .app-tag {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.brand-info p {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

@media (max-width: 1200px) {
  .brand-info p {
    display: none;
  }
}

@media (max-width: 768px) {
  .top-navbar {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 12px;
    gap: 8px;
  }
  .brand-section {
    justify-content: space-between;
  }
  .nav-actions {
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-actions::-webkit-scrollbar {
    display: none;
  }
  .nav-actions .btn {
    flex-shrink: 0;
  }
}

/* ==========================================================================
   BUTTONS & BADGES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: #ffffff;
  color: #0b0f19;
  font-weight: 600;
}
.btn-primary:hover {
  background: #f3f4f6;
  transform: translateY(-1px);
}

.btn-accent {
  background: #4f46e5;
  color: #ffffff;
}
.btn-accent:hover {
  background: #4338ca;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: #4b5563;
}

.btn-success {
  background: #059669;
  color: #ffffff;
}
.btn-success:hover {
  background: #047857;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-paid {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-draft {
  background: rgba(156, 163, 175, 0.15);
  color: #d1d5db;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

.badge-overdue {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ==========================================================================
   APP MAIN DUAL LAYOUT
   ========================================================================== */
.app-container {
  display: grid;
  grid-template-columns: minmax(380px, 480px) 1fr;
  height: calc(100vh - 66px);
  overflow: hidden;
}

@media (min-width: 1600px) {
  .app-container {
    grid-template-columns: 520px 1fr;
  }
}

@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
}

/* Mobile View Tabs */
.mobile-view-bar {
  display: none;
}

@media (max-width: 1024px) {
  .mobile-view-bar {
    display: flex;
    background: #0f172a;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 14px;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 95;
  }
  .mobile-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
  }
  .mobile-tab-btn.active {
    background: #4f46e5;
    border-color: #6366f1;
    color: #ffffff;
  }

  .editor-panel.mobile-hidden,
  .preview-panel.mobile-hidden {
    display: none !important;
  }
}

/* ==========================================================================
   LEFT EDITOR PANEL
   ========================================================================== */
.editor-panel {
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 20px 80px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Custom Scrollbar */
.editor-panel::-webkit-scrollbar,
.preview-container::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
.editor-panel::-webkit-scrollbar-track,
.preview-container::-webkit-scrollbar-track {
  background: transparent;
}
.editor-panel::-webkit-scrollbar-thumb,
.preview-container::-webkit-scrollbar-thumb {
  background: #374151;
  border-radius: 4px;
}

/* Form Section Cards */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  width: 100%;
  min-height: min-content;
  transition: border-color var(--transition-fast);
}
.form-card:hover {
  border-color: #4b5563;
}

.card-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.card-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.form-card.open .card-header {
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.04);
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}

.card-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f3f4f6;
}

.card-header p {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.chevron-icon {
  display: block !important;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.form-card.open .chevron-icon {
  transform: rotate(180deg) !important;
  color: #818cf8;
}

.card-body {
  display: none;
  padding: 18px;
  flex-direction: column;
  gap: 14px;
}

.form-card.open .card-body {
  display: flex !important;
  flex-shrink: 0 !important;
  min-height: min-content !important;
}

.editor-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 10px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}

/* Form Fields & Grids */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.form-row-4 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-group label span.hint {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 0.7rem;
}

.input-field,
.select-field,
.textarea-field {
  width: 100%;
  background: #0b1120;
  border: 1px solid #475569;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: #ffffff;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.input-field::placeholder,
.textarea-field::placeholder {
  color: #94a3b8;
  opacity: 1;
}

.input-field:focus,
.select-field:focus,
.textarea-field:focus {
  outline: none;
  border-color: #818cf8;
  background: #0f172a;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.textarea-field {
  resize: vertical;
  min-height: 60px;
}

/* Quick Pills */
.pills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 5px 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: normal;
  text-align: left;
  line-height: 1.35;
}
.pill-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: #6b7280;
}
.pill-btn.active {
  background: #4f46e5;
  border-color: #6366f1;
  color: #ffffff;
}

/* Line Items Table in Editor */
.line-items-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

select.select-field option {
  background: #0f172a;
  color: #ffffff;
}

.item-row {
  background: #141c2e;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: border-color var(--transition-fast);
}
.item-row:hover {
  border-color: #6366f1;
}

.item-row-top {
  display: flex;
  gap: 8px;
  align-items: center;
}
.item-title-input {
  flex: 1;
  font-weight: 600;
}

.item-field-label {
  font-size: 0.68rem;
  color: #94a3b8;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
  white-space: nowrap;
}

.item-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
  gap: 10px;
  align-items: end;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.line-items-wrapper.hide-sac .item-sac-col {
  display: none !important;
}

.item-line-total {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: #34d399;
  text-align: right;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 38px;
  box-sizing: border-box;
}

@media (max-width: 600px) {
  .item-row-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .item-amount-col {
    grid-column: span 2;
  }
}

.btn-remove-item {
  color: #f87171;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-remove-item:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Service Presets Category Tabs */
.preset-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 8px;
}

.preset-cat-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.preset-cat-btn:hover {
  color: #ffffff;
}
.preset-cat-btn.active {
  background: #374151;
  color: #ffffff;
  font-weight: 600;
}

/* Service presets bar */
.presets-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-color);
}
.presets-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}

/* Project / Scope Banner on Invoice */
.inv-project-banner {
  background: #f8fafc;
  border-left: 3px solid var(--inv-theme);
  padding: 8px 14px;
  margin: 12px 0 14px 0;
  border-radius: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.inv-project-title {
  font-size: 9.5pt;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}
.inv-project-meta {
  font-size: 8pt;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 12px;
}
.inv-project-meta span strong {
  color: #334155;
}

.unit-badge {
  display: inline-block;
  padding: 2px 6px;
  background: #f1f5f9;
  border-radius: 4px;
  font-size: 7.5pt;
  font-weight: 600;
  color: #475569;
}

/* Calculation Summary Card */
.summary-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  color: var(--text-muted);
}
.summary-line.total {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
  margin-top: 4px;
}
.summary-line span.value {
  font-family: var(--font-mono);
  color: #f3f4f6;
  font-weight: 500;
}
.summary-line.total span.value {
  color: #34d399;
  font-size: 1.15rem;
}

.amount-words-box {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.78rem;
  color: #cbd5e1;
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.amount-words-box strong {
  color: #a5b4fc;
  white-space: nowrap;
}

/* ==========================================================================
   RIGHT PREVIEW PANEL
   ========================================================================== */
.preview-panel {
  background-color: #030712;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Template Selector Tabs */
.template-tabs {
  display: flex;
  background: var(--bg-input);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.template-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.template-tab-btn:hover {
  color: #ffffff;
}
.template-tab-btn.active {
  background: #374151;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Color Accent Swatches */
.color-swatches {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch.active {
  border-color: #ffffff;
  transform: scale(1.15);
}

/* Zoom Controls */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
}
.zoom-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}
.zoom-level {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 0 6px;
  min-width: 42px;
  text-align: center;
}

/* Preview Scroll Container */
.preview-container {
  flex: 1;
  overflow: auto;
  padding: 30px 20px 80px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: radial-gradient(circle at top, #1e293b 0%, #030712 100%);
}

.preview-wrapper {
  transform-origin: top center;
  transition: transform var(--transition-fast);
}

/* ==========================================================================
   THE A4 INVOICE SHEET (TRUE A4 PRINT DIMENSIONS: 210mm x 297mm)
   ========================================================================== */
.invoice-sheet {
  width: 210mm;
  min-height: 297mm;
  background: #ffffff;
  color: #1e293b;
  box-shadow: var(--shadow-paper);
  border-radius: 2px;
  padding: 16mm 18mm;
  position: relative;
  font-size: 9.5pt;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Stamp Overlay */
.invoice-stamp {
  position: absolute;
  top: 130px;
  right: 50px;
  border: 4px solid #ef4444;
  color: #ef4444;
  font-size: 26pt;
  font-weight: 900;
  text-transform: uppercase;
  padding: 6px 18px;
  border-radius: 8px;
  transform: rotate(-15deg);
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.1em;
  z-index: 5;
  display: none;
}
.invoice-stamp.visible {
  display: block;
}
.invoice-stamp.stamp-paid {
  border-color: #059669;
  color: #059669;
}
.invoice-stamp.stamp-overdue {
  border-color: #dc2626;
  color: #dc2626;
}
.invoice-stamp.stamp-draft {
  border-color: #6b7280;
  color: #6b7280;
}

/* ==========================================================================
   INVOICE TEMPLATES STYLING
   ========================================================================== */

/* --------------------------------------------------------------------------
   TEMPLATE 1: TESSUX STUDIO (Dark Minimalist / Creative Agency Aesthetic)
   -------------------------------------------------------------------------- */
.template-tessux .inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--inv-theme);
}

.template-tessux .inv-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.template-tessux .inv-logo {
  max-height: 64px;
  max-width: 140px;
  object-fit: contain;
}

.template-tessux .inv-brand-text h2 {
  font-size: 18pt;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--inv-theme);
  text-transform: uppercase;
  line-height: 1.1;
}

.template-tessux .inv-brand-text .inv-tagline {
  font-size: 8.5pt;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}

.template-tessux .inv-meta {
  text-align: right;
}

.template-tessux .inv-title {
  font-size: 24pt;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--inv-theme);
  text-transform: uppercase;
  margin-bottom: 6px;
  line-height: 1;
}

.template-tessux .inv-meta-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 12px;
  font-size: 8.5pt;
  text-align: right;
  justify-content: end;
}

.template-tessux .inv-meta-label {
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 7.5pt;
}

.template-tessux .inv-meta-val {
  font-weight: 700;
  color: #0f172a;
}

/* Info grid: From & To */
.template-tessux .inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  padding: 16px 0;
}

.template-tessux .party-card h4 {
  font-size: 8pt;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.template-tessux .party-card h3 {
  font-size: 11pt;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.template-tessux .party-details {
  font-size: 8.5pt;
  color: #475569;
  line-height: 1.45;
}

/* Table */
.template-tessux .inv-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
}

.template-tessux .inv-table th {
  background: var(--inv-theme);
  color: var(--inv-theme-contrast);
  padding: 9px 12px;
  font-size: 8pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}
.template-tessux .inv-table th.th-right,
.template-tessux .inv-table td.td-right {
  text-align: right;
}
.template-tessux .inv-table th.th-center,
.template-tessux .inv-table td.td-center {
  text-align: center;
}

.template-tessux .inv-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 8.5pt;
  vertical-align: top;
}

.template-tessux .inv-table tbody tr:nth-child(even) {
  background-color: #f8fafc;
}

.template-tessux .item-title {
  font-weight: 700;
  color: #0f172a;
}
.template-tessux .item-desc {
  font-size: 8pt;
  color: #64748b;
  margin-top: 2px;
  white-space: pre-line;
}
.template-tessux .item-code {
  font-size: 7.5pt;
  color: #94a3b8;
  font-family: var(--font-mono);
}

/* Bottom Section */
.template-tessux .inv-bottom {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 24px;
  margin-top: 10px;
}

.template-tessux .inv-totals-table {
  width: 100%;
  border-collapse: collapse;
}

.template-tessux .inv-totals-table td {
  padding: 5px 8px;
  font-size: 8.5pt;
}

.template-tessux .inv-totals-table .totals-label {
  color: #64748b;
  font-weight: 600;
  text-align: left;
}

.template-tessux .inv-totals-table .totals-val {
  text-align: right;
  font-weight: 600;
  color: #0f172a;
}

.template-tessux .inv-totals-table tr.grand-total {
  border-top: 2px solid var(--inv-theme);
  border-bottom: 2px solid var(--inv-theme);
}
.template-tessux .inv-totals-table tr.grand-total td {
  padding: 8px;
  font-size: 11pt;
  font-weight: 800;
  color: var(--inv-theme);
}

.template-tessux .words-block {
  margin-top: 12px;
  padding: 8px 12px;
  background: #f1f5f9;
  border-left: 3px solid var(--inv-theme);
  font-size: 8pt;
  color: #334155;
}

.template-tessux .pay-details {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 8pt;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.template-tessux .qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.template-tessux .qr-container svg,
.template-tessux .qr-container img {
  width: 80px;
  height: 80px;
  border: 1px solid #cbd5e1;
  padding: 3px;
  background: #ffffff;
  border-radius: 4px;
}
.template-tessux .qr-container span {
  font-size: 6.5pt;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}

/* Footer / Signatures */
.template-tessux .inv-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.template-tessux .footer-notes {
  font-size: 7.5pt;
  color: #64748b;
  max-width: 65%;
  line-height: 1.4;
}

.template-tessux .signature-area {
  text-align: right;
  min-width: 160px;
}

.template-tessux .sign-img {
  max-height: 48px;
  margin-bottom: 4px;
  display: block;
  margin-left: auto;
}

.template-tessux .sign-line {
  border-top: 1px solid #94a3b8;
  padding-top: 4px;
  font-size: 7.5pt;
  font-weight: 700;
  color: #0f172a;
}
.template-tessux .sign-sub {
  font-size: 7pt;
  color: #64748b;
}

/* --------------------------------------------------------------------------
   TEMPLATE 2: EXECUTIVE MODERN (Sleek Colored Banner / Pill Highlights)
   -------------------------------------------------------------------------- */
.template-executive .inv-header {
  background: var(--inv-theme);
  color: var(--inv-theme-contrast);
  margin: -16mm -18mm 16px -18mm;
  padding: 16mm 18mm 14mm 18mm;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.template-executive .inv-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.template-executive .inv-logo {
  max-height: 58px;
  max-width: 140px;
  background: #ffffff;
  padding: 4px;
  border-radius: 6px;
}

.template-executive .inv-brand-text h2 {
  font-size: 16pt;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.template-executive .inv-brand-text .inv-tagline {
  font-size: 8pt;
  color: rgba(255, 255, 255, 0.8);
}

.template-executive .inv-meta {
  text-align: right;
}

.template-executive .inv-title {
  font-size: 22pt;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #ffffff;
  margin-bottom: 4px;
}

.template-executive .inv-meta-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 12px;
  font-size: 8pt;
  text-align: right;
  justify-content: end;
  color: rgba(255, 255, 255, 0.9);
}

.template-executive .inv-meta-label {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

.template-executive .inv-meta-val {
  font-weight: 700;
}

.template-executive .inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding-bottom: 14px;
}

.template-executive .party-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--inv-theme);
  border-radius: 4px;
  padding: 10px 14px;
}

.template-executive .party-card h4 {
  font-size: 7.5pt;
  font-weight: 700;
  color: var(--inv-theme);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.template-executive .party-card h3 {
  font-size: 10.5pt;
  font-weight: 700;
  color: #0f172a;
}

.template-executive .party-details {
  font-size: 8pt;
  color: #475569;
}

.template-executive .inv-table th {
  background: #f1f5f9;
  color: #334155;
  border-bottom: 2px solid var(--inv-theme);
  padding: 8px 10px;
  font-size: 8pt;
  font-weight: 700;
  text-transform: uppercase;
}

.template-executive .inv-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 8.5pt;
}

.template-executive .inv-bottom {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 20px;
  margin-top: 10px;
}

.template-executive .inv-totals-table tr.grand-total {
  background: #f8fafc;
  border-left: 3px solid var(--inv-theme);
}
.template-executive .inv-totals-table tr.grand-total td {
  padding: 8px;
  font-size: 11pt;
  font-weight: 800;
  color: var(--inv-theme);
}

/* --------------------------------------------------------------------------
   TEMPLATE 3: CLEAN PROFESSIONAL / GST FORMAL
   -------------------------------------------------------------------------- */
.template-gst {
  font-family: Arial, Helvetica, sans-serif;
  border: 2px solid #0f172a;
  padding: 12mm 14mm;
}

.template-gst .inv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.template-gst .inv-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.template-gst .inv-logo {
  max-height: 52px;
  max-width: 120px;
  object-fit: contain;
}

.template-gst .inv-brand-text h2 {
  font-size: 15pt;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.template-gst .inv-brand-text .inv-tagline {
  font-size: 8pt;
  color: #475569;
}

.template-gst .inv-meta {
  text-align: right;
}

.template-gst .inv-title {
  font-size: 18pt;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #0f172a;
  text-transform: uppercase;
}

.template-gst .inv-meta-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 10px;
  font-size: 8pt;
  text-align: right;
  justify-content: end;
}

.template-gst .inv-meta-label {
  color: #475569;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 7pt;
}

.template-gst .inv-meta-val {
  font-weight: 700;
  color: #000000;
}

.template-gst .inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #0f172a;
  margin-bottom: 14px;
}

.template-gst .party-card {
  padding: 8px 12px;
}
.template-gst .party-card:first-child {
  border-right: 1px solid #0f172a;
}

.template-gst .party-card h4 {
  font-size: 7.5pt;
  font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 3px;
  margin-bottom: 4px;
}

.template-gst .party-card h3 {
  font-size: 10pt;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.template-gst .party-details {
  font-size: 8pt;
  color: #1e293b;
  line-height: 1.4;
}

.template-gst .inv-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #0f172a;
  margin-bottom: 14px;
}

.template-gst .inv-table th {
  border: 1px solid #0f172a;
  background: #f1f5f9;
  color: #0f172a;
  padding: 6px 8px;
  font-size: 7.5pt;
  font-weight: 800;
  text-transform: uppercase;
  text-align: left;
}
.template-gst .inv-table th.th-center,
.template-gst .inv-table td.td-center {
  text-align: center;
}
.template-gst .inv-table th.th-right,
.template-gst .inv-table td.td-right {
  text-align: right;
}

.template-gst .inv-table td {
  border: 1px solid #0f172a;
  padding: 7px 8px;
  font-size: 8pt;
  vertical-align: top;
}

.template-gst .item-title {
  font-weight: 700;
  color: #0f172a;
}
.template-gst .item-desc {
  font-size: 7.5pt;
  color: #475569;
}
.template-gst .item-code {
  font-family: var(--font-mono);
  font-weight: 600;
}

.template-gst .inv-bottom {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 16px;
  margin-top: 10px;
}

.template-gst .inv-totals-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #0f172a;
}

.template-gst .inv-totals-table td {
  border: 1px solid #0f172a;
  padding: 5px 8px;
  font-size: 8pt;
}

.template-gst .inv-totals-table .totals-label {
  font-weight: 700;
  color: #1e293b;
}
.template-gst .inv-totals-table .totals-val {
  text-align: right;
  font-weight: 700;
  color: #000000;
}

.template-gst .inv-totals-table tr.grand-total {
  background: #f1f5f9;
}
.template-gst .inv-totals-table tr.grand-total td {
  font-size: 10pt;
  font-weight: 900;
  color: #0f172a;
}

.template-gst .words-block {
  border: 1px solid #0f172a;
  padding: 6px 10px;
  font-size: 7.5pt;
  background: #f8fafc;
  margin-top: 8px;
}

.template-gst .pay-details {
  border: 1px solid #0f172a;
  padding: 8px 10px;
  font-size: 7.5pt;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  background: #ffffff;
}

.template-gst .inv-footer {
  margin-top: 16px;
  border-top: 2px solid #0f172a;
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.template-gst .footer-notes {
  font-size: 7pt;
  color: #475569;
  max-width: 65%;
}

.template-gst .signature-area {
  text-align: right;
  min-width: 160px;
}
.template-gst .sign-line {
  border-top: 1px solid #0f172a;
  padding-top: 4px;
  font-size: 7.5pt;
  font-weight: 800;
  color: #0f172a;
}
.template-gst .sign-sub {
  font-size: 7pt;
  color: #475569;
}

/* --------------------------------------------------------------------------
   TEMPLATE 4: MINIMAL AGENCY
   -------------------------------------------------------------------------- */
.template-minimal {
  font-family: var(--font-sans);
  padding: 16mm 18mm;
}

.template-minimal .inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.template-minimal .inv-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.template-minimal .inv-logo {
  max-height: 52px;
  max-width: 120px;
  object-fit: contain;
}

.template-minimal .inv-brand-text h2 {
  font-size: 16pt;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.template-minimal .inv-brand-text .inv-tagline {
  font-size: 8pt;
  color: #64748b;
}

.template-minimal .inv-meta {
  text-align: right;
}

.template-minimal .inv-title {
  font-size: 16pt;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}

.template-minimal .inv-meta-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 12px;
  font-size: 8pt;
  text-align: right;
  justify-content: end;
}

.template-minimal .inv-meta-label {
  color: #94a3b8;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 7.5pt;
}

.template-minimal .inv-meta-val {
  font-weight: 600;
  color: #0f172a;
}

.template-minimal .inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  padding: 20px 0;
}

.template-minimal .party-card h4 {
  font-size: 7.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 4px;
}

.template-minimal .party-card h3 {
  font-size: 10.5pt;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 2px;
}

.template-minimal .party-details {
  font-size: 8pt;
  color: #64748b;
  line-height: 1.5;
}

.template-minimal .inv-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.template-minimal .inv-table th {
  background: transparent;
  color: #0f172a;
  border-top: 1px solid #0f172a;
  border-bottom: 1px solid #0f172a;
  padding: 8px 6px;
  font-size: 7.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}
.template-minimal .inv-table th.th-right,
.template-minimal .inv-table td.td-right {
  text-align: right;
}
.template-minimal .inv-table th.th-center,
.template-minimal .inv-table td.td-center {
  text-align: center;
}

.template-minimal .inv-table td {
  padding: 10px 6px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 8.5pt;
  vertical-align: top;
}

.template-minimal .item-title {
  font-weight: 600;
  color: #0f172a;
}
.template-minimal .item-desc {
  font-size: 8pt;
  color: #64748b;
  margin-top: 2px;
}
.template-minimal .item-code {
  font-size: 7.5pt;
  color: #94a3b8;
  font-family: var(--font-mono);
}

.template-minimal .inv-bottom {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 30px;
  margin-top: 14px;
}

.template-minimal .inv-totals-table {
  width: 100%;
  border-collapse: collapse;
}

.template-minimal .inv-totals-table td {
  padding: 5px 4px;
  font-size: 8.5pt;
}

.template-minimal .inv-totals-table .totals-label {
  color: #64748b;
}

.template-minimal .inv-totals-table .totals-val {
  text-align: right;
  font-weight: 600;
  color: #0f172a;
}

.template-minimal .inv-totals-table tr.grand-total {
  border-top: 1px solid #0f172a;
  border-bottom: 1px solid #0f172a;
}
.template-minimal .inv-totals-table tr.grand-total td {
  padding: 8px 4px;
  font-size: 11pt;
  font-weight: 800;
  color: #0f172a;
}

.template-minimal .words-block {
  margin-top: 12px;
  font-size: 8pt;
  color: #64748b;
  padding: 6px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.template-minimal .pay-details {
  border: 1px solid #f1f5f9;
  background: #fafafa;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 8pt;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.template-minimal .inv-footer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.template-minimal .footer-notes {
  font-size: 7.5pt;
  color: #94a3b8;
  max-width: 65%;
  line-height: 1.4;
}

.template-minimal .signature-area {
  text-align: right;
  min-width: 160px;
}
.template-minimal .sign-line {
  border-top: 1px solid #0f172a;
  padding-top: 4px;
  font-size: 7.5pt;
  font-weight: 700;
  color: #0f172a;
}
.template-minimal .sign-sub {
  font-size: 7pt;
  color: #94a3b8;
}

/* ==========================================================================
   COLOR ACCENTS FOR TEMPLATES
   ========================================================================== */
.accent-black {
  --inv-theme: #111827;
  --inv-theme-contrast: #ffffff;
}
.accent-indigo {
  --inv-theme: #4f46e5;
  --inv-theme-contrast: #ffffff;
}
.accent-emerald {
  --inv-theme: #059669;
  --inv-theme-contrast: #ffffff;
}
.accent-blue {
  --inv-theme: #2563eb;
  --inv-theme-contrast: #ffffff;
}
.accent-burgundy {
  --inv-theme: #9f1239;
  --inv-theme-contrast: #ffffff;
}

/* ==========================================================================
   MODAL DIALOGS & OVERLAYS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 20px;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(15px);
  transition: transform var(--transition-normal);
  overflow: hidden;
}
.modal-backdrop.open .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
}

/* History List inside Modal */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   CRUD INVOICES DASHBOARD & HISTORY
   ========================================================================== */
.modal-history-card {
  max-width: 840px !important;
}

.crud-kpi-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

@media (max-width: 640px) {
  .crud-kpi-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.crud-kpi-card {
  background: #0b1120;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.crud-kpi-card .kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #94a3b8;
}
.crud-kpi-card .kpi-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #f8fafc;
}
.crud-kpi-card.kpi-paid .kpi-value {
  color: #34d399;
}
.crud-kpi-card.kpi-pending .kpi-value {
  color: #fbbf24;
}

.crud-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.crud-status-tabs {
  display: flex;
  gap: 4px;
  background: #0b1120;
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid #334155;
  overflow-x: auto;
}

.crud-filter-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.crud-filter-btn:hover {
  color: #ffffff;
}
.crud-filter-btn.active {
  background: #4f46e5;
  color: #ffffff;
}

.crud-invoice-card {
  background: #141c2e;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition-fast);
  margin-bottom: 10px;
}
.crud-invoice-card:hover {
  border-color: #6366f1;
  background: #182238;
}

.crud-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.crud-card-id-block {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.crud-inv-num {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  font-family: var(--font-mono);
}
.crud-status-toggle {
  cursor: pointer;
  border: none;
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  text-transform: uppercase;
  transition: transform 0.15s ease;
}
.crud-status-toggle:hover {
  transform: scale(1.05);
}
.crud-po-tag {
  font-size: 0.7rem;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.crud-inv-total {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: #34d399;
}

.crud-card-mid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.crud-client-name {
  font-size: 0.9rem;
  color: #f1f5f9;
}
.crud-contact-sub {
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: normal;
  margin-left: 4px;
}
.crud-project-name {
  font-size: 0.78rem;
  color: #cbd5e1;
}

.crud-card-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.74rem;
  color: #94a3b8;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.crud-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-fast);
}
.history-item:hover {
  border-color: #6366f1;
  background: var(--bg-card-hover);
}

.history-item-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.history-num {
  font-weight: 700;
  font-size: 0.9rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-client {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.history-date {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.history-item-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-total {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: #34d399;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #ffffff;
  border: 1px solid #374151;
  border-left: 4px solid #6366f1;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease forwards;
  pointer-events: auto;
}
.toast.toast-success {
  border-left-color: #10b981;
}
.toast.toast-error {
  border-left-color: #ef4444;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==========================================================================
   AUTHENTICATION & SECURITY VAULT STYLES
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(circle at 50% 20%, #1e293b 0%, #0b1120 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(59, 130, 246, 0.15);
  padding: 32px 28px;
  animation: authFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes authFadeUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid #475569;
  background: #000;
}

.auth-brand-text h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  margin: 0;
}

.auth-tag {
  display: inline-block;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}

.auth-header-desc h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 4px 0;
}

.auth-header-desc p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 16px 0;
}

.auth-security-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.sec-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-field-icon {
  position: absolute;
  left: 12px;
  color: #64748b;
  pointer-events: none;
}

.auth-input {
  padding-left: 36px !important;
  padding-right: 40px !important;
  background: #1e293b !important;
  border: 1px solid #334155 !important;
  color: #ffffff !important;
  font-size: 0.9rem !important;
  height: 42px;
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25) !important;
}

.btn-toggle-pwd {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-toggle-pwd:hover {
  color: #f1f5f9;
}

.auth-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-size: 0.8rem;
}

.auth-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.auth-submit-btn {
  width: 100%;
  height: 44px;
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #4f46e5 !important;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.auth-submit-btn:hover {
  background: #4338ca !important;
}

.auth-submit-btn:active {
  transform: scale(0.99);
}

.auth-error-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.auth-demo-hint {
  margin-top: 20px;
  padding: 12px 14px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px dashed #334155;
  border-radius: var(--radius-sm);
}

.auth-hint-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.btn-quick-fill {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.4);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-quick-fill:hover {
  background: rgba(99, 102, 241, 0.4);
}

.auth-cred-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: #020617;
  padding: 6px 10px;
  border-radius: 4px;
  color: #38bdf8;
  border: 1px solid #1e293b;
}

/* TOPBAR VAULT PILL */
.vault-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
}

.vault-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.vault-pill.saving .vault-dot {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse 1s infinite;
}

.vault-pill.saving {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* SECURITY MODAL */
.sec-info-card {
  background: #0b1120;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.8rem;
}
.sec-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sec-info-row:last-child {
  border-bottom: none;
}

/* ==========================================================================
   PRINT STYLESHEET (CRITICAL FOR PDF & DIRECT PRINT)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .top-navbar,
  .editor-panel,
  .preview-toolbar,
  .modal-backdrop,
  .toast-container,
  .auth-overlay,
  .no-print {
    display: none !important;
  }

  .app-container {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .preview-panel {
    background: transparent !important;
    height: auto !important;
    overflow: visible !important;
  }

  .preview-container {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  .preview-wrapper {
    transform: none !important;
  }

  .invoice-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    min-height: auto !important;
    margin: 0 !important;
  }

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

  .inv-footer,
  .inv-bottom {
    page-break-inside: avoid;
  }
}
