:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #617069;
  --line: #dce5df;
  --paper: #f6f8f5;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #2563eb;
  --green-soft: #dff5ed;
  --amber-soft: #fff3d6;
  --red-soft: #ffe4df;
  --shadow: 0 16px 40px rgba(29, 45, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  background: #14221d;
  color: white;
  padding: 24px 18px;
}

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

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

.brand span,
.topbar p,
.panel-head span,
.note {
  color: var(--muted);
}

.brand span {
  display: block;
  color: #b7c8c0;
  font-size: 13px;
}

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

.nav-item {
  width: 100%;
  border-radius: 8px;
  padding: 12px 14px;
  background: transparent;
  color: #dce9e3;
  text-align: left;
}

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

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

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 32px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.actions,
.toolbar,
.dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.primary,
.ghost,
.danger {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  background: #e8efea;
  color: var(--ink);
}

.danger {
  background: var(--red-soft);
  color: var(--red);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.split,
.integration-layout,
.stockout-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar {
  margin-bottom: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

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

.toolbar input {
  max-width: 520px;
}

.toolbar select {
  max-width: 190px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.item-title strong {
  display: block;
}

.product-cell {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.thumb {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #eef2ef;
}

.thumb.placeholder,
.photo-preview.placeholder,
.variant-preview.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.item-title span,
.compact-row span,
.task span,
.color-list {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--green-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

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

.badge.red {
  background: var(--red-soft);
  color: var(--red);
}

.badge.muted {
  background: #eef2ef;
  color: var(--muted);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #eef2ef;
  color: var(--ink);
  font-size: 20px;
}

.task-list,
.compact-list,
.sync-list {
  display: grid;
  gap: 10px;
}

.task,
.compact-row,
.sync-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.lane {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
  box-shadow: var(--shadow);
}

.lane h2 {
  margin-bottom: 12px;
}

.sale-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.sale-card strong {
  font-size: 15px;
}

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

.variants-editor {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.photo-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.photo-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.photo-preview {
  width: 86px;
  height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #eef2ef;
}

.photo-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  background: #e8efea;
  color: var(--ink);
  font-size: 14px;
}

.photo-button input {
  display: none;
}

.variants-head,
.variant-row {
  display: grid;
  grid-template-columns: 74px 1fr 0.8fr 90px 1.1fr 38px;
  gap: 8px;
  align-items: center;
}

.variants-head {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#variantsList {
  display: grid;
  gap: 8px;
}

.variant-photo {
  position: relative;
}

.variant-preview {
  display: block;
  width: 56px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #eef2ef;
}

.variant-photo input[type="file"] {
  display: none;
}

.variant-photo button {
  position: absolute;
  right: 8px;
  bottom: 4px;
  min-height: 22px;
  border-radius: 6px;
  padding: 0 7px;
  background: rgba(20, 34, 29, 0.82);
  color: white;
  font-size: 11px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label.full {
  display: grid;
  margin-top: 14px;
}

.note {
  margin: 14px 0 0;
  line-height: 1.5;
}

.strong-note {
  color: var(--ink);
  font-weight: 700;
}

dialog {
  width: min(760px, calc(100vw - 30px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(18, 30, 25, 0.24);
}

dialog::backdrop {
  background: rgba(20, 34, 29, 0.42);
}

.item-form {
  padding: 20px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  margin-top: 18px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    overflow: auto;
  }

  .nav-item {
    white-space: nowrap;
    text-align: center;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .split,
  .integration-layout,
  .stockout-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .metrics,
  .kanban,
  .form-grid,
  .settings-grid,
  .photo-editor,
  .variants-head,
  .variant-row {
    grid-template-columns: 1fr;
  }

  .actions,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar input,
  .toolbar select {
    max-width: none;
  }
}
