/* =====================================================
   Admin analytics dashboard
   Chart colours: series from the validated reference palette
   (blue + orange, ΔE 24.7 CVD). Statuses keep the app's status
   colours and always carry a label, a count and a tooltip.
   ===================================================== */
.viz {
    --surface: #ffffff;
    --ink: #1e293b;          /* primary text */
    --ink-2: #475569;        /* secondary text */
    --ink-3: #64748b;        /* muted: axes, hints */
    --grid: #e2e8f0;         /* hairline grid */
    --s1: #2a78d6;           /* series 1: blue */
    --s2: #eb6834;           /* series 2: orange */
    --c-open: #3b82f6;
    --c-in_progress: #f59e0b;
    --c-resolved: #10b981;
    --c-closed: #64748b;
    --p-low: #86b6ef;        /* priority = ordered, one blue ramp light -> dark */
    --p-medium: #2a78d6;
    --p-high: #104281;
    display: flex; flex-direction: column; gap: 18px;
}
.viz .muted { color: var(--ink-3); }
.viz .small { font-size: .82rem; }

/* ---------- date filter ---------- */
.pills { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 4px; gap: 2px; }
.pill { padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: .86rem; color: var(--ink-3); white-space: nowrap; }
.pill:hover { background: var(--bg); color: var(--ink); }
.pill.on { background: var(--primary); color: #fff; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: .82rem; color: var(--ink-3); font-weight: 600; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.15; color: var(--ink); }
.kpi-value small { font-size: 1rem; font-weight: 600; color: var(--ink-3); }
.kpi-sub { font-size: .8rem; color: var(--ink-3); }
.kpi-sub b.up, .kpi-sub b.down { color: var(--ink-2); }          /* more tickets is neither good nor bad */
.kpi-sub b.good { color: #006300; }
.kpi-sub b.bad, .kpi-sub b.warn { color: #b91c1c; }

/* ---------- layout ---------- */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: stretch; }
.grid-2.wide-left { grid-template-columns: 1.5fr 1fr; }
.viz .card { padding: 20px 22px; }
.viz .card-head { align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px; }
.legend { display: inline-flex; gap: 14px; font-size: .82rem; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--ink-3); flex-shrink: 0; }
.legend .key.s1, .legend .key.s2 { height: 3px; width: 16px; border-radius: 2px; }     /* line key for lines */
.key.s1 { background: var(--s1); } .key.s2 { background: var(--s2); }
.key.c-open, .seg.c-open { background: var(--c-open); } .key.c-in_progress, .seg.c-in_progress { background: var(--c-in_progress); }
.key.c-resolved, .seg.c-resolved { background: var(--c-resolved); } .key.c-closed, .seg.c-closed { background: var(--c-closed); }
.key.p-low, .seg.p-low { background: var(--p-low); } .key.p-medium, .seg.p-medium { background: var(--p-medium); } .key.p-high, .seg.p-high { background: var(--p-high); }

/* ---------- line chart ---------- */
.chart-wrap { width: 100%; }
.lc { width: 100%; height: auto; display: block; overflow: visible; }
.lc .grid { stroke: var(--grid); stroke-width: 1; }
.lc .axis { fill: var(--ink-3); font-size: 11px; }
.lc .line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lc .line.s1 { stroke: var(--s1); } .lc .line.s2 { stroke: var(--s2); }
.lc .area.s1 { fill: var(--s1); opacity: .10; }
.lc .dot { stroke: var(--surface); stroke-width: 2; }
.lc .dot.s1 { fill: var(--s1); } .lc .dot.s2 { fill: var(--s2); }
.lc .endlabel { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.lc .xhair { stroke: var(--ink-3); stroke-width: 1; opacity: 0; pointer-events: none; }
.lc .xhair.on { opacity: .6; }
.lc .hit { fill: transparent; cursor: crosshair; outline: none; }
.viz-table { margin-top: 10px; font-size: .86rem; }
.viz-table summary { cursor: pointer; color: var(--primary); font-weight: 600; width: fit-content; }
.viz-table .scroll { max-height: 220px; overflow: auto; margin-top: 8px; }

/* ---------- stacked bars (status, priority, workload) ---------- */
.stack { display: flex; gap: 2px; height: 24px; background: transparent; }
.stack.thin { height: 20px; }
.stack.empty { background: var(--bg); color: var(--ink-3); align-items: center; justify-content: center; font-size: .85rem; border-radius: 4px; }
.seg { min-width: 6px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .78rem; font-weight: 700; cursor: default; outline: none; transition: filter .12s; }
.seg:first-child { border-radius: 4px 0 0 4px; } .seg:last-child { border-radius: 0 4px 4px 0; } .seg:only-child { border-radius: 4px; }
.seg:hover, .seg:focus-visible, .hbar:hover, .hbar:focus-visible { filter: brightness(1.12) saturate(1.1); }
.seg.c-in_progress { color: #0b0b0b; }                    /* dark label on amber, white on the rest */
.seg.p-low { color: #0b0b0b; }

.key-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.key-list li { display: grid; grid-template-columns: 14px 1fr auto 44px; gap: 8px; align-items: center; font-size: .9rem; color: var(--ink-2); }
.key-list li b { color: var(--ink); } .key-list li small { text-align: right; }
.key-list.inline { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.key-list.inline li { display: inline-flex; gap: 6px; }

/* ---------- horizontal bars ---------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bars.slim { gap: 9px; }
.bar-row { display: grid; grid-template-columns: 112px 1fr 30px; gap: 12px; align-items: center; }
.bar-name { font-size: .88rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-total { font-size: .88rem; font-weight: 700; color: var(--ink); text-align: right; }
.bar-track { min-width: 0; }
.hbar { height: 14px; background: var(--s1); border-radius: 0 4px 4px 0; outline: none; transition: filter .12s; }
.star { color: #f59e0b; }

/* ---------- attention list ---------- */
.attention { border-left: 5px solid #ec835a; padding: 16px 22px; }
.att-list { display: flex; flex-direction: column; }
.att-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 14px; align-items: center; padding: 10px 6px; border-top: 1px solid var(--grid); color: var(--ink); border-radius: 8px; }
.att-row:first-child { border-top: 0; }
.att-row:hover { background: #f8fafc; }
.att-id { font-weight: 700; color: var(--primary); font-size: .82rem; }
.att-main { display: flex; flex-direction: column; min-width: 0; }
.att-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
/* status tags: colour + icon + words, never colour alone */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.tag i { font-style: normal; font-size: .8rem; }
.tag-critical { background: #fee2e2; color: #b91c1c; }
.tag-serious  { background: #ffedd5; color: #b45309; }
.tag-warning  { background: #fef3c7; color: #92400e; }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; }
.score td, .score th { white-space: nowrap; }
.score td { padding: 12px; vertical-align: middle; }
.who { display: flex; align-items: center; gap: 10px; }
.who .avatar { width: 34px; height: 34px; font-size: .85rem; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.mini-kpis div { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.mini-kpis b { font-size: 1.35rem; color: var(--ink); line-height: 1.2; }
.mini-kpis span { font-size: .76rem; color: var(--ink-3); font-weight: 600; }
.sub-h { margin: 18px 0 10px; font-size: .86rem; color: var(--ink-2); }

/* ---------- tooltip ---------- */
#vizTip { position: fixed; z-index: 50; pointer-events: none; background: #fff; color: var(--ink); border: 1px solid var(--grid);
    border-radius: 10px; padding: 8px 12px; box-shadow: 0 8px 24px rgba(15, 23, 42, .14); font-size: .85rem; min-width: 120px; }
#vizTip[hidden] { display: none; }
.tip-title { color: var(--ink-3); font-weight: 600; font-size: .78rem; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row i.key { width: 14px; height: 3px; border-radius: 2px; }             /* line key, not a box */
.tip-row b { font-size: 1rem; }
.tip-row span { color: var(--ink-2); }
#vizTip .key.c-open { background: var(--c-open); } #vizTip .key.c-in_progress { background: var(--c-in_progress); }
#vizTip .key.c-resolved { background: var(--c-resolved); } #vizTip .key.c-closed { background: var(--c-closed); }
#vizTip .key.p-low { background: var(--p-low); } #vizTip .key.p-medium { background: var(--p-medium); } #vizTip .key.p-high { background: var(--p-high); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .grid-2, .grid-2.wide-left { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi { padding: 12px 14px; } .kpi-value { font-size: 1.6rem; }
    .kpi:first-child { grid-column: 1 / -1; }
    .viz .card { padding: 16px; }
    .pills { width: 100%; justify-content: space-between; }
    .pill { padding: 7px 10px; font-size: .8rem; flex: 1; text-align: center; }
    .bar-row { grid-template-columns: 84px 1fr 26px; gap: 8px; }
    .att-row { grid-template-columns: 1fr; gap: 6px; }
    .att-tags { justify-content: flex-start; }
    .mini-kpis { grid-template-columns: repeat(2, 1fr); }
    .lc .axis { font-size: 12px; }
}

/* phone-sized chart is a separate, larger-text SVG */
.lc-m { display: none; }
.viz > section > *, .viz .card { min-width: 0; }
@media (max-width: 1000px) {
    .grid-2, .grid-2.wide-left { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
    .lc-d { display: none; }
    .lc-m { display: block; }
    .lc .axis { font-size: 11px; }
    .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bar-row { grid-template-columns: 92px minmax(0, 1fr) 26px; }
}
