:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #16201d;
  --muted: #65706b;
  --line: #dce3df;
  --teal: #117c73;
  --teal-2: #d9efec;
  --coral: #d65f45;
  --gold: #c79728;
  --green: #4c8d54;
  --blue: #315f9f;
  --violet: #7562a8;
  --shadow: 0 16px 42px rgba(22, 32, 29, 0.08);
  --shadow-soft: 0 6px 18px rgba(22, 32, 29, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button:hover {
  border-color: var(--teal);
  color: var(--teal);
  transform: translateY(-1px);
}

a {
  color: inherit;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 30px clamp(18px, 4vw, 54px) 22px;
  background:
    linear-gradient(135deg, rgba(17, 124, 115, 0.08), rgba(214, 95, 69, 0.05)),
    var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-header h1 {
  max-width: 100%;
  margin: 4px 0 0;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  line-height: 1.06;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

.app-header > div {
  min-width: 0;
  max-width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.source-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.source-pill strong {
  color: var(--ink);
}

.publish-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}

main {
  padding: 22px clamp(18px, 4vw, 54px) 46px;
}

.tab-nav {
  position: sticky;
  top: 0;
  z-index: 4;
  display: inline-flex;
  gap: 6px;
  max-width: 100%;
  margin-bottom: 14px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.tab-button,
.metric-button {
  min-height: 34px;
  border-radius: 6px;
  white-space: nowrap;
}

.tab-button.is-active,
.metric-button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(7, minmax(132px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.metric-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
}

.metric-strip > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-buttons {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(17, 124, 115, 0.18);
  outline-offset: 2px;
  border-color: var(--teal);
}

.filter-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(86px, 1fr));
  gap: 8px;
}

.filter-actions button:last-child {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

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

.kpi-card,
.insight-card,
.analysis-card,
.recommendation-card,
.rank-item,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.kpi-card .label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.kpi-card .value {
  margin: 0;
  font-size: clamp(1.45rem, 2.5vw, 2.1rem);
  font-weight: 850;
  line-height: 1.05;
}

.kpi-card .sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.insight-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  min-height: 104px;
  border-top: 4px solid var(--teal);
}

.insight-card:nth-child(2) {
  border-top-color: var(--coral);
}

.insight-card:nth-child(3) {
  border-top-color: var(--gold);
}

.insight-card:nth-child(4) {
  border-top-color: var(--green);
}

.insight-card .title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.insight-card .value {
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-card .detail {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

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

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-wide,
.panel-full {
  grid-column: 1 / -1;
}

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

.panel h2 {
  margin: 3px 0 0;
  font-size: 1.08rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--teal-2);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.chart-area {
  min-height: 280px;
  overflow: hidden;
}

.trend-svg,
.scatter-svg {
  display: block;
  width: 100%;
  height: 280px;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(118px, 0.9fr) minmax(110px, 1.6fr) minmax(66px, auto);
  gap: 10px;
  align-items: center;
  min-height: 34px;
}

.bar-label {
  overflow: hidden;
  color: var(--ink);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8eeeb;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 99px;
  background: var(--teal);
}

.bar-row:nth-child(3n + 2) .bar-fill {
  background: var(--coral);
}

.bar-row:nth-child(3n + 3) .bar-fill {
  background: var(--gold);
}

.bar-row:nth-child(3n + 4) .bar-fill {
  background: var(--blue);
}

.bar-value {
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.heatmap {
  display: grid;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap-cell,
.heatmap-label {
  min-width: 68px;
  min-height: 42px;
  border-radius: 6px;
  padding: 8px;
  font-size: 0.76rem;
}

.heatmap-label {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

.heatmap-cell {
  display: grid;
  align-items: center;
  border: 1px solid rgba(22, 32, 29, 0.07);
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f7f5;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
  white-space: nowrap;
}

th[data-sort] {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fbfa;
}

td {
  color: var(--ink);
  font-size: 0.9rem;
}

.numeric {
  text-align: right;
  white-space: nowrap;
}

.name-cell {
  min-width: 170px;
  font-weight: 800;
}

.match-cell {
  max-width: 460px;
  min-width: 280px;
  line-height: 1.35;
}

.muted {
  color: var(--muted);
}

.analysis-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.analysis-card {
  min-height: 132px;
  padding: 16px;
  border-top: 4px solid var(--teal);
}

.analysis-card:nth-child(2) {
  border-top-color: var(--blue);
}

.analysis-card:nth-child(3) {
  border-top-color: var(--coral);
}

.analysis-card:nth-child(4) {
  border-top-color: var(--violet);
}

.analysis-card .label,
.recommendation-card .label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.analysis-card .value {
  display: block;
  overflow: hidden;
  margin-bottom: 8px;
  font-size: 1.16rem;
  font-weight: 850;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-card .detail,
.recommendation-card p,
.rank-item span,
.quadrant-label {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.38;
}

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

.recommendation-card {
  min-height: 132px;
  padding: 16px;
  border-left: 4px solid var(--teal);
  box-shadow: var(--shadow-soft);
}

.recommendation-card:nth-child(2) {
  border-left-color: var(--coral);
}

.recommendation-card:nth-child(3) {
  border-left-color: var(--gold);
}

.recommendation-card:nth-child(4) {
  border-left-color: var(--blue);
}

.recommendation-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.recommendation-card p {
  margin: 0;
}

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

.rank-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  box-shadow: var(--shadow-soft);
}

.rank-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--teal);
  font-weight: 850;
}

.rank-main {
  min-width: 0;
}

.rank-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  color: var(--ink);
  font-weight: 850;
  white-space: nowrap;
}

.quadrant-chart {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(0deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px)),
    #fbfcfc;
}

.quadrant-dot {
  position: absolute;
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 4px 12px rgba(22, 32, 29, 0.2);
  transform: translate(-50%, -50%);
}

.quadrant-dot:nth-child(3n + 1) {
  background: var(--coral);
}

.quadrant-dot:nth-child(3n + 2) {
  background: var(--gold);
}

.quadrant-label {
  position: absolute;
  max-width: 130px;
  padding: 8px;
  font-weight: 750;
}

.quadrant-label.top-left {
  top: 8px;
  left: 8px;
}

.quadrant-label.top-right {
  top: 8px;
  right: 8px;
  text-align: right;
}

.quadrant-label.bottom-left {
  bottom: 8px;
  left: 8px;
}

.quadrant-label.bottom-right {
  right: 8px;
  bottom: 8px;
  text-align: right;
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 18px;
  margin-bottom: 18px;
}

.planner-input-panel,
.assistant-panel {
  min-height: 360px;
}

.planner-label {
  display: grid;
  gap: 8px;
}

.planner-scope {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.planner-textarea {
  min-height: 190px;
  padding: 12px;
  line-height: 1.45;
  resize: vertical;
}

.planner-actions,
.assistant-compose,
.suggestion-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.planner-actions button:last-child,
.assistant-compose button {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.assistant-compose {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
}

.suggestion-buttons button {
  min-height: 34px;
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.assistant-answer {
  min-height: 154px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  line-height: 1.45;
}

.assistant-answer p {
  margin: 0 0 10px;
}

.assistant-answer p:last-child {
  margin-bottom: 0;
}

.planner-results {
  display: grid;
  gap: 14px;
}

.game-plan-card {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 1.4fr);
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  box-shadow: var(--shadow-soft);
}

.game-plan-main {
  min-width: 0;
}

.game-plan-main h3 {
  margin: 8px 0 8px;
  font-size: 1.12rem;
  line-height: 1.25;
}

.game-plan-main p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.42;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.score-pill,
.reason-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.score-pill {
  background: var(--ink);
  color: #ffffff;
}

.reason-pill {
  background: var(--teal-2);
  color: var(--teal);
}

.talent-picks {
  display: grid;
  gap: 8px;
}

.talent-pick {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.talent-pick strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.talent-role {
  display: inline-flex;
  margin: 3px 0 4px;
  color: var(--ink);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 850;
}

.talent-pick span {
  color: var(--muted);
  font-size: 0.84rem;
}

.talent-score {
  color: var(--teal);
  font-weight: 850;
  white-space: nowrap;
}

.stream-table table {
  min-width: 980px;
}

.data-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 1500px) {
  .filter-panel {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }

  .filter-actions {
    grid-column: span 2;
  }
}

@media (max-width: 1300px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .analysis-summary,
  .recommendation-grid {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
  }

  .game-plan-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 880px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-panel,
  .kpi-grid,
  .insight-grid,
  .analysis-summary,
  .recommendation-grid,
  .planner-layout,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    grid-column: auto;
  }

  .panel-wide,
  .panel-full {
    grid-column: auto;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-value {
    text-align: left;
  }

  .metric-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .assistant-compose {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app-header > div:first-child {
    width: 100%;
  }

  .app-header h1 {
    font-size: 1.4rem;
    line-height: 1.12;
  }

  .source-pill {
    white-space: normal;
  }

  .filter-actions {
    grid-template-columns: 1fr;
  }
}
