/* Availability (#units): live summary strip, toolbar, table polish, mobile cards
   with plan thumbnails, and the cursor-follow floor plan peek.
   Loaded after app.css. Everything is scoped to #units or prefixed inv-. */

/* ---------- Summary strip ---------- */
.inv-sum {
  display: grid;
  grid-template-columns: 1.25fr repeat(4, minmax(0, 1fr));
  gap: 20px 28px;
  margin: 0 0 28px;
  padding: 24px 28px;
  border-radius: var(--r-card);
  background: var(--ash);
}
.inv-sum .cell { display: flex; flex-direction: column; min-width: 0; }
.inv-sum .k { font-size: 12.5px; font-weight: 600; letter-spacing: .01em; color: var(--pewter); }
.inv-sum .v {
  margin-top: 8px;
  font-size: clamp(28px, 2.6vw, 38px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--carbon);
  font-variant-numeric: proportional-nums lining-nums;
  white-space: nowrap;
}
.inv-sum .s { margin-top: 6px; font-size: 13px; line-height: 1.4; color: var(--pewter); font-variant-numeric: tabular-nums lining-nums; }
.inv-sum .cell.zero .v, .inv-sum .cell.zero .s { color: var(--fog); }
.inv-meter { display: flex; gap: 2px; height: 3px; margin-top: 14px; border-radius: 2px; overflow: hidden; }
.inv-meter:empty { display: none; }
.inv-meter i { flex: 0 1 0; min-width: 2px; }
.inv-meter .a { background: var(--available); }
.inv-meter .r { background: var(--reserved); }
.inv-meter .x { background: var(--sold); opacity: .5; }

@media (max-width: 1100px) {
  .inv-sum { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .inv-sum .cell { grid-column: span 2; }
  .inv-sum .cell:nth-child(n + 4) { grid-column: span 3; }
}
@media (max-width: 560px) {
  .inv-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; padding: 20px 18px; margin-bottom: 24px; }
  .inv-sum .cell, .inv-sum .cell:nth-child(n + 4) { grid-column: span 1; }
  .inv-sum .cell.lead { grid-column: 1 / -1; }
  .inv-sum .v { font-size: 28px; }
}

/* ---------- Toolbar ---------- */
/* Desktop: search, scope and actions on one line; type and size filters beneath. */
#units .inv-tools {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "search scope . actions" "filters filters filters filters";
  gap: 14px 16px;
  align-items: center;
  justify-content: stretch;
  margin-bottom: 16px;
}
.inv-search { grid-area: search; }
.inv-search input { width: 260px; }
.inv-scope { grid-area: scope; }
.inv-actions { grid-area: actions; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.inv-filters { grid-area: filters; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 28px; min-width: 0; }
.inv-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.inv-lbl { font-size: 12.5px; font-weight: 600; color: var(--fog); }
.inv-clear { font-size: 13px; }
@media (max-width: 1100px) {
  #units .inv-tools {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "search scope" "filters filters" "actions actions";
  }
  .inv-scope { justify-self: end; }
  .inv-actions { justify-content: flex-start; }
}
#units .chip .n:empty, .inv-scope .n:empty { display: none; }
#units .chip.zero { color: var(--fog); }
#units .chip.zero:hover { color: var(--pewter); }

.inv-scope { flex: 0 0 auto; }
.inv-scope button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.inv-scope button:hover { color: var(--carbon); }
.inv-scope button[aria-pressed="true"] { background: var(--canvas); color: var(--carbon); }
.inv-scope .n { color: var(--fog); font-variant-numeric: tabular-nums lining-nums; }

/* ---------- Table ---------- */
table.inv th .inv-sort {
  padding: 0; border: 0; background: none;
  font: inherit; letter-spacing: inherit; color: inherit; text-align: inherit;
  cursor: pointer; transition: color var(--t);
}
table.inv th .inv-sort:hover, table.inv th[aria-sort] { color: var(--carbon); }
table.inv .c-star { width: 44px; padding-right: 0; }
table.inv td.c-star { padding-top: 6px; padding-bottom: 6px; }
table.inv .inv-open {
  padding: 0; border: 0; background: none;
  font: inherit; font-weight: 600; color: inherit; cursor: pointer;
  font-variant-numeric: tabular-nums lining-nums;
}
table.inv td b { font-weight: 600; }
table.inv td.c-price { font-weight: 500; }
table.inv td.c-rate { color: var(--pewter); }
table.inv tr.is-sold td { color: var(--fog); }
table.inv:not(.show-status) .c-status { display: none; }
table.inv tbody tr:focus-within { background: var(--ash); }
.inv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* Empty state (table row and card list) */
table.inv tbody tr.inv-empty { cursor: default; }
table.inv tbody tr.inv-empty:hover { background: transparent; }
table.inv tr.inv-empty td { padding: 48px 16px; text-align: center; box-shadow: none; }
.inv-empty p { margin: 0 0 10px; font-size: 15px; color: var(--graphite); }
.inv-empty .acts { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; }
div.inv-empty { padding: 32px 16px; border-radius: var(--r-card); background: var(--ash); text-align: center; }

#invSync:not(:empty)::before { content: "\00b7"; margin: 0 8px; }

/* ---------- Mobile cards with plan thumbnails ---------- */
.inv-card {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  column-gap: 14px;
  row-gap: 2px;
  align-items: center;
  padding: 12px 4px 12px 12px;
  border-radius: var(--r-card);
  background: var(--ash);
  transition: background-color var(--t);
  content-visibility: auto;
  contain-intrinsic-size: auto 86px;
}
.inv-card:active { background: var(--ash-2); }
.inv-card-hit { position: absolute; inset: 0; z-index: 1; padding: 0; border: 0; border-radius: inherit; background: transparent; cursor: pointer; }
.inv-card .th { grid-column: 1; grid-row: 1 / 4; width: 76px; height: 60px; border-radius: 8px; background: #fff; overflow: hidden; }
.inv-card .th img { display: block; width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.inv-card .th.err img { visibility: hidden; }
.inv-card .t { grid-column: 2; grid-row: 1; font-size: 16px; font-weight: 600; color: var(--carbon); font-variant-numeric: tabular-nums lining-nums; }
.inv-card .star {
  grid-column: 3; grid-row: 1;
  position: relative; z-index: 2;
  display: grid; place-items: center;
  width: 44px; height: 40px; margin: -8px 0;
  padding: 0; border: 0; background: none;
  color: var(--fog); font-size: 20px; cursor: pointer;
}
.inv-card .star[aria-pressed="true"] { color: var(--accent); }
.inv-card .m { grid-column: 2 / 4; grid-row: 2; padding-right: 8px; font-size: 13px; line-height: 1.4; color: var(--pewter); }
.inv-card .p { grid-column: 2; grid-row: 3; font-size: 15px; font-weight: 500; color: var(--carbon); font-variant-numeric: tabular-nums lining-nums; }
.inv-card .status { grid-column: 3; grid-row: 3; justify-self: end; padding-right: 8px; }
.inv-card.is-sold .t { color: var(--graphite); }

@media (max-width: 760px) {
  #units .inv-tools {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "search" "scope" "filters" "actions";
    gap: 12px;
  }
  .inv-search, .inv-search input { width: 100%; }
  .inv-scope { display: flex; width: 100%; justify-self: stretch; }
  .inv-scope button { flex: 1 1 0; min-width: 0; min-height: 40px; padding: 0 8px; }
  #units .inv-tools .chip, #units .inv-tools .btn.sm { min-height: 40px; }
  .inv-filters { gap: 14px 16px; }
  .inv-group { flex-direction: column; align-items: flex-start; gap: 6px; }
  .inv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #units .inv-actions > * { justify-content: center; background: var(--ash); }
  #units .inv-actions > [aria-pressed="true"] { background: var(--ash-2); }
}

/* ---------- Floor plan peek (desktop hover only) ---------- */
.inv-peek {
  position: fixed; left: 0; top: 0; z-index: 65;
  width: 260px;
  pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .18s ease, visibility 0s linear .18s;
  will-change: transform;
}
.inv-peek.on { opacity: 1; visibility: visible; transition: opacity .18s ease; }
.inv-peek-in {
  padding: 8px;
  border-radius: var(--r-card);
  background: var(--carbon);
  color: #fff;
  transform: scale(.96);
  transition: transform .25s var(--ease);
}
.inv-peek.on .inv-peek-in { transform: none; }
.inv-peek .pl { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; background: #fff; overflow: hidden; }
.inv-peek .pl img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 10px; transition: opacity .2s ease; }
.inv-peek.loading .pl img { opacity: 0; }
.inv-peek.loading .pl { background: linear-gradient(100deg, #fff 35%, var(--ash) 50%, #fff 65%) 0 0 / 300% 100%; animation: inv-shimmer 1.1s linear infinite; }
@keyframes inv-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.inv-peek .ph { position: absolute; inset: 0; display: none; place-items: center; font-size: 13px; color: var(--fog); }
.inv-peek.err .ph { display: grid; }
.inv-peek.err .pl img { display: none; }
.inv-peek .cap { padding: 9px 4px 2px; font-size: 13px; line-height: 1.45; }
.inv-peek .row { display: flex; justify-content: space-between; gap: 12px; }
.inv-peek .row b { font-size: 14px; font-weight: 600; }
.inv-peek .pr { font-weight: 500; font-variant-numeric: tabular-nums lining-nums; }
.inv-peek .muted { color: rgba(255, 255, 255, .65); }

@media (hover: none), (pointer: coarse) { .inv-peek { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  .inv-peek, .inv-peek.on, .inv-peek-in, .inv-peek .pl img, .inv-card { transition: none; }
  .inv-peek-in { transform: none; }
  .inv-peek.loading .pl { animation: none; }
}

@media print { .inv-peek { display: none !important; } }
