:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --ink: #18201d;
  --muted: #66736d;
  --line: #dce2dc;
  --soft: #e8eee7;
  --accent: #0f8b72;
  --accent-2: #c98b2e;
  --danger: #ad3e37;
  --shadow: 0 22px 70px rgba(24, 32, 29, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(244, 245, 241, 0.95)),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1400px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.shell-wide {
  width: calc(100% - 24px);
  max-width: none;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  font-size: 21px;
  line-height: 1.18;
}

.status,
.period,
.muted {
  color: var(--muted);
  font-size: 14px;
}

.status {
  max-width: 420px;
  text-align: right;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.nav-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  background: rgba(15, 139, 114, 0.08);
  border: 1px solid rgba(15, 139, 114, 0.2);
  border-radius: 7px;
}

.controls {
  display: grid;
  grid-template-columns: 120px 145px 200px 160px 180px minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.subject-controls {
  grid-template-columns: 140px 180px 240px 180px 180px minmax(160px, 1fr);
}

.control {
  display: grid;
  gap: 7px;
}

.control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.control input,
.control select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.control input:focus,
.control select:focus {
  border-color: rgba(15, 139, 114, 0.7);
  box-shadow: 0 0 0 4px rgba(15, 139, 114, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  margin-top: 18px;
}

.graph-panel,
.inspector,
.table-section {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.graph-panel {
  min-height: 590px;
  padding: 22px 22px 10px;
  overflow: hidden;
}

.graph-head,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

#stockGraph {
  display: block;
  width: 100%;
  height: min(62vh, 520px);
  min-height: 420px;
  margin-top: 10px;
}

.outer-circle {
  fill: #dfe9e2;
  stroke: #8da69c;
  stroke-width: 2;
  filter: url("#softShadow");
}

.inner-circle {
  fill: rgba(15, 139, 114, 0.86);
  stroke: #0b6958;
  stroke-width: 2;
  transition: r 420ms ease, cx 420ms ease, cy 420ms ease;
}

.leader {
  fill: none;
  stroke: #8da69c;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.leader.accent {
  stroke: var(--accent);
}

.svg-caption {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.svg-caption.accent {
  fill: #0b6958;
}

.center-number {
  fill: var(--ink);
  font-size: 44px;
  font-weight: 780;
}

.center-label {
  fill: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.inspector {
  display: grid;
  gap: 1px;
  align-content: start;
  overflow: hidden;
}

.kpi {
  display: grid;
  gap: 7px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.74);
  border-bottom: 1px solid var(--line);
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi strong {
  font-size: 28px;
  line-height: 1.05;
}

.kpi.accent strong {
  color: var(--accent);
}

.note {
  padding: 20px 22px 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.table-section {
  margin-top: 18px;
  padding: 20px 20px 10px;
}

.subjects-panel {
  margin-top: 18px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.total {
  background: #dfe9e2;
  border: 1px solid #8da69c;
}

.legend-dot.selected {
  background: var(--accent);
}

.legend-dot.gender {
  background: var(--accent-2);
}

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.graph-toolbar button {
  min-width: 42px;
  height: 36px;
  padding: 0 10px;
  color: var(--ink);
  font-weight: 850;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.graph-toolbar button:hover {
  transform: translateY(-1px);
  background: rgba(15, 139, 114, 0.08);
  border-color: rgba(15, 139, 114, 0.35);
}

.graph-toolbar button:disabled {
  color: rgba(31, 42, 38, 0.32);
  background: rgba(255, 255, 255, 0.64);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.graph-toolbar button.is-active,
.graph-toolbar button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(15, 139, 114, 0.16);
}

.graph-toolbar .icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.graph-toolbar .icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.graph-toolbar .icon-button + .icon-button {
  margin-right: 6px;
}

.graph-toolbar span {
  min-width: 48px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.neural-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(320px, 18vw, 390px);
  gap: 16px;
  align-items: start;
  margin-top: 6px;
}

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

.neural-wrap {
  width: 100%;
  margin-top: 18px;
  overflow: auto;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 45%, rgba(15, 139, 114, 0.1), transparent 28%),
    linear-gradient(180deg, rgba(248, 250, 247, 0.92), rgba(255, 255, 255, 0.82));
  border: 1px solid var(--line);
}

#neuralGraph {
  display: block;
  width: 2200px;
  max-width: none;
  height: 900px;
  min-height: 720px;
  transition: width 180ms ease, height 180ms ease;
}

.neural-edge {
  fill: none;
  stroke: rgba(102, 115, 109, 0.34);
  stroke-linecap: round;
}

.neural-edge.gender-edge {
  stroke: rgba(201, 139, 46, 0.55);
}

.neural-edge.subject-edge {
  stroke: rgba(15, 139, 114, 0.3);
}

.neural-edge.article-edge {
  stroke: rgba(15, 139, 114, 0.34);
}

.neural-edge.sku-edge {
  stroke: rgba(91, 118, 111, 0.24);
}

.neural-node {
  cursor: default;
}

.neural-node.is-clickable {
  cursor: pointer;
}

#neuralGraph.is-transitioning .neural-node.is-clickable {
  pointer-events: none;
}

.neural-node.is-birth-node {
  transform-box: fill-box;
  transform-origin: center;
  animation: universe-node-birth var(--birth-duration, 760ms) cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform, opacity, filter;
}

.neural-node.is-center-birth .node-shell {
  transform-box: fill-box;
  transform-origin: center;
  animation: universe-center-pulse 760ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.neural-edge.is-birth-edge {
  opacity: 0;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: universe-edge-birth var(--edge-duration, 820ms) cubic-bezier(0.16, 1, 0.3, 1) both;
}

.label-callout.is-birth-callout {
  opacity: 0;
  animation: universe-callout-birth 360ms ease-out both;
}

.neural-node.is-collapsing-node,
.label-callout.is-collapsing-node {
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: universe-node-collapse var(--collapse-duration, 680ms) cubic-bezier(0.7, 0, 0.84, 0) both;
  will-change: transform, opacity, filter;
}

.neural-edge.is-collapsing-edge {
  pointer-events: none;
  animation: universe-edge-collapse var(--collapse-duration, 490ms) ease-in both;
}

.neural-node.is-collapsed .node-shell {
  stroke-dasharray: 8 5;
}

.neural-node.is-collapsed .node-fill {
  opacity: 0.42;
}

.neural-node.is-selected .node-shell {
  stroke: #15211e;
  stroke-width: 4;
}

.label-callout-line {
  stroke: rgba(15, 139, 114, 0.32);
  stroke-width: 1;
  fill: none;
}

.label-callout-bg {
  fill: rgba(255, 255, 255, 0.88);
  stroke: rgba(141, 166, 156, 0.32);
  stroke-width: 1;
}

.label-callout-text {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 820;
  dominant-baseline: middle;
  pointer-events: none;
}

.node-shell {
  fill: rgba(223, 233, 226, 0.94);
  stroke: rgba(141, 166, 156, 0.95);
  stroke-width: 2;
}

.node-fill {
  fill: rgba(15, 139, 114, 0.76);
  stroke: rgba(11, 105, 88, 0.92);
  stroke-width: 1.5;
}

.node-center .node-shell {
  fill: rgba(255, 255, 255, 0.96);
  stroke: rgba(15, 139, 114, 0.55);
  stroke-width: 3;
}

.node-gender .node-shell {
  fill: rgba(253, 245, 230, 0.98);
  stroke: rgba(201, 139, 46, 0.8);
}

.node-gender .node-fill {
  fill: rgba(201, 139, 46, 0.72);
  stroke: rgba(149, 95, 25, 0.8);
}

.node-article .node-shell {
  fill: rgba(233, 246, 242, 0.96);
  stroke: rgba(15, 139, 114, 0.72);
}

.node-article .node-fill {
  fill: rgba(15, 139, 114, 0.72);
  stroke: rgba(11, 105, 88, 0.84);
}

.node-sku .node-shell {
  fill: rgba(245, 247, 245, 0.96);
  stroke: rgba(118, 143, 135, 0.72);
}

.node-sku .node-fill {
  fill: rgba(73, 144, 125, 0.66);
  stroke: rgba(41, 99, 84, 0.78);
}

.node-label {
  fill: var(--ink);
  font-weight: 820;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.node-caption,
.node-subcaption {
  fill: var(--muted);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.node-label.center-label-text {
  font-size: 22px;
}

.node-label.gender-label-text {
  font-size: 18px;
}

.node-label.subject-label-text {
  font-size: 12px;
}

.node-label.article-label-text {
  font-size: 11px;
}

.node-label.sku-label-text {
  font-size: 9px;
}

.node-caption {
  font-size: 12px;
}

.node-subcaption {
  font-size: 10px;
}

.node-inspector {
  position: sticky;
  top: 14px;
  margin-top: 66px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 46px rgba(24, 32, 29, 0.08);
}

@keyframes universe-node-birth {
  0% {
    opacity: 0;
    filter: blur(8px);
    transform: translate(var(--birth-dx), var(--birth-dy)) scale(0.08);
  }
  72% {
    opacity: 1;
    filter: blur(0);
    transform: translate(var(--birth-overshoot-x), var(--birth-overshoot-y)) scale(1.05);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translate(0, 0) scale(1);
  }
}

@keyframes universe-edge-birth {
  0% {
    opacity: 0;
    stroke-dashoffset: 1;
  }
  45% {
    opacity: calc(var(--edge-opacity, 0.35) * 0.35);
  }
  100% {
    opacity: var(--edge-opacity, 0.35);
    stroke-dashoffset: 0;
  }
}

@keyframes universe-callout-birth {
  0% {
    opacity: 0;
    filter: blur(3px);
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

@keyframes universe-node-collapse {
  0% {
    opacity: 1;
    filter: blur(0);
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    filter: blur(7px);
    transform: translate(var(--collapse-dx), var(--collapse-dy)) scale(0.06);
  }
}

@keyframes universe-edge-collapse {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes universe-center-pulse {
  0% {
    filter: drop-shadow(0 0 0 rgba(15, 139, 114, 0));
    transform: scale(0.92);
  }
  45% {
    filter: drop-shadow(0 0 18px rgba(15, 139, 114, 0.25));
    transform: scale(1.08);
  }
  100% {
    filter: drop-shadow(0 0 0 rgba(15, 139, 114, 0));
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .neural-node,
  .neural-edge,
  .label-callout,
  .node-shell,
  #neuralGraph {
    animation: none !important;
    transition: none !important;
  }
}

.inspector-title {
  display: grid;
  gap: 5px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.inspector-title span,
.inspector-kpi span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.inspector-title strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.16;
}

.inspector-kpi {
  display: grid;
  gap: 7px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.inspector-kpi strong {
  color: var(--ink);
  font-size: 26px;
  line-height: 1.08;
}

.inspector-kpi.accent strong {
  color: var(--accent);
}

.inspector-note {
  min-height: 136px;
  padding: 18px 20px 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.subject-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.subject-tile {
  min-height: 276px;
  display: grid;
  grid-template-rows: 188px 1fr;
  align-items: start;
  justify-items: center;
  padding: 10px 10px 14px;
  background: rgba(248, 250, 247, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.subject-tile:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: rgba(15, 139, 114, 0.35);
}

.subject-tile svg {
  width: 100%;
  max-width: 192px;
  height: 188px;
}

.subject-outer {
  fill: #dfe9e2;
  stroke: #8da69c;
  stroke-width: 1.8;
}

.subject-inner {
  fill: rgba(15, 139, 114, 0.86);
  stroke: #0b6958;
  stroke-width: 1.6;
  transition: r 320ms ease, cx 320ms ease, cy 320ms ease;
}

.subject-share {
  fill: var(--ink);
  font-size: 20px;
  font-weight: 820;
}

.subject-meta {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: center;
}

.subject-meta h3 {
  margin: 0;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.18;
}

.subject-meta p,
.subject-meta span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.subject-meta p {
  color: var(--accent);
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  margin-top: 14px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sku {
  display: grid;
  gap: 3px;
}

.sku strong {
  font-size: 14px;
}

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

.empty,
.error {
  padding: 22px 10px;
  color: var(--muted);
}

.error {
  color: var(--danger);
}

@media (max-width: 980px) {
  .shell {
    width: min(100% - 24px, 760px);
    padding-top: 20px;
  }

  .shell-wide {
    width: min(100% - 24px, 760px);
  }

  .topbar,
  .graph-head,
  .section-head {
    display: grid;
    gap: 10px;
  }

  .status {
    text-align: left;
  }

  .top-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .controls,
  .subject-controls,
  .workspace,
  .neural-layout {
    grid-template-columns: 1fr;
  }

  .node-inspector {
    position: static;
    margin-top: 0;
  }

  .graph-panel {
    min-height: auto;
    padding: 18px 12px 0;
  }

  #stockGraph {
    min-height: 350px;
    height: 430px;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 18px;
  }

  .controls {
    padding: 12px;
  }

  .kpi strong {
    font-size: 24px;
  }

  #stockGraph {
    height: 360px;
    min-height: 320px;
  }
}
