/* ── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', 'Segoe UI', sans-serif; background: #f8f9fa; color: #111; font-size: 14px; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
input, select, textarea, button { font-family: inherit; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }

/* ── VARIABLES ──────────────────────────────────────────────── */
:root {
  --red:        #E42022;
  --red-light:  #fef2f2;
  --red-border: #fecaca;
  --red-dark:   #b91c1c;
  --green:      #16a34a;
  --green-light:#f0fdf4;
  --green-border:#bbf7d0;
  --gray:       #6b7280;
  --gray-light: #f9fafb;
  --border:     #e5e7eb;
  --shadow:     0 1px 4px rgba(0,0,0,.06);
  --radius:     10px;
  --sidebar-w:  220px;
}

/* ── LAYOUT ─────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.main-wrap  { flex: 1; margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.content    { flex: 1; padding: 24px 28px; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.logo-icon {
  width: 36px; height: 36px; background: var(--red);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.logo-name { font-weight: 700; font-size: 15px; color: #111; }
.logo-sub  { font-size: 10px; color: var(--gray); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-label {
  font-size: 10px; font-weight: 600; color: #9ca3af;
  letter-spacing: .08em; padding: 4px 8px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 2px;
  color: #374151; font-size: 13px; transition: all .15s;
}
.nav-item:hover  { background: #f9fafb; }
.nav-item.active { background: var(--red-light); color: var(--red); font-weight: 600; }
.nav-icon        { width: 18px; text-align: center; font-size: 13px; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid #f3f4f6;
}
.platform-label { font-size: 10px; color: var(--gray); font-weight: 600; margin-bottom: 6px; }
.platform-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge-platform {
  border-radius: 6px; padding: 3px 9px; font-size: 11px; font-weight: 700;
}
.badge-platform.active   { background: var(--red-light); color: var(--red); border: 1px solid var(--red-border); }
.badge-platform.inactive { background: #f9fafb; color: #9ca3af; border: 1px solid var(--border); }

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-badge { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; display: inline-block; }
.topbar-title { font-size: 22px; font-weight: 700; color: #111; }
.topbar-sub { font-size: 13px; color: var(--gray); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--red);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-logout {
  border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 12px; font-size: 12px; color: var(--gray);
  cursor: pointer; transition: all .15s;
}
.btn-logout:hover { background: var(--red-light); color: var(--red); border-color: var(--red-border); }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
}
.card-sm { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* ── STAT CARDS ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 11px; color: var(--gray); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-value { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.stat-sub   { font-size: 12px; color: var(--gray); }
.stat-sub.red { color: var(--red); }
.stat-sub.green { color: var(--green); }

/* ── GRID HELPERS ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.gap-14 { gap: 14px; }
.mb-16  { margin-bottom: 16px; }
.mb-20  { margin-bottom: 20px; }
.mb-24  { margin-bottom: 24px; }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  border-radius: 20px; padding: 2px 9px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-red    { background: var(--red-light); color: var(--red); border: 1px solid var(--red-border); }
.badge-green  { background: var(--green-light); color: var(--green); border: 1px solid var(--green-border); }
.badge-gray   { background: #f9fafb; color: var(--gray); border: 1px solid var(--border); }
.badge-kode   { background: var(--red-light); color: var(--red); border: 1px solid var(--red-border); border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 700; }

/* ── ALERTS ─────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius); padding: 14px 18px;
  margin-bottom: 20px; display: flex; align-items: flex-start; gap: 12px;
}
.alert-red   { background: var(--red-light); border: 1px solid var(--red-border); }
.alert-green { background: var(--green-light); border: 1px solid var(--green-border); }
.alert-icon  { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-weight: 700; font-size: 14px; }
.alert-body  { font-size: 12px; margin-top: 2px; }

/* ── TABLE ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: #fff; }
thead tr { background: #f9fafb; }
th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; color: var(--gray);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }
td.bold  { font-weight: 600; }
td.red   { color: var(--red); font-weight: 700; }
td.green { color: var(--green); font-weight: 600; }
td.gray  { color: var(--gray); }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.form-label .req { color: var(--red); }
.form-control {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; font-size: 13px; outline: none; transition: border .15s;
  background: #fff;
}
.form-control:focus { border-color: var(--red); box-shadow: 0 0 0 2px rgba(228,32,34,.1); }
.form-hint { font-size: 11px; color: var(--gray); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 4px; }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none; transition: all .15s;
}
.btn-primary   { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: #fff; color: #374151; border: 1px solid var(--border); }
.btn-secondary:hover { background: #f9fafb; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid var(--red-border); }

/* ── FILTERS ────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar .form-control { width: auto; min-width: 180px; }
.filter-bar .ml-auto { margin-left: auto; }

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: #f8f9fa;
}
.login-box {
  background: #fff; border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px; justify-content: center;
}
.login-logo .logo-icon { width: 44px; height: 44px; font-size: 16px; }
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.login-sub   { font-size: 13px; color: var(--gray); text-align: center; margin-bottom: 28px; }
.login-error { background: var(--red-light); border: 1px solid var(--red-border); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--red); margin-bottom: 16px; }

/* ── CHARTS ─────────────────────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { max-width: 100%; }

/* ── SUMMARY BANNER (merah) ─────────────────────────────────── */
.summary-banner {
  background: var(--red); color: #fff;
  border-radius: var(--radius); padding: 24px 28px;
  display: flex; align-items: center; gap: 32px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.summary-banner .s-group { flex: 1; min-width: 140px; }
.summary-banner .s-label { font-size: 11px; opacity: .8; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.summary-banner .s-value { font-size: 22px; font-weight: 700; }
.summary-banner .s-sub   { font-size: 11px; opacity: .7; margin-top: 2px; }
.summary-banner .divider { width: 1px; background: rgba(255,255,255,.25); align-self: stretch; }

/* ── GROWTH BADGE ────────────────────────────────────────────── */
.growth-up   { background: var(--green-light); color: var(--green); border: 1px solid var(--green-border); border-radius: 20px; padding: 2px 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.growth-dn   { background: var(--red-light); color: var(--red); border: 1px solid var(--red-border); border-radius: 20px; padding: 2px 8px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.growth-neu  { background: #f9fafb; color: var(--gray); border: 1px solid var(--border); border-radius: 20px; padding: 2px 8px; font-size: 11px; font-weight: 700; }

/* ── MODAL ──────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; padding: 28px;
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .stats-grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ── UTILS ──────────────────────────────────────────────────── */
.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.text-gray  { color: var(--gray); }
.text-bold  { font-weight: 700; }
.text-sm    { font-size: 12px; }
.d-flex     { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }
.mt-16  { margin-top: 16px; }
