/* ─────────────────────────────────────────────────────────────────────────────
   BVL Theme — matches Blazor app palette exactly
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --color-primary:        #1a2744;
  --color-primary-dark:   #111b33;
  --color-primary-light:  #2d4070;
  --color-secondary:      #0288d1;
  --color-secondary-dark: #01579b;
  --color-bg:             #eef1f6;
  --color-bg-gray:        #f0f3f9;
  --color-surface:        #ffffff;
  --color-text:           #1a1f2e;
  --color-text-muted:     #5a6378;
  --color-border:         #dde3ee;
  --color-hover:          #e3f0fd;
  --color-success:        #2e7d32;
  --color-success-light:  #e8f5e9;
  --color-warning:        #f57f17;
  --color-warning-light:  #fff8e1;
  --color-error:          #c62828;
  --border-radius:        8px;
  --shadow-sm:            0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:            0 2px 10px rgba(0,0,0,0.12);
  --header-height:        56px;
  --nav-height:           64px;
}

/* ── Reset + Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  overflow-x: hidden;
  height: 100%;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─────────────────────────────────────────────────────────────────────────────
   LOGIN SCREEN
   ───────────────────────────────────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 20px;
}

.login-container {
  width: 100%;
  max-width: 380px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
}

.login-card { padding: 28px 24px; }

/* ── Form Elements ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: 17px;
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}

.form-group input:focus {
  border-color: var(--color-secondary);
  background: white;
}

.error-message {
  color: var(--color-error);
  font-size: 14px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: #ffebee;
  border-radius: var(--border-radius);
  border-left: 3px solid var(--color-error);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-light); }

.btn-success { background: var(--color-success); color: white; }
.btn-success:hover:not(:disabled) { background: #1b5e20; }

.btn-secondary { background: var(--color-primary); color: white; }
.btn-secondary:hover:not(:disabled) { background: var(--color-primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
  height: 44px;
  font-size: 15px;
}

.btn-full { width: 100%; }
.btn-large { height: 58px; font-size: 18px; width: 100%; }

/* ── Icon Button ───────────────────────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  color: inherit;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.12); }

/* ── Spinner (button) ──────────────────────────────────────────────────────── */
.btn-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   APP SHELL
   ───────────────────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sync Banner ───────────────────────────────────────────────────────────── */
.sync-banner {
  background: #fff3e0;
  border-bottom: 2px solid #ff8f00;
  color: #e65100;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  flex-shrink: 0;
  z-index: 20;
}

/* ── App Header ────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--color-primary);
  color: white;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 10;
}

.route-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ── Content Area ──────────────────────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* ── Pull-to-Refresh Indicator ─────────────────────────────────────────────── */
.ptr-indicator {
  text-align: center;
  padding: 12px;
  color: var(--color-text-muted);
  font-size: 13px;
  height: 0;
  overflow: hidden;
  transition: height 0.2s ease;
}

.ptr-indicator.visible {
  height: 44px;
}

/* ── Bottom Navigation ─────────────────────────────────────────────────────── */
.bottom-nav {
  background: #fff;
  border-top: 1px solid var(--color-border);
  height: 52px;
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
  position: relative;
}

.app-version {
  position: absolute;
  right: 6px;
  bottom: calc(4px + env(safe-area-inset-bottom));
  font-size: 9px;
  color: var(--color-border);
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.02em;
}

.nav-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 15px;
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab.active {
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
}

/* ── Loading Spinner ───────────────────────────────────────────────────────── */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--color-text-muted);
  font-size: 15px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────────────────────────────────────
   CHARGEMENT TAB
   ───────────────────────────────────────────────────────────────────────────── */
.summary-badge {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 7px 18px;
  font-size: 14px;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 16px;
  font-weight: 500;
}

.summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-bg-gray);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.product-section {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.product-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-gray);
}

.section-pill {
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pill-pleine { background: var(--color-primary);   color: white; }
.pill-vide   { background: #607d8b;                color: white; }
.pill-jus    { background: var(--color-secondary);  color: white; }

.section-total {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-left: auto;
}

.product-list { padding: 2px 0; }

.product-row {
  display: flex;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 6px;
}
.product-row:last-child { border-bottom: none; }

.product-qty {
  font-weight: 700;
  font-size: 18px;
  color: var(--color-primary);
  min-width: 36px;
}

.product-code {
  font-size: 17px;
  font-family: 'Courier New', monospace;
  color: var(--color-text);
}

/* ─────────────────────────────────────────────────────────────────────────────
   LIVRAISONS TAB
   ───────────────────────────────────────────────────────────────────────────── */
.delivery-list { display: flex; flex-direction: column; gap: 10px; }

.delivery-card {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-left-color 0.2s, background 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border: 0.5px solid var(--color-border);
  border-left: 4px solid #dde3ee;
}

.delivery-card:active { background: var(--color-hover); }

.delivery-card.done {
  border-left-color: #2e7d32;
  background: #f1f8f1;
}

/* ── Status Badges ─────────────────────────────────────────────────────────── */
.status-done {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #2e7d32;
  color: white;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
}

.status-pending {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f0f3f9;
  color: #5a6378;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 12px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   DETAIL PANEL (slides in from right)
   ───────────────────────────────────────────────────────────────────────────── */
.detail-panel {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.detail-panel.open { transform: translateX(0); }

.detail-header {
  background: var(--color-primary);
  color: white;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.back-btn {
  background: none;
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,0.12); }

.detail-title-area { min-width: 0; flex: 1; }

.detail-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-bvlid {
  font-size: 12px;
  opacity: 0.72;
  font-family: 'Courier New', monospace;
  display: block;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: 40px;
}

/* ── Info Sections (in detail) ─────────────────────────────────────────────── */
.info-section {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.info-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  padding: 9px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-gray);
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-row {
  display: flex;
  padding: 13px 16px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  align-items: flex-start;
}
.info-row:last-child { border-bottom: none; }

.info-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 78px;
  flex-shrink: 0;
  padding-top: 2px;
}

.info-value {
  font-size: 17px;
  color: var(--color-text);
  flex: 1;
  line-height: 1.35;
}

.info-value a {
  color: var(--color-secondary);
  text-decoration: none;
}

.badge-exclusif {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 600;
}

/* ── Collect payment badge (delivery card) ────────────────────────────────── */
.badge-collect-payment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #c62828;
  color: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
}

/* ── Collect payment banner (detail panel) ────────────────────────────────── */
.collect-payment-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #c62828;
  color: #fff;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid #b71c1c;
}

.collect-payment-icon {
  font-size: 22px;
  font-weight: 900;
}

/* ── Inventory badge (delivery card) ──────────────────────────────────────── */
.badge-inventaire {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff8e1;
  color: #e65100;
  border: 1px solid #ffcc02;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
}

.badge-inventaire-done {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
  font-weight: 600;
}

/* ── Inventory section (detail panel) ─────────────────────────────────────── */
.inventory-section {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.inventory-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #e65100;
  margin-bottom: 12px;
}

.inventory-icon {
  font-size: 20px;
}

.inventory-section.inventory-done {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #e8f5e9;
  border-bottom-color: #a5d6a7;
  color: #2e7d32;
  font-size: 15px;
  font-weight: 600;
}

.inventory-section.inventory-done > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-inventory {
  background: #e65100;
  color: white;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  letter-spacing: 0.3px;
}

.btn-inventory:active { background: #bf360c; }

/* ── Products in detail ────────────────────────────────────────────────────── */
.detail-product-sub {
  border-bottom: 1px solid var(--color-border);
}
.detail-product-sub:last-child { border-bottom: none; }

.detail-product-sub-header {
  padding: 8px 16px;
  background: var(--color-bg-gray);
  border-bottom: 1px solid var(--color-border);
}

.detail-product-row {
  padding: 11px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
  font-size: 17px;
}
.detail-product-row:last-child { border-bottom: none; }

/* ── Item edit controls (driver quantity edit / line delete) ─────────────────── */
.item-edit-row { gap: 6px; }

.item-qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface, #fff);
  color: var(--color-primary);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.item-qty-btn:active { background: var(--color-bg-gray); }

.item-qty-value { min-width: 28px; text-align: center; }

.item-delete-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface, #fff);
  color: #c62828;
  font-size: 15px;
  flex-shrink: 0;
  margin-left: auto;
}
.item-delete-btn:active { background: #ffebee; }

/* ── Notes card ────────────────────────────────────────────────────────────── */
.notes-card {
  background: var(--color-warning-light);
  border: 1px solid #ffe082;
  border-radius: var(--border-radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.notes-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #c17900;
  margin-bottom: 8px;
}

.notes-card-text {
  font-size: 16px;
  color: #5d4037;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Driver Note ───────────────────────────────────────────────────────────── */
.driver-note-section {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.driver-note-textarea {
  width: 100%;
  min-height: 90px;
  padding: 13px 16px;
  border: none;
  border-top: 1px solid var(--color-border);
  font-size: 16px;
  font-family: inherit;
  color: var(--color-text);
  resize: none;
  outline: none;
  background: var(--color-surface);
  display: block;
}
.driver-note-textarea::placeholder { color: #aab2c0; }

.note-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 12px;
  justify-content: flex-end;
}

.note-save-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: opacity 0.2s;
}

.note-save-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.note-save-btn.loading {
  opacity: 0.7;
  cursor: not-allowed;
}

.note-status {
  font-size: 13px;
  transition: opacity 0.5s;
}

.note-status.success { color: #2e7d32; }
.note-status.offline { color: #e65100; }
.note-status.error   { color: #c62828; }

/* ── Save Icon Button (note + invoice) ─────────────────────────────────────── */
.save-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #2e7d32;
  color: white;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, background 0.2s;
}
.save-icon-btn:disabled {
  background: #dde3ee;
  color: #5a6378;
  cursor: not-allowed;
}
.save-icon-btn.loading {
  background: #1b5e20;
  cursor: not-allowed;
}

/* ── Action Section ────────────────────────────────────────────────────────── */
.action-section { margin-bottom: 14px; }

.success-banner {
  background: var(--color-success-light);
  border: 1px solid #a5d6a7;
  border-radius: var(--border-radius);
  padding: 18px 16px;
  color: var(--color-success);
  font-size: 18px;
  font-weight: 600;
}

.success-banner .success-time {
  display: block;
  font-size: 14px;
  font-weight: 400;
  margin-top: 4px;
  color: #388e3c;
}

/* ── Undo completion link ──────────────────────────────────────────────────── */
.undo-link {
  display: block;
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-align: center;
  cursor: pointer;
  margin-top: 12px;
  padding: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.undo-link:hover { color: var(--color-error); }

/* ── Invoice recipient name, shown under the print button ──────────────────── */
.print-received-by {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  text-align: center;
}
.print-received-by-edit {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--color-secondary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0 0 0 4px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.offline-note {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 10px;
  padding: 8px;
  background: #fff8e1;
  border-radius: var(--border-radius);
  border: 1px solid #ffe082;
}

/* ─────────────────────────────────────────────────────────────────────────────
   LOGIN — ROUTE SELECTOR
   ───────────────────────────────────────────────────────────────────────────── */

/* Loading spinner row */
.routes-loading-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px 16px;
  color: var(--color-text-muted);
  font-size: 15px;
}

.routes-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Route dropdown */
.route-select {
  width: 100%;
  height: 56px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  background: white;
  color: var(--color-text);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: auto; /* keep native OS chevron */
  transition: border-color 0.15s;
}

.route-select:focus {
  border-color: var(--color-secondary);
}

/* Stale-cache indicator below select */
.routes-cache-note {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

/* Offline / no-cache notice above manual input */
.routes-offline-msg {
  font-size: 14px;
  color: var(--color-warning);
  background: var(--color-warning-light);
  border: 1px solid #ffe082;
  border-radius: var(--border-radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  font-weight: 500;
}

/* Se connecter button — secondary blue */
.login-submit-btn {
  background: var(--color-secondary);
  color: white;
}
.login-submit-btn:hover:not(:disabled) {
  background: var(--color-secondary-dark);
}

/* ── Confirmation Dialog ───────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  /* Must stay above #print-invoice-overlay (z-index: 10000) — the recipient-name
     dialog is shown from inside that overlay's print button handler. */
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dialog-box {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  padding: 24px;
  width: 100%;
  max-width: 340px;
}

.dialog-message {
  font-size: 17px;
  color: var(--color-text);
  margin-bottom: 24px;
  line-height: 1.45;
}

.dialog-box--payment {
  border-top: 4px solid #c62828;
}

.dialog-box--payment .dialog-message {
  color: #c62828;
  font-weight: 600;
}

.dialog-box--payment #dialog-confirm {
  background: #c62828;
}
.dialog-box--payment #dialog-confirm:hover:not(:disabled) {
  background: #b71c1c;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.dialog-input-row { margin-bottom: 16px; }

.dialog-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: var(--border-radius);
  color: var(--color-text);
}
.dialog-input:focus {
  outline: none;
  border-color: var(--color-secondary);
}
.dialog-input--error {
  border-color: #c62828;
}

.dialog-input-error {
  color: #c62828;
  font-size: 13px;
  margin: 6px 0 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   PRINT — on-the-spot invoice (see pwa/js/print.js)
   ───────────────────────────────────────────────────────────────────────────── */
#print-invoice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 10000;
  flex-direction: column;
}
#print-invoice-overlay.open { display: flex; }

.pi-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.pi-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  justify-content: center;
}

.pi-doc {
  background: white;
  color: #1a1a1a;
  width: 100%;
  max-width: 640px;
  padding: 24px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
}

.pi-header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.pi-company-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.pi-company-detail { font-size: 11px; color: #555; }
.pi-meta { text-align: right; }
.pi-title { font-weight: 700; font-size: 16px; letter-spacing: 1px; margin-bottom: 6px; }
.pi-meta-table td { padding: 1px 0; font-size: 12px; white-space: nowrap; }
.pi-meta-table td:first-child { color: #555; padding-right: 10px; }

.pi-bill-to { margin-bottom: 16px; }
.pi-section-label { font-size: 10px; text-transform: uppercase; color: #888; letter-spacing: 0.5px; margin-bottom: 3px; }
.pi-customer-name { font-weight: 600; }
.pi-customer-detail, .pi-customer-id { font-size: 12px; color: #444; }

/* Plain table-layout: auto (NOT fixed) + white-space:nowrap on every column
   except Description. Per spec, a nowrap cell's full text width becomes a hard
   MINIMUM for its column under auto layout — the browser must honor it and can
   only compress columns that are still allowed to wrap, which is only
   Description (no nowrap here). So Produit/Qté/Prix unit./Total/TX always show
   their full content on one line, and Description alone absorbs the squeeze.
   A previous attempt used table-layout:fixed with width:1% on those columns
   (a common desktop-browser "shrink to content" trick) — don't reintroduce
   that: Android's print rendering takes width:1% literally instead of
   shrink-to-fit, squeezing those columns to near-nothing and making every
   row's text overlap since there was nothing to make it clip instead. Plain
   auto layout has no such quirk-dependence and is what's proven to work here. */
.pi-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.pi-table th:not(:nth-child(3)), .pi-table td:not(:nth-child(3)) {
  white-space: nowrap;
}
.pi-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; color: #666;
  border-bottom: 2px solid #ccc; padding: 6px 4px;
}
.pi-table td {
  padding: 6px 4px; border-bottom: 1px solid #eee; font-size: 12.5px;
  vertical-align: top;
}
.pi-desc {
  overflow-wrap: break-word;
}
.pi-center { text-align: center; }
.pi-num { text-align: right; }

.pi-totals { margin-left: auto; width: 260px; }
.pi-totals td { padding: 3px 4px; font-size: 12.5px; }
.pi-total-row td { font-weight: 700; font-size: 14px; border-top: 2px solid #333; padding-top: 6px; }

.pi-footnote-mark { font-size: 10px; vertical-align: super; }
.pi-footnote { font-size: 10px; margin-bottom: 4px; }

.pi-footer { font-size: 11px; color: #666; text-align: center; }

/* Forces real paper feed past the footer before the print job ends. The ZQ520
   (confirmed on-device) prints everything, including trailing blank CSS margin —
   but doesn't feed blank space past the tear bar unless something with actual ink
   comes after it, so a driver tearing right where the paper stops feeding cuts into
   the last printed line. A blank CSS margin at the very end of the document doesn't
   fix this (tested 20mm/40mm/80mm — no effect: it's trailing space with nothing
   after it, so it's never fed out). This div is real drawn content (a border, i.e.
   ink) placed AFTER the footer with a real gap before it — the print head has to
   physically advance through that gap to reach it, which is what actually creates
   safe tear clearance. Keep this as the last element in .pi-doc. */
.pi-cut-line { border-top: 1px dashed #999; margin: 15mm 0 2mm; }

/* Printer paper width — this is a continuous thermal roll, not cut sheets, so page
   HEIGHT must be "auto" (fit the actual content) rather than a fixed A4/Letter length,
   or the print job comes out with a huge blank tail. Real printer is the Zebra ZQ520,
   a 104mm (4") direct-thermal roll — printed to via the browser's print dialog
   (window.print()), with the driver selecting it through the "Zebra Print" Android
   print-service app. (An earlier version of this sent ZPL straight to the printer via
   Zebra's "Browser Print" local service, skipping the OS dialog — abandoned because
   Chrome's Local/Private Network Access policy blocks that service from an HTTPS page;
   see print.js.) Both the Zebra Print app's "Fit to Page" OFF / "Variable Length" ON
   settings (see companion memory) AND .pi-cut-line above are needed for a clean tear —
   this margin alone does nothing since it's trailing blank space (see .pi-cut-line). */
@page {
  size: 104mm auto;
  margin: 4mm;
}

@media print {
  body > *:not(#print-invoice-overlay) { display: none !important; }
  #print-invoice-overlay { position: static; display: block !important; background: white; }
  .pi-toolbar { display: none !important; }
  .pi-scroll { overflow: visible; padding: 0; display: block; }
  .pi-doc { box-shadow: none; max-width: 100%; padding: 0; font-size: 10px; }
  .pi-company-name { font-size: 12px; }
  .pi-title { font-size: 13px; }
}
