/* Sections 07-10 of automation 09 (Invoice Processing Pipeline): #features, #dashboard, #stack
   and #industries. Every rule is scoped under its section id; every class invented here starts
   with ip-. Shared pieces come from features.css, dashboard.css and site.css. */

/* Closing footnav (09): the Next link has a 44px hit area, like the Prev and All automations links */
#footnav .ip-next-link {
  padding: 14px 0;
  margin: -14px 0;
}


/* ---------- 07 / Features: every title reserves two lines, so each body starts on the same y ---------- */

#features .features-tile .cell-t {
  min-height: 2.3em;
  max-width: 14ch;
  text-wrap: pretty;
}

#features .features-tile .cell-p {
  text-wrap: pretty;
}

@media (min-width: 1280px) {
  #features .features-tile .cell-t {
    max-width: 20ch;
  }
}

/* One column on phones: titles run on one line where they fit, with no reserved gap */
@media (max-width: 639px) {
  #features .features-tile .cell-t {
    min-height: 0;
    max-width: none;
  }
}

/* ---------- 08 / Dashboard: warning token (amber, distinct from gold) ---------- */

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

/* ---------- Window body: sidebar | main ---------- */

#dashboard .ip-dash-body {
  display: block;
}

@media (min-width: 1280px) {
  #dashboard .ip-dash-body {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
  }
}

#dashboard .ip-dash-main {
  min-width: 0;
}

/* Labels and sub-lines wrap rather than truncate: the cards are narrow at 1280 and 390 */
#dashboard .ip-dash .dashboard-stat-l,
#dashboard .ip-dash .dashboard-stat-s,
#dashboard .ip-dash .dashboard-meta {
  white-space: normal;
  text-overflow: clip;
}

#dashboard .ip-dash .dashboard-stat-l {
  text-wrap: balance;
}

/* The window title may wrap on phones instead of being cut off */
#dashboard .ip-dash .dashboard-bar-title {
  white-space: normal;
  line-height: 1.4;
}

@media (max-width: 639px) {
  #dashboard .ip-dash .dashboard-bar {
    height: auto;
    min-height: 40px;
    padding-block: 10px;
  }
}

/* The footer keeps "Synced from your books" on phones too */
#dashboard .ip-dash .dashboard-foot-sync {
  display: inline;
}

#dashboard .ip-dash .dashboard-stat-n {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------- Panels: heading block, columns ---------- */

#dashboard .ip-head {
  display: grid;
  gap: 6px;
  min-width: 0;
}

#dashboard .ip-block {
  min-width: 0;
}

#dashboard .ip-block .dashboard-toolbar {
  padding-bottom: 16px;
  align-items: flex-start;
}

#dashboard .ip-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

#dashboard .ip-block + .ip-block {
  border-top: 1px solid var(--line);
}

#dashboard .ip-due-sum {
  flex: none;
  padding-top: 2px;
}

@media (min-width: 1024px) {
  #dashboard .ip-columns {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-areas:
      "spend due"
      "log log";
  }

  #dashboard .ip-spend {
    grid-area: spend;
    border-right: 1px solid var(--line);
  }

  #dashboard .ip-due {
    grid-area: due;
    border-top: 0;
  }

  #dashboard .ip-log-block {
    grid-area: log;
  }
}

/* ---------- Spend by supplier: rows with a bar under each ---------- */

#dashboard .ip-bars {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0 20px 20px;
  list-style: none;
}

#dashboard .ip-bar-row {
  display: grid;
  gap: 8px;
  min-width: 0;
}

#dashboard .ip-bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

#dashboard .ip-bar-name {
  min-width: 0;
  font-size: 15px;
  line-height: 1.3;
  color: var(--bone);
  text-wrap: pretty;
}

#dashboard .ip-bar-figs {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

#dashboard .ip-bar-val {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--bone);
}

#dashboard .ip-bar-chg {
  min-width: 4.2em;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: 0.06em;
  color: var(--ash);
}

#dashboard .ip-bar-chg.is-warn {
  color: var(--ip-warn);
}

#dashboard .ip-bar-track {
  display: block;
  height: 4px;
  background: var(--line);
}

#dashboard .ip-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: hsl(42 30% 94% / 0.22);
  transform-origin: left center;
}

#dashboard .ip-bar-fill--gold {
  background: var(--accent);
}

/* Bars grow once when the window scrolls into view. The finished width is already set in the
   markup by the script, so ?static=1, reduced motion and no-JS all show the finished state. */
#dashboard .ip-dash--play .ip-bar-fill {
  animation: ip-grow 0.9s var(--ease-out) both;
  animation-delay: var(--d, 0s);
}

@keyframes ip-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* ---------- Due soon ---------- */

#dashboard .ip-due-list {
  display: grid;
  margin: 0;
  padding: 0 20px 12px;
  list-style: none;
}

#dashboard .ip-due-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
}

#dashboard .ip-due-row:first-child {
  border-top: 0;
}

#dashboard .ip-due-who {
  display: grid;
  gap: 4px;
  min-width: 0;
}

#dashboard .ip-due-name {
  font-size: 15px;
  line-height: 1.3;
  color: var(--bone);
  text-wrap: pretty;
}

#dashboard .ip-due-num {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--ash);
}

#dashboard .ip-due-side {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

#dashboard .ip-due-when {
  min-width: 6.5em;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: 0.06em;
  color: var(--ash);
  white-space: nowrap;
}

#dashboard .ip-due-when.is-warn {
  color: var(--ip-warn);
}

#dashboard .ip-due-amt {
  min-width: 5.5em;
  text-align: right;
  font-size: 15px;
  line-height: 1.3;
  color: var(--bone);
  white-space: nowrap;
}

#dashboard .ip-due-open {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bone-70);
  border-bottom: 1px solid var(--line);
  cursor: default;
  pointer-events: none;
}

/* ---------- Review log: a full-width table, chips by tone ---------- */

#dashboard .ip-log-wrap {
  min-width: 0;
}

#dashboard .ip-log {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 15px;
  line-height: 1.4;
}

#dashboard .ip-log .ip-h-date { width: 11%; }
#dashboard .ip-log .ip-h-inv { width: 13%; }
#dashboard .ip-log .ip-h-sup { width: 22%; }
#dashboard .ip-log .ip-h-reason { width: 24%; }
#dashboard .ip-log .ip-h-out { width: 22%; }
#dashboard .ip-log .ip-h-by { width: 8%; }

#dashboard .ip-log th {
  height: 36px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ash);
  white-space: nowrap;
}

#dashboard .ip-log td {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--bone-80);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

#dashboard .ip-log th:first-child,
#dashboard .ip-log td:first-child {
  padding-left: 20px;
}

#dashboard .ip-log th:last-child,
#dashboard .ip-log td:last-child {
  padding-right: 20px;
}

#dashboard .ip-log tbody tr:last-child td {
  border-bottom: 0;
}

#dashboard .ip-log tbody tr {
  transition: background-color 0.2s var(--ease-std);
}

#dashboard .ip-log tbody tr:hover {
  background: var(--elev);
}

#dashboard .ip-c-date {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ash);
  white-space: nowrap;
}

#dashboard .ip-c-inv {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--bone);
  white-space: nowrap;
}

#dashboard .ip-c-sup {
  color: var(--bone);
}

#dashboard .ip-c-reason {
  color: var(--bone-70);
}

#dashboard .ip-chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 7px 3px;
  border: 1px solid var(--chip-tone);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--chip-tone);
  overflow-wrap: anywhere;
}

#dashboard .ip-chip--fail {
  --chip-tone: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

#dashboard .ip-chip--ok {
  --chip-tone: color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok);
}

#dashboard .ip-chip--info {
  --chip-tone: color-mix(in srgb, var(--info) 45%, transparent);
  color: var(--info);
}

#dashboard .ip-c-by {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}

/* ---------- Phone: 2x2 stats, stacked panels, log as stacked rows ---------- */

@media (max-width: 639px) {
  #dashboard .ip-dash .dashboard-stat-n {
    font-size: 1.5rem;
  }

  #dashboard .ip-dash .dashboard-stat {
    padding: 16px 14px 14px;
  }

  #dashboard .ip-dash-app .dashboard-foot {
    padding: 10px 14px;
    letter-spacing: 0.04em;
  }

  #dashboard .ip-log thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  #dashboard .ip-log,
  #dashboard .ip-log tbody {
    display: block;
    width: 100%;
    table-layout: auto;
  }

  #dashboard .ip-log tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 0;
    padding: 14px 20px;
    border-top: 1px solid var(--line-soft);
    border-bottom: 0;
  }

  #dashboard .ip-log tbody tr:first-child {
    border-top: 0;
  }

  #dashboard .ip-log tbody tr:hover {
    background: transparent;
  }

  #dashboard .ip-log td,
  #dashboard .ip-log td:first-child,
  #dashboard .ip-log td:last-child {
    display: block;
    height: auto;
    padding: 0;
    border: 0;
    white-space: normal;
    line-height: 1.4;
  }

  /* Line 1: date · invoice. Line 2: supplier. Line 3: reason. Line 4: outcome chip, then by. */
  #dashboard .ip-c-date {
    order: 1;
    flex: none;
  }

  #dashboard .ip-c-inv {
    order: 2;
    flex: none;
  }

  #dashboard .ip-c-inv::before {
    content: "·";
    margin: 0 8px;
    color: var(--ash);
  }

  #dashboard .ip-c-sup {
    order: 3;
    flex: 0 0 100%;
    margin-top: 6px;
    font-size: 16px;
    font-weight: 500;
  }

  #dashboard .ip-c-reason {
    order: 4;
    flex: 0 0 100%;
    margin-top: 4px;
    font-size: 15px;
  }

  #dashboard .ip-c-out {
    order: 5;
    flex: none;
    margin-top: 10px;
    max-width: 100%;
  }

  #dashboard .ip-c-by {
    order: 6;
    margin-left: auto;
    margin-top: 10px;
  }
}

/* ---------- Due soon and spend rows on phones: keep figures on one line ---------- */

@media (max-width: 639px) {
  #dashboard .ip-due-list,
  #dashboard .ip-bars {
    padding-left: 14px;
    padding-right: 14px;
  }

  #dashboard .ip-block .dashboard-toolbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  #dashboard .ip-due-when {
    min-width: 0;
  }

  #dashboard .ip-due-amt {
    min-width: 0;
  }
}

/* ---------- 09 / Stack: seven tools on hairlines ----------
   Each cell draws its own hairlines, so any column count works. 7 across from 1280,
   4 + 3 from 1024, 2 wide from 640 and one wide below that. */

#stack .ip-stack {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#stack .ip-stack > * {
  min-width: 0;
  padding: 28px 22px;
  border-left: 0;
  border-top: 0;
}

#stack .ip-stack .features-glyph {
  margin-bottom: 24px;
}

/* The caption sits 24px under the grid at every width */
#stack .features-caption {
  margin-top: 24px;
}

#stack .ip-tool-text {
  display: grid;
  gap: 8px;
  min-width: 0;
}

/* Names may take two lines ("OpenAI / Claude (vision)"), so every line of copy starts on the same y */
@media (min-width: 640px) {
  #stack .ip-tool-text .features-tool-n {
    min-height: 2.5em;
  }
}

#stack .ip-tool-r {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ash);
  text-wrap: pretty;
}

#stack .ip-stack > *:hover .ip-tool-r {
  color: var(--bone-70);
}

@media (min-width: 1280px) {
  #stack .ip-stack {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  #stack .ip-stack > *:nth-child(n + 2) {
    border-left: 1px solid var(--line);
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  #stack .ip-stack > *:nth-child(4n + 2),
  #stack .ip-stack > *:nth-child(4n + 3),
  #stack .ip-stack > *:nth-child(4n + 4) {
    border-left: 1px solid var(--line);
  }

  #stack .ip-stack > *:nth-child(n + 5) {
    border-top: 1px solid var(--line);
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  #stack .ip-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #stack .ip-stack > *:nth-child(2n) {
    border-left: 1px solid var(--line);
  }

  #stack .ip-stack > *:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 639px) {
  #stack .ip-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  #stack .ip-stack > *:nth-child(n + 2) {
    border-top: 1px solid var(--line);
  }

  /* One tool per row: glyph on the left, name with its line of copy beside it */
  #stack .ip-stack > * {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 0;
  }

  #stack .ip-stack .features-glyph {
    flex: none;
    margin: 2px 0 0;
  }

  #stack .ip-stack .ip-tool-r {
    font-size: 1rem;
  }
}

/* ---------- 10 / Built for: name and one line per row ---------- */

#industries .ip-ind-row {
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  padding: 24px 0;
}

#industries .ip-ind-text {
  display: grid;
  gap: 8px;
  min-width: 0;
}

#industries .ip-ind-row .features-hex {
  margin-top: 8px;
}

#industries .ip-ind-line {
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ash);
  text-wrap: pretty;
}

@media (max-width: 767px) {
  #industries .ip-ind-row {
    min-height: 0;
    padding: 20px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #dashboard .ip-dash--play .ip-bar-fill {
    animation: none;
  }
}
