/* Staff analytics (an- prefix). Builds on the dashboard's db- grid, tiles and SVG chart classes. */

/* ---------- dashboard entry tabs (Command center | Analytics) ---------- */
.an-dashtabs { display: flex; gap: 0; border-bottom: 2px solid var(--brand-primary); flex-wrap: wrap; }
.an-dashtabs a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; font-size: 12.5px; font-weight: 700; color: #2f5f88; background: linear-gradient(#fff, #eef3f8); border: 1px solid #cbd7e2; border-bottom: 0; border-radius: 4px 4px 0 0; margin-right: 4px; }
.an-dashtabs a:hover { color: var(--brand-primary); }
.an-dashtabs a.on { background: linear-gradient(180deg, var(--brand-primary-light), #0868c9); color: #fff; border-color: var(--brand-primary); }
.an-dashtabs a .new { font-size: 10px; font-weight: 700; background: #d99a06; color: #fff; border-radius: 8px; padding: 1px 6px; }
.an-dashtabs a.on .new { background: rgba(255, 255, 255, .25); }

/* ---------- section tabs ---------- */
.an-tabs { display: flex; gap: 4px; flex-wrap: wrap; background: linear-gradient(180deg, var(--brand-primary), var(--brand-primary-dark)); border: 1px solid var(--brand-primary-dark); border-radius: 4px; padding: 5px; box-shadow: var(--shadow); }
.an-tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 3px; color: #e3f0fd; font-size: 12px; font-weight: 700; white-space: nowrap; }
.an-tabs a i { font-size: 14px; opacity: .9; }
.an-tabs a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.an-tabs a.on { background: #fff; color: #0a4f99; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.an-tabs a.sa { background: color-mix(in srgb, var(--brand-navy) 35%, transparent); }
.an-tabs a.sa.on { background: #fff; }

/* ---------- filter bar ---------- */
.an-filterbar .ct-input { min-height: 30px; padding: 4px 8px; font-size: 12px; width: auto; }
.an-filterbar input[type=date].ct-input { width: 138px; }
.an-filterbar select.ct-input { max-width: 210px; }

/* ---------- KPI row and insights ---------- */
.an-kpis.db-kpis .ct-kpi em { white-space: normal; overflow: visible; line-height: 1.35; }
.an-insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.an-insight { display: flex; gap: 10px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--infoFg); border-radius: 4px; padding: 10px 11px; box-shadow: var(--shadow); font-size: 12.5px; min-width: 0; }
.an-insight.ok { border-left-color: #12a079; } .an-insight.warn { border-left-color: #d99a06; } .an-insight.bad { border-left-color: #d6334b; }
.an-insight .ic { width: 30px; height: 30px; flex: none; border-radius: 4px; display: grid; place-items: center; background: var(--infoBg); color: var(--infoFg); font-size: 15px; }
.an-insight.ok .ic { background: var(--okBg); color: var(--okFg); } .an-insight.warn .ic { background: var(--warnBg); color: var(--warnFg); } .an-insight.bad .ic { background: var(--badBg); color: var(--badFg); }
.an-insight > div { min-width: 0; }
.an-insight b { display: block; color: var(--text); font-size: 13px; }
.an-insight p { margin: 3px 0 0; color: var(--text2); line-height: 1.4; }
.an-insight .more { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; margin-top: 4px; }

/* ---------- CSV link ---------- */
.an-csv { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: #2f5f88; border: 1px solid #c7d6e4; background: #f5f8fb; border-radius: 3px; padding: 2px 8px; white-space: nowrap; }
.an-csv:hover { background: #e4f0ff; color: var(--blue); border-color: #9fc3e8; }
.ct-panelhead.blue .an-csv { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .4); }

/* ---------- overview headlines ---------- */
.an-heads { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.an-head { position: relative; display: flex; flex-direction: column; gap: 3px; background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--brand-primary); border-radius: 4px; padding: 10px 12px 0; box-shadow: var(--shadow); color: var(--text); overflow: hidden; min-width: 0; }
.an-head:nth-child(8n+2) { border-top-color: #12a079; } .an-head:nth-child(8n+3) { border-top-color: #d99a06; } .an-head:nth-child(8n+4) { border-top-color: #7048c8; }
.an-head:nth-child(8n+5) { border-top-color: #e8632a; } .an-head:nth-child(8n+6) { border-top-color: #2bb3d9; } .an-head:nth-child(8n+7) { border-top-color: #d6334b; } .an-head:nth-child(8n+8) { border-top-color: #123d72; }
.an-head:hover { border-color: #9fc3e8; color: var(--text); box-shadow: 0 4px 12px rgba(18, 45, 72, .14); }
.an-head .t { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #2f5f88; display: flex; align-items: center; gap: 6px; }
.an-head small { font-size: 12px; color: var(--muted); }
.an-head strong { font-size: 24px; line-height: 1.1; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-head .d { display: flex; gap: 6px; align-items: baseline; font-size: 12px; min-width: 0; }
.an-head .d em { font-style: normal; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-head .sp { margin: 4px -12px 0; }
.an-head .sp svg { width: 100%; height: 34px; display: block; }
.an-mini { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }

/* ---------- cohort grid ---------- */
.an-cohort { display: flex; flex-direction: column; gap: 2px; overflow-x: auto; font-size: 11.5px; padding-bottom: 2px; }
.an-ch, .an-cr { display: grid; grid-template-columns: 74px 34px repeat(12, minmax(30px, 1fr)); gap: 2px; align-items: center; min-width: 520px; }
.an-ch span { color: var(--muted); font-weight: 700; text-align: center; font-size: 11px; }
.an-ch span:first-child { text-align: left; }
.an-cr > span { color: var(--text2); white-space: nowrap; }
.an-cr > span.r, .an-ch > span.r { text-align: right; padding-right: 4px; }
.an-cr i { font-style: normal; height: 24px; border-radius: 2px; display: grid; place-items: center; font-size: 11px; font-variant-numeric: tabular-nums; color: #0f3f6e; background: rgba(26, 127, 224, var(--o, .08)); }
.an-cr i.hi { color: #fff; }
.an-cr i.na { background: repeating-linear-gradient(135deg, #f3f6f9 0 4px, #e9eef3 4px 8px); }
.an-cr i.z { background: #eef3f8; }

/* ---------- funnel ---------- */
.an-funnel { display: flex; flex-direction: column; gap: 12px; }
.an-funnel .top { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; margin-bottom: 4px; }
.an-funnel .top b { flex: 1; min-width: 0; color: var(--text); }
.an-funnel .top span { font-size: 15px; font-weight: 700; color: var(--text); }
.an-funnel .top em { font-style: normal; color: var(--muted); width: 40px; text-align: right; }
.an-funnel .bar { height: 18px; background: #e8eef4; border-radius: 3px; overflow: hidden; }
.an-funnel .bar span { display: block; height: 100%; border-radius: 3px; }
.an-funnel .foot { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.an-funnel .conv { color: #2f5f88; font-weight: 700; }

/* ---------- ageing bars ---------- */
.an-age { display: flex; flex-direction: column; gap: 9px; }
.an-age .top { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; margin-bottom: 4px; }
.an-age .l { flex: 1; min-width: 0; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-age .l small { color: var(--muted); font-size: 11px; margin-left: 6px; }
.an-age .bar { display: flex; gap: 2px; height: 10px; background: #e8eef4; border-radius: 3px; overflow: hidden; }
.an-age .bar span { display: block; min-width: 3px; }

/* ---------- inline bars in tables ---------- */
.an-cum { display: inline-block; vertical-align: middle; width: 80px; height: 7px; border-radius: 4px; background: #e8eef4; overflow: hidden; }
.an-cum i { display: block; height: 100%; background: #1a7fe0; border-radius: inherit; }
.an-ratecell { white-space: nowrap; }
.an-rate { display: inline-block; vertical-align: middle; width: 70px; height: 7px; border-radius: 4px; background: #e8eef4; overflow: hidden; margin-right: 4px; }
.an-rate i { display: block; height: 100%; background: #12a079; }
.an-rate i.w { background: #d99a06; } .an-rate i.b { background: #d6334b; }
.an-ratecell .db-d { margin-left: 4px; }

/* ---------- exposure strip ---------- */
.an-expo { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 12px; border-bottom: 1px solid #e3eaf0; background: #fbfcfe; }
.an-expo > div { border-left: 3px solid #d6334b; padding-left: 9px; min-width: 0; }
.an-expo > div:nth-child(2) { border-left-color: #7048c8; } .an-expo > div:nth-child(3) { border-left-color: #e8632a; }
.an-expo span { display: block; font-size: 11.5px; color: var(--muted); }
.an-expo b { font-size: 17px; color: var(--text); white-space: nowrap; }
.an-expo small { display: block; font-size: 11px; color: var(--muted); }

/* ---------- charts ---------- */
.db-legend i.an-dash { background: repeating-linear-gradient(90deg, var(--c, #8a9bb0) 0 4px, transparent 4px 7px); }
.an-donut .db-dlegend { flex-basis: 150px; }
.an-page .db-panel .ct-pbody > .db-ring { margin: 0 auto; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    .an-tabs a.sa { margin-left: 0; }
}
@media (max-width: 760px) {
    .an-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .an-tabs a { flex: none; }
    .an-filterbar .db-fgroup { width: 100%; }
    .an-filterbar .ct-seg { width: 100%; }
    .an-filterbar .ct-seg a { flex: 1 1 auto; justify-content: center; padding: 0 6px; }
    .an-filterbar select.ct-input { flex: 1; max-width: none; }
    .an-custom input[type=date].ct-input { flex: 1; min-width: 0; width: auto; }
    .an-filterbar .db-stamp { white-space: normal; }
    .an-expo { grid-template-columns: minmax(0, 1fr); }
    .an-insights { grid-template-columns: minmax(0, 1fr); }
    .an-dashtabs a { padding: 7px 11px; }
}
@media (max-width: 640px) {
    .an-kpis { grid-template-columns: minmax(0, 1fr); }
    .an-heads { grid-template-columns: minmax(0, 1fr); }
}

.an-page .db-hbars .top .db-d { flex: none; }
