/* =============================================================================
   Inventario — stock + ledger tool
   Implemented from the Claude Design project "Inventario" (2191f8ad),
   files "Inventario.dc.html" (phone) and "Inventario Desktop.dc.html" (wide).

   MOBILE FIRST on purpose: the phone layout is the base and should feel like
   an app — bottom tab bar, thumb-reachable add/remove buttons, sheets that
   rise from the bottom. The desktop design is the >=900px branch of the same
   markup: two columns, a right-hand drawer, and buttons back up in the header.

   Colors, buttons, chips, fields, cards, the sheet and the toast come from
   /ds/. What is here is this tool's layout and its own pieces.
   ========================================================================== */

:root {
  /* home indicator / notch on phones */
  --inv-safe-b: env(safe-area-inset-bottom, 0px);
}

html, body { -webkit-text-size-adjust: 100%; }

.inv-app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- header -- */

.inv-header {
  position: sticky; top: 0; z-index: var(--z-header);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hb-line);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.inv-brand { display: flex; flex-direction: column; gap: 4px; }
.inv-wordmark { font-size: 20px; font-weight: 700; letter-spacing: -.01em; line-height: 1; }

.inv-who {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-ui-md); font-weight: 600; color: var(--hb-ink-soft);
  min-width: 0;
}
.inv-who-name {
  max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inv-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-pill); flex-shrink: 0;
  background: var(--hb-sol-light); color: var(--hb-chalkboard);
  font-size: var(--fs-ui-sm); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* header controls live here on desktop, in the Counts view on mobile */
.inv-header-tools { display: none; }

/* ------------------------------------------------------------------ main -- */

.inv-main {
  flex: 1; width: 100%; max-width: 1360px; margin: 0 auto;
  padding: 16px 16px calc(96px + var(--inv-safe-b));
}

.inv-panel {
  background: var(--hb-paper); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.inv-panel + .inv-panel { margin-top: 16px; }

.inv-panel-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--hb-line);
}
.inv-eyebrow { font-size: var(--fs-ui-md); font-weight: 700; letter-spacing: .12em; }
.inv-panel-meta { font-size: var(--fs-ui-sm); color: var(--hb-ink-soft); }

/* the phone shows one tab at a time; the desktop shows both panels at once */
[data-phone-hidden="true"] { display: none; }

/* ---------------------------------------------------------------- filters -- */

/* inside the card, so it needs the card's padding itself */
.inv-filters { display: flex; flex-direction: column; gap: 10px; padding: 16px 16px 0; margin-bottom: 12px; }

.inv-filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.inv-pill { height: 40px; }
.inv-select { height: 40px; }
.inv-search { height: 46px; }

/* ------------------------------------------------------------ count rows -- */

.inv-group-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 18px 8px; background: var(--hb-cloud);
  border-bottom: 1px solid var(--hb-line);
}
.inv-group-name { flex: 1; font-size: var(--fs-ui-md); font-weight: 700; letter-spacing: .1em; }
.inv-group-meta { font-size: var(--fs-ui-sm); color: var(--hb-ink-soft); }

/* the desktop column header — hidden on phones, where rows are cards */
.inv-cols { display: none; }

.inv-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  grid-template-areas:
    "thumb main count"
    "thumb sub  sub";
  gap: 2px 12px; align-items: start;
  padding: 12px 16px; border-bottom: 1px solid var(--hb-line);
  width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0;
  color: inherit; font: inherit;
}
.inv-thumb { grid-area: thumb; }
.inv-row-main { grid-area: main; }
.inv-row-sub { grid-area: sub; }
.inv-count { grid-area: count; }
.inv-row[data-expandable="true"] { cursor: pointer; }
.inv-row:hover { background: var(--hb-cloud-soft); }
.inv-row:last-child { border-bottom: 0; }

.inv-thumb {
  width: 52px; height: 52px; border-radius: var(--radius-btn); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-ui-md); font-weight: 700; letter-spacing: .04em;
  background-size: cover; background-position: center;
  flex-shrink: 0;
}

.inv-row-main {
  min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 4px 8px; padding-top: 2px;
}
.inv-row-name { font-size: var(--fs-ui-lg); font-weight: 600; line-height: 1.3; }
.inv-row-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.inv-sku { font-size: var(--fs-ui-sm); color: var(--hb-ink-soft); letter-spacing: .06em; }
.inv-chev { font-size: var(--fs-ui-xs); color: var(--hb-ink-soft); }

.inv-count { display: flex; align-items: baseline; gap: 5px; padding-top: 2px; }
.inv-count b { font-size: 19px; font-weight: 700; line-height: 1; padding: 4px 6px; border-radius: var(--radius-btn-sm); }
.inv-count span { font-size: var(--fs-ui-xs); color: var(--hb-ink-soft); }
.inv-count[data-low="true"] b { background: var(--hb-adobe-light); color: var(--hb-adobe-ink); }

/* what a bundle contains */
.inv-contains {
  flex-basis: 100%;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 0 2px; animation: invExpand .28s var(--ease-out) both;
}
.inv-contains-label { font-size: var(--fs-ui-2xs); font-weight: 700; letter-spacing: .12em; color: var(--hb-ink-soft); }
.inv-part {
  display: flex; gap: 10px; align-items: baseline;
  font-size: var(--fs-ui-md); padding: 3px 8px; margin: 0 -8px; border-radius: 6px;
}
.inv-part[data-bottleneck="true"] { background: var(--hb-adobe-light); }
.inv-part-qty { font-weight: 700; min-width: 28px; }
.inv-part-name { flex: 1; min-width: 0; }
.inv-part-sku { font-size: var(--fs-ui-xs); letter-spacing: .06em; color: var(--hb-ink-soft); }
.inv-part-avail { font-weight: 700; min-width: 32px; text-align: right; }

@keyframes invExpand { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* --------------------------------------------------------------- activity -- */

.inv-txn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--hb-line);
}
.inv-txn:last-child { border-bottom: 0; }
.inv-txn-glyph {
  width: 34px; height: 34px; border-radius: var(--radius-pill); flex-shrink: 0;
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.inv-txn[data-dir="in"] .inv-txn-glyph { background: var(--hb-agave-light); color: var(--hb-agave-ink); }
.inv-txn[data-dir="out"] .inv-txn-glyph { background: var(--hb-adobe-light); color: var(--hb-adobe-ink); }
.inv-txn[data-dir="flat"] .inv-txn-glyph { background: var(--hb-cloud); color: var(--hb-muted); }
.inv-txn-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.inv-txn-name { font-size: var(--fs-ui); font-weight: 600; line-height: 1.25; }
.inv-txn-meta { font-size: var(--fs-ui-xs); color: var(--hb-ink-soft); }
.inv-txn-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.inv-txn-qty { font-size: var(--fs-ui-lg); font-weight: 700; }
.inv-txn[data-dir="in"] .inv-txn-qty { color: var(--hb-agave-ink); }
.inv-txn[data-dir="out"] .inv-txn-qty { color: var(--hb-adobe-ink); }
.inv-txn-time { font-size: var(--fs-ui-xs); color: var(--hb-muted); }

/* ------------------------------------------------------------ empty/state -- */

.inv-empty { margin: 16px; }

.inv-notice {
  margin: 16px; padding: 16px 18px; border-radius: var(--radius-card);
  background: var(--hb-sol-light); color: var(--hb-sol-ink);
  font-size: var(--fs-ui); line-height: 1.5;
}
.inv-notice b { display: block; margin-bottom: 4px; color: var(--hb-chalkboard); }

/* ----------------------------------------------------------------- FABs --- */

/* pulled in from the screen edge so they ride on top of the counts card
   rather than beside it */
.inv-fabs {
  position: fixed; right: 28px; z-index: var(--z-fab);
  bottom: calc(76px + var(--inv-safe-b));
  display: flex; flex-direction: column; gap: 12px;
}
.inv-fab {
  width: 56px; height: 56px; border-radius: var(--radius-pill); border: none;
  font-size: 26px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-fab);
  transition: transform .18s var(--ease-bounce);
}
.inv-fab:active { transform: scale(.94); }
.inv-fab[data-sign="add"] { background: var(--hb-agave); color: var(--hb-chalkboard); }
.inv-fab[data-sign="remove"] { background: var(--hb-adobe-light); color: var(--hb-adobe-ink); }

/* -------------------------------------------------------------- bottom nav */

.inv-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px); border-top: 1px solid var(--hb-line);
  padding-bottom: var(--inv-safe-b);
}
.inv-nav button {
  flex: 1; min-height: 60px; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--hb-muted); font-size: var(--fs-ui-xs); font-weight: 600;
}
.inv-nav button[aria-current="page"] { color: var(--hb-chalkboard); }
.inv-nav .inv-nav-icon { font-size: var(--fs-ui-xl); line-height: 1; }

/* ------------------------------------------------------------- draft sheet
   (the scrim + sheet are hb-scrim--sheet / hb-sheet from /ds/dialog.css) */

.inv-draft {
  border-radius: var(--radius-card); padding: 16px;
  box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column; gap: 14px;
}
.inv-draft-head { display: flex; align-items: center; gap: 10px; }
.inv-draft-sign {
  width: 28px; height: 28px; border-radius: var(--radius-pill); background: var(--hb-paper);
  font-size: 18px; font-weight: 700; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.inv-draft-title { flex: 1; font-size: var(--fs-ui-lg); font-weight: 700; }
.inv-draft-close {
  width: 44px; height: 44px; margin: -8px -8px -8px 0;
  border: none; background: transparent; color: var(--hb-chalkboard);
  font-size: 20px; cursor: pointer; border-radius: var(--radius-pill);
}

.inv-peek {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border: none; border-radius: var(--radius-card);
  box-shadow: var(--shadow-md); cursor: pointer; text-align: left;
}
.inv-peek-title { flex: 1; min-width: 0; font-size: var(--fs-ui); font-weight: 600; color: var(--hb-chalkboard); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.inv-picked {
  display: flex; align-items: center; gap: 10px;
  background: var(--hb-paper); border-radius: var(--radius-card); padding: 10px 12px;
}
.inv-picked-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inv-picked-name { font-size: var(--fs-ui); font-weight: 600; }
.inv-picked-sub { font-size: var(--fs-ui-xs); color: var(--hb-ink-soft); letter-spacing: .06em; }

.inv-results {
  background: var(--hb-paper); border-radius: var(--radius-card); overflow: hidden;
  box-shadow: var(--shadow-sm); max-height: 260px; overflow-y: auto;
}
.inv-result {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 48px; padding: 8px 12px;
  border: none; border-bottom: 1px solid var(--hb-line);
  background: transparent; cursor: pointer; text-align: left;
}
.inv-result:hover { background: var(--hb-cloud); }
.inv-result:last-child { border-bottom: 0; }
.inv-result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inv-result-name { font-size: var(--fs-ui); font-weight: 600; color: var(--hb-chalkboard); }
.inv-result-sku { font-size: var(--fs-ui-xs); color: var(--hb-ink-soft); letter-spacing: .06em; }
.inv-result-count { font-size: var(--fs-ui-sm); color: var(--hb-ink-soft); white-space: nowrap; }

.inv-field { display: flex; flex-direction: column; gap: 6px; }
.inv-field-label { font-size: var(--fs-ui-sm); font-weight: 600; letter-spacing: .1em; }

.inv-stepper {
  display: flex; align-items: center; background: var(--hb-paper);
  border-radius: var(--radius-card); overflow: hidden; width: max-content;
}
.inv-stepper button {
  width: 48px; height: 48px; border: none; background: transparent;
  font-size: 20px; color: var(--hb-chalkboard); cursor: pointer;
}
.inv-stepper button:active { transform: scale(.94); }
.inv-stepper input {
  width: 64px; height: 48px; border: none; background: transparent;
  text-align: center; font-size: var(--fs-ui-xl); font-weight: 700; color: var(--hb-chalkboard);
}

.inv-toggle { display: flex; background: var(--hb-paper); border-radius: var(--radius-card); padding: 4px; gap: 4px; }
.inv-toggle button {
  min-height: 40px; padding: 0 14px; border: none; border-radius: 9px;
  background: transparent; color: var(--hb-ink-soft);
  font-size: var(--fs-ui-md); font-weight: 600; cursor: pointer;
}
.inv-toggle button[aria-pressed="true"][data-sign="add"] { background: var(--hb-agave); color: var(--hb-chalkboard); }
.inv-toggle button[aria-pressed="true"][data-sign="remove"] { background: var(--hb-adobe-light); color: var(--hb-adobe-ink); }

.inv-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.inv-draft-actions { display: flex; gap: 10px; padding-top: 2px; }
.inv-draft-btn { flex: 1; min-height: 50px; font-weight: 700; }
.inv-draft-btn.hb-btn--outline { border: 2px solid var(--hb-chalkboard); }
.inv-draft-btn--main { flex: 1.4; }

/* ---------------------------------------------------------------- toast ---
   hb-toast, lifted above the phone tab bar */
.inv-toast { bottom: calc(84px + var(--inv-safe-b)); }

/* ---------------------------------------------------------------- login --- */

.inv-gate {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.inv-gate-card h1 { margin: 0; font-size: 22px; font-weight: 700; }
.inv-gate-card p { margin: 0; font-size: var(--fs-ui); color: var(--hb-ink-soft); line-height: 1.5; }

/* =========================================================================
   DESKTOP — the "Inventario Desktop" design.
   Same markup: the tab bar and FABs give way to header buttons, the two
   panels sit side by side, and the sheet becomes a right-hand drawer.
   ========================================================================= */

@media (min-width: 900px) {
  .inv-header { padding: 14px 24px; gap: 12px 16px; flex-wrap: wrap; }
  .inv-header-tools { display: flex; align-items: center; gap: 12px; flex: 1; flex-wrap: wrap; }
  .inv-header-tools .inv-search { width: min(380px, 100%); height: 44px; font-size: var(--fs-ui); }
  .inv-header-tools .inv-pill, .inv-header-tools .inv-select { height: 44px; }
  .inv-header-spacer { flex: 1; }

  .inv-action { height: 44px; font-weight: 700; box-shadow: var(--shadow-sm); }
  .inv-action[data-sign="add"], .inv-action[data-sign="add"]:hover { background: var(--hb-agave); color: var(--hb-chalkboard); }
  .inv-action[data-sign="remove"], .inv-action[data-sign="remove"]:hover { background: var(--hb-adobe-light); color: var(--hb-adobe-ink); }

  /* the phone-only chrome steps aside */
  .inv-nav, .inv-fabs { display: none; }
  .inv-filters { display: none; }

  .inv-main {
    padding: 24px;
    display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start;
  }
  .inv-panel { margin: 0; }
  [data-phone-hidden="true"] { display: flex; }
  .inv-panel-counts { flex: 1 1 620px; min-width: 0; display: flex; flex-direction: column; }
  .inv-panel-activity {
    flex: 1 1 320px; min-width: 280px;
    position: sticky; top: 97px; max-height: calc(100dvh - 121px);
    display: flex; flex-direction: column;
  }
  .inv-panel-activity .inv-scroll { flex: 1; overflow-y: auto; }
  .inv-panel + .inv-panel { margin-top: 0; }

  /* table layout with a real column header */
  .inv-cols {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 92px 128px 96px;
    gap: 0 12px; padding: 10px 24px;
    border-bottom: 1px solid var(--hb-line); background: var(--hb-cloud);
  }
  .inv-cols div { font-size: var(--fs-ui-xs); font-weight: 700; letter-spacing: .12em; }
  .inv-cols div:last-child { text-align: right; }

  .inv-row {
    grid-template-columns: 64px minmax(0, 1fr) 92px 128px 96px;
    grid-template-areas: none;              /* five real columns, one row */
    padding: 12px 24px;
  }
  /* drop the phone's named areas, so children place in source order:
     thumb | product | type | sku | units */
  .inv-row > * { grid-area: auto; }
  /* lift badge + SKU out of their wrapper so each lands in its own column */
  .inv-row .inv-row-sub { display: contents; }
  .inv-row .inv-badge { align-self: start; justify-self: start; margin-top: 6px; }
  .inv-row .inv-sku { align-self: start; margin-top: 7px; font-size: var(--fs-ui-sm); }
  .inv-count { justify-content: flex-end; }

  .inv-group-head, .inv-panel-head { padding-left: 24px; padding-right: 24px; }
  .inv-txn { padding: 12px 20px; }

  .inv-who-name { max-width: 220px; }
  .inv-toast { bottom: 32px; }
}

