:root {
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #718096;
  --line: #e6ebf2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --cyan: #06b6d4;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(37, 99, 235, 0.10), transparent 35%),
    radial-gradient(circle at 95% 0%, rgba(6, 182, 212, 0.10), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.5px; }
h2 { font-size: 19px; display: flex; align-items: center; gap: 9px; }
h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 26px 0 10px; }

.muted { color: var(--muted); font-size: 12px; }
.error { color: var(--danger); min-height: 18px; margin: 8px 0 0; font-size: 12px; }

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  vertical-align: middle;
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- Login & public ---------- */
.login-screen {
  display: grid;
  place-items: center;
  padding: 36px 20px;
}

.login-wrap {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 46px;
  align-items: center;
}

.login-intro .brand-logo.hero { width: 290px; height: auto; margin-bottom: 22px; }
.login-intro h1 { max-width: 460px; }
.login-intro > p { color: var(--muted); font-size: 15px; max-width: 460px; line-height: 1.7; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.chips span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: #475569;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}
.chips .icon { color: var(--primary); width: 15px; height: 15px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h2 { margin-bottom: 4px; }

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(6, 182, 212, 0.12));
  color: var(--primary);
  margin-bottom: 14px;
}
.card-icon .icon { width: 21px; height: 21px; }

label { display: block; margin-bottom: 14px; }
label > span { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: #475569; }

input, select, textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 10px;
  padding: 10px 15px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18);
}
button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25); }
button:active { transform: translateY(0); }
button.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
button.ghost:hover { background: var(--surface-soft); }
button.small { padding: 7px 11px; font-size: 12px; }
button.danger { background: linear-gradient(135deg, #ef4444, #f97316); box-shadow: none; }
button.ok { background: linear-gradient(135deg, #059669, #14b8a6); box-shadow: none; }
button + button { margin-left: 8px; }
.login-card button { width: 100%; margin-top: 8px; }
.login-card button + button { margin-left: 0; }

/* ---------- App shell ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 26px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-brand { display: flex; align-items: center; gap: 16px; }
.brand-logo { width: 168px; height: auto; display: block; }
.tagline {
  padding-left: 16px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.header-user { display: flex; align-items: center; gap: 12px; }
.header-user .name { display: block; font-weight: 700; font-size: 13px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: #eaf1ff;
}

.layout {
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 22px;
  padding: 22px 26px 40px;
  max-width: 1440px;
  margin: 0 auto;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  height: max-content;
  box-shadow: var(--shadow);
}
nav button {
  justify-content: flex-start;
  background: transparent;
  color: #64748b;
  box-shadow: none;
  padding: 11px 13px;
  font-weight: 500;
}
nav button:hover { background: var(--surface-soft); transform: none; box-shadow: none; }
nav button.active {
  background: linear-gradient(135deg, #eaf1ff, #ecfeff);
  color: var(--primary-dark);
}
nav button.active .icon { color: var(--primary); }

main { min-width: 0; }
.page-title { margin-bottom: 16px; }
.page-title p { margin: 4px 0 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar select { width: 175px; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search-box input { width: 230px; padding-left: 34px; background: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong { display: block; font-size: 23px; margin-top: 4px; letter-spacing: -0.4px; }
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #eaf1ff;
  color: var(--primary);
}
.stat-icon.green { background: #e7f8f1; color: var(--ok); }
.stat-icon.red { background: #fdecec; color: var(--danger); }
.stat-icon.amber { background: #fef3e2; color: var(--warn); }
.stat-icon.cyan { background: #e6f9fc; color: #0891b2; }

/* ---------- Dashboard panels & traffic live ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel-head { margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 5px 0 0; }
.panel h3 { margin: 0 0 10px; }
.panel .table-wrap { box-shadow: none; }

.stats-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.dashboard-grid,
.traffic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  align-items: start;
}
.traffic-panel { margin-bottom: 16px; }
.traffic-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: #e7f8f1;
  color: var(--ok);
  font-size: 11px;
  font-weight: 700;
}
.live-badge.offline { background: #fdecec; color: var(--danger); }
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.traffic-summary { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; }
.traffic-summary .stat { padding: 14px; box-shadow: none; }
.traffic-summary .stat strong { font-size: 19px; }
.traffic-summary .stat-icon { width: 36px; height: 36px; }

.rate { display: flex; flex-direction: column; gap: 5px; min-width: 108px; font-size: 12px; font-weight: 600; }
.meter { height: 5px; border-radius: 999px; background: #e8eef6; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--cyan)); }
.meter.up i { background: linear-gradient(90deg, var(--ok), #14b8a6); }

/* ---------- Data pelanggan ---------- */
.customer-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.customer-stats .stat { padding: 13px 15px; box-shadow: none; }
.customer-stats .stat strong { font-size: 19px; }
.customer-stats .stat-icon { width: 34px; height: 34px; }

.pagination { margin-top: 14px; gap: 12px; }
.pagination button { min-width: 116px; }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.cell-main { font-weight: 600; }
.cell-sub { margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 400; }
td.actions button.icon-only { padding: 6px 8px; }
td.actions button.icon-only .icon { width: 15px; height: 15px; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; background: var(--surface-soft); }
tbody tr:hover { background: #fafcff; }
tr:last-child td { border-bottom: 0; }
td.actions button { padding: 6px 9px; font-size: 11px; margin-left: 5px; box-shadow: none; }
td.actions button:first-child { margin-left: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge .icon { width: 13px; height: 13px; }
.badge.ACTIVE, .badge.APPROVED, .badge.ONLINE { background: #e7f8f1; color: var(--ok); }
.badge.PENDING { background: #fef3e2; color: var(--warn); }
.badge.EXPIRED, .badge.SUSPENDED, .badge.REJECTED, .badge.OFFLINE { background: #fdecec; color: var(--danger); }

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(3px);
  z-index: 50;
  padding: 20px;
}
.modal-card { width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto; }
.modal-card h2 { margin-bottom: 18px; }
.modal-card > button { margin-top: 6px; }

.import-note { margin: 0 0 12px; }
.import-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.import-toolbar button { padding: 7px 11px; font-size: 12px; box-shadow: none; }
.import-list { max-height: 46vh; overflow: auto; margin-bottom: 16px; }
.import-list th, .import-list td { padding: 8px 10px; font-size: 12px; }
.import-list input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.import-reason { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--ok);
  color: #fff;
  padding: 12px 17px;
  border-radius: 12px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.2s;
  z-index: 100;
  box-shadow: 0 12px 28px rgba(5, 150, 105, 0.25);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); box-shadow: 0 12px 28px rgba(220, 38, 38, 0.25); }

/* ---------- Banner peringatan, aksi massal, grafik & modal tambahan ---------- */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border: 1px solid #f6d7a7;
  border-left: 4px solid var(--warn);
  border-radius: 12px;
  background: #fffaf0;
  color: #92400e;
  font-size: 12px;
}
.alert-banner .icon { color: var(--warn); }
.alert-banner strong { display: block; font-size: 13px; margin-bottom: 5px; }
.alert-banner ul { margin: 0; padding-left: 18px; line-height: 1.6; }

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #eaf1ff;
  border: 1px solid #d6e4ff;
  border-radius: 12px;
}
.bulk-toolbar span { margin-right: 6px; }
.bulk-toolbar button { margin-left: 0; }

#customers-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.sync-error-link {
  padding: 2px 4px !important;
  margin-left: 5px !important;
  background: #fdecec;
  color: var(--danger);
  box-shadow: none;
}
.sync-error-link .icon { width: 13px; height: 13px; }

.traffic-history {
  margin: 14px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.sparkline-head { gap: 10px; font-size: 12px; font-weight: 600; }
.sparkline-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sparkline-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.sparkline-legend .legend-rx { background: var(--primary); }
.sparkline-legend .legend-tx { background: var(--ok); }
.sparkline { display: block; width: 100%; height: 110px; margin-top: 8px; }
.sparkline-axis { stroke: var(--line); stroke-width: 1; }
.sparkline polyline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.sparkline-rx { stroke: var(--primary); }
.sparkline-tx { stroke: var(--ok); }

.proof-thumb {
  padding: 3px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: none;
}
.proof-thumb img { display: block; width: 44px; height: 36px; object-fit: cover; border-radius: 6px; }
.proof-file { min-width: 44px; height: 36px; font-size: 11px; }
.proof-preview { text-align: center; }
.proof-preview img { display: block; max-width: 100%; max-height: 62vh; margin: 0 auto 12px; border-radius: 10px; }
.proof-preview p { overflow-wrap: anywhere; }
.proof-link { text-decoration: none; }

.confirm-dialog-message { margin: 0 0 18px; color: #475569; line-height: 1.6; }
.detail-block {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}

.diagnose-result h4 { margin: 18px 0 8px; font-size: 13px; }
.diagnose-list { list-style: none; margin: 12px 0; padding: 0; }
.diagnose-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.diagnose-item.ok { color: var(--ok); }
.diagnose-item.bad { color: var(--danger); }
.diagnose-item small { display: block; color: var(--muted); font-size: 11px; }
.diagnose-rules > div { margin-bottom: 10px; }
.diagnose-rules span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; margin-bottom: 4px; }
.diagnose-rules code, .diagnose-missing code {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 7px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text);
}

.audit-toolbar { margin-bottom: 14px; }
.audit-toolbar .date-filter { margin: 0; }
.audit-toolbar .date-filter span { display: inline; margin-right: 6px; }
.audit-toolbar .date-filter input { display: inline-block; width: 150px; }

@media (max-width: 1100px) {
  .dashboard-grid,
  .traffic-grid { grid-template-columns: 1fr; }
  .traffic-status { width: 100%; }
}

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; gap: 24px; max-width: 460px; }
  .login-intro { text-align: center; }
  .login-intro .brand-logo.hero { margin-left: auto; margin-right: auto; }
  .login-intro h1 { font-size: 24px; }
  .chips { justify-content: center; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  nav { flex-direction: row; overflow-x: auto; }
  nav button { white-space: nowrap; }
  .tagline { display: none; }
  .search-box input { width: 180px; }
}
