:root {
  color-scheme: light;
  --orange: #f26a2e;
  --orange-dark: #c84f1d;
  --orange-soft: #fff0e7;
  --anthracite: #202124;
  --anthracite-2: #303136;
  --muted: #756f68;
  --bg: #f7f1e8;
  --bg-soft: #fbf7f0;
  --panel: #fffdf8;
  --panel-soft: #fff8ef;
  --line: #eadfce;
  --line-strong: #dacbb7;
  --green: #23784d;
  --yellow: #a76518;
  --red: #a83b32;
  --blue: #315f91;
  --radius: 12px;
  --radius-sm: 8px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 20px;
  --text-xl: 28px;
  --shadow: 0 14px 36px rgba(42, 35, 29, 0.08);
  --shadow-soft: 0 8px 22px rgba(42, 35, 29, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--anthracite);
  background:
    radial-gradient(circle at top left, rgba(242, 106, 46, 0.10), transparent 32%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--text-md);
}

button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 16px; line-height: 1.2; letter-spacing: 0; }
h2 { font-size: var(--text-xl); line-height: 1.12; letter-spacing: 0; }
h3 { font-size: var(--text-md); line-height: 1.25; letter-spacing: 0; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
  color: #fff8ef;
  background: linear-gradient(180deg, #202124 0%, #171719 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-1) var(--space-4);
  border-bottom: 1px solid rgba(255, 248, 239, 0.10);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #fff7ed;
  font-weight: 900;
  background: linear-gradient(135deg, var(--orange), #ff9f68);
  box-shadow: 0 10px 22px rgba(242, 106, 46, 0.28);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--orange);
  font-size: var(--text-xs);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sidebar .eyebrow { color: #ffb287; }

.side-nav {
  display: grid;
  gap: 5px;
  margin-top: var(--space-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 var(--space-2);
  color: #d6cfc4;
  text-align: left;
  font-size: var(--text-md);
  font-weight: 800;
  cursor: pointer;
  background: transparent;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: #ffbd93;
  font-size: 10px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item:hover,
.nav-item.active {
  color: #fffdf8;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
  border-color: rgba(242, 106, 46, 0.45);
  box-shadow: inset 3px 0 0 var(--orange);
}

.nav-item.active span {
  color: #fffdf8;
  background: var(--orange);
}

.workspace { min-width: 0; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 610px);
  gap: var(--space-4);
  padding: 22px clamp(18px, 3vw, 38px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.86);
  backdrop-filter: blur(10px);
}

.hero h2 {
  font-size: clamp(28px, 3vw, 34px);
}

.hero-copy {
  max-width: 660px;
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.hero-status {
  display: flex;
  align-content: start;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.pill, .decision-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 900;
  background: var(--panel-soft);
}

.pill.good, .score-good { color: var(--green); border-color: #c7dfce; background: #f2fbf4; }
.pill.warn, .score-mid { color: var(--yellow); border-color: #f0cfaa; background: #fff5e6; }
.pill.bad, .score-low { color: var(--red); border-color: #efc7c0; background: #fff2ef; }
.pill.safe { color: var(--blue); border-color: #c9d7e8; background: #f2f6fb; }
.pill.dark { color: #fff8ef; border-color: #303136; background: var(--anthracite); }

.decision-produce { color: var(--green); border-color: #c7dfce; background: #f2fbf4; }
.decision-test { color: var(--yellow); border-color: #f0cfaa; background: #fff5e6; }
.decision-skip { color: var(--red); border-color: #efc7c0; background: #fff2ef; }

.content {
  display: grid;
  gap: var(--space-4);
  width: min(1460px, calc(100% - 32px));
  margin: var(--space-4) auto 42px;
}

.view, .system-panel, .panel-card, .history-section, .score-hero, .score-card, .action-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.view { display: none; padding: var(--space-5); }
.view.active { display: grid; gap: var(--space-4); }

#view-product-intelligence {
  border-color: rgba(242, 106, 46, 0.28);
  background: linear-gradient(180deg, #fffdf8 0%, #fff9f2 100%);
  box-shadow: var(--shadow);
}

.module-section {
  display: grid;
  gap: var(--space-2);
}

.module-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-3);
}

.module-title h3,
.card h3,
.panel-card h3,
.history-section h3 {
  color: var(--anthracite-2);
  font-size: var(--text-sm);
  font-weight: 900;
  text-transform: uppercase;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.section-head.compact { margin-bottom: var(--space-3); }

.metric-grid, .report-grid, .history-grid, .score-layout, .settings-grid, .system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.metric-grid { grid-template-columns: repeat(6, minmax(138px, 1fr)); }
.report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.score-layout { grid-template-columns: 255px minmax(0, 1fr); align-items: stretch; }
.system-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.span-2 { grid-column: 1 / -1; }

.action-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  padding: var(--space-4);
  border-color: rgba(242, 106, 46, 0.22);
  background: linear-gradient(135deg, #fffdf8, #fff4e9);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 850;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--anthracite);
  background: #fffefa;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(242, 106, 46, 0.65);
  box-shadow: 0 0 0 3px rgba(242, 106, 46, 0.12);
}

textarea { min-height: 118px; resize: vertical; }

button {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 13px;
  color: #fffdf8;
  font-size: var(--text-sm);
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  box-shadow: 0 9px 18px rgba(242, 106, 46, 0.18);
}

button:hover { filter: brightness(0.97); }
button:disabled { cursor: not-allowed; opacity: 0.55; box-shadow: none; }
.secondary {
  border: 1px solid var(--line);
  color: var(--anthracite);
  background: #fff9f0;
  box-shadow: none;
}

.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: var(--text-md);
}
.message.success { color: var(--green); }
.message.error { color: var(--red); }
.message.info { color: var(--orange-dark); }

.score-hero {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-2);
  min-height: 232px;
  padding: var(--space-5);
  border-color: rgba(242, 106, 46, 0.30);
  background:
    linear-gradient(180deg, rgba(242, 106, 46, 0.10), transparent),
    var(--panel);
}

.score-hero strong {
  color: var(--anthracite);
  font-size: 52px;
  line-height: 1;
}

.ai-verdict-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid rgba(242, 106, 46, 0.34);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(242, 106, 46, 0.12), transparent 46%),
    var(--panel);
  box-shadow: var(--shadow);
}

.ai-verdict-hero h3 {
  margin-bottom: var(--space-2);
  color: var(--anthracite);
  font-size: 28px;
  text-transform: none;
}

.verdict-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
}

.verdict-grid article {
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 248, 239, 0.78);
}

.verdict-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 900;
  text-transform: uppercase;
}

.verdict-grid strong {
  display: block;
  color: var(--anthracite);
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.verdict-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
}

.score-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: var(--space-2);
}

.score-card, .panel-card, .history-section { padding: var(--space-3); }
.score-card { display: grid; gap: var(--space-2); border-top: 3px solid var(--orange); }
.score-card strong { font-size: 25px; }
.score-card span { color: var(--muted); font-size: var(--text-xs); font-weight: 900; text-transform: uppercase; }

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee2d2;
}
.bar span { display: block; height: 100%; background: var(--orange); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: var(--text-sm);
}
.data-table th {
  color: var(--orange-dark);
  font-size: var(--text-xs);
  text-transform: uppercase;
  background: #fff4e7;
}
.data-table small { display: block; margin-top: 5px; color: var(--muted); }

.stack { display: grid; gap: var(--space-2); }
.empty { color: var(--muted); }

.empty-state, .loading-state {
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--bg-soft);
}
.loading-state { border-color: #f7bd9b; color: var(--orange-dark); background: #fff2e8; }

.card {
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.card h3, .panel-card h3, .history-section h3 { margin-bottom: 8px; }
.meta { color: var(--muted); font-size: var(--text-sm); line-height: 1.55; }

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: var(--space-2);
}
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid #f0c2a6;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--orange-dark);
  font-size: var(--text-xs);
  font-weight: 850;
  background: var(--orange-soft);
}

.tag-row.empty {
  color: var(--muted);
  font-size: var(--text-sm);
}

.metric-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.metric-line strong {
  color: var(--anthracite);
  font-size: 22px;
}

.opportunity-meter {
  display: grid;
  gap: var(--space-2);
}

.meter-track {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee2d2;
}

.meter-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--yellow), var(--orange), var(--green));
}

.meter-empty {
  color: var(--muted);
  font-size: var(--text-sm);
}

.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.executive-card-grid,
.competitor-card-grid,
.market-health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
}

.competitor-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.market-health-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.executive-card-grid.empty,
.competitor-card-grid.empty {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
}

.summary-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: var(--space-2);
  border-radius: 8px;
  color: #fffdf8;
  font-size: 11px;
  font-weight: 900;
  background: var(--orange);
}

.market-health-card {
  min-width: 0;
}

.market-health-card .metric-line {
  align-items: start;
}

.market-health-card .metric-line strong {
  font-size: 18px;
}

.competitor-card {
  min-width: 0;
}

.recommendation-grid .card {
  border-left: 3px solid var(--orange);
}

.recommendation-grid.empty {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
}

.copy-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.copy-row button {
  min-height: 30px;
  flex: 0 0 auto;
  padding: 0 9px;
  font-size: var(--text-xs);
}

.copy-block {
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--anthracite);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #fffefa;
}

.compact-list {
  display: grid;
  gap: 7px;
  margin: var(--space-2) 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.compact-list strong { color: var(--anthracite); }
.compact-list span { display: block; margin-top: 3px; }

.accordion {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.accordion summary {
  padding: 12px var(--space-3);
  cursor: pointer;
  font-weight: 900;
}
.accordion > div { padding: 0 var(--space-3) var(--space-3); }

.system-panel { padding: var(--space-4); }

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

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .side-nav { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .nav-item { flex: 0 0 auto; }
  .hero { grid-template-columns: 1fr; }
  .hero-status { justify-content: flex-start; }
  .ai-verdict-hero { grid-template-columns: 1fr; }
  .verdict-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .verdict-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .executive-card-grid, .competitor-card-grid, .market-health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recommendation-grid { grid-template-columns: 1fr; }
  .score-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .content { width: min(100% - 20px, 1460px); margin-top: 12px; }
  .view { padding: var(--space-3); }
  .section-head, .copy-row, .module-title { display: grid; }
  .metric-grid, .report-grid, .history-grid, .settings-grid, .system-grid, .action-panel, .score-card-grid {
    grid-template-columns: 1fr;
  }
  h2 { font-size: 23px; }
  .hero h2 { font-size: 28px; }
  .ai-verdict-hero { padding: var(--space-3); }
  .ai-verdict-hero h3 { font-size: 24px; }
  .verdict-grid, .verdict-actions, .executive-card-grid, .competitor-card-grid, .market-health-grid { grid-template-columns: 1fr; }
  .score-hero strong { font-size: 46px; }
  .span-2 { grid-column: auto; }
  .button-row { display: grid; }
}
