:root {
  color-scheme: light;
  --ink: #10191b;
  --ink-soft: #344044;
  --paper: #f2f0e9;
  --panel: #fbfaf6;
  --line: #d9d8d0;
  --line-strong: #babbb4;
  --muted: #6e7677;
  --accent: #ff6a32;
  --accent-dark: #d94a16;
  --blue: #005bff;
  --green: #157e57;
  --yellow: #f5c84c;
  --red: #cc3b2e;
  --sidebar: 236px;
  --radius: 14px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Onest", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(16, 25, 27, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 25, 27, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 24px 18px 18px;
  background: var(--ink);
  color: #f5f2e9;
  border-right: 1px solid #263235;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
  letter-spacing: .05em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--accent);
  color: #10191b;
  border-radius: 4px 12px 4px 4px;
  font: 700 21px/1 var(--mono);
}

.brand strong { display: block; font-size: 14px; letter-spacing: .13em; }
.brand small { display: block; margin-top: 1px; color: #95a0a2; font: 10px/1.2 var(--mono); letter-spacing: .04em; }

.nav { display: grid; gap: 6px; margin-top: 60px; }
.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 25px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #aeb7b8;
  text-align: left;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}
.nav-item:hover { background: #1a2629; color: white; transform: translateX(2px); }
.nav-item.is-active { background: #f5f2e9; color: var(--ink); }
.nav-item b {
  min-width: 23px;
  padding: 2px 6px;
  border-radius: 10px;
  background: #293638;
  color: #aeb7b8;
  font: 500 10px/1.4 var(--mono);
  text-align: center;
}
.nav-item.is-active b { background: var(--accent); color: var(--ink); }
.nav-icon { font: 18px/1 var(--mono); }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 10px;
  border: 1px solid #2e3a3d;
  border-radius: 9px;
  background: #141f21;
}
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 11px; font-weight: 600; }
.sidebar-foot small { color: #7e8b8d; font-size: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px rgba(245, 200, 76, .12); }

.workspace {
  grid-column: 2;
  min-width: 0;
  padding: 0 clamp(18px, 3.5vw, 54px) 52px;
}

.topbar {
  min-height: 95px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line-strong);
}
.topbar h1 { margin: 2px 0 0; font-size: 24px; line-height: 1; letter-spacing: -.04em; }
.eyebrow, .section-index { margin: 0; color: var(--muted); font: 500 10px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.sync-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sync-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.sync-state.is-saving i { background: var(--yellow); animation: pulse 1s infinite; }
.sync-state.is-error i { background: var(--red); }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); cursor: pointer; }

.view { display: none; animation: reveal .28s ease both; }
.view.is-active { display: block; }

.inventory-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
  gap: 36px;
  align-items: end;
  padding: 44px 0 30px;
}
.hero-copy h2, .section-heading h2 {
  margin: 10px 0 10px;
  max-width: 760px;
  font-size: clamp(31px, 4vw, 56px);
  line-height: .98;
  letter-spacing: -.055em;
}
.hero-copy p, .section-heading p { max-width: 650px; margin: 0; color: var(--muted); font-size: 15px; }

.completion-card {
  padding: 22px;
  background: var(--ink);
  color: white;
  border-radius: 6px 22px 6px 6px;
  box-shadow: 0 18px 40px rgba(16, 25, 27, .12);
}
.completion-top { display: flex; align-items: baseline; justify-content: space-between; }
.completion-top span { color: #98a4a6; font-size: 12px; }
.completion-top strong { font: 600 30px/1 var(--mono); }
.progress-track { height: 7px; margin: 19px 0 12px; overflow: hidden; border-radius: 10px; background: #334043; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .45s cubic-bezier(.22,1,.36,1); }
.completion-card p { margin: 0; color: #98a4a6; font: 11px/1.4 var(--mono); }
.completion-card p b { color: white; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}
.metric { min-height: 125px; padding: 20px 22px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span, .metric small { display: block; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin: 9px 0 5px; font: 600 32px/1 var(--mono); letter-spacing: -.04em; }
.metric small { color: #8b9292; font-size: 10px; }
.metric-primary { position: relative; background: #fff; }
.metric-primary::after { content: ""; position: absolute; inset: auto 18px 14px auto; width: 18px; height: 18px; border-right: 4px solid var(--accent); border-bottom: 4px solid var(--accent); }

.table-panel {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(16, 25, 27, .06);
}
.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 15px;
  border-bottom: 1px solid var(--line);
}
.toolbar-main, .toolbar-actions { display: flex; align-items: center; gap: 8px; }
.search-box {
  min-width: min(340px, 30vw);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.search-box:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(16, 25, 27, .06); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::placeholder { color: #9ca2a1; }
.search-box kbd { padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; color: #8e9696; background: #f5f4ef; font: 9px/1.4 var(--mono); }
select {
  height: 40px;
  padding: 0 32px 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink-soft);
  cursor: pointer;
}
.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-quiet { border-color: var(--line); background: white; color: var(--ink-soft); }
.button-accent { background: var(--accent); color: var(--ink); box-shadow: 0 5px 14px rgba(255, 106, 50, .18); }
.button-accent:hover { background: #ff7947; }
.button-accent.is-active { background: var(--ink); color: white; }

.category-tabs { display: flex; gap: 6px; padding: 11px 15px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.category-tab {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 15px;
  background: #ebeae4;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.category-tab.is-active { background: var(--ink); color: white; }
.category-tab b { margin-left: 5px; font: 500 9px/1 var(--mono); opacity: .7; }

.table-scroll { overflow: auto; max-height: min(62vh, 720px); }
.stock-table { width: 100%; min-width: 1190px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.stock-table th {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 38px;
  padding: 0 11px;
  border-bottom: 1px solid var(--line-strong);
  background: #ecebe5;
  color: #697273;
  font: 500 9px/1 var(--mono);
  letter-spacing: .055em;
  text-align: left;
  text-transform: uppercase;
}
.stock-table td { height: 58px; padding: 7px 11px; border-bottom: 1px solid #e4e3dc; vertical-align: middle; }
.stock-table tbody tr { transition: background-color .12s ease; }
.stock-table tbody tr:hover { background: #f6f4ed; }
.stock-table tbody tr.is-unfilled { background: rgba(245, 200, 76, .055); }
.stock-table tbody tr.is-saving { opacity: .55; }
.col-number { width: 44px; }
.col-product { width: 270px; }
.col-stock, .col-reserved, .col-available { width: 94px; }
.col-warehouse { width: 150px; }
.col-sku { width: 215px; }
.col-status { width: 120px; }
.col-note { width: 175px; }
.row-number { color: #9ca2a1; font: 10px/1 var(--mono); }
.product-name { display: block; font-weight: 600; line-height: 1.25; }
.product-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.mono-cell { color: var(--ink-soft); font: 10px/1.35 var(--mono); overflow-wrap: anywhere; }

.stock-input {
  width: 72px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: white;
  color: var(--ink);
  font: 600 15px/1 var(--mono);
  text-align: right;
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}
.stock-input::placeholder { color: #b5b9b7; }
.stock-input:hover { border-color: #aeb2af; }
.stock-input:focus { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(255, 106, 50, .12); }
.inventory-mode .stock-input[data-field="stock"] { border-color: var(--accent); background: #fff8f2; }
.available-value { font: 600 14px/1 var(--mono); }
.available-value.is-empty { color: #a9aeac; }
.note-input { width: 100%; height: 34px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; outline: 0; color: var(--ink-soft); font-size: 11px; }
.note-input:hover, .note-input:focus { border-color: var(--line); background: white; }
.note-input::placeholder { color: #a9aeac; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 10px; }
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.status-unfilled::before { background: var(--yellow); }
.status-out::before { background: var(--red); }
.status-low::before { background: var(--accent); }
.status-healthy::before { background: var(--green); }

.empty-state { padding: 65px 20px; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { margin-bottom: 4px; color: var(--ink); }
.table-footer { display: flex; justify-content: space-between; padding: 11px 15px; border-top: 1px solid var(--line); color: var(--muted); font: 10px/1.4 var(--mono); }

.section-heading { padding: 52px 0 30px; }
.activity-list { display: grid; gap: 8px; max-width: 980px; }
.activity-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.activity-badge { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #e8e7e1; font: 600 11px/1 var(--mono); }
.activity-badge.marketplace { background: #e5eeff; color: var(--blue); }
.activity-copy strong { display: block; margin-bottom: 3px; font-size: 13px; }
.activity-copy p { margin: 0; color: var(--muted); font-size: 11px; }
.activity-time { color: var(--muted); font: 10px/1.4 var(--mono); text-align: right; }
.activity-empty { padding: 54px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; }

.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 440px)); gap: 18px; }
.integration-card { position: relative; min-height: 270px; padding: 24px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); }
.integration-card h3 { margin: 33px 0 6px; font-size: 22px; letter-spacing: -.03em; }
.integration-card p { max-width: 330px; margin: 0; color: var(--muted); }
.integration-logo { height: 38px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.ozon-logo { padding: 0 12px; border-radius: 9px; background: var(--blue); color: white; letter-spacing: -.04em; }
.yandex-logo { width: 38px; border-radius: 10px; background: var(--yellow); color: #e52922; font-size: 22px; }
.connection-pill { position: absolute; top: 25px; right: 24px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font: 9px/1.2 var(--mono); }
.connection-pill.is-ready { border-color: rgba(21, 126, 87, .3); background: rgba(21, 126, 87, .08); color: var(--green); }
.integration-mode { position: absolute; inset: auto 24px 22px 24px; display: flex; justify-content: space-between; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; }
.integration-mode span { color: var(--muted); }
.security-note { max-width: 898px; display: flex; gap: 15px; margin-top: 18px; padding: 18px; border: 1px solid #c5cbc8; border-radius: 10px; background: #e8eee9; }
.security-note strong { display: block; }
.security-note p { margin: 3px 0 0; color: #62706b; font-size: 12px; }
.security-icon { font-size: 22px; color: var(--green); }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: 1fr minmax(320px, 440px); align-items: center; padding: clamp(22px, 6vw, 90px); background: var(--ink); color: white; }
.login-brand { align-self: start; display: flex; align-items: center; gap: 12px; letter-spacing: .12em; }
.login-card { padding: 34px; border-radius: 8px 30px 8px 8px; background: var(--panel); color: var(--ink); box-shadow: 0 30px 100px rgba(0,0,0,.28); }
.login-card h1 { margin: 12px 0 7px; font-size: 38px; letter-spacing: -.05em; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.login-card label { display: grid; gap: 6px; margin-bottom: 14px; color: var(--muted); font-size: 11px; }
.login-card input { height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: white; color: var(--ink); }
.login-card input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(16,25,27,.08); }
.login-card .button { width: 100%; margin-top: 4px; }
.login-card small { display: block; min-height: 18px; margin-top: 10px; color: var(--red); text-align: center; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(360px, calc(100vw - 32px)); padding: 12px 15px; border-radius: 9px; background: var(--ink); color: white; box-shadow: 0 14px 40px rgba(0,0,0,.2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--red); }

@keyframes reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 1120px) {
  :root { --sidebar: 82px; }
  .sidebar { padding-inline: 13px; }
  .brand > span:last-child, .nav-item span:not(.nav-icon), .sidebar-foot div { display: none; }
  .brand { justify-content: center; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .nav-item b { position: absolute; transform: translate(18px, -13px); }
  .sidebar-foot { justify-content: center; border: 0; background: transparent; }
  .table-toolbar { align-items: flex-start; }
  .toolbar-main { flex-wrap: wrap; }
  .search-box { min-width: 280px; }
}

@media (max-width: 820px) {
  :root { --sidebar: 0px; }
  .app-shell { display: block; }
  .sidebar { inset: auto 0 0; width: 100%; height: 64px; flex-direction: row; align-items: center; padding: 7px 12px; border: 0; border-top: 1px solid #2c393b; }
  .sidebar .brand, .sidebar-foot { display: none; }
  .nav { width: 100%; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 0; }
  .nav-item { display: flex; justify-content: center; gap: 6px; }
  .nav-item span:not(.nav-icon) { display: inline; font-size: 11px; }
  .nav-item b { position: static; transform: none; }
  .workspace { padding: 0 14px 88px; }
  .topbar { min-height: 75px; }
  .eyebrow, .sync-state span { display: none; }
  .inventory-hero { grid-template-columns: 1fr; gap: 22px; padding-top: 30px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 104px; border-bottom: 1px solid var(--line); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(3), .metric:nth-child(4) { border-bottom: 0; }
  .table-toolbar { flex-direction: column; }
  .toolbar-main, .toolbar-actions { width: 100%; }
  .toolbar-main { display: grid; grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; width: 100%; min-width: 0; }
  .toolbar-actions .button { flex: 1; }
  .table-footer span:last-child { display: none; }
  .integration-grid { grid-template-columns: 1fr; }
  .login-screen { grid-template-columns: 1fr; gap: 50px; }
}

@media (max-width: 520px) {
  .hero-copy h2, .section-heading h2 { font-size: 34px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 16px; }
  .metric strong { font-size: 27px; }
  .toolbar-main { grid-template-columns: 1fr; }
  .search-box { grid-column: 1; }
  .toolbar-main select { width: 100%; }
  .activity-item { grid-template-columns: 36px 1fr; }
  .activity-time { grid-column: 2; text-align: left; }
  .login-screen { padding: 20px; }
  .login-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition-duration: .01ms !important; }
}
