/* STEM AUTOSPARES - Production styles */

:root {
  --primary: #0c4a6e;
  --primary-dark: #082f49;
  --primary-light: #0369a1;
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #334155;
    --border: #334155;
    --border-strong: #475569;
    --primary: #0ea5e9;
    --primary-light: #38bdf8;
    --success-bg: #064e3b;
    --danger-bg: #7f1d1d;
    --warning-bg: #78350f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.topbar {
  background: var(--primary);
  color: white;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
  gap: 10px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.brand-name { font-size: 15px; font-weight: 700; line-height: 1.1; letter-spacing: 0.4px; }
.brand-sub { font-size: 11px; opacity: 0.7; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.branch-switcher {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  max-width: 200px;
}

.branch-switcher option { background: var(--primary); color: white; }

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.15);
}
.connection-pill.online { background: rgba(34,197,94,0.3); }
.connection-pill.offline { background: rgba(245,158,11,0.3); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  overflow-x: auto;
  position: sticky;
  top: 60px;
  z-index: 40;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: transparent;
  border: none;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--accent); font-weight: 600; }

@media (prefers-color-scheme: dark) {
  .tab.active { color: var(--primary-light); }
}

.main { padding: 18px; max-width: 1400px; margin: 0 auto; width: 100%; }

.section { display: none; }
.section.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value { font-size: 22px; font-weight: 700; margin-top: 6px; color: var(--text); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat.danger .stat-value { color: var(--danger); }
.stat.success .stat-value { color: var(--success); }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.card-title .label { display: flex; align-items: center; gap: 6px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: 12px;
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.row-end { text-align: right; flex-shrink: 0; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.input, .select, .textarea {
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12,74,110,0.1);
}

.input { flex: 1; min-width: 180px; }
.textarea { resize: vertical; min-height: 60px; width: 100%; }

.btn {
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: white; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 4px 8px; font-size: 12px; }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
  max-height: 70vh;
}

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table tr:hover td { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }

.cell-name { font-weight: 600; color: var(--text); }
.cell-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cell-models { font-size: 11px; color: var(--text-muted); }

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
}
.pill-low { background: var(--danger-bg); color: var(--danger); }
.pill-warn { background: var(--warning-bg); color: var(--warning); }
.pill-ok { background: var(--success-bg); color: var(--success); }
.pill-info { background: rgba(14,165,233,0.15); color: var(--primary-light); }

.actions { display: flex; gap: 2px; flex-wrap: wrap; }

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 14px;
  display: inline-flex;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--accent);
}

.cat-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .cat-icon { color: var(--primary-light); }
}

.cat-name { font-size: 14px; font-weight: 600; }
.cat-count { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.cat-meta { font-size: 11px; color: var(--text-light); margin-top: 8px; line-height: 1.5; }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 12px;
  z-index: 100;
  overflow-y: auto;
}
.modal-bg.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}

.field input, .field select, .field textarea {
  width: 100%;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  cursor: pointer;
  padding: 3px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text);
}

.checkbox-grid input { width: auto; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  transition: transform 0.3s ease;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 12px;
}
.bar-label { width: 200px; color: var(--text-muted); flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); transition: width 0.3s; }
.bar-fill.warning { background: var(--warning); }
.bar-fill.danger { background: var(--danger); }
.bar-value { width: 100px; text-align: right; font-weight: 600; flex-shrink: 0; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.notice {
  background: var(--warning-bg);
  color: var(--warning);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
  border-left: 4px solid var(--warning);
}

.sale-builder {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
}

.sale-cart {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--border);
  position: sticky;
  top: 120px;
  height: fit-content;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: 8px;
}
.cart-item:last-child { border-bottom: none; }

.cart-totals {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--border-strong);
}

.cart-total-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.cart-total-row.grand {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.qty-stepper button { background: var(--surface-2); border: none; width: 24px; height: 24px; }
.qty-stepper input { width: 40px; text-align: center; border: none; padding: 4px; background: var(--surface); }

.request-item-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.request-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.request-item-header strong { font-size: 13px; }

.footer {
  text-align: center;
  padding: 18px;
  font-size: 11px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  margin-top: 30px;
}

.install-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 400px;
  margin: 0 auto;
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  z-index: 90;
  font-size: 13px;
}
.install-banner.show { display: flex; }
.install-banner button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
}
.install-banner .dismiss { background: transparent; font-size: 18px; padding: 4px 8px; }

@media (max-width: 768px) {
  .main { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 18px; }
  .sale-builder { grid-template-columns: 1fr; }
  .sale-cart { position: static; }
  .toolbar .input { min-width: 100%; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 8px 8px; }
  .topbar { padding: 10px 12px; }
  .brand-sub { display: none; }
  .bar-label { width: 130px; }
  .branch-switcher { max-width: 140px; }
}

@media (max-width: 480px) {
  .checkbox-grid { grid-template-columns: 1fr; }
  .modal { padding: 16px; }
  .connection-pill { display: none; }
}

/* ============== BARCODE SCANNER ============== */
.scanner-view {
  position: relative;
  background: black;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  margin-bottom: 6px;
}

.scanner-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scanner-frame {
  width: 75%;
  aspect-ratio: 2 / 1;
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  position: relative;
  animation: scanner-pulse 2s ease-in-out infinite;
}

.scanner-frame::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 8px var(--accent);
  animation: scanner-line 1.8s ease-in-out infinite;
}

@keyframes scanner-pulse {
  0%, 100% { border-color: var(--accent); }
  50%      { border-color: #fde68a; }
}

@keyframes scanner-line {
  0%   { transform: translateY(-46%); opacity: 1; }
  50%  { transform: translateY(46%);  opacity: 0.6; }
  100% { transform: translateY(-46%); opacity: 1; }
}

.scanner-status {
  position: absolute;
  left: 12px; right: 12px; bottom: 10px;
  text-align: center;
  font-size: 11px;
  color: white;
  background: rgba(0,0,0,0.55);
  padding: 6px 10px;
  border-radius: 999px;
  pointer-events: none;
}

/* ============== INVOICE ============== */
/* Screen preview format that mirrors the print-ready layout */

.inv-doc {
  background: white;
  color: #1e3a5f;
  padding: 32px 40px;
  font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  max-width: 820px;
  margin: 0 auto 20px;
}

.inv-brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
}
.inv-brand-mark {
  width: 34px; height: 34px;
  border-radius: 999px;
  background: #F26C21;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.5px;
}
.inv-brand-name {
  font-weight: 900;
  color: #1e3a5f;
  font-size: 16px;
  letter-spacing: 0.4px;
}
.inv-brand-title {
  color: #1e3a5f;
  font-weight: 400;
  font-size: 22px;
  margin-left: 8px;
}
.inv-brand-num {
  color: #1e3a5f;
  font-weight: 700;
  font-size: 22px;
  margin-left: 4px;
}
.inv-brand-spacer { flex: 1; }
.inv-orange-rule {
  height: 3px;
  background: #F26C21;
  margin-bottom: 20px;
}

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 24px;
  padding-bottom: 22px;
}
.inv-supplier { text-align: left; }
.inv-client { text-align: right; }
.inv-party-label {
  font-weight: 700;
  font-size: 11px;
  color: #1e3a5f;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.inv-party-name {
  font-weight: 900;
  color: #1e3a5f;
  font-size: 13px;
  margin-bottom: 4px;
}
.inv-party-detail {
  color: #4a5c7a;
  font-size: 11.5px;
  line-height: 1.5;
}
.inv-qr {
  width: 100px;
  height: 100px;
  color: #1e3a5f;
}
.inv-qr svg { display: block; width: 100%; height: 100%; }

.inv-meta-block {
  background: #F5F6F8;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px 24px;
  margin-bottom: 2px;
}
.inv-meta-label {
  font-size: 10.5px;
  color: #4a5c7a;
  margin-bottom: 2px;
}
.inv-meta-value {
  color: #1e3a5f;
  font-weight: 500;
  font-size: 12px;
  word-break: break-word;
}
.inv-meta-block + .inv-meta-block {
  border-top: 1px solid #E4E7EC;
}

.inv-items {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
  font-size: 11.5px;
}
.inv-items thead {
  background: #F5F6F8;
}
.inv-items th {
  padding: 10px 8px;
  text-align: left;
  color: #4a5c7a;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.inv-items th.num, .inv-items td.num { text-align: right; white-space: nowrap; }
.inv-items th.ctr, .inv-items td.ctr { text-align: center; }
.inv-items td {
  padding: 10px 8px;
  color: #1e3a5f;
  border-bottom: 1px solid #F0F1F4;
  vertical-align: top;
}
.inv-items td.desc { font-weight: 500; }
.inv-items td.code {
  color: #4a5c7a;
  font-family: 'Courier New', monospace;
  font-size: 11px;
}

.inv-totals {
  text-align: right;
  margin-top: 14px;
  padding-top: 4px;
}
.inv-total-row {
  padding: 4px 0;
  font-size: 12px;
  color: #4a5c7a;
}
.inv-total-row span:first-child {
  display: inline-block;
  margin-right: 20px;
  letter-spacing: 0.5px;
}
.inv-total-row span:last-child {
  display: inline-block;
  min-width: 130px;
  color: #1e3a5f;
  font-weight: 500;
}
.inv-total-row.grand {
  border-top: 1px solid #D9DCE1;
  padding-top: 10px;
  margin-top: 6px;
  font-weight: 700;
}
.inv-total-row.grand span:last-child {
  color: #1e3a5f;
  font-weight: 900;
  font-size: 14px;
}

.inv-vat-table {
  margin: 30px auto 20px;
  border-collapse: collapse;
  font-size: 11px;
}
.inv-vat-table th, .inv-vat-table td {
  padding: 6px 20px;
  border: 1px solid #E4E7EC;
  text-align: right;
  color: #1e3a5f;
}
.inv-vat-table th {
  background: #F5F6F8;
  color: #4a5c7a;
  font-weight: 600;
  font-size: 10.5px;
}
.inv-vat-table td:first-child, .inv-vat-table th:first-child {
  text-align: center;
}

.inv-page-num {
  text-align: right;
  color: #B4B9C2;
  font-size: 10.5px;
  margin-top: 30px;
  padding-top: 10px;
}

.inv-payment-heading {
  color: #F26C21;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 3px solid #F26C21;
}
.inv-payment-body {
  font-size: 12px;
  color: #1e3a5f;
  line-height: 2;
}
.inv-payment-body strong { color: #1e3a5f; font-weight: 700; }
.inv-payment-ref {
  margin-top: 14px;
  font-size: 11px;
  color: #4a5c7a;
  letter-spacing: 0.3px;
}

/* Editor & list styling (screen only) */
.inv-editor-item {
  display: grid;
  grid-template-columns: 2fr 1fr 90px 100px 80px 100px 30px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
}
.inv-editor-item input, .inv-editor-item select {
  width: 100%;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.inv-editor-item-header {
  display: grid;
  grid-template-columns: 2fr 1fr 90px 100px 80px 100px 30px;
  gap: 8px;
  padding: 8px 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border-strong);
}

@media (max-width: 768px) {
  .inv-doc { padding: 18px 16px; font-size: 11px; }
  .inv-meta-block { grid-template-columns: 1fr 1fr; }
  .inv-parties { grid-template-columns: 1fr; text-align: left; }
  .inv-client { text-align: left; }
  .inv-qr { justify-self: left; }
  .inv-editor-item, .inv-editor-item-header {
    grid-template-columns: 1fr 1fr;
    row-gap: 4px;
  }
}

/* Print rules — clean invoice output only */
@media print {
  body.print-invoice .topbar,
  body.print-invoice .tabs,
  body.print-invoice .toolbar,
  body.print-invoice .actions,
  body.print-invoice .install-banner,
  body.print-invoice .footer,
  body.print-invoice .no-print,
  body.print-invoice .modal-header,
  body.print-invoice .modal-actions { display: none !important; }

  body.print-invoice, body.print-invoice html {
    background: white !important;
    color: #1e3a5f !important;
    margin: 0;
    padding: 0;
  }
  body.print-invoice .modal-bg {
    position: static !important;
    background: none !important;
    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
  }
  body.print-invoice .modal {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }
  body.print-invoice .inv-doc {
    border: none !important;
    padding: 12mm !important;
    margin: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
  }
  body.print-invoice .inv-page-break {
    page-break-before: always;
  }
  @page { size: A4; margin: 8mm; }
}

/* ============== PRINTABLE RECEIPT ============== */
/* Screen view styling: shows receipt nicely inside the modal preview */

.receipt-wrap { max-width: 420px; }

.receipt {
  background: white;
  color: black;
  padding: 16px 18px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.45;
  border-radius: 6px;
  border: 1px dashed var(--border-strong);
  margin: 4px 0;
}

.r-header { text-align: center; padding-bottom: 6px; }
.r-shop {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  font-family: Arial, sans-serif;
  margin-bottom: 4px;
}
.r-contact { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.r-branches { font-size: 11px; line-height: 1.4; padding: 0 4px; }

.r-rule {
  border-top: 1px dashed #000;
  margin: 8px 0;
}

.r-meta { font-size: 11px; }
.r-meta-row {
  display: flex;
  justify-content: space-between;
  padding: 1px 0;
}
.r-meta-row span:first-child { color: #555; }

.r-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.r-table th {
  text-align: left;
  font-weight: 700;
  padding: 4px 2px;
  border-bottom: 1px solid #000;
  background: transparent;
  color: black;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.4px;
}
.r-table td {
  padding: 4px 2px;
  vertical-align: top;
  border-bottom: 1px dotted #999;
  background: transparent;
}
.r-table tr:last-child td { border-bottom: none; }

.r-table .r-item { width: auto; }
.r-table .r-qty   { width: 36px; text-align: center; }
.r-table .r-price { width: 80px; text-align: right; white-space: nowrap; }
.r-table .r-amt   { width: 90px; text-align: right; font-weight: 700; white-space: nowrap; }

.r-item-name { font-weight: 600; line-height: 1.3; }
.r-item-sku  { font-size: 9px; color: #666; font-family: 'Courier New', monospace; }

.r-totals { font-size: 12px; }
.r-total-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.r-total-row.grand {
  font-size: 15px;
  font-weight: 900;
  border-top: 2px solid #000;
  margin-top: 4px;
  padding-top: 4px;
}

.r-payment { font-size: 11px; }
.r-payment div { padding: 2px 0; }

.r-footer { text-align: center; font-size: 11px; padding-top: 4px; }
.r-thanks { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.r-terms  { font-size: 10px; color: #555; margin: 2px 0; }
.r-tagline {
  font-size: 10px;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ============== PRINT MEDIA ============== */
@media print {
  /* hide everything that isn't the receipt */
  .topbar, .tabs, .toolbar, .actions, .install-banner, .footer,
  .main, .modal-header, .modal-actions, .no-print { display: none !important; }

  body, html {
    background: white !important;
    color: black !important;
    margin: 0;
    padding: 0;
    font-size: 12pt;
  }

  /* unstack the modal so only the receipt prints */
  .modal-bg {
    position: static !important;
    background: none !important;
    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
  }
  .modal, .receipt-wrap {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }

  .receipt {
    border: none !important;
    padding: 8mm !important;
    margin: 0 !important;
    font-size: 11pt !important;
    color: black !important;
    background: white !important;
    page-break-inside: avoid;
  }

  .r-shop      { font-size: 22pt !important; }
  .r-contact   { font-size: 11pt !important; }
  .r-branches  { font-size: 9pt  !important; }
  .r-meta, .r-payment { font-size: 9pt !important; }
  .r-table     { font-size: 9pt !important; }
  .r-table th  { font-size: 8pt !important; }
  .r-item-sku  { font-size: 7pt !important; }
  .r-total-row.grand { font-size: 13pt !important; }
  .r-thanks    { font-size: 11pt !important; }
  .r-terms     { font-size: 8pt !important; }
  .r-tagline   { font-size: 8pt !important; }

  /* thermal printer paper size hint, falls back to A4 if not available */
  @page { margin: 6mm; }
}

/* Thermal receipt paper helper: forces 80mm column if user has thermal printer */
@media print and (max-width: 80mm) {
  @page { size: 80mm auto; margin: 3mm; }
  .receipt { padding: 3mm !important; }
}
