/*
 * Mines Up SCM — дизайны систем
 * ─────────────────────────────────────────────────────────────
 * Фонт (SPEC §11):
 *   LiebherrHead-Black   — гарчиг, dashboard-ийн том тоо
 *   LiebherrHead-Regular — үндсэн текст, хүснэгт
 *   LiebherrText-Bold    — товч, шошго, хүснэгтийн толгой
 * Өнгө: Mines Up-ийн ногоон (#6CBF72) нь брэндийн тэмдэг. Товчны
 * дэвсгэрт илүү бараан ногоон ашиглана — цагаан текст уншигдахуйц (WCAG AA).
 * Дүрэм: ТОМ ҮСГЭЭР бичсэн шошго хэрэглэхгүй; бүтэц нь мэдээлэл агуулна.
 */

/* ── Фонт ─────────────────────────────────────────────────── */
@font-face {
  font-family: 'Liebherr Head';
  src:
    url('/static/fonts/LiebherrHead-Regular.woff2') format('woff2'),
    url('/static/fonts/LiebherrHead-Regular.woff') format('woff');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Liebherr Head';
  src: url('/static/fonts/LiebherrHead-Black.woff2') format('woff2');
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: 'Liebherr Text';
  src:
    url('/static/fonts/LiebherrText-Bold.woff2') format('woff2'),
    url('/static/fonts/LiebherrText-Bold.woff') format('woff');
  font-weight: 700;
  font-display: swap;
}

/* ── Токен ────────────────────────────────────────────────── */
:root {
  --ink: #17221d; /* үндсэн текст, хажуугийн цэс */
  --ink-2: #4b5852; /* туслах текст */
  --ink-3: #7a8780; /* идэвхгүй, placeholder */
  --paper: #f2f5f3; /* хуудасны дэвсгэр */
  --surface: #ffffff;
  --line: #d5ddd8;
  --line-soft: #e6ece8;

  --brand: #6cbf72; /* Mines Up ногоон — тэмдэг, идэвхтэй төлөв */
  --brand-strong: #2c7a38; /* товч — цагаан текст 5.2:1 */
  --brand-tint: #e5f3e6;

  --amber: #8a5a0b;
  --amber-tint: #fbefd8;
  --amber-mark: #d99a22; /* хүлээгдэж буй */
  --blue: #1b5683;
  --blue-tint: #e2edf6;
  --blue-mark: #3d84ba; /* замд */
  --red: #a8261b;
  --red-tint: #fbe7e4;
  --red-mark: #d4473a; /* алдаа, доод нөөц */

  --font-body: 'Liebherr Head', system-ui, sans-serif;
  --font-ui: 'Liebherr Text', 'Liebherr Head', system-ui, sans-serif;

  /* 1.25 харьцаатай масштаб */
  --fs-xs: 0.8125rem; /* 13 */
  --fs-sm: 0.875rem; /* 14 */
  --fs-md: 0.9375rem; /* 15 — үндсэн */
  --fs-lg: 1.125rem; /* 18 */
  --fs-xl: 1.4rem; /* 22 */
  --fs-2xl: 1.75rem; /* 28 */
  --fs-3xl: 2.25rem; /* 36 */

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --focus: 0 0 0 3px rgba(108, 191, 114, 0.55);
  --sidebar-w: 248px;
}

/* ── Суурь ────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
  font-weight: 900;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}
h1 {
  font-size: var(--fs-2xl);
}
h2 {
  font-size: var(--fs-lg);
}
h3 {
  font-size: var(--fs-md);
}
p {
  margin: 0 0 0.75em;
}
a {
  color: var(--brand-strong);
  text-underline-offset: 2px;
}
a:hover {
  color: var(--ink);
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-sm);
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--ink-2);
}
.small {
  font-size: var(--fs-sm);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
[x-cloak] {
  display: none !important;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Хүрээ (shell) ────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #c7d2cc;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-left: 4px solid var(--brand); /* брэндийн зураас */
}
.sidebar__brand {
  padding: 22px 20px 18px;
  text-decoration: none;
  color: #fff;
  display: block;
}
.sidebar__brand strong {
  display: block;
  font-weight: 900;
  font-size: 1.375rem;
  letter-spacing: -0.01em;
}
.sidebar__brand span {
  font-size: var(--fs-sm);
  color: #93a29a;
}
.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
}
.nav-group {
  margin-top: 18px;
}
.nav-group__title {
  font-size: var(--fs-xs);
  color: #7f8e86;
  padding: 0 12px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: #d6dfda;
  text-decoration: none;
  font-size: var(--fs-md);
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-link[aria-current='page'] {
  background: rgba(108, 191, 114, 0.16);
  color: #fff;
}
.nav-link[aria-current='page']::before {
  content: '';
  width: 3px;
  height: 18px;
  margin-left: -8px;
  margin-right: 1px;
  border-radius: 2px;
  background: var(--brand);
}
.nav-link .count {
  margin-left: auto;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  background: var(--amber-mark);
  color: var(--ink);
  border-radius: 10px;
  padding: 0 7px;
  line-height: 20px;
}
.sidebar__user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--fs-sm);
}
.sidebar__user b {
  font-family: var(--font-ui);
  color: #fff;
  display: block;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar__menu {
  display: none;
}
.topbar__search {
  flex: 1;
  max-width: 460px;
}
.topbar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--paper);
}
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--red-mark);
  color: #fff;
  font: 700 10px/16px var(--font-ui);
}
.content {
  padding: 28px;
  max-width: 1360px;
  width: 100%;
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 300px);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vmax rgba(10, 16, 13, 0.45);
  }
  .topbar {
    padding: 10px 16px;
  }
  .topbar__menu {
    display: inline-grid;
  }
  .topbar__search {
    display: none;
  }
  .content {
    padding: 20px 16px 96px;
  }
}

/* Утсан дээрх доод мөр — агуулахын ажилтанд QR хамгийн ойр байна */
.mobile-scan {
  display: none;
}
@media (max-width: 960px) {
  .mobile-scan {
    display: flex;
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 10;
    justify-content: center;
  }
  .mobile-scan .btn {
    width: 100%;
    height: 54px;
    font-size: var(--fs-lg);
    box-shadow: 0 6px 18px rgba(23, 34, 29, 0.25);
  }
  .topbar .btn-scan {
    display: none;
  }
}

/* ── Хуудасны толгой ──────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--ink-2);
}

/* ── Товч ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--brand-strong);
  color: #fff;
}
.btn-primary:hover {
  background: #236630;
  color: #fff;
}
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover {
  background: var(--paper);
  color: var(--ink);
}
.btn-ghost {
  background: transparent;
  color: var(--brand-strong);
  padding: 0 10px;
}
.btn-ghost:hover {
  background: var(--brand-tint);
  color: var(--ink);
}
.btn-danger {
  background: var(--surface);
  color: var(--red);
  border-color: #e9b9b3;
}
.btn-danger:hover {
  background: var(--red-tint);
  color: var(--red);
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: var(--fs-xs);
}
.btn-lg {
  height: 48px;
  padding: 0 22px;
  font-size: var(--fs-md);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn svg {
  flex: none;
}

/* ── Форм ─────────────────────────────────────────────────── */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-sm);
}
.field .help {
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.input,
.select,
.textarea {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}
.input::placeholder {
  color: var(--ink-3);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand-strong);
  box-shadow: var(--focus);
}
.field.has-error .input,
.field.has-error .select {
  border-color: var(--red-mark);
}
.field .error {
  font-size: var(--fs-xs);
  color: var(--red);
}
.input-group {
  position: relative;
}
.input-group .input {
  padding-right: 46px;
}
.input-group .icon-inline {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: var(--r-sm);
}
.search {
  position: relative;
}
.search .input {
  padding-left: 38px;
  height: 40px;
  background: var(--paper);
  border-color: transparent;
}
.search .input:focus {
  background: var(--surface);
}
.search svg {
  position: absolute;
  left: 12px;
  top: 11px;
  color: var(--ink-3);
}
.code-input {
  font-family: var(--font-ui);
  letter-spacing: 0.3em;
  text-align: center;
  font-size: var(--fs-xl);
}
.check {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: var(--fs-sm);
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-strong);
}

/* ── Самбар, хүснэгт ─────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.panel__head h2 {
  font-size: 1.0625rem;
}
.panel__body {
  padding: 16px 20px;
}
.panel + .panel,
.grid + .panel,
.panel + .grid {
  margin-top: 20px;
}

.grid {
  display: grid;
  gap: 20px;
}
.grid-2 {
  grid-template-columns: 1.35fr 1fr;
}
@media (max-width: 1100px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-xs);
  color: var(--ink-2);
  text-align: left;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 11px 20px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr:hover {
  background: #f8faf9;
}
.table .r {
  text-align: right;
}
.table .code {
  font-family: var(--font-ui);
  font-weight: 700;
  white-space: nowrap;
}
.table .sub {
  display: block;
  color: var(--ink-2);
  font-size: var(--fs-xs);
}

/* ── Төлөвийн тэмдэг ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-xs);
  line-height: 20px;
  white-space: nowrap;
  background: var(--paper);
  color: var(--ink-2);
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-green {
  background: var(--brand-tint);
  color: var(--brand-strong);
}
.badge-amber {
  background: var(--amber-tint);
  color: var(--amber);
}
.badge-blue {
  background: var(--blue-tint);
  color: var(--blue);
}
.badge-red {
  background: var(--red-tint);
  color: var(--red);
}

/* ── Мэдэгдэл ─────────────────────────────────────────────── */
.notice {
  padding: 12px 16px;
  border-radius: var(--r-md);
  border-left: 4px solid var(--blue-mark);
  background: var(--blue-tint);
  color: var(--ink);
  font-size: var(--fs-sm);
  margin-bottom: 16px;
}
.notice-success {
  border-color: var(--brand);
  background: var(--brand-tint);
}
.notice-warning {
  border-color: var(--amber-mark);
  background: var(--amber-tint);
}
.notice-error {
  border-color: var(--red-mark);
  background: var(--red-tint);
}
.notice b {
  font-family: var(--font-ui);
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-2);
}
.empty h3 {
  color: var(--ink);
  margin-bottom: 6px;
  font-size: var(--fs-lg);
}

/* ── Dashboard: хураангуй мөр ─────────────────────────────── */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
}
.summary__item {
  padding: 18px 22px;
  border-left: 1px solid var(--line-soft);
  text-decoration: none;
  color: inherit;
}
.summary__item:first-child {
  border-left: 0;
}
.summary__label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.summary__label i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}
.summary__item[data-tone='amber'] i {
  background: var(--amber-mark);
}
.summary__item[data-tone='blue'] i {
  background: var(--blue-mark);
}
.summary__item[data-tone='red'] i {
  background: var(--red-mark);
}
.summary__value {
  font-weight: 900;
  font-size: var(--fs-3xl);
  line-height: 1.1;
  margin-top: 6px;
}
.summary__value small {
  font-size: var(--fs-lg);
  margin-left: 4px;
}
.summary__hint {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  margin-top: 2px;
}
@media (max-width: 960px) {
  .summary {
    grid-template-columns: 1fr 1fr;
  }
  .summary__item:nth-child(3) {
    border-left: 0;
  }
  .summary__item:nth-child(n + 3) {
    border-top: 1px solid var(--line-soft);
  }
  .summary__value {
    font-size: var(--fs-2xl);
  }
}

/* ── Нийлүүлэлтийн зам — гол дүрслэл ──────────────────────
   Ачилт бүр нийлүүлэгчээс агуулах хүртэл 7 зогсоолтой замаар явна.
   Зогсоол дээрх тоо = тэр шатанд байгаа ачилтын тоо. */
.route {
  padding: 22px 20px 8px;
  overflow-x: auto;
}
.route__track {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  position: relative;
  min-width: 840px;
}
.route__track::before {
  content: '';
  position: absolute;
  left: calc(100% / 14);
  right: calc(100% / 14);
  top: 17px;
  height: 4px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 10px, transparent 10px 16px);
}
.stop {
  position: relative;
  text-align: center;
  padding: 0 6px;
}
.stop__dot {
  width: 38px;
  height: 38px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--ink-3);
  font: 900 var(--fs-md) / 1 var(--font-body);
}
.stop.is-active .stop__dot {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.stop[data-key='AT_CUSTOMS'].is-active .stop__dot {
  background: var(--amber-mark);
  border-color: var(--amber-mark);
  color: var(--ink);
}
.stop[data-key='RECEIVED'] .stop__dot {
  border-color: var(--brand);
}
.stop__label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-xs);
  margin-top: 8px;
}
.stop__items {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  text-align: left;
}
.stop__items li {
  background: var(--paper);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  font-size: var(--fs-xs);
  line-height: 1.35;
}
.stop__items a {
  font-family: var(--font-ui);
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  display: block;
}
.stop__items span {
  color: var(--ink-2);
}

/* ── Нөөцийн хэмжүүр (min-ийн тэмдэгтэй) ──────────────────
   SVG-ээр зурна — CSP inline style-ийг хаадаг тул өргөнийг атрибутаар өгнө. */
.gauge {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.gauge svg {
  flex: none;
  overflow: visible;
}
.gauge .g-track {
  fill: var(--line-soft);
}
.gauge .g-fill {
  fill: var(--ink-2);
}
.gauge .g-min {
  fill: var(--ink);
}
.gauge.is-low .g-fill {
  fill: var(--red-mark);
}
.gauge.is-low .gauge__value {
  color: var(--red);
}
.gauge__value {
  font-family: var(--font-ui);
  font-weight: 700;
  min-width: 40px;
  text-align: right;
}

/* ── Батлалтын жагсаалт ──────────────────────────────────── */
.queue {
  list-style: none;
  margin: 0;
  padding: 0;
}
.queue li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.queue li:last-child {
  border-bottom: 0;
}
.queue .code {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-sm);
}
.queue .meta {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  grid-column: 1;
}
.queue .actions {
  grid-row: 1 / span 3;
  grid-column: 2;
  display: flex;
  gap: 6px;
}
.queue li.is-overdue {
  box-shadow: inset 4px 0 0 var(--amber-mark);
}
.queue li.is-overdue .waited {
  color: var(--amber);
  font-family: var(--font-ui);
  font-weight: 700;
}
@media (max-width: 600px) {
  .queue li {
    grid-template-columns: 1fr;
  }
  .queue .actions {
    grid-row: auto;
    grid-column: 1;
    margin-top: 6px;
  }
}

/* ── Нэвтрэх хуудас ──────────────────────────────────────── */
.auth {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) 1.1fr;
  min-height: 100vh;
}
.auth__side {
  background: var(--ink);
  color: #dfe7e2;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 6px solid var(--brand);
}
.auth__mark {
  font-weight: 900;
  font-size: var(--fs-2xl);
  color: #fff;
}
.auth__mark span {
  display: block;
  font-weight: 400;
  font-size: var(--fs-md);
  color: #93a29a;
  margin-top: 4px;
}
.auth__statement {
  font-weight: 900;
  font-size: clamp(1.75rem, 3vw, 2.6rem);
  line-height: 1.15;
  color: #fff;
  max-width: 15ch;
}
.auth__route {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 420px;
}
.auth__route i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #5c6b64;
  flex: none;
}
.auth__route i.on {
  background: var(--brand);
  border-color: var(--brand);
}
.auth__route b {
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(90deg, #5c6b64 0 6px, transparent 6px 10px);
}
.auth__route-labels {
  display: flex;
  justify-content: space-between;
  max-width: 420px;
  font-size: var(--fs-xs);
  color: #93a29a;
  margin-top: 8px;
}
.auth__foot {
  font-size: var(--fs-xs);
  color: #7f8e86;
}
.auth__main {
  display: grid;
  place-items: center;
  padding: 40px 24px;
}
.auth__form {
  width: 100%;
  max-width: 400px;
}
.auth__form h1 {
  margin-bottom: 6px;
}
.auth__form > p {
  color: var(--ink-2);
  margin-bottom: 24px;
}
.auth__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -4px 0 20px;
}
@media (max-width: 860px) {
  .auth {
    grid-template-columns: 1fr;
  }
  .auth__side {
    padding: 24px 20px;
    border-left: 0;
    border-top: 6px solid var(--brand);
  }
  .auth__statement,
  .auth__route,
  .auth__route-labels,
  .auth__foot {
    display: none;
  }
}

/* ── Үзүүлэн хуудасны туслах ─────────────────────────────── */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.swatch {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: var(--fs-xs);
}
.swatch div {
  height: 56px;
}
.swatch p {
  margin: 0;
  padding: 8px 10px;
}
.swatch code {
  color: var(--ink-2);
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.type-scale > * + * {
  margin-top: 10px;
}
.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.error-page__box {
  max-width: 520px;
}
.error-page__code {
  font-weight: 900;
  font-size: 4rem;
  color: var(--brand);
  line-height: 1;
}
.error-page pre {
  white-space: pre-wrap;
  font-size: var(--fs-xs);
  background: var(--surface);
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  overflow: auto;
}

/* ── Жижиг туслах классууд (CSP-ийн улмаас inline style ашиглахгүй) ── */
.btn-block {
  width: 100%;
}
.mt-8 {
  margin-top: 8px;
}
.mt-20 {
  margin-top: 20px;
}
.mb-0 {
  margin-bottom: 0;
}

/* ── Засварууд: жагсаалтын дугаар, desktop цэс, grid доторх зай ── */
.route__track {
  list-style: none;
  margin: 0;
  padding: 0;
}
.topbar .topbar__menu {
  display: none;
}
.grid > .panel {
  margin-top: 0;
}
@media (max-width: 960px) {
  .topbar .topbar__menu {
    display: inline-grid;
  }

  /* Утсан дээр зам босоо болно — хажуу тийш гүйлгэхгүй. */
  .route {
    padding: 16px 16px 4px;
  }
  .route__track {
    grid-template-columns: 1fr;
    min-width: 0;
  }
  .route__track::before {
    left: 18px;
    right: auto;
    top: 19px;
    bottom: 19px;
    width: 4px;
    height: auto;
    background: repeating-linear-gradient(180deg, var(--line) 0 10px, transparent 10px 16px);
  }
  .stop {
    display: grid;
    grid-template-columns: 38px 1fr;
    column-gap: 12px;
    text-align: left;
    padding: 0 0 14px;
  }
  .stop__dot {
    margin: 0;
    grid-row: 1 / span 2;
  }
  .stop__label {
    margin-top: 0;
    align-self: center;
    font-size: var(--fs-sm);
  }
  .stop__items {
    grid-column: 2;
    margin-top: 6px;
  }
}

/* ── S1: нэмэлт бүрэлдэхүүн ─────────────────────────────── */
.lead {
  color: var(--ink-2);
  margin-bottom: 24px;
}
.mb-16 {
  margin-bottom: 16px;
}
.narrow {
  max-width: 640px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}
.select-sm {
  height: 34px;
  width: auto;
  min-width: 150px;
  font-size: var(--fs-sm);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.filters .search {
  flex: 1 1 240px;
}
.filters .search .input {
  background: var(--surface);
  border-color: var(--line);
}
.filters .select,
.filters input[type='date'] {
  width: auto;
  height: 40px;
}

.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

.dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 20px;
  margin: 0;
}
.dl dt {
  color: var(--ink-2);
  font-size: var(--fs-sm);
}
.dl dd {
  margin: 0;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.list li:last-child {
  border-bottom: 0;
}
.notifications a {
  display: grid;
  gap: 2px;
  text-decoration: none;
  color: var(--ink);
}
.notifications li.is-unread {
  box-shadow: inset 3px 0 0 var(--brand);
}
.checklist li {
  justify-content: flex-start;
}
.checklist span {
  font-family: var(--font-ui);
  width: 20px;
  color: var(--brand-strong);
}

.code-tag {
  font-family: var(--font-ui);
  font-weight: 700;
}
.onetime__value {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin-top: 12px;
  align-items: center;
}
.onetime__value code,
.backup-codes code,
.secret {
  font-family: var(--font-ui);
  font-size: var(--fs-lg);
  letter-spacing: 0.06em;
  background: var(--surface);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  justify-self: start;
}
.backup-codes {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 10px 16px;
}

.actions-list {
  display: grid;
  gap: 12px;
}
.actions-list form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.perm-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0 24px;
  padding: 8px 20px;
}
.perm-group {
  border: 0;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.perm-group legend {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-sm);
  padding: 0;
  margin-bottom: 6px;
}
.perm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: var(--fs-sm);
}
.perm-state {
  color: var(--ink-3);
  font-family: var(--font-ui);
}
.perm-state.on {
  color: var(--brand-strong);
}

.diff summary {
  cursor: pointer;
  color: var(--brand-strong);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
}
.diff__table {
  margin-top: 8px;
  border-collapse: collapse;
  font-size: var(--fs-xs);
}
.diff__table th,
.diff__table td {
  padding: 4px 8px;
  border: 1px solid var(--line-soft);
  text-align: left;
  max-width: 260px;
  overflow-wrap: anywhere;
}
.diff__table .was {
  background: var(--red-tint);
}
.diff__table .now {
  background: var(--brand-tint);
}

.twofa {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px 32px;
  align-items: start;
}
.twofa .steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
  grid-column: 1;
}
.twofa__qr {
  grid-column: 2;
  grid-row: 1 / span 2;
  text-align: center;
}
.twofa__qr .qr svg {
  width: 200px;
  height: 200px;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.twofa__form {
  grid-column: 1;
  max-width: 320px;
}
@media (max-width: 700px) {
  .twofa {
    grid-template-columns: 1fr;
  }
  .twofa__qr {
    grid-column: 1;
    grid-row: auto;
  }
}

.roadmap {
  list-style: none;
  margin: 0;
  padding: 8px 20px 16px;
  display: grid;
  gap: 0;
}
.roadmap li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 10px 26px;
  position: relative;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
}
.roadmap li:last-child {
  border-bottom: 0;
}
.roadmap li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 15px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--line);
}
.roadmap li.done {
  color: var(--ink);
}
.roadmap li.done::before {
  background: var(--brand);
  border-color: var(--brand);
}
.roadmap li span {
  font-size: var(--fs-xs);
  font-family: var(--font-ui);
}
a.sidebar__user {
  color: inherit;
  text-decoration: none;
  display: block;
}
a.sidebar__user:hover b {
  text-decoration: underline;
}
.topbar__actions form {
  margin: 0;
}

/* Edge/IE-ийн өөрийн «нууц үг харах» товчийг нууна — манай товч байгаа. */
input[type='password']::-ms-reveal,
input[type='password']::-ms-clear {
  display: none;
}

.skip-2fa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.twofa__qr .qr svg {
  max-width: 200px;
  height: auto;
}

/* ── S2: форм, бараа ─────────────────────────────────────── */
.narrow-wide {
  max-width: 860px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
.form-grid .span-2 {
  grid-column: 1 / -1;
}
.form-grid h3 {
  margin: 4px 0 12px;
}
@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}
.upload-form {
  border-top: 1px solid var(--line-soft);
}
.input-file {
  height: auto;
  padding: 8px;
}
.input-xs {
  width: 80px;
  height: 36px;
  text-align: right;
}
.pre {
  white-space: pre-wrap;
}
.with-thumb {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 14rem; /* утсан дээр нэр нь нэг үгээр тасрахгүй — хүснэгт хажуу тийш гүйлгэгдэнэ */
}
.thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  object-fit: cover;
  border: 1px solid var(--line-soft);
  flex: none;
}
.thumb--empty {
  display: grid;
  place-items: center;
  color: var(--ink-3);
  background: var(--paper);
}
.product-head {
  display: flex;
  align-items: center;
  gap: 16px;
}
.product-head__img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.gallery__item {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.gallery__item.is-primary {
  border-color: var(--brand);
}
.gallery__item img {
  width: 100%;
  height: 130px;
  object-fit: contain;
  display: block;
  background: var(--paper);
}
.gallery__item figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  align-items: center;
}

/* ── Агуулах, байршил ───────────────────────────────────── */
.wh-card {
  text-decoration: none;
  color: inherit;
  display: block;
}
.wh-card:hover {
  border-color: var(--brand);
}
.wh-card h2 {
  margin: 6px 0 4px;
  font-size: var(--fs-xl);
}
.wh-card__stats {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.wh-card__stats b {
  color: var(--ink);
  font-family: var(--font-ui);
}
.tree {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 1px dashed var(--line);
}
.tree--root {
  border-left: 0;
  padding-left: 20px;
}
.tree__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  min-height: 36px;
}
.tree__row form {
  margin-left: auto;
}
.tree__type {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  width: 52px;
  flex: none;
}
.tree__stock {
  color: var(--brand-strong);
  font-family: var(--font-ui);
}

.labels-page {
  background: #fff;
}
.labels-toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.labels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 10mm;
}
.label {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6mm 4mm;
  border: 1px dashed #c9d2cd;
  break-inside: avoid;
}
.label__qr svg {
  width: 28mm;
  height: 28mm;
  display: block;
}
.label__text {
  display: grid;
  gap: 2px;
}
.label__text b {
  font-weight: 900;
  font-size: 15pt;
  letter-spacing: 0.02em;
}
.label__text span {
  font-size: 9pt;
  color: #333;
}
.label__text small {
  font-size: 7pt;
  color: #777;
}
@media print {
  .labels-toolbar {
    display: none;
  }
  .labels {
    padding: 0;
  }
  @page {
    size: A4;
    margin: 8mm;
  }
}
