/* Termo-Vodovod PWA Stylesheet
   Clean Minimalist Light Theme with Zero Clutter
   Desktop: Counter Mode (Left Navigation)
   Mobile: Warehouse Mode (Bottom Touch Navigation)
   Print: Pristine Official A4 Macedonian Document View
*/

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-light: #e2e8f0;
  --border-dark: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --accent-orange: #ea580c;
  --accent-orange-light: #fff7ed;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --sidebar-width: 250px;
  --header-height: 64px;
  --bottom-nav-height: 68px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Typography & Utilities */
h1, h2, h3, h4 {
  font-weight: 600;
  color: var(--text-main);
}

a {
  color: var(--primary);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.15s ease-in-out;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  max-width: 100%;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  text-overflow: ellipsis;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-orange { background: var(--accent-orange-light); color: var(--accent-orange); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: #b45309; }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: var(--bg-subtle); color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-dark);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}
.btn-success:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover {
  background-color: #fee2e2;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.btn-icon:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* App Layout Structure */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* DESKTOP SIDEBAR: Counter Mode (Cashier / POS View) */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-header {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: white;
  flex-shrink: 0;
}

.app-brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
}
.app-brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  width: 100%;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  flex-shrink: 0;
}

.nav-link:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.nav-link.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-light);
  background: #fafafa;
}

.mode-badge-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-app);
}

/* Top App Bar */
.top-header {
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-title-wrapper {
  min-width: 0;
}

.header-title-wrapper h1 {
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.edition-header-badge,
.header-kbd-badge {
  white-space: nowrap;
  flex-shrink: 0;
}

.mobile-menu-btn,
.mobile-sidebar-close,
.sidebar-backdrop {
  display: none;
}
.mobile-only {
  display: none !important;
}

.doc-qty-group {
  width: 140px;
  flex-shrink: 0;
}

.search-input-wrap {
  min-width: 260px;
  flex: 0 1 320px;
}

/* Page Section Container */
.content-area {
  padding: 24px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.page-view {
  display: none;
}
.page-view.active {
  display: block;
}

/* Cards & Panels */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
  max-width: 100%;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
}

/* Fast Document Creator Styles */
.doc-type-selector {
  display: flex;
  gap: 8px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
}

.doc-type-btn {
  flex: 1;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-align: center;
}

.doc-type-btn.active {
  background: white;
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.doc-grid-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.doc-grid-header > *,
.doc-footer-grid > * {
  min-width: 0;
  max-width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.client-selected-info {
  margin-top: 8px;
  padding: 10px 14px;
  background-color: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Quick Add Item Bar */
.add-item-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-end;
  background: #f8fafc;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.item-search-wrapper {
  flex: 2;
  position: relative;
  min-width: 0;
  max-width: 100%;
}

#doc-item-search {
  width: 100%;
}

.item-dropdown-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
  display: none;
}

.dropdown-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.dropdown-item:hover, .dropdown-item.selected {
  background-color: var(--primary-light);
}

/* Document Items Table */
.table-container {
  overflow-x: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: white;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

table.data-table th {
  background-color: #f8fafc;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

table.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover td {
  background-color: #fafbfc;
}

.qty-input {
  width: 75px;
  text-align: center;
  font-weight: 600;
}

.rabat-input {
  width: 65px;
  text-align: center;
}

/* Document Financial Summary */
.doc-footer-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: start;
}

.vat-recap-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.vat-recap-table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
}

.vat-recap-table th, .vat-recap-table td {
  padding: 6px 8px;
  text-align: right;
}
.vat-recap-table th:first-child, .vat-recap-table td:first-child {
  text-align: left;
}

.totals-summary-box {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.summary-row.grand-total {
  border-top: 2px solid var(--border-light);
  margin-top: 10px;
  padding-top: 12px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
}

/* Inventory & Stock View */
.inventory-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  justify-content: space-between;
  align-items: center;
}

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.pill {
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.pill.active {
  background: var(--primary);
  color: white;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 20px;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafafa;
}

/* Camera Barcode Scanner View */
.scanner-viewport-box {
  position: relative;
  width: 100%;
  height: 280px;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay-reticle {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.reticle-box {
  width: 240px;
  height: 140px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.35);
}

.reticle-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  top: 50%;
  animation: laserSweep 2s infinite ease-in-out;
}

@keyframes laserSweep {
  0% { top: 15%; opacity: 0.8; }
  50% { top: 85%; opacity: 1; }
  100% { top: 15%; opacity: 0.8; }
}

.scanner-test-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.test-chip {
  padding: 5px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.test-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Mobile Quick Adjust Controls */
.quick-adjust-group {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.stock-pill-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-main);
  text-align: center;
}

.stock-pill-btn.add {
  background: var(--success-light);
  color: #047857;
  border-color: #a7f3d0;
}
.stock-pill-btn.sub {
  background: var(--danger-light);
  color: #b91c1c;
  border-color: #fecaca;
}

/* MOBILE WAREHOUSE MODE: Bottom Touch Bar */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.04);
  z-index: 50;
  padding: 0 6px;
}

.bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-around;
}

.bottom-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  position: relative;
}

.bottom-tab-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.bottom-tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.bottom-tab-btn.highlight {
  color: #ffffff;
  background: var(--primary);
  border-radius: var(--radius-md);
  margin: 6px 4px;
  height: calc(100% - 12px);
}
.bottom-tab-btn.highlight svg {
  color: white;
}

/* Floating Action Button on Mobile */
.fab-scan {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 20px;
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 45;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  background: #0f172a;
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastFadeIn 0.25s ease;
  pointer-events: auto;
}

.toast.success { background: #065f46; }
.toast.danger { background: #991b1b; }
.toast.warning { background: #92400e; }

/* --- INSTALLER PORTAL (CONTRACTOR / FIELD PORTAL) --- */
.installer-portal-header {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  padding: 18px 22px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.installer-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.installer-product-card,
.installer-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.installer-product-card:hover,
.installer-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

.installer-card-title {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 8px;
}

.installer-price-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
}

.installer-discounted-price {
  font-size: 1.25rem;
  font-weight: 800;
  color: #047857;
  line-height: 1.2;
  margin: 2px 0;
}

.installer-original-price {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.installer-stepper-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.installer-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.btn-step-sub,
.btn-step-add {
  width: 34px;
  height: 36px;
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-step-sub:active,
.btn-step-add:active {
  background: var(--border-light);
}

.installer-qty-input {
  width: 54px;
  height: 36px;
  border: none;
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  border-radius: 0;
  text-align: center;
  font-weight: 700;
  padding: 4px;
}

.price-strike {
  text-decoration: line-through;
  color: var(--text-subtle);
  font-size: 0.85rem;
}

.installer-price {
  font-size: 1.35rem;
  font-weight: 700;
  color: #047857;
}

.installer-qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.installer-qty-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.installer-qty-btn:active {
  background: var(--border-light);
}

/* Floating Cart Bar for Installer on Phone */
.installer-floating-cart {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 500px;
  margin: 0 auto;
  background: #0f172a;
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  z-index: 60;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.installer-floating-cart:hover {
  transform: scale(1.02);
}

/* Status Badges for Orders */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-preparing { background: #e0f2fe; color: #0369a1; }
.status-ready { background: #dcfce7; color: #15803d; }
.status-completed { background: #f1f5f9; color: #475569; }

/* Pulse animation for new pending orders */
.pulse-badge {
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* RESPONSIVE BREAKPOINTS */
@media (max-width: 1280px) {
  .edition-header-badge {
    display: none !important;
  }
}

@media (max-width: 1080px) {
  .header-kbd-badge {
    display: none !important;
  }
}

/* Warehouse & Mobile Responsive Mode (< 900px) */
@media (max-width: 899px) {
  .sidebar {
    display: none;
  }

  .sidebar.mobile-open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 85vw);
    height: 100dvh;
    z-index: 130;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
  }

  .sidebar.mobile-open .mobile-sidebar-close {
    display: inline-flex !important;
    margin-left: auto;
    flex-shrink: 0;
  }

  .sidebar-backdrop.active {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 125;
    backdrop-filter: blur(2px);
  }

  .mobile-menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 6px;
    margin-left: -4px;
    color: var(--text-main);
    flex-shrink: 0;
  }

  .bottom-nav {
    display: block;
  }

  .fab-scan {
    display: flex;
    width: 50px;
    height: 50px;
    right: 14px;
    bottom: calc(var(--bottom-nav-height) + 12px);
  }

  .top-header {
    height: 56px !important;
    max-height: 56px !important;
    overflow: hidden !important;
    padding: 0 12px !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
  }

  .header-left {
    gap: 8px !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .header-title-wrapper {
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .header-title-wrapper h1 {
    font-size: 1.05rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .edition-header-badge,
  .header-kbd-badge,
  #btn-toggle-mode,
  #btn-open-scanner,
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline !important;
  }

  .header-actions {
    gap: 6px !important;
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }

  .header-actions .btn-sm {
    padding: 6px 10px !important;
    font-size: 0.76rem !important;
    white-space: nowrap !important;
    gap: 4px !important;
  }

  .content-area {
    padding: 12px;
    padding-bottom: calc(var(--bottom-nav-height) + 78px);
  }

  .card {
    padding: 14px;
    margin-bottom: 14px;
  }

  .doc-grid-header {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .client-selected-info {
    flex-wrap: wrap;
    gap: 6px;
  }

  .doc-footer-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .add-item-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 10px;
  }

  .doc-qty-group {
    width: 100%;
  }

  .add-item-bar .btn {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
  }

  .inventory-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-input-wrap {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
    max-width: 100% !important;
  }

  .filter-pills {
    width: 100%;
    max-width: 100%;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .vat-recap-box {
    padding: 12px;
    overflow-x: auto;
  }

  .vat-recap-table {
    font-size: 0.78rem;
  }

  .vat-recap-table th,
  .vat-recap-table td {
    padding: 5px 4px;
  }

  .totals-summary-box {
    padding: 14px;
  }

  .summary-row {
    font-size: 0.88rem;
    gap: 8px;
  }

  .summary-row.grand-total {
    font-size: 1.18rem;
  }

  .installer-portal-header {
    padding: 14px;
  }

  .installer-floating-cart {
    left: 10px;
    right: 10px;
    bottom: 12px;
    padding: 10px 14px;
    gap: 8px;
    font-size: 0.85rem;
  }

  #installer-cart-total {
    font-size: 1rem !important;
    white-space: nowrap;
  }

  .toast-container {
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-nav-height) + 12px);
  }
}

@media screen and (max-width: 640px) {
  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .doc-type-selector {
    width: 100%;
    gap: 4px;
    padding: 4px;
  }

  .doc-type-btn {
    padding: 8px 6px;
    font-size: 0.82rem;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .installer-catalog-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #installer-login-view {
    margin: 12px auto !important;
    padding: 18px 16px !important;
  }

  .analytics-chart-grid {
    gap: 4px !important;
    padding: 14px 4px 8px !important;
  }

  .modal-overlay {
    padding: 10px;
  }

  .modal-box {
    max-height: 92dvh;
    width: 100%;
  }

  .modal-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-body {
    padding: 14px;
  }

  .modal-footer {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-body [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .a4-sheet-preview .print-header-grid,
  .a4-sheet-preview .print-parties-box,
  .a4-sheet-preview .print-financials-grid {
    flex-direction: column;
    gap: 10px;
  }

  .a4-sheet-preview .print-doc-meta,
  .a4-sheet-preview .print-grand-total-box {
    text-align: left;
    width: 100%;
  }

  .a4-sheet-preview .print-vat-box {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .top-header {
    padding: 8px 10px;
    gap: 6px;
  }

  .header-title-wrapper h1 {
    font-size: 0.92rem;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .btn-sm {
    padding: 5px 7px;
    font-size: 0.72rem;
  }

  .bottom-tab-btn {
    font-size: 0.68rem;
  }
}

/* =========================================================
   A4 DOCUMENT PREVIEW MODAL & SHARED PRINT STYLES
   ========================================================= */
.modal-box-a4 {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  width: 95%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.a4-preview-scroll-area {
  background: #334155;
  padding: 24px 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  justify-content: center;
}

.a4-sheet-preview {
  background: #ffffff;
  color: #111827;
  width: 100%;
  max-width: 800px;
  min-height: 1050px;
  padding: 38px 44px;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .a4-preview-scroll-area {
    padding: 10px 4px;
  }
  .a4-sheet-preview {
    padding: 16px 12px;
    font-size: 8pt;
  }
}

/* SHARED INVOICE & REPORT TYPOGRAPHY */
.print-header-grid {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 2px solid #000;
  padding-bottom: 12px;
}

.print-seller-info h2 {
  font-size: 13.5pt;
  font-weight: 800;
  margin: 0 0 4px 0;
  color: #0f172a;
}
.print-seller-info p {
  font-size: 9pt;
  line-height: 1.35;
  margin: 2px 0;
  color: #334155;
}

.print-doc-meta {
  text-align: right;
}
.print-doc-title {
  font-size: 15pt;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #0284c7;
}
.print-meta-row {
  font-size: 9.5pt;
  margin: 2px 0;
}

.print-parties-box {
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 20px;
}

.print-party-card {
  flex: 1;
  border: 1px solid #cbd5e1;
  padding: 10px 12px;
  border-radius: 4px;
  background: #f8fafc;
}
.print-party-card h4 {
  font-size: 9.5pt;
  font-weight: bold;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
  margin: 0 0 6px 0;
  text-transform: uppercase;
  color: #475569;
}
.print-party-card p {
  font-size: 9pt;
  line-height: 1.4;
  margin: 2px 0;
  color: #1e293b;
}

/* Document & Analytics Tables */
table.print-table,
table.print-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 9pt;
}
table.print-table th,
table.print-items-table th {
  background-color: #f1f5f9 !important;
  border: 1px solid #94a3b8;
  padding: 6px 8px;
  font-weight: 700;
  text-align: right;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
table.print-table th:nth-child(1),
table.print-table th:nth-child(2),
table.print-table th:nth-child(3),
table.print-table th:nth-child(4),
table.print-items-table th:nth-child(1),
table.print-items-table th:nth-child(2),
table.print-items-table th:nth-child(3) {
  text-align: left;
}
table.print-table td,
table.print-items-table td {
  border: 1px solid #cbd5e1;
  padding: 6px 8px;
  text-align: right;
}
table.print-table td:nth-child(1),
table.print-table td:nth-child(2),
table.print-table td:nth-child(3),
table.print-table td:nth-child(4),
table.print-items-table td:nth-child(1),
table.print-items-table td:nth-child(2),
table.print-items-table td:nth-child(3) {
  text-align: left;
}

.print-financials-grid {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
}

.print-vat-box {
  width: 54%;
  border: 1px solid #94a3b8;
  font-size: 8.5pt;
  border-radius: 4px;
  overflow: hidden;
}
.print-vat-box table {
  width: 100%;
  border-collapse: collapse;
}
.print-vat-box th, .print-vat-box td {
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  text-align: right;
}
.print-vat-box th:first-child, .print-vat-box td:first-child {
  text-align: left;
}

.print-grand-total-box {
  width: 42%;
  text-align: right;
}
.print-grand-total-box .total-label {
  font-size: 11pt;
  font-weight: bold;
  color: #334155;
}
.print-grand-total-box .total-number {
  font-size: 18pt;
  font-weight: 900;
  margin-top: 4px;
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
  padding: 4px 0;
  color: #0f172a;
}

.print-signatures-box {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  padding-top: 20px;
}
.print-sig-col {
  width: 42%;
  text-align: center;
}
.sig-line {
  border-bottom: 1px dashed #333;
  margin-bottom: 6px;
  height: 40px;
}
.sig-label {
  font-size: 9pt;
  font-weight: 600;
}

/* Shared Header for Summary Reports (Weekly Analytics, Expenses) */
.print-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  border-bottom: 2px solid #334155;
  padding-bottom: 10px;
}
.print-doc-brand .company-name {
  font-size: 13pt;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 3px;
}
.print-doc-brand .company-details {
  font-size: 8.5pt;
  line-height: 1.35;
  color: #475569;
}
.doc-type-badge {
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid;
  border-radius: 4px;
  display: inline-block;
}
.doc-number-row {
  font-size: 8.5pt;
  color: #334155;
}

/* =========================================================
   PRINT STYLESHEET (A4 Physical Print & PDF Output)
   ========================================================= */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 10mm 8mm 10mm;
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 9.5pt !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    width: 100% !important;
    overflow: visible !important;
  }

  /* Completely hide all app chrome, wrappers, sidebars, navigation, modals, and FAB */
  .app-container,
  .main-wrapper,
  .content-area,
  .sidebar,
  .top-header,
  .bottom-nav,
  .fab-scan,
  .toast-container,
  .modal-overlay,
  .no-print,
  .btn,
  .filter-pills,
  .inventory-controls,
  .page-view {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
  }

  /* ONLY #print-container is printed */
  #print-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #111 !important;
    background: #fff !important;
  }

  .print-header-grid {
    margin-bottom: 12px !important;
    padding-bottom: 8px !important;
    page-break-inside: avoid !important;
  }

  .print-parties-box {
    margin-bottom: 12px !important;
    gap: 14px !important;
    page-break-inside: avoid !important;
  }

  .print-party-card {
    padding: 8px 10px !important;
  }

  table.print-table {
    margin-bottom: 12px !important;
    page-break-inside: auto !important;
  }
  table.print-table th, table.print-table td {
    padding: 4px 6px !important;
  }

  .print-financials-grid {
    margin-bottom: 12px !important;
    gap: 14px !important;
    page-break-inside: avoid !important;
  }

  .print-signatures-box {
    margin-top: 20px !important;
    padding-top: 10px !important;
    page-break-inside: avoid !important;
  }
  .sig-line {
    height: 28px !important;
  }
}

/* =========================================================
   STRICT INSTALLER ISOLATION MODE
   Hides all internal store chrome, sidebars, headers, bottom navigation,
   and prevents access to POS/Counter/Warehouse management.
   ========================================================= */
body.installer-mode .sidebar,
body.installer-mode .sidebar.mobile-open,
body.installer-mode .sidebar-backdrop,
body.installer-mode .top-header,
body.installer-mode .bottom-nav,
body.installer-mode .fab-scan,
body.installer-mode #btn-exit-installer-portal,
body.installer-mode #btn-open-settings,
body.installer-mode #btn-toggle-mode {
  display: none !important;
}

body.installer-mode .app-container {
  display: block !important;
}

body.installer-mode .main-wrapper {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
}

body.installer-mode .content-area {
  padding: 12px !important;
  padding-bottom: 90px !important;
  max-width: 1200px !important;
  margin: 0 auto !important;
}

body.installer-mode .page-view:not(#view-installer-portal) {
  display: none !important;
}

body.installer-mode #view-installer-portal {
  display: block !important;
}
