:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #0d121d;
  --panel-2: #111827;
  --panel-3: #151d2d;
  --line: #263244;
  --text: #edf5ff;
  --muted: #8c9aad;
  --faint: #536174;
  --green: #10d692;
  --cyan: #2dd4bf;
  --blue: #60a5fa;
  --rose: #fb7185;
  --amber: #fbbf24;
  --purple: #c084fc;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 25% 0%, rgba(16, 214, 146, 0.11), transparent 24rem),
    radial-gradient(circle at 80% 10%, rgba(96, 165, 250, 0.08), transparent 26rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

#app {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 78px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  background: rgba(10, 15, 27, 0.9);
  border-right: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 24px 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--green), #2563eb);
  color: #041014;
  font-weight: 950;
  font-size: 24px;
  box-shadow: 0 16px 38px rgba(16, 214, 146, 0.18);
}

.side-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  cursor: pointer;
}

.side-icon.active {
  background: rgba(16, 214, 146, 0.11);
  border-color: rgba(16, 214, 146, 0.25);
  color: var(--green);
}

.sidebar-version {
  margin-top: auto;
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  writing-mode: vertical-rl;
}

.shell {
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(20px, 4vw, 44px);
  background: rgba(10, 15, 27, 0.78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

.topbar h1 span {
  color: var(--green);
  font-size: 13px;
  vertical-align: middle;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.system-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(21, 29, 45, 0.78);
  color: var(--green);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(16, 214, 146, 0.12);
}

.workspace {
  max-width: 1480px;
  margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 44px) 44px;
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.control-panel,
.report-panel,
.report,
.empty-state,
.loading-state {
  background: rgba(13, 18, 29, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 118px;
  border-radius: 18px;
  padding: 20px;
}

.report-panel {
  min-height: 680px;
  border-radius: 20px;
  overflow: hidden;
}

.panel-head,
.report-toolbar,
.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head {
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.section-kicker,
.step-tag {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.step-tag {
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 6px 8px;
}

.panel-head h2,
.report-toolbar h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.module-grid {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.module-card {
  text-align: left;
  color: var(--text);
  background: rgba(17, 24, 39, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
}

.module-card span {
  display: block;
  font-weight: 900;
  margin-bottom: 5px;
}

.module-card small {
  color: var(--muted);
  line-height: 1.45;
}

.module-card.active {
  border-color: rgba(16, 214, 146, 0.32);
  background: linear-gradient(135deg, rgba(16, 214, 146, 0.12), rgba(96, 165, 250, 0.08));
}

.module-card.muted {
  opacity: 0.45;
  cursor: not-allowed;
}

.match-picker {
  margin-top: 18px;
}

.picker-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.picker-head h3 {
  margin: 4px 0 0;
  font-size: 16px;
}

.match-count {
  color: var(--green);
  border: 1px solid rgba(16, 214, 146, 0.22);
  background: rgba(16, 214, 146, 0.08);
  border-radius: 999px;
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.filter-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 14px 0 4px;
  padding: 4px;
  background: rgba(10, 15, 27, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
}

.filter-chip {
  min-width: 0;
  height: 34px;
  color: var(--muted);
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.filter-chip.active {
  color: #041014;
  background: linear-gradient(135deg, var(--green), var(--cyan));
}

.field-label {
  display: block;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-input,
.select-input {
  width: 100%;
  background: var(--panel-3);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  outline: none;
}

.search-input,
.select-input {
  height: 44px;
  padding: 0 13px;
}

.search-input:focus,
.select-input:focus {
  border-color: rgba(16, 214, 146, 0.66);
}

.selected-match-card {
  margin-top: 12px;
  display: grid;
  gap: 5px;
  padding: 13px;
  border: 1px solid rgba(16, 214, 146, 0.28);
  background: linear-gradient(135deg, rgba(16, 214, 146, 0.12), rgba(96, 165, 250, 0.08));
  border-radius: 14px;
}

.selected-match-card strong {
  font-size: 16px;
  line-height: 1.35;
}

.selected-match-card small {
  color: #b6c4d7;
  line-height: 1.45;
}

.selected-match-card em {
  color: var(--amber);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.selected-kicker {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.match-list {
  margin-top: 14px;
  max-height: 390px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.match-item {
  width: 100%;
  text-align: left;
  background: rgba(10, 15, 27, 0.86);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.match-item:hover {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(21, 29, 45, 0.9);
  transform: translateY(-1px);
}

.match-item.active {
  border-color: rgba(16, 214, 146, 0.5);
  background: rgba(16, 214, 146, 0.08);
}

.match-item.locked {
  opacity: 0.56;
  cursor: not-allowed;
}

.match-item.locked:hover {
  transform: none;
  background: rgba(10, 15, 27, 0.86);
}

.match-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.match-row-top b {
  color: var(--green);
  font-size: 11px;
}

.match-row-top small {
  color: var(--faint);
  font-size: 10px;
  font-weight: 900;
}

.match-item strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  line-height: 1.35;
}

.match-item strong span {
  color: var(--faint);
  font-size: 12px;
  margin: 0 2px;
}

.match-item small {
  color: var(--muted);
  line-height: 1.45;
}

.match-empty {
  color: var(--muted);
  border: 1px dashed rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  font-size: 13px;
}

.mini-head span {
  font-size: 12px;
  font-weight: 900;
}

.mini-head small {
  color: var(--muted);
}

.primary-button,
.ghost-button {
  border-radius: 14px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  height: 52px;
  margin-top: 18px;
  color: #041014;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 18px 40px rgba(16, 214, 146, 0.14);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.primary-button.compact {
  width: auto;
  height: 42px;
  margin-top: 0;
  padding: 0 18px;
}

.empty-state,
.loading-state {
  min-height: 680px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 34px;
  border: 0;
  box-shadow: none;
}

.empty-state h2,
.loading-state h2 {
  margin: 18px 0 8px;
}

.empty-state p,
.loading-state p {
  max-width: 620px;
  color: var(--muted);
  line-height: 1.75;
}

.empty-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.empty-tags span,
.score-chips span {
  border: 1px solid rgba(16, 214, 146, 0.22);
  background: rgba(16, 214, 146, 0.08);
  color: var(--green);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 800;
}

.orbital-ball {
  width: 80px;
  height: 80px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent 47%, rgba(5, 7, 10, 0.8) 48% 52%, transparent 53%),
    linear-gradient(0deg, transparent 47%, rgba(5, 7, 10, 0.8) 48% 52%, transparent 53%),
    radial-gradient(circle at 35% 30%, #ffffff, #8ff4cd 28%, #10d692 58%, #0a6b57);
  box-shadow: 0 0 70px rgba(16, 214, 146, 0.32);
}

.loader {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 4px solid rgba(16, 214, 146, 0.18);
  border-top-color: var(--green);
  animation: spin 0.9s linear infinite;
}

.trace {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.report {
  border: 0;
  box-shadow: none;
  border-radius: 0;
  padding: 22px;
}

.report-toolbar {
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.ghost-button {
  color: var(--text);
  background: rgba(21, 29, 45, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.16);
  padding: 11px 14px;
}

.ghost-button.strong {
  color: #041014;
  background: linear-gradient(135deg, var(--green), var(--cyan));
}

.match-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: linear-gradient(135deg, rgba(16, 214, 146, 0.11), rgba(96, 165, 250, 0.08));
  border-radius: 18px;
}

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

.match-hero h3 {
  margin: 6px 0 0;
  font-size: clamp(22px, 4vw, 34px);
}

.rating-pill {
  color: var(--green);
  border: 1px solid rgba(16, 214, 146, 0.28);
  background: rgba(16, 214, 146, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 950;
  min-width: 86px;
  text-align: center;
}

.rating-box {
  display: grid;
  gap: 7px;
  justify-items: end;
  max-width: 190px;
}

.rating-box small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: right;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.score-grid > div,
.probability-card,
.dimension-card,
.strategy-card,
.summary-card,
.source-card {
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(10, 15, 27, 0.74);
  border-radius: 16px;
}

.score-grid > div {
  padding: 14px;
}

.score-grid small {
  display: block;
  color: var(--faint);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.score-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.probability-card,
.research-meta,
.summary-card,
.source-card {
  padding: 16px;
}

.probability-rows {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.prob-row {
  display: grid;
  gap: 7px;
}

.prob-row-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.12);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.dimension-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.dimension-card {
  padding: 16px;
}

.research-meta {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(10, 15, 27, 0.74);
  border-radius: 16px;
}

.research-meta p {
  margin: 7px 0 0;
  color: #cbd5e1;
  line-height: 1.68;
  font-size: 13px;
}

.recheck-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.recheck-tags span {
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.22);
  background: rgba(251, 191, 36, 0.08);
  border-radius: 999px;
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 800;
}

.dimension-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dimension-card h4 {
  margin: 0 0 10px;
  color: var(--text);
}

.dimension-title-row em {
  flex: 0 0 auto;
  color: var(--green);
  background: rgba(16, 214, 146, 0.08);
  border: 1px solid rgba(16, 214, 146, 0.18);
  border-radius: 999px;
  padding: 6px 8px;
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
}

.dimension-card p {
  color: #cbd5e1;
  line-height: 1.72;
  font-size: 13px;
  margin: 0;
}

.dimension-score {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.dimension-score span {
  padding: 5px 7px;
  background: rgba(21, 29, 45, 0.78);
  border-radius: 8px;
}

.dimension-analysis {
  margin-top: 12px;
}

.inline-report-block {
  margin: 10px 0 0;
  color: #cbd5e1;
  line-height: 1.72;
  font-size: 13px;
}

.inline-report-block strong {
  color: var(--green);
}

.bottom-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 14px;
  margin-top: 16px;
}

.strategy-card {
  padding: 16px;
}

.strategy-card p,
.summary-card p {
  color: #cbd5e1;
  line-height: 1.72;
}

.score-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
}

.score-chips span {
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

.summary-card,
.source-card {
  margin-top: 16px;
}

.source-card a {
  display: inline-flex;
  margin: 8px 8px 0 0;
  color: var(--text);
  text-decoration: none;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(21, 29, 45, 0.7);
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
}

.hidden {
  display: none;
}

.access-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 7, 10, 0.72);
  backdrop-filter: blur(14px);
}

.access-modal.hidden {
  display: none;
}

.access-dialog {
  width: min(430px, 100%);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(13, 18, 29, 0.98), rgba(17, 24, 39, 0.98));
  box-shadow: var(--shadow);
  padding: 22px;
}

.access-dialog h2 {
  margin: 8px 0 8px;
  font-size: 22px;
}

.access-dialog p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 13px;
}

.access-input {
  width: 100%;
  height: 46px;
  color: var(--text);
  background: rgba(10, 15, 27, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  padding: 0 13px;
  outline: none;
}

.access-input:focus {
  border-color: rgba(16, 214, 146, 0.68);
  box-shadow: 0 0 0 4px rgba(16, 214, 146, 0.08);
}

.access-error {
  display: block;
  min-height: 18px;
  margin-top: 9px;
  color: var(--amber);
  font-size: 12px;
  line-height: 1.45;
}

.access-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

  .control-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  #app {
    display: block;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    justify-content: center;
    position: static;
    padding: 12px;
  }

  .sidebar-version {
    display: none;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    padding: 14px;
  }

  .score-grid,
  .dimension-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .match-hero,
  .report-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions button {
    flex: 1;
  }

  .access-actions {
    flex-direction: column-reverse;
  }

  .access-actions button {
    width: 100%;
  }
}

@media print {
  body {
    background: white;
    color: #0f172a;
  }

  .sidebar,
  .topbar,
  .control-panel,
  .no-print,
  .empty-state,
  .loading-state {
    display: none !important;
  }

  #app,
  .shell,
  .workspace,
  .report-panel {
    display: block;
    padding: 0;
    margin: 0;
    background: white;
    box-shadow: none;
    border: 0;
  }

  .report {
    color: #0f172a;
    background: white;
  }

  .match-hero,
  .score-grid > div,
  .probability-card,
  .dimension-card,
  .strategy-card,
  .summary-card,
  .source-card {
    break-inside: avoid;
    border-color: #cbd5e1;
    background: white;
    color: #0f172a;
  }

  .dimension-card p,
  .strategy-card p,
  .summary-card p {
    color: #1e293b;
  }
}
