/* App 04 - Portfolio Decoherence */

:root {
  --ink: #111111;
  --paper: #f9f9f9;
  --surface: #ffffff;
  --border: rgba(17, 17, 17, .10);
  --border-s: rgba(17, 17, 17, .065);
  --orange: var(--primary-color, #EAB308);
  --gold: #c88728;
  --dim: #6b6b6b;
  --muted: #9ca3af;
  --danger: #b03010;
  --safe: #3a7050;
  --f-ui: var(--font-primary, 'Inter', sans-serif);
  --f-serif: var(--font-heading, 'Playfair Display', serif);
  --f-mono: 'DM Mono', monospace;
}

html,
body {
  min-height: 100%;
}

body {
  overflow: hidden;
  background: #050505;
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .65), transparent 62%);
  z-index: 0;
}

.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 700;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0 1.5rem;
  background: rgba(17, 17, 17, .93);
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .16);
  backdrop-filter: blur(14px);
}

.topnav-back,
.topnav-app,
.usage-label {
  color: rgba(255, 255, 255, .72);
  line-height: 1;
}

.topnav-back {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topnav-back:hover,
.topnav-app {
  color: #fff;
}

.topnav-sep {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, .13);
}

.topnav-app {
  font-family: var(--f-ui);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .01em;
}

.topnav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .85rem;
}

.usage-chips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.chip {
  display: block;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .13);
}

.chip.empty {
  background: rgba(255, 255, 255, .20);
  box-shadow: none;
}

.usage-label {
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .06em;
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(320px, 365px) 1fr;
  height: calc(100vh - 68px);
  margin-top: 68px;
  padding: 16px;
  gap: 16px;
}

.sidebar {
  position: relative;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 20px;
  background: rgba(8, 8, 8, .92);
  box-shadow: none;
  backdrop-filter: blur(16px);
}

.sidebar-block {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-block:last-child {
  border-bottom: 0;
}

.blk-label,
.card-title,
.interp-lbl {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: .64rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.blk-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-bottom: .85rem;
  color: rgba(255, 255, 255, .42);
}

.wave-info {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.wi-lbl {
  color: #FACC15;
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.wi-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .7rem;
  padding-top: .5rem;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.wi-key,
.wi-val {
  font-family: var(--f-mono);
  font-size: .66rem;
}

.wi-key {
  color: rgba(255, 255, 255, .42);
}

.wi-val {
  color: rgba(255, 255, 255, .76);
  text-align: right;
}

.book-ref {
  color: rgba(255, 255, 255, .42);
  font-family: var(--f-mono);
  font-size: .6rem;
  letter-spacing: .08em;
  line-height: 1.7;
}

.book-ref span {
  color: #FACC15;
}

.main {
  min-width: 0;
  overflow: hidden;
  background: transparent;
}

.run-btn,
.pro-go {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--f-ui);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: box-shadow .2s ease, transform .2s ease;
}

.run-btn {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  padding: 0 1.1rem;
  background: var(--gradient-1);
  color: #fff;
  box-shadow: none;
}

.run-btn:hover,
.pro-go:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(249, 115, 22, .30);
}

.spin-icon {
  display: none;
  animation: spin .7s linear infinite;
}

.run-btn.loading .run-icon {
  display: none;
}

.run-btn.loading .spin-icon {
  display: inline;
}

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

.content {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1rem 0 1rem 1rem;
}

.deco-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: .35rem;
  padding: .25rem;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 999px;
  background: rgba(8, 8, 8, .92);
}

.deco-tab {
  min-width: 112px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, .48);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: background .18s ease, color .18s ease;
}

.deco-tab:hover {
  color: #fff;
}

.deco-tab.on {
  background: var(--gradient-1);
  color: #fff;
}

.deco-panel {
  display: none;
  flex-direction: column;
  gap: 1.2rem;
}

.deco-panel.active {
  display: flex;
}

.data-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 1.2rem;
  align-items: start;
}

.branches-wrap,
.corr-wrap,
.card,
.interp {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .035);
  border-radius: 18px;
  background: rgba(255, 255, 255, .93);
  box-shadow: none;
}

.branches-wrap,
.corr-wrap {
  border-color: rgba(255, 255, 255, .06);
  background: transparent;
}

.br-head,
.corr-head,
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .95rem 1.1rem;
  border-bottom: 1px solid var(--border-s);
}

.br-head,
.corr-head {
  background: #111;
  color: #fff;
}

.br-title,
.corr-title {
  color: #fff;
  font-family: var(--f-mono);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.br-sub,
.corr-sub {
  margin-top: .28rem;
  color: rgba(255, 255, 255, .48);
  font-family: var(--f-mono);
  font-size: .62rem;
  line-height: 1.45;
}

.card-head {
  background: rgba(17, 17, 17, .035);
}

.card-title {
  color: var(--ink);
  font-weight: 800;
}

.br-table,
.corr-table,
.scr-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, .93);
}

.br-table th,
.corr-table th,
.scr-table th {
  padding: .62rem .8rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: .58rem;
  font-weight: 400;
  letter-spacing: .12em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.br-table td,
.corr-table td,
.scr-table td {
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border-s);
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: .72rem;
  text-align: center;
  vertical-align: middle;
}

.br-table th:nth-child(2),
.br-table td:nth-child(2),
.scr-table th:first-child,
.scr-table td:first-child {
  text-align: left;
}

.br-table tr:last-child td,
.corr-table tr:last-child td,
.scr-table tr:last-child td {
  border-bottom: 0;
}

.br-inp,
.corr-inp {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: .72rem;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}

.br-inp::-webkit-outer-spin-button,
.br-inp::-webkit-inner-spin-button,
.corr-inp::-webkit-outer-spin-button,
.corr-inp::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.br-inp:focus,
.corr-inp:focus {
  color: #A16207;
}

.br-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: .4rem;
}

.corr-scroll {
  overflow-x: auto;
}

.corr-table th:first-child {
  min-width: 92px;
}

.corr-row-lbl {
  color: var(--dim) !important;
  text-align: left !important;
}

.corr-diag {
  background: rgba(249, 115, 22, .07);
  color: #A16207 !important;
  font-weight: 600;
}

.add-layer-btn {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-top: 1px dashed rgba(17, 17, 17, .14);
  background: rgba(255, 255, 255, .93);
  color: var(--dim);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.add-layer-btn:hover {
  color: #A16207;
}

.add-layer-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.empty {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  background: rgba(8, 8, 8, .92);
  text-align: center;
}

.usage-chips .chip.empty {
  width: 8px;
  height: 8px;
  min-height: 0;
  display: block;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .20);
  box-shadow: none;
}

.empty-wave {
  margin-bottom: .5rem;
  color: #FACC15;
  font-family: var(--f-serif);
  font-size: 4.4rem;
  line-height: .8;
}

.empty-title {
  margin-bottom: .45rem;
  color: rgba(255, 255, 255, .88);
  font-size: 1.05rem;
  font-weight: 800;
}

.empty-sub {
  color: rgba(255, 255, 255, .46);
  font-family: var(--f-mono);
  font-size: .72rem;
  line-height: 1.7;
}

#rw {
  display: none;
  flex-direction: column;
  gap: 1.2rem;
}

#rw.show {
  display: flex;
}

.result-context {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1rem;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  background: rgba(8, 8, 8, .92);
}

.result-context span {
  color: rgba(255, 255, 255, .42);
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.result-context strong {
  color: #FACC15;
  font-family: var(--f-ui);
  font-size: .95rem;
  font-weight: 800;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.kpi {
  min-height: 138px;
  padding: 1.35rem 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 18px;
  background: rgba(8, 8, 8, .92);
}

.kpi-meta {
  display: flex;
  align-items: center;
  gap: .45rem;
  color: rgba(255, 255, 255, .46);
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.kpi-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.kpi-val {
  margin-top: .55rem;
  color: #fff;
  font-family: var(--f-ui);
  font-size: clamp(1.65rem, 2.2vw, 2.35rem);
  font-weight: 800;
  line-height: 1;
}

.kpi-val.accent,
.wave-higher,
.t-high {
  color: #FACC15;
}

.kpi-unit {
  margin-top: .45rem;
  color: rgba(255, 255, 255, .38);
  font-family: var(--f-mono);
  font-size: .62rem;
  line-height: 1.45;
}

.results-3col {
  display: grid;
  grid-template-columns: minmax(260px, .75fr) minmax(0, 1.25fr);
  gap: 1.2rem;
  align-items: stretch;
}

.gauge-wrap {
  min-height: 290px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  padding: 1.4rem;
  background: rgba(255, 255, 255, .93);
}

.gauge-canvas {
  display: block;
}

.gauge-value {
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1;
}

.gauge-label {
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: .6rem;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
}

.gauge-regime {
  color: #A16207;
  font-family: var(--f-ui);
  font-size: .82rem;
  font-weight: 800;
  text-align: center;
}

.scr-bar-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
}

.scr-bar-bg {
  width: 60px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(17, 17, 17, .10);
}

.scr-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
}

.scr-bar-fill.safe {
  background: var(--safe);
}

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

.chart-row .card {
  background: rgba(255, 255, 255, .93);
}

.chart-area {
  padding: 1rem;
  background: rgba(255, 255, 255, .93);
}

.chart-wrap {
  position: relative;
  height: 235px;
  border-radius: 12px;
  background: rgba(17, 17, 17, .025);
}

.card-action {
  border: 1px solid rgba(17, 17, 17, .12);
  border-radius: 999px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: .62rem;
  letter-spacing: .08em;
  padding: .35rem .75rem;
  text-transform: uppercase;
}

.card-action:hover {
  color: #A16207;
}

.interp {
  padding: 1.2rem 1.35rem;
  border-color: rgba(255, 255, 255, .08);
  background: rgba(8, 8, 8, .92);
}

.interp-lbl {
  margin-bottom: .8rem;
  color: rgba(255, 255, 255, .42);
}

.interp-body {
  color: rgba(255, 255, 255, .58);
  font-size: .9rem;
  line-height: 1.8;
}

.interp-body strong {
  color: rgba(255, 255, 255, .92);
}

.pro-veil {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(8, 8, 8, .78);
  backdrop-filter: blur(8px);
}

.pro-veil.show {
  display: flex;
}

.pro-card {
  width: min(420px, 100%);
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 22px;
  background: #111;
  color: #fff;
  text-align: center;
}

.pro-ico {
  color: #FACC15;
  font-size: 2rem;
}

.pro-h {
  margin-top: .5rem;
  font-size: 1.2rem;
  font-weight: 800;
}

.pro-p {
  margin: .9rem 0 1.2rem;
  color: rgba(255, 255, 255, .58);
  font-size: .88rem;
  line-height: 1.6;
}

.pro-go {
  width: 100%;
  min-height: 42px;
  background: var(--gradient-1);
  color: #fff;
}

.pro-skip {
  display: inline-block;
  margin-top: 1rem;
  color: rgba(255, 255, 255, .46);
  cursor: pointer;
  font-size: .78rem;
}

@media (max-width: 1180px) {
  .data-grid,
  .chart-row,
  .results-3col {
    grid-template-columns: 1fr;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .content {
    padding-left: 0;
  }
}

@media (max-width: 680px) {
  .topnav {
    padding: 0 .9rem;
  }

  .topnav-app {
    font-size: .86rem;
  }

  .usage-chips {
    display: none;
  }

  .kpi-strip {
    grid-template-columns: 1fr;
  }
}
