/* ==========================================================================
   Fuel Receipt Generator — Styling & Thermal Paper System
   ========================================================================== */

:root {
  /* App Dark Theme */
  --bg-primary: #0f1117;
  --bg-secondary: #161922;
  --bg-card: #1c202d;
  --bg-input: #12141c;
  --bg-input-focus: #181b26;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: #6366f1;
  --border-hover: rgba(255, 255, 255, 0.16);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);

  /* Receipt Theme Defaults */
  --receipt-bg: #f8f6f0;
  --receipt-text: #1a1a1a;
  --receipt-ink-opacity: 0.92;
  --receipt-font-size: 17px;
  --receipt-logo-width: 170px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   App Layout & Header
   ========================================================================== */

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

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

.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-logo h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.2;
}

.sub-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: #818cf8;
  letter-spacing: 0.05em;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  color: #fff;
  background: var(--accent-primary);
  box-shadow: 0 2px 8px var(--accent-glow);
}

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

/* ==========================================================================
   Main Grid Layout
   ========================================================================== */

.main-container {
  display: grid;
  grid-template-columns: minmax(460px, 560px) 1fr;
  min-height: calc(100vh - 64px);
  background: var(--bg-primary);
}

/* ==========================================================================
   Left Pane: Form
   ========================================================================== */

.form-pane {
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  padding: 24px;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Template Selector Buttons */
.template-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tpl-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.tpl-btn:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.03);
}

.tpl-btn.active {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.tpl-icon {
  font-size: 16px;
  line-height: 1;
}

.tpl-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tpl-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.tpl-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Accordions */
.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
  transition: border-color 0.2s ease;
}

.accordion-item:hover {
  border-color: var(--border-hover);
}

.accordion-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: var(--bg-card);
}

.accordion-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.accordion-arrow {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s ease;
}

.accordion-item.open .accordion-arrow {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 18px 18px 18px;
  display: none;
  flex-direction: column;
  gap: 14px;
}

.accordion-item.open .accordion-content {
  display: flex;
}

/* Form Inputs */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.input-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.label-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-upload-font-link {
  font-size: 11px;
  color: #818cf8;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  transition: color 0.15s ease;
}

.btn-upload-font-link:hover {
  color: #a5b4fc;
  text-decoration: underline;
}

.custom-font-loaded-banner {
  margin-top: 4px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #4ade80;
}

.custom-font-loaded-banner .font-file-title {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-font-loaded-banner .btn-remove-custom-font {
  background: transparent;
  border: none;
  color: #f87171;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  transition: background 0.15s ease;
}

.custom-font-loaded-banner .btn-remove-custom-font:hover {
  background: rgba(239, 68, 68, 0.15);
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="range"] {
  accent-color: var(--accent-primary);
  height: 6px;
  margin-top: 10px;
}

.input-with-action {
  display: flex;
  gap: 6px;
}

.input-prefix-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 10px;
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-suffix {
  position: absolute;
  right: 10px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-prefix-wrapper input {
  padding-left: 24px;
}

.input-prefix-wrapper .input-suffix~input,
.input-prefix-wrapper input:has(+ .input-suffix) {
  padding-right: 26px;
}

.input-prefix-wrapper.highlight input {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.05);
  font-weight: 600;
  color: #a5b4fc;
}

.btn-input-action {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0 10px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.btn-input-action:hover {
  background: var(--bg-input-focus);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Helper Banner */
.calc-helper-banner {
  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: 12px;
  color: #a5b4fc;
  display: flex;
  align-items: center;
}

/* Custom Checkbox */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.custom-checkbox .checkmark {
  width: 18px;
  height: 18px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.custom-checkbox input:checked~.checkmark {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.custom-checkbox input:checked~.checkmark::after {
  content: "✓";
  font-size: 12px;
  color: #fff;
  font-weight: bold;
}

.custom-checkbox code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}

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

.btn-secondary {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-input-focus);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-icon {
  padding: 8px;
}

.w-100 {
  width: 100%;
}

/* Size Adjustments Cards & Controls */
.size-control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.size-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.size-label .icon {
  font-size: 14px;
}

.stepper-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-stepper {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-stepper:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-primary);
}

.btn-stepper:active {
  background: rgba(99, 102, 241, 0.2);
}

.size-value-badge {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #818cf8;
  min-width: 48px;
  text-align: center;
  user-select: none;
  font-family: 'Space Mono', monospace;
}

.size-slider-row {
  display: flex;
  align-items: center;
  padding: 2px 0;
}

.size-slider {
  width: 100%;
  accent-color: var(--accent-primary);
  height: 5px;
  cursor: pointer;
}

.preset-pills-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.preset-pill {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.preset-pill:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.preset-pill.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
  box-shadow: 0 1px 6px var(--accent-glow);
}

.logo-extra-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  gap: 8px;
  flex-wrap: wrap;
}

.custom-logo-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-custom-logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-custom-logo:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ==========================================================================
   Right Pane: Preview Viewport & Export
   ========================================================================== */

.preview-pane {
  background: #0b0d13;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.export-toolbar {
  min-height: 60px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(22, 25, 34, 0.85);
  backdrop-filter: blur(8px);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 20;
}

.export-actions-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Quick Adjustments on Preview Toolbar */
.preview-quick-adjustments {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-adjust-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.quick-adjust-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
  user-select: none;
}

.quick-adjust-btn {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.quick-adjust-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.quick-adjust-btn:active {
  transform: scale(0.95);
}

.quick-adjust-badge {
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  min-width: 42px;
  text-align: center;
  font-family: 'Space Mono', monospace;
  user-select: none;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.2);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.8;
  }
}

.export-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-export {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  transition: all 0.2s ease;
}

.btn-pdf {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
}

.btn-pdf:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-1px);
}

.btn-png {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.25);
}

.btn-png:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
}

/* Receipt Viewport */
.receipt-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background-image:
    radial-gradient(circle at center, rgba(99, 102, 241, 0.05) 0%, transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px, 20px 20px;
}

/* ==========================================================================
   Thermal Paper Exact Rendering
   ========================================================================== */

.receipt-wrapper {
  position: relative;
  width: 275px;
  filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.7));
  margin-bottom: 40px;
  transition: transform 0.2s ease;
}

/* Serrated / Jagged Torn Paper Edges */
.jagged-edge {
  height: 10px;
  width: 100%;
  position: relative;
  background-repeat: repeat-x;
  background-size: 14px 10px;
}

.jagged-edge.top {
  background-image: radial-gradient(circle at 7px 0px, transparent 7px, var(--receipt-bg) 7px);
}

.jagged-edge.bottom {
  background-image: radial-gradient(circle at 7px 10px, transparent 7px, var(--receipt-bg) 7px);
}

.receipt-paper {
  background-color: var(--receipt-bg);
  color: var(--receipt-text);
  padding: 14px 14px 18px 16px;
  min-height: 480px;
  font-size: var(--receipt-font-size, 17px);
  line-height: 1.38;
  letter-spacing: -0.01em;
  position: relative;
  user-select: text;
  box-sizing: border-box;
}

/* ==========================================================================
   Thermal & Matrix Hardware / Local Fonts ( bitMatrix Series)
   ========================================================================== */

@font-face {
  font-family: 'bitMatrix-D1';
  src: local('bitMatrix-D1'), local('bitMatrixD1'), local('bitMatrix D1'), local('bitMatrix');
  font-display: swap;
}

@font-face {
  font-family: 'bitMatrix-A4';
  src: local('bitMatrix-A4'), local('bitMatrixA4'), local('bitMatrix A4');
  font-display: swap;
}

@font-face {
  font-family: 'bitMatrix-A1';
  src: local('bitMatrix-A1'), local('bitMatrixA1'), local('bitMatrix A1');
  font-display: swap;
}

@font-face {
  font-family: 'bitMatrix-B1';
  src: local('bitMatrix-B1'), local('bitMatrixB1'), local('bitMatrix B1');
  font-display: swap;
}

/* Fonts */
/* --- bitMatrix Series --- */
.font-bitmatrix-d1 {
  font-family: 'bitMatrix-D1', 'bitMatrix', 'DotGothic16', monospace;
  font-size: calc(var(--receipt-font-size, 17px) * 0.98);
  letter-spacing: 0.015em;
  line-height: 1.42;
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}

.font-bitmatrix-a4 {
  font-family: 'bitMatrix-A4', 'bitMatrix', 'DotGothic16', monospace;
  font-size: calc(var(--receipt-font-size, 17px) * 1.02);
  letter-spacing: 0.025em;
  line-height: 1.4;
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}

.font-bitmatrix-a1 {
  font-family: 'bitMatrix-A1', 'bitMatrix', 'VT323', 'DotGothic16', monospace;
  font-size: calc(var(--receipt-font-size, 17px) * 1.08);
  letter-spacing: 0.04em;
  line-height: 1.35;
  -webkit-font-smoothing: none;
}

.font-bitmatrix-b1 {
  font-family: 'bitMatrix-B1', 'bitMatrix', 'DotGothic16', 'VT323', monospace;
  font-size: calc(var(--receipt-font-size, 17px) * 0.95);
  letter-spacing: 0.01em;
  line-height: 1.38;
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}

.font-dotgothic {
  font-family: 'DotGothic16', monospace;
  font-size: calc(var(--receipt-font-size, 17px) * 0.96);
  letter-spacing: 0.02em;
  line-height: 1.42;
  -webkit-font-smoothing: none;
}

/* --- Standard Fonts --- */
.font-chivo-mono,
.font-spline-mono,
.font-ubuntu-mono {
  font-family: 'Chivo Mono', monospace;
  font-size: var(--receipt-font-size, 17px);
  letter-spacing: -0.01em;
  line-height: 1.38;
}

.font-space-mono {
  font-family: 'Space Mono', monospace;
  font-size: var(--receipt-font-size, 17px);
  letter-spacing: -0.02em;
}

.font-courier {
  font-family: 'Courier Prime', Courier, monospace;
  font-size: var(--receipt-font-size, 17px);
}

.font-dot-matrix {
  font-family: 'VT323', monospace;
  font-size: calc(var(--receipt-font-size, 17px) * 1.06);
  letter-spacing: 0.03em;
}

.font-share-tech-mono {
  font-family: 'Share Tech Mono', monospace;
  font-size: var(--receipt-font-size, 17px);
  letter-spacing: 0.01em;
  line-height: 1.4;
  font-variant-numeric: slashed-zero;
}

.font-roboto-mono {
  font-family: 'Roboto Mono', monospace;
  font-size: var(--receipt-font-size, 17px);
  letter-spacing: -0.01em;
  line-height: 1.38;
}

/* --- Custom Uploaded Font --- */
.font-custom {
  font-family: var(--custom-font-name, 'CustomUserFont'), monospace;
  font-size: var(--receipt-font-size, 17px);
  line-height: 1.38;
}

/* Paper Tones */
.tone-authentic {
  --receipt-bg: #f8f6ee;
  background-color: #f8f6ee;
}

.tone-fresh {
  --receipt-bg: #ffffff;
  background-color: #ffffff;
}

.tone-aged {
  --receipt-bg: #f2ede0;
  background-color: #f2ede0;
}

/* Ink effect */
.receipt-paper * {
  opacity: var(--receipt-ink-opacity);
}

/* Receipt Logo */
.receipt-logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  transition: all 0.15s ease;
}

.receipt-logo-container.hidden {
  display: none !important;
}

.receipt-logo-svg {
  width: var(--receipt-logo-width, 170px) !important;
  max-width: 100% !important;
  height: auto !important;
  display: block;
}

.receipt-logo-img {
  width: var(--receipt-logo-width, 170px) !important;
  max-width: 100% !important;
  max-height: 250px;
  height: auto;
  display: block;
  margin: 0 auto;
  mix-blend-mode: multiply;
  object-fit: contain;
}

.receipt-welcomes {
  text-align: center;
  font-size: calc(var(--receipt-font-size, 17px) * 1.35);
  letter-spacing: 0.03em;
  margin-top: 4px;
  margin-bottom: 6px;
  font-weight: 400;
  transform: scaleX(0.82) scaleY(1.35);
  transform-origin: center;
  display: block;
  line-height: 1.15;
}

/* Station Details */
.receipt-station-info {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.r-dealer-name {
  text-align: left;
  font-weight: 400;
  text-transform: uppercase;
}

.r-address-1,
.r-address-2 {
  text-align: left;
  text-transform: uppercase;
}

.r-tel-no {
  text-align: left;
  margin-top: 4px;
}

.receipt-divider-space {
  height: 12px;
}

/* Key-Value Rows (Left Aligned like authentic thermal POS printers) */
.r-row {
  display: block !important;
  text-align: left !important;
  white-space: pre;
  font-family: inherit;
  line-height: 1.45;
}

.r-label,
.r-val {
  display: inline;
}

.receipt-meta,
.receipt-pricing,
.receipt-vehicle,
.receipt-datetime,
.receipt-tax {
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

/* Footer */
.receipt-footer {
  text-align: left;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.r-footer-msg {
  white-space: pre-line;
}

.r-printed-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

@keyframes slideIn {
  from {
    transform: translateX(30px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ==========================================================================
   Responsive & Print Media
   ========================================================================== */

@media (max-width: 980px) {
  .main-container {
    grid-template-columns: 1fr;
  }

  .form-pane {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .preview-pane {
    min-height: 600px;
  }
}

@media (max-width: 680px) {
  .export-toolbar {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    padding: 12px 16px;
    gap: 10px;
  }

  .preview-quick-adjustments {
    justify-content: space-between;
  }

  .export-buttons {
    justify-content: stretch;
  }

  .export-buttons .btn-export {
    flex: 1;
    justify-content: center;
  }
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .app-header,
  .form-pane,
  .export-toolbar,
  .toast-container {
    display: none !important;
  }

  .main-container,
  .preview-pane,
  .receipt-viewport {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: none !important;
    width: 100% !important;
  }

  .receipt-wrapper {
    margin: 0 auto !important;
    filter: none !important;
    width: 58mm !important;
  }

  .receipt-paper {
    background: #fff !important;
    color: #000 !important;
    padding: 8px 8px 8px 10px !important;
  }
}