:root {
  --bg: #0b1020;
  --bg-soft: #0f1730;
  --card-bg: rgba(18, 26, 47, 0.85);
  --card-bg-solid: #161b22;
  --card-border: transparent;
  --text: #e9f0f7;
  --muted: #8aa0b6;
  --accent: #5b8bff;
  --accent-2: #22d3ee;
  --accent-3: #a78bfa;
  --success: #22c55e;
  --danger: #f43f5e;
  --warning: #f59e0b;
  --shadow: 0 10px 24px rgba(3, 7, 18, 0.35);
}

body.light {
  --bg: #f4f7fb;
  --bg-soft: #eef2ff;
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-bg-solid: #ffffff;
  --card-border: transparent;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #06b6d4;
  --accent-3: #7c3aed;
  --success: #16a34a;
  --danger: #e11d48;
  --warning: #d97706;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(91, 139, 255, 0.25), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, 0.18), transparent 60%),
    radial-gradient(700px 500px at 80% 90%, rgba(167, 139, 250, 0.18), transparent 60%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow: auto;
  overflow-x: hidden;
  /* App-like feel */
  display: flex;
  flex-direction: column;
}

/* Layout */
.app-container {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  padding: 16px;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Header */
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-right: 8px;
}

.brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.025em;
}

.brand .sub {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Controls Bar */
.controls-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card-bg);
  padding: 10px 16px;
  border-radius: 12px;
  border: 0;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
  row-gap: 8px;
}

.trend-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.trend-metrics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.trend-metrics label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--muted);
  padding: 4px 6px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: 0.2s;
  border-radius: 999px;
  border: 1px solid var(--card-border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: rgba(59, 130, 246, 0.35);
  border-color: rgba(59, 130, 246, 0.5);
}

.switch input:checked + .slider:before {
  transform: translateX(22px);
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.control-inline label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
}

.control-inline button {
  margin-top: 0;
}

.control-inline select,
.control-inline input {
  min-width: 120px;
}

.control-account select {
  min-width: 160px;
}

.control-period select {
  min-width: 140px;
}

.control-balance .balance-value {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 120px;
  text-align: right;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.controls-user {
  margin-left: auto;
}

.mobile-menu-toggle {
  display: none;
  margin-left: auto;
}

.mobile-menu-panel {
  display: contents;
}

.avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.accounts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.accounts-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

/* Admin area */
.admin-page .controls-bar .brand .sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-toggle label {
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-users {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-user {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-user-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.avatar-badge {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(59, 130, 246, 0.2);
  color: var(--text);
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.pill.neutral {
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.4);
}

/* Profile */
.profile-page .controls-bar .brand .sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.profile-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.profile-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.meta-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.meta-value {
  font-weight: 600;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-actions {
  display: flex;
  justify-content: flex-start;
}

@media (max-width: 980px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.custom-range {
  gap: 8px;
  flex-wrap: nowrap;
}

.custom-range .control-group {
  gap: 4px;
}

.custom-range .control-group label {
  display: none;
}

.custom-range input[type="date"] {
  min-width: 120px;
  width: 120px;
}

.control-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}


select,
input,
button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.controls-fullscreen {
  align-self: center;
  margin-left: auto;
}

.controls-theme {
  margin-left: auto;
  gap: 6px;
}

.controls-theme i {
  color: var(--muted);
  font-size: 0.85rem;
}

select:hover,
input:hover,
button:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

button {
  cursor: pointer;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.2);
}

button:hover {
  background: rgba(59, 130, 246, 0.2);
}

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: auto;
  gap: 16px;
  overflow: visible;
  padding-bottom: 8px;
}

.trend-fullscreen .bento-grid {
  grid-template-columns: 1fr;
}

.trend-fullscreen .bento-grid > .card {
  display: none;
}

.trend-fullscreen .bento-grid > .area-trend {
  display: flex;
  grid-column: 1 / -1;
  min-height: 70vh;
}

/* Grid Areas Definition */
/* Grid Areas Definition */
.area-kpis {
  grid-column: span 4;
  padding: 10px;
  min-height: auto;
  align-self: start;
  min-width: 0;
}

.area-trend {
  grid-column: span 2;
  min-height: 380px;
}

.area-campaigns {
  grid-column: span 1;
  min-height: 220px;
}

.area-adsets {
  grid-column: span 1;
  min-height: 220px;
}

.area-ads {
  grid-column: span 2;
  min-height: 220px;
}

.area-funnel {
  grid-column: span 1;
  min-height: 220px;
}
.area-funnel {
  grid-column: span 1;
}

.area-demo {
  /* Demografia */
  grid-column: span 1;
  min-height: 220px;
}

.area-channels {
  /* Plataformas */
  grid-column: span 1;
  min-height: 220px;
}

.area-alerts {
  grid-column: span 1;
  min-height: 220px;
}

.area-creatives {
  grid-column: span 2;
  /* Give more space to creatives */
}

.area-table {
  grid-column: span 4;
  min-height: 250px;
  /* Reduced from 400px */
  max-height: 400px;
}

/* Card Styles */
.card {
  background: var(--card-bg);
  border: 0;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card:hover {
  transform: translateY(-1px);
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(91, 139, 255, 0.08), rgba(34, 211, 238, 0.06), rgba(167, 139, 250, 0.06));
  opacity: 0.7;
  pointer-events: none;
}

.card > * {
  position: relative;
  z-index: 1;
}

.card h2,
.card h3 {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
}

.ghost-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.tiny-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 0;
  box-shadow: 0 6px 14px rgba(3, 7, 18, 0.2);
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.65rem;
}

.tiny-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.trendMetricBtn.active {
  color: var(--text);
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.trendMetricBtn.active[data-metric="spend"] { background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.6); color:#e9f0f7; }
.trendMetricBtn.active[data-metric="impressions"] { background: rgba(16,185,129,0.2); border-color: rgba(16,185,129,0.6); color:#e9f0f7; }
.trendMetricBtn.active[data-metric="clicks"] { background: rgba(245,158,11,0.2); border-color: rgba(245,158,11,0.6); color:#e9f0f7; }
.trendMetricBtn.active[data-metric="results"] { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.6); color:#e9f0f7; }
.trendMetricBtn.active[data-metric="ctr"] { background: rgba(139,92,246,0.2); border-color: rgba(139,92,246,0.6); color:#e9f0f7; }
.trendMetricBtn.active[data-metric="cpc"] { background: rgba(34,197,94,0.2); border-color: rgba(34,197,94,0.6); color:#e9f0f7; }
.trendMetricBtn.active[data-metric="cpm"] { background: rgba(6,182,212,0.2); border-color: rgba(6,182,212,0.6); color:#e9f0f7; }

body.light .trendMetricBtn.active[data-metric="spend"],
body.light .trendMetricBtn.active[data-metric="impressions"],
body.light .trendMetricBtn.active[data-metric="clicks"],
body.light .trendMetricBtn.active[data-metric="results"],
body.light .trendMetricBtn.active[data-metric="ctr"],
body.light .trendMetricBtn.active[data-metric="cpc"],
body.light .trendMetricBtn.active[data-metric="cpm"] {
  color: #0f172a;
}

.trendMetricBtn[data-metric="spend"] { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.25); }
.trendMetricBtn[data-metric="impressions"] { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.25); }
.trendMetricBtn[data-metric="clicks"] { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.25); }
.trendMetricBtn[data-metric="results"] { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.25); }
.trendMetricBtn[data-metric="ctr"] { background: rgba(139,92,246,0.08); border-color: rgba(139,92,246,0.25); }
.trendMetricBtn[data-metric="cpc"] { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.25); }
.trendMetricBtn[data-metric="cpm"] { background: rgba(6,182,212,0.08); border-color: rgba(6,182,212,0.25); }

.card h2::after {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--card-border);
}

/* KPIs Row */
.kpi-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: scroll;
  overflow-y: hidden;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.kpi-card {
  background: rgba(255, 255, 255, 0.06);
  padding: 10px;
  border-radius: 12px;
  border: 0;
  text-align: center;
  position: relative;
  box-shadow: 0 8px 16px rgba(3, 7, 18, 0.2);
  min-width: 180px;
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.kpi-spend { background: rgba(91, 139, 255, 0.18); }
.kpi-results { background: rgba(244, 63, 94, 0.18); }
.kpi-conversations { background: rgba(34, 197, 94, 0.18); }
.kpi-lp { background: rgba(34, 211, 238, 0.18); }
.kpi-leads { background: rgba(245, 158, 11, 0.18); }
.kpi-cpa { background: rgba(167, 139, 250, 0.18); }
.kpi-reach { background: rgba(34, 197, 94, 0.14); }
.kpi-impressions { background: rgba(91, 139, 255, 0.14); }
.kpi-clicks { background: rgba(14, 165, 233, 0.18); }
.kpi-ctr { background: rgba(168, 85, 247, 0.18); }
.kpi-cpc { background: rgba(34, 197, 94, 0.18); }
.kpi-cpm { background: rgba(34, 211, 238, 0.18); }

.kpi-card .label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-card .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.kpi-card .delta {
  margin-top: 6px;
  font-size: 0.7rem;
  font-weight: 600;
}

.delta.pos { color: var(--success); }
.delta.neg { color: var(--danger); }
.delta.neu { color: var(--muted); }

.kpi-row::-webkit-scrollbar {
  height: 6px;
}

.tooltip {
  position: fixed;
  padding: 6px 8px;
  background: rgba(22, 27, 34, 0.9);
  color: var(--text);
  font-size: 0.7rem;
  border-radius: 8px;
  pointer-events: none;
  z-index: 1000;
  max-width: 240px;
  text-align: center;
  border: 1px solid var(--card-border);
}

.tooltip.hidden {
  display: none;
}

/* Charts */
.chart-container {
  flex: 1;
  position: relative;
  min-height: 200px;
  width: 100%;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

/* Tables */
.table-wrapper {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.cols-menu {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.cols-menu label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

th {
  background: rgba(0, 0, 0, 0.3);
  text-align: left;
  padding: 10px;
  position: sticky;
  top: 0;
  backdrop-filter: blur(4px);
  color: var(--muted);
  font-weight: 600;
  z-index: 10;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--card-border);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

td.num {
  text-align: right;
  font-family: 'SF Mono', 'Roboto Mono', monospace;
}

/* Creative Previews */
.creative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  overflow-y: auto;
  max-height: 500px;
  /* Increased height for better visibility */
}

.creative-item {
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  overflow: hidden;
  position: relative;
}

.creative-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  padding: 8px;
  font-size: 0.7rem;
  backdrop-filter: blur(4px);
}

.entity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  max-height: 320px;
}

/* Single-column layout for ads list */
#listAds {
  display: grid;
  grid-template-columns: 1fr;
}

.entity-item {
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(3, 7, 18, 0.2);
}

.entity-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator {
  --status-color: var(--success);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: var(--status-color);
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.status-active {
  --status-color: var(--success);
}

.status-inactive {
  --status-color: var(--danger);
}

.entity-item.active {
  background: rgba(91, 139, 255, 0.16);
}

.entity-item .name {
  font-weight: 600;
  font-size: 0.8rem;
}

.entity-item .meta {
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 2px;
}

.funnel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.funnel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 14px rgba(3, 7, 18, 0.2);
}

.funnel-row:nth-child(1) { background: rgba(91, 139, 255, 0.22); }
.funnel-row:nth-child(2) { background: rgba(34, 211, 238, 0.22); }
.funnel-row:nth-child(3) { background: rgba(14, 165, 233, 0.22); }
.funnel-row:nth-child(4) { background: rgba(244, 63, 94, 0.22); }
.funnel-row:nth-child(5) { background: rgba(34, 197, 94, 0.22); }
.funnel-row:nth-child(6) { background: rgba(167, 139, 250, 0.22); }

.funnel-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.2px;
  font-weight: 600;
}

.funnel-value {
  font-size: 0.8rem;
  color: #fff;
  font-weight: 700;
}

.funnel-rate {
  font-size: 0.7rem;
  color: var(--muted);
  padding-left: 10px;
}

.ad-card {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 10px;
  align-items: center;
}

.ad-info .name {
  font-weight: 600;
  font-size: 0.8rem;
}

.ad-info .meta {
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 4px;
}

.ad-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  background: var(--bg-soft);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 0;
  position: relative;
}

.ad-open {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.7rem;
}

.ad-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  position: relative;
}

.ad-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.8;
}

.ad-thumb-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
  font-size: 1.1rem;
  z-index: 1;
}


.insights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.85rem;
}

.insight-item {
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 14px rgba(3, 7, 18, 0.2);
}

.insight-item strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Responsive */
@media (max-width: 1200px) {
  .bento-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .area-kpis {
    grid-column: span 2;
  }

  .area-trend {
    grid-column: span 2;
  }

  .area-table {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app-container {
    display: block;
    padding: 10px;
    gap: 10px;
  }

  .controls-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px;
  }

  .brand {
    grid-column: 1 / 2;
    margin-right: 0;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-column: 2 / 3;
    justify-self: end;
  }

  .control-account {
    grid-column: 1 / -1;
  }

  .mobile-menu-panel {
    grid-column: 1 / -1;
    display: none;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .controls-bar.mobile-menu-open .mobile-menu-panel {
    display: flex;
  }

  .mobile-menu-panel .control-inline {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  .mobile-menu-panel .control-inline select,
  .mobile-menu-panel .control-inline input,
  .mobile-menu-panel .control-inline button {
    min-width: 0;
    width: 100%;
  }

  .control-account select,
  .control-period select,
  .control-balance .balance-value {
    min-width: 0;
    width: 100%;
  }

  .control-balance .balance-value {
    text-align: left;
  }

  .custom-range {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .custom-range .control-group {
    width: 100%;
  }

  .custom-range .control-group:last-child {
    grid-column: 1 / -1;
  }

  .custom-range input[type="date"] {
    width: 100%;
    min-width: 0;
  }

  .mobile-menu-panel > button {
    width: 100%;
  }

  .controls-theme,
  .controls-fullscreen,
  .controls-report,
  .controls-help,
  .controls-user {
    margin-left: 0;
    align-self: flex-start;
    width: auto;
  }

  .bento-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .kpi-row {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 10px;
    padding-bottom: 6px;
  }

  .kpi-card {
    min-width: 150px;
    flex: 0 0 auto;
    text-align: left;
  }

  .kpi-card .label {
    font-size: 0.7rem;
  }

  .kpi-card .value {
    font-size: 0.98rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .insights-list {
    font-size: 0.8rem;
    gap: 8px;
  }

  .insight-item {
    padding: 9px;
    overflow-wrap: anywhere;
  }

  .footer-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .footer-bar #status {
    font-size: 0.78rem;
  }
}
.footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  padding: 10px 16px;
  border-radius: 12px;
  border: 0;
  box-shadow: var(--shadow);
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-card {
  width: 320px;
  padding: 18px;
  background: var(--card-bg);
  border: 0;
  border-radius: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.modal-card.wide {
  width: min(520px, 92vw);
  max-height: 85vh;
  overflow: auto;
}

.modal-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.progress {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 6px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.ad-preview-frame {
  margin: 12px 0;
  background: #0b0f14;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  max-height: 55vh;
  margin-left: auto;
  margin-right: auto;
}

.ad-preview-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.help-card {
  text-align: left;
  width: min(900px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--card-bg-solid);
  border: 0;
  box-shadow: var(--shadow);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 14px 0 10px;
}

.help-item {
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 14px rgba(3, 7, 18, 0.2);
}

.help-section {
  margin-top: 12px;
}

.help-section-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin: 10px 0 8px;
}

.help-example {
  border: 0;
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 14px rgba(3, 7, 18, 0.2);
}

.help-example .meta {
  color: var(--muted);
  font-size: 0.7rem;
  margin-top: 4px;
}

.help-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.help-badge {
  padding: 4px 8px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.7rem;
  color: var(--muted);
}

.help-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.help-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.help-kpi-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-kpi-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 14px rgba(3, 7, 18, 0.2);
}

.help-kpi-row .kpi-card {
  margin: 0;
}

.help-kpi-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 700px) {
  .help-kpi-row {
    grid-template-columns: 1fr;
  }
}

.help-term {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.help-desc {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

.done-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--success);
  font-weight: 600;
}

.done-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}
