/* ==========================================================================
   TAGIHKILAT — Modern Responsive Design System & Stylesheet
   ========================================================================== */

:root {
  /* Dark Cockpit Palette (Editor Frame) */
  --bg-main: #0b0f19;
  --bg-card: #151d30;
  --bg-card-hover: #1c2742;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  /* Brand Accent */
  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.35);
  --primary-hover: #4338ca;
  --accent-gold: #f59e0b;
  --accent-emerald: #10b981;
  --accent-danger: #ef4444;

  /* Live A4 Theme Colors (Default: Indigo) */
  --theme-accent: #4338ca;
  --theme-light: #eef2ff;
  --theme-text: #1e1b4b;
  
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Global */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* --------------------------------------------------------------------------
   Header Bar
   -------------------------------------------------------------------------- */
.app-header {
  height: 64px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  font-size: 1.35rem;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px var(--primary-glow);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.2;
}

.pro-tag {
  font-size: 0.65rem;
  font-weight: 800;
  background: #334155;
  color: #cbd5e1;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  transition: var(--transition-smooth);
}

.pro-tag.is-pro {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Action Buttons */
button {
  font-family: var(--font-family);
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-upgrade {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #1e1b4b;
  font-weight: 800;
  font-size: 0.825rem;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
  animation: pulse-glow 2.5s infinite;
}

.btn-upgrade:hover {
  transform: scale(1.03);
}

.btn-theme-toggle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.825rem;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.2); }
  50% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.6); }
}

/* --------------------------------------------------------------------------
   Mobile Tab Switcher (Segmented Control)
   -------------------------------------------------------------------------- */
.mobile-tabs-bar {
  display: none; /* hidden on desktop */
  background: #0f172a;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 64px;
  z-index: 45;
  gap: 8px;
}

.mobile-tab-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.mobile-tab-btn.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border-color: #6366f1;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.tab-badge {
  background: #f59e0b;
  color: #000;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
}

/* --------------------------------------------------------------------------
   App Layout (Split Screen on Desktop)
   -------------------------------------------------------------------------- */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Left Editor Column */
.editor-panel {
  width: 500px;
  background: var(--bg-main);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.btn-ghost-sm {
  background: transparent;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-decoration: underline;
  padding: 2px 4px;
}
.btn-ghost-sm:hover {
  color: var(--text-main);
}

/* Form Cards */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 0.85rem;
}

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

.badge-count {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Grid & Inputs */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: #0d1321;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.825rem;
  transition: var(--transition-smooth);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Status Pembayaran Toggle Group */
.status-form-group {
  margin-top: 0.6rem;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

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

.status-quick-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 400;
}

.status-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.btn-status-toggle {
  background: #0d1321;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.btn-status-toggle:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
  transform: translateY(-1px);
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dot-unpaid {
  background: #f87171;
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.6);
}

.dot-paid {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
}

.btn-status-toggle.active[data-status="unpaid"] {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #fca5a5;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.25);
}

.btn-status-toggle.active[data-status="unpaid"] .dot-unpaid {
  transform: scale(1.3);
  box-shadow: 0 0 10px #ef4444;
}

.btn-status-toggle.active[data-status="paid"] {
  background: rgba(16, 185, 129, 0.16);
  border-color: #10b981;
  color: #6ee7b7;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
}

.btn-status-toggle.active[data-status="paid"] .dot-paid {
  transform: scale(1.3);
  box-shadow: 0 0 10px #10b981;
}

/* File Uploaders */
.file-upload-wrapper {
  position: relative;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.6rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.file-upload-wrapper input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.btn-clear-img {
  background: var(--accent-danger);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 2;
}

/* Item Rows Table */
.items-table-wrapper {
  margin-bottom: 0.75rem;
}

.items-table-header {
  display: flex;
  gap: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  padding: 0.35rem 0.25rem;
  text-transform: uppercase;
}

.col-desc { flex: 3; }
.col-qty { flex: 1; text-align: center; }
.col-price { flex: 1.5; text-align: right; }
.col-total { flex: 1.5; text-align: right; }
.col-act { width: 28px; }

.item-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  animation: fadeIn 0.2s ease-in-out;
}

.item-row input {
  padding: 0.45rem 0.5rem;
  font-size: 0.8rem;
}

.btn-remove-row {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}
.btn-remove-row:hover {
  background: var(--accent-danger);
  color: #fff;
}

.btn-add-item {
  width: 100%;
  background: rgba(99, 102, 241, 0.1);
  border: 1px dashed rgba(99, 102, 241, 0.4);
  color: #818cf8;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.6rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.btn-add-item:hover {
  background: rgba(99, 102, 241, 0.2);
}

.calc-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.75rem;
}

/* Signature Pad */
.signature-box-wrapper {
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}

#sigCanvas {
  width: 100%;
  height: 80px;
  background: #fff;
  cursor: crosshair;
  touch-action: none !important;
}

.sig-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px;
  border-top: 1px solid #e2e8f0;
}

.sig-hint {
  font-size: 0.65rem;
  color: #64748b;
}

.btn-ghost-xs {
  background: transparent;
  color: #ef4444;
  font-size: 0.65rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Right Live A4 Preview
   -------------------------------------------------------------------------- */
.preview-panel {
  flex: 1;
  background: #111827;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-toolbar {
  height: 48px;
  background: #1f2937;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  flex-shrink: 0;
}

.preview-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

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

.theme-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-pill {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition-smooth);
}

.theme-pill.active {
  border-color: #fff;
  transform: scale(1.15);
}

.theme-indigo { background: #4338ca; }
.theme-emerald { background: #059669; }
.theme-slate { background: #334155; }
.theme-crimson { background: #be123c; }

/* The A4 Viewport */
.a4-sheet-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  justify-content: center;
}

/* A4 Page Dimensions (794px standard A4) */
.a4-sheet {
  width: 794px;
  min-height: 1120px;
  background: #ffffff;
  color: #1e293b;
  padding: 48px 56px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  position: relative;
  box-sizing: border-box;
}

/* Invoice Header */
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.inv-brand-section {
  display: flex;
  gap: 16px;
  max-width: 440px;
}

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

.inv-company-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--theme-accent);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.inv-company-text {
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.4;
}

.inv-badge-section {
  text-align: right;
}

.inv-title-large {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--theme-accent);
  line-height: 1;
  margin-bottom: 12px;
}

.inv-meta-row {
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.meta-label {
  color: #64748b;
  margin-right: 6px;
}

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

.inv-divider {
  height: 2px;
  background: var(--theme-accent);
  margin-bottom: 24px;
  opacity: 0.85;
}

/* Client Bill To */
.inv-client-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border-left: 4px solid var(--theme-accent);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 28px;
}

.client-heading {
  font-size: 0.7rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.05em;
}

.client-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 2px 0;
}

.client-sub {
  font-size: 0.8rem;
  color: #475569;
}

.status-stamp {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: 6px;
  transform: rotate(-3deg);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.status-stamp:hover {
  transform: rotate(-1deg) scale(1.06);
}

.status-stamp:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

.status-stamp.status-unpaid {
  color: #dc2626;
  border: 2px solid #dc2626;
  background: rgba(220, 38, 38, 0.06);
}

.status-stamp.status-paid {
  color: #059669;
  border: 2px solid #059669;
  background: rgba(5, 150, 105, 0.08);
}

/* Invoice Table */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.inv-table th {
  background: var(--theme-accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  letter-spacing: 0.05em;
}

.inv-table th:first-child { border-radius: 6px 0 0 6px; }
.inv-table th:last-child { border-radius: 0 6px 6px 0; }

.inv-table td {
  padding: 12px 14px;
  font-size: 0.825rem;
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
}

.inv-table tr:last-child td {
  border-bottom: 2px solid #cbd5e1;
}

/* Summary & Totals */
.inv-summary-section {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.inv-payment-box {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
}

.pay-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--theme-accent);
  margin-bottom: 6px;
}

.pay-info {
  font-family: var(--font-family);
  font-size: 0.75rem;
  color: #334155;
  white-space: pre-wrap;
  line-height: 1.5;
}

.prev-qris-container {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 6px 10px;
  border-radius: 6px;
}

.prev-qris-container img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.prev-qris-container span {
  font-size: 0.7rem;
  font-weight: 700;
  color: #0f172a;
}

.inv-totals-box {
  width: 280px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 6px 0;
  color: #475569;
}

.calc-row span:last-child {
  font-weight: 600;
  color: #0f172a;
}

.text-danger {
  color: #dc2626 !important;
}

.inv-divider-sm {
  height: 1px;
  background: #cbd5e1;
  margin: 6px 0;
}

.total-highlight {
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  color: var(--theme-accent) !important;
  border-top: 2px solid var(--theme-accent);
  padding-top: 8px;
}

.total-highlight span:last-child {
  color: var(--theme-accent) !important;
  font-size: 1.15rem;
}

/* Footer & Signature */
.inv-footer-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 20px;
}

.inv-notes-box {
  max-width: 440px;
}

.notes-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
}

.notes-text {
  font-size: 0.75rem;
  color: #475569;
  margin-top: 4px;
}

.inv-signature-block {
  text-align: center;
  width: 180px;
}

.sig-company-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 8px;
}

.sig-space {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sig-space img {
  max-height: 55px;
  max-width: 140px;
}

.sig-line {
  height: 1px;
  background: #475569;
  margin: 4px 0;
}

.sig-title {
  font-size: 0.7rem;
  color: #64748b;
}

/* Watermark */
.inv-watermark {
  margin-top: 24px;
  text-align: center;
  font-size: 0.7rem;
  color: #94a3b8;
  border-top: 1px dashed #e2e8f0;
  padding-top: 10px;
}

/* --------------------------------------------------------------------------
   Floating Mobile Quick Bar
   -------------------------------------------------------------------------- */
.mobile-floating-bar {
  display: none; /* hidden on desktop */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 14px;
  z-index: 90;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.floating-info {
  display: flex;
  flex-direction: column;
}

.floating-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.floating-val {
  font-size: 0.95rem;
  color: #f59e0b;
}

.floating-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-float-view {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-float-pdf {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* --------------------------------------------------------------------------
   Modal Upgrade PRO (Monetization Engine)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: #131b2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 1.75rem;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  animation: scaleUp 0.25s ease-out;
}

.modal-close-btn {
  position: absolute;
  top: 14px; right: 18px;
  background: transparent;
  color: #94a3b8;
  font-size: 1.5rem;
}
.modal-close-btn:hover { color: #fff; }

.modal-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1e1b4b;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.25rem;
}

.modal-subtitle {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.price-highlight {
  color: #f59e0b;
  font-size: 1.05rem;
}

.pro-perks-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.perk-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.75rem;
  border-radius: 8px;
}

.perk-icon { font-size: 1.2rem; }

.perk-item b {
  font-size: 0.825rem;
  color: #fff;
}

.perk-item p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.payment-box {
  background: #0a0f1d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 1rem;
}

.pay-step-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 0.5rem;
}

.pay-steps {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-left: 1.2rem;
  margin-bottom: 0.75rem;
}

.admin-bank-card {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 0.85rem;
}

.bank-tag {
  font-size: 0.65rem;
  color: #818cf8;
  font-weight: 700;
}

.bank-acc {
  font-size: 0.9rem;
  color: #fff;
}

.bank-name {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.voucher-input-group {
  display: flex;
  gap: 0.5rem;
}

.btn-activate {
  background: #10b981;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0 1rem;
  border-radius: 6px;
  white-space: nowrap;
}
.btn-activate:hover { background: #059669; }

.voucher-hint {
  font-size: 0.7rem;
  color: #f59e0b;
  margin-top: 0.5rem;
}

/* Toast */
.toast-notification {
  position: fixed;
  bottom: 74px;
  right: 18px;
  background: #1e293b;
  color: #fff;
  border-left: 4px solid var(--accent-emerald);
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-size: 0.825rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 9999;
}

.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE ENGINE (CRITICAL FIX)
   ========================================================================== */
@media screen and (max-width: 900px) {

  /* Header on Mobile */
  .app-header {
    height: 56px;
    padding: 0 10px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .brand-subtitle {
    display: none;
  }

  .btn-theme-toggle {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .btn-theme-toggle .btn-text {
    display: none;
  }

  .btn-upgrade {
    padding: 6px 9px;
    font-size: 0.75rem;
  }

  .btn-primary, .btn-secondary {
    display: none; /* Accessible via mobile quick bar */
  }

  /* Show Mobile Nav Bar */
  .mobile-tabs-bar {
    display: flex;
    top: 56px;
  }

  /* Main Container Stacked */
  .app-container {
    height: auto;
    min-height: calc(100vh - 110px);
    flex-direction: column;
    overflow: visible;
  }

  /* Panels Mobile Switching */
  .editor-panel {
    width: 100% !important;
    border-right: none;
    padding: 1rem 0.85rem 5.5rem;
    overflow-y: visible;
  }

  .preview-panel {
    width: 100% !important;
    overflow-y: visible;
    padding-bottom: 5.5rem;
  }

  /* When editor is active on mobile, hide preview; and vice versa */
  body.mobile-view-editor .preview-panel {
    display: none !important;
  }

  body.mobile-view-preview .editor-panel {
    display: none !important;
  }

  body.mobile-view-preview .preview-panel {
    display: flex !important;
  }

  /* Show Floating Mobile Action Bar */
  .mobile-floating-bar {
    display: flex;
  }

  /* Grids collapse to 1 column on phone */
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  /* Items Table on Phone */
  .items-table-header {
    display: none; /* Hide header, label inside rows */
  }

  .item-row {
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px;
    border-radius: 8px;
    gap: 6px;
  }

  .item-row .col-desc {
    flex: 1 1 100%;
    font-weight: 600;
  }

  .item-row .col-qty {
    flex: 1;
    min-width: 60px;
  }

  .item-row .col-price {
    flex: 2;
    min-width: 100px;
  }

  .item-row .col-total {
    flex: 2;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  /* A4 Invoice Preview on Mobile */
  .a4-sheet-wrapper {
    padding: 0.75rem 0.5rem 5.5rem !important;
    overflow-x: auto;
  }

  .a4-sheet {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    padding: 20px 14px !important;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  }

  .inv-header {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
  }

  .inv-brand-section {
    max-width: 100%;
  }

  .inv-company-name {
    font-size: 1.15rem;
  }

  .inv-badge-section {
    text-align: left;
    width: 100%;
    border-top: 1px dashed #e2e8f0;
    padding-top: 10px;
  }

  .inv-title-large {
    font-size: 1.5rem;
    margin-bottom: 6px;
  }

  .inv-client-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
  }

  .status-stamp {
    transform: none;
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .inv-table th,
  .inv-table td {
    padding: 8px 6px;
    font-size: 0.75rem;
  }

  .inv-summary-section {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
  }

  .inv-totals-box {
    width: 100%;
  }

  .inv-footer-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }

  .inv-notes-box {
    max-width: 100%;
  }

  .inv-signature-block {
    width: 100%;
    text-align: left;
  }

  .sig-space {
    justify-content: flex-start;
  }
}

/* --------------------------------------------------------------------------
   PRINT STYLESHEET (Clean A4 Printout)
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
  }

  .app-header,
  .mobile-tabs-bar,
  .mobile-floating-bar,
  .editor-panel,
  .preview-toolbar,
  .modal-overlay,
  .toast-notification {
    display: none !important;
  }

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

  .preview-panel {
    background: transparent !important;
    overflow: visible !important;
    width: 100% !important;
    display: block !important;
  }

  .a4-sheet-wrapper {
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  .a4-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    width: 100% !important;
    padding: 16mm !important;
    min-height: auto !important;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }
}
