:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(60, 60, 67, 0.16);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --teal: #30b0c7;
  --indigo: #5856d6;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(245, 245, 247, 0.8)),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: rgba(246, 246, 248, 0.86);
  backdrop-filter: blur(24px);
}

.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
}

.app-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(145deg, var(--blue), var(--teal));
  box-shadow: 0 8px 22px rgba(0, 122, 255, 0.24);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  letter-spacing: 0;
}

h2 {
  margin-top: 4px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: rgba(0, 122, 255, 0.1);
}

.nav-item span {
  width: 20px;
  text-align: center;
  color: var(--blue);
}

.sidebar-panel {
  position: absolute;
  right: 18px;
  bottom: 24px;
  left: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
}

.panel-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stack-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stack-flow span,
.pill {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  background: rgba(118, 118, 128, 0.12);
}

.workspace {
  min-width: 0;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar,
.section-heading,
.topbar-actions,
.control-strip {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar-actions {
  gap: 10px;
}

.upload-button,
.ghost-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
}

.upload-button,
.primary-button {
  padding: 0 14px;
  color: #fff;
  background: var(--blue);
}

.ghost-button {
  width: 38px;
  color: var(--text);
  background: rgba(118, 118, 128, 0.12);
}

.upload-button input {
  display: none;
}

.control-strip {
  position: sticky;
  top: 0;
  z-index: 2;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(22px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.04);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="search"] {
  min-height: 36px;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
}

.search-field {
  flex: 1;
}

.search-field input {
  width: 100%;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card,
.chart-panel,
.ai-panel,
.data-section,
.report-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 116px;
  padding: 16px;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 27px;
  letter-spacing: 0;
}

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--green);
}

.warning {
  color: var(--orange);
}

.critical {
  color: var(--red);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.insight-layout,
.split-section {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.chart-panel,
.ai-panel,
.data-section,
.report-section {
  min-width: 0;
  padding: 18px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.score-badge {
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--blue);
  font-size: 13px;
  font-weight: 750;
  background: rgba(0, 122, 255, 0.1);
}

.bar-chart,
.rating-bars,
.suggestion-list,
.keyword-cloud {
  display: grid;
  gap: 12px;
}

.bar-row,
.rating-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 12px;
  min-height: 34px;
}

.bar-track,
.rating-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.12);
}

.bar-fill,
.rating-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.suggestion {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.68);
}

.suggestion strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.suggestion p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  font-size: 14px;
}

.score-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.mini-meter {
  width: 64px;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.12);
}

.mini-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.keyword-cloud {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.keyword {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(48, 176, 199, 0.1);
}

.keyword strong {
  display: block;
  font-size: 18px;
}

.keyword span {
  color: var(--muted);
  font-size: 12px;
}

.creative-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.creative-card,
.report-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.creative-card {
  display: grid;
  gap: 12px;
}

.creative-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  background:
    linear-gradient(135deg, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.02)),
    var(--indigo);
}

.creative-card h4,
.report-card h4 {
  margin: 0;
  font-size: 15px;
}

.creative-card p,
.report-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(18px);
  opacity: 0;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: rgba(29, 29, 31, 0.9);
  box-shadow: var(--shadow);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .insight-layout,
  .split-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .sidebar-panel {
    position: static;
    margin-top: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .control-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  select,
  input[type="search"] {
    width: 100%;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
