/* Сайтын нийтлэг стиль. Tailwind CDN үндсэн стилийг хариуцна. */
html { scroll-behavior: smooth; }
/* Гар утсан дээр хажуу тийш гүйлгэхгүй (дэлгэцээс гадуурх drawer, урт үг г.м.).
   clip нь hidden-ээс ялгаатай нь sticky header-ийг эвдэхгүй. */
html, body { overflow-x: clip; }
@supports not (overflow: clip) { body { overflow-x: hidden; } }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }

/* Гар утасны доод цэсний зай */
body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0)); }
@media (min-width: 768px) { body { padding-bottom: 0; } }

.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== Drawer ===== */
/* Хаалттай үед visibility:hidden — эс тэгвээс shadow нь дэлгэцийн баруун ирмэгт цацарна. */
.drawer { transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
.drawer.open { transform: translateX(0); visibility: visible; transition: transform .25s ease, visibility 0s; }

/* ===== Bottom nav ===== */
.bottom-nav { padding-bottom: env(safe-area-inset-bottom, 0); }
.bnav-item.active { color: var(--c-primary-h); }
.bnav-item.active .bnav-dot { background: var(--c-primary-h); }

/* ===== Flash messages ===== */
.flash { transition: opacity .3s ease, transform .3s ease; }
.flash.hide { opacity: 0; transform: translateY(-4px); }

/* =====================================================================
   Нийтлэг компонентууд — бүх хуудас эдгээрийг ашиглана.
   Өнгө/хэмжээг өөрчлөхдөө зөвхөн энд засна.
   ===================================================================== */
:root {
  /* Мандах их сургуулийн брэнд өнгө (mandakh.edu.mn): хар хөх #0C2340, цэнхэр #1F5EDE, улаан #CC0000 */
  --c-brand-navy: #0C2340; --c-brand-red: #CC0000;
  --c-primary: #1F5EDE; --c-primary-h: #1749B5;
  --c-danger: #dc2626;  --c-danger-h: #b91c1c;
  --c-success: #16a34a; --c-success-h: #15803d;
  --c-warning: #d97706; --c-warning-h: #b45309;
  --c-dark: #1f2937;    --c-dark-h: #111827;
  --c-border: #e5e7eb;
  --radius: .5rem; --radius-lg: .75rem;
}

/* ----- Хуудасны толгой ----- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; line-height: 2rem; font-weight: 700; color: #111827; letter-spacing: -.01em; }
@media (min-width: 768px) { .page-title { font-size: 1.75rem; line-height: 2.25rem; } }
.page-subtitle { margin-top: .25rem; font-size: .875rem; color: #6b7280; }
.section-title { font-size: 1.0625rem; line-height: 1.5rem; font-weight: 600; color: #1f2937; }

/* ----- Card ----- */
.card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
.card-body { padding: 1.25rem; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
a.card:hover, .card-link:hover { border-color: #bfdbfe; box-shadow: 0 4px 12px rgba(16, 24, 40, .08); }

/* ----- Товч ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .5rem 1rem; font-size: .875rem; line-height: 1.25rem; font-weight: 500;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(31, 94, 222, .35); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.btn.btn-sm { padding: .3125rem .75rem; font-size: .8125rem; }
.btn.btn-lg { padding: .75rem 1.25rem; font-size: 1rem; }
.btn.btn-primary { background: var(--c-primary); color: #fff; }
.btn.btn-primary:hover:not(:disabled) { background: var(--c-primary-h); }
.btn.btn-danger { background: var(--c-danger); color: #fff; }
.btn.btn-danger:hover:not(:disabled) { background: var(--c-danger-h); }
.btn.btn-success { background: var(--c-success); color: #fff; }
.btn.btn-success:hover:not(:disabled) { background: var(--c-success-h); }
.btn.btn-warning { background: var(--c-warning); color: #fff; }
.btn.btn-warning:hover:not(:disabled) { background: var(--c-warning-h); }
.btn.btn-dark { background: var(--c-dark); color: #fff; }
.btn.btn-dark:hover:not(:disabled) { background: var(--c-dark-h); }
.btn.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn.btn-secondary:hover:not(:disabled) { background: #f9fafb; border-color: #9ca3af; }
.btn.btn-ghost { background: transparent; color: #374151; }
.btn.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }

/* ----- Форм ----- */
.form-label { display: block; font-size: .875rem; font-weight: 500; color: #374151; margin-bottom: .25rem; }
.form-control {
  width: 100%; padding: .5rem .75rem; font-size: .875rem; line-height: 1.25rem; color: #111827;
  background: #fff; border: 1px solid #d1d5db; border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .2); }
.form-hint { margin-top: .25rem; font-size: .75rem; color: #6b7280; }

/* ----- Жижиг тэмдэглэгээ ----- */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .125rem .5rem; font-size: .75rem; font-weight: 500; border-radius: 9999px; background: #f3f4f6; color: #374151; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }

/* ----- Хоосон төлөв ----- */
.empty-state { padding: 2.5rem 1rem; text-align: center; color: #6b7280; font-size: .875rem; }

/* ===== DataTable ===== */
.dt-table thead tr:first-child th { background: #f9fafb; font-weight: 600; color: #374151; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
.dt-table tbody tr { border-top: 1px solid #e5e7eb; }
.dt-table tbody tr:hover { background: #f9fafb; }
.dt-sortable:hover { background: #f3f4f6; }
td.dt-actions { white-space: nowrap; padding: 6px 12px; }
td.dt-actions > * { display: inline-flex; align-items: center; }
td.dt-actions > * + * { margin-left: 10px; }
td.dt-actions a, td.dt-actions button { vertical-align: middle; }

/* ----- Icon-ий өнгөт дэвсгэр (stat_card, action_tile) ----- */
.tone-blue { background: #dbeafe; color: #1d4ed8; }
.tone-sky { background: #e0f2fe; color: #0369a1; }
.tone-indigo { background: #e0e7ff; color: #4338ca; }
.tone-purple { background: #f3e8ff; color: #7e22ce; }
.tone-green { background: #dcfce7; color: #15803d; }
.tone-teal { background: #ccfbf1; color: #0f766e; }
.tone-amber { background: #fef3c7; color: #b45309; }
.tone-rose { background: #ffe4e6; color: #be123c; }
.tone-red { background: #fee2e2; color: #b91c1c; }
.tone-gray { background: #f3f4f6; color: #374151; }

/* Мөр доторх устгах товч — хэт хашгирахгүй, гэхдээ аюултай гэдэг нь тод */
.btn.btn-outline-danger { background: #fff; color: var(--c-danger); border-color: #fca5a5; }
.btn.btn-outline-danger:hover:not(:disabled) { background: #fef2f2; border-color: var(--c-danger); }

/* Файл сонгох товчийг бусад товчтой нийцүүлэх */
input[type="file"] { font-size: .875rem; color: #4b5563; }
input[type="file"]::file-selector-button {
  margin-right: .75rem; padding: .375rem .75rem; font-size: .8125rem; font-weight: 500;
  color: #374151; background: #fff; border: 1px solid #d1d5db; border-radius: var(--radius); cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
input[type="file"]::file-selector-button:hover { background: #f9fafb; border-color: #9ca3af; }

/* =====================================================================
   Rail — хэвтээ гүйдэг жагсаалт (нүүр хуудасны клуб, нийтлэл).
   static/js/rail.js-тэй хамт ажиллана.
   ===================================================================== */
.chip-row { display: flex; gap: .5rem; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.chip-row::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: .3125rem .875rem; font-size: .8125rem; font-weight: 500; white-space: nowrap; border-radius: 9999px; border: 1px solid #d1d5db; background: #fff; color: #374151; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.chip:hover { background: #f9fafb; }
.chip.is-active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

.rail { position: relative; }
.rail-track { display: flex; gap: 1rem; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 2px 6px; }
.rail-track::-webkit-scrollbar { display: none; }
.rail-item { flex: 0 0 clamp(220px, 78%, 280px); scroll-snap-align: start; display: flex; flex-direction: column; }
.rail-item[hidden] { display: none; }
.rail-more { flex: 0 0 180px; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; border: 2px dashed #bfdbfe; border-radius: var(--radius-lg); background: #f8fbff; color: var(--c-primary); font-weight: 600; font-size: .9375rem; text-align: center; padding: 1rem; transition: background-color .15s, border-color .15s; }
.rail-more:hover { background: #eff6ff; border-color: var(--c-primary); }
.rail-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 2.25rem; height: 2.25rem; border-radius: 9999px; background: #fff; border: 1px solid var(--c-border); box-shadow: 0 2px 8px rgba(16,24,40,.12); display: none; align-items: center; justify-content: center; color: #374151; }
.rail-btn:hover { background: #f9fafb; }
.rail-btn.prev { left: -.75rem; }
.rail-btn.next { right: -.75rem; }
@media (min-width: 768px) { .rail-btn { display: inline-flex; } }
.rail-btn[disabled] { opacity: 0; pointer-events: none; }

/* Sticky header-ийн доор anchor (#clubs г.м.) нуугдахгүй байх */
section[id] { scroll-margin-top: 84px; }

/* =====================================================================
   Хуудасны загварууд (templates/base/*.html) — docs/GUIDE.md
   ===================================================================== */
.page { max-width: 80rem; margin: 0 auto; padding: 1rem; }
@media (min-width: 768px) { .page { padding: 1.5rem; } }
.page-back { display: inline-block; margin-bottom: .5rem; font-size: .875rem; color: #6b7280; }
.page-back:hover { color: var(--c-primary); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.page-actions:empty { display: none; }

/* Шүүлтүүр: талбаргүй бол бүтнээрээ нуугдана */
.filter-box { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; padding: .875rem 1rem; margin-bottom: 1rem; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); }
.filter-box:not(:has(.filter-fields > *)) { display: none; }
.filter-fields { display: flex; flex-wrap: wrap; gap: .75rem; flex: 1; }
.filter-field { display: flex; flex-direction: column; min-width: 160px; flex: 1 1 160px; max-width: 260px; }
.filter-field .form-label { font-size: .75rem; color: #6b7280; }
.filter-buttons { display: flex; gap: .5rem; }

/* Жагсаалт */
.list-card { min-width: 0; }
.list-card > table:not(.dt-table) { width: 100%; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); }

/* BaseInfo */
.info-layout { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .info-layout { grid-template-columns: minmax(0, 1fr) 300px; } }
.info-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.info-fields { display: grid; grid-template-columns: 1fr; margin: 0; }
@media (min-width: 640px) { .info-fields { grid-template-columns: 1fr 1fr; } }
.info-fields > div { padding: .75rem 1.25rem; border-bottom: 1px solid #f3f4f6; }
.info-fields dt { font-size: .75rem; color: #6b7280; }
.info-fields dd { margin: .125rem 0 0; font-size: .9375rem; color: #111827; word-break: break-word; }
.menu-list { display: flex; flex-direction: column; overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; font-size: .9375rem; color: #374151; border-bottom: 1px solid #f3f4f6; }
.menu-item:last-child { border-bottom: 0; }
.menu-item:hover { background: #f9fafb; color: var(--c-primary); }
.menu-item.is-danger { color: var(--c-danger); }
.menu-item.is-danger:hover { background: #fef2f2; }

/* BaseInfoTreeList / BaseGroupList */
.tree-layout { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .tree-layout { grid-template-columns: 240px minmax(0, 1fr); align-items: start; } }
.tree-nav { padding: .5rem; }
.tree-title { padding: .375rem .625rem; font-size: .75rem; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .03em; }
.tree-root, .tree-root ul { list-style: none; margin: 0; padding: 0; }
.tree-root ul { padding-left: .875rem; border-left: 1px solid #e5e7eb; margin-left: .75rem; }
.tree-link { display: flex; align-items: center; gap: .5rem; padding: .4375rem .625rem; border-radius: var(--radius); font-size: .875rem; color: #374151; }
.tree-link:hover { background: #f3f4f6; }
.tree-link.is-active { background: #eff6ff; color: var(--c-primary); font-weight: 600; }
.tree-count { margin-left: auto; font-size: .75rem; color: #9ca3af; }
.tree-link.is-active .tree-count { color: var(--c-primary); }
/* Утсан дээр мод нь хэвтээ гүйдэг мөр болно */
@media (max-width: 1023px) {
  .tree-nav { padding: .375rem; }
  .tree-title { display: none; }
  .tree-root { display: flex; gap: .375rem; overflow-x: auto; scrollbar-width: none; }
  .tree-root::-webkit-scrollbar { display: none; }
  .tree-root ul { display: contents; }
  .tree-root li { display: contents; }
  .tree-link { white-space: nowrap; border: 1px solid #e5e7eb; border-radius: 9999px; padding: .3125rem .875rem; }
}
.tree-content { min-width: 0; }

/* SearchSelect (static/js/search-select.js) */
.ss-wrap { position: relative; }
.ss-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 16rem; overflow-y: auto; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: 0 10px 25px -5px rgb(0 0 0 / .12); padding: .25rem; }
.ss-item, .ss-none { padding: .5rem .625rem; border-radius: calc(var(--radius) - 2px); font-size: .875rem; }
.ss-item { cursor: pointer; color: #1f2937; }
.ss-item:hover, .ss-item.is-active { background: #eff6ff; color: var(--c-primary); }
.ss-item.is-selected { font-weight: 600; }
.ss-item.is-empty { color: #9ca3af; }
.ss-none { color: #9ca3af; }

/* DocumentForm */
.doc-form { max-width: 56rem; }
.doc-form.is-narrow { max-width: 28rem; }
.page.page-narrow { max-width: calc(28rem + 2rem); }
@media (min-width: 768px) { .page.page-narrow { max-width: calc(28rem + 3rem); padding-top: 3rem; } }
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .doc-form:not(.is-narrow) .form-grid { grid-template-columns: 1fr 1fr; } }
.form-field.is-wide { grid-column: 1 / -1; }
.form-error { margin-top: .25rem; font-size: .75rem; color: var(--c-danger); }
.form-errors { padding: .625rem .875rem; border-radius: var(--radius); background: #fef2f2; color: #991b1b; font-size: .875rem; }
.doc-form-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .875rem 1.25rem; border-top: 1px solid var(--c-border); background: #f9fafb; border-radius: 0 0 var(--radius-lg) var(--radius-lg); position: sticky; bottom: 0; }

/* =====================================================================
   DataTable (static/js/datatable.js) — өөрийн загвар
   ===================================================================== */
.dt-wrap { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: 0 1px 2px rgba(16,24,40,.05); overflow: hidden; }
.dt-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .625rem .75rem; border-bottom: 1px solid var(--c-border); }
.dt-toolbar-left, .dt-toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.dt-search-wrap { display: flex; align-items: center; gap: .375rem; padding: 0 .625rem; height: 2rem; border: 1px solid #d1d5db; border-radius: var(--radius); color: #9ca3af; background: #fff; }
.dt-search-wrap:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.dt-search { border: 0; outline: 0; font-size: .8125rem; width: 13rem; color: #111827; background: transparent; }
.dt-group-wrap, .dt-size-wrap { display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; color: #6b7280; }
.dt-group-wrap select, .dt-size-wrap select { height: 2rem; padding: 0 .5rem; border: 1px solid #d1d5db; border-radius: var(--radius); font-size: .8125rem; color: #111827; background: #fff; }
.dt-cols-menu { position: absolute; z-index: 30; margin-top: .25rem; min-width: 200px; max-height: 18rem; overflow: auto; padding: .375rem; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16,24,40,.12); font-size: .8125rem; }
.dt-cols-item { display: flex; align-items: center; gap: .5rem; padding: .3125rem .5rem; border-radius: 6px; cursor: pointer; }
.dt-cols-item:hover { background: #f3f4f6; }
.dt-scroll { overflow-x: auto; }
.dt-table thead tr:first-child th { position: sticky; top: 0; z-index: 1; }
.dt-table td, .dt-table th { padding: .5625rem .875rem; }
.dt-filter-row th { padding: .375rem .5rem; background: #fff; border-bottom: 1px solid var(--c-border); }
.dt-filter-input { width: 100%; padding: .25rem .5rem; font-size: .75rem; border: 1px solid #e5e7eb; border-radius: 6px; }
.dt-filter-input:focus { outline: 0; border-color: #3b82f6; }
.dt-group td { padding: .5rem .875rem; background: #f8fafc; border-top: 1px solid var(--c-border); font-size: .8125rem; color: #374151; cursor: pointer; user-select: none; }
.dt-group:hover td { background: #eff6ff; }
.dt-group-caret { display: inline-block; transition: transform .15s; color: #9ca3af; }
.dt-group.is-collapsed .dt-group-caret { transform: rotate(-90deg); }
.dt-group-col { color: #6b7280; }
.dt-group-count { margin-left: .375rem; padding: 0 .4375rem; border-radius: 9999px; background: #e0e7ff; color: #3730a3; font-size: .6875rem; font-weight: 600; }
.dt-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .75rem; border-top: 1px solid var(--c-border); font-size: .8125rem; color: #6b7280; }
.dt-pager { display: flex; flex-wrap: wrap; gap: .25rem; }
.dt-page-btn { min-width: 2rem; height: 2rem; padding: 0 .5rem; border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; color: #374151; font-size: .8125rem; }
.dt-page-btn:hover:not(:disabled) { background: #f3f4f6; }
.dt-page-btn.is-active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.dt-page-btn:disabled { opacity: .4; cursor: default; }
@media (max-width: 640px) { .dt-search { width: 9rem; } }
/* Хоосон жагсаалт (DataTable ажиллаагүй үед) */
.list-card > table:not(.dt-table) th { padding: .625rem .875rem; text-align: left; font-size: 12px; font-weight: 600; color: #374151; text-transform: uppercase; letter-spacing: .02em; background: #f9fafb; border-bottom: 1px solid var(--c-border); }
.list-card > table:not(.dt-table) { border-collapse: separate; border-spacing: 0; overflow: hidden; }

/* =====================================================================
   KPI карт + хоёр оны график (components/kpi_card.html, year_compare_chart.html)
   Цувралын өнгө: validate_palette.js-ээр шалгасан (CVD ΔE 24.7, contrast >= 3:1)
   ===================================================================== */
:root { --series-this: #2a78d6; --series-last: #eb6834; --chart-grid: #ececea; --chart-ink: #52514e; }
.kpi-card { text-align: left; display: flex; flex-direction: column; gap: .25rem; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.kpi-card:hover { border-color: #bfdbfe; }
.kpi-card.is-selected { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(31, 94, 222, .15); }
.kpi-total { margin-top: .375rem; font-size: 1.875rem; line-height: 1; font-weight: 700; color: #111827; }
.kpi-years { display: flex; gap: .75rem; font-size: .8125rem; color: #374151; }
.kpi-years b { font-weight: 600; color: #6b7280; }
.kpi-change { font-size: .75rem; color: #374151; }

.yc { padding: 1rem 1.25rem 1.25rem; }
.yc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.yc-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .25rem; font-size: .8125rem; color: #374151; }
.yc-legend > span { display: inline-flex; align-items: center; gap: .375rem; }
.yc-sw { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; flex-shrink: 0; }
.yc-sw-this { background: var(--series-this); }
.yc-sw-last { background: var(--series-last); }
.yc-metrics { margin: .875rem 0 .5rem; }
.yc-body { position: relative; }
.yc-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.yc-grid { stroke: var(--chart-grid); stroke-width: 1; }
.yc-base { stroke: #d6d5d1; stroke-width: 1; }
.yc-axis { font-size: 11px; fill: var(--chart-ink); }
.yc-axis.is-future { fill: #b4b3ad; }
.yc-value { font-size: 11px; font-weight: 600; fill: #111827; }
.yc-bar-this { fill: var(--series-this); }
.yc-bar-last { fill: var(--series-last); }
.yc-hover { fill: transparent; }
.yc-month:hover .yc-hover { fill: rgba(17, 24, 39, .04); }
.yc-tooltip { position: absolute; z-index: 5; min-width: 150px; padding: .5rem .625rem; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); font-size: .8125rem; color: #111827; pointer-events: none; }
.yc-tip-title { font-weight: 600; margin-bottom: .25rem; }
.yc-tip-row { display: flex; align-items: center; gap: .375rem; color: #374151; }
.yc-tip-row b { margin-left: auto; padding-left: .75rem; color: #111827; }
.yc-tip-diff { margin-top: .25rem; padding-top: .25rem; border-top: 1px solid #f3f4f6; color: #374151; }
.yc-table table { width: 100%; font-size: .875rem; border-collapse: collapse; }
.yc-table th, .yc-table td { padding: .375rem .625rem; border-bottom: 1px solid #f3f4f6; text-align: right; }
.yc-table th:first-child, .yc-table td:first-child { text-align: left; }
.yc-table tfoot td { font-weight: 600; border-bottom: 0; }

/* ----- DataTable: бүлэглэх панель (зүүн тал) ----- */
.dt-body { display: flex; align-items: stretch; min-width: 0; }
.dt-body > .dt-scroll { flex: 1; min-width: 0; }
.dt-side { flex: 0 0 220px; padding: .75rem; border-right: 1px solid var(--c-border); background: #fafaf9; font-size: .8125rem; }
.dt-side[hidden] { display: none; }
.dt-side-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; color: #111827; margin-bottom: .5rem; }
.dt-side-close { width: 1.5rem; height: 1.5rem; border-radius: 6px; color: #6b7280; }
.dt-side-close:hover { background: #ececea; }
.dt-side-label { margin: .75rem 0 .375rem; font-size: .6875rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #6b7280; }
.dt-side-hint { margin-top: .375rem; font-size: .6875rem; color: #9ca3af; line-height: 1.35; }
.dt-group-list { list-style: none; margin: 0; padding: .375rem; min-height: 2.75rem; border: 1px dashed #d6d5d1; border-radius: var(--radius); background: #fff; transition: border-color .15s, background-color .15s; }
.dt-group-list.is-over { border-color: var(--c-primary); background: #eff6ff; }
.dt-group-empty { padding: .375rem; color: #9ca3af; text-align: center; }
.dt-group-item { display: flex; align-items: center; gap: .375rem; padding: .3125rem .375rem; border-radius: 6px; background: #eef2ff; color: #1e3a8a; }
.dt-group-item + .dt-group-item { margin-top: .25rem; }
.dt-group-n { display: inline-flex; align-items: center; justify-content: center; width: 1.125rem; height: 1.125rem; border-radius: 9999px; background: #fff; font-size: .6875rem; font-weight: 700; flex-shrink: 0; }
.dt-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dt-mini { width: 1.375rem; height: 1.375rem; border-radius: 5px; font-size: .75rem; color: #3730a3; flex-shrink: 0; }
.dt-mini:hover { background: #fff; }
.dt-col-list { list-style: none; margin: 0; padding: 0; }
.dt-col-item { padding: .375rem .5rem; border-radius: 6px; color: #374151; cursor: pointer; user-select: none; }
.dt-col-item:hover { background: #ececea; }
.dt-col-item[draggable="true"] { cursor: grab; }
.dt-col-item.is-used { color: #b4b3ad; cursor: default; }
.dt-col-item.is-used::after { content: " ✓"; }
.dt-group-toggle.is-on { border-color: var(--c-primary); color: var(--c-primary); background: #eff6ff; }
.dt-group-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.125rem; height: 1.125rem; padding: 0 .25rem; border-radius: 9999px; background: var(--c-primary); color: #fff; font-size: .6875rem; }
.dt-table th[draggable="true"] { cursor: grab; }
.dt-group.dt-level-1 td { background: #fbfcfe; }
.dt-group.dt-level-2 td { background: #fdfdfe; }
@media (max-width: 767px) {
  .dt-body { flex-direction: column; }
  .dt-side { flex-basis: auto; border-right: 0; border-bottom: 1px solid var(--c-border); }
}

/* ----- DataTable: зүүн = бүлэглэх хэмжүүр, баруун дээд = утгын шүүлтүүр ----- */
.dt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dt-dim-list { list-style: none; margin: 0; padding: 0; }
.dt-dim { display: flex; align-items: center; gap: .5rem; padding: .5rem .625rem; border-radius: var(--radius); color: #374151; cursor: pointer; user-select: none; }
.dt-dim:hover { background: #ececea; }
.dt-dim.is-active { background: #eff6ff; color: var(--c-primary); font-weight: 600; }
.dt-dim-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-dim-count { font-size: .6875rem; color: #9ca3af; }
.dt-dim.is-active .dt-dim-count { color: var(--c-primary); }
.dt-value-bar { display: flex; align-items: center; gap: .375rem; padding: .625rem .75rem; border-bottom: 1px solid var(--c-border); overflow-x: auto; scrollbar-width: thin; }
.dt-value-bar[hidden] { display: none; }
.dt-value-label { flex-shrink: 0; margin-right: .25rem; font-size: .8125rem; font-weight: 600; color: #374151; }
.dt-value-bar .chip { flex-shrink: 0; }
.dt-value-n { font-size: .6875rem; opacity: .7; }
.dt-group-badge:not([hidden]) { width: auto; padding: 0 .4375rem; }
@media (max-width: 767px) {
  .dt-side .dt-dim-list { display: flex; gap: .375rem; overflow-x: auto; }
  .dt-side .dt-dim { flex-shrink: 0; border: 1px solid #e5e7eb; border-radius: 9999px; padding: .3125rem .75rem; }
}

/* =====================================================================
   Үйлдлийн icon товч ({% icon_action %}) + дээр нь tooltip
   ===================================================================== */
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: var(--radius); color: #4b5563; background: transparent; border: 1px solid transparent; font-size: 1.125rem; line-height: 1; cursor: pointer; transition: background-color .12s, color .12s, border-color .12s; text-decoration: none; }
.icon-btn:hover { background: #f3f4f6; color: #111827; border-color: #e5e7eb; }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(31, 94, 222, .3); }
.icon-btn.is-danger:hover { background: #fef2f2; color: var(--c-danger); border-color: #fecaca; }
.icon-btn.is-success:hover { background: #f0fdf4; color: var(--c-success); border-color: #bbf7d0; }
/* Tooltip: icon-ы дээр, хар дэвсгэр */
.icon-btn[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translate(-50%, 2px);
  padding: .25rem .5rem; border-radius: 6px; background: #111827; color: #fff; font-size: .75rem; font-weight: 500; line-height: 1.2;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s, transform .12s; z-index: 50;
}
.icon-btn[data-tip]::before {
  content: ""; position: absolute; bottom: calc(100% + 1px); left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #111827; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 50;
}
.icon-btn[data-tip]:hover::after, .icon-btn[data-tip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.icon-btn[data-tip]:hover::before, .icon-btn[data-tip]:focus-visible::before { opacity: 1; }
.icon-actions, td.dt-actions { white-space: nowrap; }
td.dt-actions > .icon-btn + .icon-btn, .icon-actions > * + * { margin-left: 2px; }
td.dt-actions form { display: inline-flex; }
/* Хүснэгтийн scroll хайрцаг tooltip-ийг таслахгүйн тулд эхний мөрөнд доош нь гаргана */
.dt-table tbody tr:first-child .icon-btn[data-tip]::after { bottom: auto; top: calc(100% + 6px); }
.dt-table tbody tr:first-child .icon-btn[data-tip]::before { bottom: auto; top: calc(100% + 1px); border-top-color: transparent; border-bottom-color: #111827; }

/* ----- DataTable: мөр тодруулах, багана нуух, багтаах ----- */
.dt-table tbody tr:not(.dt-group):hover td { background: #eef4ff; }
.dt-table tbody tr:not(.dt-group) { cursor: default; }
.dt-table thead tr:first-child th { position: relative; }
.dt-hide-col { position: absolute; top: 50%; right: .25rem; transform: translateY(-50%); width: 1.375rem; height: 1.375rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; color: #9ca3af; background: #f9fafb; opacity: 0; transition: opacity .12s; font-size: .9375rem; }
.dt-table thead th:hover .dt-hide-col, .dt-hide-col:focus-visible { opacity: 1; }
.dt-hide-col:hover { color: var(--c-danger); background: #fef2f2; }
@media (hover: none) { .dt-hide-col { opacity: .6; } }
.dt-hidden-note { margin-left: .25rem; padding: .25rem .625rem; border-radius: 9999px; background: #fef3c7; color: #92400e; font-size: .75rem; font-weight: 500; white-space: nowrap; }
.dt-hidden-note:hover { background: #fde68a; }
.dt-hidden-note[hidden] { display: none; }
/* Хажуу тийш гүйлгэхгүй — багтахгүй баганыг JS нууна */
.dt-scroll { overflow-x: hidden; }
.dt-table td { overflow-wrap: anywhere; }
/* Хүснэгтийн мөр доторх icon арай жижиг; хүрэлтийн дэлгэцэнд хуруугаар гүйлгэхийг зөвшөөрнө */
.dt-table .icon-btn { width: 1.75rem; height: 1.75rem; font-size: 1.0625rem; }
@media (hover: none) { .dt-scroll { overflow-x: auto; } }
/* Мөр: hover-д тод өнгө, дэлгэрэнгүй рүү ордог мөрөнд гар хуруу курсор */
.dt-table tbody tr:not(.dt-group):hover td { background: #e6efff; }
.dt-table tbody tr.dt-row-link { cursor: pointer; }
.dt-table tbody tr.is-selected, .dt-table tbody tr.is-selected:hover { background: #eff6ff; }
.dt-table tbody tr.is-selected > td:first-child { box-shadow: inset 3px 0 0 var(--c-primary); }
/* Систем админ клубийн горимд байх үеийн мөр (base.html) */
.acting-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; padding: .4375rem 1rem; background: #eef2ff; color: #3730a3; font-size: .8125rem; border-bottom: 1px solid #e0e7ff; }
.acting-bar a { font-weight: 600; text-decoration: underline; }

/* =====================================================================
   Зураг оруулах preview (static/js/image-input.js)
   ===================================================================== */
.img-input { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.img-prev { position: relative; flex-shrink: 0; overflow: hidden; background: #f3f4f6; border: 1px solid var(--c-border); display: flex; align-items: center; justify-content: center; }
.img-prev.is-square { width: 96px; height: 96px; border-radius: var(--radius-lg); }
.img-prev.is-circle { width: 96px; height: 96px; border-radius: 9999px; }
.img-prev.is-wide { width: 100%; max-width: 360px; aspect-ratio: 3 / 1; border-radius: var(--radius-lg); }
.img-prev img { width: 100%; height: 100%; object-fit: cover; }
.img-prev.is-square img { object-fit: contain; background: #fff; }
.img-prev.is-new { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(31, 94, 222, .15); }
.img-prev.is-clearing { opacity: .45; }
.img-empty { display: flex; flex-direction: column; align-items: center; gap: .125rem; font-size: .6875rem; color: #9ca3af; }
.img-empty i { font-size: 1.5rem; }
.img-badge { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); padding: 1px 6px; border-radius: 9999px; background: #111827cc; color: #fff; font-size: .625rem; white-space: nowrap; }
.img-badge[hidden], .img-empty[hidden], .img-prev img[hidden] { display: none; }
.img-side { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; }
.img-side [hidden] { display: none; }
.img-info { flex-basis: 100%; font-size: .75rem; color: #6b7280; overflow-wrap: anywhere; }
.img-info:empty { display: none; }
.img-native { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
label.btn { position: relative; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; margin-top: .5rem; }
.img-grid[hidden] { display: none; }
.img-card { position: relative; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; background: #f9fafb; }
.img-card img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.img-card span { display: block; padding: 2px 6px; font-size: .625rem; color: #6b7280; }
.img-remove { position: absolute; top: 4px; right: 4px; width: 1.5rem; height: 1.5rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 9999px; background: #ffffffe6; color: #b91c1c; border: 1px solid #fecaca; }
.img-remove:hover { background: #fef2f2; }
/* data-autosave: зурган дээр дарж цэс нээнэ */
.img-input:has(.is-editable) { position: relative; }
.img-prev.is-editable { cursor: pointer; }
.img-prev.is-editable:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.img-hover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(17, 24, 39, .35); color: #fff; font-size: 1.5rem; opacity: 0; transition: opacity .15s; }
.img-prev.is-editable:hover .img-hover { opacity: 1; }
.img-prev.is-saving { opacity: .6; pointer-events: none; }
.img-corner-del { position: absolute; top: 6px; right: 6px; z-index: 1; width: 1.75rem; height: 1.75rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 9999px; background: #ffffffe6; color: #b91c1c; border: 1px solid #fecaca; }
.img-corner-del:hover { background: #fef2f2; }
.img-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; min-width: 180px; padding: .25rem; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); }
.img-menu-item { display: flex; width: 100%; align-items: center; gap: .5rem; padding: .4375rem .625rem; border-radius: 6px; font-size: .875rem; color: #374151; text-align: left; }
.img-menu-item:hover { background: #f3f4f6; }
.img-menu-item.is-danger { color: #b91c1c; }
.img-menu-item.is-danger:hover { background: #fef2f2; }
.img-viewer { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(0, 0, 0, .85); }
.img-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius); background: #fff; }
.img-viewer-close { position: absolute; top: 1rem; right: 1rem; width: 2.5rem; height: 2.5rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 9999px; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.25rem; }
