:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #3b82f6;
  --brand-2: #2563eb;
  --brand-soft: #eff6ff;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --violet: #8b5cf6;
  --violet-soft: #f5f3ff;
  --cyan: #06b6d4;
  --cyan-soft: #ecfeff;
  --sidebar-w: 264px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.04);
  --shadow-hover: 0 8px 28px rgba(15,23,42,.08);
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 400px at 100% -10%, rgba(59,130,246,.08), transparent 50%),
    radial-gradient(700px 300px at 0% 0%, rgba(139,92,246,.06), transparent 45%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-2); text-decoration: none; }
.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: transform .25s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.2rem 1.15rem;
  color: #fff !important;
  border-bottom: 1px solid rgba(148,163,184,.1);
}
.brand img {
  width: 38px; height: 38px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255,255,255,.08);
}
.brand strong { display: block; font-size: 1rem; font-weight: 750; letter-spacing: -.02em; }
.brand small { display: block; color: #94a3b8; font-size: .75rem; margin-top: .12rem; }

.nav {
  padding: .75rem .75rem .5rem;
  display: grid;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  align-content: start;
}
.nav-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #64748b;
  padding: .25rem .7rem .4rem;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  color: #cbd5e1; padding: .55rem .75rem;
  border-radius: 10px; font-weight: 600; font-size: .9rem;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 6px 16px rgba(37,99,235,.35);
}
.nav-item.logout { color: #fca5a5; margin-top: .25rem; }

.sidebar-foot {
  padding: .85rem .8rem 1rem;
  border-top: 1px solid rgba(148,163,184,.1);
}
.user-card { display: flex; gap: .7rem; align-items: center; padding: .4rem .55rem .7rem; }
.avatar {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #fff; display: grid; place-items: center; font-weight: 750; flex-shrink: 0;
}
.user-meta strong {
  display: block; font-size: .86rem; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.user-meta small {
  display: block; color: #94a3b8; font-size: .72rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: .9rem;
  padding: .85rem 1.5rem;
  background: rgba(244,247,251,.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226,232,240,.9);
  position: sticky; top: 0; z-index: 20;
}
.search-wrap { flex: 1; max-width: 420px; }
.top-search {
  display: flex; align-items: center; gap: .55rem;
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: .55rem .85rem;
  box-shadow: var(--shadow); color: var(--muted);
}
.top-search input {
  border: 0; outline: none; width: 100%; font: inherit; background: transparent; color: var(--ink);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .65rem; }
.balance-box {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: .4rem .85rem; box-shadow: var(--shadow); min-width: 128px;
}
.balance-box span {
  display: block; font-size: .65rem; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
}
.balance-box strong {
  display: block; font-size: 1.02rem; font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.balance-box small { color: var(--muted); font-size: .72rem; font-weight: 650; }

.menu-btn {
  display: none; width: 40px; height: 40px; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 0;
}
.menu-btn span { width: 16px; height: 2px; background: var(--ink); border-radius: 2px; }

.content {
  padding: 1.4rem 1.5rem 1.75rem;
  flex: 1;
  width: 100%;
  max-width: none;
}
.footer {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .9rem 1.5rem 1.25rem; color: var(--muted); font-size: .82rem;
  border-top: 1px solid var(--line);
}
.status-ok { display: inline-flex; align-items: center; gap: .4rem; }
.status-ok i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(16,185,129,.2);
}

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h1 {
  margin: 0; font-size: clamp(1.4rem, 2vw, 1.7rem); font-weight: 800; letter-spacing: -.03em;
}
.page-head p { margin: .35rem 0 0; color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  display: flex; gap: .9rem; align-items: flex-start;
  transition: transform .18s ease, box-shadow .18s ease;
}
.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.metric-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.metric-icon.blue { background: var(--brand-soft); color: var(--brand-2); }
.metric-icon.green { background: var(--ok-soft); color: var(--ok); }
.metric-icon.violet { background: var(--violet-soft); color: var(--violet); }
.metric-icon.cyan { background: var(--cyan-soft); color: var(--cyan); }
.metric .label { color: var(--muted); font-size: .8rem; font-weight: 650; }
.metric .value {
  margin-top: .2rem; font-size: 1.55rem; font-weight: 800;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.metric .meta { margin-top: .25rem; font-size: .78rem; color: var(--muted); }

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel, .card, .stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem;
}
.panel h2, .panel h3, .card h2, .card h3 {
  margin: 0 0 .2rem; font-size: 1.02rem; font-weight: 750; letter-spacing: -.02em;
}
.panel .sub, .card .sub { margin: 0 0 1rem; color: var(--muted); font-size: .88rem; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}
.quick-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--ink) !important;
  font-weight: 650;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.quick-link:hover {
  background: #fff;
  border-color: #bfdbfe;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.quick-link .qi {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-2);
}
.quick-link small { display: block; color: var(--muted); font-weight: 500; font-size: .75rem; margin-top: .15rem; }

.detail-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .85rem;
}
.detail-box {
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: .9rem 1rem;
}
.detail-box .label { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.detail-box strong { display: block; margin-top: .3rem; font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; }

.activity-list { display: grid; gap: .55rem; }
.activity-item {
  display: flex; gap: .75rem; align-items: flex-start;
  padding: .75rem .8rem; border-radius: 11px; background: #f8fafc; border: 1px solid var(--line);
}
.activity-item .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
  margin-top: .45rem; flex-shrink: 0;
}
.activity-item strong { display: block; font-size: .86rem; font-weight: 650; }
.activity-item span { display: block; color: var(--muted); font-size: .78rem; margin-top: .15rem; }

.clock-card {
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 60%, #1d4ed8 140%);
  color: #fff; border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow-hover); min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.clock-card .label { color: #94a3b8; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.clock-card .time { margin-top: .55rem; font-size: 2.15rem; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.clock-card .date { color: #cbd5e1; margin-top: .35rem; font-size: .92rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 650; }
.stat .value { margin-top: .3rem; font-size: 1.55rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.toolbar input {
  flex: 1; min-width: 200px; border: 1px solid var(--line); border-radius: 11px;
  padding: .7rem .9rem; font: inherit; background: #fff;
}
.toolbar input:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(59,130,246,.15); }

.btn {
  appearance: none; border: 0; border-radius: 11px; padding: .68rem 1rem;
  font: inherit; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff; box-shadow: 0 6px 14px rgba(37,99,235,.28);
}
.btn-primary:hover { color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-warn { background: var(--warn-soft); color: #b45309; border: 1px solid #fde68a; }
.btn-danger { background: var(--danger-soft); color: #b91c1c; border: 1px solid #fecaca; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-sm { padding: .48rem .8rem; font-size: .84rem; }

.form-grid { display: grid; gap: .9rem; }
.form-row { display: grid; gap: .35rem; }
.form-row label { font-weight: 650; font-size: .88rem; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px;
  padding: .72rem .9rem; font: inherit; background: #fff;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(59,130,246,.15);
}
.hint, .label { color: var(--muted); font-size: .82rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; }
table.data th, table.data td { text-align: left; padding: .95rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: #f8fafc; font-weight: 750;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #f8fafc; }
table.data tr.row-topup td { background: #ecfdf5; }
table.data tr.row-topup:hover td { background: #d1fae5; }
table.data tr.row-expired td { background: #fef2f2; }
table.data tr.row-expired:hover td { background: #fee2e2; }
table.data tr.row-expired td:first-child { box-shadow: inset 3px 0 0 #ef4444; }
table.data tr.row-limit td { background: #fffbeb; }
table.data tr.row-limit:hover td { background: #fef3c7; }
table.data tr.row-limit td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.amt-credit { color: #047857; font-weight: 750; font-variant-numeric: tabular-nums; }
.amt-debit { color: #b91c1c; font-weight: 750; font-variant-numeric: tabular-nums; }

.badge, .chip {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: .2rem .55rem; font-size: .72rem; font-weight: 750;
}
.badge.ok { background: var(--ok-soft); color: #047857; }
.badge.warn { background: var(--warn-soft); color: #b45309; }
.badge.danger { background: var(--danger-soft); color: #b91c1c; }
.badge.muted { background: #f1f5f9; color: #475569; }
.badge.info { background: var(--brand-soft); color: var(--brand-2); }

.progress { height: 7px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: .4rem; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: inherit; }

.actions { display: flex; gap: .45rem; flex-wrap: wrap; }
.pagination { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: 1rem; }
.pagination a, .pagination span {
  min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 650; font-size: .88rem;
}
.pagination .current { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }

.alert {
  border-radius: 12px; padding: .85rem 1rem; margin-bottom: 1rem;
  border: 1px solid; font-weight: 650; font-size: .92rem;
}
.alert-success { background: var(--ok-soft); border-color: #a7f3d0; color: #047857; }
.alert-error { background: var(--danger-soft); border-color: #fecaca; color: #b91c1c; }
.alert-info { background: var(--brand-soft); border-color: #bfdbfe; color: #1d4ed8; }

.clock {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  color: #fff; border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow);
}
.clock .time { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; }
.clock .date { color: #cbd5e1; margin-top: .25rem; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.48);
  display: none; align-items: center; justify-content: center; z-index: 80; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(440px, 100%); background: #fff; border-radius: 16px;
  padding: 1.25rem; box-shadow: var(--shadow-hover);
}
.loading-overlay {
  position: fixed; inset: 0; background: rgba(244,247,251,.84);
  display: none; place-items: center; z-index: 90; text-align: center;
}
.loading-overlay.show { display: grid; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid #dbeafe; border-top-color: var(--brand-2);
  animation: spin .7s linear infinite; margin: 0 auto .7rem;
}
.overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.42); z-index: 30; }

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.25rem;
  background:
    radial-gradient(800px 400px at 15% -10%, rgba(59,130,246,.18), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(139,92,246,.12), transparent 50%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%); background: #fff; border: 1px solid var(--line);
  border-radius: 18px; padding: 1.6rem; box-shadow: var(--shadow-hover);
}
.login-card .brand-row { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.15rem; }
.login-card .brand-row img { width: 42px; height: 42px; border-radius: 11px; object-fit: contain; }
.login-card h1 { margin: 0; font-size: 1.45rem; font-weight: 800; letter-spacing: -.03em; }
.login-card .lead { margin: .35rem 0 1.15rem; color: var(--muted); }
.login-error {
  background: var(--danger-soft); color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 11px; padding: .7rem .8rem; margin-bottom: .9rem; font-weight: 650;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Floating WhatsApp (reseller contact) */
.wa-float {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 60;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #25d366;
  color: #fff;
  box-shadow: 0 10px 28px rgba(37, 211, 102, .45);
  transition: transform .18s ease, box-shadow .18s ease;
}
.wa-float:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 14px 32px rgba(37, 211, 102, .55);
  color: #fff;
}
.wa-float:focus-visible {
  outline: 3px solid #86efac;
  outline-offset: 3px;
}

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    width: min(280px, 88vw);
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .nav { flex: 0 0 auto; overflow: visible; }
  .sidebar-foot { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
  .overlay.show { display: block; }
  .search-wrap { display: none; }
  .metrics, .grid-2, .grid-3, .grid-4, .quick-grid, .detail-row { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
  .wa-float { right: .9rem; bottom: .9rem; width: 52px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
