:root {
  color-scheme: light;
  --background: #f6f3ee;
  --surface: #ffffff;
  --surface-soft: #edf2ee;
  --ink: #1d2c25;
  --muted: #68746e;
  --line: #e3ddd4;
  --accent: #304c3f;
  --accent-strong: #20372d;
  --success: #dff1e5;
  --success-ink: #205c38;
  --warning: #fff0c2;
  --warning-ink: #70520d;
  --danger: #f8e1df;
  --danger-ink: #7d302b;
  --shadow: 0 14px 38px rgba(29, 44, 37, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(48, 76, 63, 0.25);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 26px 16px 18px;
  background: var(--accent-strong);
  color: white;
}

.brand {
  margin: 0 10px;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.product-label {
  margin: 5px 10px 27px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.navigation {
  display: grid;
  gap: 5px;
}

.nav-button {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 11px 13px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  text-align: left;
}

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

.sidebar-boundary {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 11px;
  line-height: 1.45;
}

.sidebar-boundary strong {
  color: white;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.workspace-header,
.section-heading,
.button-row,
.header-actions,
.summary-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.workspace-header,
.section-heading {
  justify-content: space-between;
  align-items: flex-start;
}

.workspace-header {
  margin-bottom: 18px;
}

.workspace-header h1,
.section-heading h2 {
  margin: 0;
}

.workspace-header h1 {
  font-size: clamp(25px, 3vw, 34px);
}

.section-heading h2 {
  font-size: 18px;
}

.section-heading p,
.subtitle,
.security-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.header-actions {
  justify-content: flex-end;
}

.status-badge,
.boundary-chip,
.data-badge {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.status-badge.warning,
.data-badge.warning {
  background: var(--warning);
  color: var(--warning-ink);
}

.status-badge.success,
.data-badge.success {
  background: var(--success);
  color: var(--success-ink);
}

.data-badge.danger {
  background: var(--danger);
  color: var(--danger-ink);
}

.boundary-chip {
  border: 1px solid var(--line);
  background: #f9f7f3;
  color: var(--muted);
}

.card,
.kpi {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  margin-top: 16px;
  border-radius: 18px;
  padding: 17px;
}

.connection-card {
  margin-bottom: 18px;
}

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

.connection-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

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

.button-row {
  margin-top: 13px;
}

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

.product-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #ece8e1;
}

.product-thumb-empty {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.product-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  min-height: 39px;
  border: 1px solid var(--accent);
  border-radius: 11px;
  padding: 9px 13px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.button.secondary {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.message-region:empty {
  display: none;
}

.message {
  margin-top: 11px;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.message.success {
  background: var(--success);
  color: var(--success-ink);
}

.message.error {
  background: var(--danger);
  color: var(--danger-ink);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 11px;
}

.kpi-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.kpi {
  border-radius: 15px;
  padding: 14px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 25px;
}

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

.intake-columns {
  align-items: start;
}

.check-list {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 1.45;
}

.check-list li {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 9px;
  align-items: start;
}

.dot {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
}

.dot.ready {
  background: #3f8a5a;
}

.dot.waiting {
  background: #d5a528;
}

.summary-row {
  margin-top: 10px;
}

.summary-pill {
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 11px;
  font-weight: 750;
}

.table-wrap {
  margin-top: 13px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 11px;
  border-bottom: 1px solid #eee9e2;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

th {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.mono {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  overflow-wrap: anywhere;
}

.cell-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.empty-state,
.empty-cell {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.empty-state {
  padding: 30px 12px;
}

.empty-cell {
  padding: 30px;
}

.catalog-preview-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.catalog-preview-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #eee9e2;
  padding-bottom: 8px;
  font-size: 12px;
}

.catalog-preview-item:last-child {
  border-bottom: 0;
}

.lab-result {
  min-height: 43px;
  margin-top: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 11px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    display: block;
    width: auto;
    height: auto;
    padding: 16px;
  }

  .product-label {
    margin-bottom: 13px;
  }

  .navigation {
    display: flex;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .nav-button {
    width: auto;
    white-space: nowrap;
  }

  .sidebar-boundary {
    display: none;
  }

  .workspace {
    padding: 16px;
  }

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace-header {
    display: block;
  }

  .header-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .form-grid,
  .connection-grid,
  .kpi-grid,
  .kpi-grid.compact {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
