:root {
  --bg: #b8b8b8;
  --panel: #ffffff;
  --panel-soft: #f8fbfd;
  --ink: #5f5650;
  --muted: #7b736d;
  --line: rgba(89, 73, 55, 0.22);
  --accent: #f18f01;
  --accent-soft: #fff8f0;
  --green: #2f7d45;
  --red: #b45252;
  --shadow: 0 16px 28px rgba(82, 60, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "IBM Plex Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.home-link {
  border: 1px solid rgba(241, 143, 1, 0.78);
  border-radius: 0;
  background: var(--accent);
  color: #fffefc;
  min-height: 38px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
}

button:hover,
.home-link:hover {
  background: #d97900;
  border-color: rgba(217, 121, 0, 0.9);
  color: #fffefc;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.inventory-page {
  width: min(1440px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 26px 0 40px;
  display: grid;
  gap: 16px;
}

.page-header,
.search-panel,
.selected-panel,
.stock-panel,
.site-card {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.page-header {
  position: relative;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  overflow: hidden;
}

.page-header::before,
.search-panel::before,
.selected-panel::before,
.stock-panel::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  height: 1px;
  background: rgba(241, 143, 1, 0.34);
}

.page-header h1,
.selected-head h2,
.stock-head h2 {
  margin: 0;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.search-panel,
.selected-panel,
.stock-panel {
  position: relative;
  padding: 18px;
  overflow: hidden;
}

#productSearchForm {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.search-field {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.search-field input:focus {
  outline: 2px solid rgba(241, 143, 1, 0.22);
  border-color: rgba(241, 143, 1, 0.55);
}

.status-line,
.muted-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.status-line {
  margin-top: 10px;
}

.status-line.is-error {
  color: var(--red);
}

.status-line.is-success {
  color: var(--green);
}

.status-line.is-loading {
  width: 160px;
  min-height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.loading-track {
  position: relative;
  width: 118px;
  height: 6px;
  overflow: hidden;
  border: 1px solid rgba(241, 143, 1, 0.28);
  background: rgba(255, 244, 230, 0.72);
}

.loading-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -44%;
  width: 44%;
  background: linear-gradient(90deg, rgba(241, 143, 1, 0), rgba(241, 143, 1, 0.88), rgba(241, 143, 1, 0));
  animation: loading-sweep 1.15s ease-in-out infinite;
}

.loading-time {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.loading-time span {
  width: 5px;
  height: 5px;
  background: var(--accent);
  opacity: 0.25;
  animation: loading-tick 1.05s ease-in-out infinite;
}

.loading-time span:nth-child(2) {
  animation-delay: 0.16s;
}

.loading-time span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes loading-sweep {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(330%);
  }
}

@keyframes loading-tick {
  0%,
  100% {
    opacity: 0.25;
  }
  45% {
    opacity: 0.95;
  }
}

.product-results {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.product-button {
  width: 100%;
  min-height: 0;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  font-weight: 400;
  background: #ffffff;
  border-color: rgba(89, 73, 55, 0.18);
  color: var(--ink);
}

.product-button:hover,
.product-button.is-selected {
  background: var(--accent);
  border-color: rgba(217, 121, 0, 0.9);
  color: #fffefc;
}

.product-button.is-selected .product-code,
.product-button:hover .product-code,
.product-button.is-selected .product-sub,
.product-button:hover .product-sub {
  color: #fffefc;
}

.product-main {
  display: grid;
  gap: 4px;
}

.product-name {
  font-weight: 800;
}

.product-sub {
  color: var(--muted);
  font-size: 13px;
}

.product-code {
  color: var(--accent);
  font-weight: 900;
  white-space: nowrap;
}

.selected-panel.is-hidden {
  display: none;
}

.selected-head,
.stock-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.standard-code-wrap {
  margin-top: 16px;
}

.standard-code-wrap h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.standard-code-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.standard-chip {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 10px;
  background: var(--panel-soft);
  font-size: 13px;
}

.site-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.site-card {
  overflow: hidden;
  box-shadow: none;
  background: #ffffff;
}

.site-title {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 16px;
}

.site-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.site-mediyoung {
  grid-column: 1 / -1;
}

.site-mediyoung th.name-cell,
.site-mediyoung td.name-cell {
  width: 30%;
  max-width: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.site-mediyoung th:nth-child(2),
.site-mediyoung td:nth-child(2) {
  width: 14%;
}

.site-mediyoung th:nth-child(n+3),
.site-mediyoung td:nth-child(n+3) {
  width: 28%;
}

.site-mediyoung th {
  white-space: normal;
  word-break: keep-all;
}

.stock-delay-badge {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid #eac487;
  border-radius: 4px;
  background: #fff4df;
  color: #8b570b;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}

.site-updated {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.site-filter {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.site-select {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(241, 143, 1, 0.28);
  border-radius: 0;
  background: #ffffff;
  color: var(--ink);
  padding: 6px 10px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 0;
}

tr.is-hidden {
  display: none;
}

th.name-cell,
td.name-cell {
  width: 64%;
  max-width: 300px;
}

th:not(.name-cell),
td:not(.name-cell) {
  width: 12%;
}

.site-dongwon th.name-cell,
.site-dongwon td.name-cell {
  width: 60%;
  max-width: none;
  font-size: 12px;
}

.site-dongwon th:not(.name-cell),
.site-dongwon td:not(.name-cell) {
  width: 20%;
}

.site-geoyoung th.name-cell,
.site-geoyoung td.name-cell {
  width: 55%;
  max-width: none;
  font-size: 12px;
}

.site-geoyoung th:not(.name-cell),
.site-geoyoung td:not(.name-cell) {
  width: 15%;
}

.site-geopharm th.name-cell,
.site-geopharm td.name-cell {
  width: 60%;
  max-width: none;
  font-size: 12px;
}

.site-geopharm th:not(.name-cell),
.site-geopharm td:not(.name-cell) {
  width: 20%;
}

.site-smartpharm th.name-cell,
.site-smartpharm td.name-cell {
  width: 34%;
  max-width: 160px;
  font-size: 12px;
}

.site-smartpharm th:not(.name-cell),
.site-smartpharm td:not(.name-cell) {
  width: 16%;
}

.site-baekje th.name-cell,
.site-baekje td.name-cell {
  width: 60%;
  max-width: none;
}

.site-baekje th:not(.name-cell),
.site-baekje td:not(.name-cell) {
  width: 20%;
}

th {
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 900;
}

.site-empty,
.site-error {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.site-error {
  color: var(--red);
}

.site-loading {
  padding: 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 900px) {
  .inventory-page {
    width: min(100vw - 20px, 760px);
  }

  #productSearchForm,
  .product-results,
  .site-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .selected-head,
  .stock-head,
  .product-button {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

/* Final portal frame alignment: match the home page first-card position. */
body {
  background: linear-gradient(180deg, #f4f7fb 0%, #e9eef5 100%) !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.62;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.34) 0 18%, transparent 18% 100%),
    linear-gradient(-16deg, rgba(255, 255, 255, 0.2) 0 16%, transparent 16% 100%);
}

.inventory-page {
  width: min(1460px, calc(100vw - 40px)) !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding: 42px 36px 36px !important;
  gap: 18px !important;
}

@media (max-width: 980px) {
  .inventory-page {
    width: auto !important;
    padding: 20px 18px 18px !important;
  }
}

@media (max-width: 720px) {
  .inventory-page {
    width: min(100vw - 24px, 100%) !important;
    gap: 14px !important;
  }
}
