.search-toggle, .history-cards { display: none; }
.report-mobile-card__stock small { font-size: 12px; font-weight: 400; color: var(--inv-muted); }

/* Product form: keep every field within the dialog at all desktop widths. */
.wide-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.wide-dialog .inv-form-product {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide-dialog .inv-field input,
.wide-dialog .inv-field select,
.wide-dialog .inv-file2 {
  min-width: 0;
  width: 100%;
}

@media (max-width: 900px) {
  .wide-dialog .inv-form-product {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "title title"
      "name sku"
      "qty unit"
      "cat child"
      "image submit";
  }
}

@media (max-width: 600px) {
  .wide-dialog {
    width: calc(100vw - 20px);
    padding: 18px;
  }

  .wide-dialog .inv-form-product {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "name"
      "sku"
      "qty"
      "unit"
      "cat"
      "child"
      "image"
      "submit";
  }
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 14px 0 20px;
  padding: 16px;
  border: 1px solid var(--inv-border);
  border-radius: 14px;
}

.detail-image {
  width: 110px;
  height: 82px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 10px;
  background: #f6f6f6;
}

.detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-head h2 {
  margin: 5px 0 8px;
  font-size: 21px;
}

.detail-filters {
  margin-top: 0;
}

.detail-btn {
  height: 36px;
  padding: 0 12px;
  white-space: nowrap;
}

.inv-stock {
  color: var(--inv-text);
}

.inv-card__price {
  color: var(--inv-text);
}

.brand-logo {
  display: block;
  width: 190px;
  height: auto;
}

.auth-logo {
  overflow: hidden;
}

.auth-logo img {
  display: block;
  width: 100%;
  height: 100%;
}

.category-page__intro p {
  margin: 0 0 20px;
  color: var(--inv-muted);
}

.category-page__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.category-panel {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 20px;
  border: 1px solid var(--inv-border);
  border-radius: 14px;
  background: #fff;
}

.category-panel h3 {
  margin: 0;
  font-size: 17px;
}

.category-panel .inv-field input,
.category-panel .inv-field select {
  min-width: 0;
  width: 100%;
}

.category-panel .inv-btn {
  justify-self: start;
}

.mobile-only,
.report-cards {
  display: none;
}

.detail-delete {
  margin-left: 0;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #f4dddd;
  border-radius: 10px;
  color: #dc3838;
  background: #fff5f5;
  cursor: pointer;
}

.detail-identity { min-width: 0; }
.detail-identity h2 { overflow-wrap: anywhere; }
.detail-balance { margin-left: auto; text-align: right; display: grid; gap: 4px; }
.detail-balance > span, .detail-balance small { color: var(--inv-muted); font-size: 13px; }
.detail-balance strong { font-size: 32px; line-height: 1.15; }
.detail-filters { padding-bottom: 20px; margin-bottom: 20px; }
.inv-m__price { color: var(--inv-text); }
.entry-expand { scroll-margin-top: 95px; }
.entry-expand:not([open]) { display: none; }
.entry-expand[open] { border: 1px solid var(--inv-green); border-radius: 14px; padding: 20px; margin-bottom: 24px; }
.entry-expand summary { font-size: 18px; font-weight: 700; cursor: pointer; margin-bottom: 18px; }
.entry-expand .inline-product h2 { display: none; }
.inline-product .inv-form-product { grid-template-columns: repeat(4,minmax(0,1fr)); grid-template-areas: "title title title title" "name sku qty unit" "cat child image submit"; }
.inline-product .inv-form-product h2 { margin: 0 0 8px; font-size: 22px; }
.inline-product .inv-field, .inline-product .inv-field input, .inline-product .inv-field select, .inline-product .inv-file2 { min-width: 0; width: 100%; }

@media (max-width: 850px) {
  #entry-panels { display: none; }
  .inline-product .inv-form-product { grid-template-columns: repeat(2,minmax(0,1fr)); grid-template-areas: "title title" "name sku" "qty unit" "cat child" "image submit"; }
}
@media (max-width: 560px) {
  .inline-product .inv-form-product { grid-template-columns: minmax(0,1fr); grid-template-areas: "title" "name" "sku" "qty" "unit" "cat" "child" "image" "submit"; }
  .detail-head { display: grid; grid-template-columns: 60px minmax(0,1fr) 40px; gap: 12px; padding: 12px; }
  .detail-image { width: 60px; height: 60px; }
  .detail-identity h2 { font-size: 17px; }
  .detail-balance { grid-row: 2; grid-column: 1 / -1; width: 100%; border-top: 1px solid var(--inv-border); padding-top: 12px; }
  .detail-delete { grid-row: 1; grid-column: 3; }
  .detail-filters .inv-ctl__item, .detail-filters input, .detail-filters select { min-width: 0; width: 100%; }
}

.delete-dialog {
  width: min(420px, calc(100vw - 32px));
}

.delete-dialog p {
  color: var(--inv-muted);
  line-height: 1.6;
}

.delete-form {
  display: grid;
  gap: 16px;
}

.delete-form label {
  display: grid;
  gap: 6px;
  color: var(--inv-muted);
}

.delete-form input {
  height: 42px;
  border: 1px solid var(--inv-border);
  border-radius: 10px;
  padding: 8px 10px;
}

.delete-form > div {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 850px) {
  .detail-head {
    align-items: flex-start;
  }

  .detail-delete {
    margin-left: 0;
  }

  .head-actions {
    display: none;
  }

  .head-inner nav.open {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .head-inner nav .nav-btn {
    width: 100%;
    text-align: left;
  }

  .mobile-only {
    display: block;
  }

  .report-table-desktop {
    display: none;
  }

  .report-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .report-mobile-card {
    overflow: hidden;
    border: 1px solid var(--inv-border);
    border-radius: 14px;
    background: #fff;
  }

  .report-mobile-card img,
  .report-mobile-placeholder {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #f6f6f6;
  }

  .report-mobile-card__body {
    display: grid;
    gap: 5px;
    padding: 10px;
  }

  .report-mobile-card__code {
    color: var(--inv-muted);
    font-size: 11px;
  }

  .report-mobile-card__name {
    min-height: 38px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
  }

  .report-mobile-card__stock {
    color: var(--inv-text);
    font-size: 18px;
    font-weight: 800;
  }

  .report-mobile-card .detail-btn {
    width: 100%;
    margin-top: 5px;
  }

  .category-page__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .brand-logo {
    width: 148px;
  }

  .inv-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 850px) {
  .inv-page.wrap { width: 100%; max-width: none; padding: 0 10px; }
  .search-expand { width: 100%; min-width: 0; margin-bottom: 18px; }
  .search-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; min-height: 44px; padding: 12px;
    border: 1px solid var(--inv-border); border-radius: 10px;
    background: #fff; font-weight: 600; text-align: left; cursor: pointer;
  }
  .search-toggle::after { content: '⌄'; }
  .search-toggle[aria-expanded="true"] { border-color: var(--inv-green); }
  .search-toggle[aria-expanded="true"]::after { content: '⌃'; }
  .search-expand:not(.is-expanded) .search-expand__body { display: none; }
  .search-expand__body { padding-top: 14px; }
  .search-expand .inv-filters { border: 0; padding: 0; margin: 0; }
  .search-expand .inv-divider { display: none; }
  .search-expand .inv-filter-form, .search-expand .report-filter {
    display: grid; grid-template-columns: minmax(0,1fr) 44px; gap: 12px; width: 100%;
  }
  .search-expand .inv-ctl__item { grid-column: 1 / -1; min-width: 0; width: 100%; }
  .search-expand .inv-ctl__q { grid-column: 1; }
  .search-expand .inv-clear, .search-expand #detail-clear { grid-column: 2; width: 44px; }
  .search-expand input, .search-expand select { min-width: 0; width: 100%; }
  .search-expand #report-filter .inv-ctl__q { grid-column: 1 / -1; }
  .detail-table-desktop { display: none; }
  .history-cards { display: grid; gap: 12px; width: 100%; }
  .history-card { min-width: 0; border: 1px solid var(--inv-border); border-radius: 12px; padding: 14px; }
  .history-card__top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 13px; }
  .history-card time { white-space: nowrap; color: #555; }
  .history-card__quantity { margin: 12px 0; font-size: 24px; }
  .history-card__quantity small { font-size: 12px; font-weight: 400; color: var(--inv-muted); }
  .history-card dl { margin: 0; display: grid; gap: 8px; font-size: 13px; }
  .history-card dl > div { display: grid; grid-template-columns: 100px minmax(0,1fr); gap: 10px; }
  .history-card dt { color: var(--inv-muted); }
  .history-card dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
  .detail-balance { text-align: right; justify-items: end; }
  .report-mobile-card__stock { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
  .report-mobile-card__stock small { font-size: 12px; font-weight: 400; }
}
