:root {
  --bg: #d9e0e7;
  --panel: #eef3f7;
  --panel-strong: #ffffff;
  --ink: #17232f;
  --muted: #5f7385;
  --blue-deep: #173a59;
  --blue-mid: #2d5c84;
  --steel: #7e8f9f;
  --line: #b6c3ce;
  --accent: #4d86b7;
  --accent-warm: #f4c768;
  --danger: #b64d4d;
  --shadow: 0 18px 40px rgba(23, 42, 58, 0.14);
  --radius: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 58, 89, 0.14), rgba(23, 58, 89, 0) 34%),
    linear-gradient(135deg, #f2f5f8 0%, #d5dde5 100%);
}

.page-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.hero,
.toolbar,
.status-card,
.part-card,
.dialog-card,
.legend {
  border: 1px solid rgba(23, 58, 89, 0.12);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.45fr 0.75fr;
  gap: 24px;
  align-items: stretch;
  padding: 42px 46px 28px;
  border-radius: 34px;
  color: #f5f8fb;
  background:
    radial-gradient(circle at top right, rgba(126, 143, 159, 0.52), rgba(126, 143, 159, 0) 32%),
    linear-gradient(135deg, #102738 0%, #173a59 48%, #456988 100%);
}

.eyebrow {
  margin: 0 0 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 1.08rem;
  font-weight: 900;
  color: #eef5fb;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.hero h1 {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.02em;
  font-size: clamp(2.4rem, 5.4vw, 4.7rem);
  line-height: 0.88;
  letter-spacing: -0.05em;
  color: var(--accent-warm);
  text-shadow: 0 1px 0 rgba(255,255,255,0.14);
}

.subtitle {
  max-width: 840px;
  margin: 20px 0 0;
  color: #d6e4f0;
  font-size: 1.08rem;
}

.hero-copy {
  display: flex;
  flex-direction: column;
}

.hero-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 18px;
}

.hero-search {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(430px, 100%);
  padding: 16px 18px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(225, 236, 245, 0.12);
}

.hero-search span {
  font-size: 0.84rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #d9e7f3;
}

.hero-search input {
  border: 1px solid rgba(209, 224, 236, 0.24);
  border-radius: 18px;
  padding: 18px 20px;
  color: #eaf2f8;
  background: rgba(234, 243, 250, 0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.09);
}

.hero-search input::placeholder {
  color: #c9d9e6;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: 100%;
  padding-right: 4px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 16px 24px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-button {
  color: white;
  background: linear-gradient(180deg, #4b88bb, #2d5c84);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.68),
    0 10px 22px rgba(21, 52, 77, 0.26);
}

.secondary-button {
  color: #173a59;
  background: #e5edf4;
  box-shadow: 0 10px 22px rgba(21, 52, 77, 0.1);
}

.toolbar {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr;
  gap: 16px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
}

.toolbar-heading {
  grid-column: 1 / -1;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue-deep);
}

.toolbar label,
.search-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: var(--panel-strong);
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 18px 0;
}

.status-card {
  padding: 18px 20px;
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff, #eef3f7);
}

.status-label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  margin-bottom: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 22px;
}

.results-categories {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.category-home-intro {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
  padding: 24px 26px;
  border-radius: 24px;
  border: 1px solid rgba(23, 58, 89, 0.12);
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(236,242,247,0.94));
}

.category-home-intro h2 {
  margin: 6px 0 8px;
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.category-home-intro p {
  margin: 0;
  color: var(--muted);
}

.category-home-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--blue-deep);
}

.category-home-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  color: var(--muted);
}

.category-home-summary strong {
  font-size: 1.35rem;
  color: var(--blue-deep);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.category-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 16px;
  align-items: start;
  text-align: left;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(23, 58, 89, 0.12);
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(235,241,246,0.98));
  overflow: hidden;
}

.category-card-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.category-card h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.category-card p {
  margin: 0;
  color: var(--muted);
}

.category-card-photo-frame,
.part-photo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  border: 1px solid rgba(23, 58, 89, 0.12);
  background: linear-gradient(180deg, #edf3f8, #dce6ef);
  overflow: hidden;
}

.category-card-photo-frame {
  width: 118px;
  height: 118px;
}

.category-card-photo,
.part-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.category-card-photo-empty,
.part-photo-empty {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8095a8;
}

.category-pill {
  display: inline-flex;
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--blue-deep);
  background: #dce8f2;
}

.part-card {
  border-radius: 26px;
  padding: 24px 22px 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(235,241,246,0.98));
  min-height: 240px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.part-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 40px rgba(23, 42, 58, 0.17);
}

.part-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.part-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.part-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  flex: 0 0 auto;
}

.part-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.part-number-callout {
  margin: 0 0 8px;
  font-size: 1.02rem;
  font-weight: 900;
  color: var(--blue-deep);
  letter-spacing: 0.015em;
}

.part-description {
  margin: 10px 0 0;
  color: var(--muted);
  min-height: 66px;
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.part-photo-frame {
  width: 106px;
  height: 122px;
}

.badge-row,
.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.stock {
  color: white;
  background: linear-gradient(180deg, #335e86, #173a59);
  min-width: 48px;
  justify-content: center;
}

.badge.vendor {
  color: #173a59;
  background: #dce8f2;
}

.badge.warning {
  color: #8d6510;
  background: #f5e7bc;
}

.badge.missing {
  color: #6d7681;
  background: #edf1f5;
}

.meta-grid {
  margin-top: 16px;
  flex-direction: column;
}

.meta-item {
  display: grid;
  grid-template-columns: 124px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid rgba(126, 143, 159, 0.22);
}

.meta-item strong {
  color: var(--blue-deep);
}

.meta-value.muted {
  color: var(--muted);
  font-style: italic;
}

.po-note {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.84rem;
  color: #6c5940;
  background: linear-gradient(180deg, #f5ecd3, #efe2bd);
}

.empty-state {
  padding: 40px;
  border-radius: 22px;
  text-align: center;
  color: var(--muted);
  background: rgba(255,255,255,0.8);
}

.print-header {
  display: none;
}

.part-dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

.dialog-card {
  width: min(860px, calc(100vw - 24px));
  padding: 28px;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff, #eef3f7);
  position: relative;
}

.dialog-card::backdrop,
.part-dialog::backdrop {
  background: rgba(8, 16, 24, 0.54);
}

.close-button {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: #d7e1ea;
  color: #173a59;
}

.dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.dialog-grid .full {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

@media print {
  @page {
    size: auto;
    margin: 0.4in;
  }

  body {
    background: white;
    font-size: 10.5pt;
  }

  .hero-actions,
  .toolbar,
  .status-row,
  .legend {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .hero {
    color: black;
    background: white;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0 0 0.14in;
    margin: 0 0 0.12in;
    display: block;
  }

  .hero h1,
  .subtitle,
  .hero-search {
    display: none !important;
  }

  .hero-copy,
  .hero-side {
    display: block;
  }

  .eyebrow {
    margin: 0;
    font-size: 11pt;
    letter-spacing: 0.08em;
    color: #173a59;
    text-shadow: none;
  }

  .category-home-intro,
  .category-grid {
    display: none !important;
  }

  .print-header {
    display: block;
    margin: 0 0 0.16in;
    padding: 0 0 0.08in;
    border-bottom: 1px solid #c7d2dc;
    font-size: 14pt;
    font-weight: 800;
    color: #173a59;
  }

  .results-grid {
    grid-template-columns: 1fr;
    gap: 0.08in;
    align-items: start;
  }

  .part-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 1.82in;
    column-gap: 0.1in;
    row-gap: 0;
    min-height: auto;
    padding: 0.08in 0 0.12in;
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid #c7d2dc;
    box-shadow: none;
    background: white;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .part-card:hover {
    transform: none;
    box-shadow: none;
  }

  .part-title {
    font-size: 12pt;
    margin-bottom: 1px;
  }

  .part-number-callout {
    margin: 0 0 2px;
    font-size: 9.5pt;
    font-weight: 900;
  }

  .part-description {
    min-height: 0;
    margin-top: 3px;
    font-size: 9.25pt;
  }

  .badge {
    padding: 2px 6px;
    font-size: 8pt;
  }

  .part-top {
    display: contents;
  }

  .badge-row {
    gap: 6px;
    margin-top: 6px;
  }

  .part-copy {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
  }

  .part-card > .badge-row {
    display: none;
  }

  .part-side {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 0.04in;
    align-self: start;
  }

  .part-photo-frame {
    width: 1.62in;
    height: 1.62in;
    border-radius: 0.14in;
    background: white;
  }

  .part-photo {
    object-fit: contain;
    background: white;
  }

  .meta-grid {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px 10px;
    max-width: none;
    align-self: end;
    padding-top: 0.1in;
  }

  .meta-item {
    display: block;
    padding: 0;
    border-top: 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .meta-item strong {
    display: block;
    margin-bottom: 1px;
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .meta-item span {
    display: block;
    font-size: 8.75pt;
  }

  .meta-item strong,
  .meta-item span,
  .part-title,
  .part-number-callout,
  .part-description {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .meta-value.muted {
    font-style: italic;
  }

  .empty-state {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

@media (max-width: 980px) {
  .toolbar,
  .status-row,
  .dialog-grid {
    grid-template-columns: 1fr;
  }

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

  .category-home-summary {
    align-items: flex-start;
  }

  .hero {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 34px 24px 24px;
  }

  .hero-side {
    width: 100%;
    align-items: stretch;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .hero-search {
    width: 100%;
  }

  .part-top {
    flex-direction: column;
  }
}
