/*
 * 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; /* талбар, тэмдэгийн дэвсгэр */
  --page: #eef2ef; /* хуудасны дэвсгэр */
  --tint: #f7f9f8; /* картын толгой */
  --surface: #ffffff;
  --line: #d5ddd8;
  --line-soft: #e6ece8;

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

  --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: 14px;
  --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(--page);
  -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;
}
.sidebar__brand {
  display: block;
  padding: 22px 22px 14px;
  text-decoration: none;
}
.sidebar__brand img {
  display: block;
  width: 150px;
  height: auto;
}
.sidebar__brand span {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: #93a29a;
}
.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 16px;
}
.nav-group {
  margin-top: 16px;
}
.nav-group__title {
  font-size: var(--fs-xs);
  color: #7f8e86;
  padding: 0 12px 6px;
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: #d6dfda;
  text-decoration: none;
  font-size: var(--fs-md);
}
.nav-link svg {
  color: #93a29a;
}
.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;
  font-family: var(--font-ui);
  font-weight: 700;
}
.nav-link[aria-current='page'] svg {
  color: var(--brand);
}
/* Идэвхтэй мөрийн тэмдэг — логоны ташуу параллелограмм */
.nav-link[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 6px;
  background: var(--brand);
  transform: skewX(-14deg);
}
.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 {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--fs-xs);
}
.sidebar__user b {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  color: #fff;
  display: block;
}
.avatar {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: var(--ink);
  font: 700 var(--fs-sm) / 1 var(--font-ui);
}

.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__logo {
  display: none;
}
.topbar__logo img {
  display: block;
  width: 96px;
  height: auto;
}
.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);
  background: var(--tint);
  border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0;
}
.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-ийн хүүхэд доторх өргөн хүснэгт баганыг тэлэхгүй — хүснэгт өөрөө гүйнэ. */
.grid > * {
  min-width: 0;
}
.grid-2 {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 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,
.spot-item .sub,
.list .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(--green-tint);
  color: var(--green);
}
.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(--green-mark);
  background: var(--green-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);
}

/* ── Хураангуй мөр (үлдэгдэл г.м.) ─────────────────────────────── */
.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);
  }
}

/* Утсан дээр хүснэгтийн багана шахагдахгүй — хайрцаг дотроо хажуу тийш гүйнэ. */
@media (max-width: 600px) {
  .table-wrap > .table:not(.table--stack) {
    min-width: 560px;
  }
}

/* ── Dashboard: KPI картууд ───────────────────────────────
   Цагаан карт, том тоо; өнгө зөвхөн логоны ташуу хэлбэртэй тэмдэгт. */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.kpi {
  --k-mark: var(--brand);
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 2px;
  padding: 20px 22px 18px;
  min-height: 150px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  text-decoration: none;
  isolation: isolate;
}
/* Буланд том ташуу хавтан — логоны хэлбэр */
.kpi::after {
  content: '';
  position: absolute;
  right: -34px;
  bottom: -26px;
  width: 150px;
  height: 78px;
  background: var(--k-mark);
  opacity: 0.1;
  transform: skewX(-22deg);
  z-index: -1;
}
.kpi:hover {
  box-shadow: inset 0 0 0 2px var(--k-mark);
}
.kpi--amber {
  --k-mark: var(--amber-mark);
}
.kpi--blue {
  --k-mark: var(--blue-mark);
}
.kpi--coral {
  --k-mark: var(--red-mark);
}
.kpi--coral .kpi__hint {
  color: var(--red);
}
.kpi__icon {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 48px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #fff;
}
.kpi__icon::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--k-mark);
  border-radius: 4px;
  transform: skewX(-14deg);
  z-index: -1;
}
.kpi--sky .kpi__icon,
.kpi--amber .kpi__icon {
  color: var(--ink);
}
.kpi__label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-sm);
  padding-right: 60px;
}
.kpi__value {
  font-weight: 900;
  font-size: 2.75rem;
  line-height: 1.05;
  margin-top: 10px;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.kpi__value small {
  font-size: var(--fs-lg);
  margin-left: 6px;
  letter-spacing: 0;
}
.kpi__hint {
  font-size: var(--fs-xs);
}
@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 520px) {
  .kpis {
    gap: 10px;
  }
  .kpi {
    min-height: 128px;
    padding: 14px 14px 12px;
  }
  .kpi__icon {
    top: 12px;
    right: 12px;
    width: 38px;
    height: 32px;
  }
  .kpi {
    align-content: start;
  }
  /* Хоёр мөр шошготой картын тоо хөршийнхтэйгөө ижил өндөрт байна. */
  .kpi__label {
    padding-right: 44px;
    font-size: var(--fs-xs);
    min-height: 2.6em;
  }
  .kpi__value {
    font-size: 2rem;
  }
}

/* ── Нийлүүлэлтийн зам — гол дүрслэл ──────────────────────
   7 шат нь логоны ташуу хавтан шиг дараалсан сум. Ачилттай шат будагдана:
   цэнхэр = явж буй, амбер = гаальд, ногоон = агуулахад. */
.route {
  padding: 22px 24px 18px;
  overflow-x: auto;
}
.route__track {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
  gap: 8px;
  min-width: 860px;
  padding: 0 10px;
}
.stop {
  position: relative;
  min-width: 0;
}
.stop__seg {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 16px 0 20px;
  color: var(--ink-3);
  isolation: isolate;
}
.stop__seg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--paper);
  border-radius: 4px;
  transform: skewX(-14deg);
  z-index: -1;
}
.stop.is-active .stop__seg {
  color: #fff;
}
.stop.is-active .stop__seg::before {
  background: var(--ink);
}
.stop[data-key='AT_CUSTOMS'].is-active .stop__seg {
  color: var(--ink);
}
.stop[data-key='AT_CUSTOMS'].is-active .stop__seg::before {
  background: var(--amber-mark);
}
.stop[data-key='RECEIVED'].is-active .stop__seg {
  color: var(--ink);
}
.stop[data-key='RECEIVED'].is-active .stop__seg::before {
  background: var(--brand);
}
.stop__count {
  font: 900 1.75rem / 1 var(--font-body);
}
.stop__label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-xs);
  line-height: 1.2;
}
.stop:not(.is-active) .stop__label {
  color: var(--ink-2);
}
.stop__items {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.stop__items li {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  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 {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--ink);
  color: #c7d2cc;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
/* Логоны хоёр ташуу хавтан — арын том хэлбэр */
.auth__side::before,
.auth__side::after {
  content: '';
  position: absolute;
  z-index: -1;
  transform: skewX(-22deg);
}
.auth__side::before {
  right: -120px;
  bottom: 70px;
  width: 360px;
  height: 120px;
  background: var(--brand);
  opacity: 0.12;
}
.auth__side::after {
  right: -60px;
  bottom: -20px;
  width: 300px;
  height: 80px;
  background: var(--brand);
  opacity: 0.22;
}
.auth__mark img {
  display: block;
  width: 210px;
  height: auto;
}
.auth__mark span {
  display: block;
  font-size: var(--fs-sm);
  color: #93a29a;
  margin-top: 10px;
}
.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: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 420px;
  padding-left: 6px;
}
.auth__route i {
  height: 14px;
  background: rgba(255, 255, 255, 0.14);
  transform: skewX(-22deg);
}
.auth__route i.on {
  background: var(--brand);
}
.auth__route-labels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-width: 420px;
  font-family: var(--font-ui);
  font-weight: 700;
  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: 22px 20px;
  }
  .auth__side::before,
  .auth__side::after {
    display: none;
  }
  .auth__mark img {
    width: 150px;
  }
  .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;
  }
  .topbar__logo {
    display: block;
  }

  /* Утсан дээр зам босоо болно — хажуу тийш гүйлгэхгүй. */
  .route {
    padding: 16px 16px 12px;
  }
  .route__track {
    grid-template-columns: 1fr;
    min-width: 0;
    gap: 6px;
  }
  .stop__seg {
    height: 52px;
  }
  .stop__count {
    font-size: 1.375rem;
    min-width: 24px;
  }
  .stop__label {
    font-size: var(--fs-sm);
  }
  .stop__items {
    margin: 6px 0 6px 18px;
  }
}

/* ── 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(min(320px, 100%), 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: flex;
}
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: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 20px;
}
.form-grid > * {
  min-width: 0;
}
.form-grid .span-2 {
  grid-column: 1 / -1;
}
.form-grid h3 {
  margin: 4px 0 12px;
}
@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Урт товч утсан дээр хоёр мөр болно — хайрцагнаас гарахгүй. */
  .form-grid .btn {
    max-width: 100%;
    height: auto;
    min-height: 44px;
    padding-block: 8px;
    white-space: normal;
    text-align: center;
  }
}
.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;
  }
}

/* ── Агуулахын үйл ажиллагаа (S3) ─────────────────────────── */
.nowrap {
  white-space: nowrap;
}
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tabs a {
  padding: 10px 14px;
  color: var(--ink-2);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover {
  color: var(--ink);
}
.tabs a[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--brand);
}

/* Байршил/тавцангийн хуудас — утсанд хуруугаар дарахад тохиромжтой мөр */
.spot-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.spot-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px 16px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.spot-item:last-child {
  border-bottom: 0;
}
.spot-item__main {
  min-width: 0;
}
.spot-item__main .badge {
  margin-top: 4px;
}
.spot-item__qty {
  text-align: right;
  font-size: var(--fs-lg);
}
.spot-item__actions {
  display: flex;
  gap: 8px;
}
@media (max-width: 640px) {
  .spot-item {
    grid-template-columns: 1fr auto;
  }
  .spot-item__actions {
    grid-column: 1 / -1;
  }
  .spot-item__actions .btn {
    flex: 1;
    height: 42px;
  }
}

.input-lg {
  height: 52px;
  font-size: var(--fs-lg);
}
.scan-cam__video {
  display: block;
  width: 100%;
  max-height: 60vh;
  margin-top: 14px;
  border-radius: var(--r-md);
  background: var(--ink);
  object-fit: cover;
}
.count-table .input-xs {
  width: 96px;
}
.count-table tr.is-variance td {
  background: var(--amber-tint);
}
.filters .check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.scan-label {
  display: block;
  font-family: var(--font-ui);
  font-weight: 600;
  margin-bottom: 6px;
}
.scan-row {
  display: flex;
  gap: 8px;
}
.scan-row .input {
  flex: 1;
  min-width: 0;
}
.scan-row .btn {
  height: 52px;
}

/* Тооллого утсан дээр: мөр бүр карт, тоолсон тоо хуруунд ойр */
@media (max-width: 640px) {
  .count-table thead {
    display: none;
  }
  .count-table,
  .count-table tbody {
    display: block;
  }
  .count-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
  }
  .count-table td,
  .count-table td.r {
    display: block;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .count-table tr.is-variance {
    background: var(--amber-tint);
  }
  .count-table tr.is-variance td {
    background: none;
  }
  .count-table td:nth-child(1),
  .count-table td:nth-child(2) {
    grid-column: 1 / -1;
  }
  .count-table td:nth-child(3)::before,
  .count-table td:nth-child(4)::before,
  .count-table td:nth-child(5)::before {
    display: block;
    font-size: var(--fs-xs);
    color: var(--ink-2);
  }
  .count-table td:nth-child(3)::before {
    content: 'Систем';
  }
  .count-table td:nth-child(4)::before {
    content: 'Тоолсон';
  }
  .count-table td:nth-child(5)::before {
    content: 'Зөрүү';
  }
  .count-table .input-xs {
    width: 100%;
    height: 44px;
    text-align: left;
  }
}

/* ── Худалдан авалт, батлалт (S4) ─────────────────────────── */
.steps-mini {
  list-style: none;
  margin: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.steps-mini li {
  flex: 1;
  min-width: 90px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--ink-3);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-top: 3px solid var(--line);
}
.steps-mini li.is-done {
  color: var(--ink);
  border-top-color: var(--brand);
}
.steps-mini li.is-current {
  background: var(--brand-tint);
}

.approval + .approval {
  border-top: 1px solid var(--line-soft);
}
.approval--old {
  opacity: 0.75;
}
.approval__head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.approval__steps {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.approval__steps li {
  display: flex;
  gap: 12px;
  align-items: center;
}
.approval__steps .sub {
  display: block;
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.approval__dot {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.approval__steps li.is-done .approval__dot {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.approval__steps li.is-current .approval__dot {
  border-color: var(--amber-mark);
  color: var(--amber);
  background: var(--amber-tint);
}
.approval__log {
  list-style: none;
  margin: 16px 0 0;
  padding: 12px 0 0;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 10px;
  font-size: var(--fs-sm);
}
.approval__comment {
  margin-top: 4px;
  padding: 8px 12px;
  background: var(--paper);
  border-radius: var(--r-sm);
  white-space: pre-wrap;
}
.approval__form {
  border-top: 1px solid var(--line-soft);
}
.approval__form label {
  display: block;
  font-family: var(--font-ui);
  font-weight: 600;
  margin-bottom: 6px;
}

fieldset.checks {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
fieldset.checks legend {
  font-family: var(--font-ui);
  font-weight: 600;
  margin-bottom: 8px;
  padding: 0;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* PO хэвлэх */
.doc-page {
  background: var(--paper);
}
.doc {
  max-width: 820px;
  margin: 24px auto;
  background: #fff;
  padding: 40px 44px;
  border: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.doc__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 3px solid var(--brand);
  padding-bottom: 16px;
}
.doc__head h1 {
  margin: 0;
  font-size: var(--fs-xl);
  letter-spacing: 0.04em;
}
.doc__sub {
  margin: 2px 0 0;
  color: var(--ink-2);
}
.doc__brand {
  text-align: right;
  display: grid;
}
.doc__brand span {
  color: var(--ink-2);
  font-size: var(--fs-xs);
}
.doc__meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 20px;
  margin: 20px 0;
}
.doc__meta dt {
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.doc__meta dd {
  margin: 2px 0 0;
  font-family: var(--font-ui);
  font-weight: 700;
}
.doc__table {
  width: 100%;
  border-collapse: collapse;
}
.doc__table th,
.doc__table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.doc__table th {
  background: var(--paper);
  font-size: var(--fs-xs);
}
.doc__table .r {
  text-align: right;
}
.doc__note {
  margin-top: 16px;
  white-space: pre-wrap;
}
.doc__sign {
  display: flex;
  justify-content: space-between;
  margin-top: 56px;
  color: var(--ink-2);
}
.doc__sign b {
  color: var(--ink);
}
@media print {
  .doc-page {
    background: #fff;
  }
  .doc {
    border: 0;
    margin: 0;
    padding: 0;
    max-width: none;
  }
}
@media (max-width: 640px) {
  .doc__meta {
    grid-template-columns: 1fr 1fr;
  }
  .doc {
    padding: 20px;
  }
}

.input-date {
  width: auto;
  flex: 0 0 auto;
}
label.check.span-2 {
  margin-bottom: 16px;
}

/* ── Ачилт (S5) ───────────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.board__col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.board__col h2 {
  font-size: var(--fs-sm);
  margin: 0 0 4px;
  display: flex;
  justify-content: space-between;
}
.board__col .count {
  color: var(--ink-2);
}
.board__card {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--paper);
  border-left: 3px solid var(--blue-mark);
  text-decoration: none;
  color: var(--ink);
  font-size: var(--fs-xs);
}
.board__card:hover {
  background: var(--blue-tint);
}
.board__card b {
  font-size: var(--fs-sm);
}
.board__card.is-late {
  border-left-color: var(--red-mark);
}
.board__card .late {
  color: var(--red);
  font-weight: 700;
}

.track {
  list-style: none;
  margin: 0 0 20px;
  padding: 18px 12px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.track li {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 4px;
  position: relative;
}
.track li + li::before {
  content: '';
  position: absolute;
  top: 15px;
  right: 50%;
  width: 100%;
  border-top: 2px dashed var(--line);
  z-index: 0;
}
.track li.is-done::before,
.track li.is-current::before {
  border-top-style: solid;
  border-color: var(--brand);
}
.track__dot {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 2px solid var(--line);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: var(--fs-xs);
  color: var(--ink-3);
}
.track li.is-done .track__dot {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.track li.is-current .track__dot {
  border-color: var(--blue-mark);
  background: var(--blue-tint);
  color: var(--blue);
}
.track__label {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--fs-xs);
}
.track__date {
  font-size: 0.75rem;
  color: var(--ink-2);
  min-height: 1em;
}
@media (max-width: 760px) {
  .track {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .track li {
    grid-template-columns: 32px 1fr auto;
    justify-items: start;
    align-items: center;
    text-align: left;
    gap: 10px;
  }
  .track li + li::before {
    display: none;
  }
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 8px 20px 16px 36px;
  position: relative;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 16px;
  bottom: 16px;
  border-left: 2px solid var(--line);
}
.timeline li {
  position: relative;
  padding: 10px 0;
  display: grid;
  gap: 2px;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -17px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
}
.timeline__head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Борлуулалт, портал (S6) ──────────────────────────────── */
.text-red {
  color: var(--red);
  font-weight: 700;
}
.doc__meta .span-2 {
  grid-column: span 2;
}
.portal-manager {
  font-size: var(--fs-lg);
  margin-top: 10px;
}
.portal-orders {
  list-style: none;
  margin: 0;
  padding: 0;
}
.portal-orders li {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 10px;
}
.portal-orders li:last-child {
  border-bottom: 0;
}
.portal-orders__head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}
.portal-orders__head .code {
  font-weight: 700;
}
.portal-orders__date {
  margin-left: auto;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.portal-dlv + .portal-dlv {
  border-top: 1px solid var(--line-soft);
}
.portal-dlv__head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.portal-dlv__head .btn {
  margin-left: auto;
}
.doc-links {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.doc-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-decoration: none;
  font-size: var(--fs-sm);
  color: var(--ink);
  background: var(--paper);
}
.doc-links a:hover {
  border-color: var(--brand);
}
.order-lines {
  display: grid;
  gap: 10px;
}
.order-lines__row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
}
@media (max-width: 640px) {
  .order-lines__row {
    grid-template-columns: 1fr 110px;
  }
}

.steps-mini {
  padding: 0;
}
@media (max-width: 520px) {
  .steps-mini li {
    min-width: 120px;
  }
}
/* Утсан дээр хүснэгтийн мөрийг карт болгоно (td-д data-label) */
@media (max-width: 640px) {
  .table--stack thead {
    display: none;
  }
  .table--stack,
  .table--stack tbody,
  .table--stack tr {
    display: block;
  }
  .table--stack tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
  }
  .table--stack td,
  .table--stack td.r {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border: 0;
    text-align: right;
  }
  .table--stack td:first-child {
    display: block;
    text-align: left;
    padding-bottom: 6px;
  }
  .table--stack td[data-label]::before {
    content: attr(data-label);
    color: var(--ink-2);
    font-size: var(--fs-xs);
  }
}
.bullets {
  margin: 0 0 18px;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

/* ── Чат (S7) ─────────────────────────────────────────────── */
.chat {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  height: calc(100vh - 210px);
  min-height: 460px;
}
.chat--single {
  grid-template-columns: 1fr;
  max-width: 860px;
}
.chat__threads {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.chat__threads ul {
  list-style: none;
  margin: 0;
  padding: 6px;
}
.chat__none {
  padding: 16px;
}
.chat__thread {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--ink);
}
.chat__thread:hover {
  background: var(--paper);
}
.chat__thread.is-active {
  background: var(--brand-tint);
}
.chat__label {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.chat__last {
  grid-column: 1;
  font-size: var(--fs-xs);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat__thread .count {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--brand-strong);
  color: #fff;
  font-size: var(--fs-xs);
  display: grid;
  place-items: center;
  padding: 0 6px;
}
.chat__new {
  border-top: 1px solid var(--line-soft);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  font-size: var(--fs-sm);
}
.chat__new label {
  font-family: var(--font-ui);
  font-weight: 600;
}
.chat__new .row {
  flex-wrap: nowrap;
}
.chat__new .select {
  min-width: 0;
  width: auto;
  flex: 1 1 0;
}
.chat__new .row .btn {
  flex-shrink: 0;
}
.chat__new summary {
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
}
.chat__new form {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.chat__members {
  display: grid;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.chat-pane {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-pane--empty {
  justify-content: center;
}
.chat-pane__head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.chat-pane__head h2 {
  margin: 0;
  font-size: var(--fs-lg);
}
.chat-pane__list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
}
.msg {
  max-width: 72%;
  align-self: flex-start;
  background: var(--paper);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 12px;
}
.msg.is-mine {
  align-self: flex-end;
  background: var(--brand-tint);
  border-radius: 12px 12px 4px 12px;
}
.msg.is-customer {
  background: var(--blue-tint);
}
.msg__meta {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  margin-bottom: 2px;
}
.msg__body {
  white-space: pre-wrap;
  word-break: break-word;
}
.msg__file {
  display: inline-block;
  margin-top: 4px;
  font-size: var(--fs-sm);
}
.chat-pane__form {
  border-top: 1px solid var(--line-soft);
  padding: 12px 16px;
  display: grid;
  gap: 8px;
}
.chat-pane__form .textarea {
  resize: none;
}
.chat-pane__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-pane__actions .btn-primary {
  margin-left: auto;
}
.chat-pane__attach {
  cursor: pointer;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-pane__back {
  display: none;
  margin-bottom: 4px;
}
@media (max-width: 860px) {
  /* Утсан дээр: /chat — зөвхөн жагсаалт, /chat/:id — зөвхөн яриа (буцах холбоостой) */
  .chat {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .chat:not(.chat--open) .chat-pane--empty,
  .chat--open .chat__threads {
    display: none;
  }
  .chat-pane__back {
    display: inline-block;
  }
  .chat-pane {
    height: calc(100dvh - 190px);
    min-height: 420px;
  }
  .msg {
    max-width: 88%;
  }
}

/* ── Тайлан (S8) ──────────────────────────────────────────── */
.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.report-card {
  display: grid;
  gap: 6px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: var(--ink);
  border-left: 4px solid var(--brand);
}
.report-card:hover {
  border-color: var(--brand);
}
.report-card b {
  font-size: var(--fs-lg);
}
.report-card span {
  color: var(--ink-2);
  font-size: var(--fs-sm);
}
.report-card .report-card__modes {
  font-size: var(--fs-xs);
  color: var(--brand-strong);
  font-family: var(--font-ui);
  font-weight: 600;
}
.filter-label {
  display: grid;
  gap: 2px;
}
.filter-label > span {
  font-size: var(--fs-xs);
  color: var(--ink-2);
}
.filters:has(.filter-label) {
  align-items: end;
}
.report-table tfoot td {
  border-top: 2px solid var(--line);
  background: var(--paper);
}
.doc--wide {
  max-width: 1180px;
  page: report;
}
@page report {
  size: A4 landscape;
  margin: 10mm;
}
.doc .table {
  font-size: var(--fs-xs);
}
.doc .table th,
.doc .table td {
  padding: 6px 8px;
}
.doc .table td.num,
.doc .table td.code,
.doc .table td.dt,
.doc .table th.r {
  white-space: nowrap;
}
.doc .table tbody tr:hover {
  background: none;
}
@media print {
  .doc .table-wrap {
    overflow: visible;
  }
  .doc .table thead {
    display: table-header-group;
  }
  .doc .table tr {
    break-inside: avoid;
  }
}
