/**
 * Customer portal — day/night compatible via lux-auth-theme tokens (--a-*)
 * Load AFTER lux-auth-theme.css
 */

/* ===== Portal page shell (respects light / dark) ===== */
body.lux-rs-portal-mode,
body.lux-rs-portal-mode.lux-landing,
body.lux-rs-portal-mode.lux-apple-rs,
body.lux-rs-portal-mode.lux-rs-body {
  background: var(--a-bg, #f5f5f7) !important;
  background-image: none !important;
  color: var(--a-text, #1d1d1f) !important;
  color-scheme: light dark !important;
}

html:has(body.lux-rs-portal-mode) {
  background: var(--a-bg, #f5f5f7) !important;
}

/* Hide main site chrome */
body.lux-rs-portal-mode .lux-auth-nav,
body.lux-rs-portal-mode .lux-landing-nav,
body.lux-rs-portal-mode nav.lux-auth-nav,
body.lux-rs-portal-mode .lux-lang-fab {
  display: none !important;
}

/* Full-width responsive canvas */
body.lux-rs-portal-mode .ldx-wrap {
  width: 100% !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding-top: max(0.75rem, env(safe-area-inset-top, 0px)) !important;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
  padding-inline: max(0.75rem, env(safe-area-inset-left, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px)) !important;
  box-sizing: border-box !important;
  background: transparent !important;
}

body.lux-rs-portal-mode .lux-rs-page {
  width: 100% !important;
  max-width: min(1280px, 100%) !important;
  margin: 0 auto !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-results--portal {
  width: 100% !important;
  max-width: none !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  color: inherit !important;
}

@media (min-width: 640px) {
  body.lux-rs-portal-mode .ldx-wrap {
    padding-inline: max(1.25rem, env(safe-area-inset-left, 0px))
      max(1.25rem, env(safe-area-inset-right, 0px)) !important;
  }
}

@media (min-width: 1024px) {
  body.lux-rs-portal-mode .ldx-wrap {
    padding-inline: max(1.75rem, env(safe-area-inset-left, 0px))
      max(1.75rem, env(safe-area-inset-right, 0px)) !important;
  }
}

/* ===== Portal UI tokens (bound to auth theme) ===== */
.lux-cp {
  --cp-bg: var(--a-bg, #f5f5f7);
  --cp-card: var(--a-surface, #ffffff);
  --cp-inset: var(--a-surface-2, #f5f5f7);
  --cp-text: var(--a-text, #1d1d1f);
  --cp-text-2: var(--a-text-2, #3a3a3c);
  --cp-muted: var(--a-muted, #6e6e73);
  --cp-line: var(--a-line, #d2d2d7);
  --cp-line-soft: var(--a-line-soft, #e8e8ed);
  --cp-blue: var(--a-blue, #0071e3);
  --cp-blue-hi: var(--a-blue-hi, #0077ed);
  --cp-blue-soft: var(--a-blue-bg, rgba(0, 113, 227, 0.1));
  --cp-ok: var(--a-green, #1d6f42);
  --cp-ok-bg: var(--a-green-bg, rgba(29, 111, 66, 0.1));
  --cp-warn: var(--a-amber, #8a5a00);
  --cp-warn-bg: var(--a-amber-bg, rgba(180, 120, 0, 0.1));
  --cp-bad: var(--a-red, #d70015);
  --cp-bad-bg: var(--a-red-bg, rgba(215, 0, 21, 0.08));
  --cp-violet: var(--a-violet, #5a3fc0);
  --cp-violet-bg: var(--a-violet-bg, rgba(90, 63, 192, 0.1));
  --cp-radius: 18px;
  --cp-shadow: 0 1px 2px var(--a-shadow, rgba(0, 0, 0, 0.06)),
    0 8px 24px var(--a-shadow, rgba(0, 0, 0, 0.08));

  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: var(--cp-text);
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: min(1280px, 100%);
  margin: 0 auto;
  padding-bottom: 1.5rem;
  box-sizing: border-box;
}

.lux-cp__card {
  background: var(--cp-card);
  border: 1px solid var(--cp-line);
  border-radius: var(--cp-radius);
  box-shadow: var(--cp-shadow);
}

/* Lux.pa brand — soft, minimal, screen only */
.lux-cp__brand {
  margin: 0.75rem 0 0.25rem;
  padding: 0.85rem 0.5rem 0.35rem;
  text-align: center;
  background: transparent !important;
  border: 0;
  box-shadow: none;
}

.lux-cp__brand-line {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: #86868b !important;
  -webkit-text-fill-color: #86868b !important;
  font-weight: 400;
}

.lux-cp__brand-name,
.lux-cp__brand-line a {
  color: #0071e3 !important;
  -webkit-text-fill-color: #0071e3 !important;
  font-weight: 600;
  text-decoration: none;
  border-bottom: none;
}

.lux-cp__brand-name:hover,
.lux-cp__brand-line a:hover {
  opacity: 0.8;
  color: #0071e3 !important;
  -webkit-text-fill-color: #0071e3 !important;
}

.lux-cp__brand-cta {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none !important;
  color: #0071e3 !important;
  -webkit-text-fill-color: #0071e3 !important;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none !important;
  box-shadow: none;
  transition: opacity 0.15s ease;
}

.lux-cp__brand-cta:hover {
  opacity: 0.75;
  transform: none;
  background: none !important;
  box-shadow: none;
  color: #0071e3 !important;
  -webkit-text-fill-color: #0071e3 !important;
  text-decoration: underline !important;
}

.lux-cp__brand-cta:active {
  transform: none;
  box-shadow: none;
}

@media print {
  .lux-cp__brand,
  .lux-inv-brand,
  .no-print {
    display: none !important;
  }
}

.lux-cp__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.2rem 1rem;
  flex-wrap: wrap;
}

.lux-cp__identity {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.lux-cp__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--cp-line);
  background: var(--cp-blue-soft);
  color: var(--cp-blue);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}

.lux-cp__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lux-cp__avatar-letter {
  font-size: 1.35rem;
  font-weight: 700;
}

.lux-cp__eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cp-muted);
  letter-spacing: 0.02em;
}

.lux-cp__name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--cp-text);
}

.lux-cp__meta {
  margin: 0.35rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  color: var(--cp-muted);
  font-size: 0.84rem;
}

.lux-cp__tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.lux-cp__logout-form { margin: 0; }

.lux-cp__ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--cp-line);
  background: var(--cp-card);
  color: var(--cp-text);
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}

.lux-cp__ghost:hover { background: var(--cp-inset); }
.lux-cp__ghost--danger { color: var(--cp-bad); border-color: var(--a-red-bd, rgba(215, 0, 21, 0.24)); }
.lux-cp__ghost--danger:hover { background: var(--cp-bad-bg); }

.lux-cp__icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--cp-line);
  background: var(--cp-card);
  color: var(--cp-text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lux-cp__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--cp-bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lux-cp__kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--cp-line);
  border-top: 1px solid var(--cp-line);
  border-radius: 0 0 var(--cp-radius) var(--cp-radius);
  overflow: hidden;
}

@media (min-width: 720px) {
  .lux-cp__kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.lux-cp__kpi {
  background: var(--cp-inset);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.lux-cp__kpi span {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--cp-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lux-cp__kpi strong {
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--cp-text);
}

.lux-cp__kpi strong.is-ok { color: var(--cp-ok); }
.lux-cp__kpi strong.is-warn { color: var(--cp-warn); }
.lux-cp__kpi--money strong { font-variant-numeric: tabular-nums; }

.lux-cp__panel { padding: 0; overflow: hidden; }
.lux-cp__panel--soft { opacity: 0.98; }

/* Collapsible panels (invoices / devices) — closed until customer opens */
.lux-cp__fold {
  display: block;
}
.lux-cp__fold > summary.lux-cp__panel-head {
  list-style: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  border-bottom: 0;
}
.lux-cp__fold > summary.lux-cp__panel-head::-webkit-details-marker { display: none; }
.lux-cp__fold > summary.lux-cp__panel-head::marker { content: ""; }
.lux-cp__fold[open] > summary.lux-cp__panel-head {
  border-bottom: 1px solid var(--cp-line);
}
.lux-cp__fold > summary.lux-cp__panel-head:hover {
  background: var(--cp-inset);
}
.lux-cp__fold > summary.lux-cp__panel-head:focus-visible {
  outline: 2px solid var(--cp-blue);
  outline-offset: -2px;
}

.lux-cp__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--cp-line);
}

.lux-cp__panel-title {
  flex: 1 1 auto;
  min-width: 0;
}

.lux-cp__panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--cp-text);
}

.lux-cp__panel-head p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--cp-muted);
}

/* Unified trailing cluster: [unread?] [count] [chevron] — same place on every fold */
.lux-cp__panel-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  margin-inline-start: auto;
}

.lux-cp__count {
  min-width: 2rem;
  height: 1.85rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: var(--cp-blue-soft);
  color: var(--cp-blue);
  font-size: 0.82rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cp-blue) 14%, transparent);
}

/* Force [hidden] even when display:inline-flex is set (was causing a stray 0) */
.lux-cp__count[hidden],
.lux-cp__panel-meta > [hidden] {
  display: none !important;
}

/* Unread on devices panel — red pill, only when > 0 */
.lux-cp__count--unread {
  background: var(--cp-bad-bg, rgba(215, 0, 21, 0.1));
  color: var(--cp-bad, #d70015);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cp-bad, #d70015) 18%, transparent);
  min-width: 1.65rem;
  height: 1.65rem;
  font-size: 0.72rem;
}

.lux-cp__chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--cp-muted);
  background: var(--cp-inset);
  font-size: 0.72rem;
  transition: transform 0.18s ease, color 0.15s ease, background 0.15s ease;
}
.lux-cp__fold[open] > summary .lux-cp__chev {
  transform: rotate(180deg);
  color: var(--cp-blue);
  background: var(--cp-blue-soft);
}

.lux-cp__empty {
  text-align: center;
  padding: 2.2rem 1rem;
  color: var(--cp-muted);
}

.lux-cp__empty i {
  font-size: 1.5rem;
  margin-bottom: 0.45rem;
  opacity: 0.55;
}

.lux-cp__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lux-cp__list > li + li {
  border-top: 1px solid var(--cp-line);
}

.lux-cp__row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.95rem 1.15rem;
  border: 0;
  background: var(--cp-card);
  color: inherit;
  text-align: start;
  cursor: pointer;
  transition: background 0.12s ease;
}

.lux-cp__row--invoice {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  cursor: default;
  background: var(--cp-card);
}

.lux-cp__row--invoice:hover {
  background: var(--cp-card);
}

.lux-cp__row-hit {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.95rem 1.15rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: start;
  cursor: pointer;
}

.lux-cp__row-hit:hover,
.lux-cp__row-hit:focus {
  background: var(--cp-inset);
  outline: none;
}

.lux-cp__pay {
  flex: 0 0 auto;
  align-self: center;
  margin-inline-end: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0 0.9rem;
  border-radius: 999px;
  background: var(--cp-blue);
  color: #fff !important;
  font-size: 0.82rem;
  font-weight: 750;
  text-decoration: none !important;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.22);
}

.lux-cp__pay:hover {
  background: var(--cp-blue-hi);
  color: #fff !important;
}

.lux-cp__row:hover,
.lux-cp__row:focus {
  background: var(--cp-inset);
  outline: none;
}

.lux-cp__row--invoice:hover {
  background: var(--cp-card);
}

.lux-cp__row-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.lux-cp__row-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--cp-blue-soft);
  color: var(--cp-blue);
  flex: 0 0 auto;
}

.lux-cp__row-ico--dev {
  background: var(--cp-violet-bg);
  color: var(--cp-violet);
}

.lux-cp__row-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.lux-cp__row-text strong {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--cp-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lux-cp__row-text small {
  font-size: 0.78rem;
  color: var(--cp-muted);
}

.lux-cp__row-side {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lux-cp__money {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--cp-text);
  min-width: 5.5rem;
  text-align: end;
}

.lux-cp__pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.lux-cp__pill--ok { background: var(--cp-ok-bg); color: var(--cp-ok); }
.lux-cp__pill--mid { background: var(--cp-warn-bg); color: var(--cp-warn); }
.lux-cp__pill--bad { background: var(--cp-bad-bg); color: var(--cp-bad); }
.lux-cp__pill--info {
  background: var(--cp-blue-soft);
  color: var(--cp-blue);
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lux-cp__cta {
  color: var(--cp-blue);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.lux-cp__dot {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--cp-bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* Notif panel */
.lux-cp .lux-cp__notif,
.lux-cp .lux-rs-notif-panel {
  background: var(--cp-card) !important;
  border: 1px solid var(--cp-line) !important;
  color: var(--cp-text) !important;
  box-shadow: 0 12px 40px var(--a-shadow, rgba(0, 0, 0, 0.14)) !important;
  border-radius: 14px !important;
}

.lux-cp .lux-rs-notif-item {
  background: transparent !important;
  color: var(--cp-text) !important;
}

.lux-cp .lux-rs-notif-item:hover {
  background: var(--cp-inset) !important;
}

.lux-cp .lux-rs-notif-item strong,
.lux-cp .lux-rs-notif-panel-head strong {
  color: var(--cp-text) !important;
}

.lux-cp .lux-rs-notif-item em,
.lux-cp .lux-rs-notif-empty {
  color: var(--cp-muted) !important;
}

/* Modal — theme aware */
body.lux-rs-portal-mode .lux-rs-modal-panel {
  background: var(--a-surface, #fff) !important;
  color: var(--a-text, #1d1d1f) !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  border-radius: 18px !important;
  width: min(960px, 96vw) !important;
  max-width: 960px !important;
}

body.lux-rs-portal-mode .lux-rs-modal-head {
  border-bottom: 1px solid var(--a-line, #e5e5ea) !important;
  color: var(--a-text, #1d1d1f) !important;
  background: var(--a-surface, #fff) !important;
}

body.lux-rs-portal-mode .lux-rs-modal-head h3 {
  color: var(--a-text, #1d1d1f) !important;
}

body.lux-rs-portal-mode .lux-rs-modal-btn,
body.lux-rs-portal-mode .lux-rs-modal-close {
  color: var(--a-text, #1d1d1f) !important;
  border-color: var(--a-line, #e5e5ea) !important;
  background: var(--a-surface-2, #f5f5f7) !important;
}

/* Invoice/detail preview close action — clear, touch-friendly and visible in both themes. */
body.lux-rs-portal-mode .lux-rs-modal-close {
  width: 2.65rem !important; height: 2.65rem !important; min-width: 2.65rem !important;
  padding: 0 !important; display: inline-flex !important; align-items: center !important;
  justify-content: center !important; border: 1px solid #d1d5db !important;
  border-radius: .8rem !important; background: #f3f4f6 !important; color: #111827 !important;
  box-shadow: 0 2px 8px rgba(15,23,42,.10) !important; cursor: pointer !important;
  transition: transform .15s ease, background .15s ease, color .15s ease !important;
}
body.lux-rs-portal-mode .lux-rs-modal-close i { color: inherit !important; -webkit-text-fill-color: inherit !important; font-size: 1rem !important; }
body.lux-rs-portal-mode .lux-rs-modal-close:hover,
body.lux-rs-portal-mode .lux-rs-modal-close:focus-visible {
  background: #fee2e2 !important; border-color: #f87171 !important; color: #b91c1c !important;
  transform: translateY(-1px) !important; outline: 3px solid rgba(239,68,68,.18) !important; outline-offset: 2px !important;
}

body.lux-rs-portal-mode .lux-rs-modal-backdrop {
  background: rgba(15, 23, 42, 0.4) !important;
}

body.lux-rs-portal-mode .lux-rs-modal-body {
  max-height: min(78vh, 820px);
  overflow: auto;
  background: var(--a-bg, #f5f5f7) !important;
  padding: 0.85rem !important;
  color: var(--a-text, #1d1d1f) !important;
}

/* Invoice in modal — isolated iframe (print stays on modal head only) */
body.lux-rs-portal-mode .lux-cp-invoice-frame-wrap {
  background: #f5f5f7;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--a-line, #e5e5ea);
  min-height: min(72vh, 760px);
  margin: 0;
}

body.lux-rs-portal-mode .lux-cp-invoice-frame {
  display: block;
  width: 100%;
  min-height: min(72vh, 760px);
  height: min(72vh, 760px);
  border: 0;
  background: #f5f5f7;
}

body.lux-rs-portal-mode .lux-rs-modal-content:has(.lux-cp-invoice-frame) {
  padding: 0 !important;
  background: transparent !important;
}

body.lux-rs-portal-mode .lux-rs-modal-body:has(.lux-cp-invoice-frame) {
  padding: 0.5rem !important;
  background: var(--a-bg, #f5f5f7) !important;
}

/* Wider modal when showing invoice for better paper margins */
body.lux-rs-portal-mode .lux-rs-modal-panel:has(.lux-cp-invoice-frame) {
  width: min(920px, 97vw) !important;
  max-width: 920px !important;
}

/* Repair detail in modal */
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-card,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-cp-repair,
.lux-cp-print-root .lux-rs-card,
.lux-cp-repair {
  background: var(--a-surface, #fff) !important;
  color: var(--a-text, #1d1d1f) !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  border-radius: 16px !important;
  box-shadow: none !important;
  padding: 0.85rem !important;
  margin: 0 !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-card-head {
  background: transparent !important;
  color: var(--a-text, #1d1d1f) !important;
  border-color: var(--a-line, #e5e5ea) !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content h1,
body.lux-rs-portal-mode .lux-rs-modal-content h2,
body.lux-rs-portal-mode .lux-rs-modal-content h3,
body.lux-rs-portal-mode .lux-rs-modal-content strong,
body.lux-rs-portal-mode .lux-rs-modal-content p,
body.lux-rs-portal-mode .lux-rs-modal-content li,
body.lux-rs-portal-mode .lux-rs-modal-content em {
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
}

/* Do NOT force color on every span — that broke stat icons / pills */
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-muted,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-order-label,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat > div > span,
body.lux-rs-portal-mode .lux-rs-modal-content small {
  color: var(--a-muted, #6e6e73) !important;
  -webkit-text-fill-color: var(--a-muted, #6e6e73) !important;
}

/* ---- Stats tiles: icon + text aligned in one row ---- */
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stats,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-cp-repair__stats {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.55rem !important;
  padding: 0.65rem 0 0.15rem !important;
  background: transparent !important;
  border: 0 !important;
}

@media (min-width: 720px) {
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stats,
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-cp-repair__stats {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.6rem !important;
  padding: 0.7rem 0.75rem !important;
  border-radius: 12px !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  background: var(--a-surface-2, #f5f5f7) !important;
  min-width: 0 !important;
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat > div {
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat strong {
  display: block !important;
  font-size: 0.9rem !important;
  font-weight: 750 !important;
  line-height: 1.25 !important;
  word-break: break-word !important;
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat__icon {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  flex: 0 0 34px !important;
  border-radius: 10px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: color-mix(in srgb, var(--rs-status-color, #0071e3) 12%, #fff) !important;
  border: 1px solid color-mix(in srgb, var(--rs-status-color, #0071e3) 28%, transparent) !important;
  color: var(--rs-status-color, #0071e3) !important;
  -webkit-text-fill-color: var(--rs-status-color, #0071e3) !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat__icon svg {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
  flex-shrink: 0 !important;
  stroke: currentColor !important;
}

/* Sections flat (no floating shadow) */
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-section {
  margin-top: 0.75rem !important;
  padding: 0.85rem !important;
  border-radius: 12px !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  background: var(--a-surface, #fff) !important;
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-section--panic,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-panic-list,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-panic-card {
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-panic-card {
  background: var(--a-surface-2, #f5f5f7) !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  border-radius: 12px !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-section h3 {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 0.4rem !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-h-dot {
  width: 7px !important;
  height: 7px !important;
  border-radius: 50% !important;
  flex: 0 0 auto !important;
  display: inline-block !important;
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-section-count {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 1.4rem !important;
  height: 1.25rem !important;
  padding: 0 0.4rem !important;
  border-radius: 999px !important;
  font-size: 0.7rem !important;
  line-height: 1 !important;
  vertical-align: middle !important;
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-status-pill {
  background: color-mix(in srgb, var(--rs-status-color, #0071e3) 14%, #fff) !important;
  border: 1px solid color-mix(in srgb, var(--rs-status-color, #0071e3) 32%, transparent) !important;
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
  border-radius: 999px !important;
  padding: 0.25rem 0.65rem !important;
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-wa-composer,
body.lux-rs-portal-mode .lux-rs-customer-comment,
body.lux-rs-portal-mode .lux-rs-chat-panel {
  background: var(--a-surface, #fff) !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  border-radius: 12px !important;
  color: var(--a-text, #1d1d1f) !important;
  box-shadow: none !important;
}

/* Flat panic + chat blocks in modal (no floating shadow) */
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-section--panic,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-section--chat,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im-section,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-panel,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im-panel {
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-rs-pin-form label,
body.lux-rs-portal-mode .lux-rs-pin-field label {
  color: var(--a-text, #1d1d1f) !important;
}

body.lux-rs-portal-mode .lux-rs-pin-form input {
  background: var(--a-surface-2, #f5f5f7) !important;
  color: var(--a-text, #1d1d1f) !important;
  border: 1px solid var(--a-line, #d2d2d7) !important;
}

/* Large screens */
@media (min-width: 900px) {
  .lux-cp__row-hit {
    padding: 1.05rem 1.35rem;
    gap: 1.25rem;
  }
  .lux-cp__row-text strong { font-size: 1rem; }
  .lux-cp__row-side { min-width: 0; gap: 0.85rem; flex: 0 1 auto; }
  .lux-cp__money { min-width: 6rem; }
  .lux-cp__header { padding: 1.25rem 1.4rem 1.1rem; }
  .lux-cp__panel-head { padding: 1.1rem 1.35rem 0.95rem; }
  /* Desktop invoice: hit content + pay side by side */
  .lux-cp__row--invoice {
    flex-direction: row;
    align-items: center;
  }
  .lux-cp__row--invoice .lux-cp__row-hit {
    flex: 1 1 auto;
    min-width: 0;
  }
  .lux-cp__row--invoice .lux-cp__pay {
    flex: 0 0 auto;
    margin-inline: 0 1rem;
  }
}

/* Mobile — invoice cards (no wide “table”, pay full-width at bottom) */
@media (max-width: 640px) {
  .lux-cp__list {
    overflow: hidden;
    width: 100%;
  }

  .lux-cp__list > li {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .lux-cp__row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.9rem 1rem;
    max-width: 100%;
  }

  /* Invoice item = compact vertical card */
  .lux-cp__row--invoice {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .lux-cp__row--invoice .lux-cp__row-hit {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    width: 100%;
    max-width: 100%;
    padding: 0.85rem 0.9rem 0.5rem;
    box-sizing: border-box;
  }

  .lux-cp__row--invoice .lux-cp__row-main {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }

  .lux-cp__row--invoice .lux-cp__row-text {
    min-width: 0;
    flex: 1 1 auto;
  }

  .lux-cp__row--invoice .lux-cp__row-text strong {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
    line-height: 1.25;
  }

  /* Status + amount on one tidy row under the title */
  .lux-cp__row--invoice .lux-cp__row-side {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem 0.65rem;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-top: 0.15rem;
  }

  .lux-cp__row--invoice .lux-cp__money {
    text-align: end;
    min-width: 0;
    margin-inline-start: auto;
    font-size: 0.95rem;
  }

  .lux-cp__row--invoice .lux-cp__pill {
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Hide “View” label on phone — whole row is tappable */
  .lux-cp__row--invoice .lux-cp__cta {
    display: none;
  }

  /* Pay button: full width under the card content, never floating in the middle */
  .lux-cp__row--invoice .lux-cp__pay {
    display: flex;
    width: calc(100% - 1.8rem);
    max-width: calc(100% - 1.8rem);
    margin: 0.15rem 0.9rem 0.85rem;
    align-self: stretch;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    box-sizing: border-box;
    flex: 0 0 auto;
  }

  /* Device rows stay simple single column */
  .lux-cp__row:not(.lux-cp__row--invoice) {
    flex-direction: column;
    align-items: stretch;
  }

  .lux-cp__row:not(.lux-cp__row--invoice) .lux-cp__row-side {
    justify-content: space-between;
    width: 100%;
    min-width: 0;
  }

  .lux-cp__money { text-align: start; min-width: 0; }
  .lux-cp__header { padding: 1rem; }
  .lux-cp__tools { width: 100%; }
  .lux-cp__ghost { flex: 1; justify-content: center; }
  .lux-cp__kpis { grid-template-columns: 1fr 1fr; }
  .lux-cp__kpi--money { grid-column: 1 / -1; }
}

@media (max-width: 380px) {
  .lux-cp__name { font-size: 1.15rem; }
  .lux-cp__pill { font-size: 0.68rem; }
  .lux-cp__cta { display: none; }

  .lux-cp__row--invoice .lux-cp__row-ico {
    width: 34px;
    height: 34px;
  }

  .lux-cp__row--invoice .lux-cp__pay {
    width: calc(100% - 1.5rem);
    max-width: calc(100% - 1.5rem);
    margin-inline: 0.75rem;
  }
}

/* ===== Instant Messenger chat (Comentarios y actualizaciones) ===== */
body.lux-rs-portal-mode .lux-im-section {
  margin-top: 1rem !important;
  padding: 0 !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  border-radius: 18px !important;
  background: var(--a-surface, #fff) !important;
  overflow: hidden;
}

body.lux-rs-portal-mode .lux-im-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--a-line, #e5e5ea);
  background: linear-gradient(180deg, var(--a-surface-2, #f5f5f7) 0%, var(--a-surface, #fff) 100%);
}

body.lux-rs-portal-mode .lux-im-section__title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

body.lux-rs-portal-mode .lux-im-section__ico {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--a-blue-bg, rgba(0, 113, 227, 0.1));
  color: var(--a-blue, #0071e3);
  flex: 0 0 auto;
}

body.lux-rs-portal-mode .lux-im-section__h {
  margin: 0 !important;
  font-size: 0.98rem !important;
  font-weight: 750 !important;
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
}

body.lux-rs-portal-mode .lux-im-section__sub {
  margin: 0.12rem 0 0;
  font-size: 0.75rem;
  color: var(--a-muted, #6e6e73) !important;
  -webkit-text-fill-color: var(--a-muted, #6e6e73) !important;
}

body.lux-rs-portal-mode .lux-im-section__live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--a-green, #1d6f42);
  background: var(--a-green-bg, rgba(29, 111, 66, 0.1));
  border: 1px solid var(--a-green-bd, rgba(29, 111, 66, 0.22));
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  white-space: nowrap;
}

body.lux-rs-portal-mode .lux-im-section__live .fa-circle {
  font-size: 0.45rem;
  color: #30d158;
  animation: lux-im-pulse 1.6s ease-in-out infinite;
}

@keyframes lux-im-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

body.lux-rs-portal-mode .lux-im-panel,
body.lux-rs-portal-mode .lux-rs-chat-panel {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  min-height: 320px;
  max-height: min(52vh, 480px);
}

body.lux-rs-portal-mode .lux-im,
body.lux-rs-portal-mode #lux_rs_chat_feed.lux-im {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(1200px 400px at 10% -10%, color-mix(in srgb, var(--a-blue, #0071e3) 8%, transparent), transparent 55%),
    var(--a-surface-2, #f5f5f7);
}

body.lux-rs-portal-mode .lux-im__feed {
  flex: 1;
  min-height: 220px;
  max-height: min(42vh, 400px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.9rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Messages — tight WhatsApp-style bubbles (no huge empty width) */
body.lux-rs-portal-mode .lux-im__row,
body.lux-rs-portal-mode .lux-rs-chat-row {
  display: flex !important;
  align-items: flex-end !important;
  gap: 0.45rem !important;
  width: fit-content !important;
  max-width: min(78%, 22rem) !important;
  animation: lux-im-in 0.22s ease both;
  /* kill legacy full-width chat rows */
  margin-left: 0 !important;
  margin-right: 0 !important;
}

@keyframes lux-im-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

body.lux-rs-portal-mode .lux-im__row--them,
body.lux-rs-portal-mode .lux-rs-chat-row.is-them {
  align-self: flex-start !important;
  margin-inline-end: auto !important;
}

body.lux-rs-portal-mode .lux-im__row--me,
body.lux-rs-portal-mode .lux-rs-chat-row.is-me {
  align-self: flex-end !important;
  flex-direction: row-reverse !important;
  margin-inline-start: auto !important;
}

body.lux-rs-portal-mode .lux-im__col {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.15rem !important;
  width: fit-content !important;
  max-width: 100% !important;
  min-width: 0 !important;
  flex: 0 1 auto !important;
}

body.lux-rs-portal-mode .lux-im__row--me .lux-im__col { align-items: flex-end !important; }
body.lux-rs-portal-mode .lux-im__row--them .lux-im__col { align-items: flex-start !important; }

body.lux-rs-portal-mode .lux-im__av,
body.lux-rs-portal-mode .lux-rs-chat-av {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  border-radius: 50% !important;
  display: grid !important;
  place-items: center !important;
  font-size: 0.75rem !important;
  font-weight: 750 !important;
  flex: 0 0 32px !important;
  background: var(--a-surface, #fff) !important;
  color: var(--a-blue, #0071e3) !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  overflow: hidden !important;
  box-shadow: 0 2px 8px var(--a-shadow, rgba(0,0,0,0.08));
}

body.lux-rs-portal-mode .lux-im__av--me,
body.lux-rs-portal-mode .lux-rs-chat-av.is-me {
  background: var(--a-blue, #0071e3) !important;
  color: #fff !important;
  border-color: transparent !important;
}

body.lux-rs-portal-mode .lux-im__av--img img,
body.lux-rs-portal-mode .lux-rs-chat-av--img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body.lux-rs-portal-mode .lux-im__bubble,
body.lux-rs-portal-mode .lux-rs-chat-bubble {
  position: relative !important;
  display: inline-block !important;
  width: fit-content !important;
  max-width: min(18.5rem, 72vw) !important;
  min-width: 0 !important;
  padding: 0.45rem 0.7rem 0.4rem !important;
  border-radius: 16px !important;
  box-shadow: 0 1px 2px var(--a-shadow, rgba(0,0,0,0.06));
  border: 1px solid transparent !important;
  /* prevent stretched full-width bubbles from legacy CSS */
  flex: 0 1 auto !important;
}

/* Technician / shop bubbles — status color + auto contrast text */
body.lux-rs-portal-mode .lux-im__bubble--them,
body.lux-rs-portal-mode .lux-rs-chat-bubble.is-them,
body.lux-rs-portal-mode .lux-cp-repair .lux-im__bubble--them,
body.lux-rs-portal-mode .lux-cp-repair .lux-rs-chat-bubble.is-them,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them {
  background: var(
    --rs-tech-bubble-bg,
    color-mix(in srgb, var(--rs-status-color, #f5c518) 26%, #ffffff)
  ) !important;
  border-color: var(
    --rs-tech-bubble-bd,
    color-mix(in srgb, var(--rs-status-color, #f5c518) 40%, transparent)
  ) !important;
  border-bottom-left-radius: 5px !important;
  color: var(--rs-tech-bubble-fg, #1d1d1f) !important;
  -webkit-text-fill-color: var(--rs-tech-bubble-fg, #1d1d1f) !important;
  box-shadow: none !important;
}

/* Name + body text inherit contrast ink (beat modal global text rules) */
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them .lux-im__name,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them .lux-im__text,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them .lux-rs-chat-name,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them .lux-rs-chat-text,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them strong,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them p,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them span,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them em,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them .lux-im__name,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them .lux-im__text,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them .lux-rs-chat-name,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them .lux-rs-chat-text,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them strong,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them p,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them span,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them em {
  color: var(--rs-tech-bubble-fg, #1d1d1f) !important;
  -webkit-text-fill-color: var(--rs-tech-bubble-fg, #1d1d1f) !important;
}

body.lux-rs-portal-mode .lux-im__bubble--me,
body.lux-rs-portal-mode .lux-rs-chat-bubble.is-me {
  background: linear-gradient(145deg, var(--a-blue-hi, #0077ed), var(--a-blue, #0071e3)) !important;
  color: #fff !important;
  border-bottom-right-radius: 5px !important;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.22);
}

/* Name only on shop/technician side; keep bubble compact for “me” */
body.lux-rs-portal-mode .lux-im__name,
body.lux-rs-portal-mode .lux-rs-chat-name {
  display: block;
  font-size: 0.68rem !important;
  font-weight: 750 !important;
  margin: 0 0 0.12rem !important;
  line-height: 1.2 !important;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.78;
  color: inherit !important;
  -webkit-text-fill-color: currentColor !important;
}

body.lux-rs-portal-mode .lux-im__bubble--me .lux-im__name,
body.lux-rs-portal-mode .lux-rs-chat-bubble.is-me .lux-rs-chat-name {
  display: none !important; /* WhatsApp-style: no name on own bubbles */
}

body.lux-rs-portal-mode .lux-im__text,
body.lux-rs-portal-mode .lux-rs-chat-text {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.9rem !important;
  line-height: 1.35 !important;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: inherit !important;
  -webkit-text-fill-color: currentColor !important;
  display: inline !important;
}

/* Time inside bubble (tight, WhatsApp-like) */
body.lux-rs-portal-mode .lux-im__meta--in,
body.lux-rs-portal-mode .lux-im__bubble .lux-im__meta,
body.lux-rs-portal-mode .lux-rs-chat-bubble .lux-rs-chat-meta {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.2rem !important;
  float: inline-end !important;
  margin: 0.25rem 0 0 0.55rem !important;
  font-size: 0.62rem !important;
  line-height: 1 !important;
  opacity: 0.78;
  width: auto !important;
  max-width: none !important;
  padding: 0 !important;
  position: relative !important;
  top: 0.15rem;
}

body.lux-rs-portal-mode .lux-im__bubble--them .lux-im__meta--in,
body.lux-rs-portal-mode .lux-rs-chat-bubble.is-them .lux-rs-chat-meta,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them .lux-im__meta--in,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-im__bubble--them time,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them .lux-rs-chat-meta,
body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-chat-bubble.is-them time {
  color: var(--rs-tech-bubble-meta, var(--a-muted, #6e6e73)) !important;
  -webkit-text-fill-color: var(--rs-tech-bubble-meta, var(--a-muted, #6e6e73)) !important;
}

body.lux-rs-portal-mode .lux-im__bubble--me .lux-im__meta--in,
body.lux-rs-portal-mode .lux-rs-chat-bubble.is-me .lux-rs-chat-meta {
  color: rgba(255, 255, 255, 0.85) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.85) !important;
}

body.lux-rs-portal-mode .lux-im__ticks {
  display: inline-flex;
  letter-spacing: -0.2em;
  color: inherit;
  font-size: 0.55rem;
  opacity: 0.95;
}

/* Clear float so bubble height wraps short text correctly */
body.lux-rs-portal-mode .lux-im__bubble::after,
body.lux-rs-portal-mode .lux-rs-chat-bubble::after {
  content: "";
  display: table;
  clear: both;
}

/* Kill legacy full-width chat rules that stretch bubbles */
body.lux-rs-portal-mode .lux-rs-chat-row,
body.lux-rs-portal-mode .lux-rs-chat--pro .lux-rs-chat-row {
  width: fit-content !important;
  max-width: min(78%, 22rem) !important;
}

body.lux-rs-portal-mode .lux-rs-chat-bubble,
body.lux-rs-portal-mode .lux-rs-chat--pro .lux-rs-chat-bubble {
  width: fit-content !important;
  max-width: min(18.5rem, 72vw) !important;
}

body.lux-rs-portal-mode .lux-im__sys {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0;
}

body.lux-rs-portal-mode .lux-im__sys-pill,
body.lux-rs-portal-mode .lux-rs-chat-sys-pill {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.4rem;
  max-width: min(100%, 28rem);
  padding: 0.4rem 0.7rem !important;
  border-radius: 999px !important;
  background: var(--a-surface, #fff) !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  color: var(--a-text-2, #3a3a3c) !important;
  -webkit-text-fill-color: var(--a-text-2, #3a3a3c) !important;
  font-size: 0.74rem !important;
  font-weight: 650 !important;
  box-shadow: 0 1px 2px var(--a-shadow, rgba(0,0,0,0.05));
}

body.lux-rs-portal-mode .lux-im__sys-pill i {
  color: var(--a-violet, #5a3fc0);
}

body.lux-rs-portal-mode .lux-im__sys-pill time {
  opacity: 0.75;
  font-weight: 600;
}

body.lux-rs-portal-mode .lux-im__empty {
  margin: auto;
  text-align: center;
  padding: 1.75rem 1rem;
  color: var(--a-muted, #6e6e73);
  max-width: 18rem;
}

body.lux-rs-portal-mode .lux-im__empty-ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.7rem;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--a-blue-bg, rgba(0, 113, 227, 0.1));
  color: var(--a-blue, #0071e3);
  font-size: 1.25rem;
}

body.lux-rs-portal-mode .lux-im__empty strong {
  display: block;
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

body.lux-rs-portal-mode .lux-im__empty p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--a-muted, #6e6e73) !important;
  -webkit-text-fill-color: var(--a-muted, #6e6e73) !important;
}

/* Composer */
body.lux-rs-portal-mode .lux-im-composer,
body.lux-rs-portal-mode .lux-rs-wa-composer {
  border-top: 1px solid var(--a-line, #e5e5ea) !important;
  background: var(--a-surface, #fff) !important;
  padding: 0.7rem 0.75rem 0.8rem !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.lux-rs-portal-mode .lux-im-composer__bar,
body.lux-rs-portal-mode .lux-rs-wa-bar {
  display: flex !important;
  align-items: flex-end !important;
  gap: 0.5rem !important;
}

body.lux-rs-portal-mode .lux-im-composer__av,
body.lux-rs-portal-mode .lux-rs-wa-av {
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  flex: 0 0 auto !important;
  display: grid !important;
  place-items: center !important;
  background: var(--a-blue-bg, rgba(0, 113, 227, 0.1)) !important;
  color: var(--a-blue, #0071e3) !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  font-weight: 750;
  font-size: 0.78rem;
}

body.lux-rs-portal-mode .lux-im-composer__av img,
body.lux-rs-portal-mode .lux-rs-wa-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.lux-rs-portal-mode .lux-im-composer__field {
  flex: 1;
  min-width: 0;
}

body.lux-rs-portal-mode .lux-im-composer__input,
body.lux-rs-portal-mode .lux-rs-wa-input {
  width: 100% !important;
  min-height: 42px !important;
  max-height: 110px !important;
  resize: none !important;
  border-radius: 18px !important;
  border: 1px solid var(--a-line, #d2d2d7) !important;
  background: var(--a-surface-2, #f5f5f7) !important;
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
  padding: 0.65rem 0.9rem !important;
  font-size: 0.92rem !important;
  line-height: 1.35 !important;
  outline: none !important;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

body.lux-rs-portal-mode .lux-im-composer__input:focus,
body.lux-rs-portal-mode .lux-rs-wa-input:focus {
  border-color: var(--a-blue, #0071e3) !important;
  background: var(--a-surface, #fff) !important;
  box-shadow: 0 0 0 3px var(--a-blue-bg, rgba(0, 113, 227, 0.15));
}

body.lux-rs-portal-mode .lux-im-composer__input::placeholder,
body.lux-rs-portal-mode .lux-rs-wa-input::placeholder {
  color: var(--a-faint, #86868b) !important;
  -webkit-text-fill-color: var(--a-faint, #86868b) !important;
}

body.lux-rs-portal-mode .lux-im-composer__send,
body.lux-rs-portal-mode .lux-rs-wa-send {
  width: 42px !important;
  height: 42px !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: linear-gradient(145deg, var(--a-blue-hi, #0077ed), var(--a-blue, #0071e3)) !important;
  color: #fff !important;
  display: grid !important;
  place-items: center !important;
  cursor: pointer !important;
  flex: 0 0 auto !important;
  box-shadow: 0 6px 14px rgba(0, 113, 227, 0.3);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

body.lux-rs-portal-mode .lux-im-composer__send:hover,
body.lux-rs-portal-mode .lux-rs-wa-send:hover {
  transform: scale(1.04);
}

body.lux-rs-portal-mode .lux-im-composer__send:disabled,
body.lux-rs-portal-mode .lux-rs-wa-send:disabled {
  opacity: 0.55;
  transform: none;
}

body.lux-rs-portal-mode .lux-im-composer__msg,
body.lux-rs-portal-mode .lux-rs-customer-comment-msg {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  font-weight: 650;
}

body.lux-rs-portal-mode .lux-rs-customer-comment-msg.is-ok { color: var(--a-green, #1d6f42) !important; }
body.lux-rs-portal-mode .lux-rs-customer-comment-msg.is-err { color: var(--a-red, #d70015) !important; }

/* Hide old decorative dots in chat title when present */
body.lux-rs-portal-mode .lux-im-section .lux-rs-h-dot { display: none !important; }

@media (max-width: 640px) {
  body.lux-rs-portal-mode .lux-im-panel,
  body.lux-rs-portal-mode .lux-rs-chat-panel {
    max-height: min(58vh, 520px);
  }
  body.lux-rs-portal-mode .lux-im__feed {
    max-height: min(46vh, 420px);
    padding: 0.85rem 0.7rem 0.6rem;
  }
  body.lux-rs-portal-mode .lux-im__row {
    max-width: 94%;
  }
}

/* ===== Change PIN modal (Cambiar contraseña) ===== */
body.lux-rs-portal-mode .lux-cp-pin-modal .lux-cp-pin-modal__panel,
body.lux-rs-portal-mode #lux_portal_pin_modal .lux-cp-pin-modal__panel {
  width: min(420px, 94vw) !important;
  max-width: 420px !important;
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 22px !important;
  border: 1px solid var(--a-line, #e5e5ea) !important;
  background: var(--a-surface, #fff) !important;
  box-shadow: 0 24px 64px var(--a-shadow, rgba(0, 0, 0, 0.18)) !important;
}

body.lux-rs-portal-mode .lux-cp-pin-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.15rem 1.15rem 0.9rem;
  border-bottom: 1px solid var(--a-line, #e5e5ea);
  background:
    radial-gradient(500px 120px at 0% 0%, color-mix(in srgb, var(--a-blue, #0071e3) 12%, transparent), transparent 60%),
    var(--a-surface, #fff);
}

body.lux-rs-portal-mode .lux-cp-pin-modal__brand {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
}

body.lux-rs-portal-mode .lux-cp-pin-modal__ico {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--a-blue-bg, rgba(0, 113, 227, 0.12));
  color: var(--a-blue, #0071e3);
  font-size: 1.1rem;
  border: 1px solid var(--a-blue-bd, rgba(0, 113, 227, 0.22));
}

body.lux-rs-portal-mode .lux-cp-pin-modal__head h3 {
  margin: 0 !important;
  font-size: 1.1rem !important;
  font-weight: 780 !important;
  letter-spacing: -0.02em;
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
}

body.lux-rs-portal-mode .lux-cp-pin-modal__lead {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--a-muted, #6e6e73) !important;
  -webkit-text-fill-color: var(--a-muted, #6e6e73) !important;
}

body.lux-rs-portal-mode .lux-cp-pin-modal__close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--a-line, #e5e5ea);
  background: var(--a-surface-2, #f5f5f7);
  color: var(--a-text, #1d1d1f);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

body.lux-rs-portal-mode .lux-cp-pin-modal__close:hover {
  background: var(--a-line-soft, #e8e8ed);
}

body.lux-rs-portal-mode .lux-cp-pin-modal__body {
  padding: 1.1rem 1.15rem 1.2rem !important;
  background: var(--a-surface, #fff) !important;
  max-height: none !important;
  overflow: visible !important;
}

body.lux-rs-portal-mode .lux-cp-pin-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

body.lux-rs-portal-mode .lux-cp-pin-field label,
body.lux-rs-portal-mode .lux-cp-pin-form .lux-rs-pin-field label {
  display: block;
  margin: 0 0 0.4rem !important;
  font-size: 0.78rem !important;
  font-weight: 700 !important;
  color: var(--a-text-2, #3a3a3c) !important;
  -webkit-text-fill-color: var(--a-text-2, #3a3a3c) !important;
  letter-spacing: 0.01em;
}

body.lux-rs-portal-mode .lux-cp-pin-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

body.lux-rs-portal-mode .lux-cp-pin-input-wrap > i {
  position: absolute;
  inset-inline-start: 0.85rem;
  color: var(--a-muted, #6e6e73);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 1;
}

body.lux-rs-portal-mode .lux-cp-pin-input-wrap input,
body.lux-rs-portal-mode .lux-cp-pin-form input {
  width: 100% !important;
  min-height: 48px !important;
  border-radius: 14px !important;
  border: 1.5px solid var(--a-line, #d2d2d7) !important;
  background: var(--a-surface-2, #f5f5f7) !important;
  color: var(--a-text, #1d1d1f) !important;
  -webkit-text-fill-color: var(--a-text, #1d1d1f) !important;
  padding: 0.7rem 0.9rem 0.7rem 2.5rem !important;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.18em !important;
  outline: none !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

html[dir="rtl"] body.lux-rs-portal-mode .lux-cp-pin-input-wrap input,
html[dir="rtl"] body.lux-rs-portal-mode .lux-cp-pin-form input {
  padding: 0.7rem 2.5rem 0.7rem 0.9rem !important;
}

body.lux-rs-portal-mode .lux-cp-pin-input-wrap input::placeholder {
  color: var(--a-faint, #86868b) !important;
  -webkit-text-fill-color: var(--a-faint, #86868b) !important;
  letter-spacing: 0.28em;
  font-weight: 600;
}

body.lux-rs-portal-mode .lux-cp-pin-input-wrap input:focus,
body.lux-rs-portal-mode .lux-cp-pin-form input:focus {
  border-color: var(--a-blue, #0071e3) !important;
  background: var(--a-surface, #fff) !important;
  box-shadow: 0 0 0 4px var(--a-blue-bg, rgba(0, 113, 227, 0.14)) !important;
}

body.lux-rs-portal-mode .lux-cp-pin-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--a-muted, #6e6e73);
}

body.lux-rs-portal-mode .lux-cp-pin-msg,
body.lux-rs-portal-mode .lux-rs-pin-msg {
  margin: 0.1rem 0 0 !important;
  padding: 0.55rem 0.7rem !important;
  border-radius: 12px !important;
  font-size: 0.8rem !important;
  font-weight: 650 !important;
  line-height: 1.35 !important;
}

body.lux-rs-portal-mode .lux-cp-pin-msg.is-ok,
body.lux-rs-portal-mode .lux-rs-pin-msg.is-ok {
  background: var(--a-green-bg, rgba(29, 111, 66, 0.1)) !important;
  color: var(--a-green, #1d6f42) !important;
  border: 1px solid var(--a-green-bd, rgba(29, 111, 66, 0.22));
}

body.lux-rs-portal-mode .lux-cp-pin-msg.is-err,
body.lux-rs-portal-mode .lux-rs-pin-msg.is-err {
  background: var(--a-red-bg, rgba(215, 0, 21, 0.08)) !important;
  color: var(--a-red, #d70015) !important;
  border: 1px solid var(--a-red-bd, rgba(215, 0, 21, 0.22));
}

body.lux-rs-portal-mode .lux-cp-pin-submit,
body.lux-rs-portal-mode #lux_portal_pin_submit {
  margin-top: 0.25rem;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: linear-gradient(145deg, var(--a-blue-hi, #0077ed), var(--a-blue, #0071e3));
  color: #fff !important;
  font-size: 0.95rem;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.28);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

body.lux-rs-portal-mode .lux-cp-pin-submit:hover {
  transform: translateY(-1px);
}

body.lux-rs-portal-mode .lux-cp-pin-submit:disabled {
  opacity: 0.6;
  transform: none;
  cursor: wait;
}

/* Hide default modal head styles when using custom pin head */
body.lux-rs-portal-mode #lux_portal_pin_modal .lux-rs-modal-head {
  display: none !important;
}

/* ============================================================
   Portal responsive system — phone → tablet → desktop → wide
   ============================================================ */

/* Base: never allow horizontal scroll from portal chrome */
html:has(body.lux-rs-portal-mode),
body.lux-rs-portal-mode {
  overflow-x: clip;
  max-width: 100vw;
}

body.lux-rs-portal-mode .lux-cp,
body.lux-rs-portal-mode .lux-rs-page,
body.lux-rs-portal-mode .lux-rs-results--portal,
body.lux-rs-portal-mode .ldx-wrap {
  max-width: 100%;
  box-sizing: border-box;
}

body.lux-rs-portal-mode .lux-cp *,
body.lux-rs-portal-mode .lux-rs-modal * {
  box-sizing: border-box;
}

body.lux-rs-portal-mode .lux-cp__card {
  border-radius: max(14px, var(--cp-radius));
  border-color: color-mix(in oklab, var(--cp-line) 72%, transparent);
  box-shadow: 0 10px 30px color-mix(in oklab, var(--a-shadow, rgba(15, 23, 42, 0.16)) 18%, transparent);
}

body.lux-rs-portal-mode .lux-cp__kpi strong {
  line-height: 1.25;
}

/* Readable text truncation helpers */
body.lux-rs-portal-mode .lux-cp__name,
body.lux-rs-portal-mode .lux-cp__row-text strong,
body.lux-rs-portal-mode .lux-cp__panel-title h2 {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Touch-friendly controls (iOS 44px target) */
body.lux-rs-portal-mode .lux-cp__ghost,
body.lux-rs-portal-mode .lux-cp__pay,
body.lux-rs-portal-mode .lux-cp__row,
body.lux-rs-portal-mode .lux-cp__row-hit,
body.lux-rs-portal-mode .lux-rs-modal-btn,
body.lux-rs-portal-mode .lux-rs-modal-close,
body.lux-rs-portal-mode .lux-cp__icon-btn {
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body.lux-rs-portal-mode .lux-cp__icon-btn {
  width: 44px;
  height: 44px;
}

/* Avoid iOS zoom on inputs */
body.lux-rs-portal-mode input,
body.lux-rs-portal-mode select,
body.lux-rs-portal-mode textarea {
  font-size: 16px !important;
  max-width: 100%;
}

/* ---- Extra small phones ---- */
@media (max-width: 380px) {
  body.lux-rs-portal-mode .ldx-wrap {
    padding-inline: max(0.55rem, env(safe-area-inset-left, 0px))
      max(0.55rem, env(safe-area-inset-right, 0px)) !important;
  }

  .lux-cp {
    gap: 10px;
    --cp-radius: 14px;
  }

  .lux-cp__header {
    padding: 0.85rem !important;
    gap: 0.75rem;
  }

  .lux-cp__avatar {
    width: 48px;
    height: 48px;
  }

  .lux-cp__name {
    font-size: 1.1rem;
  }

  .lux-cp__meta {
    font-size: 0.78rem;
    gap: 0.25rem 0.5rem;
  }

  .lux-cp__kpis {
    grid-template-columns: 1fr 1fr;
  }

  .lux-cp__kpi {
    padding: 0.7rem 0.75rem;
    gap: 0.15rem;
  }

  .lux-cp__panel-head {
    padding: 0.85rem 0.9rem !important;
    gap: 0.5rem;
  }

  .lux-cp__panel-title h2 {
    font-size: 0.98rem;
  }

  .lux-cp__panel-title p {
    font-size: 0.72rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .lux-cp__row-ico {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .lux-cp__row-main {
    min-width: 0;
    align-items: flex-start;
  }

  .lux-cp__row-text {
    min-width: 0;
  }

  .lux-cp__cta {
    display: none;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stats,
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-cp-repair__stats {
    grid-template-columns: 1fr !important;
  }
}

/* ---- Phones (default mobile polish) ---- */
@media (max-width: 640px) {
  body.lux-rs-portal-mode .ldx-wrap {
    padding-top: max(0.6rem, env(safe-area-inset-top, 0px)) !important;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px) + 1rem) !important;
  }

  .lux-cp {
    gap: 12px;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  }

  .lux-cp__card {
    border-radius: 16px;
  }

  /* Header: identity full width, tools as action bar */
  .lux-cp__header {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem !important;
  }

  .lux-cp__identity {
    width: 100%;
  }

  .lux-cp__tools {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 0.45rem;
  }

  .lux-cp__tools .lux-rs-notif-wrap {
    justify-self: start;
  }

  .lux-cp__tools .lux-cp__ghost,
  .lux-cp__tools .lux-cp__logout-form {
    width: 100%;
  }

  .lux-cp__tools .lux-cp__logout-form .lux-cp__ghost {
    width: 100%;
  }

  .lux-cp__ghost {
    justify-content: center;
    font-size: 0.78rem;
    padding-inline: 0.55rem;
  }

  /* Fold headers: title + meta always one row */
  .lux-cp__panel-head {
    align-items: center !important;
    gap: 0.55rem !important;
  }

  .lux-cp__panel-title p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .lux-cp__panel-meta {
    gap: 0.3rem;
  }

  /* Invoice / device rows */
  .lux-cp__row-main {
    gap: 0.6rem;
    align-items: flex-start;
  }

  .lux-cp__row-side {
    flex-wrap: wrap;
    gap: 0.4rem !important;
    width: 100%;
    justify-content: flex-end;
    row-gap: 0.3rem !important;
  }

  .lux-cp__row--invoice {
    align-items: stretch;
  }

  .lux-cp__row--invoice .lux-cp__row-hit {
    padding: 0.8rem 0.72rem;
    width: 100%;
    justify-content: space-between;
  }

  .lux-cp__row--invoice .lux-cp__row-side {
    justify-content: flex-end;
    margin-inline-start: 0.5rem;
    min-width: 0;
  }

  .lux-cp__money {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 0;
  }

  .lux-cp__row--invoice .lux-cp__money {
    margin-inline-start: auto;
  }

  body.lux-rs-portal-mode .lux-cp__pay {
    width: 100%;
    margin-inline-end: 0;
    margin-inline-start: 0.4rem;
    justify-content: center;
    min-height: 42px;
  }

  body.lux-rs-portal-mode .lux-cp__row-text strong {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  /* Modal → near full-screen sheet on phone (NOT the PIN dialog) */
  body.lux-rs-portal-mode .lux-rs-modal:not(.lux-cp-pin-modal):not(#lux_portal_pin_modal) > .lux-rs-modal-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(96dvh, 100%) !important;
    height: auto !important;
    border-radius: 18px 18px 0 0 !important;
    margin: 0 !important;
    align-self: flex-end;
  }

  body.lux-rs-portal-mode .lux-rs-modal:not([hidden]):not(.lux-cp-pin-modal):not(#lux_portal_pin_modal) {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-head {
    padding: 0.85rem 0.9rem !important;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 2;
  }

  body.lux-rs-portal-mode .lux-rs-modal-head h3 {
    font-size: 0.95rem !important;
    line-height: 1.25 !important;
    max-width: calc(100% - 7rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.lux-rs-portal-mode .lux-rs-modal-body {
    max-height: min(82dvh, 820px) !important;
    padding: 0.55rem !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-panel:has(.lux-cp-invoice-frame),
  body.lux-rs-portal-mode .lux-rs-modal-panel:has(.lux-cp-repair) {
    width: 100% !important;
    max-width: 100% !important;
  }

  body.lux-rs-portal-mode .lux-cp-invoice-frame-wrap,
  body.lux-rs-portal-mode .lux-cp-invoice-frame {
    min-height: min(70dvh, 640px) !important;
    height: min(70dvh, 640px) !important;
  }

  /* Repair detail inside modal */
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-cp-repair,
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-card {
    padding: 0.7rem !important;
    border-radius: 14px !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stats,
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-cp-repair__stats {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.45rem !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat {
    padding: 0.6rem 0.65rem !important;
    gap: 0.45rem !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stat__icon {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    flex-basis: 30px !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-section {
    padding: 0.7rem !important;
    margin-top: 0.55rem !important;
  }

  /* Chat on phone */
  body.lux-rs-portal-mode .lux-im-section__head {
    padding: 0.75rem 0.8rem 0.55rem !important;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  body.lux-rs-portal-mode .lux-im__bubble,
  body.lux-rs-portal-mode .lux-rs-chat-bubble {
    max-width: min(17.5rem, 82vw) !important;
  }

  body.lux-rs-portal-mode .lux-im-panel,
  body.lux-rs-portal-mode .lux-rs-chat-panel {
    max-height: min(55dvh, 480px) !important;
    min-height: 280px;
  }

  body.lux-rs-portal-mode .lux-im__feed {
    max-height: min(42dvh, 380px) !important;
  }

  /* Notif panel stays within viewport */
  body.lux-rs-portal-mode .lux-rs-notif-panel,
  body.lux-rs-portal-mode .lux-cp__notif {
    width: min(92vw, 360px) !important;
    max-width: calc(100vw - 1.25rem) !important;
    right: 0 !important;
    left: auto !important;
  }

  html[dir="rtl"] body.lux-rs-portal-mode .lux-rs-notif-panel,
  html[dir="rtl"] body.lux-rs-portal-mode .lux-cp__notif {
    left: 0 !important;
    right: auto !important;
  }
}

/* ---- Tablets ---- */
@media (min-width: 641px) and (max-width: 1023px) {
  body.lux-rs-portal-mode .lux-rs-page,
  body.lux-rs-portal-mode .lux-cp {
    max-width: min(920px, 100%) !important;
  }

  .lux-cp__header {
    flex-wrap: nowrap;
  }

  .lux-cp__tools {
    flex: 0 0 auto;
    max-width: 48%;
    justify-content: flex-end;
    gap: 0.55rem;
  }

  .lux-cp__tools .lux-cp__ghost {
    min-height: 40px;
  }

  .lux-cp__tools .lux-cp__icon-btn {
    width: 40px;
    height: 40px;
  }

  .lux-cp__kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.lux-rs-portal-mode .lux-rs-modal-panel {
    width: min(860px, 94vw) !important;
    max-width: 94vw !important;
    border-radius: 18px !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.lux-rs-portal-mode .lux-cp-invoice-frame-wrap,
  body.lux-rs-portal-mode .lux-cp-invoice-frame {
    min-height: min(68vh, 700px) !important;
    height: min(68vh, 700px) !important;
  }
}

/* ---- Desktop ---- */
@media (min-width: 1024px) {
  body.lux-rs-portal-mode .lux-rs-page,
  body.lux-rs-portal-mode .lux-cp {
    max-width: min(1120px, 100%) !important;
  }

  .lux-cp {
    gap: 16px;
  }

  .lux-cp__header {
    padding: 1.35rem 1.5rem 1.15rem;
    align-items: center;
  }

  .lux-cp__name {
    font-size: 1.5rem;
  }

  .lux-cp__kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .lux-cp__kpi {
    padding: 1rem 1.15rem;
  }

  .lux-cp__panel-head {
    padding-inline: 1.4rem;
  }

  .lux-cp__row {
    padding: 0.9rem 1.25rem;
  }

  body.lux-rs-portal-mode .lux-rs-modal-panel {
    width: min(960px, 92vw) !important;
    max-width: 960px !important;
    border-radius: 20px !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-panel:has(.lux-cp-invoice-frame) {
    width: min(980px, 94vw) !important;
    max-width: 980px !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-stats,
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-cp-repair__stats {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  body.lux-rs-portal-mode .lux-cp-invoice-frame-wrap,
  body.lux-rs-portal-mode .lux-cp-invoice-frame {
    min-height: min(74vh, 780px) !important;
    height: min(74vh, 780px) !important;
  }

  body.lux-rs-portal-mode .lux-im__bubble,
  body.lux-rs-portal-mode .lux-rs-chat-bubble {
    max-width: min(22rem, 46vw) !important;
  }
}

/* ---- Wide desktop ---- */
@media (min-width: 1400px) {
  body.lux-rs-portal-mode .lux-rs-page,
  body.lux-rs-portal-mode .lux-cp {
    max-width: min(1280px, 100%) !important;
  }

  body.lux-rs-portal-mode .ldx-wrap {
    padding-inline: max(2rem, env(safe-area-inset-left, 0px))
      max(2rem, env(safe-area-inset-right, 0px)) !important;
  }

  .lux-cp__header {
    padding: 1.5rem 1.75rem 1.25rem;
  }

  body.lux-rs-portal-mode .lux-rs-modal-panel {
    width: min(1040px, 90vw) !important;
    max-width: 1040px !important;
  }
}

/* Landscape phones: keep modal usable */
@media (max-height: 480px) and (orientation: landscape) {
  body.lux-rs-portal-mode .lux-rs-modal-panel {
    max-height: 96vh !important;
    border-radius: 14px !important;
    align-self: center;
  }

  body.lux-rs-portal-mode .lux-rs-modal {
    align-items: center !important;
    padding: 0.5rem !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-body {
    max-height: 78vh !important;
  }

  body.lux-rs-portal-mode .lux-cp-invoice-frame-wrap,
  body.lux-rs-portal-mode .lux-cp-invoice-frame {
    min-height: 70vh !important;
    height: 70vh !important;
  }

  body.lux-rs-portal-mode .lux-im-panel,
  body.lux-rs-portal-mode .lux-rs-chat-panel {
    max-height: 55vh !important;
    min-height: 180px;
  }
}

/* Prefer dynamic viewport units where supported (mobile browser chrome) */
@supports (height: 100dvh) {
  @media (max-width: 640px) {
    body.lux-rs-portal-mode .lux-rs-modal-body {
      max-height: min(82dvh, 820px) !important;
    }
  }
}

/* High-DPI / reduce motion respect */
@media (prefers-reduced-motion: reduce) {
  body.lux-rs-portal-mode *,
  body.lux-rs-portal-mode *::before,
  body.lux-rs-portal-mode *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Modal shell — ONLY when not [hidden] (was forcing PIN open on load) */
body.lux-rs-portal-mode .lux-rs-modal[hidden],
body.lux-rs-portal-mode .lux-cp-pin-modal[hidden],
body.lux-rs-portal-mode #lux_portal_pin_modal[hidden],
body.lux-rs-portal-mode #lux_portal_modal[hidden],
body.lux-rs-portal-mode.lux-apple-rs .lux-rs-modal[hidden],
body.lux-apple-rs.lux-rs-portal-mode .lux-rs-modal[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.lux-rs-portal-mode .lux-rs-modal:not([hidden]) {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(0.75rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px)) !important;
  place-items: unset !important;
}

/* PIN modal: always a centered compact card (never full bottom-sheet) */
body.lux-rs-portal-mode .lux-cp-pin-modal:not([hidden]),
body.lux-rs-portal-mode #lux_portal_pin_modal:not([hidden]) {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: max(1rem, env(safe-area-inset-top, 0px))
    max(0.75rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(0.75rem, env(safe-area-inset-left, 0px)) !important;
}

body.lux-rs-portal-mode .lux-cp-pin-modal .lux-cp-pin-modal__panel,
body.lux-rs-portal-mode #lux_portal_pin_modal .lux-cp-pin-modal__panel {
  width: min(420px, 94vw) !important;
  max-width: 420px !important;
  max-height: min(90dvh, 640px) !important;
  border-radius: 22px !important;
  margin: 0 auto !important;
  align-self: center !important;
  padding-bottom: 0 !important;
  overflow: auto !important;
}

@media (max-width: 640px) {
  /* Detail/invoice modals only → bottom sheet; exclude PIN */
  body.lux-rs-portal-mode .lux-rs-modal:not([hidden]):not(.lux-cp-pin-modal):not(#lux_portal_pin_modal) {
    align-items: flex-end !important;
    justify-content: stretch !important;
    padding: 0 !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal:not(.lux-cp-pin-modal):not(#lux_portal_pin_modal) > .lux-rs-modal-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 0.35rem) !important;
    border-radius: 18px 18px 0 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* PIN stays centered card on phone too */
  body.lux-rs-portal-mode .lux-cp-pin-modal:not([hidden]),
  body.lux-rs-portal-mode #lux_portal_pin_modal:not([hidden]) {
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem 0.75rem !important;
  }

  body.lux-rs-portal-mode .lux-cp-pin-modal .lux-cp-pin-modal__panel,
  body.lux-rs-portal-mode #lux_portal_pin_modal .lux-cp-pin-modal__panel {
    width: min(400px, 94vw) !important;
    max-width: 400px !important;
    border-radius: 20px !important;
  }
}

/* Beat apple-rs modal centering only when open */
body.lux-rs-portal-mode.lux-apple-rs .lux-rs-modal:not([hidden]),
body.lux-apple-rs.lux-rs-portal-mode .lux-rs-modal:not([hidden]) {
  display: flex !important;
  place-items: unset !important;
}

/* Card head in repair modal: stack status pill under title on narrow */
@media (max-width: 640px) {
  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-card-head {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.55rem !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-status-pill {
    align-self: flex-start !important;
  }

  body.lux-rs-portal-mode .lux-rs-modal-content .lux-rs-card-head h2 {
    font-size: 1.1rem !important;
    line-height: 1.25 !important;
  }
}

/* Desktop: two-column feel for long meta lines not needed; ensure row-side doesn't overflow */
@media (min-width: 900px) {
  .lux-cp__row-side {
    flex-wrap: nowrap;
  }
}

/* Refined preview close button: quiet by default, expressive on interaction. */
body.lux-rs-portal-mode .lux-rs-modal-head .lux-rs-modal-close {
  width: 2.75rem !important;
  height: 2.75rem !important;
  min-width: 2.75rem !important;
  min-height: 2.75rem !important;
  border: 1px solid color-mix(in srgb, var(--a-line, #d8d8dc) 85%, transparent) !important;
  border-radius: 50% !important;
  background: transparent !important;
  color: var(--a-muted, #6e6e73) !important;
  box-shadow: none !important;
  transform: none !important;
}
body.lux-rs-portal-mode .lux-rs-modal-head .lux-rs-modal-close i {
  font-size: 1.05rem !important;
  font-weight: 400 !important;
}
body.lux-rs-portal-mode .lux-rs-modal-head .lux-rs-modal-close:hover,
body.lux-rs-portal-mode .lux-rs-modal-head .lux-rs-modal-close:focus-visible {
  background: #fef2f2 !important;
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
  transform: rotate(90deg) !important;
  outline: none !important;
}
