:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #5d6876;
  --line: #d8dee7;
  --surface: #ffffff;
  --page: #f4f7f5;
  --accent: #2f6f5e;
  --accent-strong: #214f44;
  --warn: #b2442f;
  --ok: #2f6f5e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  display: grid;
  grid-template-columns: 260px 1fr;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sidebar {
  background: #17211d;
  color: #f5fbf8;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: #f1c84b;
  color: #17211d;
  font-weight: 800;
}

.brand small,
.topbar p,
.card span,
.status-list span {
  color: var(--muted);
}

.sidebar .brand small,
.sidebar nav a,
.logout-form span {
  color: #c8d5cf;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  background: #26352f;
  color: #ffffff;
}

.logout-form {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 18px;
}

.card,
.panel,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card {
  padding: 18px;
}

.stat-card {
  display: grid;
  gap: 8px;
}

.stat-card strong {
  font-size: 26px;
}

.panel {
  padding: 22px;
}

.panel.narrow {
  max-width: 620px;
}

.panel-heading {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.status-list {
  display: grid;
  gap: 12px;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 650;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  background: #ffffff;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  padding: 11px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.button-link {
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  padding: 10px 13px;
  font-weight: 700;
  text-decoration: none;
}

.button-link.secondary {
  background: #3b4d5c;
}

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

.login-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 26px;
}

.login-brand {
  margin-bottom: 24px;
}

.alert,
.success {
  border-radius: 6px;
  padding: 10px 12px;
}

.alert {
  color: #6f2012;
  background: #f8ded8;
}

.success {
  color: var(--ok);
  background: #e3f1ed;
  margin-bottom: 16px;
}

.etsy-api-notice {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fbfcfd;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.low-stock {
  background: #fff8e1;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.warning {
  color: #785100;
  background: #ffe5a3;
}

.badge.ok {
  color: #1f5d4c;
  background: #dff1ec;
}

.badge.muted {
  color: #58606b;
  background: #e7ebf0;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.empty-state {
  display: grid;
  gap: 6px;
  color: var(--muted);
  padding: 24px 0;
}

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

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

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  resize: vertical;
  font: inherit;
}

.checkbox-label {
  display: flex;
  align-items: center;
}

.checkbox-label input {
  width: auto;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

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

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

.product-card img,
.photo-strip img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #eef2f4;
}

.product-card-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.product-card h3 {
  margin: 0;
}

.product-card span,
.description {
  color: var(--muted);
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.metric-list dt {
  color: var(--muted);
}

.metric-list dd {
  margin: 0;
  font-weight: 800;
}

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

.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.cost-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  align-self: start;
}

.inline-form,
.bom-form {
  display: grid;
  gap: 12px;
}

.bom-form {
  grid-template-columns: minmax(180px, 1fr) 180px minmax(180px, 1fr) auto;
  align-items: end;
  margin-bottom: 18px;
}

.link-button {
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.link-button.danger {
  color: var(--warn);
}

.inline-reset-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.table-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
  margin-bottom: 6px;
}

.notes-block {
  margin-top: 18px;
}

.status-form {
  grid-template-columns: minmax(220px, 320px) auto;
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(120px, 180px) auto;
  gap: 8px;
  align-items: center;
}

.chart-list {
  display: grid;
  gap: 14px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 14px;
  align-items: center;
}

.chart-row small,
.bar-stack small {
  color: var(--muted);
}

.bar-stack {
  display: grid;
  gap: 5px;
}

.bar-track {
  height: 14px;
  border-radius: 999px;
  background: #e7ebf0;
  overflow: hidden;
}

.bar-track span {
  display: block;
  min-width: 3px;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.workflow-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.workflow-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.workflow-column h3 {
  margin: 0;
  font-size: 15px;
}

.workflow-card {
  display: grid;
  gap: 5px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.workflow-card span,
.workflow-card small {
  color: var(--muted);
}

.workflow-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.empty-state.compact {
  padding: 8px 0;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

@media (max-width: 520px) {
  .main {
    padding: 18px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .status-list div {
    display: grid;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .product-detail-grid,
  .bom-form,
  .filter-form,
  .chart-row {
    grid-template-columns: 1fr;
  }
}
