/* ═══════════════════════════════════════════════════════════
   J&T Express — Complaint Dashboard
   ═══════════════════════════════════════════════════════════ */

:root {
  --red: #ed1c24;
  --red-2: #c8102e;
  --red-soft: #fdecec;
  --ink: #14161b;
  --ink-2: #2b303b;
  --muted: #6c7686;
  --bg: #f3f4f7;
  --bg-2: #e9ebf0;
  --card: #ffffff;
  --line: #e6e8ee;
  --line-2: #f0f1f5;
  --green: #16a34a;
  --green-soft: #e7f7ee;
  --amber: #f59e0b;
  --amber-soft: #fff5e5;
  --blue: #0ea5e9;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 28px -22px rgba(16, 24, 40, 0.5);
  --shadow-lg: 0 30px 60px -30px rgba(16, 24, 40, 0.45);
  --r: 18px;
  --r-sm: 12px;
  --ff: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --ff-num: "Barlow Condensed", "Plus Jakarta Sans", Arial, sans-serif;
}

html[data-theme="dark"] {
  --ink: #eef0f4;
  --ink-2: #cfd4dd;
  --muted: #98a1b0;
  --bg: #0a0b0e;
  --bg-2: #101216;
  --card: #14161c;
  --line: #23262f;
  --line-2: #1c1f26;
  --red-soft: #33151a;
  --green-soft: #12281c;
  --amber-soft: #2b2211;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 20px 40px -28px rgba(0, 0, 0, 0.9);
  --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, 0.95);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--ff);
  background:
    radial-gradient(900px 420px at 8% -8%, rgba(237, 28, 36, 0.10), transparent 62%),
    radial-gradient(760px 380px at 100% 0%, rgba(14, 165, 233, 0.07), transparent 58%),
    var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.025em; }
p { margin: 0; }
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

.app { max-width: 1440px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 14px; }

/* ══════════════ HEADER ══════════════ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow); flex-wrap: wrap;
}
.topbar::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  border-radius: var(--r) var(--r) 0 0;
  background: linear-gradient(90deg, var(--red), #ff5a44 40%, #ffb020 72%, var(--red-2));
  background-size: 220% 100%;
  animation: slideGradient 9s linear infinite;
}
@keyframes slideGradient { to { background-position: 220% 0; } }

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-logo { display: flex; align-items: center; height: 42px; flex: none; }
.brand-logo img { height: 100%; width: auto; display: block; }
.brand-logo .lg-white { display: none; }
html[data-theme="dark"] .brand-logo .lg-red { display: none; }
html[data-theme="dark"] .brand-logo .lg-white { display: block; }
.brand-logo:hover { opacity: 0.88; }
.logo {
  width: 52px; height: 46px; border-radius: 13px; flex: none; position: relative;
  background: linear-gradient(150deg, var(--red), var(--red-2));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 10px 22px -12px rgba(237, 28, 36, 0.95);
}
.logo-jt { font-family: var(--ff-num); font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.logo-bar { position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%); width: 22px; height: 2.5px; background: rgba(255,255,255,.85); border-radius: 2px; }
.brand-text h1 { font-size: 20px; line-height: 1.15; }
.brand-text p { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); margin-top: 3px; flex-wrap: wrap; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55); animation: pulse 2.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }
.sep { opacity: 0.5; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clock {
  font-family: var(--ff-num); font-size: 19px; font-weight: 700; letter-spacing: 0.5px;
  padding: 6px 12px; border-radius: 10px; background: var(--bg-2); color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 11px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink-2); cursor: pointer; transition: 0.16s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--red); color: var(--red); transform: translateY(-1px); }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: 0.16s; position: relative; overflow: hidden;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: #cfd4dd; background: var(--bg-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-2));
  box-shadow: 0 12px 22px -14px rgba(237, 28, 36, 1);
}
.btn-primary:hover { background: linear-gradient(135deg, #ff3b41, var(--red)); border-color: transparent; }
.btn-ghost-danger { color: var(--red); border-color: rgba(237, 28, 36, 0.35); background: transparent; }
.btn-ghost-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: 9px; }

/* ══════════════ FILTER BAR ══════════════ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }

.filterbar { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 14px; flex-wrap: wrap; }
.tabs button {
  flex: 1 1 auto; min-width: 140px; padding: 10px 14px; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s;
}
.tabs button .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.tabs button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.55); }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 6px 14px -10px rgba(16, 24, 40, 0.6); }
.tabs button.active .dot { background: var(--red); opacity: 1; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 8px 13px; border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px; transition: 0.16s;
}
.chip:hover { border-color: var(--red); color: var(--red); transform: translateY(-1px); }
.chip.active { background: linear-gradient(135deg, var(--red), var(--red-2)); border-color: transparent; color: #fff; box-shadow: 0 10px 18px -14px rgba(237, 28, 36, 1); }
.chip .chip-val { font-family: var(--ff-num); font-size: 14px; opacity: 0.85; }

.filter-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 9px; flex: 1 1 260px; max-width: 420px;
  height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--muted); transition: 0.16s;
}
.search svg { width: 17px; height: 17px; flex: none; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font: inherit; font-size: 13.5px; color: var(--ink); min-width: 0; }
.search kbd {
  font-family: var(--ff); font-size: 10.5px; padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.search:focus-within { border-color: var(--red); background: var(--card); box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.10); }
.toggle {
  height: 40px; padding: 0 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); font-size: 12.5px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: 0.16s;
}
.toggle:hover { border-color: var(--red); }
.toggle[aria-pressed="true"] { background: var(--red-soft); border-color: rgba(237, 28, 36, 0.5); color: var(--red); }
.dot-red { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

/* ══════════════ KPI ══════════════ */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  position: relative; overflow: hidden; padding: 16px 16px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 92px; height: 92px; border-radius: 50%;
  background: var(--tint, rgba(237, 28, 36, 0.07));
}
.kpi-top { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.kpi-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--tint, var(--red-soft)); color: var(--tone, var(--red)); }
.kpi-ic svg { width: 14px; height: 14px; }
.kpi-value { font-family: var(--ff-num); font-size: 38px; line-height: 1; font-weight: 800; margin: 10px 0 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-family: var(--ff); font-size: 15px; font-weight: 700; opacity: 0.55; margin-left: 2px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.spark { position: absolute; right: 14px; bottom: 12px; display: flex; align-items: flex-end; gap: 2.5px; height: 26px; opacity: 0.85; }
.spark i { width: 4px; border-radius: 2px; background: var(--tone, var(--red)); opacity: 0.35; }
.spark i:last-child { opacity: 0.95; }

/* ══════════════ GRID MAIN ══════════════ */
.grid-main { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); gap: 14px; align-items: start; }
.col-side { display: flex; flex-direction: column; gap: 14px; }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-head.compact { padding: 14px 16px; align-items: center; }
.card-head h2 { font-size: 15px; }
.head-text p { font-size: 12px; color: var(--muted); margin-top: 3px; }

.seg { display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--muted); transition: 0.16s; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 4px 10px -8px rgba(16, 24, 40, 0.8); }
.seg.small button { padding: 6px 10px; font-size: 11.5px; }

/* chart */
.chart-scroll { position: relative; }
.chart-axis, .chart-row {
  display: grid;
  grid-template-columns: 34px minmax(110px, 210px) minmax(80px, 1fr) 74px 62px;
  gap: 10px; align-items: center; padding: 0 18px;
}
.chart-axis {
  position: sticky; top: 0; z-index: 2; background: var(--card);
  padding-top: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.chart-axis .ticks { display: flex; justify-content: space-between; font-style: normal; font-size: 9.5px; letter-spacing: 0; text-transform: none; opacity: 0.8; }
.chart-axis .ticks i { font-style: normal; }
.chart-axis .right { text-align: right; }
.chart-rows { max-height: 560px; overflow-y: auto; padding: 6px 0 10px; }
.chart-rows::-webkit-scrollbar, .heat-wrap::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.chart-rows::-webkit-scrollbar-thumb, .heat-wrap::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb {
  background: var(--bg-2); border-radius: 8px; border: 2px solid var(--card);
}
.chart-row {
  width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer;
  padding-top: 5px; padding-bottom: 5px; border-radius: 10px; color: inherit; transition: background 0.14s;
  animation: rowIn 0.35s backwards;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } }
.chart-row:hover { background: var(--bg-2); }
.chart-row:hover .rname { color: var(--red); }
.rnk { font-family: var(--ff-num); font-size: 15px; font-weight: 700; color: var(--muted); text-align: center; }
.rnk.medal-1 { color: #d4a017; }
.rnk.medal-2 { color: #8d99ae; }
.rnk.medal-3 { color: #b5651d; }
.rname { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color 0.14s; }
.rtrack {
  position: relative; height: 24px; border-radius: 7px; background: var(--bg-2); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.05);
}
.rtrack .grid-lines { position: absolute; inset: 0; background-image: linear-gradient(to right, transparent calc(25% - 1px), var(--line) 25%, transparent calc(25% + 1px), transparent calc(50% - 1px), var(--line) 50%, transparent calc(50% + 1px), transparent calc(75% - 1px), var(--line) 75%, transparent calc(75% + 1px)); opacity: 0.75; }
.rfill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 7px;
  transition: width 0.75s cubic-bezier(0.22, 1, 0.36, 1);
  background: linear-gradient(90deg, var(--c1), var(--c2));
  box-shadow: 0 0 14px -4px var(--c2);
}
.rtrack .target-tick {
  position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: 0.45;
  border-radius: 2px; z-index: 2;
}
.rval { font-family: var(--ff-num); font-size: 16px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.rdelta { font-size: 11px; font-weight: 700; text-align: right; padding: 3px 7px; border-radius: 7px; white-space: nowrap; }
.rdelta.up { color: var(--green); background: var(--green-soft); }
.rdelta.down { color: var(--red); background: var(--red-soft); }
.rdelta.flat { color: var(--muted); background: var(--bg-2); }
.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 13px; }

/* rank list */
.rank-list { list-style: none; margin: 0; padding: 6px 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.rank-item { display: grid; grid-template-columns: 26px 1fr auto; gap: 9px; align-items: center; padding: 8px 8px; border-radius: 9px; cursor: pointer; transition: 0.14s; border: 0; background: transparent; text-align: left; width: 100%; color: inherit; }
.rank-item:hover { background: var(--bg-2); }
.rank-item:hover .rl-name { color: var(--red); }
.rl-no { font-family: var(--ff-num); font-size: 14px; font-weight: 700; color: var(--muted); text-align: center; }
.rl-name { font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-bar { height: 3px; border-radius: 3px; background: var(--bg-2); margin-top: 4px; overflow: hidden; }
.rl-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--c1), var(--c2)); transition: width 0.6s ease; }
.rl-val { font-family: var(--ff-num); font-size: 15px; font-weight: 700; }

/* distribution */
.dist { padding: 14px 16px 18px; display: flex; align-items: flex-end; gap: 8px; height: 132px; }
.dist-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; cursor: pointer; }
.dist-bar { width: 100%; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--c1), var(--c2)); min-height: 3px; transition: height 0.6s cubic-bezier(0.22, 1, 0.36, 1), filter 0.15s; }
.dist-col:hover .dist-bar { filter: brightness(1.1); }
.dist-lbl { font-size: 9.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.dist-cnt { font-family: var(--ff-num); font-size: 13px; font-weight: 700; }
.dist-col.on .dist-lbl { color: var(--red); }

/* ══════════════ HEATMAP ══════════════ */
.legend { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--muted); flex-wrap: wrap; }
.lg { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }
.lg-bad { background: rgba(237, 28, 36, 0.32); }
.lg-mid { background: rgba(245, 158, 11, 0.4); }
.lg-good { background: rgba(22, 163, 74, 0.4); }
.lg-target { background: var(--green); }
.heat-wrap { overflow: auto; max-height: 460px; }
.heat { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 11px; }
.heat th {
  position: sticky; top: 0; z-index: 3; background: var(--card); padding: 0;
  border-bottom: 1px solid var(--line); font-weight: 700; color: var(--muted);
}
.heat thead th { padding: 8px 4px; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.15; vertical-align: bottom; }
.heat thead th.g-fr { color: var(--red); }
.heat thead th.g-ff { color: #b45309; }
.heat thead th.g-qa { color: #0284c7; }
.heat th.name, .heat td.name {
  position: sticky; left: 0; z-index: 2; background: var(--card); text-align: left;
  padding: 6px 12px; font-size: 11.5px; font-weight: 650; white-space: nowrap;
  border-right: 1px solid var(--line); min-width: 168px; max-width: 240px; overflow: hidden; text-overflow: ellipsis;
}
.heat thead th.name { z-index: 4; }
.heat td.cell { padding: 0; text-align: center; border-bottom: 1px solid var(--line-2); }
.heat td.cell button {
  width: 100%; min-width: 62px; border: 0; background: transparent; cursor: pointer;
  padding: 7px 4px; font-family: var(--ff-num); font-size: 14px; font-weight: 700; color: var(--ink);
  transition: 0.12s; display: block;
}
.heat td.cell button:hover { outline: 2px solid var(--red); outline-offset: -2px; transform: scale(1.02); }
.heat tr:hover td.name { color: var(--red); }
.heat .v0 { background: rgba(237, 28, 36, 0.34); }
.heat .v1 { background: rgba(237, 28, 36, 0.22); }
.heat .v2 { background: rgba(245, 158, 11, 0.30); }
.heat .v3 { background: rgba(22, 163, 74, 0.18); }
.heat .v4 { background: rgba(22, 163, 74, 0.34); }
.heat .vnull { color: var(--muted); opacity: 0.6; }
html[data-theme="dark"] .heat .v0 { background: rgba(237, 28, 36, 0.45); }
html[data-theme="dark"] .heat .v4 { background: rgba(22, 163, 74, 0.4); }

/* ══════════════ TABLE ══════════════ */
.table-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.check-all { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.table-wrap { overflow: auto; max-height: 620px; }
.data-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 3; background: var(--card);
  padding: 10px 8px; border-bottom: 1px solid var(--line);
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); white-space: nowrap; text-align: center; cursor: pointer; user-select: none;
}
.data-table thead th.dp-col { text-align: left; padding-left: 14px; }
.data-table thead th:hover { color: var(--ink); }
.data-table thead th.sorted { color: var(--red); }
.data-table thead th .arrow { font-size: 8px; margin-left: 2px; }
.data-table tbody td { padding: 7px 8px; border-bottom: 1px solid var(--line-2); text-align: center; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover td { background: var(--bg-2); }
.data-table td.dp-col {
  position: sticky; left: 0; z-index: 2; background: var(--card); text-align: left;
  padding-left: 14px; font-weight: 700; font-size: 12px; white-space: nowrap; max-width: 250px; overflow: hidden; text-overflow: ellipsis;
}
.data-table tbody tr:hover td.dp-col { background: var(--bg-2); }
.data-table td.chk, .data-table th.chk { width: 34px; padding-left: 12px; }
.data-table td.num-cell { cursor: text; font-family: var(--ff-num); font-size: 14px; font-weight: 700; }
.data-table td.num-cell:hover { background: var(--red-soft); box-shadow: inset 0 0 0 1px rgba(237, 28, 36, 0.35); }
.data-table td.num-cell.low { color: var(--red); }
.data-table td.num-cell.mid { color: #b45309; }
.data-table td.num-cell.null { color: var(--muted); font-weight: 500; }
.data-table td.act { white-space: nowrap; }
.mini {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 7px; width: 27px; height: 27px; cursor: pointer; font-size: 11px;
  display: inline-grid; place-items: center; transition: 0.14s;
}
.mini:hover { border-color: var(--red); color: var(--red); transform: translateY(-1px); }
.mini.danger:hover { background: var(--red-soft); }
.cell-input {
  width: 66px; padding: 4px 6px; border-radius: 6px; border: 1.5px solid var(--red);
  background: var(--card); color: var(--ink); font-family: var(--ff-num); font-size: 14px; font-weight: 700; text-align: center; outline: none;
}
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.pager-btns { display: flex; gap: 4px; }
.pager-btns button {
  min-width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); cursor: pointer; font-size: 12px; font-weight: 600;
}
.pager-btns button:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.pager-btns button.active { background: linear-gradient(135deg, var(--red), var(--red-2)); border-color: transparent; color: #fff; }
.pager-btns button:disabled { opacity: 0.4; cursor: default; }

.foot { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 11px; color: var(--muted); padding: 8px 0 0; flex-wrap: wrap; }
.dotsep { opacity: 0.5; }

/* ══════════════ DRAWER ══════════════ */
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, 0.45); backdrop-filter: blur(2px); z-index: 60; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(480px, 100vw); z-index: 61;
  background: var(--card); border-left: 1px solid var(--line);
  transform: translateX(102%); transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex; flex-direction: column; box-shadow: -30px 0 60px -40px rgba(0, 0, 0, 0.6);
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--line-2); position: relative; }
.drawer-head::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--red), #ffb020); }
.drawer-close { position: absolute; top: 16px; right: 16px; }
.drawer-title { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; padding-right: 44px; }
.drawer-meta { font-size: 11.5px; color: var(--muted); margin-top: 5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); }
.badge.good { background: var(--green-soft); color: var(--green); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.gauge { text-align: center; }
.gauge svg { width: 100%; max-width: 92px; transform: rotate(-90deg); }
.gauge .g-track { fill: none; stroke: var(--bg-2); stroke-width: 8; }
.gauge .g-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
.gauge-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin-top: 2px; }
.gauge-val { font-family: var(--ff-num); font-size: 15px; font-weight: 700; margin-top: -2px; }

.sec-title { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 16px 0 8px; display: flex; align-items: center; gap: 7px; }
.sec-title::after { content: ""; height: 1px; flex: 1; background: var(--line-2); }
.mrow { display: grid; grid-template-columns: 1fr 78px; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px dashed var(--line-2); }
.mrow label { font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.mrow .mbar { height: 4px; border-radius: 4px; background: var(--bg-2); margin-top: 5px; overflow: hidden; position: relative; }
.mrow .mbar i { display: block; height: 100%; border-radius: 4px; }
.mrow .mbar u { position: absolute; top: -1px; width: 2px; height: 6px; background: var(--ink); opacity: 0.4; }
.mrow input {
  width: 100%; height: 34px; text-align: right; padding: 0 9px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  font-family: var(--ff-num); font-size: 15px; font-weight: 700; outline: none;
}
.mrow input:focus { border-color: var(--red); background: var(--card); box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.1); }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; align-items: center; }

/* ══════════════ MODAL ══════════════ */
.modal-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(10, 12, 16, 0.5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px; animation: fade 0.18s; }
.modal { width: min(620px, 100%); max-height: 88dvh; display: flex; flex-direction: column; background: var(--card); border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: pop 0.2s cubic-bezier(0.22, 1, 0.36, 1); overflow: hidden; }
@keyframes pop { from { transform: translateY(10px) scale(0.985); opacity: 0; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.field input {
  height: 42px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--ink); font: inherit; font-size: 13.5px; outline: none; width: 100%;
}
.field input:focus { border-color: var(--red); background: var(--card); box-shadow: 0 0 0 3px rgba(237, 28, 36, 0.1); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.form-grid .field { margin-bottom: 4px; }
.form-grid .field input { height: 38px; font-family: var(--ff-num); font-size: 15px; font-weight: 700; }
.drop {
  border: 2px dashed var(--line); border-radius: 16px; padding: 34px 20px; text-align: center;
  cursor: pointer; transition: 0.18s; background: var(--bg-2);
}
.drop:hover, .drop.over { border-color: var(--red); background: var(--red-soft); }
.drop-ic { width: 46px; height: 46px; border-radius: 14px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--card); color: var(--red); border: 1px solid var(--line); }
.drop-ic svg { width: 22px; height: 22px; }
.drop b { display: block; font-size: 14px; margin-bottom: 4px; }
.drop span { font-size: 12px; color: var(--muted); }
.result { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-size: 12.5px; font-weight: 600; }
.result.err { background: var(--red-soft); color: var(--red); }

.format-help {
  margin-top: 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  font-size: 12px; line-height: 1.65; color: var(--ink-2);
}
.format-help b { display: block; margin-bottom: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.format-help ol { margin: 0; padding-left: 18px; }
.format-help li { margin-bottom: 3px; }
.format-help code { background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; font-size: 11px; }

/* ══════════════ TOAST ══════════════ */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 11px 15px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: 360px;
  animation: toastIn 0.24s cubic-bezier(0.22, 1, 0.36, 1); border-left: 3px solid var(--green);
}
.toast.err { border-left-color: var(--red); }
@keyframes toastIn { from { transform: translateX(16px); opacity: 0; } }

.skeleton { background: linear-gradient(90deg, var(--bg-2) 25%, var(--line-2) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════ MODE ADMIN / PUBLIK ══════════════ */
body.is-public .admin-only { display: none !important; }
body:not(.is-public) .public-only { display: none !important; }

.admin-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 999px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em;
  color: #fff; background: linear-gradient(135deg, var(--red), var(--red-2));
  box-shadow: 0 8px 18px -12px rgba(237, 28, 36, 1);
}
.admin-chip .adot { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 2.2s infinite; }

body.is-public .data-table td.num-cell { cursor: default; }
body.is-public .data-table td.num-cell:hover { background: transparent; box-shadow: none; }
body.is-public .heat td.cell button:hover { outline: 2px solid rgba(237, 28, 36, 0.35); transform: none; }
body.is-public .foot strong { font-weight: 700; }

/* ══════════════ LOGIN ══════════════ */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 22px;
  background:
    radial-gradient(700px 380px at 20% 0%, rgba(237, 28, 36, 0.16), transparent 60%),
    radial-gradient(600px 340px at 100% 100%, rgba(237, 28, 36, 0.10), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%); padding: 26px 26px 22px;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
  animation: pop 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--red), #ff5a44 45%, #ffb020 75%, var(--red-2));
}
.login-title { font-size: 20px; margin: 18px 0 4px; }
.login .field input { height: 44px; font-size: 14px; }
.login .btn-block { width: 100%; justify-content: center; }
.login-err {
  margin: 0 0 10px; padding: 9px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 600;
  background: var(--red-soft); color: var(--red); border: 1px solid rgba(237, 28, 36, 0.3);
}
.login-back { display: inline-block; margin-top: 16px; font-size: 12px; color: var(--muted); text-decoration: none; }
.login-back:hover { color: var(--red); }
.login[hidden] { display: none; }

.readonly-val { font-family: var(--ff-num); font-size: 15px; font-weight: 700; text-align: right; }
.mrow.readonly label { cursor: default; }

body.is-public .drawer-body { padding-bottom: 12px; }

/* ══════════════ RESPONSIVE ══════════════ */
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: 1fr; }
  .col-side { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app { padding: 12px 12px 30px; }
  .topbar { padding: 10px 12px; }
  .brand-text h1 { font-size: 17px; }
  .clock { display: none; }
  .chart-axis, .chart-row { grid-template-columns: 28px minmax(84px, 140px) 1fr 60px; padding: 0 12px; }
  .rdelta { display: none; }
  .chart-axis .right { display: none; }
}
@media (max-width: 640px) {
  .col-side { grid-template-columns: 1fr; }
  .brand-logo { height: 30px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 9px; }
  .kpi-value { font-size: 30px; }
  .kpi-sub { font-size: 10.5px; }
  .tabs button { min-width: 0; font-size: 12px; padding: 9px 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .heat th.name, .heat td.name { min-width: 130px; }
  .brand-text p #brandSub { display: none; }
  .btn span { display: none; }
}

/* ── periode, ringkasan agent, kolom volume ── */
.period { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.period select {
  font: inherit; font-weight: 700; color: var(--ink); background: var(--card);
  border: 1px solid var(--line, rgba(0,0,0,.12)); border-radius: 10px; padding: 7px 28px 7px 10px; cursor: pointer;
}
.agent-bar { padding: 14px 16px; margin-bottom: 14px; }
.ag-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.ag-name { font-family: var(--ff-num); font-size: 22px; font-weight: 800; color: var(--red); letter-spacing: .5px; }
.ag-sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.ag-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.ag-vol { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line, rgba(0,0,0,.12)); }
.ag-item { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-radius: 10px; background: rgba(127,127,127,.07); min-width: 0; }
.ag-item span { font-size: 10.5px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-item b { font-family: var(--ff-num); font-size: 19px; font-weight: 800; }
.data-table td.count-cell { font-family: var(--ff-num); font-size: 14px; font-weight: 700; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.gauges { grid-template-columns: repeat(2, 1fr); }

/* ── dwibahasa: teks Mandarin ── */
.zh { font-size: .8em; font-weight: 500; color: var(--muted); margin-left: .25em; letter-spacing: .02em; }
.zh.blk { display: block; margin: 2px 0 0; font-size: 11px; }
h1 .zh { font-size: .62em; font-weight: 600; }
.tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.tab-l { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; text-align: left; }
.tab-l b { font-weight: 800; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px; }
.chip.card-chip { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; padding: 9px 13px; border-radius: 12px; }
.chip.card-chip .chip-l { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.chip.card-chip .chip-l b { font-size: 12.5px; font-weight: 700; }
.chip.card-chip .chip-val { font-size: 17px; font-weight: 800; }
.chip.card-chip.static { cursor: default; }
.chip.card-chip.static:hover { border-color: inherit; color: inherit; transform: none; }
.chip.card-chip.static .chip-val.vol { color: var(--ink); }
.chip.active .zh { color: rgba(255, 255, 255, .85); }
.period-seg button { white-space: nowrap; }
.ag-item span { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.25; }
.ag-item span .zh { display: block; margin: 1px 0 0; }
