:root {
  --primary: #09090b;
  --primary-dark: #000000;
  --primary-light: #18181b;
  --accent: #aec538;
  --accent-light: #c5dc4c;
  --accent-dark: #7a8f15;
  --accent-bg: #f8faec;
  --accent-border: #dbe79a;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --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 -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: var(--font-main);
  background-color: #f1f5f9;
  color: var(--slate-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==================== APP HEADER ==================== */
.app-header {
  background: linear-gradient(135deg, #09090b 0%, #18181b 50%, #09090b 100%);
  color: var(--white);
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.header-container {
  max-width: 1720px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

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

.brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1.5px solid rgba(174, 197, 56, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  background: #000;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.brand-svg-logo {
  width: 100%;
  height: 100%;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--white);
  line-height: 1.1;
}

.brand-title span {
  color: var(--accent-light);
  font-size: 0.85rem;
  background: rgba(16, 185, 129, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #a7f3d0;
  font-weight: 500;
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: var(--radius-md);
}

.nav-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.revenue-summary {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rev-label {
  color: #a7f3d0;
  font-weight: 500;
}

.rev-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--white);
}

/* ==================== TABS SYSTEM ==================== */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.container {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

.max-w-800 {
  max-width: 800px;
}

/* ==================== BUILDER LAYOUT ==================== */
.builder-layout {
  display: grid;
  grid-template-columns: 580px 1fr;
  min-height: calc(100vh - 65px);
}

@media (max-width: 1200px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }
}

.builder-form-panel {
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  border-right: 1px solid var(--slate-200);
  height: calc(100vh - 65px);
  overflow-y: auto;
}

.builder-preview-panel {
  padding: 1.5rem;
  background: #e2e8f0;
  height: calc(100vh - 65px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ==================== CARDS & FORMS ==================== */
.form-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--slate-100);
}

.card-header h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--slate-800);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.header-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent);
  display: inline-block;
}

.hint-text {
  font-size: 0.75rem;
  color: var(--slate-500);
}

.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
  background: var(--white);
  border-color: var(--accent-border);
}

.action-buttons-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s ease-in-out;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  background: var(--slate-100);
  color: var(--slate-700);
  border-color: var(--slate-300);
}

.btn-secondary:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.btn-accent {
  background: #047857;
  color: var(--white);
}

.btn-accent:hover {
  background: #065f46;
}

.btn-outline {
  background: var(--white);
  border-color: #25d366;
  color: #128c7e;
}

.btn-outline:hover {
  background: #f0fdf4;
}

.btn-ghost {
  background: transparent;
  color: var(--slate-600);
  border-color: var(--slate-200);
}

.btn-ghost:hover {
  background: var(--slate-100);
  color: var(--slate-900);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.mini-btn {
  background: var(--slate-100);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.mini-btn:hover {
  background: var(--slate-200);
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--slate-700);
}

input[type="text"],
input[type="date"],
input[type="tel"],
input[type="email"],
input[type="number"],
select,
textarea {
  font-family: var(--font-main);
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--slate-800);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.input-with-action {
  display: flex;
  gap: 0.35rem;
}

.input-with-action input {
  flex: 1;
}

.input-split {
  display: flex;
  gap: 0.35rem;
}

.input-split input {
  width: 60%;
}

.input-split select {
  width: 40%;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

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

.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.text-emerald { color: #059669; }
.text-muted { color: var(--slate-500); font-size: 0.85rem; }

/* Segmented Control */
.segmented-control {
  display: inline-flex;
  background: var(--slate-100);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
}

.segmented-control input[type="radio"] {
  display: none;
}

.segmented-control label {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  color: var(--slate-600);
  transition: all 0.15s ease;
}

.segmented-control input[type="radio"]:checked + label {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Fast Catalog Pills */
.fast-catalog-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-height: 140px;
  overflow-y: auto;
  padding-bottom: 2px;
}

.pill-item {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: #065f46;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.pill-item:hover {
  background: #d1fae5;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.pill-price {
  font-family: var(--font-mono);
  background: rgba(6, 78, 59, 0.1);
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 0.7rem;
}

/* Items Table inside Form */
.table-responsive {
  overflow-x: auto;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.items-table th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-weight: 700;
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--slate-200);
}

.items-table td {
  padding: 0.4rem 0.35rem;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: top;
}

.items-table input {
  width: 100%;
  padding: 0.35rem 0.45rem;
  font-size: 0.8rem;
}

.btn-remove-row {
  background: transparent;
  border: none;
  color: var(--slate-400);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: color 0.15s ease;
}

.btn-remove-row:hover {
  color: var(--danger);
}

/* Calculation summary bar */
.calculation-summary {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.25rem 0;
  color: var(--slate-600);
}

.total-line {
  border-top: 2px solid var(--slate-300);
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}

.grand-value {
  color: var(--primary);
}

/* ==================== PREVIEW TOOLBAR ==================== */
.preview-toolbar {
  width: 100%;
  max-width: 820px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  background: var(--white);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-300);
  box-shadow: var(--shadow-sm);
}

.preview-mode-tag {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--slate-600);
  letter-spacing: 0.05em;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.preview-controls {
  display: flex;
  gap: 0.4rem;
}

.icon-toggle-btn {
  background: var(--slate-100);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-toggle-btn.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

/* ==================== INVOICE SHEET (A4) ==================== */
.invoice-viewport {
  width: 100%;
  display: flex;
  justify-content: center;
}

.invoice-paper {
  background: var(--white);
  position: relative;
  box-shadow: var(--shadow-xl);
  border-radius: 2px;
  overflow: hidden;
}

.a4-size {
  width: 210mm;
  min-height: 297mm;
  padding: 18mm 16mm;
  display: flex;
  flex-direction: column;
}

.invoice-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-35deg);
  font-size: 9rem;
  font-weight: 900;
  color: rgba(6, 78, 59, 0.025);
  pointer-events: none;
  z-index: 0;
  letter-spacing: 0.2em;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 1.25rem;
  border-bottom: 3px solid #09090b;
  position: relative;
  z-index: 1;
}

.company-logo-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.invoice-logo-img {
  width: 68px;
  height: 68px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 2px solid #09090b;
  background: #000000;
}

.brand-text-block {
  display: flex;
  flex-direction: column;
}

.comp-name {
  font-size: 1.85rem;
  font-weight: 900;
  color: #09090b;
  letter-spacing: -0.02em;
  line-height: 1;
}

.comp-tagline {
  font-size: 0.75rem;
  color: #6a7d0e;
  font-weight: 700;
  margin-top: 3px;
}

.company-contact-block {
  font-size: 0.75rem;
  color: var(--slate-600);
  line-height: 1.45;
  max-width: 340px;
}

.invoice-meta-col {
  text-align: right;
}

.invoice-type-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.meta-row {
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.meta-label {
  color: var(--slate-500);
  margin-right: 0.4rem;
}

.meta-value {
  font-weight: 700;
  color: var(--slate-800);
}

.status-stamp {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-stamp.paid {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #10b981;
}

.status-stamp.pending {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #f59e0b;
}

.status-stamp.overdue {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #ef4444;
}

.status-stamp.draft {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #94a3b8;
}

/* ==================== PAYMENT REPORT ==================== */
.payments-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.payment-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.payment-summary-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--slate-400);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}

.payment-summary-card span {
  display: block;
  color: var(--slate-500);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.payment-summary-card strong {
  display: block;
  color: var(--slate-900);
  font-family: var(--font-mono);
  font-size: 1.2rem;
  margin-top: 0.35rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef5ef;
}

.login-shell { width: min(92vw, 420px); }

.login-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  padding: 2.25rem;
}

.login-brand {
  color: var(--slate-900);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.login-kicker {
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h1 { margin: 1.6rem 0 1.35rem; }
.login-card label { display: block; margin: 0.9rem 0 0.35rem; font-weight: 700; }
.login-card input { width: 100%; }
.login-submit { width: 100%; margin-top: 1.25rem; }
.login-error { min-height: 1.25rem; color: var(--danger); font-size: 0.82rem; margin: 0.8rem 0 0; }

.paid-card { border-left-color: #10b981; }
.pending-card { border-left-color: #f59e0b; }
.partial-card { border-left-color: #3b82f6; }
.receivable-card { border-left-color: #ef4444; }

.payment-report-card { margin-bottom: 1.25rem; }
.payment-report-card .card-header input { max-width: 260px; }
.payments-table { min-width: 820px; }
.payments-table tfoot th { background: var(--slate-100); border-top: 2px solid var(--slate-300); }
.empty-table-state { text-align: center; color: var(--slate-500); padding: 1.5rem !important; }

@media (max-width: 900px) {
  .payment-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .payments-heading, .payment-report-card .card-header { align-items: stretch; flex-direction: column; }
  .payment-report-card .card-header input { max-width: none; }
}

/* Client & Payment Row */
.invoice-client-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  margin: 1.25rem 0;
  position: relative;
  z-index: 1;
}

.box-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: #047857;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.client-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--slate-900);
}

.client-detail {
  font-size: 0.78rem;
  color: var(--slate-600);
  line-height: 1.4;
}

.pay-method-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 0.2rem;
}

.bank-details-content {
  font-size: 0.72rem;
  color: var(--slate-600);
  line-height: 1.4;
  white-space: pre-line;
  background: var(--slate-50);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  border-left: 2px solid var(--accent);
}

/* Preview Table */
.preview-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem 0;
  position: relative;
  z-index: 1;
}

.preview-table th {
  background: #09090b;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.55rem 0.7rem;
  border-bottom: 2px solid var(--accent);
}

.preview-table td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.8rem;
  color: var(--slate-800);
}

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

.th-num { width: 5%; }
.th-item { width: 55%; }
.th-qty { width: 10%; }
.th-price { width: 15%; }
.th-total { width: 15%; }

.item-sku-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  background: #ecfdf5;
  color: #065f46;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 6px;
}

.item-desc-sub {
  font-size: 0.72rem;
  color: var(--slate-500);
  margin-top: 2px;
}

/* Summary Block */
.invoice-summary-block {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  margin-top: 0.75rem;
  position: relative;
  z-index: 1;
}

.eco-seal {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #f0fdf4;
  border: 1px dashed #86efac;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
}

.seal-icon {
  font-size: 1.5rem;
}

.eco-seal strong {
  font-size: 0.75rem;
  color: #065f46;
  display: block;
}

.eco-seal p {
  font-size: 0.68rem;
  color: #047857;
  margin: 0;
}

.signature-line-wrap {
  margin-top: 2.2rem;
  width: 200px;
}

.sig-line {
  border-bottom: 1px solid var(--slate-400);
  margin-bottom: 4px;
}

.sig-text {
  font-size: 0.7rem;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.totals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.totals-table td {
  padding: 0.35rem 0.5rem;
}

.grand-total-row {
  border-top: 2px solid #09090b;
  border-bottom: 2px solid #09090b;
  font-size: 1rem;
  font-weight: 800;
  color: #09090b;
}

.grand-total-row td {
  padding: 0.55rem 0.5rem;
}

/* Footer Section */
.invoice-footer-section {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--slate-200);
  position: relative;
  z-index: 1;
}

.footer-block strong {
  font-size: 0.72rem;
  color: #09090b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 2px;
}

.footer-block p {
  font-size: 0.7rem;
  color: var(--slate-600);
  line-height: 1.35;
}

.sheet-bottom-banner {
  margin-top: 0.75rem;
  background: #09090b;
  color: var(--white);
  padding: 0.45rem 0.85rem;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  border-left: 4px solid var(--accent);
}

.thermal-logo-img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  margin: 0 auto 6px auto;
  display: block;
  background: #000;
  border: 1px solid #000;
}

.brand-logo-preview-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #f8faec;
  border: 1px solid #dbe79a;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  margin-bottom: 1.25rem;
}

.settings-logo-img {
  width: 58px;
  height: 58px;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
  border: 2px solid #aec538;
}

/* ==================== 80mm THERMAL RECEIPT ==================== */
.thermal-receipt-paper {
  width: 80mm;
  min-height: 140mm;
  background: #ffffff;
  padding: 8mm 6mm;
  box-shadow: var(--shadow-xl);
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  line-height: 1.35;
  color: #000000;
  border: 1px solid #d1d5db;
}

.thermal-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
}

.thermal-sub {
  font-size: 10px;
  font-weight: 700;
}

.thermal-contact {
  font-size: 9px;
  margin-top: 2px;
}

.thermal-divider {
  overflow: hidden;
  white-space: nowrap;
  font-size: 9px;
  margin: 4px 0;
  color: #555;
}

.thermal-meta div {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.thermal-items-header {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 10px;
}

.th-item-row {
  margin-bottom: 4px;
}

.th-item-name {
  font-weight: bold;
}

.th-item-calc {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.th-row {
  display: flex;
  justify-content: space-between;
}

.total-large {
  font-size: 13px;
  font-weight: 900;
  margin-top: 4px;
}

.thermal-footer {
  font-size: 9px;
  margin-top: 6px;
}

/* ==================== TAB 2: INVOICES HISTORY ==================== */
.history-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: var(--white);
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--slate-100);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  flex: 1;
  max-width: 480px;
}

.search-box input {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0.2rem;
}

.filter-pills {
  display: flex;
  gap: 0.4rem;
}

.filter-pill {
  background: var(--slate-100);
  border: 1px solid var(--slate-300);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--slate-600);
  transition: all 0.15s ease;
}

.filter-pill.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.invoices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.invoice-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}

.invoice-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-border);
}

.inv-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.inv-card-number {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.inv-card-date {
  font-size: 0.75rem;
  color: var(--slate-500);
}

.inv-card-client {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.25rem;
}

.inv-card-items-preview {
  font-size: 0.75rem;
  color: var(--slate-600);
  margin-bottom: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-card-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--slate-100);
  margin-top: auto;
}

.inv-card-total-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--slate-900);
}

.inv-card-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

/* ==================== TAB 3: PRODUCT CATALOG ==================== */
.catalog-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  background: var(--white);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

.inventory-summary {
  margin-left: auto;
  margin-right: 1rem;
  color: var(--slate-600);
  font-size: 0.78rem;
  font-weight: 700;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.25rem;
}

.product-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.prod-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--accent-bg);
  color: #065f46;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.prod-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.2rem;
}

.prod-sku {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--slate-500);
  margin-bottom: 0.5rem;
}

.prod-stock {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.prod-stock.ok { color: var(--success); }
.prod-stock.low { color: var(--warning); }
.prod-stock.out { color: var(--danger); }

.prod-desc {
  font-size: 0.78rem;
  color: var(--slate-600);
  margin-bottom: 1rem;
  line-height: 1.4;
  flex: 1;
}

.prod-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--slate-100);
}

.prod-price {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--slate-900);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--slate-400);
}

.modal-close:hover {
  color: var(--slate-800);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--slate-900);
  color: var(--white);
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.2s ease-out;
}

.toast-success {
  border-left: 4px solid var(--accent);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

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

.hidden {
  display: none !important;
}

/* ==================== PRINT MEDIA STYLES ==================== */
@media print {
  body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .no-print,
  .app-header,
  .builder-form-panel,
  .preview-toolbar,
  .history-top-bar,
  .nav-tabs,
  #toast-container,
  .modal-overlay {
    display: none !important;
  }

  .main-content,
  .builder-layout,
  .builder-preview-panel,
  .invoice-viewport {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Reset A4 Paper styles for exact printer engine */
  .a4-size {
    width: 100% !important;
    min-height: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 auto !important;
  }

  /* Force print background graphics & colors */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  @page {
    size: A4 portrait;
    margin: 12mm 12mm 12mm 12mm;
  }

  .thermal-receipt-paper {
    width: 76mm !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto !important;
    padding: 0 !important;
  }
}

