* { box-sizing: border-box; }

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --primary: #4550e6; /* PingPing brand blue/purple */
  --primary-dark: #2f36b8;
  --brand-gradient: linear-gradient(135deg, #228dfc, #5350fb);
  --pending: #9ca3af;
  --in-progress: #f59e0b;
  --ready: #16a34a;
  --border: #e5e7eb;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 12px;
  row-gap: 10px;
  padding: 12px 20px;
  background: var(--brand-gradient);
  color: white;
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar-left { min-width: 0; justify-self: start; }
.topbar-center { justify-self: center; }
.brand-badge {
  background: white;
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  line-height: 0;
}
.brand-badge img { height: 42px; display: block; }
.brand-subtitle { font-size: 30px; opacity: 0.9; font-weight: 600; }
.topbar-actions {
  min-width: 0;
  justify-self: end;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:active { background: var(--primary-dark); }
.btn-ghost { background: rgba(255,255,255,0.15); color: white; text-decoration: none; display: inline-block; padding: 10px 16px; border-radius: 8px; font-weight: 600; border: none; cursor: pointer; font-family: inherit; font-size: 15px; }
.btn-secondary { background: #e5e7eb; color: #111; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-success { background: #dcfce7; color: #14532d; }
.btn-icon { padding: 10px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon svg { display: block; }

.readonly-banner {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  padding: 12px 20px;
}
.readonly-banner.hidden { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #1a1a1a;
  color: white;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 22px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 2000;
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.hidden { display: none; }

.new-job { padding: 20px; }
.new-job form { display: flex; flex-wrap: wrap; gap: 12px; max-width: 600px; }
.new-job input {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 20px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
}
.new-job button { flex: 0 0 auto; }

.dockett-section .error { margin: 4px 0 0; }
.scan-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 600px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.scan-row input {
  flex: 0 0 auto;
  width: 100%;
  font-size: 20px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
}
.scan-buttons-row { display: flex; flex-wrap: wrap; gap: 12px; }
.scan-row button { flex: 0 0 auto; }
#find-dockett-btn, #camera-scan-btn { display: inline-flex; align-items: center; gap: 6px; }

.camera-video {
  width: 100%;
  max-width: 320px;
  margin: 12px auto;
  display: block;
  border-radius: 10px;
  background: #000;
}

/* The printed docket is never shown on screen — only when window.print()
   runs, via the @media print rules further down. */
.print-docket { display: none; }

.queue {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 0 20px 40px;
}

.job-card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 8px solid var(--pending);
}
.job-card.status-pending { border-left-color: var(--pending); }
.job-card.status-in_progress { border-left-color: var(--in-progress); }
.job-card.status-ready { border-left-color: var(--ready); }

.job-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.job-number { font-size: 28px; font-weight: 800; }
.job-status-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: 60%;
}
.status-badge {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  color: white;
}
.status-badge.status-pending { background: var(--pending); }
.status-badge.status-in_progress { background: var(--in-progress); }
.status-badge.status-ready { background: var(--ready); }

.job-description-highlight {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.25;
  text-align: right;
}
.job-timestamp { font-size: 13px; color: var(--muted); margin-top: 2px; }
.job-cost-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-top: 6px; }
.job-cost-value { font-weight: 700; color: var(--primary); }
.job-cost-items { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.notified-note { font-size: 13px; color: var(--ready); font-weight: 600; margin-top: 8px; }
.customer-info { margin: 10px 0; min-height: 44px; }
.customer-info .waiting { color: var(--muted); font-style: italic; }
.customer-info .name { font-weight: 600; }
.phone-row, .missing-contact-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 2px; }
.phone-row .phone { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.btn-pill {
  border: none;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn-pill-secondary { background: #e5e7eb; color: #111; }

.job-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.job-actions .btn { padding: 10px 14px; font-size: 15px; flex: 1; }
.job-actions .btn-icon { flex: 0 0 auto; }

.empty-state { color: var(--muted); text-align: center; padding: 60px 20px; grid-column: 1 / -1; }

.modal {
  /* Explicit top/right/bottom/left instead of the `inset` shorthand —
     older tablet browsers (pre-2021ish) silently ignore `inset`, which
     left this stuck in a corner sized to its content instead of covering
     the screen. */
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.modal.hidden { display: none; }
/* showConfirm() can now be triggered while another modal (e.g. the recycle
   bin) is already open — without this, both share the same z-index and
   stack in DOM order, where confirm-modal happens to come first in the
   markup, so it rendered invisibly underneath instead of on top. */
#confirm-modal { z-index: 1050; }
.modal-card {
  background: white;
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}
.modal-card img { width: 100%; max-width: 320px; margin: 12px auto; display: block; }
.modal-card .btn { width: 100%; margin-top: 12px; }
.modal-card input[type="number"], .modal-card input[type="text"], .modal-card input[type="tel"] {
  width: 100%;
  font-size: 20px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  margin-top: 8px;
  font-family: inherit;
}
.modal-field-label { display: block; text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 14px; }
.modal-card .qty-stepper { margin-top: 8px; }

.scan-result-card { max-width: 560px; padding: 20px; }
#scan-result-job { text-align: left; margin-top: 12px; }
#scan-result-job .job-status-col { max-width: 75%; }

.recycle-card { max-width: 640px; text-align: left; }
#recycle-empty.hidden { display: none; }
.recycle-list.hidden { display: none; }

/* ---------- Dockett "Quick Add" service picker ---------- */

.service-picker-card { max-width: 480px; }
#service-picker-back { width: auto; margin: 0 0 14px; }
.service-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.service-square-wrap { display: flex; flex-direction: column; gap: 6px; }
.service-square {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 8px;
  min-height: 90px;
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: white;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.service-square:active { background: var(--bg); }
.service-square-emoji { font-size: 32px; }

.service-picker-hint { color: var(--muted); font-size: 13px; margin: -8px 0 14px; }

.service-picker-cart { margin-bottom: 16px; text-align: left; }
.cart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--bg);
}
.cart-row-label { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.cart-row-remove {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 2px 6px;
}
.service-picker-actions { display: flex; gap: 10px; }
.service-picker-actions .btn { width: auto; flex: 1; margin-top: 0; }

.qty-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.qty-btn:active { background: var(--border); }
.qty-value { min-width: 24px; text-align: center; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }

.dockett-service-display {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
}
.dockett-service-label { font-weight: 700; font-size: 17px; line-height: 1.5; }
.dockett-service-actions { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.dockett-service-display .btn-pill { flex: 0 0 auto; }
.recycle-list {
  max-height: 50vh;
  overflow: auto;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.recycle-header, .recycle-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  min-width: 0;
}
.recycle-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.recycle-row { border-bottom: 1px solid var(--border); }
.recycle-row:last-child { border-bottom: none; }
.recycle-row input[type="checkbox"] { width: 20px; height: 20px; }
.recycle-col { font-size: 15px; overflow-wrap: break-word; }
.recycle-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.recycle-actions .btn { flex: 1 1 140px; min-width: 0; margin-top: 0; }
.recycle-actions .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.muted { color: var(--muted); font-size: 15px; }
.hidden { display: none !important; }

.settings-page { max-width: 480px; margin: 0 auto; padding: 24px; }
.settings-page label { display: block; margin: 14px 0 4px; font-weight: 600; }
.settings-page input, .settings-page select { width: 100%; padding: 10px; border: 2px solid var(--border); border-radius: 8px; font-size: 16px; font-family: inherit; background: white; }
.settings-page .row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.settings-page .row label { width: 90px; margin: 0; }
.settings-page .actions { margin-top: 20px; display: flex; gap: 12px; }
.settings-page code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
}
.settings-page textarea {
  width: 100%;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}
.reset-template-btn { margin-top: 8px; font-size: 14px; padding: 8px 14px; }
.template-preview {
  margin-top: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.template-preview-label { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.template-preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 15px;
  margin: 0 0 8px;
  background: var(--card);
  border-radius: 8px;
  padding: 10px 12px;
}
#template-preview-meta { font-size: 13px; }
#template-preview-meta.warning { color: #b45309; font-weight: 600; }

/* ---------- Admin: Dockett services editor ---------- */

.services-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.service-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.service-card-head { display: flex; align-items: center; gap: 10px; }
.service-emoji { font-size: 22px; }
.service-name { flex: 1; min-width: 0; font-weight: 700; }
.service-subcats { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.subcat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 6px 6px 12px;
}
.subcat-name { flex: 1; min-width: 0; font-size: 14px; }

.subcat-remove {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  padding: 2px 6px;
}
.subcat-add-row, .service-add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.subcat-add-row input, .service-add-row input {
  flex: 1 1 160px;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.service-name-input { flex: 1 1 220px !important; }

.emoji-picker-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  font-size: 20px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-picker-btn:hover { background: var(--bg); }
.service-card-head .emoji-picker-btn { width: 36px; height: 36px; font-size: 18px; border-radius: 8px; }

.emoji-picker-popover {
  position: fixed;
  z-index: 1000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 10px;
  max-width: 320px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.emoji-picker-popover.hidden { display: none; }
.emoji-picker-option {
  width: 36px;
  height: 36px;
  font-size: 19px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-picker-option:hover { background: var(--bg); }

.claim-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
  text-align: center;
}
.card-logo { height: 40px; margin-bottom: 16px; }
.card h1 { margin: 0 0 6px; font-size: 22px; }
.card label {
  display: block;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  margin: 16px 0 6px;
}
.card input {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  border: 2px solid var(--border);
  border-radius: 10px;
  text-align: left;
}
.card button {
  width: 100%;
  margin-top: 20px;
}
.error { color: #991b1b; margin-top: 10px; }

.stats-page { max-width: 900px; margin: 0 auto; padding: 24px; }
.range-picker { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.range-picker .btn { padding: 10px 16px; font-size: 15px; }

.custom-range-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--card);
  border-radius: 10px;
}
.custom-range-row.hidden { display: none; }
.custom-range-row label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.custom-range-row input[type="date"] {
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.custom-range-row .btn { padding: 8px 16px; font-size: 14px; }

.range-summary { margin-bottom: 16px; font-size: 14px; }

.print-insights-btn { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.stat-tile {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-value { font-size: 34px; font-weight: 800; color: var(--primary); }
.stat-label { margin-top: 4px; font-weight: 600; }
.stat-percent { margin-top: 6px; font-size: 13px; color: var(--muted); }

.export-row { margin-top: 24px; }
.export-row .btn { display: inline-block; text-decoration: none; }

/* ---------- Business Insights dashboard ---------- */

.insights-section {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-top: 20px;
}
.insights-section h2 { margin: 0 0 4px; font-size: 18px; }
.insights-section .muted { margin: 0 0 16px; font-size: 14px; }
.insights-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) {
  .insights-row { grid-template-columns: 1fr; }
}

/* Single-hue bar chart — one brand color, height carries magnitude, so it
   stays legible without relying on hue-vs-hue color discrimination. */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  padding-top: 8px;
  overflow-x: auto;
}
.bar-chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 0 20px;
  min-width: 20px;
  height: 100%;
}
.bar-chart-track {
  flex: 1;
  width: 100%;
  max-width: 32px;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
}
.bar-chart-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.bar-chart-label {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* New vs returning customers — a single stacked bar, direct-labeled below
   rather than relying on the two colors alone. */
.split-bar-track {
  display: flex;
  height: 28px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}
.split-bar-segment { height: 100%; }
.split-bar-new { background: #eb6834; }
.split-bar-returning { background: var(--primary); }
.split-bar-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 14px; }
.split-bar-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.split-bar-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.split-bar-swatch-new { background: #eb6834; }
.split-bar-swatch-returning { background: var(--primary); }

.opportunities-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.opportunities-list li {
  padding-left: 24px;
  position: relative;
  font-size: 15px;
  line-height: 1.4;
}
.opportunities-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.opportunities-list li.empty-state { padding-left: 0; }
.opportunities-list li.empty-state::before { display: none; }

.per-business-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.per-business-table th, .per-business-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.per-business-table th { color: var(--muted); font-weight: 600; }
.per-business-table td.num, .per-business-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Analytics dashboard ---------- */

.analytics-section-heading {
  margin: 28px 0 4px;
  font-size: 20px;
  font-weight: 800;
  padding-top: 12px;
  border-top: 2px solid var(--border);
}
.analytics-section-heading:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}
.chart-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chart-controls select {
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: white;
}
.chart-controls .btn { padding: 6px 12px; font-size: 13px; }

.chart-svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 13px; justify-content: center; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.growth-label { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.growth-bar-up { color: var(--ready); font-weight: 700; }
.growth-bar-down { color: #991b1b; font-weight: 700; }

.definition-note {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0 16px;
}

.kpi-detail { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------- PingPing Dockett: printed docket ---------- */

/* A named page (CSS Paged Media) scoped to just the docket — the shared
   @media print block below also prints the Insights dashboard from a
   different page, which must stay normal-page-sized (A4/Letter, for a desk
   printer or PDF export), so this can't be a blanket `@page` rule. Sized
   for a 58mm thermal receipt printer (e.g. GOOJPRT PT-210): "58mm" paper is
   really ~48-54mm of printable width once you account for the printer's
   own margins, and `auto` lets the length run however long the content
   needs instead of forcing a fixed receipt length. Without this, the
   browser defaults to A4 for the print job — which, fed to a thermal
   printer that's set up with a generic "Text Only" driver (common for
   these, since they rarely ship a real graphics driver), can make the
   driver dump the raw print command stream as literal text instead of
   rasterizing the page, i.e. it "prints code" instead of the docket. This
   CSS half only works once the printer itself is also configured for its
   real paper width rather than A4 — see the printer's own driver/paper
   settings in the OS.) */
@page docket {
  size: 58mm auto;
  /* Zero rather than a few mm — Chrome draws its own injected header/footer
     (date, page title/URL, page number) inside the page margin, so a 0
     margin leaves it nowhere to draw and it's dropped automatically. The
     content itself still gets breathing room from .print-docket's own
     padding below, just not from the page box. Staff can also turn this
     off by hand in the print dialog's "More settings" → "Headers and
     footers" — Chrome remembers that choice for next time — but this means
     they shouldn't need to. */
  margin: 0;
}

.print-docket-header img { height: 24px; }
.print-docket-number { font-size: 20px; font-weight: 800; margin-top: 8px; }
.print-docket-desc:not(:empty) { font-size: 16px; font-weight: 700; margin-top: 6px; }
.print-docket-cost:not(:empty) { font-size: 13px; font-weight: 500; margin-top: 4px; }
.print-docket-phone { font-size: 17px; font-weight: 700; margin-top: 8px; letter-spacing: 1px; }
.print-docket-name { font-size: 13px; margin-top: 2px; }
.print-docket-qr { width: 42mm; height: 42mm; margin: 10px auto; display: block; }
.print-docket-footer { font-size: 10px; color: #444; }
.print-docket-notes { margin-top: 10px; text-align: left; }
.print-docket-notes-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 4px; }
.print-docket-notes-box { border: 1px solid #000; height: 18mm; padding: 3px 4px; font-size: 11px; line-height: 1.3; box-sizing: border-box; overflow: hidden; }

@media print {
  /* `display: none` (not `visibility: hidden`) on everything except the
     thing being printed — visibility:hidden still occupies layout space,
     which is harmless on a normal-width A4/Letter page but disastrous on
     the docket's 58mm page: the full job queue, reflowed into a column
     that narrow, becomes extremely tall, and the browser paginates that
     invisible height into a dozen-plus extra blank pages that a thermal
     printer then dutifully prints. display:none removes it from layout
     entirely, so it can't contribute to page count. (display:none on an
     ancestor can't be un-hidden by a descendant the way visibility can,
     which is why this targets body's direct children with :not(), rather
     than using a blanket `body *` selector the way the old visibility
     version did.) */
  body > *:not(.print-docket):not(#insights-root) { display: none !important; }

  .print-docket {
    page: docket;
    display: block;
    width: 100%;
    padding: 3mm;
    text-align: center;
  }

  /* Business Insights print/export-to-PDF — shares the hiding rule above. */
  #insights-root {
    display: block;
    width: 100%;
    padding: 16px;
  }
  .range-picker, .custom-range-row, .print-insights-btn { display: none !important; }
  .print-header { display: block !important; }
  .insights-section, .stat-tile { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }

  /* Browsers default to skipping background colors/images when printing
     (to save ink), which is invisible on screen but silently blanks out
     the bar charts and the new/returning split bar — both are pure
     background-color fills with no visible border or content of their
     own. This forces backgrounds to print without the user needing to
     dig up "Background graphics" in their print dialog's More Settings. */
  #insights-root, #insights-root * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

.print-header { display: none; }
.print-header h1 { margin: 0 0 4px; font-size: 22px; }
.print-header .muted { margin: 0 0 16px; }
