/*
  ВГМ_торговля UI — принципы Контур.Гайдов (не копия фирменного стиля Контура):
  серая структура, продукт-акцент точечно, 3 уровня поверхностей, 8px-модуль.
  Сегмент «торговля» в гайдах → голубой акцент.
  https://guides.kontur.ru/principles/base/color/
*/

@import url("https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600;700&display=swap");

:root {
  --mod: 8px;

  /* Surfaces (нижний / базовый / приподнятый) */
  --surface-lower: #f0f0f0;
  --surface-base: #ffffff;
  --surface-raised: #ffffff;
  --topbar: #222222;

  /* Neutrals */
  --text: #222222;
  --text-soft: #6b6b6b;
  --text-on-dark: #ffffff;
  --text-on-dark-soft: rgba(255, 255, 255, 0.72);
  --border: #d6d6d6;
  --border-soft: #e6e6e6;
  --hover: #f5f5f5;
  --active-nav: #ebebeb;

  /* Product accent — торговля / ритейл (принцип продуктового цвета) */
  --product: #2291ff;
  --product-hover: #0f7ae5;
  --product-soft: #e8f4ff;
  --product-ink: #15327b;

  /* Status only */
  --ok: #25ad50;
  --ok-bg: #e8f7ee;
  --warn: #f0a528;
  --warn-bg: #fff6e0;
  --bad: #e14848;
  --bad-bg: #fdecec;

  --shadow-raised: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
  --radius: 2px;
  --radius-panel: 4px;
  --font: "Golos Text", "Segoe UI", "PT Sans", sans-serif;
  --focus: 0 0 0 2px var(--surface-base), 0 0 0 4px var(--product);

  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface-lower);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--surface-lower);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--product);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* —— Topbar (шапка) —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--mod) * 2);
  min-height: 48px;
  padding: 0 calc(var(--mod) * 2);
  background: var(--topbar);
  color: var(--text-on-dark);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 3px solid var(--product);
}

.topbar__brand {
  display: flex;
  align-items: baseline;
  gap: calc(var(--mod) * 1);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--text-on-dark);
  text-decoration: none;
  white-space: nowrap;
}
.topbar__brand:hover {
  text-decoration: none;
  color: var(--text-on-dark);
}
.topbar__brand span {
  font-weight: 400;
  color: var(--text-on-dark-soft);
  font-size: 13px;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: calc(var(--mod) * 1.5);
  color: var(--text-on-dark-soft);
  font-size: 13px;
}

/* —— Shell: sidenav + content —— */
.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 48px);
}

.sidenav {
  background: var(--surface-base);
  border-right: 1px solid var(--border-soft);
  padding: calc(var(--mod) * 2) 0;
}

.sidenav__section {
  padding: calc(var(--mod) * 1.5) calc(var(--mod) * 2) calc(var(--mod) * 0.5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.sidenav a {
  display: block;
  padding: 9px calc(var(--mod) * 2);
  color: var(--text);
  text-decoration: none;
  border-left: 3px solid transparent;
  margin: 1px 0;
}
.sidenav a:hover {
  background: var(--hover);
  text-decoration: none;
}
.sidenav a.is-active {
  background: var(--product-soft);
  border-left-color: var(--product);
  color: var(--product-ink);
  font-weight: 600;
}

.content {
  padding: calc(var(--mod) * 3) calc(var(--mod) * 3) calc(var(--mod) * 5);
  max-width: 1100px;
}

.page-head {
  margin: 0 0 calc(var(--mod) * 2.5);
}
.page-head h1 {
  margin: 0 0 calc(var(--mod) * 0.5);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.page-head p,
.page-lead {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
  max-width: 52rem;
}

.crumbs {
  margin: 0 0 calc(var(--mod) * 1.5);
  font-size: 13px;
  color: var(--text-soft);
}
.crumbs a {
  color: var(--text-soft);
}
.crumbs a:hover {
  color: var(--product);
}

/* —— Panels / cards as base surfaces —— */
.panel,
.card {
  background: var(--surface-base);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-panel);
  padding: calc(var(--mod) * 2);
  margin-bottom: calc(var(--mod) * 2);
}

.panel h2,
.card h2 {
  margin: 0 0 calc(var(--mod) * 1.5);
  font-size: 16px;
  font-weight: 600;
}

.grid {
  display: grid;
  gap: calc(var(--mod) * 2);
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: calc(var(--mod) * 2);
}

.stat {
  background: var(--surface-base);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-panel);
  padding: calc(var(--mod) * 2);
}
.stat .label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
}
.stat .value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

th {
  color: var(--text-soft);
  font-weight: 600;
  font-size: 12px;
  background: var(--surface-lower);
  border-bottom-color: var(--border);
}

tr:hover td {
  background: var(--hover);
}

td.num,
th.num {
  text-align: right;
}

/* —— Controls —— */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

input,
textarea,
select {
  width: 100%;
  max-width: 420px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-base);
  color: var(--text);
  font: inherit;
  margin: 0 0 calc(var(--mod) * 1.5);
}
textarea {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}
input:focus,
textarea:focus,
select:focus,
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--product);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--product);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  background: var(--product-hover);
  text-decoration: none;
  color: #fff;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.secondary {
  background: var(--surface-base);
  color: var(--text);
  border-color: var(--border);
}
.btn.secondary:hover {
  background: var(--hover);
  color: var(--text);
}

.btn.link {
  background: transparent;
  color: var(--product);
  border: none;
  padding: 0 4px;
  min-height: auto;
  font-weight: 500;
}
.btn.link:hover {
  background: transparent;
  color: var(--product-hover);
  text-decoration: underline;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--mod) * 1);
  align-items: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--mod) * 1);
  align-items: flex-end;
  margin-bottom: calc(var(--mod) * 2);
}
.toolbar input {
  margin: 0;
  max-width: 320px;
}

.muted {
  color: var(--text-soft);
}
.error {
  color: var(--bad);
  background: var(--bad-bg);
  border: 1px solid #f5c2c2;
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: calc(var(--mod) * 1.5);
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--active-nav);
  color: var(--text-soft);
}
.badge.ok {
  background: var(--ok-bg);
  color: #0f6b32;
}
.badge.warn {
  background: var(--warn-bg);
  color: #8a5a00;
}

pre.summary {
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.5;
  margin: 0;
  font-size: 14px;
}

.empty {
  padding: calc(var(--mod) * 4);
  text-align: center;
  color: var(--text-soft);
}

/* —— Auth / login —— */
body.auth {
  background: var(--surface-lower);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-top {
  min-height: 48px;
  background: var(--topbar);
  border-bottom: 3px solid var(--product);
  display: flex;
  align-items: center;
  padding: 0 calc(var(--mod) * 2);
  color: var(--text-on-dark);
  font-weight: 700;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--mod) * 3);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-raised);
  padding: calc(var(--mod) * 3);
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
}
.login-card .page-lead {
  margin-bottom: calc(var(--mod) * 2.5);
}
.login-card .btn {
  width: 100%;
  margin-top: calc(var(--mod) * 0.5);
}
.login-card input {
  max-width: none;
}

/* —— 404 —— */
.err404 {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
  padding: calc(var(--mod) * 2) calc(var(--mod) * 2) calc(var(--mod) * 4);
}
.err404__art {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin: 0 auto calc(var(--mod) * 2.5);
  border-radius: var(--radius-panel);
  background: var(--surface-base);
  box-shadow: var(--shadow-raised);
  animation: err404-bob 4.5s ease-in-out infinite;
}
.err404 h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.err404 .muted {
  margin: 0 auto calc(var(--mod) * 2.5);
  max-width: 34em;
  color: var(--text-soft);
}
.err404__actions {
  justify-content: center;
}
@keyframes err404-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .err404__art {
    animation: none;
  }
}

/* Legacy aliases used in templates */
header {
  /* overridden by .topbar when present */
}
main {
  /* content lives in .content */
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidenav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: calc(var(--mod) * 1);
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .sidenav__section {
    width: 100%;
    padding-bottom: 0;
  }
  .sidenav a {
    border-left: none;
    border-radius: var(--radius);
    padding: 8px 12px;
  }
  .sidenav a.is-active {
    border-left: none;
  }
  .content {
    padding: calc(var(--mod) * 2);
  }
}
