:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #19212a;
  --muted: #66717f;
  --line: #dce2ea;
  --brand: #176f6b;
  --brand-strong: #0f5754;
  --accent: #b5491f;
  --soft: #edf5f4;
  --danger: #ad2d2d;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.sidebar {
  background: #102022;
  color: #f7faf9;
  padding: 24px 18px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 28px;
}

.nav-button {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
  color: #dbe8e6;
  background: transparent;
}

.nav-button.active,
.nav-button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.content {
  padding: 28px;
  max-width: 1220px;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

h1 {
  margin: 0 0 6px;
  font-size: 30px;
}

.subtitle,
.muted {
  color: var(--muted);
}

.actions,
.filters,
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary {
  background: var(--brand);
  color: white;
  padding: 11px 15px;
}

.primary:hover {
  background: var(--brand-strong);
}

.secondary {
  background: #e7ecef;
  color: var(--ink);
  padding: 10px 13px;
}

.danger {
  background: #f3dfdf;
  color: var(--danger);
  padding: 9px 11px;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

label {
  color: #34404b;
  font-weight: 700;
  font-size: 14px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
  min-width: 0;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.filters input {
  min-width: 260px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.product-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  min-height: 148px;
  position: relative;
}

.inline-check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}

.classify-list {
  display: grid;
  gap: 6px;
}

.classify-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
  font-weight: 600;
  font-size: 14px;
}

.product-card img,
.placeholder {
  width: 112px;
  height: 148px;
  object-fit: contain;
  object-position: center;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.placeholder {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 800;
}

.product-body {
  padding: 13px;
  display: grid;
  gap: 8px;
}

.product-title {
  font-weight: 800;
  line-height: 1.25;
}

.badge {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
}

.price {
  color: var(--accent);
  font-size: 20px;
  font-weight: 900;
}

.empty {
  border: 1px dashed #b7c2cc;
  border-radius: 8px;
  padding: 36px 20px;
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 22, 0.48);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.modal header,
.modal footer {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal main {
  padding: 18px;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail {
  display: grid;
  grid-template-columns: minmax(220px, 330px) 1fr;
  gap: 18px;
}

.detail img,
.detail .placeholder {
  width: 100%;
  height: 260px;
  border-radius: 8px;
  object-fit: contain;
  object-position: center;
  background: #ffffff;
  border: 1px solid var(--line);
}

.history {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
}

.history th,
.history td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.history th {
  color: var(--muted);
  font-size: 13px;
}

.history-actions-cell {
  position: relative;
  width: 64px;
}

.history-row-actions {
  position: relative;
  display: flex;
  justify-content: center;
}

.history-menu-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.history-menu-button:hover,
.history-menu-button[aria-expanded="true"] {
  background: var(--soft);
}

.history-action-menu {
  position: absolute;
  top: 38px;
  right: 0;
  z-index: 12;
  display: grid;
  min-width: 128px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  box-shadow: 0 10px 24px rgba(24, 34, 42, 0.16);
}

.history-action-menu button {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.history-action-menu button:hover {
  background: var(--soft);
}

.history-action-menu .danger-text {
  color: #b02f2f;
}

.history-edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid #9db8aa;
  border-radius: 7px;
  background: #eef7f1;
  color: #234b38;
  font-weight: 700;
}

.category-list {
  display: grid;
  gap: 10px;
}

.category-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
}

.category-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  max-width: 310px;
}

.subcategory-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.subcategory-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.subcategory-item small {
  color: var(--muted);
  margin-left: 6px;
}

.compact {
  padding: 5px 7px;
  font-size: 12px;
  line-height: 1.15;
}

.compact-actions {
  max-width: none;
}

.iconish {
  font-weight: 600;
}

.info-button {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 900;
  vertical-align: middle;
}

.notice {
  background: #fff7e8;
  border: 1px solid #ebd2a1;
  color: #765018;
  padding: 10px;
  border-radius: 7px;
  margin-bottom: 12px;
}

@media (max-width: 780px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 14px;
  }

  .brand {
    margin-bottom: 10px;
  }

  .content {
    padding: 18px;
  }

  .topbar,
  .detail,
  .two {
    grid-template-columns: 1fr;
    display: grid;
  }

  .filters input,
  .filters select,
  .actions button {
    width: 100%;
  }

  .category-item,
  .subcategory-item {
    grid-template-columns: 1fr;
  }

  .category-actions {
    justify-content: flex-start;
    max-width: none;
  }

  .category-actions button {
    width: auto;
  }
}
