:root {
  color-scheme: light;
  --ink: #182024;
  --muted: #64727a;
  --line: #dce4e6;
  --panel: #ffffff;
  --page: #f5f7f2;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --warn: #b45309;
  --soft: #e7f3f1;
  --shadow: 0 16px 40px rgba(24, 32, 36, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel h1,
.auth-panel p {
  margin: 0;
}

.auth-panel h1 {
  font-size: 32px;
}

.auth-error {
  color: #b91c1c;
  font-weight: 700;
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.button-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0 14px;
  text-decoration: none;
}

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

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

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 28px;
  background: #172326;
  color: #fff;
}

.sidebar h1,
.topbar h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.sidebar h1 {
  font-size: 30px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: #83d8ce;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.nav-button,
.ghost {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #d9eeee;
  text-align: left;
  padding: 0 14px;
}

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

.ghost.dark {
  width: auto;
  color: var(--ink);
  border-color: var(--line);
}

.ghost.dark:hover {
  color: #fff;
  background: var(--accent-dark);
}

.full {
  margin-top: auto;
}

.backup-actions {
  display: grid;
  gap: 8px;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.topbar .eyebrow {
  color: var(--accent);
}

.topbar h2 {
  font-size: 34px;
}

.cloud-status {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cloud-status.connected {
  color: var(--accent);
}

.cloud-status.offline {
  color: var(--warn);
}

.cloud-status.conflict {
  color: #b91c1c;
}

.topbar-stack {
  display: grid;
  gap: 10px;
}

.session-user {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.metric-range {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.metric-range label {
  display: grid;
  gap: 4px;
  min-width: 140px;
}

.metric-range span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

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

.metric {
  min-height: 78px;
  padding: 14px;
}

.metric span,
.panel-head p,
.muted,
td span,
td small {
  color: var(--muted);
}

.metric span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  font-size: 20px;
}

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

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

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

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

.panel {
  padding: 18px;
}

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

.panel-head p {
  margin: 0;
}

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

.search {
  max-width: 380px;
}

.search-actions {
  display: grid;
  grid-template-columns: 150px minmax(220px, 380px) 96px 110px;
  gap: 10px;
  align-items: center;
}

.context-menu {
  position: fixed;
  z-index: 70;
  display: grid;
  gap: 4px;
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(9, 18, 20, 0.24);
}

.context-menu button {
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0 10px;
}

.context-menu button:hover {
  background: var(--soft);
  color: var(--accent-dark);
}

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

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

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

tr.excluded-row {
  opacity: 0.55;
  background: #f1f3f0;
}

tr.excluded-row .sku-link {
  color: var(--muted);
}

td strong,
td span,
td small {
  display: block;
}

td small {
  margin-top: 4px;
  font-size: 12px;
}

.stock-counted,
.stock-partial,
.stock-not-counted {
  width: max-content;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 999px;
  font-weight: 700;
}

.stock-counted {
  background: #e6f5ed;
  color: #17643a;
}

.stock-partial {
  background: #fff3d6;
  color: #7a4d00;
}

.stock-not-counted {
  background: #f2e8e6;
  color: #8a2f1c;
}

td input,
td select {
  width: 100%;
  min-height: 36px;
  padding: 0 8px;
}

.table-thumb {
  display: grid;
  width: 46px;
  height: 46px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #edf4f1;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
  object-fit: cover;
}

.risk-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

.risk-dot.accept,
.risk-dot.none {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

.risk-dot.investigate {
  background: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}

.risk-dot.cancel {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.sku-link {
  width: auto;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  text-align: left;
  font-weight: 900;
}

.sku-link:hover {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

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

.form {
  display: grid;
  gap: 10px;
}

.form.row {
  grid-template-columns: 150px 1fr 130px 130px 1fr 110px;
}

.orders-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(170px, 1fr) 150px 150px 120px;
  gap: 10px;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.product-detail {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 104px);
}

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

.modal-window {
  width: min(1180px, 100%);
  height: min(880px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.34);
  padding: 18px;
}

.detail-header {
  display: grid;
  grid-template-columns: 112px minmax(180px, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.compact-header {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.detail-stats {
  grid-column: 1 / -1;
}

.product-image {
  display: grid;
  width: 112px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf4f1;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image.empty span {
  color: var(--accent-dark);
  font-size: 30px;
  font-weight: 900;
}

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

.icon-close {
  width: auto;
  min-height: 38px;
  padding: 0 14px;
  background: #233134;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.detail-form {
  gap: 14px;
  width: 100%;
}

.tab-panel {
  width: 100%;
  min-height: 430px;
  align-content: start;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.tab-button {
  width: auto;
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
}

.tab-button:hover,
.tab-button.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent-dark);
}

fieldset,
.subpanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
}

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

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

legend {
  padding: 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

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

.subpanel {
  padding: 14px;
}

.composition-list,
.history-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.composition-table {
  display: grid;
  gap: 0;
  overflow-x: auto;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.composition-table-head,
.composition-table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(80px, 0.7fr) minmax(110px, 0.8fr) minmax(190px, 1fr) minmax(110px, 0.8fr) minmax(96px, 0.6fr);
  gap: 10px;
  align-items: center;
  min-width: 850px;
  padding: 10px 12px;
}

.composition-table-head {
  background: #f3f7f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.composition-table-row {
  background: #fff;
  border-top: 1px solid var(--line);
}

.composition-line,
.history-line {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.composition-line {
  grid-template-columns: 1fr auto auto;
  align-items: center;
}

.composition-line.editable {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 320px) auto;
}

.composition-quantity {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.composition-quantity label {
  min-width: 0;
}

.history-line span,
.history-line small {
  color: var(--muted);
}

.history-line small {
  font-size: 12px;
}

.history-table {
  display: grid;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-table-head,
.history-table-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(100px, 0.7fr) minmax(90px, 0.6fr) minmax(190px, 1fr) minmax(220px, 1.4fr);
  gap: 10px;
  align-items: center;
  min-width: 820px;
  padding: 10px 12px;
}

.history-table-head {
  background: #f3f7f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.history-table-row {
  background: #fff;
  border-top: 1px solid var(--line);
}

.history-cost-form {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 8px;
}

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

.stock-remove-form {
  margin-top: 0;
}

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

.button-row button {
  width: auto;
  padding: 0 14px;
}

.detail-pairs {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px 14px;
}

.detail-pairs span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-pairs strong {
  min-width: 0;
}

.address-lines {
  display: grid;
  gap: 3px;
  line-height: 1.35;
}

.address-lines span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-transform: none;
}

.shipping-label-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.label-list {
  display: grid;
  gap: 8px;
}

.label-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(170px, 1.1fr) minmax(180px, 1.1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.mini {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.danger {
  background: #b42318;
}

.danger:hover {
  background: #8f1d14;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metric-range {
    justify-content: stretch;
  }

  .metric-range label {
    flex: 1 1 160px;
  }

  .grid.two,
  .grid.three,
  .form.row,
  .detail-header,
  .detail-grid,
  .search-actions,
  .form-grid,
  .form-grid.compact,
  .stock-actions,
  .shipping-label-form,
  .label-row,
  .orders-toolbar,
  .detail-pairs {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

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

  .metric-range {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel-head,
  .detail-stats,
  .triple,
  .inline-form,
  .composition-line,
  .composition-line.editable,
  .composition-quantity {
    grid-template-columns: 1fr;
  }

  .panel-head {
    display: grid;
  }

  .topbar h2 {
    font-size: 28px;
  }
}
