/* «Ирцийн хяналт» (Editors/AttendanceMonitor). Бүх класс atm- угтвартай.
   Өнгө нь Bootstrap-ийн хувьсагчийг (DevExpress-ийн сэдэв) дагана — attendance-dashboard.css-тэй ижил.
   Төлөвийн өнгө (амжилттай / алдаатай / илгээгдээгүй / хүлээгдэж буй) нь ЗӨВХӨН төлөвт — үргэлж
   тэмдэг (✓ ✕ ! ⏳) ба шошготой хамт; график бүр тайлбар (legend), title-тооцоотой. */

.atm-root {
    --atm-accent: var(--bs-primary, #2563eb);
    --atm-border: var(--bs-border-color, #e2e8f0);
    --atm-muted: var(--bs-secondary-color, #64748b);
    --atm-surface: var(--bs-body-bg, #ffffff);
    --atm-soft: var(--bs-tertiary-bg, #f8fafc);
    --atm-good: var(--bs-success, #16a34a);
    --atm-bad: var(--bs-danger, #dc2626);
    --atm-warn: #b45309;
    --atm-info: var(--bs-info, #0284c7);
    --atm-neutral: #64748b;
    --atm-track: var(--bs-secondary-bg, #e9ecef);
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 0.875rem;
    max-width: 1440px;
}

.atm-error { padding: 16px; border: 1px solid var(--atm-bad); border-radius: 8px; color: var(--atm-bad); }
.atm-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.atm-title { font-size: 1.25rem; font-weight: 600; }
.atm-muted { color: var(--atm-muted); }
.atm-good { color: var(--atm-good); }
.atm-bad { color: var(--atm-bad); }
.atm-warn { color: var(--atm-warn); }
.atm-nowrap { white-space: nowrap; }
.atm-hint { color: var(--atm-muted); font-size: 0.8rem; line-height: 1.5; }
.atm-empty { color: var(--atm-muted); padding: 8px 0; }

.atm-icon-btn {
    border: 1px solid var(--atm-border);
    background: var(--atm-surface);
    border-radius: 8px;
    min-width: 36px; height: 36px;
    font-size: 1rem;
    cursor: pointer;
}
.atm-icon-btn:disabled { opacity: .4; cursor: default; }

/* ── Хугацаа ─────────────────────────────── */
.atm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.atm-seg { display: inline-flex; border: 1px solid var(--atm-border); border-radius: 8px; overflow: hidden; }
.atm-seg-btn { border: 0; background: var(--atm-surface); padding: 7px 14px; cursor: pointer; }
.atm-seg-btn + .atm-seg-btn { border-left: 1px solid var(--atm-border); }
.atm-seg-active { background: var(--atm-accent); color: #fff; }
.atm-nav { display: flex; align-items: center; gap: 6px; }
.atm-period { min-width: 190px; text-align: center; font-weight: 600; }
.atm-date { width: 150px; }
.atm-chip {
    border: 1px solid var(--atm-border); background: var(--atm-surface);
    border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.atm-chip-active { border-color: var(--atm-accent); color: var(--atm-accent); }

/* ── Шүүлтүүр ─────────────────────────────── */
.atm-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px 12px;
    padding: 12px;
    border: 1px solid var(--atm-border);
    border-radius: 10px;
    background: var(--atm-soft);
}
.atm-field { display: flex; flex-direction: column; gap: 3px; margin: 0; }
.atm-field > span { font-size: 0.75rem; color: var(--atm-muted); }
.atm-field-wide { grid-column: span 2; }
.atm-select, .atm-input {
    height: 32px; padding: 4px 8px;
    border: 1px solid var(--atm-border); border-radius: 6px;
    background: var(--atm-surface); color: inherit; font-size: 0.85rem;
}
.atm-combo { width: 100%; }

/* ── Drill-down зам ─────────────────────────────── */
.atm-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.9rem; }
.atm-crumb { border: 0; background: none; padding: 2px 4px; color: var(--atm-accent); cursor: pointer; font-weight: 600; }
.atm-crumb:disabled, .atm-crumb-current { color: inherit; cursor: default; }
.atm-crumb-sep { color: var(--atm-muted); }

/* ── KPI ─────────────────────────────── */
.atm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.atm-kpi {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    border: 1px solid var(--atm-border); border-left-width: 4px;
    border-radius: 10px; background: var(--atm-surface);
    padding: 10px 12px; text-align: left; color: inherit; font: inherit;
}
button.atm-kpi { cursor: pointer; transition: box-shadow .15s; }
button.atm-kpi:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.atm-kpi-value { font-size: 1.4rem; font-weight: 600; line-height: 1.2; }
.atm-kpi-sub { font-size: 0.75rem; color: var(--atm-muted); }
.atm-kpi-good { border-left-color: var(--atm-good); }
.atm-kpi-bad { border-left-color: var(--atm-bad); }
.atm-kpi-warn { border-left-color: var(--atm-warn); }

/* ── Карт, хүснэгт ─────────────────────────────── */
.atm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.atm-span-2 { grid-column: 1 / -1; }
.atm-card {
    border: 1px solid var(--atm-border); border-radius: 10px; background: var(--atm-surface);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.atm-card-title { font-weight: 600; font-size: 0.95rem; }
.atm-card-sub { font-weight: 600; font-size: 0.8rem; color: var(--atm-muted); margin-top: 6px; }
.atm-scroll { overflow-x: auto; }
.atm-table { width: 100%; border-collapse: collapse; }
.atm-table th {
    text-align: left; font-weight: 600; font-size: 0.75rem; color: var(--atm-muted);
    border-bottom: 1px solid var(--atm-border); padding: 6px 8px; white-space: nowrap;
}
.atm-table td { border-bottom: 1px solid var(--atm-border); padding: 6px 8px; vertical-align: top; }
.atm-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.atm-row { cursor: pointer; }
.atm-row:hover td { background: var(--atm-soft); }
.atm-dates { font-variant-numeric: tabular-nums; max-width: 260px; }
.atm-msg { max-width: 320px; }
.atm-link { border: 0; background: none; padding: 0; color: var(--atm-accent); cursor: pointer; text-align: left; }
.atm-link:hover { text-decoration: underline; }

.atm-tag {
    display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px;
    font-size: 0.7rem; border: 1px solid var(--atm-border);
}
.atm-tag-warn { color: var(--atm-warn); border-color: var(--atm-warn); }

.atm-status { display: inline-block; white-space: nowrap; font-weight: 600; font-size: 0.8rem; }
.atm-status-good { color: var(--atm-good); }
.atm-status-bad { color: var(--atm-bad); }
.atm-status-warn { color: var(--atm-warn); }
.atm-status-info { color: var(--atm-info); }

.atm-retry { font-size: 0.8rem; white-space: nowrap; border-bottom: 1px dotted currentColor; cursor: help; }
.atm-retry-yes { color: var(--atm-good); }
.atm-retry-afterfix { color: var(--atm-warn); }
.atm-retry-no { color: var(--atm-muted); }

.atm-detail-row td { background: var(--atm-soft); }
.atm-detail { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; line-height: 1.5; }
.atm-pre { white-space: pre-wrap; word-break: break-word; font-family: var(--bs-font-monospace, monospace); font-size: 0.75rem; }

/* ── Tab ─────────────────────────────── */
.atm-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--atm-border); }
.atm-tab {
    border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--atm-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600;
}
.atm-tab-active { color: var(--atm-accent); border-bottom-color: var(--atm-accent); }
.atm-pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.atm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.atm-chip-static { border: 1px solid var(--atm-border); border-radius: 999px; padding: 3px 10px; }

/* ── Графикууд (CSS) ─────────────────────────────── */
.atm-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.8rem; }
.atm-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.atm-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.atm-sw-good { background: var(--atm-good); }
.atm-sw-bad { background: var(--atm-bad); }
.atm-sw-warn { background: var(--atm-warn); }
.atm-sw-info { background: var(--atm-info); }
.atm-sw-off { background: var(--atm-track); }

/* Өдөр бүрийн чиг хандлага: өгсөн (доор) + өгөөгүй (дээр), 2px зай */
.atm-trend { display: flex; align-items: flex-end; gap: 6px; height: 190px; overflow-x: auto; padding-bottom: 2px; }
.atm-trend-col {
    flex: 1 0 34px; display: flex; flex-direction: column; align-items: center; gap: 2px;
    border: 0; background: none; padding: 0; cursor: pointer; height: 100%; color: inherit; font: inherit;
}
.atm-trend-col:hover .atm-trend-track { outline: 2px solid var(--atm-accent); outline-offset: 1px; }
.atm-trend-val { font-size: 0.7rem; color: var(--atm-muted); min-height: 1em; }
.atm-trend-track { flex: 1; width: 22px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; border-radius: 4px; }
.atm-trend-good { background: var(--atm-good); border-radius: 0 0 4px 4px; }
.atm-trend-bad { background: var(--atm-bad); opacity: .75; border-radius: 4px 4px 0 0; }
.atm-trend-off { height: 100%; background: var(--atm-track); border-radius: 4px; }
.atm-trend-label { font-size: 0.75rem; font-weight: 600; }
.atm-trend-sub { font-size: 0.65rem; color: var(--atm-muted); }
.atm-trend-dense .atm-trend-val { display: none; }
.atm-trend-dense .atm-trend-col { flex-basis: 26px; }
.atm-trend-dense .atm-trend-track { width: 16px; }

/* Хэвтээ баар (төрөл, алдааны ангилал) */
.atm-hbar { display: grid; grid-template-columns: minmax(120px, 38%) 1fr 64px; align-items: center; gap: 8px; font-size: 0.8rem; }
.atm-hbar-btn { border: 0; background: none; padding: 2px 0; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.atm-hbar-btn:hover .atm-hbar-label { color: var(--atm-accent); }
.atm-hbar-track { height: 12px; background: var(--atm-track); border-radius: 4px; overflow: hidden; }
.atm-hbar-fill { display: block; height: 100%; background: var(--atm-good); border-radius: 0 4px 4px 0; }
.atm-hbar-neutral { background: var(--atm-neutral); }
.atm-hbar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Овоолсон баар (өгсөн/өгөөгүй, ESIS төлөв) — сегмент хооронд 2px */
.atm-stack { display: flex; gap: 2px; height: 16px; border-radius: 4px; overflow: hidden; }
.atm-stack-seg { display: block; height: 100%; min-width: 2px; }

/* ── Шууд холбоос ─────────────────────────────── */
.atm-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.atm-action {
    padding: 10px 14px; min-height: 46px; border: 1px solid var(--atm-border); border-radius: 10px;
    background: var(--atm-surface); font-weight: 600; cursor: pointer; text-align: left; color: inherit;
}
.atm-action:hover { border-color: var(--atm-accent); }

@media (max-width: 700px) {
    .atm-field-wide { grid-column: auto; }
    .atm-period { min-width: 0; }
    .atm-hbar { grid-template-columns: 1fr 64px; }
    .atm-hbar-track { grid-column: 1 / -1; grid-row: 2; }
}
