:root {
  --roll-width: 105mm;
  --stickers-per-row: 2;
  --sticker-width: 50mm;
  --sticker-height: 38mm;
  --left-margin: 2mm;
  --right-margin: 1mm;
  --horizontal-gap: 1mm;
  --vertical-gap: 4mm;
  --preview-zoom: 1;
  
  --bg-color: #f8fafc;
  --panel-bg: #ffffff;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
}

* { box-sizing: border-box; }

body { font-family: 'Inter', sans-serif; padding: 0; margin: 0; background-color: var(--bg-color); color: var(--text-main); height: 100vh; overflow: hidden; }

.app-container { display: flex; height: 100vh; }
.sidebar { width: 360px; background: var(--panel-bg); border-right: 1px solid var(--border); padding: 24px; display: flex; flex-direction: column; overflow-y: auto; box-shadow: 4px 0 15px rgba(0,0,0,0.03); z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--primary); margin-bottom: 32px; }
.brand h1 { font-size: 1.4rem; font-weight: 800; margin: 0; letter-spacing: -0.5px; }

.panel { margin-bottom: 24px; }
.panel h2 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin: 0 0 12px 0; letter-spacing: 0.5px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: #334155; }
.form-group input[type="number"] { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem; font-family: inherit; background: white; }
.file-drop-area { position: relative; display: flex; align-items: center; justify-content: center; min-height: 100px; padding: 20px; border: 2px dashed #cbd5e1; border-radius: 8px; background: #f8fafc; text-align: center; cursor: pointer; }
.file-drop-area input[type="file"] { position: absolute; left: 0; top: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.actions { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding-top: 16px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 6px; font-size: 0.95rem; font-weight: 600; cursor: pointer; border: none; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: white; color: #334155; border: 1px solid #cbd5e1; }
.footer-note { margin-top: 16px; text-align: center; font-size: 0.75rem; color: #94a3b8; }

/* Preview & Queue Area */
.preview-container { flex: 1; display: flex; flex-direction: column; padding: 32px; overflow-y: auto; align-items: center; }
.preview-header { width: 100%; max-width: 1000px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; background: white; padding: 16px 24px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.preview-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }
.badge { background: #e0e7ff; color: var(--primary); padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; display: inline-block; margin-top: 6px; }

.zoom-controls { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 0.9rem; }
.zoom-controls input[type="range"] { accent-color: var(--primary); cursor: pointer; }

.queue-list { width: 100%; max-width: 1000px; display: flex; flex-direction: column; gap: 24px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 250px; font-size: 0.9rem; background: white; border-radius: 12px; border: 1px dashed #cbd5e1; }

.queue-card { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 10px 30px -5px rgba(0,0,0,0.08); display: flex; gap: 32px; align-items: flex-start; border: 1px solid #e2e8f0; }
.queue-details { flex: 0 0 250px; display: flex; flex-direction: column; gap: 12px; }
.queue-details h3 { margin: 0; font-size: 1rem; color: var(--text-main); font-weight: 800; line-height: 1.3;}
.queue-details button { margin-top: auto; align-self: flex-start; background: #fee2e2; color: #ef4444; border: none; padding: 8px 12px; border-radius: 6px; font-weight: bold; cursor: pointer; }

.queue-preview-wrap {
  transform: scale(var(--preview-zoom)); 
  transform-origin: top left;
  border: 1px solid #e2e8f0;
  display: inline-block;
  background: #f1f5f9;
}

/* Sticker Print Grid */
.print-area-grid {
  background: white;
  display: grid;
  grid-template-columns: repeat(var(--stickers-per-row), var(--sticker-width));
  column-gap: var(--horizontal-gap);
  row-gap: var(--vertical-gap);
  padding-left: var(--left-margin);
  padding-right: var(--right-margin);
  width: var(--roll-width);
  box-sizing: border-box;
}

.sticker {
  width: var(--sticker-width);
  height: var(--sticker-height);
  background: white;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  border: 1px dashed #cbd5e1;
  color: black;
  font-family: 'Segoe UI', Arial, sans-serif;
  padding: 3.5mm 1mm 1.5mm 1mm;
}

/* Dynamic Font System for Header (3 lines auto-adjust) */
.sticker-header {
  text-align: center;
  border-bottom: 2px solid black;
  padding-bottom: 0px;
  margin-bottom: 0px;
  font-size: 10pt; /* Base size */
  max-height: 14mm; 
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.sticker-brand { font-weight: 900; font-size: 1.05em; margin: 0; text-transform: uppercase; line-height: 1.1; }
.sticker-address, .sticker-fssai { font-size: 0.55em; font-weight: 800; margin: 0; line-height: 1.1; }

.sticker-product { text-align: center; font-weight: 800; font-size: 9pt; margin: 1px 0; text-transform: uppercase; }
.barcode-container { display: flex; justify-content: center; align-items: center; margin: -0.5mm 0; }
.barcode-container svg { max-width: 95%; height: 11mm; }
.price-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0 1mm; margin-bottom: 0px; z-index: 2; position: relative; }
.price-mrp-group { display: flex; align-items: baseline; gap: 0.5mm; }
.mrp-line { font-size: 12pt; font-weight: 900; margin: 0; line-height: 1; }
.tax-line-center { font-size: 4.5pt; font-weight: 600; line-height: 1; text-align: center; margin-top: -1.5mm; width: 100%; z-index: 1; position: relative; }
.usp { font-size: 7pt; font-weight: 800; text-align: right; line-height: 1; }
.dates-grid { display: grid; grid-template-columns: auto auto auto auto; gap: 0px 1.5mm; font-size: 6.5pt; font-weight: 800; padding: 0.5mm 1mm 0 1mm; }

#print-only { display: none; }

@media print {
  @page { margin: 0; }
  body { background: white; height: auto; overflow: visible; }
  .no-print, .app-container { display: none !important; }
  
  #print-only {
    display: grid !important;
    background: white;
    grid-template-columns: repeat(var(--stickers-per-row), var(--sticker-width));
    column-gap: var(--horizontal-gap);
    row-gap: var(--vertical-gap);
    padding-left: var(--left-margin);
    padding-right: var(--right-margin);
    width: var(--roll-width);
    box-sizing: border-box;
  }
  .sticker { border: none; page-break-inside: avoid; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
