/* ============================================================
   Эмнэлэг "Мөнгөн" — Санхүүгийн систем
   common.css — бүх хуудсанд хэрэглэгдэнэ
   ============================================================ */

:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --accent: #d4a574;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #3b82f6;
  --sidebar-text: #cbd5e1;
  --sidebar-section: #64748b;
  --bg-main: #f5f7fa;
  --border: #e5e7eb;
  --ink: #1f2937;
  --ink-mute: #6b7280;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  font-size: 14px;
  background: var(--bg-main);
}

.app-wrapper { display: flex; min-height: 100vh; }

/* ========== SIDEBAR ========== */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;            /* хэвтээ скролл арилгана */
  scrollbar-width: thin;          /* Firefox — нарийн босоо скролл */
  scrollbar-color: #475569 transparent;
  transition: width 0.25s ease, transform 0.25s ease;
  z-index: 1000;
}

.sidebar::-webkit-scrollbar { width: 5px; height: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }

.sidebar-brand {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #1e3a8a);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-icon i { color: white; font-size: 18px; }
.sidebar-brand-name { font-size: 14.5px; font-weight: 600; color: white; line-height: 1.2; }
.sidebar-brand-sub { font-size: 11px; color: var(--sidebar-section); margin-top: 2px; }

.sidebar-section {
  padding: 18px 24px 8px;
  font-size: 10.5px;
  color: var(--sidebar-section);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

.sidebar-menu { list-style: none; padding: 0; margin: 0; }

.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-link:hover { background: var(--sidebar-hover); color: white; }

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.12);
  color: white;
  border-left-color: var(--sidebar-active);
}

.sidebar-link i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-link .badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  background: var(--accent);
  color: #1f2937;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 12px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b8895c);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { color: white; font-size: 13px; font-weight: 500; }
.user-role { color: var(--sidebar-section); font-size: 11px; }

.topbar-btn-logout {
  background: none; border: none; color: #cbd5e1;
  font-size: 18px; cursor: pointer; padding: 6px;
  border-radius: 6px;
}

.topbar-btn-logout:hover { background: rgba(255,255,255,0.08); }

/* ========== MAIN ========== */
.main-content { margin-left: 260px; flex: 1; min-width: 0; }

/* ===== Multi-tab bar (folder/browser хэлбэр — цэс дарахад таб) ===== */
/* overflow-y: hidden ЗААВАЛ — overflow-x:auto нь overflow-y-г auto болгож намхан босоо
   scrollbar гаргадаг (баруун дээд булангийн ∧∨). Strip нь зөвхөн хэвтээ гүйнэ. */
/* ⚠ border-bottom ТАВИХГҮЙ: идэвхтэй таб түүнийг бүрхэх ёстой боловч
   .spa-tab-strip-д overflow-y:hidden байдаг тул табын ::after стрипээс
   гадагш гарч чаддаггүй — зураас үргэлж цухуйдаг. Тусгаарлалтыг
   самбарын дэвсгэр (gradient) болон табуудын өөрсдийн хүрээ өгнө. */
.spa-tab-bar { display: flex; align-items: stretch; gap: 4px; background: linear-gradient(to bottom, #e9f1f7, #dbe7f0); padding: 6px 6px 0; position: sticky; top: 0; z-index: 40; height: 41px; box-sizing: border-box; }
.spa-tab-nav { flex: 0 0 auto; width: 26px; border: none; background: transparent; color: #5b7185; font-size: 15px; cursor: pointer; border-radius: 6px; align-self: center; height: 28px; }
.spa-tab-nav:hover { background: rgba(13,148,136,0.12); color: #0d9488; }
.spa-tab-strip { display: flex; align-items: flex-end; gap: 3px; flex: 1 1 auto; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; -ms-overflow-style: none; }
.spa-tab-strip::-webkit-scrollbar { display: none; width: 0; height: 0; }
.tab-panel { width: 100%; }
.spa-tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 8px 48px 9px 13px; font-size: 12.5px; color: #46586a; background: #eef4f9; border: 1px solid #c3d3e0; border-bottom: none; border-radius: 11px 11px 0 0; cursor: pointer; max-width: 238px; flex: 0 0 auto; user-select: none; height: 34px; box-sizing: border-box; }
.spa-tab:hover { background: #f7fafc; color: #16323f; }
.spa-tab.active { background: #fff; color: #0d9488; font-weight: 600; border-color: #c3d3e0; z-index: 2; box-shadow: 0 -1px 3px rgba(0,0,0,0.05); }
/* (Идэвхтэй табын доод бүрхүүл хэрэггүй болсон — самбарт зураас алга) */
.spa-tab-icon { font-size: 13.5px; color: #0d9488; flex: 0 0 auto; }
.spa-tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spa-tab-close { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-size: 15px; color: #e0a818; line-height: 1; border-radius: 4px; }
.spa-tab-close:hover { background: #fef3c7; color: #d97706; }
.spa-tab-refresh { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); font-size: 12px; color: #8aa0b3; line-height: 1; border-radius: 4px; padding: 2px; cursor: pointer; }
.spa-tab-refresh:hover { background: rgba(13,148,136,0.15); color: #0d9488; }
.spa-tab-refresh.spinning { animation: spa-tab-spin 0.6s linear; }
@keyframes spa-tab-spin { from { transform: translateY(-50%) rotate(0deg); } to { transform: translateY(-50%) rotate(360deg); } }

.topbar {
  background: white;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.toggle-sidebar {
  background: none; border: none;
  font-size: 20px; color: var(--ink-mute);
  cursor: pointer; padding: 6px 8px;
  border-radius: 6px;
}

.toggle-sidebar:hover { background: #f1f5f9; }

.breadcrumb-custom {
  margin: 0; padding: 0; list-style: none;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}

.breadcrumb-custom li { color: var(--ink-mute); }
.breadcrumb-custom li.active { color: var(--ink); font-weight: 500; }
.breadcrumb-custom .sep { color: #cbd5e1; }
.breadcrumb-custom a { color: var(--ink-mute); text-decoration: none; }
.breadcrumb-custom a:hover { color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-period {
  font-size: 12px; color: var(--ink-mute);
  padding: 6px 12px; background: #f1f5f9;
  border-radius: 6px;
}

.topbar-period strong { color: var(--ink); }

.content { padding: 16px 20px; }

.page-header {
  margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}

.page-title { font-size: 22px; font-weight: 600; margin: 0; }
.page-subtitle { font-size: 13px; color: var(--ink-mute); margin-top: 4px; }

/* ========== METRICS ========== */
/* НЯГТ ХУВИЛБАР (2026-06-06): дээд талын metric box-ууд талбай их иддэг
   байсныг Мөнгөн хөрөнгийн (.bank-card) загвартай адил жижигрүүлсэн —
   icon баруун дээд буланд, padding/font багассан. БҮХ хуудсанд хамаарна. */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  background: white;
  border-radius: 10px;
  padding: 10px 14px 8px;
  border: 1px solid var(--border);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

/* Зөвхөн ШУУД хүү icon (ердийн metric card) — cash-ийн .bank-card-head
   доторх icon-д нөлөөлөхгүй (тэр өөрийн flex загвартай). */
.metric-card > .metric-icon {
  position: absolute;
  top: 8px; right: 10px;
  width: 30px; height: 30px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 0;
}

.metric-card > .metric-label { padding-right: 40px; }

.metric-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }

.metric-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--metric-color, var(--primary));
}

.metric-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--metric-bg, rgba(30, 64, 175, 0.1));
  color: var(--metric-color, var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.metric-label {
  font-size: 11px; color: var(--ink-mute);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.metric-value { font-size: 20px; font-weight: 600; margin-bottom: 2px; }
.metric-delta { font-size: 11px; color: var(--ink-mute); }
.metric-delta.up { color: var(--success); }
.metric-delta.down { color: var(--danger); }

/* ========== CARDS ========== */
.card-custom {
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header-custom {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title-custom { font-size: 15px; font-weight: 600; margin: 0; }
.card-body-custom { padding: 20px; }

/* ========== BUTTONS ========== */
.btn-primary-custom {
  background: var(--primary);
  color: white; border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn-primary-custom:hover { background: var(--primary-dark); }
.btn-primary-custom:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary-custom {
  background: white;
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn-secondary-custom:hover { background: #f8fafc; border-color: var(--ink-mute); }

.btn-danger-custom {
  background: var(--danger);
  color: white; border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn-success-custom {
  background: var(--success);
  color: white; border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input.form-control,
.toolbar select.form-control {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  background: white;
  width: auto;
}

.btn-icon-only {
  background: none;
  border: none;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 16px;
}

.btn-icon-only:hover { background: #f1f5f9; color: var(--ink); }
.btn-icon-only.text-danger:hover { background: #fee2e2; color: var(--danger); }

/* ========== BADGES ========== */
.badge-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.badge-pill.success { background: #dcfce7; color: #166534; }
.badge-pill.warning { background: #fef3c7; color: #92400e; }
.badge-pill.danger  { background: #fee2e2; color: #991b1b; }
.badge-pill.info    { background: #dbeafe; color: #1e40af; }
.badge-pill.muted   { background: #f1f5f9; color: #475569; }

.num-mono {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-variant-numeric: tabular-nums;
}

.text-right { text-align: right; }

/* ========== TOAST ========== */
.toast-area {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast-msg {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  font-size: 13px;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

.toast-msg.success { border-left: 3px solid var(--success); }
.toast-msg.error   { border-left: 3px solid var(--danger); }
.toast-msg.info    { border-left: 3px solid var(--info); }
.toast-msg.warning { border-left: 3px solid var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== MODAL ========== */
.modal-backdrop-custom {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop-custom.show { display: flex; }

.modal-custom {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  /* Title/footer ТОГТМОЛ — зөвхөн body дотроо гүйнэ (2026-07-02) */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-custom.modal-large { max-width: 900px; }
.modal-custom.modal-xl    { max-width: 1100px; }

.modal-header-custom {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  cursor: move;           /* header-ээр чирч зөөнө */
  user-select: none;
}

.modal-title-custom { font-size: 17px; font-weight: 600; margin: 0; }
/* overscroll-behavior:contain — модал доторх scroll арын хуудсанд алдагдахгүй (scroll chaining зогсоох, 2026-07-09)
   overflow-x:hidden — доторх grid/table хэтэрсэн ч модалд хэвтээ скролл гаргахгүй; grid өөрийн bdiv-дээ гүйнэ */
.modal-body-custom { padding: 24px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
/* Модал нээлттэй үед арын үндсэн хуудсыг гүйлгэхгүй болгоно */
body.modal-open { overflow: hidden !important; }
.modal-footer-custom { flex: 0 0 auto; }

.modal-footer-custom {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ========== FORM ========== */
.form-row { margin-bottom: 16px; }

.form-row label {
  display: block;
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: white;
  font-family: inherit;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.form-row-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-row-grid-3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1fr; }

/* .form-group / .form-control-custom — .form-row-ийн ижил хувилбар.
   ⚠ Эдгээр класст CSS дүрэм ОГТ БАЙГААГҮЙ тул 18 хуудасны (goals_ideas,
   contract, hr, customers, discount ...) формд шошго нь талбарынхаа ХАЖУУД
   наалдаж, input нь хөтчийн анхдагч өргөнтэй харагддаг байв (2026-09-22).
   Нэг газраас зассанаар бүх хуудас .form-row-тэй ижил харагдана. */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 6px;
  font-weight: 500;
}

/* checkbox/radio-г 100% өргөн болгохгүй (тэдгээр нь мөрөндөө байх ёстой) */
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea,
input.form-control-custom:not([type="checkbox"]):not([type="radio"]),
select.form-control-custom,
textarea.form-control-custom,
/* ⚠ .form-control (bootstrap-ын нэр) нь 92 JSP-д ашиглагдсан атлаа зөвхөн
   .toolbar дотор загварчлагдсан байв — гаднаа хаясан мэт харагддаг (хүрээ,
   padding, calendar/chevron дүрс алга). Стандарт төрхийг нь эндээс өгнө. */
input.form-control:not([type="checkbox"]):not([type="radio"]),
select.form-control,
textarea.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: white;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control-custom:focus,
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* ========== TABS ========== */
.tabs-custom {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  margin-bottom: 20px;
}

.tab-item {
  padding: 12px 18px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-mute);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab-item:hover { color: var(--ink); }

.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-item .tab-count {
  background: #f1f5f9;
  color: var(--ink-mute);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.tab-item.active .tab-count {
  background: var(--primary);
  color: white;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ========== JQGRID OVERRIDES ========== */
.ui-jqgrid {
  border-radius: 10px !important;
  overflow: hidden;
  border: 1px solid var(--border) !important;
  font-family: inherit !important;
  font-size: 13px !important;
}

.ui-jqgrid .ui-jqgrid-htable {
  background: #f8fafc;
}

.ui-jqgrid .ui-jqgrid-htable th {
  background: #f8fafc !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--ink-mute) !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600 !important;
  padding: 6px 8px !important;
  height: 32px !important;
}

.ui-jqgrid .ui-jqgrid-htable th div {
  padding: 0 !important;
  text-align: left !important;
  line-height: 1.3 !important;
}

.ui-jqgrid .ui-jqgrid-bdiv { background: white; }

.ui-jqgrid tr.jqgrow td {
  padding: 5px 8px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  border-right: none !important;
  font-size: 12.5px !important;
  height: auto !important;
  line-height: 1.4 !important;
  vertical-align: middle !important;
}

/* Filter toolbar (search row) — нарийн */
.ui-jqgrid .ui-search-toolbar th {
  padding: 3px 6px !important;
  height: 28px !important;
}
.ui-jqgrid .ui-search-toolbar input,
.ui-jqgrid .ui-search-toolbar select {
  padding: 3px 6px !important;
  font-size: 11px !important;
  height: 22px !important;
}

.ui-jqgrid tr.jqgrow:hover td { background: #f8fafc !important; }
.ui-jqgrid tr.ui-state-highlight td,
.ui-jqgrid tr.ui-state-active td { background: #dbeafe !important; }

.ui-jqgrid .ui-pg-button {
  border: none !important;
  background: transparent !important;
  height: 30px !important;
  color: var(--ink-mute) !important;
}

.ui-jqgrid .ui-pg-button:hover {
  background: #f1f5f9 !important;
  color: var(--ink) !important;
}

.ui-jqgrid .ui-pager-control {
  background: #f8fafc !important;
  border-top: 1px solid var(--border) !important;
}

.ui-jqgrid .ui-jqgrid-pager {
  background: #f8fafc !important;
  border-top: 1px solid var(--border) !important;
  height: 36px !important;
}

.ui-pg-table .ui-pg-input {
  height: 22px !important;
  padding: 2px 6px !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
}

.ui-pg-selbox {
  height: 26px !important;
  padding: 2px 6px !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  font-size: 12px !important;
}

.ui-jqgrid .ui-jqgrid-titlebar {
  background: white !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 14px 16px !important;
  font-weight: 600 !important;
  color: var(--ink) !important;
}

.ui-search-toolbar { background: #fafbfc !important; }

.ui-search-toolbar input,
.ui-search-toolbar select {
  width: 95% !important;
  padding: 4px 8px !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  font-size: 12px !important;
}

/* Action buttons in grid cells */
.grid-actions { display: inline-flex; gap: 4px; }

.grid-action-btn {
  background: none;
  border: none;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.grid-action-btn:hover { background: #e2e8f0; color: var(--ink); }
.grid-action-btn.danger:hover { background: #fee2e2; color: var(--danger); }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-mute);
}

.empty-state i { font-size: 48px; color: #cbd5e1; margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 15px; color: var(--ink); margin: 0 0 4px; }
.empty-state p { font-size: 13px; margin: 0; }

/* ========== INFO BOX ========== */
.info-box {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.info-box.info    { background: #eff6ff; color: #1e3a8a; border-left: 3px solid var(--info); }
.info-box.warning { background: #fef3c7; color: #92400e; border-left: 3px solid var(--warning); }
.info-box.danger  { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--danger); }
.info-box.success { background: #dcfce7; color: #166534; border-left: 3px solid var(--success); }

.info-box i { flex-shrink: 0; font-size: 16px; }

/* ========== DETAIL PROFILE ========== */
.profile-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 20px;
}

.profile-avatar-large {
  width: 80px; height: 80px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  font-weight: 600;
}

.profile-info h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}

.profile-info .meta {
  color: var(--ink-mute);
  font-size: 13px;
  margin-bottom: 12px;
}

.profile-info .stats {
  display: flex;
  gap: 24px;
  font-size: 13px;
}

.profile-info .stats > div {
  border-right: 1px solid var(--border);
  padding-right: 24px;
}
.profile-info .stats > div:last-child { border-right: none; padding-right: 0; }

/* ========== WORKFLOW STAGES (vendor_invoices.html-аас) ========== */
.workflow-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .workflow-bar { grid-template-columns: repeat(2, 1fr); } }

.stage-card {
  padding: 16px 18px;
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: all 0.15s;
  position: relative;
}
.stage-card:last-child { border-right: none; }
.stage-card:hover { background: #f8fafc; }
.stage-card.active {
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  border-bottom: 2px solid var(--primary);
}
.stage-card.active .stage-count { color: var(--primary); }

.stage-label {
  font-size: 11.5px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.stage-count {
  font-size: 24px; font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}
.stage-amount {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}
.stage-icon {
  position: absolute; top: 12px; right: 14px;
  font-size: 20px;
  opacity: 0.3;
}

.profile-info .stats .label {
  color: var(--ink-mute);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.profile-info .stats .value {
  font-size: 18px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* Sidebar collapse */
.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-link .badge,
.sidebar.collapsed .user-info { display: none; }

.sidebar.collapsed .sidebar-link { justify-content: center; padding: 10px; }
.main-content.expanded { margin-left: 70px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row-grid, .form-row-grid-3 { grid-template-columns: 1fr; }
  .profile-header { grid-template-columns: 1fr; text-align: center; }
  .profile-info .stats { flex-direction: column; gap: 12px; }
  .profile-info .stats > div { border-right: none; padding-right: 0; }
}

/* ============================================================
   SIDEBAR SUBMENU (collapsible nested menu)
   ============================================================ */
.sidebar-group {
  list-style: none;
}

.sidebar-link.has-submenu {
  cursor: pointer;
  user-select: none;
}

.sidebar-link.has-submenu .submenu-chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
  font-size: 10px;
  opacity: 0.7;
}

.sidebar-link.has-submenu .badge + .submenu-chevron {
  margin-left: 6px;
}

.sidebar-group.expanded > .sidebar-link.has-submenu .submenu-chevron {
  transform: rotate(90deg);
}

.sidebar-link.has-submenu.has-active-child {
  background: rgba(255,255,255,0.04);
  color: white;
}

.sidebar-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: rgba(0,0,0,0.15);
}

.sidebar-group.expanded > .sidebar-submenu {
  /* #11: settled (нээлттэй) төлөвт clip хийхгүй — сүүлийн дэд цэс 2 мөр болоход
     2 дахь мөр таслагдаж дараагийн үндсэн цэсэнд дарагдаж байсныг зассан.
     overflow:hidden нь зөвхөн хаалттай суурь дүрэмд (анимэйшнд) хэвээр. */
  max-height: 2000px;
  overflow: visible;
}

.sidebar-submenu .sidebar-link {
  padding-left: 56px;
  font-size: 13px;
  position: relative;
}

.sidebar-submenu .sidebar-link::before {
  content: '';
  position: absolute;
  left: 32px;
  /* #11: 2 мөр болоход холбогч зураас мөр хооронд унахгүй — эхний мөрд тулгана */
  top: 21px;
  width: 12px;
  height: 1px;
  background: rgba(255,255,255,0.15);
}

.sidebar-submenu .sidebar-link i {
  font-size: 14px;
  opacity: 0.85;
}

.sidebar-submenu .sidebar-link.active {
  background: rgba(59, 130, 246, 0.2);
}

/* ── BREADCRUMB DROPDOWN — дэд цэстэй хуудсын идэвхтэй breadcrumb дээр дарахад
      доош унадаг цэс (Бараа Материал › Бөөнөөр орлого/зарлага г.м.) ── */
.breadcrumb-custom li.active.bc-has-children { cursor: pointer; }
.breadcrumb-custom li.active.bc-has-children .bc-caret {
  display: inline-block;        /* inline <i> дээр transform ажиллахын тулд ЗААВАЛ */
  font-size: 11px;
  margin-left: 5px;
  color: var(--primary);
  opacity: 0.95;
  vertical-align: middle;
  transition: transform 0.18s ease;
}
/* dropdown нээлттэй үед гурвалжин эргэнэ (дээш) */
.breadcrumb-custom li.active.bc-has-children.bc-open .bc-caret { transform: rotate(180deg); }
.breadcrumb-custom li.active.bc-has-children:hover .bc-caret { opacity: 1; }
.bc-dropdown {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 6px 0;
  min-width: 220px;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 1400;
}
.bc-dropdown-item {
  display: block;
  padding: 9px 18px;
  color: #1e293b;
  font-size: 13.5px;
  text-decoration: none;
  white-space: nowrap;
}
.bc-dropdown-item i { color: #64748b; margin-right: 6px; }
.bc-dropdown-item:hover { background: #f1f5f9; color: #0f172a; }
.bc-dropdown-item.bc-action-item { cursor: pointer; }

/* Collapsed sidebar — submenu hidden */
.sidebar.collapsed .sidebar-submenu { display: none; }
.sidebar.collapsed .submenu-chevron { display: none; }

/* ============================================================
   МИНИ СКРОЛЛ — бүх цонх/грид/модал/дэд цонхны scrollbar нарийн
   (sidebar-ийн 5px загварыг систем даяар жигдэлсэн, 2026-07-02)
   ============================================================ */
* {
  scrollbar-width: thin;                    /* Firefox */
  scrollbar-color: #cbd5e1 transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }   /* Chrome/Edge */
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
/* Sidebar-ийн харанхуй дэвсгэрт хар саарал thumb хэвээр */
.sidebar { scrollbar-color: #475569 transparent; }
