/* ============================================================
   ARA — Analytic Research Application
   Dashboard
   ============================================================ */

:root {
  --navy-950: #060d1c;
  --navy-900: #0a1428;
  --navy-800: #0f1f3a;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --line: #e3eaf4;
  --line-strong: #d2ddec;
  --bg: #eef3fa;
  --card: #ffffff;
  --primary: #4059f6;
  --primary-dark: #2f43c9;
  --indigo: #6366f1;
  --cyan: #06b6d4;
  --sky: #0ea5e9;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --pink: #fe2062;
  --violet: #8b5cf6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px rgba(15, 23, 42, .05);
  --shadow-md: 0 18px 46px rgba(15, 23, 42, .12);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 262px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(900px 420px at 92% -8%, rgba(99, 102, 241, .10), transparent 60%),
    radial-gradient(700px 360px at 18% 0%, rgba(6, 182, 212, .08), transparent 55%),
    var(--bg);
  color: var(--ink-900);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
canvas { max-width: 100%; }
::selection { background: rgba(64, 89, 246, .18); }

.hidden { display: none !important; }

/* ------------------------------- sidebar ------------------------------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 26px 18px 18px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(620px 320px at 8% -6%, rgba(99, 102, 241, .30), transparent 60%),
    radial-gradient(520px 320px at 108% 108%, rgba(6, 182, 212, .22), transparent 58%),
    linear-gradient(172deg, var(--navy-950), #0a1a33 58%, #081426);
  color: #e8f1fb;
  z-index: 60;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 6px 24px; }
.brand-mark {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  color: #e6f9ff;
  background: linear-gradient(145deg, rgba(99, 102, 241, .55), rgba(6, 182, 212, .32));
  border: 1px solid rgba(148, 197, 255, .32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 10px 26px rgba(37, 99, 235, .25);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 19px; font-weight: 800; letter-spacing: .6px; }
.brand-text span { font-size: 9.5px; color: #8fb2d6; letter-spacing: .9px; text-transform: uppercase; margin-top: 4px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  font-size: 9.5px; letter-spacing: 1.5px; text-transform: uppercase;
  color: #6f93b8; padding: 16px 12px 7px;
  font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px;
  border-radius: 11px;
  color: #b9c9dd;
  font-size: 13px; font-weight: 600;
  transition: background .16s, color .16s, transform .16s;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.nav-item > span:not(.nav-tag) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-chev { width: 13px !important; height: 13px !important; flex: 0 0 13px !important; opacity: .55 !important; margin-left: auto; transform: rotate(90deg); }
.nav-parent.active .nav-chev { opacity: .85 !important; }

.subnav {
  display: flex; flex-direction: column; gap: 2px;
  margin: 2px 0 4px;
  padding-left: 16px;
}
.subnav-item {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px 7px 13px;
  border-radius: 9px;
  font-size: 12px; font-weight: 600;
  color: #9fb3cc;
  transition: background .15s, color .15s;
}
.subnav-item::before {
  content: "";
  width: 5px; height: 5px; flex: 0 0 5px;
  border-radius: 50%;
  background: #5d7797;
}
.subnav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.subnav-item.active { color: #fff; background: rgba(99, 102, 241, .18); }
.subnav-item.active::before { background: #67e8f9; box-shadow: 0 0 0 3px rgba(103, 232, 249, .12); }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, .42), rgba(6, 182, 212, .28));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 8px 20px rgba(37, 99, 235, .25);
}
.nav-tag {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 8.5px; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px;
  background: rgba(14, 165, 233, .18); color: #93d9ff;
  border: 1px solid rgba(14, 165, 233, .28);
}
.nav-tag-pink { background: rgba(254, 32, 98, .16); color: #ff9dbd; border-color: rgba(254, 32, 98, .3); }

.sidebar-live {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 6px 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.live-row { display: flex; align-items: flex-start; gap: 10px; }
.live-row .dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; margin-top: 5px;
  background: #22d3ee;
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .14);
}
.live-row .dot.dot-pink { background: #ff5a89; box-shadow: 0 0 0 4px rgba(255, 90, 137, .14); }
.live-row .dot.err { background: #ff5470; box-shadow: 0 0 0 4px rgba(255, 84, 112, .16); }
.live-row .dot.loading { background: #fbbf24; animation: pulse 1.4s ease-in-out infinite; }
.live-row div { display: flex; flex-direction: column; line-height: 1.35; }
.live-row span { font-size: 11.5px; font-weight: 600; color: #d7e5f5; }
.live-row small { font-size: 10.5px; color: #7f9ec0; }

@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

.sidebar-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 6px 2px;
  font-size: 10.5px; color: #6f8aab;
}

/* -------------------------------- main -------------------------------- */
.main {
  margin-left: var(--sidebar);
  padding: 30px 34px 46px;
  max-width: 1680px;
}

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 22px;
  margin-bottom: 24px;
}
.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}
.topbar h1 { font-size: 27px; font-weight: 800; letter-spacing: -.6px; }
.topbar .sub { color: var(--ink-500); font-size: 13px; margin-top: 6px; max-width: 620px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; padding-top: 6px; }
.chip-live {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; color: var(--ink-700);
  box-shadow: var(--shadow-sm);
}
.chip-live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, .16);
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-700);
  padding: 9px 15px; border-radius: 11px;
  font-size: 12.5px; font-weight: 600;
  transition: .16s;
  box-shadow: var(--shadow-sm);
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: #b9c8dd; color: var(--ink-900); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .6; pointer-events: none; }
.btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
  font-size: 12.5px;
}

/* ------------------------------ module hero ------------------------------ */
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.module-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 20px 22px 16px;
  color: #eaf3ff;
  border: 1px solid rgba(255, 255, 255, .10);
  box-shadow: 0 20px 46px rgba(15, 23, 42, .18);
  transition: transform .2s ease, box-shadow .2s ease;
  isolation: isolate;
}
.module-card::after {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 360px; height: 360px;
  border-radius: 50%;
  filter: blur(10px);
  opacity: .55;
  z-index: -1;
}
.module-card:hover { transform: translateY(-3px); box-shadow: 0 26px 56px rgba(15, 23, 42, .24); }

.module-bpom {
  background:
    radial-gradient(520px 300px at 88% -20%, rgba(14, 165, 233, .38), transparent 60%),
    linear-gradient(150deg, #0a1c36, #0b2a4d 62%, #0a2442);
}
.module-bpom::after { background: radial-gradient(circle, rgba(6, 182, 212, .45), transparent 68%); }

.module-revenue {
  background:
    radial-gradient(520px 300px at 90% -20%, rgba(254, 32, 98, .36), transparent 60%),
    linear-gradient(150deg, #1c1026, #2c1230 60%, #23102a);
}
.module-revenue::after { background: radial-gradient(circle, rgba(254, 32, 98, .42), transparent 68%); }

.module-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.module-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase;
  color: rgba(255, 255, 255, .82);
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
}
.module-badge svg { width: 14px; height: 14px; }
.module-open { font-size: 11.5px; font-weight: 600; color: rgba(255, 255, 255, .62); transition: color .16s; }
.module-card:hover .module-open { color: #fff; }

.module-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.module-label { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: rgba(255, 255, 255, .55); font-weight: 600; display: block; margin-bottom: 5px; }
.module-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; display: block; }
.module-foot { font-size: 11.5px; color: rgba(255, 255, 255, .55); display: block; margin-top: 4px; }

.module-split { display: flex; flex-direction: column; gap: 7px; min-width: 170px; }
.split-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; color: rgba(255, 255, 255, .72); }
.split-row span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.split-dot { width: 7px; height: 7px; border-radius: 2px; display: inline-block; }
.split-row strong { font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }

.module-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .10);
  font-size: 11px; color: rgba(255, 255, 255, .55);
}
.module-meta .trend { font-weight: 700; color: #7ef0c0; }
.module-meta .trend.neg { color: #ff9db5; }

/* --------------------------------- KPI --------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 17px 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--sky), var(--cyan));
}
.kpi.kpi-pink::before { background: linear-gradient(180deg, var(--pink), #ff8fb1); }
.kpi-label { font-size: 10.5px; letter-spacing: .7px; text-transform: uppercase; color: var(--ink-500); font-weight: 700; display: block; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.7px; display: block; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 11px; color: var(--ink-400); display: block; margin-top: 3px; }
.kpi-foot.neg { color: var(--rose); }
.kpi-foot.pos { color: var(--emerald); }

/* -------------------------------- cards -------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  margin-bottom: 16px;
}
.card-head h3 { font-size: 15px; font-weight: 800; letter-spacing: -.2px; }
.card-sub { font-size: 11.5px; color: var(--ink-500); margin-top: 3px; }
.link-more { font-size: 11.5px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.link-more:hover { color: var(--primary-dark); }

.chart-wrap { position: relative; height: 286px; }
.chart-card .chart-wrap { height: 300px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ink-500); font-weight: 600; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.pill-soft {
  padding: 5px 11px; border-radius: 999px;
  background: #fef1f5; color: #b3124a;
  border: 1px solid #fbd0de;
  font-size: 10.5px; font-weight: 700; white-space: nowrap;
}

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: #f1f5fb; border: 1px solid var(--line);
  border-radius: 10px;
}
.segmented button {
  border: 0; background: transparent; color: var(--ink-500);
  padding: 5px 10px; border-radius: 8px;
  font-size: 10.5px; font-weight: 700;
  transition: .15s;
}
.segmented button:hover { color: var(--ink-900); }
.segmented button.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }

/* -------------------------------- donut -------------------------------- */
.donut-row { display: flex; align-items: center; gap: 26px; }
.donut-wrap { position: relative; width: 190px; height: 190px; flex: 0 0 190px; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center; padding: 0 26px;
}
.donut-center strong { font-size: 17px; font-weight: 800; letter-spacing: -.4px; line-height: 1.2; }
.donut-center span { font-size: 9.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-400); font-weight: 700; margin-top: 3px; }

.legend-list { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 11px; }
.legend-list li { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; align-items: center; }
.legend-list .lbl { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-700); }
.legend-list .lbl i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.legend-list .val { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.legend-list .bar { grid-column: 1 / -1; height: 5px; border-radius: 999px; background: #eef2f8; overflow: hidden; }
.legend-list .bar > span { display: block; height: 100%; border-radius: 999px; }

/* ------------------------------ rank list ------------------------------ */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.rank-list li:last-child { border-bottom: 0; padding-bottom: 2px; }
.rank-list li:first-child { padding-top: 2px; }
.rank-no {
  width: 24px; height: 24px; flex: 0 0 24px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 10.5px; font-weight: 800;
  background: #eef2fa; color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}
.rank-list li:nth-child(1) .rank-no { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.rank-list li:nth-child(2) .rank-no { background: #eef2f7; color: #475569; }
.rank-list li:nth-child(3) .rank-no { background: #ffedd5; color: #9a3412; }
.rank-main { flex: 1; min-width: 0; }
.rank-name { font-size: 12.5px; font-weight: 700; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.rank-sub { font-size: 10.5px; color: var(--ink-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; margin-top: 1px; }
.rank-val { font-size: 12.5px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-val small { display: block; font-size: 9.5px; font-weight: 600; color: var(--ink-400); margin-top: 1px; }

.foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 4px 0;
  margin-top: 6px;
  border-top: 1px solid var(--line-strong);
  font-size: 11px; color: var(--ink-400);
}

/* ------------------------------ skeleton ------------------------------ */
.loading .module-value,
.loading .kpi-value { color: transparent; border-radius: 8px; background: linear-gradient(90deg, #eef2f8 25%, #f7f9fc 50%, #eef2f8 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------ responsive ------------------------------ */
@media (max-width: 1400px) {
  .main { padding: 26px 26px 40px; }
  .module-value { font-size: 28px; }
  .module-split { min-width: 145px; }
}
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-split { display: none; }
}
@media (max-width: 1024px) {
  :root { --sidebar: 232px; }
  .main { padding: 22px 20px 34px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .topbar { flex-direction: column; }
}
@media (max-width: 820px) {
  .sidebar { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; }
  .brand { padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .nav-label, .sidebar-live, .sidebar-foot { display: none; }
  .nav-item { padding: 8px 11px; }
  .nav-tag { display: none; }
  .subnav { display: none; }
  .main { margin-left: 0; }
  .module-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .donut-row { flex-direction: column; align-items: stretch; }
  .donut-wrap { align-self: center; }
  .topbar h1 { font-size: 22px; }
  .foot { flex-direction: column; align-items: flex-start; }
}
