/* ===== BASE RESET & VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:      #0d1117;
  --bg-card:      #161b25;
  --bg-card2:     #1c2333;
  --bg-hover:     #1f2d45;
  --accent-blue:  #2563eb;
  --accent-teal:  #0ea5e9;
  --accent-green: #22c55e;
  --accent-red:   #ef4444;
  --accent-orange:#f97316;
  --accent-yellow:#eab308;
  --accent-purple:#a855f7;
  --accent-pink:  #ec4899;
  --text-primary: #e2e8f0;
  --text-secondary:#94a3b8;
  --text-muted:   #64748b;
  --border:       #1e2d42;
  --border2:      #2a3a54;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans Myanmar', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tiktok-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #010101, #1a1a2e);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #333;
  flex-shrink: 0;
}
.header-title {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.header-sub {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 2px;
}
.header-right {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 4px;
}
.header-badge {
  font-size: 10px; color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap;
}
.header-badge2 {
  font-size: 10px; color: var(--accent-orange);
  background: rgba(249,115,22,0.1);
  padding: 2px 8px; border-radius: 20px;
  white-space: nowrap;
}

/* ===== NAV ===== */
.main-nav {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 1;
  min-width: 80px;
  padding: 12px 8px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  white-space: nowrap;
}
.nav-btn:hover { color: var(--text-primary); }
.nav-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== FEATURED CHANNEL ===== */
.featured-channel { padding: 16px; }
.featured-card {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px;
}
.featured-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  margin-bottom: 20px;
}
.fc-name h2 {
  font-size: 20px; font-weight: 700;
  color: var(--text-primary);
}
.fc-handle { font-size: 12px; color: var(--text-muted); }
.fc-stats { display: flex; gap: 20px; }
.fc-stat { text-align: right; }
.fc-stat-val { display: block; font-size: 18px; font-weight: 700; color: var(--text-primary); }
.fc-stat-lbl { font-size: 11px; color: var(--text-muted); }

.featured-cols {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.fc-col h4 { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.fc-col p { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.highlight-col { background: rgba(37,99,235,0.08); border-radius: var(--radius-sm); padding: 10px; border: 1px solid rgba(37,99,235,0.2); }
.highlight-col h4 { display: flex; align-items: center; gap: 6px; }
.dot-orange { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-orange); display: inline-block; }

/* ===== RECOMMENDATIONS ===== */
.recommendations { padding: 0 16px 16px; }
.rec-header {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-blue);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 14px 18px;
}
.rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; display: inline-block; flex-shrink: 0;
}
.rec-header h3 { font-size: 14px; font-weight: 700; color: #fff; }
.rec-list {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px 20px;
  list-style: none;
  counter-reset: rec-counter;
}
.rec-list li {
  counter-increment: rec-counter;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  padding-left: 28px;
  position: relative;
}
.rec-list li:last-child { border-bottom: none; }
.rec-list li::before {
  content: counter(rec-counter) ".";
  position: absolute; left: 0;
  color: var(--accent-blue);
  font-weight: 700; font-size: 13px;
}
.rec-list li strong {
  display: block; font-size: 13px;
  color: var(--text-primary); margin-bottom: 4px;
}
.rec-list li p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

/* ===== TABLE ===== */
.comparison-table-section { padding: 0 16px 16px; }
.section-title {
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.comp-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card);
  min-width: 560px;
}
.comp-table thead th {
  background: var(--bg-card2);
  color: var(--text-secondary);
  font-size: 12px; font-weight: 600;
  padding: 12px 14px; text-align: left;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}
.comp-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.comp-table tbody tr:hover { background: var(--bg-hover); }
.comp-table td {
  padding: 12px 14px; font-size: 12px;
  color: var(--text-primary);
}
.highlight-row { background: rgba(37,99,235,0.06); }
.channel-name-cell { display: flex; align-items: center; gap: 8px; }
.channel-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.channel-dot.blue   { background: var(--accent-blue); }
.channel-dot.teal   { background: var(--accent-teal); }
.channel-dot.purple { background: var(--accent-purple); }
.channel-dot.yellow { background: var(--accent-yellow); }
.channel-dot.pink   { background: var(--accent-pink); }
.eng-rate { color: var(--accent-green); font-weight: 600; }

/* ===== CTA SECTION ===== */
.cta-section { padding: 0 16px 16px; }
.cta-card {
  background: linear-gradient(135deg, #1a2740 0%, #0d1a30 100%);
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.cta-card h3 { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.cta-card p { font-size: 12px; color: var(--text-secondary); }
.cta-btn {
  background: var(--accent-blue);
  color: #fff; border: none; cursor: pointer;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background 0.2s;
}
.cta-btn:hover { background: #1d4ed8; }

/* ===== BOTTOM FEATURES ===== */
.bottom-features {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; padding: 0 16px 16px;
}
.bf-card {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
}
.bf-card h4 { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.bf-card p { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* ===== FOOTER ===== */
.app-footer {
  padding: 16px 20px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.app-footer p { font-size: 11px; color: var(--text-muted); }

/* ===== KPI CARDS ===== */
.kpi-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; padding: 16px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-label {
  font-size: 11px; color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kpi-dot.blue  { background: var(--accent-blue); }
.kpi-dot.red   { background: var(--accent-red); }
.kpi-dot.gray  { background: var(--text-secondary); }
.kpi-val { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.kpi-sub { font-size: 11px; color: var(--text-muted); }

/* ===== CHART SECTIONS ===== */
.chart-section { padding: 0 16px 16px; }
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px;
}
.mt-16 { margin-top: 0; }
.chart-section .chart-card + .chart-card { margin-top: 16px; }
.chart-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.chart-sub { font-size: 11px; color: var(--text-muted); margin-bottom: 16px; }
.chart-legend {
  display: flex; gap: 20px; flex-wrap: wrap;
  margin-top: 12px; font-size: 11px; color: var(--text-secondary);
}
.legend-item.blue  { color: #3b82f6; }
.legend-item.red   { color: #ef4444; }
.legend-item.green { color: #22c55e; }

/* ===== CHANNEL CARDS ===== */
.channels-section, .channels-full-section { padding: 0 16px 16px; }
.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.channel-card:hover { border-color: var(--accent-blue); }
.cc-header {
  display: flex; justify-content: space-between;
  align-items: flex-start; margin-bottom: 12px;
}
.cc-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.cc-handle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.cc-stats { display: flex; gap: 16px; text-align: right; }
.cc-stat-val { display: block; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.cc-stat-lbl { font-size: 11px; color: var(--text-muted); }
.cc-body {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; border-top: 1px solid var(--border); padding-top: 12px;
}
.cc-section h5 { font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.cc-section p { font-size: 11px; color: var(--text-muted); line-height: 1.5; }
.cc-section.highlight h5 { display: flex; align-items: center; gap: 5px; color: var(--accent-orange); }

/* ===== TRACKING PAGE ===== */
.tracking-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px; gap: 12px; flex-wrap: wrap;
}
.tracking-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.tracking-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.add-channel-btn {
  background: var(--accent-blue); color: #fff;
  border: none; cursor: pointer; padding: 10px 16px;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: background 0.2s; flex-shrink: 0;
}
.add-channel-btn:hover { background: #1d4ed8; }

.tracking-layout {
  display: flex; flex-direction: column; gap: 0;
  padding: 0 16px 16px;
}
.channel-list-panel {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.panel-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; }
.channel-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.channel-list-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s;
  border: 1px solid transparent;
}
.channel-list-item .cli-name { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.channel-list-item .cli-handle { font-size: 11px; color: var(--text-muted); }
.channel-list-item:hover { background: var(--bg-card2); }
.channel-list-item.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}
.channel-list-item.active .cli-name { color: #fff; }
.channel-list-item.active .cli-handle { color: rgba(255,255,255,0.7); }

.tracking-main { flex: 1; }
.tracking-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.tracking-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
}
.tki-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; }
.tki-val { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.tki-change { font-size: 11px; margin-top: 2px; }
.tki-change.up { color: var(--accent-green); }
.tki-change.down { color: var(--accent-red); }
.tracking-main .chart-card { margin-bottom: 16px; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 200;
}
.modal-overlay.show { display: block; }
.modal {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg-card2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  width: 90%; max-width: 400px;
  z-index: 201; padding: 0;
  box-shadow: var(--shadow);
}
.modal.show { display: block; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input {
  width: 100%; background: var(--bg-deep);
  border: 1px solid var(--border2); border-radius: var(--radius-sm);
  color: var(--text-primary); padding: 10px 12px; font-size: 13px;
  outline: none; transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--accent-blue); }
.save-btn {
  width: 100%; background: var(--accent-blue); color: #fff;
  border: none; cursor: pointer; padding: 12px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  transition: background 0.2s;
}
.save-btn:hover { background: #1d4ed8; }

/* ===== ENGAGEMENT BADGE ===== */
.eng-badge {
  display: inline-flex; align-items: center;
  background: rgba(34,197,94,0.12); color: var(--accent-green);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 20px; padding: 2px 10px;
  font-size: 11px; font-weight: 600;
}

/* ===== STAT NUMBER HIGHLIGHT ===== */
.stat-highlight {
  color: var(--text-primary); font-weight: 700;
}

/* ===== SCROLLABLE CHART SECTION ===== */
.tracking-charts { display: flex; flex-direction: column; gap: 16px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

/* ===== OVERVIEW STAT ROW ===== */
.overview-stats {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 12px; padding: 0 16px 16px;
}
.ov-stat {
  background: var(--bg-card);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.ov-stat-val { font-size: 20px; font-weight: 700; color: var(--text-primary); display: block; }
.ov-stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  .featured-cols { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .bottom-features { grid-template-columns: 1fr; }
  .cc-body { grid-template-columns: 1fr; }
  .tracking-kpis { grid-template-columns: 1fr; }
  .cta-card { flex-direction: column; }
  .fc-stats { gap: 12px; }
  .header-title { font-size: 14px; }
}
@media (min-width: 768px) {
  .tracking-layout { flex-direction: row; align-items: flex-start; }
  .channel-list-panel { width: 260px; flex-shrink: 0; margin-bottom: 0; margin-right: 16px; }
  .channel-list { max-height: none; }
}
