/* ABP Individual Performance Tracker */
:root {
  --abp-red: #c8102e;
  --abp-red-dark: #9e0b23;
  --charcoal: #2b2b2b;
  --charcoal-2: #3a3a3a;
  --kpi-bg: #e8f5e9;
  --kpi-border: #c8e6c9;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --page: #f4f5f7;
  --heat-views: 30, 102, 208;      /* blue */
  --heat-au: 240, 140, 0;          /* orange */
  --heat-sessions: 123, 63, 191;   /* purple */
  --heat-eng: 154, 205, 50;        /* green-yellow */
  --font: "Noto Sans", "Noto Sans Devanagari", "Noto Sans Bengali", "Noto Sans Gujarati", "Noto Sans Gurmukhi",
          "Noto Sans Tamil", "Noto Sans Telugu", "Noto Sans Kannada", system-ui, -apple-system, "Segoe UI", sans-serif;
}
html, body { background: var(--page); color: var(--ink); font-family: var(--font); font-size: 14px; }
a { color: var(--abp-red-dark); }

/* Header */
.abp-header { background: var(--abp-red); color: #fff; display: flex; align-items: center; gap: 1.25rem; padding: .55rem 1.25rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 1030; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.abp-header__brand { display: flex; align-items: center; gap: .7rem; }
.abp-logo { display: inline-grid; place-items: center; background: #fff; color: var(--abp-red); font-weight: 800; font-size: 1.05rem; letter-spacing: -.5px; width: 46px; height: 32px; border-radius: 4px; text-transform: lowercase; }
.abp-header__title { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.abp-header__sub { font-size: .75rem; opacity: .85; }
.abp-nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.abp-nav a { color: #fff; text-decoration: none; padding: .35rem .65rem; border-radius: 4px; font-size: .85rem; opacity: .88; white-space: nowrap; }
.abp-nav a:hover { background: rgba(255,255,255,.12); opacity: 1; }
.abp-nav a.active { background: #fff; color: var(--abp-red); opacity: 1; font-weight: 600; }
.abp-header__meta { display: flex; align-items: center; gap: .75rem; font-size: .8rem; flex-wrap: wrap; }
.sync-pill { padding: .2rem .55rem; border-radius: 999px; font-weight: 600; font-size: .75rem; background: rgba(255,255,255,.2); }
.sync-pill.is-ok::before { content: "●"; color: #7CFC9A; margin-right: .3rem; }
.sync-pill.is-stale { background: #ffcc00; color: #3b2f00; }
.sync-pill.is-running { background: #e3f2fd; color: #0d47a1; }
.btn-header { color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn-header:hover { background: rgba(255,255,255,.15); color: #fff; }

/* Filter bar */
.filter-bar { background: var(--charcoal); color: #eee; display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem 1rem; padding: .65rem 1.25rem; position: sticky; top: 52px; z-index: 1020; }
.filter-bar label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #bbb; margin-bottom: .15rem; }
.fb-group { min-width: 140px; }
.fb-dates { display: flex; align-items: center; gap: .3rem; }
.fb-dates input { width: 140px; }
.fb-wide { min-width: 200px; max-width: 320px; flex: 1; }
.fb-search { flex: 1; min-width: 200px; }
.fb-views { min-width: 250px; }
.view-range-buttons { display: flex; flex-wrap: wrap; gap: .2rem; }
.view-range-buttons .btn { padding: .2rem .4rem; font-size: .72rem; white-space: nowrap; }
.view-range-buttons .btn-check:checked + .btn { background: var(--abp-red); border-color: var(--abp-red); color: #fff; }
.filter-step-hint { flex-basis: 100%; margin-top: -.35rem; color: #ffe082; font-size: .72rem; }
.filter-step-hint.is-ready { color: #b9e6c9; }
.filter-step2.filter-step-locked { opacity: .48; }
.language-picker-panel { padding-bottom: .75rem; }
.language-buttons { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: .5rem; }
.language-button { min-height: 42px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--charcoal); font-weight: 600; transition: background .15s, color .15s, border-color .15s; }
.language-button:hover, .language-button.active { border-color: var(--abp-red); background: var(--abp-red); color: #fff; }
.language-button:focus-visible { outline: 3px solid rgba(200,16,46,.35); outline-offset: 2px; }
.fb-actions { display: flex; gap: .4rem; margin-left: auto; }
.btn-fb { background: var(--charcoal-2); color: #fff; border: 1px solid #555; }
.btn-fb:hover { background: #4a4a4a; color: #fff; }
.btn-export { background: var(--abp-red); color: #fff; border: 0; }
.btn-export:hover { background: var(--abp-red-dark); color: #fff; }
.export-menu { width: 260px; }
.adv-filters { flex-basis: 100%; }
.adv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem 1rem; padding-top: .4rem; border-top: 1px solid #444; }
.filter-bar .form-control, .filter-bar .form-select { background-color: #fff; }
.basis-note { font-size: .75rem; color: var(--muted); padding: .35rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line); }
.stale-banner { background: #fff4e5; color: #8a4b00; border-bottom: 1px solid #ffd8a8; padding: .45rem 1.25rem; font-size: .85rem; }

/* Select2 in dark bar */
.filter-bar .select2-container--bootstrap-5 .select2-selection { min-height: 31px; font-size: .85rem; }
.select2-container--bootstrap-5 .select2-dropdown { z-index: 1060; }

/* Layout */
.abp-main { padding: 1rem 1.25rem 3rem; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .85rem 1rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; flex-wrap: wrap; }
.panel__head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.hint { font-size: .75rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 { margin-bottom: 1rem; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.kpi { background: var(--kpi-bg); border: 1px solid var(--kpi-border); border-radius: 8px; padding: .65rem .8rem; cursor: help; min-height: 86px; }
.kpi__label { font-size: .72rem; color: #2e5e31; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.kpi__value { font-size: 1.45rem; font-weight: 700; color: #123d16; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi__value.na { color: #8a9a8b; font-size: 1.1rem; }
.kpi__delta { font-size: .72rem; color: var(--muted); }
.kpi__delta .up { color: #137333; } .kpi__delta .down { color: #b3261e; }

/* Tables */
.table-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.table-wrap.audit { max-height: 360px; }
.table-wrap table { margin: 0; }
.table-wrap thead th { position: sticky; top: 0; z-index: 2; background: var(--charcoal) !important; color: #fff !important; font-weight: 600; font-size: .75rem; white-space: nowrap; border-bottom: 0; }
table.dataTable thead > tr > th.dt-orderable-asc span.dt-column-order:before, table.dataTable thead > tr > th.dt-orderable-desc span.dt-column-order:after { opacity: .5; }
.heat-table td, .group-table td { font-size: .8rem; vertical-align: top; }
.num, td.num, th.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.heat-table td.title { min-width: 280px; max-width: 460px; white-space: normal; word-break: normal; overflow-wrap: anywhere; line-height: 1.45; }
.heat-table td.url { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; }
.heat-table td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 100px; max-width: 180px; }
.heat-table td.heat { transition: background .2s; }
.na-cell { color: #9ca3af; font-style: italic; }
.group-table tbody tr { cursor: pointer; }
.group-table tbody tr.selected { outline: 2px solid var(--abp-red); outline-offset: -2px; }
.dt-container .dt-info, .dt-container .dt-paging, .dt-container .dt-length { font-size: .8rem; padding: .4rem; }
div.dt-processing { z-index: 5; }

.legend { display: flex; gap: .5rem; font-size: .72rem; }
.legend .lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .25rem; vertical-align: -1px; }
.legend .views::before { background: rgb(var(--heat-views)); }
.legend .au::before { background: rgb(var(--heat-au)); }
.legend .sessions::before { background: rgb(var(--heat-sessions)); }
.legend .eng::before { background: rgb(var(--heat-eng)); }

/* Rank lists */
.rank-list { display: grid; gap: .3rem; }
.rank-row { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) 7rem 4.5rem; align-items: center; gap: .5rem; font-size: .82rem; }
.rank-row .n { color: var(--muted); text-align: right; }
.rank-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .bar { height: 8px; background: #eef2ff; border-radius: 4px; overflow: hidden; }
.rank-row .bar > i { display: block; height: 100%; background: rgb(var(--heat-views)); }
.rank-row .v { text-align: right; font-variant-numeric: tabular-nums; }
.rank-row a { color: inherit; text-decoration: none; }
.rank-row a:hover { color: var(--abp-red); text-decoration: underline; }

/* Tracker */
.tracker { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1rem; align-items: start; }
.tracker__side { position: sticky; top: 130px; max-height: calc(100vh - 150px); display: flex; flex-direction: column; }
.user-list { overflow: auto; flex: 1; border-top: 1px solid var(--line); }
.user-row { display: flex; align-items: center; gap: .5rem; padding: .4rem .3rem; border-bottom: 1px solid #f1f1f1; cursor: pointer; font-size: .82rem; }
.user-row:hover { background: #fafafa; }
.user-row.active { background: #fdecef; }
.user-row .uname { flex: 1; overflow-wrap: anywhere; }
.user-row .uv { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .75rem; }
.user-row input { accent-color: var(--abp-red); }

.cat-tabs .nav-link { color: var(--ink); }
.cat-tabs .nav-link.active { background: var(--charcoal); }

/* States */
.empty-state { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: .9rem; }
.empty-state.big { padding: 4rem 1rem; }
.empty-state.big i { font-size: 3rem; color: var(--abp-red); }
.is-loading { position: relative; }
.is-loading::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 50 50'%3E%3Ccircle cx='25' cy='25' r='20' fill='none' stroke='%23c8102e' stroke-width='5' stroke-dasharray='90 60'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center/32px no-repeat; border-radius: inherit; z-index: 3; }

/* Admin */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .82rem; margin-bottom: .75rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.file-browser { max-height: 260px; overflow: auto; font-size: .82rem; }
.file-browser .file { display: flex; gap: .5rem; align-items: center; padding: .3rem .2rem; border-bottom: 1px solid #f1f1f1; }
.file-browser .file .meta { color: var(--muted); font-size: .72rem; }
.file-browser .file .order { margin-left: auto; display: flex; gap: .2rem; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--abp-red) 0%, var(--abp-red-dark) 45%, var(--charcoal) 45.1%); font-family: var(--font); }
.login-card { background: #fff; border-radius: 10px; padding: 2rem; width: min(380px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.login-brand .abp-logo { background: var(--abp-red); color: #fff; }

@media (max-width: 900px) {
  .language-buttons { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tracker { grid-template-columns: 1fr; }
  .tracker__side { position: static; max-height: 360px; }
  .filter-bar { position: static; }
  .abp-header { position: static; }
  .grid-2 { grid-template-columns: 1fr; }
  .fb-actions { margin-left: 0; }
}
@media (max-width: 480px) {
  .language-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
