/* AI automation hero window: a PDF invoice is read, its fields fill a form with check chips, the dashboard updates.
   Shell and tokens (.app, .app__bar, .status, .mod) come from /style.css. Layout follows the main column's own
   width (container queries), so the 1101-1300px desktops and the phones get the stacked versions. */
.ai .side__pill { transform: translateY(96px); } /* finished state sits on Dashboard (three 30px rows + 2px gaps down); hero.js moves it with y */
.ai .app__main { container: ai-main / inline-size; }

/* Document beside the form it fills */
.ai-read { display: grid; grid-template-columns: 136px minmax(0, 1fr); gap: 10px; }

/* The PDF: a white page in a grey viewer, drawn small */
.ai-doc { display: grid; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--muted); }
.ai-page { position: relative; display: grid; align-content: start; gap: 6px; padding: 9px 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 3px; background: var(--bg); font-size: 9.5px; line-height: 1.25; }
.ai-page__t { font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.ai-page__n, .ai-page__r { color: var(--muted-fg-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-page__s { margin-top: 2px; font-weight: 700; white-space: nowrap; }
.ai-page__a, .ai-page__i { display: grid; gap: 4px; }
.ai-page__a i, .ai-page__i i { position: relative; display: block; height: 4px; border-radius: 2px; }
.ai-page__a i { width: 80%; background: var(--line); }
.ai-page__a i + i { width: 58%; }
.ai-page__i { margin-top: 3px; }
.ai-page__i i::before, .ai-page__i i::after { content: ""; position: absolute; top: 0; height: 4px; border-radius: 2px; background: var(--line); }
.ai-page__i i::before { left: 0; width: 56%; }
.ai-page__i i::after { right: 0; width: 26%; }
.ai-page__o { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: 6px; padding-top: 5px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.ai-page__o b { font-weight: 700; }
/* What the AI is reading right now: a coral frame on the page */
.ai [data-hit] { justify-self: start; border-radius: 2px; outline: 1.5px solid transparent; outline-offset: 2px; } /* an outline, so the frame never widens the page's text boxes */
.ai .ai-page__o { justify-self: stretch; }
.ai [data-hit].is-hit { outline-color: var(--coral); }
.ai-scan { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--coral); opacity: 0; pointer-events: none; }
.ai-scan::before { content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 14px; background: rgba(255, 152, 107, .16); }

/* The form the AI fills (shadcn Card with Inputs and Badges) */
.ai-form { container: ai-form / inline-size; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; padding-bottom: 5px; }
.ai-form__head { display: flex; align-items: center; gap: 8px; height: 34px; margin-bottom: 5px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.ai-form__head b { font-weight: 600; white-space: nowrap; }
.ai-form__head span { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--muted-fg); font-size: 12px; white-space: nowrap; }
.ai-form__head svg { width: 13px; height: 13px; color: var(--coral); }
.ai-f { display: grid; grid-template-columns: 70px minmax(0, 1fr); align-items: center; column-gap: 8px; height: 35px; padding: 0 12px; }
.ai-f > span { color: var(--muted-fg-2); font-size: 12px; white-space: nowrap; }
.ai-in { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 8px; border: 1px solid var(--line); border-radius: 6px; }
.ai-in b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-chip { display: inline-flex; align-items: center; flex: none; height: 18px; margin-left: auto; padding: 0 6px; border: 1px solid; border-radius: 5px; font-size: 11px; font-style: normal; font-weight: 600; white-space: nowrap; }
.ai-chip--ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.ai-chip--chk { color: var(--wait); background: var(--wait-bg); border-color: var(--wait-line); }

/* Dashboard tiles */
.ai-tiles { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, .85fr) minmax(0, .85fr); gap: 10px; }
.ai-tile { display: grid; align-content: start; gap: 4px; min-width: 0; padding: 11px 12px 12px; border: 1px solid var(--line); border-radius: 10px; }
.ai-tile small { color: var(--muted-fg); font-size: 11.5px; white-space: nowrap; }
.ai-tile b { font-size: 16px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-bars { display: flex; align-items: flex-end; gap: 3px; height: 23px; }
.ai-bars i { flex: 1; height: 100%; border-radius: 2px; background: #d4d4d8; transform-origin: bottom; transform: scaleY(var(--h)); }
.ai-bars i:last-child { background: var(--coral); }

/* Narrow form: label above its input */
@container ai-form (max-width: 269px) {
  .ai-f { grid-template-columns: minmax(0, 1fr); row-gap: 2px; height: auto; padding: 3px 12px 4px; }
  .ai-f[data-f="no"] { display: none; } /* three fields keep the stacked form short; the page still shows the number */
  .ai-form__head span { display: none; } /* the caption under the window says it is the AI */
}
/* Narrow main column: the page turns landscape above the form, tiles go two by two */
@container ai-main (max-width: 399px) {
  .ai-read { grid-template-columns: minmax(0, 1fr); }
  .ai-page { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "s t" "a n" "i r" "i o"; column-gap: 12px; row-gap: 5px; }
  .ai-page__t { grid-area: t; justify-self: end; }
  .ai .ai-page__n { grid-area: n; justify-self: end; }
  .ai .ai-page__s { grid-area: s; margin-top: 0; }
  .ai-page__a { grid-area: a; }
  .ai-page__i { grid-area: i; margin-top: 0; }
  .ai .ai-page__r { grid-area: r; justify-self: end; }
  .ai .ai-page__o { grid-area: o; }
  .ai-tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ai-tile:first-child { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .ai .ai-crumb { display: none; } /* the bar keeps the file name and the status badge */
  .ai .foot__state { white-space: normal; }
}
