/* ─── Market Research Dashboard — Google Analytics Style ─── */
@import url('https://fonts.googleapis.com/css2?family=Google+Sans:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap');

:root {
  --bg:        #f8f9fa;
  --bg2:       #ffffff;
  --bg3:       #f1f3f4;
  --border:    #dadce0;
  --text:      #202124;
  --text-muted:#5f6368;
  --accent:    #1a73e8;
  --green:     #34a853;
  --purple:    #7b1fa2;
  --orange:    #fa7b17;
  --danger:    #ea4335;
  --yellow:    #fbbc04;
  --radius:    8px;
  --shadow:    0 1px 2px rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
  --shadow-sm: 0 1px 2px rgba(60,64,67,0.2);
  --bg-input:  #ffffff;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Roboto', 'Google Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  height: 64px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-weight: 400; font-size: 18px; white-space: nowrap;
  color: var(--text-muted);
  letter-spacing: 0;
}
.nav-logo-icon { font-size: 22px; }
.nav-spacer { flex: 1; }

.nav-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  animation: pulse 2.5s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.5; }
}

/* ── Tab Nav (GA-style underline tabs) ─────────── */
.tab-nav {
  display: flex; gap: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  padding-left: 4px;
}
.tab-btn {
  padding: 0 16px;
  height: 48px;
  border: none; border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px; font-weight: 500;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  position: relative;
}
.tab-btn::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: transparent;
  border-radius: 2px 2px 0 0;
  transition: background .15s;
}
.tab-btn:hover { color: var(--accent); background: rgba(26,115,232,0.06); }
.tab-btn.active {
  color: var(--accent);
  background: transparent;
}
.tab-btn.active::after { background: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Settings ────────────────────────────────────── */
.settings-btn {
  padding: 0 12px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 4px; background: transparent;
  color: var(--text-muted); font-size: 13px;
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.settings-btn:hover { background: var(--bg3); border-color: rgba(0,0,0,0.2); }

.settings-panel {
  position: absolute; top: 68px; right: 14px;
  background: #ffffff; border: none;
  border-radius: var(--radius); padding: 16px;
  min-width: 340px; z-index: 200;
  box-shadow: 0 4px 8px 3px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.3);
  display: none; flex-direction: column; gap: 10px;
}
.settings-panel.open { display: flex; }
.settings-panel label { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.settings-panel input {
  background: var(--bg3); border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 4px 4px 0 0; padding: 8px 10px; color: var(--text);
  font-size: 13px; width: 100%; font-family: 'Roboto', sans-serif;
  transition: border-color .15s;
}
.settings-panel input:focus { outline: none; border-bottom: 2px solid var(--accent); background: #e8f0fe; }
.btn-save-settings {
  padding: 0 16px; height: 36px; background: var(--accent); border: none;
  border-radius: 4px; color: #fff; font-size: 14px;
  font-family: 'Google Sans', sans-serif;
  font-weight: 500; cursor: pointer; margin-top: 6px;
  transition: box-shadow .15s, background .15s;
  letter-spacing: .025em;
}
.btn-save-settings:hover { background: #1557b0; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

/* ── Main Container ──────────────────────────────── */
.main {
  max-width: 1440px; margin: 0 auto;
  padding: 24px 24px 48px;
}

/* ── Brand Report Header ─────────────────────────── */
.br-header {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 12px; justify-content: space-between;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.br-brand-sel {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* ── Filters Bar ─────────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px; padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-weight: 500; }
.filter-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.filter-chip {
  padding: 4px 12px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); border-radius: 16px;
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all .15s;
  font-family: 'Google Sans', 'Roboto', sans-serif;
}
.filter-chip:hover { background: rgba(26,115,232,0.06); border-color: var(--accent); color: var(--accent); }
.filter-chip.active {
  background: #e8f0fe;
  border-color: var(--accent);
  color: var(--accent);
}

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 24px; padding: 6px 14px;
  margin-left: auto;
  transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #fff; }
.search-box input {
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 14px; width: 220px;
  font-family: 'Roboto', sans-serif;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ── Stats Row ───────────────────────────────────── */
.stats-row {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 16px; margin-bottom: 20px;
}
@media (max-width:900px) { .stats-row { grid-template-columns: repeat(2,1fr); } }

.stat-card {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 20px 16px;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
  font-weight: 500; margin-bottom: 6px;
}
.stat-value { font-size: 32px; font-weight: 400; margin: 4px 0; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.purple { color: var(--purple); }
.stat-value.orange { color: var(--orange); }

/* ── Charts ──────────────────────────────────────── */
.charts-row {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.chart-card {
  flex: 1; min-width: 220px;
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
}
.chart-title {
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  margin-bottom: 12px; letter-spacing: .01em;
}
.chart-wrap { height: 160px; position: relative; }

/* ── Section ─────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title { font-size: 16px; font-weight: 500; color: var(--text); }
.section-count { font-size: 12px; color: var(--text-muted); }
.view-toggle { display: flex; gap: 2px; }
.view-btn {
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 4px; background: transparent;
  color: var(--text-muted); font-size: 16px; cursor: pointer;
  transition: all .15s;
}
.view-btn:hover, .view-btn.active {
  background: #e8f0fe; color: var(--accent);
  border-color: var(--accent);
}

/* ── Ad Grid ─────────────────────────────────────── */
.loading-wrap {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 60px 0; color: var(--text-muted);
  grid-column: 1/-1;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(26,115,232,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px,1fr));
  gap: 16px;
}
.ad-grid.list-view { grid-template-columns: 1fr; }

.ad-card {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  transition: box-shadow .2s, border-color .2s;
}
.ad-card:hover {
  border-color: rgba(26,115,232,0.5);
  box-shadow: 0 1px 6px rgba(32,33,36,0.28);
}

.ad-thumb-wrap {
  position: relative; height: 160px;
  background: var(--bg3); overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.ad-thumb-wrap img, .ad-thumb-wrap video {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.no-thumb {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-muted);
}
.ad-format-badge {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.6); border-radius: 4px;
  padding: 2px 8px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: #fff;
}
.ad-active-badge {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 2px rgba(52,168,83,0.25);
}
.ad-active-badge.inactive { background: var(--text-muted); box-shadow: none; }

.ad-body { padding: 12px 14px; }
.ad-id { font-family: monospace; font-size: 10px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.ad-copy {
  font-size: 13px; line-height: 1.5; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
  margin: 5px 0;
}
.ad-cid {
  font-family: monospace; font-size: 10px;
  color: var(--accent); opacity: .7; display: block; margin-bottom: 6px;
}
.ad-meta { display: flex; gap: 5px; flex-wrap: wrap; }

.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 12px;
  background: var(--bg3); color: var(--text-muted);
  font-weight: 500;
}
.tag.active { background: #e6f4ea; color: var(--green); }
.tag.video { background: #e8f0fe; color: var(--accent); }
.tag.competitor { background: #f3e8fd; color: var(--purple); }

/* ── Table view ──────────────────────────────────── */
.ad-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.ad-table th {
  text-align: left; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 500;
  position: sticky; top: 64px; background: var(--bg);
}
.ad-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f3f4;
  vertical-align: middle;
}
.ad-table tr:hover td { background: #f8f9fa; }

/* ── Creative Cluster Grid ───────────────────────── */
.cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px; margin-bottom: 8px;
}
.cluster-card {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.cluster-card:hover {
  box-shadow: 0 1px 6px rgba(32,33,36,0.2);
  border-color: rgba(26,115,232,0.4);
}
.cluster-thumbs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 2px; height: 120px; background: var(--bg3); overflow: hidden;
}
.cluster-thumbs img, .cluster-thumbs video { width: 100%; height: 100%; object-fit: cover; }
.cluster-thumbs .no-thumb { font-size: 22px; background: var(--bg3); }
.cluster-body { padding: 12px 14px; }
.cluster-cid {
  font-family: monospace; font-size: 11px;
  color: var(--purple); margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cluster-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cluster-copy {
  font-size: 12px; color: var(--text-muted); margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Top Ads List ────────────────────────────────── */
.top-ads-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.top-ad-row {
  display: flex; align-items: flex-start; gap: 14px;
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  transition: box-shadow .15s;
}
.top-ad-row:hover { box-shadow: var(--shadow-sm); }
.top-ad-thumb {
  width: 60px; height: 60px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0; background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-muted); overflow: hidden;
}
.top-ad-thumb img, .top-ad-thumb video { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.top-ad-info { flex: 1; min-width: 0; }
.top-ad-copy { font-size: 13px; margin-bottom: 6px; line-height: 1.4; }
.top-ad-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.top-ad-num { font-size: 20px; font-weight: 400; color: var(--text-muted); min-width: 28px; text-align: center; }

/* ── Pivot Select ────────────────────────────────── */
.pivot-select {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 10px;
  color: var(--text); font-size: 13px; cursor: pointer;
  font-family: 'Roboto', sans-serif;
  transition: border-color .15s;
}
.pivot-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ── Pivot Table ─────────────────────────────────── */
.pivot-wrap {
  overflow: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: #ffffff; max-height: 600px;
}
.pivot-table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.pivot-table th {
  position: sticky; top: 0;
  background: var(--bg3); z-index: 3;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); white-space: nowrap; font-weight: 500;
  text-align: left;
}
.pivot-table th.col-header { text-align: center; }
.pivot-table th.row-sticky { position: sticky; left: 0; z-index: 4; background: var(--bg3); }
.pivot-table td {
  padding: 9px 14px;
  border-right: 1px solid #f1f3f4;
  border-bottom: 1px solid #f1f3f4;
  text-align: center; white-space: nowrap;
}
.pivot-table td.row-label {
  position: sticky; left: 0; background: #ffffff; z-index: 2;
  text-align: left; font-weight: 500;
  border-right: 1px solid var(--border); color: var(--text);
}
.pivot-table td.total-col {
  font-weight: 700; color: var(--accent);
  background: #e8f0fe; border-left: 1px solid var(--border);
}
.pivot-table tr:hover td { background: #f8f9fa; }
.pivot-table tr:hover td.row-label { background: #f1f3f4; }

.pivot-cell-heat-1 { background: rgba(52,168,83,0.08); }
.pivot-cell-heat-2 { background: rgba(52,168,83,0.15); color: var(--green); }
.pivot-cell-heat-3 { background: rgba(52,168,83,0.28); color: #1e7e34; font-weight: 600; }
.pivot-cell-heat-4 { background: rgba(52,168,83,0.50); color: #fff; font-weight: 700; }

/* ── Modal ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.3); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: #ffffff; border: none;
  border-radius: 8px; width: 540px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 10px 1px rgba(0,0,0,0.14), 0 3px 14px 2px rgba(0,0,0,0.12), 0 5px 5px -3px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 500; font-family: 'Google Sans', sans-serif; }
.modal-close {
  background: transparent; border: none; padding: 4px;
  color: var(--text-muted); font-size: 20px; cursor: pointer;
  border-radius: 50%; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.modal-close:hover { background: var(--bg3); }
.modal-thumb { width: 100%; max-height: 280px; object-fit: cover; }
.modal-copy { padding: 16px 24px; font-size: 14px; line-height: 1.6; border-bottom: 1px solid var(--border); }
.modal-fields { padding: 16px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-field label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; font-weight: 500; }
.modal-field span { font-size: 13px; word-break: break-all; }

/* ── Period Bar ──────────────────────────────────── */
.period-bar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px; padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.period-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.period-btn {
  padding: 5px 14px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); border-radius: 16px;
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all .15s;
  font-family: 'Google Sans', 'Roboto', sans-serif;
}
.period-btn:hover { background: rgba(26,115,232,0.06); border-color: var(--accent); color: var(--accent); }
.period-btn.active {
  background: #e8f0fe;
  border-color: var(--accent); color: var(--accent);
}
.period-custom { display: flex; align-items: center; gap: 8px; }
.date-input {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 10px;
  color: var(--text); font-size: 12px; cursor: pointer;
  font-family: 'Roboto', sans-serif;
}
.date-input:focus { outline: none; border-color: var(--accent); }
.period-label-active { font-size: 12px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* ── New Creatives highlight ─────────────────────── */
.cluster-card.new-creative { border-color: rgba(26,115,232,0.4); box-shadow: 0 0 0 1px rgba(26,115,232,0.15); }
.new-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  background: #e8f0fe; color: var(--accent);
  border-radius: 10px; padding: 1px 8px; margin-left: 6px;
  vertical-align: middle; letter-spacing: .02em;
}

/* ══════════════════════════════════════════════════
   MARKET INSIGHTS TAB
══════════════════════════════════════════════════ */
.insights-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; flex-wrap: wrap;
  gap: 14px; padding: 16px 20px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 20px;
}

.insights-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-top: 4px;
}
@media (max-width: 900px) { .insights-grid { grid-template-columns: 1fr; } }

.insight-card {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: box-shadow .2s;
}
.insight-card:hover { box-shadow: var(--shadow-sm); }
.insight-card-title {
  font-size: 13px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 16px;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid #f1f3f4; padding-bottom: 10px;
}

.keyword-cloud { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; line-height: 1.8; }
.kw-tag {
  color: var(--accent); font-weight: 500; cursor: default;
  padding: 3px 10px; border-radius: 12px;
  background: #e8f0fe; font-size: 12px;
  transition: background .15s;
}
.kw-tag:hover { background: #d2e3fc; }

.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.topic-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; background: #fff;
  transition: box-shadow .15s;
}
.topic-card:hover { box-shadow: var(--shadow-sm); }
.topic-bar { height: 3px; border-radius: 2px; margin-bottom: 12px; }
.topic-name { font-size: 14px; font-weight: 500; margin-bottom: 5px; }
.topic-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; }
.topic-examples { display: flex; flex-direction: column; gap: 3px; }
.topic-ex {
  font-size: 11px; color: var(--text-muted); font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 1; line-clamp: 1;
  -webkit-box-orient: vertical; overflow: hidden;
}

.gap-item { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-bottom: 1px solid #f1f3f4; }
.gap-item:last-child { border-bottom: none; padding-bottom: 0; }
.gap-num {
  min-width: 28px; height: 28px;
  background: #e8f0fe; border-radius: 50%; font-weight: 700; font-size: 13px;
  color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.gap-text { font-size: 13px; line-height: 1.6; padding-top: 2px; }

.comp-breakdown-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.comp-breakdown-card { background: #f8f9fa; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; transition: box-shadow .2s; }
.comp-breakdown-card:hover { box-shadow: var(--shadow-sm); }
.comp-bd-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.comp-bd-name { font-size: 13px; font-weight: 500; }
.comp-bd-count { font-size: 11px; color: var(--text-muted); }
.comp-bd-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.comp-bd-kws { display: flex; gap: 5px; flex-wrap: wrap; }
.kw-mini { font-size: 11px; padding: 2px 8px; background: #e8f0fe; border-radius: 10px; color: var(--accent); font-weight: 500; }

/* ══════════════════════════════════════════════════
   AI CHAT TAB — GA style
══════════════════════════════════════════════════ */
.chat-page {
  display: flex; flex-direction: column;
  max-width: 880px; margin: 0 auto;
  padding: 24px 24px 40px;
  height: calc(100vh - 64px - 48px);
}

/* ── Chat settings bar ─────────────────────────── */
.chat-settings-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}
.chat-lang-select {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 10px;
  color: var(--text); font-size: 13px; cursor: pointer;
  font-family: 'Roboto', sans-serif;
}
.chat-lang-select:focus { outline: none; border-color: var(--accent); }

/* ── Chat wrap ─────────────────────────────────── */
.chat-wrap {
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; flex: 1;
}

/* ── Chat header ───────────────────────────────── */
.chat-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}
.chat-status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); flex-shrink: 0; margin-top: 5px;
}
.chat-clear-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-muted);
  font-size: 13px; font-family: 'Roboto', sans-serif;
  padding: 5px 12px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chat-clear-btn:hover { border-color: var(--danger); color: var(--danger); background: #fce8e6; }

/* ── Suggestion chips ──────────────────────────── */
.chat-chips {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 12px 18px;
  border-bottom: 1px solid #f1f3f4;
  background: #fafafa;
}
.chat-chip {
  padding: 5px 14px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); border-radius: 16px;
  background: #ffffff; color: var(--text-muted);
  cursor: pointer; transition: all .15s; white-space: nowrap;
  font-family: 'Google Sans', 'Roboto', sans-serif;
}
.chat-chip:hover {
  background: #e8f0fe; border-color: var(--accent); color: var(--accent);
  box-shadow: 0 1px 2px rgba(26,115,232,0.2);
}

/* ── Messages area ─────────────────────────────── */
.chat-messages {
  flex: 1; min-height: 320px; max-height: 480px;
  overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth; background: var(--bg);
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 3px; }

/* ── Message bubbles ───────────────────────────── */
.chat-bubble-row { display: flex; gap: 10px; align-items: flex-start; animation: fadeUp .2s ease; }
.chat-bubble-row.user { flex-direction: row-reverse; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #e8f0fe;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0; border: 1px solid #c5d8fb;
}
.chat-bubble-row.user .chat-avatar { background: #e6f4ea; border-color: #a8d5b5; }

.chat-bubble {
  max-width: 78%; padding: 12px 16px; border-radius: 12px;
  font-size: 14px; line-height: 1.65;
}
.chat-bubble-row.assistant .chat-bubble {
  background: #ffffff; border: 1px solid var(--border);
  border-top-left-radius: 4px; color: var(--text);
  box-shadow: 0 1px 2px rgba(60,64,67,0.1);
}
.chat-bubble-row.user .chat-bubble {
  background: #e8f0fe; border: 1px solid #c5d8fb;
  border-top-right-radius: 4px; color: #1a237e;
}

/* ── Typing indicator ──────────────────────────── */
.chat-typing { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce { 0%,80%,100% { transform: scale(.7); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* ── Chat input row ────────────────────────────── */
.chat-input-row {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--border);
  background: #ffffff;
}
.chat-textarea {
  flex: 1; min-height: 40px; max-height: 120px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 10px 16px;
  color: var(--text); font-size: 14px;
  font-family: 'Roboto', sans-serif; resize: none;
  transition: border-color .15s, background .15s; line-height: 1.45;
}
.chat-textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.chat-textarea::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; transition: background .15s, box-shadow .15s;
}
.chat-send-btn:hover { background: #1557b0; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.chat-send-btn:active { background: #0d47a1; }
.chat-send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Bubble markdown ───────────────────────────── */
.chat-bubble strong { color: #1a73e8; font-weight: 600; }
.chat-bubble em { color: var(--text-muted); font-style: italic; }
.chat-bubble code {
  background: #f1f3f4; border-radius: 3px;
  padding: 1px 5px; font-size: 12px; font-family: 'Roboto Mono', monospace;
  color: var(--text);
}
.chat-bubble ul { padding-left: 18px; margin: 6px 0; }
.chat-bubble li { margin: 3px 0; }
