:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface2: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
  --border: rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 1px 0 var(--border);
}

.site-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.site-header .tagline {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.site-nav a {
  margin-right: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav a.active,
.site-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.site-nav a.active { font-weight: 600; }

.header-user {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--muted);
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 40rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h2, .card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.card .card-desc {
  font-size: 0.82rem;
  color: var(--muted);
  margin: -0.35rem 0 1rem;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
}

.pill strong { color: var(--text); font-weight: 600; }

.pill-active {
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.muted-inline { color: var(--muted); font-weight: 400; }

.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  margin-top: 0.75rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.pill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: #1e40af;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.banner .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.toast {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.toast-warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tabs a {
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

.tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-meta {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  line-height: 1.5;
}

.strategic-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.strategic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.strategic-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.strategic-card .card-desc {
  margin-bottom: 0.65rem;
}

.strategic-card-opportunity {
  border-left: 4px solid var(--warn);
}

.strategic-card-strength {
  border-left: 4px solid var(--ok);
}

.strategic-card-rating {
  border-left: 4px solid var(--accent);
}

.strategic-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.strategic-rating-val {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0.25rem 0 0.35rem;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi {
  background: var(--surface2);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
}

.kpi .label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi .val {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 0.2rem;
}

.kpi .val.ok { color: var(--ok); }
.kpi .val.bad { color: var(--danger); }

.kpi-hint {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.review-feed {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.review-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: var(--surface2);
}

.review-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.45rem;
}

.review-stars {
  color: #ca8a04;
  letter-spacing: 0.05em;
  font-size: 0.9rem;
}

.review-date {
  font-size: 0.78rem;
  color: var(--muted);
}

.review-model {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}

.review-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.review-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.tag-positive { border-color: #bbf7d0; color: #166534; background: #f0fdf4; }
.tag-negative { border-color: #fecaca; color: #991b1b; background: #fef2f2; }
.tag-neutral { color: var(--muted); }

.badge-jtbd {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}

.badge.sentiment-positive { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge.sentiment-negative { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.sentiment-neutral { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.data th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

table.data tbody tr:hover { background: var(--surface2); }

table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

tr.row-scraping td {
  color: var(--muted);
  opacity: 0.85;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-own { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.badge-scrape { background: #f1f5f9; color: #475569; }
.badge-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-admin { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }

.gap-good { color: var(--ok); font-weight: 600; }
.gap-bad { color: var(--danger); font-weight: 600; }
.gap-verdict { font-size: 0.82rem; color: var(--muted); }
.gap-pos { color: var(--danger); font-weight: 600; }

.chart-wrap.compact { height: 200px; }
.chart-wrap.compact.tall { height: 240px; }

.card-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.card-head-row h3 { margin: 0; }

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.badge-ok {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.trend-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: 0;
  z-index: 5;
}

.trend-nav a {
  font-size: 0.82rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}

.trend-nav a:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.trend-section { scroll-margin-top: 4rem; }

.report-collapse summary {
  cursor: pointer;
  list-style: none;
}

.report-collapse summary::-webkit-details-marker { display: none; }

.review-feed.compact .review-item {
  padding: 0.65rem 0.85rem;
}

.empty-state.compact {
  padding: 1rem;
}

.kpi .val.bad { color: var(--danger); }

.text-ok { color: var(--ok); }
.text-bad { color: var(--danger); }

.season-grid {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.75rem 0;
}

.chart-wrap {
  position: relative;
  height: 260px;
  margin-top: 0.5rem;
}

.chart-wrap.tall { height: 320px; }

.report-md { font-size: 0.95rem; line-height: 1.65; }
.report-md h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
.report-md h3 { font-size: 1rem; margin: 1rem 0 0.4rem; color: var(--muted); }
.report-md p { margin: 0.5rem 0; }
.report-md ul, .report-md ol { margin: 0.5rem 0; padding-left: 1.35rem; }
.report-md li { margin: 0.35rem 0; }
.report-md strong { color: var(--text); }

.report-dates {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.report-dates a { margin-right: 0.35rem; }

.ai-insights { margin-bottom: 1.25rem; }

.ai-insights-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  font-size: 0.82rem;
  margin-bottom: 0.85rem;
}

.ai-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.78rem;
}

.ai-insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.ai-block {
  background: linear-gradient(145deg, var(--surface) 0%, rgba(37, 99, 235, 0.04) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ai-block-executive {
  grid-column: 1 / -1;
  border-color: rgba(37, 99, 235, 0.35);
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.06) 0%, var(--surface) 60%);
}

.ai-block-head {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.ai-block-head-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.ai-block-kind {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.report-data-appendix {
  margin-top: 1rem;
  font-size: 0.88rem;
}

.report-data-appendix > summary {
  cursor: pointer;
  color: var(--muted);
}

.report-data-inner {
  margin-top: 0.75rem;
}

.ai-block-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.ai-block-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ai-block-headline {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.ai-block-insight {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
}

.ai-block-actions {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.ai-block-actions li { margin: 0.2rem 0; }

.report-expand {
  margin-top: 1rem;
  font-size: 0.88rem;
}

.report-expand > summary {
  cursor: pointer;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.report-recs-list li {
  font-size: 0.9rem;
}

.report-section {
  margin: 1.25rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.report-section:first-of-type { border-top: none; padding-top: 0; }

.report-section h3 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.report-list {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.report-list li { margin: 0.3rem 0; }

.ops-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.ops-kpi {
  flex: 1 1 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
}

.ops-val { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.ops-lbl { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }

.ops-subhead {
  font-size: 0.85rem;
  margin: 1rem 0 0.4rem;
  color: var(--muted);
}

.ops-caveat {
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.6rem;
}

.metrics-legend summary {
  cursor: pointer;
  list-style: none;
  padding: 0.25rem 0;
}

.metrics-legend summary::-webkit-details-marker { display: none; }

.metrics-dl {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  line-height: 1.55;
}

.metrics-dl dt {
  font-weight: 600;
  color: var(--text);
  margin-top: 0.65rem;
}

.metrics-dl dd {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.th-help {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: help;
}

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

.themes-rest {
  margin-top: 0.85rem;
}

.themes-rest > summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--accent);
}

.themes-rest > summary::-webkit-details-marker {
  display: none;
}

.review-scope-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.review-scope-tabs a {
  font-size: 0.82rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
}

.review-scope-tabs a.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.empty-state h4 {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-size: 1rem;
}

.empty-state p { margin: 0 0 1rem; font-size: 0.88rem; }

.empty-state .icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

button, .btn {
  font: inherit;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  display: inline-block;
}

button:hover, .btn:hover { background: var(--accent-hover); filter: none; }

button.secondary, .btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover { background: var(--surface2); }

form.inline { display: inline; }

input, select, textarea {
  font: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  width: 100%;
  max-width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--accent);
}

label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

.form-row { margin-bottom: 0.75rem; }

.form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
  font-size: 0.88rem;
  color: var(--text);
}

.form-check input { width: auto; }

.login-page {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card h2 { margin-bottom: 0.25rem; }

.login-card .sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 1.25rem; }

.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

footer.site-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
