/* Automation 09 live demo: invoice viewer (PDF or phone photo with highlight boxes), AI extraction
   and checks, and Your books (Sheets, QuickBooks or Xero) with the Needs review queue. Stage chrome
   and controls come from demo.css. Every rule is scoped under #demo; every class invented here
   starts with ip-. Layout: invoice | extraction | books at 1360px and up; invoice | extraction
   and books at 1100 to 1359px; invoice | a carousel of extraction and books at 901 to 1099px; one
   column with the carousel under the invoice at 900px and below. Paper, sheet and product
   colours are the simulated product's own, defined on each screen. */

#demo [hidden] {
  display: none !important;
}

#demo-stage {
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}

#demo {
  --ip-warn: hsl(28 88% 56%);
}

/* ---------- Tabs: four equal pills in one row, label and meta stacked ---------- */

#demo .ip-demo-bar {
  align-items: flex-start;
}

#demo .ip-demo-bar .tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

#demo .ip-demo-bar .tab {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 3px;
  align-items: center;
  padding: 12px 20px;
  text-align: left;
}

#demo .ip-demo-bar .tab-n {
  grid-row: 1 / span 2;
}

#demo .ip-demo-bar .tab-l,
#demo .ip-demo-bar .tab-m {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#demo .ip-demo-bar .tab-l {
  grid-column: 2;
  grid-row: 1;
}

#demo .ip-demo-bar .tab-m {
  grid-column: 2;
  grid-row: 2;
}

#demo .ip-demo-bar .demo-note {
  margin-left: auto;
}

#demo .ip-addr {
  overflow-wrap: anywhere;
}

@media (max-width: 1099px) {
  #demo .ip-demo-bar .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #demo .ip-demo-bar .demo-note {
    margin-left: 0;
  }
}

@media (max-width: 639px) {
  #demo .ip-demo-bar .tab {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto;
    row-gap: 0;
  }

  #demo .ip-demo-bar .tab-n {
    grid-row: auto;
  }

  #demo .ip-demo-bar .tab-l {
    grid-row: auto;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.2;
  }

  #demo .ip-demo-bar .tab-m {
    display: none;
  }
}

/* ---------- Stage grid: invoice | side (extraction and books) ---------- */

#demo .ip-grid {
  --ip-h: 640px;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 24px;
}

#demo .ip-label {
  height: 28px;
  min-height: 28px;
}

#demo .ip-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 520px;
  gap: 28px;
  align-items: start;
  min-width: 0;
}

#demo .ip-col-invoice,
#demo .ip-col-ex,
#demo .ip-col-books {
  min-width: 0;
}

#demo .ip-nav {
  display: none;
}

/* ---------- Invoice viewer: mail header, canvas with the paper ---------- */

#demo .ip-viewer {
  display: flex;
  flex-direction: column;
  height: var(--ip-h);
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}

#demo .ip-mail {
  flex: none;
  padding: 12px 14px;
  background: var(--elev);
  border-bottom: 1px solid var(--line);
}

#demo .ip-mail-r1 {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#demo .ip-av {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.14);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
}

#demo .ip-who {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

#demo .ip-from-name {
  font-size: 15px;
  line-height: 1.3;
  color: var(--bone);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#demo .ip-from {
  overflow: hidden;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--ash);
  white-space: nowrap;
  text-overflow: ellipsis;
}

#demo .ip-mail-time {
  flex: none;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ash);
  white-space: nowrap;
}

#demo .ip-subject {
  margin: 9px 0 0;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--bone);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#demo .ip-preview {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ash);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#demo .ip-att {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin-top: 10px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ink);
  outline: 1px solid transparent;
  outline-offset: 2px;
  box-sizing: border-box;
  min-width: 0;
}

#demo .ip-att-ic {
  display: inline-grid;
  flex: none;
  color: var(--ash);
}

#demo .ip-att-ic svg {
  width: 15px;
  height: 15px;
}

#demo .ip-att-f {
  font-size: 14px;
  color: var(--bone);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

#demo .ip-att-s {
  flex: none;
  font-size: 11.5px;
  color: var(--ash);
  white-space: nowrap;
}

#demo .ip-att.is-picked {
  animation: ip-picked 1.2s ease-out;
}

#demo .ip-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 18px 16px 34px;
  overflow: hidden;
  background-color: var(--ink);
  background-image: radial-gradient(hsl(34 10% 17%) 1px, transparent 1px);
  background-size: 14px 14px;
  background-position: 0 0;
}

#demo .ip-canvas.is-photo {
  background: radial-gradient(130% 100% at 35% 25%, #4b4740 0%, #2c2a26 55%, #1a1916 100%);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6);
}

#demo .ip-canvas.is-flash::before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px var(--danger);
  pointer-events: none;
  animation: ip-flash 0.6s ease-out both;
}

#demo .ip-strip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  line-height: 1.3;
  color: var(--ash);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- The paper (simulated invoice) ---------- */

#demo .ip-paper {
  --accent: #3f6b3a;
  position: relative;
  box-sizing: border-box;
  width: min(100%, 290px);
  padding: 1.8em 1.7em 1.5em;
  font-family: var(--font-sans);
  font-size: 10.2px;
  line-height: 1.4;
  color: #222;
  background: #fdfcf9;
  border-radius: 2px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

#demo .ip-paper.is-photo {
  background: linear-gradient(170deg, #f8f4ea 0%, #ece5d6 100%);
  filter: contrast(0.96) saturate(0.9);
  transform: perspective(900px) rotateX(6deg) rotate(var(--tilt, 0deg));
  box-shadow: 0 22px 40px -14px rgba(0, 0, 0, 0.85);
  transition: transform 0.9s var(--ease-out), filter 0.9s var(--ease-out);
}

#demo .ip-paper.is-photo.is-straight {
  transform: perspective(900px) rotateX(0deg) rotate(0deg);
  filter: contrast(1.04) saturate(0.9);
}

/* A fold crease at 41%, as on the hero's photo */
#demo .ip-paper.is-photo::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 41%;
  height: 3px;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.07) 40%, rgba(255, 255, 255, 0.55) 60%, transparent);
  pointer-events: none;
}

#demo .ip-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.2em;
  align-items: start;
}

#demo .ip-sup {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75em;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--accent);
  overflow-wrap: anywhere;
}

#demo .ip-supsub,
#demo .ip-supaddr {
  margin: 0.35em 0 0;
  font-size: 0.95em;
  line-height: 1.4;
  color: #6b665c;
}

#demo .ip-supaddr {
  color: #6b665c;
}

#demo .ip-meta {
  text-align: right;
  min-width: 0;
}

#demo .ip-doc {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1em;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

#demo .ip-mrow {
  display: flex;
  justify-content: space-between;
  gap: 0.8em;
  margin: 0.45em 0 0;
  font-family: var(--font-mono);
  font-size: 0.95em;
  line-height: 1.3;
  white-space: nowrap;
}

#demo .ip-mrow span {
  color: #6b665c;
}

#demo .ip-mrow b {
  font-weight: 600;
  color: #222;
}

#demo .ip-bill {
  margin-top: 1.4em;
}

#demo .ip-lab {
  display: block;
  font-family: var(--font-mono);
  font-size: max(7.5px, 0.85em);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6b665c;
}

#demo .ip-billto {
  margin: 0.35em 0 0;
  font-size: 1.05em;
  color: #222;
}

#demo .ip-items {
  width: 100%;
  margin-top: 1.2em;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 1em;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

#demo .ip-items th {
  padding: 0 0 0.45em;
  border-bottom: 1px solid #e5e0d5;
  font-family: var(--font-mono);
  font-size: max(7.5px, 0.8em);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  color: #6b665c;
}

#demo .ip-items td {
  padding: 0.05em 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#demo .ip-items .ip-n {
  text-align: right;
}

#demo .ip-items .ip-cq {
  width: 3em;
}

#demo .ip-items .ip-ca {
  width: 5.5em;
}

#demo .ip-totals {
  width: 58%;
  margin: 0.9em 0 0 auto;
}

#demo .ip-tot {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
  padding: 0.2em 0;
  color: #6b665c;
}

#demo .ip-tot b {
  font-weight: 600;
  color: #222;
  font-variant-numeric: tabular-nums;
}

#demo .ip-tot--total {
  margin-top: 0.2em;
  padding-top: 0.3em;
  border-top: 1.5px solid #222;
  font-size: 1.3em;
  font-weight: 700;
  color: #222;
}

#demo .ip-tot--total b {
  font-weight: 700;
}

#demo .ip-foot {
  margin: 1.4em 0 0;
  font-size: max(7.5px, 0.85em);
  line-height: 1.4;
  color: #6b665c;
}

/* Highlight boxes sit on the paper and turn with it */
#demo .ip-box {
  position: absolute;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
  background: rgb(255 255 255 / 0.1);
  box-shadow: 0 0 0 3px rgb(255 255 255 / 0.14);
  pointer-events: none;
  animation: ip-box-in 0.22s var(--ease-out) both;
}

/* Totals rows: the tag sits in the empty left margin beside the box, not over the row above */
#demo .ip-box.is-side .ip-box-tag {
  left: auto;
  right: 100%;
  bottom: auto;
  top: 50%;
  margin: 0 4px 0 0;
  transform: translateY(-50%);
  border-radius: 2px 0 0 2px;
}

#demo .ip-box.is-fail {
  border-color: var(--danger);
  background: hsl(0 70% 52% / 0.1);
  box-shadow: 0 0 0 3px hsl(0 70% 52% / 0.14);
}

#demo .ip-box-tag {
  position: absolute;
  left: -1.5px;
  bottom: 100%;
  margin-bottom: 2px;
  padding: 2px 5px;
  border-radius: 2px 2px 2px 0;
  background: var(--accent);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

#demo .ip-box.is-tag .ip-box-tag {
  opacity: 1;
}

/* Photo straightening: the corners snap on, a scan line sweeps, then the paper squares up */
#demo .ip-scan {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

#demo .ip-scan.is-on {
  opacity: 1;
}

#demo .ip-scan i {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 0 solid var(--accent);
}

#demo .ip-scan i:nth-child(1) {
  left: 0;
  top: 0;
  border-left-width: 2px;
  border-top-width: 2px;
}

#demo .ip-scan i:nth-child(2) {
  right: 0;
  top: 0;
  border-right-width: 2px;
  border-top-width: 2px;
}

#demo .ip-scan i:nth-child(3) {
  left: 0;
  bottom: 0;
  border-left-width: 2px;
  border-bottom-width: 2px;
}

#demo .ip-scan i:nth-child(4) {
  right: 0;
  bottom: 0;
  border-right-width: 2px;
  border-bottom-width: 2px;
}

#demo .ip-scan.is-on i {
  animation: ip-snap 0.24s var(--ease-out) both;
}

#demo .ip-scanwrap {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
}

#demo .ip-scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px 2px rgb(255 255 255 / 0.5);
  opacity: 0;
}

#demo .ip-scanwrap.is-on .ip-scanline {
  animation: ip-scan 1s linear;
}

/* The stamp: a red rubber stamp across the items table */
#demo .ip-stamp {
  position: absolute;
  top: 52%;
  left: 50%;
  padding: 0.4em 0.8em;
  border: 3px double var(--danger);
  border-radius: 2px;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 1.9em;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.9;
  mix-blend-mode: multiply;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-12deg);
  animation: ip-stamp 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

#demo .ip-stamp small {
  display: block;
  font-size: 0.62em;
  letter-spacing: 0.04em;
}

/* ---------- Extraction panel ---------- */

#demo .ip-ex {
  display: flex;
  flex-direction: column;
  height: var(--ip-h);
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-sizing: border-box;
}

#demo .ip-ex-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}

#demo .ip-ex-id {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

#demo .ip-ex-id > .mono {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#demo .ip-ex-num {
  min-width: 0;
  font-weight: 400;
  font-size: 15px;
  color: var(--bone);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#demo .ip-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ash);
}

#demo .ip-pill[data-tone="live"] {
  color: var(--accent);
  border-color: rgb(255 255 255 / 0.4);
}

#demo .ip-pill[data-tone="live"]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: ip-pulse 1.4s ease-in-out infinite;
}

#demo .ip-pill[data-tone="ok"] {
  color: var(--ok);
  border-color: hsl(152 60% 48% / 0.4);
}

#demo .ip-pill[data-tone="fail"] {
  color: var(--danger);
  border-color: hsl(0 70% 56% / 0.45);
}

#demo .ip-fields {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
  padding: 12px 14px;
}

#demo .ip-cell {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 4px 4px;
  margin: -2px -4px -4px;
  border-radius: 4px;
}

#demo .ip-cell--wide {
  grid-column: 1 / -1;
}

#demo .ip-cl2 {
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--ash);
}

#demo .ip-val {
  min-width: 0;
  min-height: 16px;
  font-size: 15.5px;
  line-height: 1.3;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

#demo .ip-cell--total .ip-val {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
}

#demo .ip-skel {
  display: block;
  width: 70%;
  height: 8px;
  margin-top: 4px;
  border-radius: 4px;
  background: var(--elev);
}

#demo .ip-cell.is-reading .ip-skel,
#demo .ip-lines.is-reading .ip-skel {
  background: linear-gradient(90deg, var(--elev) 0%, rgb(255 255 255 / 0.35) 50%, var(--elev) 100%);
  background-size: 200% 100%;
  animation: ip-shim 1.2s linear infinite;
}

#demo .ip-cell.is-filled {
  animation: ip-cell-flash 0.7s ease-out;
}

#demo .ip-cell.is-filled .ip-val {
  animation: ip-fade 0.26s ease-out;
}

#demo .ip-cell.is-filled::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left center;
  animation: ip-bar 0.7s ease-out both;
}

#demo .ip-cell.is-fail .ip-val {
  color: var(--danger);
}

#demo .ip-lines {
  flex: none;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

#demo .ip-lines-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

#demo .ip-lines-h > .mono {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#demo .ip-lines-n {
  color: var(--bone-70) !important;
}

/* Room for the six shown line items and the total, so the panel does not move when they fill in */
#demo .ip-lines-b {
  min-height: 132px;
}

#demo .ip-lrow,
#demo .ip-lmore,
#demo .ip-ltotal {
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.25s var(--ease-std), transform 0.25s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms);
}

#demo .ip-lrow.is-in,
#demo .ip-lmore.is-in,
#demo .ip-ltotal.is-in {
  opacity: 1;
  transform: none;
}

#demo .ip-lrow.is-skel {
  opacity: 1;
  transform: none;
}

#demo .ip-lrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px 64px;
  align-items: center;
  gap: 8px;
  height: 22px;
  font-size: 14px;
  color: var(--bone-70);
}

#demo .ip-lrow .ip-ld {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#demo .ip-lq {
  text-align: right;
  font-size: 12px;
  color: var(--ash);
}

#demo .ip-la {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#demo .ip-lrow .ip-skel {
  width: 60%;
  margin: 0;
}

#demo .ip-lmore {
  height: 18px;
  line-height: 18px;
  font-size: 12px;
  color: var(--ash);
}

#demo .ip-ltotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 26px;
  margin-top: 2px;
  padding-top: 2px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--bone);
}

#demo .ip-ltotal b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#demo .ip-lines.is-fail .ip-ltotal b {
  color: var(--danger);
}

#demo .ip-checks {
  flex: none;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

#demo .ip-checks-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

#demo .ip-checks-h > .mono {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#demo .ip-checks-sum {
  color: var(--ash) !important;
  white-space: nowrap;
}

#demo .ip-checks-sum.is-ok {
  color: var(--ok) !important;
}

#demo .ip-checks-sum.is-fail {
  color: var(--danger) !important;
}

#demo .ip-check {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  column-gap: 10px;
  align-items: center;
  min-height: 28px;
  margin: 0 -6px;
  padding: 2px 6px;
  border-radius: 4px;
}

#demo .ip-ci {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  box-sizing: border-box;
}

#demo .ip-ci svg {
  width: 14px;
  height: 14px;
}

#demo .ip-cl {
  min-width: 0;
  font-size: 15px;
  line-height: 1.3;
  color: var(--ash);
}

#demo .ip-check.is-on .ip-cl {
  color: var(--bone);
}

#demo .ip-cn {
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1.3;
  color: var(--ok);
  text-align: right;
  white-space: nowrap;
}

#demo .ip-cfull {
  grid-column: 2 / -1;
  margin: 2px 0 0;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--danger);
}

#demo .ip-check.is-warn .ip-cfull {
  color: var(--ip-warn);
}

#demo .ip-cdet {
  grid-column: 2 / -1;
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ash);
}

#demo .ip-check.is-pass .ip-ci {
  background: var(--ok);
  border-color: var(--ok);
}

#demo .ip-check.is-fail {
  background: hsl(0 70% 52% / 0.07);
}

#demo .ip-check.is-fail::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--danger);
}

#demo .ip-check.is-fail .ip-ci {
  background: var(--danger);
  border-color: var(--danger);
}

#demo .ip-check.is-warn {
  background: hsl(28 88% 56% / 0.07);
}

#demo .ip-check.is-warn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--ip-warn);
}

#demo .ip-check.is-warn .ip-ci {
  border-color: transparent;
  background: none;
}

/* Paused or ended: the live pulses stop too, so a paused demo does not look live */
#demo-stage[data-state="paused"] .ip-pill[data-tone="live"]::before,
#demo-stage[data-state="ended"] .ip-pill[data-tone="live"]::before,
#demo-stage[data-state="paused"] .live-dot,
#demo-stage[data-state="ended"] .live-dot {
  animation-play-state: paused;
}

#demo .ip-check.is-run .ip-ci {
  border: 2px solid var(--accent);
  border-top-color: transparent;
  background: none;
  animation: ip-spin 0.8s linear infinite;
}

#demo .ip-check.is-run .ip-cl {
  color: var(--bone);
}

#demo .ip-runlog {
  position: relative;
  flex: none;
  height: 66px;
  margin-top: auto;
  padding: 0 14px 3px;
  border-top: 1px solid var(--line);
  background: var(--ink);
  box-sizing: border-box;
  overflow: hidden;
}

/* A window of exactly three lines: older lines slide up and clip at its top edge */
#demo .ip-runwin {
  position: relative;
  height: 54px;
  margin-top: 8px;
  overflow: hidden;
}

#demo .ip-runlist {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  transition: transform 0.35s var(--ease-out);
}

#demo .ip-rl {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  color: var(--bone-70);
}

#demo .ip-rt {
  flex: none;
  color: var(--ash);
}

/* One log entry is one line: a long entry is cut with an ellipsis, never wrapped into the line above */
#demo .ip-rx {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#demo .ip-rl.is-ok {
  color: var(--ok);
}

#demo .ip-rl.is-fail {
  color: var(--danger);
}

#demo .ip-rl.is-warn {
  color: var(--ip-warn);
}

#demo .ip-rl.is-person {
  color: var(--ok);
}

#demo .ip-rp {
  display: inline-grid;
  flex: none;
  width: 11px;
  height: 18px;
  place-items: center;
}

#demo .ip-rp svg {
  width: 11px;
  height: 11px;
}

/* ---------- Your books: counters, the accounting app, the review queue ---------- */

#demo .ip-view {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 999px;
}

#demo .ip-view button {
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: var(--ash);
  transition: color 0.2s, background-color 0.2s;
}

#demo .ip-view button:hover {
  color: var(--bone);
}

#demo .ip-view button[aria-pressed="true"] {
  background: var(--bone);
  color: var(--ink);
}

#demo .ip-books {
  display: flex;
  flex-direction: column;
  height: var(--ip-h);
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-sizing: border-box;
}

#demo .ip-books-head {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#demo .ip-count {
  position: relative;
  min-width: 0;
}

#demo .ip-count-l {
  display: block;
  overflow: hidden;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ash);
}

#demo .ip-count-n {
  position: relative;
  display: inline-block;
  margin-top: 4px;
}

#demo .ip-roll {
  position: relative;
  display: block;
  height: 1.1em;
  overflow: hidden;
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--bone);
  transition: color 0.3s;
}

#demo .ip-count--in .ip-roll {
  font-size: 30px;
}

#demo .ip-count--rv .ip-roll {
  font-size: 22px;
  color: var(--bone);
}

#demo .ip-count--rv.is-hot .ip-roll {
  color: var(--danger);
}

#demo .ip-roll-v {
  display: block;
}

#demo .ip-roll-v.is-out {
  position: absolute;
  left: 0;
  top: 0;
  animation: ip-roll-out 0.45s var(--ease-out) forwards;
}

#demo .ip-roll-v.is-in {
  animation: ip-roll-in 0.45s var(--ease-out) both;
}

#demo .ip-plus {
  position: absolute;
  left: calc(100% + 6px);
  top: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--accent);
  pointer-events: none;
  animation: ip-plus-up 0.9s var(--ease-out) forwards;
}

#demo .ip-plus.is-red {
  color: var(--danger);
}

#demo .ip-plus.is-minus {
  color: var(--ash);
}

/* The accounting app: Google Sheets palette, accent only on the top border, glyph and active tab */
#demo .ip-app {
  --gs-bg: #ffffff;
  --gs-head: #f8f9fa;
  --gs-line: #e1e3e6;
  --gs-ink: #1f1f1f;
  --gs-muted: #5f6368;
  --gs-new: #fff4d6;
  --gs-done: #eef7f0;
  --gs-check: #1e8e3e;
  --gs-bad: #fde8e8;
  --gs-rule: #c4c7cc;
  --cols: 28px minmax(0, 1fr) 59px 43px 61px 98px 80px 20px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 10px 10px 0;
  border-radius: var(--r-lg);
  border-top: 3px solid var(--ip-app-accent, #188038);
  background: var(--gs-bg);
  color: var(--gs-ink);
  overflow: hidden;
  box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.8);
}

#demo .ip-app.is-fade {
  animation: ip-fade 0.18s ease-out;
}

#demo .ip-appbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid var(--gs-line);
  box-sizing: border-box;
}

#demo .ip-glyph {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--ip-app-accent, #188038);
}

#demo .ip-glyph svg {
  width: 11px;
  height: 11px;
}

#demo .ip-apptitle {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gs-ink);
}

#demo .ip-appsys {
  flex: none;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gs-muted);
}

#demo .ip-sheet {
  flex: none;
  display: flex;
  flex-direction: column;
}

/* The sheet is as tall as its six rows and tabs; the books pane keeps the space below */
#demo .ip-app[data-view="sheets"] {
  flex: none;
}

#demo .ip-colstrip,
#demo .ip-sh-row {
  display: grid;
  grid-template-columns: var(--cols);
}

#demo .ip-colstrip {
  flex: none;
  height: 18px;
  background: var(--gs-head);
  border-bottom: 1px solid var(--gs-line);
}

#demo .ip-colstrip > span {
  line-height: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--gs-muted);
  border-right: 1px solid var(--gs-line);
}

#demo .ip-sh-head {
  flex: none;
  height: 24px;
  background: var(--gs-head);
  border-bottom: 2px solid var(--gs-rule);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gs-ink);
}

/* Six rows, always: the sheet never changes height when a review card arrives, and it scrolls to the
   newest row (or the flagged one) inside that window */
#demo .ip-sh-body {
  flex: 0 0 auto;
  height: 144px;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#demo .ip-sh-row {
  position: relative;
  height: 24px;
  font-size: 12px;
  color: var(--gs-ink);
}

#demo .ip-sh-row > span {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 4px;
  border-right: 1px solid var(--gs-line);
  border-bottom: 1px solid var(--gs-line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

#demo .ip-sh-row > .ip-g {
  justify-content: center;
  padding: 0;
  background: var(--gs-head);
  font-size: 11.5px;
  color: var(--gs-muted);
}

#demo .ip-sh-row .ip-num {
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}

#demo .ip-sh-row .ip-c-check {
  justify-content: center;
  padding: 0;
}

#demo .ip-tick {
  display: inline-flex;
  color: var(--gs-check);
}

#demo .ip-tick svg {
  width: 12px;
  height: 12px;
}

#demo .ip-sh-row.is-blank > span {
  background: transparent;
}

/* A long supplier name is cut with an ellipsis (a block box, so the ellipsis applies) */
#demo .ip-sh-row > .ip-c-supplier {
  display: block;
  line-height: 24px;
}

#demo .ip-sh-row.is-new > span {
  background-color: var(--gs-new);
  animation: ip-cellfill 0.3s both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

#demo .ip-sh-row.is-done > span {
  background-color: var(--gs-done);
}

#demo .ip-sh-row.is-done > .ip-g {
  box-shadow: inset 3px 0 0 var(--gs-check);
}

#demo .ip-sh-row.is-match > span {
  background-color: var(--gs-bad);
}

#demo .ip-sh-row.is-match {
  outline: 2px solid var(--danger);
  outline-offset: -2px;
}

#demo .ip-sh-row.is-match .ip-tick {
  opacity: 0;
}

/* The matched row keeps its Location and Category empty, so the pill never covers data */
#demo .ip-sh-row.is-match .ip-c-location,
#demo .ip-sh-row.is-match .ip-c-category {
  visibility: hidden;
}

#demo .ip-mpill {
  display: inline-block;
  font-style: normal;
  position: absolute;
  right: 6px;
  top: 50%;
  margin-top: -6px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--danger);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #fff;
  animation: ip-pulse2 0.5s ease-in-out 2;
}

#demo .ip-shtabs {
  flex: none;
  display: flex;
  align-items: stretch;
  height: 24px;
  background: var(--gs-head);
  border-top: 1px solid var(--gs-line);
  font-size: 12.5px;
  color: var(--gs-muted);
}

#demo .ip-shtabs > span {
  display: flex;
  align-items: center;
  padding: 0 12px;
}

#demo .ip-shtabs > .is-on {
  background: var(--gs-bg);
  font-weight: 600;
  color: var(--ip-app-accent, #188038);
  box-shadow: inset 0 -2px 0 var(--ip-app-accent, #188038);
}

/* QuickBooks and Xero: a list, newest first */
#demo .ip-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#demo .ip-lhead {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--gs-line);
  box-sizing: border-box;
}

#demo .ip-ltitle {
  font-size: 16px;
  font-weight: 600;
  color: var(--gs-ink);
}

#demo .ip-lsys {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gs-muted);
}

#demo .ip-lfilter {
  flex: none;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--gs-muted);
  border-bottom: 1px solid var(--gs-line);
}

#demo .ip-ltabs {
  flex: none;
  display: flex;
  gap: 14px;
  height: 28px;
  padding: 0 12px;
  border-bottom: 1px solid var(--gs-line);
  font-size: 12.5px;
  color: var(--gs-muted);
}

#demo .ip-ltabs > span {
  display: flex;
  align-items: center;
  height: 100%;
  box-sizing: border-box;
}

#demo .ip-ltabs > .is-on {
  color: var(--gs-ink);
  box-shadow: inset 0 -2px 0 var(--ip-app-accent, #2ca01c);
}

/* The list fades out at its bottom edge, so a row cut by the window reads as "more below" */
#demo .ip-lbody {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
}

#demo .ip-li {
  position: relative;
  padding: 9px 12px;
  border-bottom: 1px solid var(--gs-line);
}

#demo .ip-li.is-new {
  background: var(--gs-new);
}

#demo .ip-li.is-done {
  background: var(--gs-done);
}

#demo .ip-li.is-match {
  background: var(--gs-bad);
  outline: 2px solid var(--danger);
  outline-offset: -2px;
}

#demo .ip-li-1 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gs-ink);
}

#demo .ip-li-1 > span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#demo .ip-li-a {
  flex: none;
  font-variant-numeric: tabular-nums;
}

#demo .ip-li-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--gs-muted);
}

#demo .ip-li-m {
  min-width: 0;
  overflow-wrap: anywhere;
}

#demo .ip-pilll {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f3f4;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--gs-muted);
}

#demo .ip-pilll.is-new {
  background: color-mix(in srgb, var(--ip-app-accent, #2ca01c) 15%, transparent);
}

#demo .ip-li .ip-mpill {
  position: static;
  margin: 0;
  animation: ip-pulse2 0.5s ease-in-out 2;
}

/* The review queue under the books */
#demo .ip-queue {
  flex: none;
  max-height: 48%;
  padding: 12px;
  overflow: hidden;
  box-sizing: border-box;
}

#demo .ip-qhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

#demo .ip-qhead > .mono {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#demo .ip-qcount {
  min-width: 22px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px !important;
  letter-spacing: 0.04em !important;
  text-align: center;
  color: var(--bone) !important;
}

#demo .ip-qlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#demo .ip-qempty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 2px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--bone-70);
}

#demo .ip-qok {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ok);
}

#demo .ip-qok svg {
  width: 16px;
  height: 16px;
}

#demo .ip-compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-md);
}

#demo .ip-cmp-t {
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
  color: var(--bone);
}

#demo .ip-cmp-w {
  flex: none;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--ash);
}

#demo .ip-card {
  position: relative;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-lg);
  background: hsl(0 70% 52% / 0.06);
}

#demo .ip-card.is-fresh {
  animation: ip-card-in 0.5s var(--ease-out) both, ip-card-glow 1.6s ease-out both;
}

#demo .ip-card.is-resolved {
  border-left-color: var(--ok);
  background: hsl(152 60% 48% / 0.06);
}

#demo .ip-card.is-resolved.is-fresh {
  animation: ip-card-in 0.5s var(--ease-out) both;
}

#demo .ip-card-h {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

#demo .ip-card-k {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--danger);
}

#demo .ip-card-t {
  margin: 0;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--bone);
}

#demo .ip-card-line {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ash);
  overflow-wrap: anywhere;
}

#demo .ip-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

#demo .ip-chip-i {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ash);
}

#demo .ip-chip-i--fail {
  color: var(--danger);
  border-color: hsl(0 70% 56% / 0.5);
}

#demo .ip-chip-i--warn {
  color: var(--ip-warn);
  border-color: hsl(28 88% 56% / 0.5);
}

#demo .ip-card-body {
  margin: 8px 0 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--bone-70);
}

#demo .ip-mk {
  font-weight: 600;
  border-radius: 2px;
  padding: 0 2px;
}

#demo .ip-mk--fail {
  color: var(--danger);
  background: hsl(0 70% 52% / 0.12);
}

#demo .ip-mk--warn {
  color: var(--ip-warn);
  background: hsl(28 88% 56% / 0.12);
}

#demo .ip-card-f {
  margin-top: 10px;
}

#demo .ip-card-kk {
  display: block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#demo .ip-card-v {
  margin: 3px 0 0;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--bone);
}

#demo .ip-card-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

#demo .ip-btn {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--bone);
  cursor: default;
}

#demo .ip-btn--danger {
  border-color: hsl(0 70% 56% / 0.6);
  color: var(--danger);
}

#demo .ip-btn.is-pressed {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: ip-press 0.35s ease-out both;
}

#demo .ip-card-who {
  margin: 10px 0 0;
  text-align: right;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ash);
}

#demo .ip-res-h {
  display: flex;
  align-items: center;
  gap: 8px;
}

#demo .ip-res-ic {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ok);
}

#demo .ip-res-ic svg {
  width: 16px;
  height: 16px;
}

#demo .ip-res-t {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--bone);
}

#demo .ip-res-amt {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
}

#demo .ip-res-amt small {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ok);
}

#demo .ip-res-by {
  margin: 6px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ash);
}

/* ---------- Caption, controls and the side switch ---------- */

#demo .ip-demo-caption {
  min-height: calc(1.5em * 2);
  margin: 16px 0 0;
  max-width: 60ch;
  font-size: 14px;
  letter-spacing: 0.02em;
  line-height: 1.5;
  text-transform: none;
  color: var(--bone-70);
}

#demo .ip-demo-caption.is-off {
  visibility: hidden;
}

#demo .ip-controls {
  justify-content: flex-start;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}

#demo .demo-after {
  margin-top: 8px;
}

#demo .demo-after .link-mono {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 12px 0;
}

#demo .demo-side-nav {
  gap: 2px;
  padding: 3px;
  box-sizing: border-box;
}

#demo .demo-side-nav button {
  position: relative;
  min-height: 32px;
  height: auto;
  box-sizing: border-box;
  padding: 0 14px;
  line-height: 1.2;
}

/* ---------- 1360px and up: three columns, the two right-hand panels side by side ---------- */

@media (min-width: 1360px) {
  #demo .ip-side {
    grid-column: 2;
  }
}

/* ---------- 1100 to 1359px: narrower side columns; the sheet drops its Location column ---------- */

@media (max-width: 1359px) {
  #demo .ip-grid {
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 22px;
  }

  #demo .ip-side {
    grid-template-columns: minmax(0, 1fr) 460px;
    gap: 22px;
  }

  #demo .ip-paper {
    font-size: 9.2px;
  }

  /* Labels keep one line; the right-hand label is never cut */
  #demo .ip-label > .mono {
    letter-spacing: 0.08em;
    white-space: nowrap;
  }

  #demo .ip-label > .demo-label-r {
    min-width: 0;
  }
}

/* Labels keep one line at every width (the right-hand one may shorten, never wrap) */
#demo .ip-label > .mono {
  white-space: nowrap;
}

#demo .ip-label > .demo-label-r {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 1100px) and (max-width: 1359px) {
  #demo .ip-app {
    --cols: 28px minmax(0, 1fr) 59px 43px 61px 98px 20px;
  }

  #demo .ip-app .ip-c-location {
    display: none;
  }
}

/* ---------- Status row: below 1280px the sentence takes a full row of its own, never cut mid-sentence ---------- */

@media (max-width: 1279px) {
  /* The status sentence takes a full row of its own, so it is never cut off mid-sentence */
  #demo .demo-top {
    grid-template-columns: auto auto;
  }

  #demo .demo-status {
    grid-column: 1 / -1;
    order: 3;
    min-width: 0;
  }

  #demo .demo-status-text {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
}

/* ---------- 901 to 1099px: invoice on the left, the carousel of extraction and books on the right ---------- */

@media (max-width: 1099px) {
  #demo .ip-grid {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 22px;
  }

  #demo .ip-col-invoice {
    grid-column: 1;
    grid-row: 2;
  }

  #demo .ip-nav {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
    justify-self: start;
    align-self: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
  }

  #demo .ip-nav button {
    min-height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    font-family: var(--font-display);
    font-size: 15px;
    color: var(--ash);
  }

  #demo .ip-nav button[aria-pressed="true"] {
    background: var(--bone);
    color: var(--ink);
  }

  #demo .ip-nav button.has-dot::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
  }

  #demo .ip-side {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    overflow: hidden;
    gap: 0;
    min-width: 0;
  }

  #demo .ip-side > .demo-col {
    flex: none;
    width: 100%;
    transition: transform 0.6s var(--ease-out), visibility 0.6s;
  }

  #demo .ip-side[data-show="books"] > .demo-col {
    transform: translateX(-100%);
  }

  #demo .ip-side[data-show="books"] > .ip-col-ex,
  #demo .ip-side:not([data-show="books"]) > .ip-col-books {
    visibility: hidden;
  }

  #demo .ip-app {
    --cols: 28px minmax(0, 1fr) 62px 46px 64px 104px 86px 20px;
  }

  #demo .ip-sh-row,
  #demo .ip-colstrip {
    font-size: 12.5px;
  }

  #demo .ip-sh-row > span {
    font-size: 12.5px;
  }

  #demo .ip-paper {
    font-size: 10.4px;
  }

}

/* ---------- 900px and below: one column; the invoice, the carousel switch, then the carousel ---------- */

@media (max-width: 900px) {
  #demo .ip-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 16px;
  }

  #demo .ip-col-invoice {
    grid-column: 1;
    grid-row: auto;
    order: 1;
  }

  #demo .ip-viewer {
    height: 600px;
  }

  #demo .ip-nav {
    display: inline-flex;
    grid-column: 1;
    grid-row: auto;
    order: 2;
    justify-self: center;
  }

  #demo .ip-side {
    grid-column: 1;
    grid-row: auto;
    order: 3;
  }

  #demo .ip-nav button,
  #demo .demo-side-nav button {
    min-height: 36px;
  }

  #demo .ip-paper {
    font-size: 10.4px;
  }
}

/* ---------- 640px and below: phones ---------- */

@media (max-width: 640px) {
  #demo .ip-grid {
    padding: 12px;
  }

  #demo .ip-app {
    --cols: 28px minmax(0, 1fr) 62px 46px 64px 104px 86px 20px;
  }

  #demo .ip-viewer {
    height: 600px;
  }

  /* The review card renders whole: the books pane grows to hold it instead of clipping its footer */
  #demo .ip-books {
    height: auto;
  }
}

/* ---------- 600px and below: the sheet shows Supplier, Invoice, Total and Check ---------- */

@media (max-width: 600px) {
  #demo .ip-app {
    --cols: 26px minmax(0, 1fr) 62px 66px 20px;
  }

  #demo .ip-app .ip-c-due,
  #demo .ip-app .ip-c-category,
  #demo .ip-app .ip-c-location {
    display: none;
  }

  #demo .ip-sh-row.is-match .ip-c-total {
    visibility: hidden;
  }

  #demo .ip-mpill {
    font-size: 10px;
    padding: 2px 4px;
  }

  #demo .ip-view button {
    min-height: 30px;
    padding: 0 8px;
    font-size: 13px;
  }

  #demo .ip-ex-id > .mono {
    display: none;
  }

  #demo .ip-fields {
    gap: 9px 10px;
  }

  #demo .ip-val {
    font-size: 14.5px;
  }

  #demo .ip-cell--total .ip-val {
    font-size: 16.5px;
  }
}

@media (max-width: 480px) {
  #demo .ip-label {
    height: auto;
    min-height: 28px;
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  #demo .ip-label > .ip-view {
    max-width: 100%;
  }

  #demo .ip-books-head {
    gap: 10px;
    padding: 12px;
  }

  #demo .ip-count--in .ip-roll {
    font-size: 26px;
  }
}

@media (pointer: coarse) {
  #demo .ip-view button,
  #demo .ip-nav button {
    min-height: 40px;
  }
}

/* Touch targets: 44px tall and wide on tablets and phones (the visual pill can stay smaller) */
@media (max-width: 834px) {
  #demo .ip-view button,
  #demo .ip-nav button,
  #demo .demo-side-nav button {
    min-height: 44px;
  }

  #demo .ip-view button,
  #demo .demo-speed button {
    min-width: 44px;
  }

  #demo .demo-speed button {
    min-height: 44px;
  }
}

/* ---------- Keyframes ---------- */

@keyframes ip-picked {
  0% {
    outline-color: var(--accent);
  }
  100% {
    outline-color: transparent;
  }
}

@keyframes ip-flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes ip-box-in {
  from {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes ip-snap {
  from {
    opacity: 0;
    transform: scale(1.3);
  }
}

@keyframes ip-scan {
  0% {
    top: -2px;
    opacity: 1;
  }
  90% {
    top: 100%;
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

@keyframes ip-stamp {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.6);
  }
  to {
    opacity: 0.9;
    transform: translate(-50%, -50%) rotate(-12deg) scale(1);
  }
}

@keyframes ip-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

@keyframes ip-shim {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

@keyframes ip-cell-flash {
  0% {
    background: rgb(255 255 255 / 0.07);
  }
  100% {
    background: transparent;
  }
}

@keyframes ip-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes ip-bar {
  0% {
    transform: scaleX(0);
    opacity: 1;
  }
  40% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}

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

@keyframes ip-roll-out {
  to {
    opacity: 0;
    transform: translateY(-100%);
  }
}

@keyframes ip-roll-in {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
}

@keyframes ip-plus-up {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-14px);
  }
}

@keyframes ip-cellfill {
  from {
    background-color: var(--gs-bg);
  }
  to {
    background-color: var(--gs-new);
  }
}

@keyframes ip-pulse2 {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@keyframes ip-card-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
}

@keyframes ip-card-glow {
  from {
    box-shadow: 0 0 0 1px hsl(0 70% 52% / 0.5), 0 0 28px -6px hsl(0 70% 52% / 0.45);
  }
  to {
    box-shadow: 0 0 0 1px hsl(0 70% 52% / 0), 0 0 28px -6px hsl(0 70% 52% / 0);
  }
}

@keyframes ip-press {
  0% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Static (seeked finished state) and reduced motion: nothing animates ---------- */

#demo .ip-demo-stage.is-static *,
#demo .ip-demo-stage.is-static *::before,
#demo .ip-demo-stage.is-static *::after {
  transition: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  #demo .ip-demo-stage *,
  #demo .ip-demo-stage *::before,
  #demo .ip-demo-stage *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* The gold phrase of the heading moves to its own line as a whole */
#demo .sec-title .gold-i {
  display: inline-block;
}
