/* Give the stock sheet most of the inventory viewport. */
body:has(.stock-sheet-page) header {
  height: 56px;
}

main:has(.stock-sheet-page) {
  max-width: 1680px;
  padding: 18px clamp(16px, 2vw, 32px) 28px;
}

.stock-sheet-page h1 {
  margin: 0;
  color: var(--ink);
  font: 750 clamp(24px, 2.2vw, 32px)/1.2 var(--font-ui);
  letter-spacing: -.035em;
}

#inventory .section-heading {
  margin-bottom: 10px;
}

#inventory .inventory-masthead {
  align-items: center;
  position: relative;
  min-height: 94px;
  padding: 15px clamp(16px, 2.4vw, 34px);
  border: 1px solid #cbd4df;
  border-radius: 14px;
  color: var(--hero-ink);
  background-color: #a5b2bf;
  background-image: linear-gradient(98deg, var(--hero-paper) 2%, var(--hero-paper) 34%, rgb(233 238 242 / .82) 55%, rgb(222 229 235 / .25) 81%),
    var(--hardware-image);
  background-size: cover;
  background-position: center, right 53%;
  background-blend-mode: normal, screen;
}
#inventory .inventory-masthead h1 {
  color: var(--hero-ink);
  font-size: clamp(28px, 2.6vw, 38px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.04em;
}
#inventory .inventory-masthead #result-count {
  color: var(--hero-copy);
  line-height: 1.4;
}
#inventory .inventory-masthead .button {
  border-color: #a7b3c2;
  color: #30435e;
  background: #f7f8fa;
}
#inventory .inventory-masthead .button[href="#escrow"] {
  border-color: var(--purple);
  color: white;
  background: var(--purple);
}
#inventory .inventory-masthead .button:hover { border-color: #75869c; background: #fff; }
#inventory .inventory-masthead .button[href="#escrow"]:hover { background: var(--action-hover); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  #inventory .inventory-masthead .button { transition: transform 150ms ease-out, background-color 150ms ease-out; }
  #inventory .inventory-masthead .button:hover { transform: translateY(-1px); }
}

#inventory .panel {
  border-color: #d6dee6;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgb(37 57 80 / .035);
}
#inventory .toolbar {
  padding: 10px 14px 6px;
}
#inventory .tabs {
  border: 1px solid #dce2e9;
  border-radius: 8px;
  background: #f1f3f5;
}
#inventory .tabs button { color: #47566a; }
#inventory .tabs button.selected {
  background: #43536a;
  color: white;
  box-shadow: 0 1px 3px rgba(28,26,45,.16);
}
#inventory .tabs button:hover:not(.selected) { background: #e3e8ee; }
#inventory #stock-search {
  padding-inline-start: 34px;
  border-color: #d8dce8;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2367758a' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='8.3' cy='8.3' r='5.5'/%3E%3Cpath d='m12.6 12.6 4.2 4.2'/%3E%3C/svg%3E") no-repeat 10px center / 16px;
}
#inventory :is(input, select):focus-visible { outline: 2px solid #536d9c; outline-offset: 1px; }

#inventory .inventory-filters {
  padding: 4px 14px 10px;
  gap: 12px;
}

#inventory .inventory-filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #46546a;
}

#inventory .inventory-filters select {
  min-width: 0;
  margin-top: 0;
  padding-top: 6px;
  padding-bottom: 6px;
}

#inventory .inventory-filters .text-button {
  align-self: center;
  margin: 0;
}

#inventory .inventory-demo-note {
  padding: 5px 14px;
  color: #4a5c70;
  background: #eff3f6;
  border-color: #dce4ea;
}

#inventory .table-bottom {
  padding: 9px 14px;
}

.stock-sheet-results {
  display: block;
  min-width: 0;
  padding: 0;
  background: white;
}

#inventory .credit-table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

#inventory .credit-table-wrap:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: -3px;
}

#inventory .credit-stock-table {
  display: table;
  width: 100%;
  min-width: 1000px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  white-space: normal;
  color: #26354a;
  background: white;
  font-variant-numeric: tabular-nums;
}

.credit-table-caption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#inventory .credit-stock-table thead { display: table-header-group; }
#inventory .credit-stock-table tbody { display: table-row-group; padding: 0; background: none; }
#inventory .credit-stock-table tr { display: table-row; padding: 0; border: 0; background: white; }
#inventory .credit-stock-table tbody tr:nth-child(even) { background: #f8fafb; }
#inventory .credit-stock-table tbody tr:hover { background: #eff3f7; }

#inventory .credit-stock-table th,
#inventory .credit-stock-table td {
  display: table-cell;
  text-align: left;
  vertical-align: middle;
  padding: 7px clamp(5px, .5vw, 9px);
  border: 0;
  border-bottom: 1px solid #e3e8ef;
  font-size: 14px;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: none;
  overflow-wrap: anywhere;
  background: inherit;
  color: inherit;
}

#inventory .credit-stock-table td::before { display: none; content: none; }
#inventory .credit-stock-table th[scope='row'] { font-weight: 450; }
#inventory .credit-stock-table tbody tr { height: clamp(48px, calc((100dvh - 350px) / 8), 78px); }

#inventory .credit-stock-table thead th {
  padding-top: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #cfd8e5;
  background: #eaf0f4;
  color: #3d5069;
  font-size: 13px;
  font-weight: 650;
}

#inventory .credit-stock-table :is(th, td):first-child { padding-left: 14px; }
#inventory .credit-stock-table :is(th, td):last-child { padding-right: 14px; }

#inventory .credit-table-product { width: 13%; }
#inventory .credit-table-value { width: 10.4%; }
#inventory .credit-table-price { width: 10.4%; }
#inventory .credit-table-rate { width: 5.2%; }
#inventory .credit-table-quantity { width: 4%; }
#inventory .credit-table-region { width: 6%; }
#inventory .credit-table-fee { width: 13%; }
#inventory #result-count time {
  display: inline-block;
  color: #365d63;
  white-space: nowrap;
}
#inventory #result-count time::before { content: '· '; }
@media (max-width: 760px) {
  #inventory #result-count time { display: block; }
  #inventory #result-count time::before { content: none; }
}

#inventory .credit-table-deposit { width: 12%; }
#inventory .credit-table-company { width: 13%; }
#inventory .credit-table-actions { width: 13%; }
#inventory .credit-stock-table thead :is(.credit-table-rate, .credit-table-region) {
  padding-inline: 5px; white-space: nowrap;
}

#inventory .credit-stock-table .credit-table-value,
#inventory .credit-stock-table .credit-table-price,
#inventory .credit-stock-table .credit-table-rate,
#inventory .credit-stock-table .credit-table-quantity,
#inventory .credit-stock-table .credit-table-deposit {
  text-align: right;
}

#inventory .credit-stock-table .credit-table-price { font-weight: 750; }
#inventory .credit-stock-table thead .credit-table-price { color: #35476c; background: #e0e6ef; }
#inventory .credit-stock-table td.credit-table-price {
  color: #35476c;
  background-color: rgb(73 94 130 / .055);
}
#inventory .credit-stock-table .credit-table-product strong { display: block; font-size: 14px; font-weight: 700; }
#inventory .credit-table-feature {
  display: block;
  color: #495676;
  font-size: .8125rem;
  line-height: 1.2;
  font-weight: 500;
  overflow-wrap: anywhere;
}
#inventory .credit-stock-table small { margin: 2px 0 0; font-size: 12px; line-height: 1.25; color: #53677d; }
#inventory .credit-stock-table .credit-table-product > small { display: inline; }

.credit-table-details { display: inline-block; vertical-align: top; max-width: 100%; }
.credit-table-details[open] { display: block; }
.credit-table-details summary { color: #475a85; font-size: 12px; line-height: 1.5; cursor: pointer; }
.credit-table-details summary:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.credit-table-details[open] dl { margin: 6px 0; font-size: 13px; }
.credit-table-details dt { font-weight: 700; margin-top: 6px; }
.credit-table-details dd { margin: 2px 0; }

#inventory .credit-stock-table .credit-table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #42547d;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
  padding: 4px;
  cursor: pointer;
}

#inventory .credit-stock-table .credit-table-action.primary { background: #e5eaf2; color: #35476c; }
#inventory .credit-stock-table .credit-table-action:hover { background: #d8e1ed; }
#inventory .credit-stock-table .credit-table-action:disabled { color: #657286; background: #e8ebef; cursor: default; }

@media (max-width: 1180px) {
  #inventory .credit-stock-table thead th,
  #inventory .credit-stock-table tbody :is(th, td) { padding-inline: 5px; }
}

@media (max-width: 1060px) {
  #inventory .credit-stock-table tr > :first-child { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 #d6dfeb; }
  #inventory .credit-stock-table thead th:first-child { background: #eaf0f4; }
}

@media (max-width: 760px) {
  .stock-sheet-page .section-heading { align-items: center; }
  #inventory .inventory-filters { display: flex; flex-wrap: wrap; gap: 6px 8px; }
  #inventory .inventory-filters label { display: grid; gap: 3px; min-width: 90px; }
  #inventory .inventory-filters .text-button { align-self: end; }
  #inventory .toolbar { flex-wrap: wrap; align-items: stretch; }
  #inventory .search { min-width: min(100%, 160px); }
  #inventory .tabs { max-width: 100%; flex-wrap: wrap; }
  #inventory .credit-stock-table tbody tr { height: auto; }
}

#inventory .credit-stock-table td.credit-table-value,
#inventory .credit-stock-table td.credit-table-price > strong { white-space: normal; overflow-wrap: anywhere; }

#inventory .credit-stock-table td.credit-table-price > strong { font-size: 14px; }
#inventory .credit-stock-table .credit-table-status { margin-right: 8px; }
#inventory .credit-stock-table .credit-table-status.available { color: #227252; }
#inventory .credit-stock-table .credit-table-status.reserved { color: #826119; }
#inventory .credit-stock-table .credit-table-action.is-saved { color: #354a73; background: #dde5f0; }
.credit-table-own, .credit-table-unavailable { display: block; font-size: 12px; color: #57677b; }

.stock-filter-toggle { display: none; }

@media (max-width: 760px) {
  body:has(.stock-sheet-page) header { height: 44px; }
  main:has(.stock-sheet-page) { padding: 12px 12px 24px; }
  #inventory.stock-sheet-page .section-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
  }
  #inventory .inventory-masthead {
    min-height: 0;
    padding: 10px 12px;
    border-radius: 11px;
    background-image: linear-gradient(98deg, var(--hero-paper) 6%, rgb(238 242 245 / .95) 52%, rgb(230 236 241 / .55)),
      var(--hardware-image);
    background-position: center, right 50%;
  }
  #inventory .inventory-masthead h1 { font-size: clamp(20px, 6vw, 26px); }
  .stock-sheet-page .section-heading > div:first-child { display: contents; }
  .stock-sheet-page .stock-heading-actions { grid-column: 2; grid-row: 1; }
  .stock-sheet-page #result-count {
    grid-row: 2;
    grid-column: 1 / -1;
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
  }
  .stock-sheet-page:has([data-action="import"]) .section-heading { grid-template-columns: 1fr; }
  .stock-sheet-page:has([data-action="import"]) .stock-heading-actions { grid-column: 1; grid-row: 3; }
  #inventory.stock-single-page .section-heading { grid-template-columns: 1fr; }
  .stock-single-page .stock-heading-actions { grid-column: 1; grid-row: 3; }
  #inventory .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 7px 8px;
    gap: 5px;
  }
  #inventory .tabs {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr;
    grid-column: 1 / -1;
    gap: 2px;
  }
  #inventory .tabs button { padding: 7px 4px; line-height: 1.2; }
  #inventory .search { min-width: 0; }
  #inventory .search input { min-height: 38px; font-size: 16px; padding: 6px 8px; }
  #inventory .stock-filter-toggle { display: inline-flex; padding: 5px 12px; }
  #inventory .stock-filter-toggle[aria-expanded="true"] { border-color: #a0afc2; color: #35476c; background: #e9eef5; }
  #inventory .panel:has(.stock-filter-toggle[aria-expanded="false"]) .inventory-filters { display: none; }
  #inventory .credit-stock-table thead th { padding-block: 5px; line-height: 1.15; }
}

@media (min-width: 761px) {
  #inventory.stock-sheet-page .credit-table-wrap {
    max-height: max(300px, calc(100dvh - 255px));
    overflow: auto;
  }
  #inventory.stock-sheet-page thead th {
    position: sticky;
    top: 0;
    z-index: 2;
  }
  #inventory.stock-sheet-page thead th:first-child { z-index: 3; }
}

.stock-mobile-summary { display: none; }

@media (max-width: 760px) {
  #inventory .credit-table-scroll { overflow: visible; }
  #inventory .credit-table,
  #inventory .credit-table tbody,
  #inventory .credit-table .credit-table-row {
    display: block;
    width: 100%;
    min-width: 0;
  }
  #inventory .credit-table thead,
  #inventory .credit-table .credit-table-row > td,
  #inventory .credit-table .credit-table-product > :not(details),
  #inventory .credit-table .credit-desktop-summary { display: none; }

  #inventory .credit-table .credit-table-row {
    height: auto;
    border-bottom: 1px solid #d3e1e4;
  }
  #inventory .credit-table tr.credit-table-row:nth-child(even) { background: #f7faf9; }
  #inventory .credit-table tr.credit-table-row:has(details[open]) { background: #f0f7f5; }
  #inventory .credit-table .credit-table-row:last-child { border-bottom: 0; }
  #inventory .credit-table .credit-table-row > th.credit-table-product {
    position: static;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    box-shadow: none;
    color: var(--ink);
  }
  #inventory .credit-table-details { display: block; }
  #inventory .credit-table-details > summary {
    display: block;
    list-style: none;
    color: inherit;
  }
  #inventory .credit-table-details > summary::-webkit-details-marker { display: none; }
  #inventory .credit-table-details summary:focus-visible { outline-offset: -2px; }

  .stock-mobile-summary {
    display: grid;
    gap: 3px;
    padding: 7px 11px;
    font-variant-numeric: tabular-nums;
    text-align: left;
    overflow-wrap: anywhere;
  }
  .stock-mobile-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 6px;
    align-items: baseline;
    gap: 6px;
    font-size: 1rem;
    line-height: 1.2;
    font-weight: 720;
    color: #152e43;
    letter-spacing: -.02em;
  }
  .stock-mobile-top::after {
    content: '';
    width: 5px;
    height: 5px;
    align-self: start;
    margin-top: 4px;
    border: solid #788b90;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
  }
  details[open] > summary .stock-mobile-top::after {
    margin-top: 7px;
    transform: rotate(225deg);
  }
  .stock-mobile-feature {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: 0;
    color: #355f86;
  }
  .stock-mobile-feature::before { content: '· '; }
  .stock-mobile-price {
    color: #086658;
    text-align: right;
    font-weight: 750;
  }
  .stock-mobile-label {
    font-size: .75rem;
    font-weight: 500;
    letter-spacing: 0;
    color: #4a5d68;
  }
  .stock-mobile-price .stock-mobile-label { color: #38645f; }
  .stock-mobile-costs {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 6px;
    font-size: .75rem;
    line-height: 1.3;
    font-weight: 600;
    color: #334657;
  }
  .stock-mobile-costs > span { min-width: 0; max-width: 100%; }
  .stock-mobile-upfront {
    padding: 1px 6px;
    border-radius: 4px;
    color: #734209;
    background: #f8ead6;
  }
  .stock-mobile-upfront .stock-mobile-label { color: #795424; }
  .stock-mobile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 5px;
    font-size: .75rem;
    font-weight: 450;
    line-height: 1.2;
    color: #4a606c;
  }
  .stock-mobile-meta > span + span::before { content: '·'; margin-right: 5px; color: #70838b; }
  .stock-mobile-state.available { color: #166148; }
  .stock-mobile-state.reserved { color: #795a22; }
  #inventory .credit-table-details[open] dl {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 10px;
    border-top: 1px solid #dde5ec;
    font-size: .875rem;
  }
  #inventory .credit-table-details[open] :is(dt, dd) { margin: 0; }
  #inventory .credit-table-details[open] p { margin: 0; padding: 0 10px 10px; }
  #inventory .credit-table-row:has(details[open]) > td.credit-table-actions {
    display: flex;
    width: 100%;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 10px 10px;
    border: 0;
  }
  #inventory .credit-table-row .credit-table-action { min-height: 36px; padding-inline: 10px; }
}

@media (max-width: 380px) {
  #inventory .stock-mobile-summary { padding-inline: 8px; }
  #inventory .stock-mobile-costs { column-gap: 4px; }
  #inventory .stock-mobile-upfront { padding-inline: 4px; }
}

@media (max-width: 760px) and (max-height: 760px) {
  body:has(.stock-sheet-page) .main > header:has(#account-cta[data-action="profile"]) { display: none; }
  main:has(.stock-sheet-page) { padding-top: 6px; }
  #inventory.stock-sheet-page .inventory-masthead { gap: 2px 8px; padding-block: 6px; margin-bottom: 5px; }
  #inventory.stock-sheet-page .stock-mobile-summary { gap: 2px; padding-block: 3px; }
}
