:root {
  color-scheme: dark;
  --bg: #0b0c0b;
  --panel: rgba(252, 248, 239, 0.075);
  --panel-strong: rgba(21, 23, 22, 0.82);
  --line: rgba(250, 244, 232, 0.15);
  --text: #f6efe7;
  --muted: #afa79b;
  --blue: #79c6d1;
  --green: #74d28c;
  --amber: #d7a85d;
  --coral: #ee7468;
  --violet: #b9a2ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 96px),
    linear-gradient(118deg, #0c0c0b 0%, #151815 48%, #0b0e10 100%);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.62;
}

.dashboard {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  min-height: 100vh;
  padding: 14px;
}

.glass {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.sidebar,
.settings,
.panel,
.kpi,
.hero {
  border-radius: 8px;
}

.sidebar {
  position: sticky;
  top: 14px;
  height: auto;
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  overflow: auto;
  background: linear-gradient(180deg, rgba(252, 248, 239, 0.1), rgba(252, 248, 239, 0.045));
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--amber), var(--green));
  color: #10110f;
  font-weight: 800;
}

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

h1 {
  font-size: 20px;
}

h2 {
  margin-top: 4px;
  font-size: 32px;
  line-height: 1.05;
}

h3 {
  font-size: 17px;
}

h4 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.brand p,
.hero p,
.settings-note,
.panel p,
small {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

select,
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 12px;
}

option {
  background: #111821;
}

.segment,
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.tabs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.segment button,
.tabs button,
.ghost-btn {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segment button.active,
.tabs button.active {
  background: rgba(215, 168, 93, 0.18);
  color: var(--text);
}

.source-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.primary-btn,
.secondary-btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  border: 0;
  background: linear-gradient(135deg, var(--amber), var(--green));
  color: #10110f;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 118px;
  padding: 22px 24px;
  background:
    linear-gradient(135deg, rgba(252, 248, 239, 0.1), rgba(121, 198, 209, 0.06)),
    rgba(0, 0, 0, 0.16);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  display: grid;
  min-height: 104px;
  padding: 16px;
  border-top: 3px solid var(--blue);
  background: linear-gradient(180deg, rgba(252, 248, 239, 0.09), rgba(252, 248, 239, 0.045));
}

.kpi.green {
  border-left-color: var(--green);
}

.kpi.amber {
  border-left-color: var(--amber);
}

.kpi.coral {
  border-left-color: var(--coral);
}

.kpi.violet {
  border-left-color: var(--violet);
}

.kpi span,
.kpi small {
  color: var(--muted);
}

.kpi strong {
  align-self: center;
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  align-items: start;
  gap: 12px;
}

.panel {
  min-width: 0;
  padding: 18px;
  background: linear-gradient(180deg, rgba(252, 248, 239, 0.08), rgba(252, 248, 239, 0.04));
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.ai-panel,
.benchmark-panel {
  grid-column: span 1;
}

.ai-panel {
  position: relative;
  overflow: hidden;
  border-color: rgba(215, 168, 93, 0.32);
  background:
    linear-gradient(145deg, rgba(252, 248, 239, 0.12), rgba(121, 198, 209, 0.055) 45%, rgba(0, 0, 0, 0.12)),
    rgba(0, 0, 0, 0.12);
}

.ai-panel::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--amber), var(--green), var(--blue));
  content: "";
}

.summary {
  margin-bottom: 14px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}

.ai-brief-card {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(250, 244, 232, 0.22);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(246, 239, 231, 0.14), rgba(121, 198, 209, 0.075)),
    rgba(0, 0, 0, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 14px 28px rgba(0, 0, 0, 0.18);
}

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

.brief-kicker {
  color: #efd8ad;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.brief-score {
  border: 1px solid rgba(116, 210, 140, 0.38);
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(116, 210, 140, 0.12);
  color: #c9f3d4;
  font-size: 14px;
}

.brief-summary {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.58;
}

.brief-meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.brief-meta-row span {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid rgba(250, 244, 232, 0.14);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.brief-meta-row strong,
.brief-action-strip strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.brief-meta-row strong {
  color: var(--text);
  font-size: 13px;
}

.brief-meta-row small,
.brief-action-strip span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.brief-action-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(215, 168, 93, 0.34);
  border-radius: 8px;
  padding: 12px;
  background: rgba(215, 168, 93, 0.1);
}

.brief-action-strip strong {
  color: #ffe8b8;
  line-height: 1.35;
}

.status-pill {
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  font-size: 12px;
}

.status-pill.fallback {
  color: var(--amber);
}

.status-pill.working {
  color: var(--blue);
}

.evidence-list {
  display: grid;
  gap: 10px;
}

.evidence-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.evidence-title span {
  color: var(--text);
  font-weight: 800;
}

blockquote {
  margin: 0;
  border-left: 2px solid rgba(215, 168, 93, 0.75);
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.14);
  color: #dce7f6;
  line-height: 1.45;
}

blockquote span {
  display: block;
  margin-bottom: 4px;
  color: var(--amber);
  font-size: 12px;
}

.topic-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.topic,
.action-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.ai-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.16);
  color: var(--muted);
  line-height: 1.35;
}

.ai-status strong {
  color: var(--text);
  white-space: nowrap;
}

.ai-status.fallback {
  border-color: rgba(215, 168, 93, 0.45);
}

.ai-status.ready {
  border-color: rgba(116, 210, 140, 0.45);
}

.ai-status.working {
  border-color: rgba(121, 198, 209, 0.45);
}

.action-card div,
.table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.topic div {
  display: grid;
  align-items: start;
  justify-content: start;
  gap: 2px;
  min-width: 0;
}

.topic span,
.action-card span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.topic strong,
.action-card strong,
.table-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.topic strong {
  overflow-wrap: normal;
  word-break: normal;
}

meter {
  width: 100%;
  height: 8px;
}

.action-card p {
  color: #dce7f6;
  line-height: 1.45;
}

.chart-panel {
  overflow: hidden;
}

.trend-frame {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(250, 244, 232, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.14);
  scrollbar-color: rgba(215, 168, 93, 0.6) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.bars {
  display: flex;
  align-items: end;
  gap: 10px;
  width: 100%;
  min-width: max(100%, calc(var(--bar-count, 18) * 38px));
  min-height: 122px;
  max-height: 156px;
  padding: 12px;
  border-radius: 8px;
}

.bar-wrap {
  display: grid;
  align-items: end;
  justify-items: center;
  flex: 1;
  min-width: 26px;
  gap: 6px;
}

.bar-wrap small {
  font-size: 10px;
  white-space: nowrap;
}

.bar {
  width: 100%;
  max-width: 28px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, rgba(217, 185, 124, 0.95), rgba(91, 207, 168, 0.72));
  box-shadow: 0 10px 24px rgba(91, 207, 168, 0.14);
}

.bar.strong {
  background: linear-gradient(180deg, rgba(91, 207, 168, 0.98), rgba(217, 185, 124, 0.76));
}

.bar.steady {
  background: linear-gradient(180deg, rgba(217, 185, 124, 0.96), rgba(144, 169, 199, 0.76));
}

.bar.risk {
  background: linear-gradient(180deg, rgba(235, 111, 89, 0.96), rgba(217, 185, 124, 0.72));
}

.bar.visit-only {
  background: linear-gradient(180deg, rgba(144, 169, 199, 0.9), rgba(217, 185, 124, 0.54));
  opacity: 0.82;
}

.rating-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.rating-row span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
}

.table {
  display: grid;
  gap: 8px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 0.95fr 0.7fr 0.7fr auto;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.14);
  text-align: left;
}

.table-row strong {
  color: var(--text);
}

.competitor-row {
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.competitor-row:hover,
.competitor-row:focus-visible {
  border-color: rgba(215, 168, 93, 0.46);
  background: rgba(215, 168, 93, 0.1);
  transform: translateY(-1px);
  outline: none;
}

.row-action {
  justify-self: end;
  border: 1px solid rgba(116, 210, 140, 0.34);
  border-radius: 999px;
  padding: 4px 8px;
  color: #c9f3d4;
  background: rgba(116, 210, 140, 0.1);
  font-size: 11px;
  font-weight: 800;
}

.mini-map {
  position: relative;
  min-height: 220px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(135deg, rgba(121, 198, 209, 0.12), rgba(215, 168, 93, 0.09));
  background-size: 42px 42px, 42px 42px, auto;
}

.sync-btn {
  width: 100%;
  margin: 8px 0 12px;
}

.model-picker {
  display: grid;
  gap: 10px;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 10px;
  align-items: end;
}

.detect-models-btn {
  min-height: 44px;
}

.model-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.model-status.ready {
  border-color: rgba(116, 210, 140, 0.45);
  color: #c9f3d4;
}

.model-status.error {
  border-color: rgba(238, 116, 104, 0.48);
  color: #ffd5d1;
}

.model-status.disabled {
  border-color: rgba(215, 168, 93, 0.42);
  color: #efd8ad;
}

.model-status.working {
  border-color: rgba(121, 198, 209, 0.45);
  color: #c8eef3;
}

.live-review-note {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--muted);
  line-height: 1.4;
}

.live-review-note.ready {
  border-color: rgba(84, 214, 138, 0.45);
}

.live-review-note.error {
  border-color: rgba(255, 123, 114, 0.5);
}

.pin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--violet);
  color: #10110f;
  font-weight: 800;
}

.pin.selected {
  width: 38px;
  height: 38px;
  background: var(--green);
}

.settings {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: none;
  width: min(420px, calc(100vw - 36px));
  padding: 18px;
  gap: 14px;
}

.settings.open {
  display: grid;
}

.error {
  margin-bottom: 12px;
  color: var(--coral);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

@media (max-width: 760px) {
  .dashboard {
    padding: 10px;
  }

  .hero,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  h2 {
    font-size: 26px;
  }

  .kpi-grid,
  .topic-columns {
    grid-template-columns: 1fr;
  }

  .table-row {
    grid-template-columns: 1fr 1fr;
  }

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

  .brief-card-top,
  .evidence-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .brief-meta-row,
  .brief-action-strip {
    grid-template-columns: 1fr;
  }

  .model-row {
    grid-template-columns: 1fr;
  }
}
