/* The live pieces beside each feature: drawn in the CRM's own colours, like the window. */
.demo {
  background: var(--app-bg);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: var(--r-window);
  box-shadow: var(--shadow-window);
  font-size: var(--size-small);
  line-height: var(--lh-small);
  overflow: hidden;
}
.demo [data-s="booked"] { --edge: var(--status-booked); --fill: var(--status-booked-bg); }
.demo [data-s="active"] { --edge: var(--status-active); --fill: var(--status-active-bg); }
.demo [data-s="due"] { --edge: var(--status-due); --fill: var(--status-due-bg); }
.demo [data-s="closed"] { --edge: var(--status-closed); --fill: var(--status-closed-bg); }
.demo-top {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 3rem;
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--app-border);
}
.demo-title {
  font-weight: 600;
}
.demo-end {
  margin-left: auto;
}
.demo-2 {
  color: var(--app-text-2);
}
.demo-btn {
  height: 2rem;
  padding: 0 var(--s-3);
  border-radius: var(--r-app-control);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font: 500 var(--size-small) / 1 var(--font-text);
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.demo-btn:hover {
  background: var(--accent-strong);
}
.demo-btn[data-quiet] {
  border-color: var(--app-border);
  background: var(--app-bg);
  color: var(--app-text);
}
.demo-btn[data-quiet]:hover {
  background: var(--app-subtle);
}
.demo-btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.demo :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.demo-chip {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 var(--s-2);
  border-left: 3px solid var(--edge);
  border-radius: var(--r-chip);
  background: var(--fill);
  font-size: var(--size-meta);
  font-weight: 500;
  white-space: nowrap;
}

/* ---- Fines: Update brings the new ones, each finds its rental ---- */
.fines-wrap {
  overflow-x: auto;
}
.fines {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.fines th,
.fines td {
  height: 2.5rem;
  padding: 0 var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--app-border);
  white-space: nowrap;
}
.fines th {
  height: 2rem;
  font-weight: 500;
  color: var(--app-text-2);
  font-size: var(--size-meta);
}
.fines tr:last-child td {
  border-bottom: 0;
}
.fines .bill {
  color: var(--app-text-2);
}
/* A new fine slides in from above. */
.fines tr[data-new] {
  animation: fines-in 320ms var(--ease) both;
}
@keyframes fines-in {
  from { opacity: 0; transform: translateY(-8px); }
}
.fines-finding {
  color: var(--app-text-3);
  animation: fines-wait 900ms ease-in-out infinite alternate;
}
@keyframes fines-wait {
  to { opacity: 0.35; }
}
/* The moment it finds its rental: the row lights up once, the client's chip pops in, the bill follows. */
.fines tr[data-matched] td {
  animation: fines-lit 900ms var(--ease);
}
@keyframes fines-lit {
  from { background: var(--accent-bg); }
}
.fines tr[data-matched] .fines-chip {
  animation: fines-pop 300ms var(--ease);
}
@keyframes fines-pop {
  0% { opacity: 0; transform: scale(0.7); }
  70% { transform: scale(1.06); }
}
.fines tr[data-matched] .bill {
  animation: fines-in 300ms var(--ease) 150ms both;
}
.fines-sum {
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 var(--s-1);
  padding: var(--s-2) var(--s-4);
  border-top: 1px solid var(--app-border);
  color: var(--app-text-2);
  font-variant-numeric: tabular-nums;
}
.fines-sum:empty {
  display: none;
}
.fines-sum b {
  color: var(--app-text);
  font-weight: 600;
}

/* ---- A mulkiya read by the copilot ---- */
.paper-stage {
  padding: var(--s-3) var(--s-4);
  background: var(--app-subtle);
  border-bottom: 1px solid var(--app-border);
}
@media (width < 40rem) {
  .paper-stage {
    padding: var(--s-3);
  }
}
.paper-sides {
  display: flex;
  gap: var(--s-1);
}
.paper-sides button {
  height: 1.75rem;
  padding: 0 var(--s-3);
  border-radius: var(--r-app-control);
  border: 1px solid var(--app-border);
  background: var(--app-bg);
  color: var(--app-text-2);
  font: 500 var(--size-small) / 1 var(--font-text);
  cursor: pointer;
}
.paper-sides button[aria-pressed="true"] {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.paper-sides button:disabled {
  cursor: default;
}

/*
 * The paper: the UAE vehicle licence as it looks, front and back, drawn in its own colours (a thing, like the plate;
 * the same in the night). Made-up values, a company called "Your company", and "Sample" across it.
 */
.mk {
  container-type: inline-size;
  position: relative;
  max-width: 25rem;
  margin: 0 auto;
  transition: transform 180ms var(--ease);
}
.mk[data-turning] {
  transform: scaleX(0);
}
.mk-face {
  position: relative;
  padding: 3.2cqw 3.6cqw 2.6cqw;
  border-radius: 2.2cqw;
  background: var(--mk-bg);
  color: var(--mk-ink);
  box-shadow: 0 1px 2px rgb(60 50 20 / 0.12), 0 8px 24px -8px rgb(60 50 20 / 0.25);
  font-size: 2.3cqw;
  line-height: 1.25;
  overflow: hidden;
}
.mk-face[hidden] {
  display: none;
}
.mk-face [lang="ar"] {
  font-family: "IBM Plex Sans Arabic", var(--font-text);
  direction: rtl;
}
.mk-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 3cqw;
  margin-bottom: 2.4cqw;
}
.mk-head > :last-child {
  text-align: right;
}
.mk-country {
  white-space: nowrap;
  font-size: 1.3em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.mk-kind {
  margin-top: 0.4em;
  color: var(--mk-red);
  font-size: 1.3em;
  font-weight: 500;
}
/* The seal: a plain round mark in the card's own gold, not the state emblem. */
.mk-seal {
  display: grid;
  place-items: center;
  width: 11cqw;
  height: 11cqw;
  border-radius: 50%;
  border: 0.5cqw solid var(--mk-seal);
  color: var(--mk-seal);
  font-weight: 600;
  font-size: 0.95em;
}
.mk-seal-oval {
  width: 15cqw;
  height: 10cqw;
  border-width: 0;
  background: var(--mk-seal-2);
  color: var(--mk-bg);
}
.mk-table {
  display: grid;
  grid-template-columns: 19% 1fr auto 1fr 16%;
  border: 1px solid var(--mk-line);
  border-bottom: 0;
}
.mk-table > * {
  min-height: 4.4cqw;
  display: flex;
  align-items: center;
  padding: 0.25em 0.6em;
  border-bottom: 1px solid var(--mk-line);
  border-right: 1px solid var(--mk-line);
  white-space: nowrap;
  overflow: hidden;
}
.mk-l {
  font-weight: 500;
}
.mk-a {
  justify-content: flex-end;
  border-right: 0 !important;
  font-weight: 500;
}
.mk-v {
  font-size: 1.05em;
  font-variant-numeric: tabular-nums;
}
.mk-wide {
  grid-column: span 3;
}
/* One value written twice, English at the left and Arabic at the right, as the paper has it. */
.mk-two {
  display: flex;
  justify-content: space-between;
  width: 100%;
}
.mk-mid {
  gap: 0.6em;
  font-weight: 500;
}
.mk-c {
  justify-content: center;
}
.mk-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2cqw;
  margin-top: 1.6cqw;
  font-size: 0.85em;
}
.mk-uae {
  color: var(--mk-green);
  font-size: 2.2em;
  font-weight: 600;
  line-height: 1;
}
/* "Sample" across the card: it is a picture of a paper, never a paper. */
.mk-face::after {
  content: "Sample";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  color: var(--mk-ink);
  opacity: 0.06;
  font-size: 9em;
  font-weight: 600;
  pointer-events: none;
}
/* The copilot reading: a line passes down the paper. */
.mk-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--copilot);
  opacity: 0;
  pointer-events: none;
}
.mk[data-reading] .mk-scan {
  animation: paper-scan 900ms var(--ease);
}
@keyframes paper-scan {
  0% { top: 0; opacity: 1; }
  100% { top: 100%; opacity: 0.6; }
}
.paper-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
}
.paper-card dl {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr) 4.5rem minmax(0, 1fr);
  gap: var(--s-1) var(--s-3);
  font-size: var(--size-meta);
  line-height: var(--lh-meta);
  margin: 0;
}
@media (width < 40rem) {
  .paper-card dl {
    grid-template-columns: 5.5rem minmax(0, 1fr);
  }
}
.paper-card dt {
  color: var(--app-text-2);
}
.paper-card dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.paper-card dd[data-empty] {
  color: var(--app-text-3);
}
.paper-card dd[data-filled] {
  animation: paper-fill 400ms var(--ease);
}
@keyframes paper-fill {
  from { background: var(--accent-bg); }
}
.paper-foot {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.copilot-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--app-text-2);
  font-size: var(--size-meta);
}
.copilot-mark i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--copilot);
}

/* ---- The copilot answers a client; the deal fills itself ---- */
.rp {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}
@media (width < 40rem) {
  .rp {
    grid-template-columns: 1fr;
  }
}
.rp-chat {
  display: flex;
  flex-direction: column;
  height: 27rem;
  border-right: 1px solid var(--app-border);
}
@media (width < 40rem) {
  .rp-chat {
    height: 25rem;
    border-right: 0;
    border-bottom: 1px solid var(--app-border);
  }
}
.rp-face {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--app-subtle);
  color: var(--app-text-2);
  font-size: var(--size-meta);
  font-weight: 600;
}
.rp-face > i {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid var(--app-bg);
  background: var(--channel-whatsapp);
}
/* The switch, the CRM's on / off. */
.rp-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--app-text-2);
  font: 500 var(--size-meta) / 1 var(--font-text);
  cursor: pointer;
}
.rp-switch i {
  position: relative;
  width: 1.75rem;
  height: 1rem;
  border-radius: 0.5rem;
  background: var(--app-border);
  transition: background var(--duration) var(--ease);
}
.rp-switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--app-bg);
  box-shadow: 0 1px 2px rgb(31 35 40 / 0.2);
  transition: transform var(--duration) var(--ease);
}
.rp-switch[aria-checked="true"] i {
  background: var(--accent);
}
.rp-switch[aria-checked="true"] i::after {
  transform: translateX(0.75rem);
}
.rp-msgs {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4);
  background: var(--app-subtle);
}
.rp-msg {
  max-width: 85%;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-float);
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  animation: rp-in var(--duration) var(--ease);
}
.rp-msg[data-out] {
  align-self: flex-end;
  background: var(--accent-bg);
  border-color: transparent;
}
/* What the copilot sent by itself: outlined, as in the CRM. */
.rp-msg[data-copilot] {
  border-color: var(--accent);
}
.rp-msg small {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: 2px;
  color: var(--app-text-2);
  font-size: var(--size-meta);
  font-variant-numeric: tabular-nums;
}
.rp-note {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 2px var(--s-2);
  border-radius: var(--r-chip);
  background: var(--status-active-bg);
  color: var(--status-active-ink);
  font-size: var(--size-meta);
  font-weight: 500;
  animation: rp-saved 500ms var(--ease);
}
.rp-note i {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--status-active);
}
/* Saved: the line drops toward the deal for a moment, then settles. */
@keyframes rp-saved {
  0% { opacity: 0; transform: translateY(4px) scale(0.96); }
  60% { opacity: 1; transform: translateX(6px); }
}
.rp-files {
  display: flex;
  gap: var(--s-1);
  margin-bottom: var(--s-1);
}
.rp-file {
  padding: 2px var(--s-2);
  border-radius: var(--r-chip);
  background: var(--app-subtle);
  border: 1px solid var(--app-border);
  font-size: var(--size-meta);
}
.rp-typing {
  align-self: flex-end;
  color: var(--app-text-2);
  font-size: var(--size-meta);
}
@keyframes rp-in {
  from { opacity: 0; transform: translateY(4px); }
}
.rp-hint {
  margin: auto;
  max-width: 16rem;
  color: var(--app-text-2);
  text-align: center;
}
.rp-foot {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--app-border);
}
.rp-says {
  color: var(--app-text-2);
  font-size: var(--size-meta);
}
.rp-lines {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.rp-line {
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-float);
  border: 1px dashed var(--app-text-3);
  background: var(--app-bg);
  color: var(--app-text);
  font: 400 var(--size-small) / var(--lh-small) var(--font-text);
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}
.rp-line:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.rp-draft {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--accent);
  border-radius: var(--r-float);
}
.rp-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* The deal beside it: the card's shape, its stage, its facts, its chat. */
.rp-deal {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.rp-deal-top {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-4) var(--s-4) var(--s-3);
}
.rp-stage {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 1.75rem;
  padding: 0 var(--s-3);
  border-radius: var(--r-app-control);
  background: var(--fill);
  color: var(--app-text);
  font-weight: 500;
  transition: background var(--duration) var(--ease);
}
.rp-stage i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--edge);
}
.rp-stage small {
  color: var(--app-text-2);
  font-size: var(--size-meta);
  font-weight: 400;
}
.rp-tabs {
  display: flex;
  gap: var(--s-4);
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--app-border);
}
.rp-tabs button {
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--app-text-2);
  font: 500 var(--size-small) / 1 var(--font-text);
  cursor: pointer;
}
.rp-tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--app-text);
}
.rp-tab {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--s-4);
}
.rp-deal dl {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: var(--s-1) var(--s-3);
  align-items: center;
  margin: 0;
}
.rp-deal dt {
  color: var(--app-text-2);
}
.rp-deal dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.rp-deal dd[data-empty] {
  color: var(--app-text-3);
}
.rp-deal dd[data-filled] {
  animation: paper-fill 400ms var(--ease);
}
.rp-saved {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.rp-saved li {
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--app-border);
}
.rp-saved-note {
  color: var(--status-active-ink);
  font-size: var(--size-meta);
  font-weight: 500;
}
.rp-offers {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
}
.rp-offers [data-declined] {
  color: var(--app-text-3);
  text-decoration: line-through;
}
.rp-stage[data-changed] {
  animation: fines-pop 300ms var(--ease);
}
.rp-saved b {
  display: block;
  font-size: var(--size-meta);
  font-weight: 500;
  color: var(--app-text-2);
}
.rp-wait {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-4);
  padding: var(--s-3);
  border-radius: var(--r-float);
  background: var(--status-due-bg);
}

@media (prefers-reduced-motion: reduce) {
  .mk,
  .mk[data-reading] .mk-scan,
  .paper-card dd[data-filled],
  .rp-deal dd[data-filled],
  .rp-msg,
  .rp-note,
  .rp-stage[data-changed],
  .fines tr[data-new],
  .fines tr[data-matched] td,
  .fines tr[data-matched] .fines-chip,
  .fines tr[data-matched] .bill,
  .fines-finding {
    animation: none;
    transition: none;
  }
}
