/* ===================== AI DIGITAL MARKETING DASHBOARD ===================== */
:root {
  --bg: #0f1117;
  --bg-card: #1a1d29;
  --bg-card-hover: #222637;
  --border: #2d3142;
  --text: #e4e4e7;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-dim: #4f46e5;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  --pink: #ec4899;
  --topbar-height: 0px;
  --sidebar-width: 220px;
  --page-gutter-x: 24px;
  --page-gap-y: 18px;
  --page-top-y: 22px;
  --page-bottom-y: 32px;
  --card-gap: 20px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: 220px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 0;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease, width 0.3s;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header .logo-icon {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.sidebar-header .logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.sidebar-header .logo-text {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-header .logo-text span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.sidebar-nav {
  padding: 16px 12px;
}

.sidebar-nav .nav-section {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 12px 4px;
  letter-spacing: 0.5px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.sidebar-nav a.active {
  background: var(--primary-dim);
  color: white;
}

.sidebar-nav a .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* ===================== MAIN CONTENT ===================== */
.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  flex: 1;
  padding: 24px 32px;
  min-height: 100vh;
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: var(--page-gap-y, 18px);
  padding-bottom: 0;
  border-bottom: none;
}

.page-header > * {
  min-width: 0;
}

.page-header > div:first-child {
  flex: 1 1 300px;
}

.page-header > div:last-child:not(:first-child) {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.page-title {
  font-size: clamp(16px, 4vw, 28px);
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
  padding: 0;
}

.page-subtitle {
  font-size: clamp(12px, 2.5vw, 14px);
  color: var(--text-muted);
  margin-top: 6px;
  max-width: 760px;
  line-height: 1.5;
  padding: 0;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ===================== CARDS ===================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.filter-bar {
  padding: 14px 20px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

@media (max-width: 480px) {
  .filter-row {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-row .btn,
  .filter-row .form-input,
  .filter-row select {
    width: 100%;
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  padding: 0;
}

/* ===================== METRIC CARDS ===================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--card-gap, 20px);
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.metric-card.success::before { background: var(--success); }
.metric-card.warning::before { background: var(--warning); }
.metric-card.info::before { background: var(--info); }
.metric-card.pink::before { background: var(--pink); }

.metric-card .metric-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.metric-card .metric-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.metric-card .metric-change {
  font-size: 12px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-change.up { color: var(--success); }
.metric-change.down { color: var(--danger); }

.metric-icon {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 24px;
  opacity: 0.3;
}

/* ===================== CHARTS ===================== */
.chart-container {
  position: relative;
  height: 300px;
  margin-top: 12px;
}

.chart-container-sm {
  position: relative;
  height: 220px;
  margin-top: 12px;
}

/* ===================== TABLE ===================== */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

table tr:hover td {
  background: var(--bg-card-hover);
}

table tr:last-child td {
  border-bottom: none;
}

.table-column-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
  position: relative;
  min-height: 32px;
}

.table-column-summary {
  color: var(--text-muted);
  font-size: 12px;
}

.table-column-button {
  min-width: 74px;
}

.table-column-button::after {
  content: ' ▾';
  color: var(--text-muted);
  font-size: 11px;
}

.table-column-button[aria-expanded="true"]::after {
  content: ' ▴';
}

.table-column-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  width: min(320px, 88vw);
  max-height: 300px;
  overflow: auto;
  padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.table-column-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.table-column-option:hover {
  background: var(--bg-card-hover);
}

.table-column-option input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.table-column-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-column-hidden {
  display: none !important;
}

/* ===================== BADGES ===================== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-paused { background: var(--warning-bg); color: var(--warning); }
.badge-ended { background: rgba(107, 114, 128, 0.1); color: var(--text-dim); }

.badge-high { background: var(--danger-bg); color: var(--danger); }
.badge-medium { background: var(--warning-bg); color: var(--warning); }
.badge-low { background: var(--info-bg); color: var(--info); }
.badge-info { background: rgba(99, 102, 241, 0.1); color: var(--primary-hover); }
.badge-critical { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-healthy { background: var(--success-bg); color: var(--success); }

/* ===================== INSIGHTS ===================== */
.insight-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.insight-item.warning { border-left: 4px solid var(--warning); }
.insight-item.success { border-left: 4px solid var(--success); }
.insight-item.info { border-left: 4px solid var(--info); }

.insight-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.insight-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.insight-content p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

.insight-action {
  font-size: 12px;
  color: var(--primary-hover);
  background: rgba(99, 102, 241, 0.1);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* ===================== FORM ===================== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===================== SOCIAL CARDS ===================== */
.social-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--card-gap, 20px);
}

.social-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.social-card .platform-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.social-card .platform-name {
  font-size: 18px;
  font-weight: 700;
}

.social-card .handle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.social-card .followers {
  font-size: 32px;
  font-weight: 700;
}

.social-card .followers-label {
  font-size: 12px;
  color: var(--text-muted);
}

.social-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.social-stat {
  text-align: center;
}

.social-stat .stat-value {
  font-size: 18px;
  font-weight: 700;
}

.social-stat .stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===================== CREATIVE CARDS ===================== */
.creatives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--card-gap, 20px);
}

.creative-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  cursor: pointer;
}

.creative-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  border-color: var(--primary);
}

.creative-thumb {
  font-size: 48px;
  text-align: center;
  padding: 24px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.creative-card h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.creative-card .creative-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.creative-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
}

/* ===================== DEMOGRAPHICS ===================== */
.demo-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.demo-bar .demo-label {
  width: 80px;
  font-size: 13px;
  color: var(--text-muted);
}

.demo-bar .demo-track {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.demo-bar .demo-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  transition: width 0.5s ease;
}

.demo-legend {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 16px;
}

.demo-legend-item {
  text-align: center;
}

.demo-legend-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
}

.demo-legend-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.small {
  font-size: 11px;
}

/* ===================== FLASH MESSAGES ===================== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}

.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }

/* ===================== GRID LAYOUTS ===================== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--card-gap, 20px);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--card-gap, 20px);
}

@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ===================== RESPONSIVE ===================== */

/* ---- Mobile menu toggle button (hidden on desktop) ---- */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.mobile-menu-toggle:hover {
  background: var(--bg-card-hover);
}

/* ---- Sidebar overlay backdrop (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}
.sidebar-overlay.active {
  display: block;
}

/* ---- Desktop (default): sidebar 250px, full layout ---- */

/* ---- Small laptop / large tablet (<= 1024px) ---- */
@media (max-width: 1024px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 20px 24px;
  }
  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
  }
  .metric-card .metric-value {
    font-size: 24px;
  }
  .chart-container {
    height: 260px;
  }
}

/* ---- Tablet (<= 768px) ---- */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  /* Sidebar drawer behavior diatur oleh blok @media (max-width: 1024px) */
  .sidebar-header .logo-text,
  .sidebar-nav a span:not(.nav-icon):not(.nav-badge),
  .sidebar-nav .nav-section {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 64px 16px 24px 16px;
  }

  /* Page header stacks vertically */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header > *:last-child {
    width: 100%;
  }
  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .page-title {
    line-height: 1.2;
  }

  /* Metrics: 2 columns on tablet */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .metric-card {
    padding: 16px;
  }
  .metric-card .metric-value {
    font-size: 22px;
  }
  .metric-card .metric-label {
    font-size: 11px;
  }
  .metric-icon {
    font-size: 20px;
    top: 16px;
    right: 16px;
  }

  /* Cards less padding */
  .card {
    padding: 16px;
  }

  /* Charts shorter */
  .chart-container {
    height: 240px;
  }
  .chart-container-sm {
    height: 180px;
  }

  /* Tables: horizontal scroll with sticky first column hint */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    font-size: 12px;
  }
  table th, table td {
    padding: 8px 10px;
    white-space: nowrap;
  }

  /* Social grid: 1 column */
  .social-grid {
    grid-template-columns: 1fr;
  }

  /* Creatives grid: 1 column */
  .creatives-grid {
    grid-template-columns: 1fr;
  }

  /* Social stats wrap */
  .social-stats {
    gap: 4px;
  }
  .social-stat .stat-value {
    font-size: 16px;
  }

  /* Creative stats wrap */
  .creative-stats {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Buttons: full width on mobile context */
  .btn {
    font-size: 13px;
    padding: 10px 16px;
  }
  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Insight items: smaller */
  .insight-item {
    padding: 12px;
    gap: 12px;
  }
  .insight-icon {
    font-size: 20px;
  }
  .insight-content h4 {
    font-size: 13px;
  }
  .insight-content p {
    font-size: 12px;
  }

  /* Demo bars: narrower label */
  .demo-bar .demo-label {
    width: 60px;
    font-size: 11px;
  }

  /* Flex utils wrap */
  .flex-between,
  .flex-nowrap,
  [style*="display: flex"],
  [style*="display:flex"] {
    flex-wrap: wrap !important;
  }

  /* Override inline flex directions to stack on mobile */
  [style*="flex-direction: row"],
  [style*="flex-direction:row"] {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* Force inline gap/flex to wrap */
  [style*="display: flex"][style*="gap"],
  [style*="display:flex"][style*="gap"] {
    flex-wrap: wrap !important;
  }

  /* Inline justify-content override */
  [style*="justify-content: space-between"],
  [style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  /* Inline text-align center keep */
  [style*="text-align: center"] {
    text-align: center !important;
  }

  /* Inline max-width override for mobile */
  [style*="max-width: 700px"] {
    max-width: 100% !important;
  }

  /* Inline padding:60px -> smaller */
  [style*="padding: 60px"],
  [style*="padding:60px"] {
    padding: 24px 16px !important;
  }

  /* Force ALL inline flex containers to wrap on tablet/mobile */
  [style*="display: flex"],
  [style*="display:flex"] {
    flex-wrap: wrap !important;
  }

  /* Force ALL inline space-between to stack vertically */
  [style*="justify-content: space-between"],
  [style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
  }

  /* Force inline flex-center to stack */
  [style*="justify-content: center"],
  [style*="justify-content:center"] {
    flex-wrap: wrap !important;
    gap: 12px !important;
  }

  /* Override inline gap with smaller value */
  [style*="gap: 32px"],
  [style*="gap:32px"] { gap: 12px !important; }
  [style*="gap: 24px"],
  [style*="gap:24px"] { gap: 12px !important; }

  /* Settings inputs: full width on mobile */
  [style*="width: 120px"] { width: 100% !important; }
  [style*="width: 40px"] { width: 40px !important; text-align: center; }

  /* Page header buttons: full width stacked */
  .page-header .btn,
  .page-header a[class*="btn"] {
    width: 100% !important;
    justify-content: center !important;
    margin-bottom: 4px;
  }

  /* Card header: stack title and action */
  .card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px;
  }
  .card-header .btn,
  .card-header a[class*="btn"] {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Table: make it card-like on mobile with scroll */
  .table-container {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }

  /* Form inputs: full width */
  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100% !important;
  }
  [style*="width: 120px"] {
    width: 100% !important;
  }

  /* Alert/insight items: stack icon + content */
  .insight-item,
  [style*="display: flex; gap: 16px; padding: 16px"] {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* Detail tables (key-value): make first column narrower */
  [style] table td:first-child,
  .detail-table td:first-child {
    width: 40% !important;
    font-size: 12px !important;
  }

  /* Flex button groups: stack vertically */
  .flex.gap-2,
  .flex.gap-4 {
    flex-direction: column !important;
    width: 100%;
  }
  .flex.gap-2 .btn,
  .flex.gap-4 .btn,
  .flex.gap-2 a[class*="btn"],
  .flex.gap-4 a[class*="btn"] {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* ---- Mobile phone (<= 480px) ---- */
@media (max-width: 480px) {
  .main-content {
    padding: 60px 12px 20px 12px;
  }

  /* Metrics: 1 column on phone */
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .metric-card {
    padding: 14px;
  }
  .metric-card .metric-value {
    font-size: 20px;
  }

  .page-subtitle {
    font-size: 12px;
  }

  /* Cards minimal padding */
  .card {
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 10px;
  }

  /* Charts even shorter */
  .chart-container {
    height: 200px;
  }
  .chart-container-sm {
    height: 160px;
  }

  /* Extra: force button groups to full width stacked */
  .page-header > *:last-child,
  .page-header .flex {
    width: 100% !important;
  }
  .page-header .btn,
  .page-header .flex .btn,
  .page-header .flex a[class*="btn"] {
    width: 100% !important;
    justify-content: center !important;
    margin-bottom: 4px;
  }

  /* Card header actions: full width */
  .card-header .btn,
  .card-header a[class*="btn"] {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Table font super small */
  table th, table td {
    padding: 6px 8px !important;
  }

  /* Insight items: fully stacked */
  .insight-item {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px !important;
  }
  .insight-icon { font-size: 18px !important; }

  /* Table: even more compact */
  table {
    font-size: 11px;
  }
  table th, table td {
    padding: 6px 8px;
  }

  /* Social card compact */
  .social-card {
    padding: 16px;
  }
  .social-card .followers {
    font-size: 26px;
  }
  .social-card .platform-icon {
    font-size: 32px;
  }

  /* Buttons full width */
  .btn {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
  }
  .btn-sm {
    width: auto;
  }

  /* Hide nav badges on very small screens to save space */
  .nav-badge {
    font-size: 9px;
    padding: 1px 5px;
  }

  /* Flash messages */
  .flash {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* ---- Extra small (<= 360px) ---- */
@media (max-width: 360px) {
  .main-content {
    padding: 56px 8px 16px 8px;
  }
  .metric-card .metric-value {
    font-size: 18px;
  }
  table {
    font-size: 10px;
  }
  table th, table td {
    padding: 5px 6px;
  }
}

/* ---- Landscape phone ---- */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar-header {
    padding: 12px 16px;
  }
  .sidebar-nav {
    padding: 8px 12px;
  }
  .sidebar-nav a {
    padding: 8px 12px;
  }
  .chart-container {
    height: 160px;
  }
}

/* ---- Mobile map height ---- */
@media (max-width: 768px) {
  #map {
    height: 350px !important;
  }
}
@media (max-width: 480px) {
  #map {
    height: 280px !important;
  }
}

/* ---- Print ---- */
@media print {
  .sidebar, .mobile-menu-toggle, .sidebar-overlay,
  .btn, .page-header > *:last-child {
    display: none !important;
  }
  .main-content {
    margin-left: 0;
    padding: 0;
  }
  body {
    background: white;
    color: black;
  }
  .card {
    break-inside: avoid;
    border: 1px solid #ccc;
  }
}

/* ===================== UTILITY ===================== */
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; flex-wrap: wrap; }
.flex-nowrap { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.flex-center { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.w-full { width: 100%; }
.max-w-700 { max-width: 700px; }
.font-weight-600 { font-weight: 600; }
.font-size-11 { font-size: 11px; }
.font-size-12 { font-size: 12px; }
.font-size-13 { font-size: 13px; }
.font-size-14 { font-size: 14px; }
.text-decoration-none { text-decoration: none; }
.text-nowrap { white-space: nowrap; }

/* Detail table (key-value, two-column) */
.detail-table { margin-top: 16px; }
.detail-table td:first-child { color: var(--text-muted); width: 45%; }
.detail-table td { padding: 8px 12px; }

/* Alert item (replaces inline styles) */
.alert-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.alert-item.danger { border-left: 4px solid var(--danger); }
.alert-item.warning { border-left: 4px solid var(--warning); }
.alert-item.info { border-left: 4px solid var(--info); }
.alert-item-icon { font-size: 24px; flex-shrink: 0; }
.alert-item-body { flex: 1; min-width: 0; }
.alert-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.alert-item-title { font-size: 14px; font-weight: 600; }
.alert-item-msg { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.5; }
.alert-item-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.alert-tag { font-size: 12px; padding: 6px 12px; border-radius: var(--radius-sm); display: inline-block; }
.alert-tag-impact { color: var(--danger); background: var(--danger-bg); }
.alert-tag-rec { color: var(--primary-hover); background: rgba(99, 102, 241, 0.1); }
.alert-tag-meta { color: var(--text-muted); background: var(--bg); }

.insight-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }

.status-banner { text-align: center; padding: 16px; }
.status-banner .badge { font-size: 14px; padding: 8px 20px; }

.settings-input {
  width: 120px; padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}
.settings-checkbox { width: 20px; height: 20px; cursor: pointer; }
.settings-wa-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.health-rules-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.health-rule-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--bg);
}

.risk-protection-section {
  margin-bottom: 12px;
  padding: 0;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 20px;
  line-height: 1.25;
  margin-bottom: 6px;
}

.section-heading p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  max-width: 780px;
}

.risk-protection-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
}

.risk-protection-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  padding: 18px;
}

.risk-protection-panel h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.clean-list {
  list-style: none;
  display: grid;
  gap: 9px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.clean-list li {
  position: relative;
  padding-left: 16px;
}

.clean-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
}

.risk-disclaimer {
  margin-top: 16px;
  padding: 12px;
  border-left: 3px solid var(--warning);
  background: rgba(245, 158, 11, 0.08);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.sub-item { font-size: 11px; color: var(--text-dim); padding-left: 12px; }
.sub-sub-item { padding-left: 12px; font-size: 10px; }
.creative-stat-mini { font-size: 11px; }
.creative-stat-mini .stat-label { color: var(--text-muted); }

/* Chart canvas fill fix */
.chart-container canvas,
.chart-container-sm canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Alert banner in dashboard/meta_monitor */
.alert-banner {
  border-left: 4px solid var(--warning);
}
.alert-banner.danger { border-left-color: var(--danger); }

/* Card with left border accent */
.card-accent-success { border-left: 4px solid var(--success); }
.card-accent-primary { border-left: 4px solid var(--primary); }
.card-accent-danger { border-left: 4px solid var(--danger); }
.card-accent-warning { border-left: 4px solid var(--warning); }

/* Link styled */
.link-primary { color: var(--primary-hover); text-decoration: none; font-weight: 600; }

/* ===================== AUTH ===================== */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg) url("../images/wallpaper.png") center / cover no-repeat fixed;
}

.auth-shell {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 560px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--bg-card);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 42px;
  background:
    linear-gradient(180deg, rgba(15, 17, 23, 0.35), rgba(15, 17, 23, 0.82)),
    url("../images/wallpaper.png") center / cover no-repeat;
}

.auth-kicker {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.auth-hero h1 {
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.05;
  max-width: 420px;
}

.auth-hero p {
  margin-top: 14px;
  max-width: 460px;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.6;
  font-size: clamp(13px, 2.5vw, 14px);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 42px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.auth-logo-mark {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  flex: 0 0 auto;
}

.auth-logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

.auth-brand h2 {
  font-size: clamp(18px, 3.5vw, 22px);
  line-height: 1.2;
}

.auth-brand p,
.auth-help p,
.auth-footer {
  color: var(--text-muted);
  font-size: 13px;
}

.auth-form {
  margin-top: 8px;
}

.auth-form .form-group {
  margin-bottom: 16px;
}

.auth-form input {
  min-height: 46px;
}

.auth-submit {
  min-height: 46px;
  margin-top: 4px;
}

.auth-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.auth-footer a {
  color: var(--primary-hover);
  text-decoration: none;
  font-weight: 600;
}

.auth-help {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.auth-help code {
  display: block;
  margin: 8px 0 12px;
  padding: 10px;
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  overflow-x: auto;
  font-size: 12px;
}

@media (max-width: 820px) {
  .auth-body {
    padding: 16px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .auth-hero {
    padding: 28px;
    min-height: 200px;
  }

  .auth-panel {
    padding: 28px;
  }
}

@media (max-width: 420px) {
  .auth-hero {
    min-height: 160px;
    padding: 22px;
  }

  .auth-panel {
    padding: 22px;
  }

  .auth-brand {
    align-items: flex-start;
  }
}

/* ===================== RESPONSIVE POLISH ===================== */
html {
  overflow-x: hidden;
}

body,
.main-content,
.card,
.metric-card,
.social-card,
.creative-card,
.insight-item,
.alert-item {
  min-width: 0;
}

/* page-header styling sudah ada di line 161 — tidak perlu duplikat */

.page-title,
.card-title,
.metric-card .metric-value,
.social-card .platform-name,
.creative-card h4 {
  overflow-wrap: anywhere;
}

.btn,
.badge,
.nav-badge,
.alert-tag {
  white-space: nowrap;
}

.sidebar-nav a {
  min-height: 42px;
}

.sidebar-nav a span:not(.nav-icon):not(.nav-badge) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-container {
  max-width: 100%;
}

.table-container table {
  width: 100%;
}

/* Tabel lebar (banyak kolom) perlu horizontal scroll di mobile */
.table-wide table {
  min-width: 760px;
}

/* Baris total di akhir tabel */
.table-container tfoot {
  border-top: 2px solid var(--border);
}
.table-container tfoot td {
  font-weight: 700;
  background: var(--bg-card-hover, var(--bg));
}

td,
th {
  vertical-align: top;
}

td {
  overflow-wrap: anywhere;
}

.detail-table,
.grid-2 table,
.card > table {
  table-layout: fixed;
}

.chart-container,
.chart-container-sm {
  min-width: 0;
}

/* Large desktop: keep dense dashboard readable without stretching too far. */
@media (min-width: 1440px) {
  .main-content {
    padding: 32px 0;
  }

  .page-header {
    margin-bottom: var(--page-gap-y, 20px);
  }

  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .social-grid,
  .creatives-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

/* Laptop and tablet landscape: slightly slimmer navigation, compact content. */
@media (min-width: 769px) and (max-width: 1199px) {
  .sidebar {
    width: 220px;
  }

  .main-content {
    width: calc(100% - 220px);
    margin-left: 220px;
    padding: 20px 0;
  }

  .sidebar-header {
    padding: 20px 16px;
  }

  .sidebar-nav {
    padding: 14px 10px;
  }

  .sidebar-nav a {
    gap: 10px;
    padding: 10px;
  }

  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .social-grid,
  .creatives-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Tablet portrait: drawer navigation, two-column summaries, scrollable data. */
@media (min-width: 481px) and (max-width: 768px) {
  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 72px 18px 24px;
}

/* Sidebar width variable — pakai .sidebar di line 42 untuk styling lengkap */

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2,
  .grid-3,
  .social-grid,
  .creatives-grid,
  .risk-protection-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    flex-direction: column;
  }

  .page-header .btn,
  .page-header a[class*="btn"],
  .card-header .btn,
  .card-header a[class*="btn"] {
    width: auto !important;
  }

}

/* Phone: one clear column, full-width actions, tighter charts and cards. */
@media (max-width: 480px) {
  .mobile-menu-toggle {
    top: 12px;
    left: 12px;
    width: 42px;
    height: 42px;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 64px 12px 20px;
  }

  .sidebar {
    width: min(288px, 88vw);
  }

  .sidebar-header {
    padding: 18px 16px;
  }

  .sidebar-nav {
    padding: 12px 10px 20px;
  }

  .page-header {
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-header > div:first-child,
  .page-header > div:last-child:not(:first-child),
  .card-header > div:last-child:not(:first-child) {
    flex: 1 1 100%;
    width: 100%;
  }

  .page-header > div:last-child:not(:first-child),
  .card-header > div:last-child:not(:first-child) {
    justify-content: stretch;
  }

  .page-header .btn,
  .page-header a[class*="btn"],
  .card-header .btn,
  .card-header a[class*="btn"],
  .flex.gap-2 .btn,
  .flex.gap-4 .btn,
  .flex.gap-2 a[class*="btn"],
  .flex.gap-4 a[class*="btn"] {
    width: 100% !important;
  }

  .metrics-grid,
  .grid-2,
  .grid-3,
  .social-grid,
  .creatives-grid,
  .health-rules-grid,
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .metric-card,
  .card,
  .social-card,
  .creative-card {
    padding: 14px;
  }

  .chart-container {
    height: 220px;
  }

  .chart-container-sm {
    height: 180px;
  }

  .table-container {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .detail-table,
  .grid-2 table,
  .card > table {
    table-layout: auto;
  }

  .detail-table td,
  .grid-2 table td,
  .card > table td {
    display: block;
    width: 100% !important;
    padding: 6px 0;
  }

  .detail-table tr,
  .grid-2 table tr,
  .card > table tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }

  .social-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .demo-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .demo-bar .demo-label {
    width: auto;
  }

  .demo-bar .demo-track {
    width: 100%;
  }

  .empty-state {
    padding: 36px 12px;
  }
}

/* BOT AI status chip */
.bot-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
@media (max-width: 768px) {
  .bot-status-chip {
    width: 100%;
    white-space: normal;
    text-align: center;
  }
}

/* ===================== HIDDEN SCROLLBAR (scrollable but clean) ===================== */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* ===================== NOTION-STYLE DASHBOARD TEMPLATE ===================== */
.notion-dashboard {
  --notion-bg: #f7f6f3;
  --notion-surface: #ffffff;
  --notion-surface-soft: #fbfaf8;
  --notion-border: #e6e3dc;
  --notion-text: #2f3437;
  --notion-muted: #787774;
  --notion-accent: #2383e2;
  --notion-hover: #f1f1ef;
  background: var(--notion-bg);
  color: var(--notion-text);
  border: 1px solid var(--notion-border);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: none;
  margin: 0;
  box-shadow: 0 1px 2px rgba(15, 15, 15, 0.04);
}

.notion-dashboard .notion-page-header {
  background: transparent;
  border-bottom: 1px solid var(--notion-border);
  padding-bottom: 16px;
  margin-bottom: 18px;
}

.notion-dashboard .page-title {
  color: var(--notion-text);
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: -0.04em;
  font-weight: 700;
}

.notion-dashboard .page-subtitle {
  color: var(--notion-muted);
  margin-top: 6px;
  font-size: 14px;
}

.notion-dashboard .metrics-grid {
  gap: 12px;
  margin-bottom: 16px;
}

.notion-dashboard .metric-card,
.notion-dashboard .card {
  background: var(--notion-surface);
  border: 1px solid var(--notion-border) !important;
  border-radius: 12px;
  box-shadow: none;
  color: var(--notion-text);
}

.notion-dashboard .metric-card {
  padding: 16px;
  min-height: 118px;
  position: relative;
}

.notion-dashboard .metric-card:hover,
.notion-dashboard .card:hover {
  background: var(--notion-surface-soft);
  transform: none;
  box-shadow: 0 1px 4px rgba(15, 15, 15, 0.05);
}

.notion-dashboard .metric-label {
  color: var(--notion-muted);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.notion-dashboard .metric-value {
  color: var(--notion-text);
  font-size: 28px;
  letter-spacing: -0.03em;
  margin-top: 10px;
}

.notion-dashboard .metric-change,
.notion-dashboard .text-muted {
  color: var(--notion-muted) !important;
}

.notion-dashboard .metric-icon {
  opacity: 0.18;
  right: 16px;
  top: 14px;
}

.notion-dashboard .card {
  margin-bottom: 14px;
  overflow: hidden;
}

.notion-dashboard .card-header {
  border-bottom: 1px solid var(--notion-border);
  background: var(--notion-surface-soft);
  padding: 14px 16px;
}

.notion-dashboard .card-title {
  color: var(--notion-text);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.notion-dashboard .table-container {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.notion-dashboard table {
  background: var(--notion-surface);
  color: var(--notion-text);
}

.notion-dashboard th {
  background: var(--notion-surface-soft);
  color: var(--notion-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--notion-border);
}

.notion-dashboard td {
  border-bottom: 1px solid var(--notion-border);
  color: var(--notion-text);
}

.notion-dashboard tbody tr:hover {
  background: var(--notion-hover);
}

.notion-dashboard a {
  color: var(--notion-accent) !important;
}

.notion-dashboard .btn-outline {
  background: var(--notion-surface);
  border-color: var(--notion-border);
  color: var(--notion-text) !important;
  box-shadow: none;
}

.notion-dashboard .btn-outline:hover {
  background: var(--notion-hover);
  color: var(--notion-text) !important;
}

.notion-dashboard .badge {
  border-radius: 999px;
  font-weight: 500;
}

.notion-dashboard canvas {
  max-width: 100%;
}

.notion-dashboard .grid-2,
.notion-dashboard .grid-3 {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .notion-dashboard {
    padding: 16px;
    border-radius: 14px;
  }

  .notion-dashboard .page-title {
    font-size: 28px;
  }
}

/* ===================== SIDEBAR + PAGE LAYOUT POLISH ===================== */
.sidebar-header {
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.sidebar-header .logo {
  gap: 10px;
  min-width: 0;
}

.sidebar-header .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border-color: var(--border);
  flex: 0 0 36px;
}

.sidebar-header .logo-text {
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-header .logo-text span {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  padding: 10px 10px 18px;
}

.sidebar-nav .nav-section {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  padding: 14px 10px 6px;
  margin-top: 2px;
  border-top: 1px solid transparent;
}

.sidebar-nav .nav-section:not(:first-child) {
  margin-top: 8px;
  border-top-color: #efede8;
}

.sidebar-nav a {
  min-height: 36px;
  padding: 8px 10px;
  margin-bottom: 3px;
  gap: 10px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  min-width: 0;
}

.sidebar-nav a .nav-icon {
  width: 22px;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
}

.sidebar-nav a span:not(.nav-icon):not(.nav-badge) {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: #f1f1ef;
  color: var(--text);
}

.sidebar-nav a.active {
  background: #f1f1ef;
  color: var(--text);
  font-weight: 650;
  box-shadow: inset 3px 0 0 #2383e2;
}

.sidebar-nav a .nav-badge {
  margin-left: auto;
  flex: 0 0 auto;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.main-content > * {
  min-width: 0;
}

@media (max-width: 1024px) {
  .main-content {
    padding: 18px 18px 24px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: min(288px, 86vw);
  }

  .sidebar-header {
    padding: 14px 12px;
  }

  .sidebar-nav {
    padding: 8px 8px 16px;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 64px 14px 22px;
  }
}

/* ===================== FLAT MAIN CONTENT — removed, pakai standar ===================== */

/* ===================== SECTION LIGHT / DARK MODE ALIGNMENT ===================== */
body.theme-light {
  background: var(--bg);
  color: var(--text);
}

body.theme-dark {
  background: var(--bg);
  color: var(--text);
}

body.theme-light .main-content {
  background: var(--bg);
}

body.theme-dark .main-content {
  background: var(--bg);
}

.section-light,
.notion-dashboard,
.notion-dashboard .card,
.notion-dashboard .metric-card,
.notion-dashboard .table-container,
.notion-dashboard .empty-state,
.notion-dashboard .chart-container,
.notion-dashboard .chart-container-sm {
  color-scheme: light;
}

.section-dark,
body.theme-dark .card,
body.theme-dark .metric-card,
body.theme-dark .table-container,
body.theme-dark .empty-state,
body.theme-dark .chart-container,
body.theme-dark .chart-container-sm {
  color-scheme: dark;
}

.notion-dashboard,
.notion-dashboard .card,
.notion-dashboard .metric-card,
.notion-dashboard .table-container,
.notion-dashboard .empty-state,
.notion-dashboard .chart-container,
.notion-dashboard .chart-container-sm,
.notion-dashboard .social-card,
.notion-dashboard .creative-card,
.notion-dashboard .insight-item {
  background-color: var(--notion-surface);
  color: var(--notion-text);
  border-color: var(--notion-border);
}

.notion-dashboard .chart-container,
.notion-dashboard .chart-container-sm {
  border: 1px solid var(--notion-border);
  border-radius: 10px;
  padding: 10px;
}

.notion-dashboard .empty-state {
  border: 1px dashed var(--notion-border);
  border-radius: 10px;
}

.notion-dashboard .empty-state-icon,
.notion-dashboard .metric-change,
.notion-dashboard .text-muted,
.notion-dashboard .empty-state p,
.notion-dashboard .empty-state h3[style] {
  color: var(--notion-muted) !important;
}

.notion-dashboard input,
.notion-dashboard select,
.notion-dashboard textarea {
  background: #ffffff;
  color: var(--notion-text);
  border-color: var(--notion-border);
}

body.theme-dark .notion-dashboard {
  color-scheme: light;
}

body.theme-dark .card:not(.notion-dashboard .card),
body.theme-dark .metric-card:not(.notion-dashboard .metric-card),
body.theme-dark .table-container:not(.notion-dashboard .table-container) {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}

body.theme-dark table:not(.notion-dashboard table) {
  background: var(--bg-card);
  color: var(--text);
}

body.theme-dark th:not(.notion-dashboard th) {
  background: var(--bg-card-hover);
  color: var(--text-muted);
}

body.theme-dark td:not(.notion-dashboard td) {
  color: var(--text);
  border-color: var(--border);
}

/* ===================== STANDARD PAGE CONTAINER FOR NON-DASHBOARD PAGES ===================== */
body.theme-dark .main-content > :not(script):not(style) {
  margin-left: 0;
  margin-right: 0;
}

body.theme-dark .main-content > .page-header {
  margin-top: 22px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

body.theme-dark .main-content > .metrics-grid,
body.theme-dark .main-content > .grid-2,
body.theme-dark .main-content > .grid-3,
body.theme-dark .main-content > .social-grid,
body.theme-dark .main-content > .creatives-grid {
  width: 100%;
}

body.theme-dark .main-content > .card,
body.theme-dark .main-content > .table-container,
body.theme-dark .main-content > .settings-card,
body.theme-dark .main-content > .status-card,
body.theme-dark .main-content > .integration-card,
body.theme-dark .main-content > .filter-bar {
  width: 100%;
}

body.theme-dark .card,
body.theme-dark .table-container,
body.theme-dark .metric-card,
body.theme-dark .settings-card,
body.theme-dark .status-card,
body.theme-dark .integration-card,
body.theme-dark .filter-bar {
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: none;
}

body.theme-dark .card-header {
  border-bottom: 1px solid var(--border);
}

body.theme-dark .table-container {
  overflow-x: auto;
  overflow-y: hidden;
}

body.theme-dark .table-container table {
  width: 100%;
}

body.theme-dark .main-content > .empty-state {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

@media (max-width: 1024px) {
  body.theme-dark .main-content > :not(script):not(style) {
    margin-left: 0;
    margin-right: 0;
  }

  body.theme-dark .main-content > .metrics-grid,
  body.theme-dark .main-content > .grid-2,
  body.theme-dark .main-content > .grid-3,
  body.theme-dark .main-content > .social-grid,
  body.theme-dark .main-content > .creatives-grid,
  body.theme-dark .main-content > .card,
  body.theme-dark .main-content > .table-container,
  body.theme-dark .main-content > .settings-card,
  body.theme-dark .main-content > .status-card,
  body.theme-dark .main-content > .integration-card,
  body.theme-dark .main-content > .filter-bar,
  body.theme-dark .main-content > .empty-state {
    width: 100%;
  }
}

@media (max-width: 768px) {
  body.theme-dark .main-content > :not(script):not(style) {
    margin-left: 0;
    margin-right: 0;
  }

  body.theme-dark .main-content > .page-header {
    margin-top: 14px;
  }

  body.theme-dark .main-content > .metrics-grid,
  body.theme-dark .main-content > .grid-2,
  body.theme-dark .main-content > .grid-3,
  body.theme-dark .main-content > .social-grid,
  body.theme-dark .main-content > .creatives-grid,
  body.theme-dark .main-content > .card,
  body.theme-dark .main-content > .table-container,
  body.theme-dark .main-content > .settings-card,
  body.theme-dark .main-content > .status-card,
  body.theme-dark .main-content > .integration-card,
  body.theme-dark .main-content > .filter-bar,
  body.theme-dark .main-content > .empty-state {
    width: 100%;
  }
}

/* ===================== RESPONSIVE MOBILE/TABLET DRAWER POLISH ===================== */
.mobile-topbar {
  display: none;
}

body.drawer-open {
  overflow: hidden;
}

@media (max-width: 1024px) {
  .mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 180;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 1px 8px rgba(15, 15, 15, 0.06);
  }

  body.theme-dark .mobile-topbar {
    background: rgba(15, 17, 23, 0.92);
    color: var(--text);
    border-bottom-color: var(--border);
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.24);
  }

  .mobile-menu-toggle {
    position: static;
    display: inline-flex;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    box-shadow: none;
    font-size: 20px;
    line-height: 1;
  }

  body.theme-dark .mobile-menu-toggle {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--border);
  }

  .mobile-menu-toggle:active {
    transform: scale(0.98);
  }

  .mobile-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .mobile-topbar-brand img {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #ffffff;
    object-fit: contain;
  }

  .mobile-topbar-brand div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
  }

  .mobile-topbar-brand strong {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-topbar-brand span {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.theme-dark .mobile-topbar-brand span {
    color: var(--text-muted);
  }

  .sidebar {
    width: min(320px, 88vw);
    max-width: 88vw;
    transform: translateX(-104%);
    transition: transform 0.24s ease, box-shadow 0.24s ease;
    z-index: 220;
    border-radius: 0 16px 16px 0;
    box-shadow: none;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.24);
  }

  .sidebar-header {
    display: none;
  }

  .sidebar-nav {
    padding: 8px 8px 18px;
  }

  .sidebar-nav .nav-section {
    padding: 12px 10px 6px;
    margin-top: 4px;
    font-size: 10px;
  }

  .sidebar-nav a {
    min-height: 40px;
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 13px;
  }

  .sidebar-nav a .nav-icon {
    width: 24px;
    min-width: 24px;
    height: 24px;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 210;
    background: rgba(15, 15, 15, 0.48);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding-top: 60px;
  }

  .notion-dashboard {
    min-height: calc(100vh - 60px);
  }

  body.theme-dark .main-content > .page-header {
    margin-top: 16px;
  }
}

@media (max-width: 768px) {
  .mobile-topbar {
    height: 58px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .mobile-menu-toggle {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }

  .mobile-topbar-brand img {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .sidebar {
    width: min(300px, 90vw);
    max-width: 90vw;
  }

  .main-content {
    padding-top: 58px;
  }

  .notion-dashboard {
    min-height: calc(100vh - 58px);
  }
}

@media (max-width: 480px) {
  .mobile-topbar {
    height: 56px;
    gap: 10px;
  }

  .mobile-topbar-brand strong {
    font-size: 13px;
  }

  .mobile-topbar-brand span {
    font-size: 10.5px;
  }

  .sidebar {
    width: min(292px, 92vw);
    max-width: 92vw;
    border-radius: 0 14px 14px 0;
  }

  .sidebar-nav a {
    min-height: 39px;
    font-size: 12.5px;
  }

  .main-content {
    padding-top: 56px;
  }

  .notion-dashboard {
    min-height: calc(100vh - 56px);
  }
}

/* ===================== GLOBAL THEME TOGGLE ===================== */
.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.theme-toggle:active {
  transform: scale(0.98);
}

.theme-toggle-mobile {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
}

body.theme-dark .theme-toggle {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}

body.theme-dark .theme-toggle:hover {
  background: var(--bg-card-hover);
}

body.theme-light:not(.theme-dark) {
  --bg: #f7f6f3;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f1ef;
  --border: #e6e3dc;
  --text: #2f3437;
  --text-muted: #6f6e69;
  --text-dim: #9ca3af;
  --page-surface-light: #ffffff;
  --page-surface-soft-light: #fbfaf8;
  --page-border-light: #e6e3dc;
  --page-text-light: #2f3437;
  --page-muted-light: #787774;
  background: var(--page-bg-light);
  color: var(--page-text-light);
}

body.theme-light .main-content {
  background: var(--page-bg-light, var(--bg));
  color: var(--page-text-light, var(--text));
}

body.theme-light .page-title,
body.theme-light .card-title,
body.theme-light .metric-value,
body.theme-light td {
  color: var(--page-text-light, var(--text));
}

body.theme-light .page-subtitle,
body.theme-light .text-muted,
body.theme-light .metric-label,
body.theme-light .metric-change,
body.theme-light th {
  color: var(--page-muted-light, var(--text-muted)) !important;
}

body.theme-light .card,
body.theme-light .metric-card,
body.theme-light .table-container,
body.theme-light .settings-card,
body.theme-light .status-card,
body.theme-light .integration-card,
body.theme-light .filter-bar,
body.theme-light .empty-state,
body.theme-light .chart-container,
body.theme-light .chart-container-sm,
body.theme-light .social-card,
body.theme-light .creative-card,
body.theme-light .insight-item {
  background: var(--page-surface-light, #ffffff);
  color: var(--page-text-light, #2f3437);
  border-color: var(--page-border-light, #e6e3dc) !important;
  box-shadow: none;
}

body.theme-light .card-header,
body.theme-light th {
  background: var(--page-surface-soft-light, #fbfaf8);
  border-color: var(--page-border-light, #e6e3dc);
}

body.theme-light table {
  background: var(--page-surface-light, #ffffff);
  color: var(--page-text-light, #2f3437);
}

body.theme-light td {
  border-color: var(--page-border-light, #e6e3dc);
}

body.theme-light tbody tr:hover {
  background: #f1f1ef;
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea {
  background: #ffffff;
  color: var(--page-text-light, #2f3437);
  border-color: var(--page-border-light, #e6e3dc);
}

body.theme-light .main-content > :not(script):not(style):not(.notion-dashboard) {
  margin-left: 0;
  margin-right: 0;
}

body.theme-light .main-content > .notion-dashboard {
  margin-left: 0;
  margin-right: 0;
}

body.theme-light .main-content > .page-header {
  margin-top: 22px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--page-border-light, #e6e3dc);
}

body.theme-light .main-content > .metrics-grid,
body.theme-light .main-content > .grid-2,
body.theme-light .main-content > .grid-3,
body.theme-light .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-light .main-content > .card,
body.theme-light .main-content > .table-container,
body.theme-light .main-content > .settings-card,
body.theme-light .main-content > .status-card,
body.theme-light .main-content > .integration-card,
body.theme-light .main-content > .filter-bar,
body.theme-light .main-content > .empty-state {
  width: 100%;
}

body.theme-light .table-container {
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 1024px) {
  body.theme-light .main-content > :not(script):not(style):not(.notion-dashboard) {
    margin-left: 0;
    margin-right: 0;
  }

  body.theme-light .main-content > .metrics-grid,
  body.theme-light .main-content > .grid-2,
  body.theme-light .main-content > .grid-3,
  body.theme-light .main-content > .social-grid,
  body.theme-light .main-content > .creatives-grid,
  body.theme-light .main-content > .card,
  body.theme-light .main-content > .table-container,
  body.theme-light .main-content > .settings-card,
  body.theme-light .main-content > .status-card,
  body.theme-light .main-content > .integration-card,
  body.theme-light .main-content > .filter-bar,
  body.theme-light .main-content > .empty-state {
    width: 100%;
  }
}

@media (max-width: 768px) {
  body.theme-light .main-content > :not(script):not(style):not(.notion-dashboard) {
    margin-left: 0;
    margin-right: 0;
  }

  body.theme-light .main-content > .metrics-grid,
  body.theme-light .main-content > .grid-2,
  body.theme-light .main-content > .grid-3,
  body.theme-light .main-content > .social-grid,
  body.theme-light .main-content > .creatives-grid,
  body.theme-light .main-content > .card,
  body.theme-light .main-content > .table-container,
  body.theme-light .main-content > .settings-card,
  body.theme-light .main-content > .status-card,
  body.theme-light .main-content > .integration-card,
  body.theme-light .main-content > .filter-bar,
  body.theme-light .main-content > .empty-state {
    width: 100%;
  }

  .theme-toggle-mobile {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }
}

/* ===================== CLEAR THEME TOGGLE UI ===================== */

/* Hide section Tampilan + toggle sidebar di mobile/tablet — sudah ada di header */
@media (max-width: 1024px) {
  .nav-section-tampilan,
  .theme-toggle-sidebar {
    display: none !important;
  }
}

.theme-toggle-sidebar {
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 20px);
  margin: 8px 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.theme-toggle-sidebar:hover {
  background: var(--bg-card-hover);
}

.theme-toggle-sidebar .theme-toggle-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(99, 102, 241, 0.15);
  font-size: 16px;
}

.theme-toggle-text {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  line-height: 1.15;
}

.theme-toggle-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.theme-toggle-subtitle {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
}

body.theme-dark .theme-toggle-sidebar {
  background: var(--bg-card);
}

body.theme-dark .theme-toggle-sidebar .theme-toggle-icon {
  background: rgba(99, 102, 241, 0.18);
}

body.theme-dark .theme-toggle-title {
  color: var(--text);
}

body.theme-dark .theme-toggle-subtitle {
  color: var(--text-muted);
}

.theme-toggle-mobile {
  width: auto;
  min-width: 82px;
  height: 38px;
  padding: 0 10px;
  gap: 6px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.theme-toggle-mobile .theme-toggle-icon {
  font-size: 15px;
  line-height: 1;
}

.theme-toggle-mobile .theme-toggle-label {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
}

@media (max-width: 480px) {
  .theme-toggle-mobile {
    min-width: 74px;
    height: 36px;
    padding: 0 9px;
    font-size: 12px;
  }

  .theme-toggle-mobile .theme-toggle-label {
    font-size: 11px;
  }
}

/* ===================== THEME-AWARE SIDEBAR ===================== */
body.theme-light .sidebar {
  background: var(--bg-card);
  border-right-color: var(--border);
  box-shadow: 1px 0 0 rgba(15, 15, 15, 0.02);
}

body.theme-light .sidebar-header {
  background: var(--bg-card);
  border-bottom-color: var(--border);
}

body.theme-light .sidebar-header .logo-text,
body.theme-light .sidebar-nav a.active,
body.theme-light .sidebar-nav a:hover {
  color: var(--text);
}

body.theme-light .sidebar-header .logo-text span,
body.theme-light .sidebar-nav .nav-section,
body.theme-light .sidebar-nav a {
  color: var(--text-muted);
}

body.theme-light .sidebar-nav .nav-section:not(:first-child) {
  border-top-color: #efede8;
}

body.theme-light .sidebar-nav a:hover,
body.theme-light .sidebar-nav a.active {
  background: #f1f1ef;
}

body.theme-light .sidebar-nav a.active {
  box-shadow: inset 3px 0 0 #2383e2;
}

body.theme-dark .sidebar {
  background: #0f1117;
  border-right-color: #252936;
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.03);
}

body.theme-dark .sidebar-header {
  background: #0f1117;
  border-bottom-color: #252936;
}

body.theme-dark .sidebar-header .logo-icon {
  background: #151923;
  border-color: #2d3342;
}

body.theme-dark .sidebar-header .logo-text {
  color: #f3f4f6;
}

body.theme-dark .sidebar-header .logo-text span {
  color: #9ca3af;
}

body.theme-dark .sidebar-nav .nav-section {
  color: #8b93a7;
}

body.theme-dark .sidebar-nav .nav-section:not(:first-child) {
  border-top-color: #252936;
}

body.theme-dark .sidebar-nav a {
  color: #c4cad8;
}

body.theme-dark .sidebar-nav a:hover {
  background: #171b25;
  color: #ffffff;
}

body.theme-dark .sidebar-nav a.active {
  background: #1b2230;
  color: #ffffff;
  box-shadow: inset 3px 0 0 #60a5fa;
}

body.theme-dark .sidebar-nav a .nav-badge {
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}

@media (max-width: 1024px) {
  body.theme-light .sidebar.open {
    box-shadow: 18px 0 40px rgba(0, 0, 0, 0.18);
  }

  body.theme-dark .sidebar.open {
    box-shadow: 18px 0 44px rgba(0, 0, 0, 0.48);
  }
}

/* ===================== THEME-AWARE DASHBOARD CONTAINERS ===================== */
body.theme-light .notion-dashboard {
  --notion-bg: #f7f6f3;
  --notion-surface: #ffffff;
  --notion-surface-soft: #fbfaf8;
  --notion-border: #e6e3dc;
  --notion-text: #2f3437;
  --notion-muted: #787774;
  background: var(--notion-bg);
  color: var(--notion-text);
  color-scheme: light;
}

body.theme-dark .notion-dashboard {
  --notion-bg: #0b0f17;
  --notion-surface: #111827;
  --notion-surface-soft: #151e2d;
  --notion-border: #263244;
  --notion-text: #f3f4f6;
  --notion-muted: #a1a8b7;
  background: var(--notion-bg);
  color: var(--notion-text);
  color-scheme: dark;
}

body.theme-light .notion-dashboard .notion-page-header,
body.theme-light .notion-dashboard .card,
body.theme-light .notion-dashboard .metric-card,
body.theme-light .notion-dashboard .table-container,
body.theme-light .notion-dashboard .empty-state,
body.theme-light .notion-dashboard .chart-container,
body.theme-light .notion-dashboard .chart-container-sm {
  background: var(--notion-surface);
  color: var(--notion-text);
  border-color: var(--notion-border) !important;
}

body.theme-dark .notion-dashboard .notion-page-header,
body.theme-dark .notion-dashboard .card,
body.theme-dark .notion-dashboard .metric-card,
body.theme-dark .notion-dashboard .table-container,
body.theme-dark .notion-dashboard .empty-state,
body.theme-dark .notion-dashboard .chart-container,
body.theme-dark .notion-dashboard .chart-container-sm {
  background: var(--notion-surface);
  color: var(--notion-text);
  border-color: var(--notion-border) !important;
  box-shadow: none;
}

body.theme-light .notion-dashboard .card-header,
body.theme-light .notion-dashboard th {
  background: var(--notion-surface-soft);
  border-color: var(--notion-border);
}

body.theme-dark .notion-dashboard .card-header,
body.theme-dark .notion-dashboard th {
  background: var(--notion-surface-soft);
  color: var(--notion-muted) !important;
  border-color: var(--notion-border);
}

body.theme-light .notion-dashboard .page-title,
body.theme-light .notion-dashboard .card-title,
body.theme-light .notion-dashboard .metric-value,
body.theme-light .notion-dashboard td {
  color: var(--notion-text);
}

body.theme-dark .notion-dashboard .page-title,
body.theme-dark .notion-dashboard .card-title,
body.theme-dark .notion-dashboard .metric-value,
body.theme-dark .notion-dashboard td {
  color: var(--notion-text);
}

body.theme-light .notion-dashboard .page-subtitle,
body.theme-light .notion-dashboard .text-muted,
body.theme-light .notion-dashboard .metric-label,
body.theme-light .notion-dashboard .metric-change {
  color: var(--notion-muted) !important;
}

body.theme-dark .notion-dashboard .page-subtitle,
body.theme-dark .notion-dashboard .text-muted,
body.theme-dark .notion-dashboard .metric-label,
body.theme-dark .notion-dashboard .metric-change {
  color: var(--notion-muted) !important;
}

body.theme-light .notion-dashboard table {
  background: var(--notion-surface);
  color: var(--notion-text);
}

body.theme-dark .notion-dashboard table {
  background: var(--notion-surface);
  color: var(--notion-text);
}

body.theme-light .notion-dashboard td,
body.theme-dark .notion-dashboard td {
  border-color: var(--notion-border);
}

body.theme-light .notion-dashboard tbody tr:hover {
  background: #f1f1ef;
}

body.theme-dark .notion-dashboard tbody tr:hover {
  background: #1b2536;
}

/* ===================== BALANCED PAGE MARGINS ===================== */
.main-content > :not(script):not(style) {
  margin-left: 24px;
  margin-right: 24px;
}

.main-content > :not(script):not(style):first-child {
  margin-top: 20px;
}

.main-content > :not(script):not(style):last-child {
  margin-bottom: 28px;
}

.main-content > .notion-dashboard,
.main-content > .metrics-grid,
.main-content > .grid-2,
.main-content > .grid-3,
.main-content > .social-grid,
.main-content > .creatives-grid,
.main-content > .card,
.main-content > .table-container,
.main-content > .settings-card,
.main-content > .status-card,
.main-content > .integration-card,
.main-content > .filter-bar,
.main-content > .empty-state {
  width: calc(100% - 48px);
}

.main-content > .notion-dashboard {
  margin-top: 20px;
  margin-bottom: 28px;
}

@media (max-width: 1024px) {
  .main-content > :not(script):not(style) {
    margin-left: 18px;
    margin-right: 18px;
  }

  .main-content > :not(script):not(style):first-child {
    margin-top: 18px;
  }

  .main-content > :not(script):not(style):last-child {
    margin-bottom: 24px;
  }

  .main-content > .notion-dashboard,
  .main-content > .metrics-grid,
  .main-content > .grid-2,
  .main-content > .grid-3,
  .main-content > .social-grid,
  .main-content > .creatives-grid,
  .main-content > .card,
  .main-content > .table-container,
  .main-content > .settings-card,
  .main-content > .status-card,
  .main-content > .integration-card,
  .main-content > .filter-bar,
  .main-content > .empty-state {
    width: calc(100% - 36px);
  }
}

@media (max-width: 768px) {
  .main-content > :not(script):not(style) {
    margin-left: 14px;
    margin-right: 14px;
  }

  .main-content > :not(script):not(style):first-child {
    margin-top: 14px;
  }

  .main-content > :not(script):not(style):last-child {
    margin-bottom: 20px;
  }

  .main-content > .notion-dashboard,
  .main-content > .metrics-grid,
  .main-content > .grid-2,
  .main-content > .grid-3,
  .main-content > .social-grid,
  .main-content > .creatives-grid,
  .main-content > .card,
  .main-content > .table-container,
  .main-content > .settings-card,
  .main-content > .status-card,
  .main-content > .integration-card,
  .main-content > .filter-bar,
  .main-content > .empty-state {
    width: calc(100% - 28px);
  }
}

  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
}

/* Desktop wide */
@media (min-width: 1440px) {
  :root {
    --sidebar-width: 220px;
    --page-gutter-x: 32px;
    --page-gap-y: 20px;
    --page-top-y: 24px;
    --page-bottom-y: 36px;
    --card-gap: 20px;
  }
}

/* Laptop */
@media (min-width: 1025px) and (max-width: 1439px) {
  :root {
    --sidebar-width: 220px;
    --page-gutter-x: 24px;
    --page-gap-y: 18px;
    --page-top-y: 22px;
    --page-bottom-y: 32px;
    --card-gap: 18px;
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 0px;
    --topbar-height: 60px;
    --page-gutter-x: 18px;
    --page-gap-y: 16px;
    --page-top-y: 18px;
    --page-bottom-y: 28px;
    --card-gap: 16px;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .metrics-grid,
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2,
  .social-grid,
  .creatives-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
    --topbar-height: 58px;
    --page-gutter-x: 14px;
    --page-gap-y: 14px;
    --page-top-y: 14px;
    --page-bottom-y: 24px;
    --card-gap: 14px;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .metrics-grid,
  .grid-2,
  .grid-3,
  .social-grid,
  .creatives-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    gap: 10px;
  }

  .page-title {
    line-height: 1.15;
  }

  .page-subtitle {
    font-size: 13px;
    line-height: 1.45;
  }

  .card,
  .metric-card,
  .table-container,
  .settings-card,
  .status-card,
  .integration-card,
  .filter-bar,
  .empty-state {
    border-radius: 12px;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  :root {
    --topbar-height: 56px;
    --page-gutter-x: 12px;
    --page-gap-y: 12px;
    --page-top-y: 12px;
    --page-bottom-y: 20px;
    --card-gap: 12px;
  }

  .main-content > :not(script):not(style) {
    width: auto;
  }

  .metric-card,
  .card,
  .table-container,
  .settings-card,
  .status-card,
  .integration-card,
  .filter-bar,
  .empty-state {
    padding-left: 14px;
    padding-right: 14px;
  }
}
/* ===================== CONTAINER GUTTER NON-ZERO FINAL ===================== */
.main-content {
  padding-top: var(--topbar-height);
  padding-left: var(--page-gutter-x);
  padding-right: var(--page-gutter-x);
  padding-bottom: 0;
}

.main-content > :not(script):not(style) {
  width: auto;
  max-width: 100%;
  margin-left: var(--page-gutter-x);
  margin-right: var(--page-gutter-x);
}

.main-content > :not(script):not(style):first-child {
  margin-top: var(--page-top-y);
}

.main-content > :not(script):not(style):last-child {
  margin-bottom: var(--page-bottom-y);
}

.main-content > :not(script):not(style) + :not(script):not(style) {
  margin-top: var(--page-gap-y);
}

/* Desktop & laptop: hilangkan padding horizontal main-content,
   gutter tunggal diatur via --page-gutter-x pada child (lihat block CONTAINER CHILD MARGIN).
   Mobile/tablet tetap pakai padding sendiri (sudah rapi). */
@media (min-width: 1025px) {
  .main-content {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding-left: 7px;
    padding-right: 7px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding-left: 6px;
    padding-right: 6px;
  }
}
/* ===================== CONTAINER CHILD MARGIN NON-ZERO FINAL ===================== */
body.theme-light .main-content > :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) {
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.theme-light .main-content > :not(script):not(style):first-child,
body.theme-dark .main-content > :not(script):not(style):first-child {
  margin-top: var(--page-top-y) !important;
}

body.theme-light .main-content > :not(script):not(style):last-child,
body.theme-dark .main-content > :not(script):not(style):last-child {
  margin-bottom: var(--page-bottom-y) !important;
}

body.theme-light .main-content > :not(script):not(style) + :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) + :not(script):not(style) {
  margin-top: var(--page-gap-y) !important;
}

/* Card/metric-card di dalam grid: tidak perlu margin kiri-kanan dan margin bottom */
body.theme-light .main-content .metrics-grid > .metric-card,
body.theme-dark .main-content .metrics-grid > .metric-card,
body.theme-light .main-content .grid-2 > .card,
body.theme-dark .main-content .grid-2 > .card,
body.theme-light .main-content .grid-3 > .card,
body.theme-dark .main-content .grid-3 > .card,
body.theme-light .main-content .social-grid > .card,
body.theme-dark .main-content .social-grid > .card,
body.theme-light .main-content .creatives-grid > .card,
body.theme-dark .main-content .creatives-grid > .card {
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
}
/* ===================== SECTION CARD WIDTH BALANCE FINAL ===================== */
body.theme-light .main-content > .card,
body.theme-dark .main-content > .card,
body.theme-light .main-content > .settings-card,
body.theme-dark .main-content > .settings-card,
body.theme-light .main-content > .status-card,
body.theme-dark .main-content > .status-card,
body.theme-light .main-content > .integration-card,
body.theme-dark .main-content > .integration-card,
body.theme-light .main-content > .filter-bar,
body.theme-dark .main-content > .filter-bar,
body.theme-light .main-content > .table-container,
body.theme-dark .main-content > .table-container {
  max-width: 1000px !important;
}

body.theme-light .main-content > .page-header,
body.theme-dark .main-content > .page-header,
body.theme-light .main-content > .metrics-grid,
body.theme-dark .main-content > .metrics-grid,
body.theme-light .main-content > .grid-2,
body.theme-dark .main-content > .grid-2,
body.theme-light .main-content > .grid-3,
body.theme-dark .main-content > .grid-3,
body.theme-light .main-content > .social-grid,
body.theme-dark .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-dark .main-content > .creatives-grid,
body.theme-light .main-content > .health-rules-grid,
body.theme-dark .main-content > .health-rules-grid {
  max-width: none !important;
}

@media (min-width: 1440px) {
  body.theme-light .main-content > .card,
  body.theme-dark .main-content > .card,
  body.theme-light .main-content > .settings-card,
  body.theme-dark .main-content > .settings-card,
  body.theme-light .main-content > .status-card,
  body.theme-dark .main-content > .status-card,
  body.theme-light .main-content > .integration-card,
  body.theme-dark .main-content > .integration-card,
  body.theme-light .main-content > .filter-bar,
  body.theme-dark .main-content > .filter-bar,
  body.theme-light .main-content > .table-container,
  body.theme-dark .main-content > .table-container {
    max-width: 1040px !important;
  }
}

@media (max-width: 1024px) {
  body.theme-light .main-content > .card,
  body.theme-dark .main-content > .card,
  body.theme-light .main-content > .settings-card,
  body.theme-dark .main-content > .settings-card,
  body.theme-light .main-content > .status-card,
  body.theme-dark .main-content > .status-card,
  body.theme-light .main-content > .integration-card,
  body.theme-dark .main-content > .integration-card,
  body.theme-light .main-content > .filter-bar,
  body.theme-dark .main-content > .filter-bar,
  body.theme-light .main-content > .table-container,
  body.theme-dark .main-content > .table-container {
    max-width: none !important;
  }
}
/* ===================== ADDITIONAL SECTION CARD BALANCE FINAL ===================== */
body.theme-light .main-content > .chart-container,
body.theme-dark .main-content > .chart-container,
body.theme-light .main-content > .chart-container-sm,
body.theme-dark .main-content > .chart-container-sm,
body.theme-light .main-content > .empty-state,
body.theme-dark .main-content > .empty-state,
body.theme-light .main-content > .insight-card,
body.theme-dark .main-content > .insight-card,
body.theme-light .main-content > .social-card,
body.theme-dark .main-content > .social-card,
body.theme-light .main-content > .creative-card,
body.theme-dark .main-content > .creative-card {
  max-width: 1000px !important;
}

@media (min-width: 1440px) {
  body.theme-light .main-content > .chart-container,
  body.theme-dark .main-content > .chart-container,
  body.theme-light .main-content > .chart-container-sm,
  body.theme-dark .main-content > .chart-container-sm,
  body.theme-light .main-content > .empty-state,
  body.theme-dark .main-content > .empty-state,
  body.theme-light .main-content > .insight-card,
  body.theme-dark .main-content > .insight-card,
  body.theme-light .main-content > .social-card,
  body.theme-dark .main-content > .social-card,
  body.theme-light .main-content > .creative-card,
  body.theme-dark .main-content > .creative-card {
    max-width: 1040px !important;
  }
}

@media (max-width: 1024px) {
  body.theme-light .main-content > .chart-container,
  body.theme-dark .main-content > .chart-container,
  body.theme-light .main-content > .chart-container-sm,
  body.theme-dark .main-content > .chart-container-sm,
  body.theme-light .main-content > .empty-state,
  body.theme-dark .main-content > .empty-state,
  body.theme-light .main-content > .insight-card,
  body.theme-dark .main-content > .insight-card,
  body.theme-light .main-content > .social-card,
  body.theme-dark .main-content > .social-card,
  body.theme-light .main-content > .creative-card,
  body.theme-dark .main-content > .creative-card {
    max-width: none !important;
  }
}

/* Items inside grid wrappers: grid gap handles spacing, not card margins */
body.theme-light .main-content .health-rules-grid > .card,
body.theme-dark .main-content .health-rules-grid > .card,
body.theme-light .main-content .social-grid > .social-card,
body.theme-dark .main-content .social-grid > .social-card,
body.theme-light .main-content .creatives-grid > .creative-card,
body.theme-dark .main-content .creatives-grid > .creative-card,
body.theme-light .main-content .grid-2 > .chart-container,
body.theme-dark .main-content .grid-2 > .chart-container,
body.theme-light .main-content .grid-3 > .chart-container,
body.theme-dark .main-content .grid-3 > .chart-container,
body.theme-light .main-content .grid-2 > .empty-state,
body.theme-dark .main-content .grid-2 > .empty-state,
body.theme-light .main-content .grid-3 > .empty-state,
body.theme-dark .main-content .grid-3 > .empty-state {
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
  max-width: none !important;
}
/* ===================== UNIFIED SECTION CONTAINER FINAL ===================== */
body.theme-light .main-content > :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) {
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.theme-light .main-content > :not(script):not(style):first-child,
body.theme-dark .main-content > :not(script):not(style):first-child {
  margin-top: var(--page-top-y) !important;
}

body.theme-light .main-content > :not(script):not(style):last-child,
body.theme-dark .main-content > :not(script):not(style):last-child {
  margin-bottom: var(--page-bottom-y) !important;
}

body.theme-light .main-content > :not(script):not(style) + :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) + :not(script):not(style) {
  margin-top: var(--page-gap-y) !important;
}

/* Semua grid wrapper pakai container sama, item di dalam grid tidak punya margin sendiri */
body.theme-light .main-content .metrics-grid > .metric-card,
body.theme-dark .main-content .metrics-grid > .metric-card,
body.theme-light .main-content .grid-2 > .card,
body.theme-dark .main-content .grid-2 > .card,
body.theme-light .main-content .grid-3 > .card,
body.theme-dark .main-content .grid-3 > .card,
body.theme-light .main-content .social-grid > .social-card,
body.theme-dark .main-content .social-grid > .social-card,
body.theme-light .main-content .creatives-grid > .creative-card,
body.theme-dark .main-content .creatives-grid > .creative-card,
body.theme-light .main-content .health-rules-grid > .card,
body.theme-dark .main-content .health-rules-grid > .card,
body.theme-light .main-content .grid-2 > .chart-container,
body.theme-dark .main-content .grid-2 > .chart-container,
body.theme-light .main-content .grid-3 > .chart-container,
body.theme-dark .main-content .grid-3 > .chart-container,
body.theme-light .main-content .grid-2 > .empty-state,
body.theme-dark .main-content .grid-2 > .empty-state,
body.theme-light .main-content .grid-3 > .empty-state,
body.theme-dark .main-content .grid-3 > .empty-state {
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
}
/* ===================== UNIFIED SECTION MAX-WIDTH RESET FINAL ===================== */
body.theme-light .main-content > .page-header,
body.theme-dark .main-content > .page-header,
body.theme-light .main-content > .metrics-grid,
body.theme-dark .main-content > .metrics-grid,
body.theme-light .main-content > .grid-2,
body.theme-dark .main-content > .grid-2,
body.theme-light .main-content > .grid-3,
body.theme-dark .main-content > .grid-3,
body.theme-light .main-content > .social-grid,
body.theme-dark .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-dark .main-content > .creatives-grid,
body.theme-light .main-content > .health-rules-grid,
body.theme-dark .main-content > .health-rules-grid,
body.theme-light .main-content > .card,
body.theme-dark .main-content > .card,
body.theme-light .main-content > .metric-card,
body.theme-dark .main-content > .metric-card,
body.theme-light .main-content > .settings-card,
body.theme-dark .main-content > .settings-card,
body.theme-light .main-content > .status-card,
body.theme-dark .main-content > .status-card,
body.theme-light .main-content > .integration-card,
body.theme-dark .main-content > .integration-card,
body.theme-light .main-content > .filter-bar,
body.theme-dark .main-content > .filter-bar,
body.theme-light .main-content > .table-container,
body.theme-dark .main-content > .table-container,
body.theme-light .main-content > .chart-container,
body.theme-dark .main-content > .chart-container,
body.theme-light .main-content > .chart-container-sm,
body.theme-dark .main-content > .chart-container-sm,
body.theme-light .main-content > .empty-state,
body.theme-dark .main-content > .empty-state,
body.theme-light .main-content > .insight-card,
body.theme-dark .main-content > .insight-card,
body.theme-light .main-content > .social-card,
body.theme-dark .main-content > .social-card,
body.theme-light .main-content > .creative-card,
body.theme-dark .main-content > .creative-card {
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
/* ===================== SCOPED PAGE CONTAINER FINAL ===================== */
body.theme-light .main-content > :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) {
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

body.theme-light .main-content > .page-header,
body.theme-dark .main-content > .page-header,
body.theme-light .main-content > .metrics-grid,
body.theme-dark .main-content > .metrics-grid,
body.theme-light .main-content > .grid-2,
body.theme-dark .main-content > .grid-2,
body.theme-light .main-content > .grid-3,
body.theme-dark .main-content > .grid-3,
body.theme-light .main-content > .social-grid,
body.theme-dark .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-dark .main-content > .creatives-grid,
body.theme-light .main-content > .health-rules-grid,
body.theme-dark .main-content > .health-rules-grid,
body.theme-light .main-content > .card,
body.theme-dark .main-content > .card,
body.theme-light .main-content > .metric-card,
body.theme-dark .main-content > .metric-card,
body.theme-light .main-content > .settings-card,
body.theme-dark .main-content > .settings-card,
body.theme-light .main-content > .status-card,
body.theme-dark .main-content > .status-card,
body.theme-light .main-content > .integration-card,
body.theme-dark .main-content > .integration-card,
body.theme-light .main-content > .filter-bar,
body.theme-dark .main-content > .filter-bar,
body.theme-light .main-content > .table-container,
body.theme-dark .main-content > .table-container,
body.theme-light .main-content > .chart-container,
body.theme-dark .main-content > .chart-container,
body.theme-light .main-content > .chart-container-sm,
body.theme-dark .main-content > .chart-container-sm,
body.theme-light .main-content > .empty-state,
body.theme-dark .main-content > .empty-state,
body.theme-light .main-content > .insight-card,
body.theme-dark .main-content > .insight-card,
body.theme-light .main-content > .social-card,
body.theme-dark .main-content > .social-card,
body.theme-light .main-content > .creative-card,
body.theme-dark .main-content > .creative-card,
body.theme-light .main-content > .flash,
body.theme-dark .main-content > .flash {
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.theme-light .main-content > .page-header:first-child,
body.theme-dark .main-content > .page-header:first-child,
body.theme-light .main-content > .metrics-grid:first-child,
body.theme-dark .main-content > .metrics-grid:first-child,
body.theme-light .main-content > .grid-2:first-child,
body.theme-dark .main-content > .grid-2:first-child,
body.theme-light .main-content > .grid-3:first-child,
body.theme-dark .main-content > .grid-3:first-child,
body.theme-light .main-content > .card:first-child,
body.theme-dark .main-content > .card:first-child,
body.theme-light .main-content > .empty-state:first-child,
body.theme-dark .main-content > .empty-state:first-child {
  margin-top: var(--page-top-y) !important;
}

body.theme-light .main-content > .page-header + *,
body.theme-dark .main-content > .page-header + *,
body.theme-light .main-content > .metrics-grid + *,
body.theme-dark .main-content > .metrics-grid + *,
body.theme-light .main-content > .grid-2 + *,
body.theme-dark .main-content > .grid-2 + *,
body.theme-light .main-content > .grid-3 + *,
body.theme-dark .main-content > .grid-3 + *,
body.theme-light .main-content > .card + *,
body.theme-dark .main-content > .card + *,
body.theme-light .main-content > .table-container + *,
body.theme-dark .main-content > .table-container + *,
body.theme-light .main-content > .empty-state + *,
body.theme-dark .main-content > .empty-state + * {
  margin-top: var(--page-gap-y) !important;
}

body.theme-light .main-content .metrics-grid > .metric-card,
body.theme-dark .main-content .metrics-grid > .metric-card,
body.theme-light .main-content .grid-2 > .card,
body.theme-dark .main-content .grid-2 > .card,
body.theme-light .main-content .grid-3 > .card,
body.theme-dark .main-content .grid-3 > .card,
body.theme-light .main-content .social-grid > .social-card,
body.theme-dark .main-content .social-grid > .social-card,
body.theme-light .main-content .creatives-grid > .creative-card,
body.theme-dark .main-content .creatives-grid > .creative-card,
body.theme-light .main-content .health-rules-grid > .card,
body.theme-dark .main-content .health-rules-grid > .card,
body.theme-light .main-content .grid-2 > .chart-container,
body.theme-dark .main-content .grid-2 > .chart-container,
body.theme-light .main-content .grid-3 > .chart-container,
body.theme-dark .main-content .grid-3 > .chart-container,
body.theme-light .main-content .grid-2 > .empty-state,
body.theme-dark .main-content .grid-2 > .empty-state,
body.theme-light .main-content .grid-3 > .empty-state,
body.theme-dark .main-content .grid-3 > .empty-state {
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
  max-width: none !important;
}
/* ===================== SCOPED CONTAINER CASCADE FINAL ===================== */
/* ===================== GENERIC DIV MARGIN RESET FINAL ===================== */
body.theme-light .main-content > :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style),
body.theme-light .main-content > :not(script):not(style):first-child,
body.theme-dark .main-content > :not(script):not(style):first-child,
body.theme-light .main-content > :not(script):not(style):last-child,
body.theme-dark .main-content > :not(script):not(style):last-child,
body.theme-light .main-content > :not(script):not(style) + :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) + :not(script):not(style) {
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  max-width: none !important;
}

/* ===================== SCOPED PAGE CONTAINER FINAL ===================== */body.theme-light .main-content > :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) {
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

body.theme-light .main-content > .page-header,
body.theme-dark .main-content > .page-header,
body.theme-light .main-content > .metrics-grid,
body.theme-dark .main-content > .metrics-grid,
body.theme-light .main-content > .grid-2,
body.theme-dark .main-content > .grid-2,
body.theme-light .main-content > .grid-3,
body.theme-dark .main-content > .grid-3,
body.theme-light .main-content > .social-grid,
body.theme-dark .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-dark .main-content > .creatives-grid,
body.theme-light .main-content > .health-rules-grid,
body.theme-dark .main-content > .health-rules-grid,
body.theme-light .main-content > .card,
body.theme-dark .main-content > .card,
body.theme-light .main-content > .metric-card,
body.theme-dark .main-content > .metric-card,
body.theme-light .main-content > .settings-card,
body.theme-dark .main-content > .settings-card,
body.theme-light .main-content > .status-card,
body.theme-dark .main-content > .status-card,
body.theme-light .main-content > .integration-card,
body.theme-dark .main-content > .integration-card,
body.theme-light .main-content > .filter-bar,
body.theme-dark .main-content > .filter-bar,
body.theme-light .main-content > .table-container,
body.theme-dark .main-content > .table-container,
body.theme-light .main-content > .chart-container,
body.theme-dark .main-content > .chart-container,
body.theme-light .main-content > .chart-container-sm,
body.theme-dark .main-content > .chart-container-sm,
body.theme-light .main-content > .empty-state,
body.theme-dark .main-content > .empty-state,
body.theme-light .main-content > .insight-card,
body.theme-dark .main-content > .insight-card,
body.theme-light .main-content > .social-card,
body.theme-dark .main-content > .social-card,
body.theme-light .main-content > .creative-card,
body.theme-dark .main-content > .creative-card,
body.theme-light .main-content > .flash,
body.theme-dark .main-content > .flash {
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

body.theme-light .main-content > .page-header:first-child,
body.theme-dark .main-content > .page-header:first-child,
body.theme-light .main-content > .metrics-grid:first-child,
body.theme-dark .main-content > .metrics-grid:first-child,
body.theme-light .main-content > .grid-2:first-child,
body.theme-dark .main-content > .grid-2:first-child,
body.theme-light .main-content > .grid-3:first-child,
body.theme-dark .main-content > .grid-3:first-child,
body.theme-light .main-content > .card:first-child,
body.theme-dark .main-content > .card:first-child,
body.theme-light .main-content > .empty-state:first-child,
body.theme-dark .main-content > .empty-state:first-child {
  margin-top: var(--page-top-y) !important;
}

body.theme-light .main-content > .page-header + *,
body.theme-dark .main-content > .page-header + *,
body.theme-light .main-content > .metrics-grid + *,
body.theme-dark .main-content > .metrics-grid + *,
body.theme-light .main-content > .grid-2 + *,
body.theme-dark .main-content > .grid-2 + *,
body.theme-light .main-content > .grid-3 + *,
body.theme-dark .main-content > .grid-3 + *,
body.theme-light .main-content > .card + *,
body.theme-dark .main-content > .card + *,
body.theme-light .main-content > .table-container + *,
body.theme-dark .main-content > .table-container + *,
body.theme-light .main-content > .empty-state + *,
body.theme-dark .main-content > .empty-state + * {
  margin-top: var(--page-gap-y) !important;
}

body.theme-light .main-content .metrics-grid > .metric-card,
body.theme-dark .main-content .metrics-grid > .metric-card,
body.theme-light .main-content .grid-2 > .card,
body.theme-dark .main-content .grid-2 > .card,
body.theme-light .main-content .grid-3 > .card,
body.theme-dark .main-content .grid-3 > .card,
body.theme-light .main-content .social-grid > .social-card,
body.theme-dark .main-content .social-grid > .social-card,
body.theme-light .main-content .creatives-grid > .creative-card,
body.theme-dark .main-content .creatives-grid > .creative-card,
body.theme-light .main-content .health-rules-grid > .card,
body.theme-dark .main-content .health-rules-grid > .card,
body.theme-light .main-content .grid-2 > .chart-container,
body.theme-dark .main-content .grid-2 > .chart-container,
body.theme-light .main-content .grid-3 > .chart-container,
body.theme-dark .main-content .grid-3 > .chart-container,
body.theme-light .main-content .grid-2 > .empty-state,
body.theme-dark .main-content .grid-2 > .empty-state,
body.theme-light .main-content .grid-3 > .empty-state,
body.theme-dark .main-content .grid-3 > .empty-state {
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0 !important;
  max-width: none !important;
}
/* ===================== EXPLICIT SECTION CONTAINER CASCADE FINAL ===================== */
body.theme-light .main-content > .page-header,
body.theme-dark .main-content > .page-header,
body.theme-light .main-content > .page-header:first-child,
body.theme-dark .main-content > .page-header:first-child,
body.theme-light .main-content > .page-header:last-child,
body.theme-dark .main-content > .page-header:last-child,
body.theme-light .main-content > .metrics-grid,
body.theme-dark .main-content > .metrics-grid,
body.theme-light .main-content > .metrics-grid:first-child,
body.theme-dark .main-content > .metrics-grid:first-child,
body.theme-light .main-content > .metrics-grid:last-child,
body.theme-dark .main-content > .metrics-grid:last-child,
body.theme-light .main-content > .grid-2,
body.theme-dark .main-content > .grid-2,
body.theme-light .main-content > .grid-2:first-child,
body.theme-dark .main-content > .grid-2:first-child,
body.theme-light .main-content > .grid-2:last-child,
body.theme-dark .main-content > .grid-2:last-child,
body.theme-light .main-content > .grid-3,
body.theme-dark .main-content > .grid-3,
body.theme-light .main-content > .grid-3:first-child,
body.theme-dark .main-content > .grid-3:first-child,
body.theme-light .main-content > .grid-3:last-child,
body.theme-dark .main-content > .grid-3:last-child,
body.theme-light .main-content > .card,
body.theme-dark .main-content > .card,
body.theme-light .main-content > .card:first-child,
body.theme-dark .main-content > .card:first-child,
body.theme-light .main-content > .card:last-child,
body.theme-dark .main-content > .card:last-child,
body.theme-light .main-content > .settings-card,
body.theme-dark .main-content > .settings-card,
body.theme-light .main-content > .settings-card:first-child,
body.theme-dark .main-content > .settings-card:first-child,
body.theme-light .main-content > .settings-card:last-child,
body.theme-dark .main-content > .settings-card:last-child,
body.theme-light .main-content > .table-container,
body.theme-dark .main-content > .table-container,
body.theme-light .main-content > .table-container:first-child,
body.theme-dark .main-content > .table-container:first-child,
body.theme-light .main-content > .table-container:last-child,
body.theme-dark .main-content > .table-container:last-child,
body.theme-light .main-content > .empty-state,
body.theme-dark .main-content > .empty-state,
body.theme-light .main-content > .empty-state:first-child,
body.theme-dark .main-content > .empty-state:first-child,
body.theme-light .main-content > .empty-state:last-child,
body.theme-dark .main-content > .empty-state:last-child,
body.theme-light .main-content > .chart-container,
body.theme-dark .main-content > .chart-container,
body.theme-light .main-content > .chart-container-sm,
body.theme-dark .main-content > .chart-container-sm,
body.theme-light .main-content > .filter-bar,
body.theme-dark .main-content > .filter-bar,
body.theme-light .main-content > .status-card,
body.theme-dark .main-content > .status-card,
body.theme-light .main-content > .integration-card,
body.theme-dark .main-content > .integration-card,
body.theme-light .main-content > .social-grid,
body.theme-dark .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-dark .main-content > .creatives-grid,
body.theme-light .main-content > .health-rules-grid,
body.theme-dark .main-content > .health-rules-grid,
body.theme-light .main-content > .insight-card,
body.theme-dark .main-content > .insight-card,
body.theme-light .main-content > .social-card,
body.theme-dark .main-content > .social-card,
body.theme-light .main-content > .creative-card,
body.theme-dark .main-content > .creative-card,
body.theme-light .main-content > .flash,
body.theme-dark .main-content > .flash {
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
/* ===================== CLEAN MAIN CONTENT CONTAINER FINAL ===================== */
.main-content {
  display: flex !important;
  flex-direction: column !important;
  gap: var(--page-gap-y) !important;
  padding-top: calc(var(--topbar-height) + var(--page-top-y)) !important;
  padding-right: var(--page-gutter-x) !important;
  padding-bottom: var(--page-bottom-y) !important;
  padding-left: var(--page-gutter-x) !important;
  overflow-x: hidden !important;
}

body.theme-light .main-content > :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style),
body.theme-light .main-content > :not(script):not(style):first-child,
body.theme-dark .main-content > :not(script):not(style):first-child,
body.theme-light .main-content > :not(script):not(style):last-child,
body.theme-dark .main-content > :not(script):not(style):last-child,
body.theme-light .main-content > :not(script):not(style) + :not(script):not(style),
body.theme-dark .main-content > :not(script):not(style) + :not(script):not(style) {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

.main-content > .metrics-grid,
.main-content > .grid-2,
.main-content > .grid-3,
.main-content > .social-grid,
.main-content > .creatives-grid,
.main-content > .health-rules-grid {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

.main-content .metrics-grid > .metric-card,
.main-content .grid-2 > .card,
.main-content .grid-3 > .card,
.main-content .social-grid > .social-card,
.main-content .creatives-grid > .creative-card,
.main-content .health-rules-grid > .card,
.main-content .grid-2 > .chart-container,
.main-content .grid-3 > .chart-container,
.main-content .grid-2 > .empty-state,
.main-content .grid-3 > .empty-state {
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
}

.table-container {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* Padding horizontal main-content diatur via var(--page-gutter-x) di blok CLEAN MAIN CONTENT.
   Tidak perlu hardcode per-breakpoint di sini. */
/* ===================== CLEAN SECTION MARGIN ZERO FINAL ===================== */
body.theme-light .main-content > .page-header,
body.theme-dark .main-content > .page-header,
body.theme-light .main-content > .metrics-grid,
body.theme-dark .main-content > .metrics-grid,
body.theme-light .main-content > .grid-2,
body.theme-dark .main-content > .grid-2,
body.theme-light .main-content > .grid-3,
body.theme-dark .main-content > .grid-3,
body.theme-light .main-content > .social-grid,
body.theme-dark .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-dark .main-content > .creatives-grid,
body.theme-light .main-content > .health-rules-grid,
body.theme-dark .main-content > .health-rules-grid,
body.theme-light .main-content > .card,
body.theme-dark .main-content > .card,
body.theme-light .main-content > .metric-card,
body.theme-dark .main-content > .metric-card,
body.theme-light .main-content > .settings-card,
body.theme-dark .main-content > .settings-card,
body.theme-light .main-content > .status-card,
body.theme-dark .main-content > .status-card,
body.theme-light .main-content > .integration-card,
body.theme-dark .main-content > .integration-card,
body.theme-light .main-content > .filter-bar,
body.theme-dark .main-content > .filter-bar,
body.theme-light .main-content > .table-container,
body.theme-dark .main-content > .table-container,
body.theme-light .main-content > .chart-container,
body.theme-dark .main-content > .chart-container,
body.theme-light .main-content > .chart-container-sm,
body.theme-dark .main-content > .chart-container-sm,
body.theme-light .main-content > .empty-state,
body.theme-dark .main-content > .empty-state,
body.theme-light .main-content > .insight-card,
body.theme-dark .main-content > .insight-card,
body.theme-light .main-content > .social-card,
body.theme-dark .main-content > .social-card,
body.theme-light .main-content > .creative-card,
body.theme-dark .main-content > .creative-card,
body.theme-light .main-content > .flash,
body.theme-dark .main-content > .flash,
body.theme-light .main-content > .page-header:first-child,
body.theme-dark .main-content > .page-header:first-child,
body.theme-light .main-content > .card:first-child,
body.theme-dark .main-content > .card:first-child,
body.theme-light .main-content > .page-header:last-child,
body.theme-dark .main-content > .page-header:last-child,
body.theme-light .main-content > .card:last-child,
body.theme-dark .main-content > .card:last-child {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

/* ===================== GRID HORIZONTAL MARGIN RESET FINAL ===================== */
/* Reset margin kiri-kanan untuk semua div grid yang menjadi direct child main-content.
   Gutter horizontal diatur via padding main-content, jadi grid tidak perlu margin sendiri. */
body.theme-light .main-content > .metrics-grid,
body.theme-dark .main-content > .metrics-grid,
body.theme-light .main-content > .grid-2,
body.theme-dark .main-content > .grid-2,
body.theme-light .main-content > .grid-3,
body.theme-dark .main-content > .grid-3,
body.theme-light .main-content > .social-grid,
body.theme-dark .main-content > .social-grid,
body.theme-light .main-content > .creatives-grid,
body.theme-dark .main-content > .creatives-grid,
body.theme-light .main-content > .health-rules-grid,
body.theme-dark .main-content > .health-rules-grid,
.main-content > .metrics-grid,
.main-content > .grid-2,
.main-content > .grid-3,
.main-content > .social-grid,
.main-content > .creatives-grid,
.main-content > .health-rules-grid {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100% !important;
  max-width: none !important;
}

/* ===================== TABLE PAGINATION ===================== */
table[data-paginate] .pg-hidden { display: none !important; }

.paginate-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 12px;
  padding: 8px 4px;
  font-size: 13px;
}

.paginate-info {
  margin-right: auto;
  color: var(--text-muted);
  font-size: 12px;
}

.paginate-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.paginate-btn:hover:not(:disabled):not(.paginate-active) {
  background: var(--bg);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.paginate-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.paginate-btn.paginate-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: default;
}

.paginate-ellipsis {
  padding: 0 6px;
  color: var(--text-muted);
  user-select: none;
}

@media (max-width: 768px) {
  .paginate-controls {
    justify-content: center;
  }
  .paginate-info {
    margin-right: 0;
    width: 100%;
    text-align: center;
    margin-bottom: 6px;
  }
}
