:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-muted: #eef3ec;
  --ink: #18211f;
  --muted: #66706b;
  --line: #dbe4dc;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --green: #16803c;
  --green-soft: #e7f6ec;
  --amber: #a45c05;
  --amber-soft: #fff3d7;
  --red: #b42318;
  --red-soft: #fde8e7;
  --blue: #275da8;
  --blue-soft: #e6effd;
  --shadow: 0 18px 45px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  background: #1b2b28;
  color: #f7fbf8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand,
.topbar-status,
.toolbar,
.meta-row,
.panel-heading,
.live-pill,
.icon-button,
.switch {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: #d8fff3;
  color: #0d5c53;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: #7f8f8a;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #b9c8c2;
}

h1,
h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 1.55rem;
  line-height: 1.18;
}

h2 {
  font-size: 1.25rem;
}

.topbar-status {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.live-pill {
  gap: 8px;
  min-height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #e9f4f0;
  font-weight: 700;
  white-space: nowrap;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f4a261;
  box-shadow: 0 0 0 4px rgba(244, 162, 97, 0.18);
}

.live-pill.ok .live-dot {
  background: #55d67a;
  box-shadow: 0 0 0 4px rgba(85, 214, 122, 0.18);
}

.live-pill.error .live-dot {
  background: #ff6b5f;
  box-shadow: 0 0 0 4px rgba(255, 107, 95, 0.18);
}

.toolbar-band,
.inventory-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar-band {
  position: sticky;
  top: 12px;
  z-index: 3;
  padding: 14px;
}

.toolbar {
  flex-wrap: wrap;
  gap: 12px;
}

.field {
  display: grid;
  min-width: 170px;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-grow {
  flex: 1 1 250px;
}

.field.compact {
  min-width: 120px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  color: var(--ink);
  outline: none;
}

input {
  padding: 0 13px;
}

select {
  padding: 0 36px 0 12px;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

input:disabled {
  color: #8b9791;
  background: #f1f5f2;
}

.icon-button {
  min-height: 42px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button.primary {
  border-color: #0b5f58;
  background: #d8fff3;
  color: #073f3a;
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.switch {
  gap: 9px;
  min-height: 42px;
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.switch-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #c6d1ca;
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(24, 33, 31, 0.25);
  content: "";
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--brand);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.summary-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-card.good {
  background: var(--green-soft);
  border-color: #c4e8cf;
}

.summary-card.watch {
  background: var(--amber-soft);
  border-color: #f4d89c;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.meta-row {
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.meta-row div {
  min-width: 0;
  padding: 10px 0;
}

.meta-row span {
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
}

.meta-row strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #f0bbb7;
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 800;
}

.inventory-panel {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading > div {
  min-width: 0;
}

.panel-heading > span {
  flex: 0 0 auto;
  max-width: 45%;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

.product-card {
  min-width: 0;
  min-height: 190px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: #ffffff;
}

.product-card.normal {
  border-left-color: var(--green);
}

.product-card.general {
  border-left-color: var(--amber);
}

.product-card.low,
.product-card.offline {
  border-left-color: var(--red);
}

.product-card.unknown {
  border-left-color: var(--blue);
}

.product-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.product-title {
  min-width: 0;
}

.product-title h3 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.product-id {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-badge {
  flex: 0 0 auto;
  max-width: 44%;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.status-badge.normal {
  background: var(--green-soft);
  color: var(--green);
}

.status-badge.general {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.low,
.status-badge.offline {
  background: var(--red-soft);
  color: var(--red);
}

.status-badge.unknown {
  background: var(--blue-soft);
  color: var(--blue);
}

.product-note {
  min-height: 46px;
  margin: 16px 0;
  color: var(--ink);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.product-foot {
  display: grid;
  gap: 5px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.product-foot strong {
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 220px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.1rem;
}

.is-loading .icon-button.primary svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-status {
    justify-content: flex-start;
    width: 100%;
  }

  .summary-grid,
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .toolbar-band,
  .inventory-panel {
    border-radius: 8px;
  }

  .toolbar-band {
    position: static;
  }

  .toolbar,
  .field,
  .icon-button,
  .switch,
  .topbar-status {
    width: 100%;
  }

  .icon-button {
    justify-content: center;
  }

  .summary-grid,
  .product-grid {
    grid-template-columns: 1fr;
  }

  .meta-row,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-heading > span,
  .status-badge {
    max-width: 100%;
  }
}
