:root {
  --navy: #07155f;
  --blue: #045bf0;
  --cyan: #10a8ff;
  --ink: #111827;
  --muted: #667085;
  --line: #d9e2f1;
  --soft: #f6f8fc;
  --white: #ffffff;
  --green: #12805c;
  --yellow: #a86f00;
  --red: #c53434;
  --darkred: #721c24;
  --shadow: 0 18px 50px rgba(7, 21, 95, 0.10);
  --shadow-strong: 0 24px 70px rgba(7, 21, 95, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 22px;
  height: 76px;
  padding: 10px clamp(18px, 4vw, 54px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  padding: 0;
}

.brand img {
  width: 174px;
  height: 54px;
  object-fit: contain;
  object-position: left center;
}

.nav {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
}

.nav button,
.ghost,
.primary,
.quiet {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy);
  font-weight: 700;
  white-space: nowrap;
}

.nav button.active,
.ghost:hover,
.quiet:hover {
  border-color: var(--line);
  background: var(--soft);
}

.quiet.active-filter {
  border-color: var(--navy);
  background: var(--soft);
}

.primary {
  color: var(--white);
  background: var(--navy);
  border-color: var(--navy);
}

.primary:disabled,
.quiet:disabled {
  cursor: not-allowed;
  color: #98a2b3;
  background: #eef2f7;
  border-color: #e5eaf2;
}

.auth-actions {
  display: flex;
  gap: 8px;
}

main {
  min-height: calc(100vh - 76px);
}

.landing {
  min-height: calc(100vh - 76px);
  display: grid;
  place-items: center;
  padding: 40px 20px;
  text-align: center;
}

.landing img {
  width: min(760px, 86vw);
  max-height: 430px;
  object-fit: contain;
}

.tagline {
  margin: 10px 0 0;
  color: var(--navy);
  font-size: clamp(22px, 3vw, 40px);
  font-weight: 800;
}

.page {
  padding: 28px clamp(16px, 4vw, 54px) 58px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.page-head-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, auto) minmax(0, 1fr);
  align-items: end;
}

.page-title {
  grid-column: 2;
  text-align: center;
}

.page-actions {
  grid-column: 3;
  justify-self: end;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  color: var(--navy);
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.04;
}

h2 {
  color: var(--navy);
  font-size: 22px;
  margin-bottom: 14px;
}

h3 {
  color: var(--navy);
  font-size: 16px;
  margin-bottom: 10px;
}

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

.grid {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.dashboard-shell {
  min-height: calc(100vh - 220px);
  display: grid;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.dashboard-card {
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px;
  text-align: left;
  box-shadow: var(--shadow-strong);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.dashboard-card:hover {
  transform: translateY(-4px);
  border-color: #b8c8e6;
  box-shadow: 0 30px 90px rgba(7, 21, 95, 0.20);
}

.dashboard-card strong {
  display: block;
  color: var(--navy);
  font-size: 24px;
  margin-bottom: 8px;
}

.section {
  padding: 20px;
  margin-bottom: 18px;
}

.split {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.45fr);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--navy);
  font-size: 22px;
}

.traffic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 13px;
  color: var(--white);
  font-weight: 800;
  text-transform: capitalize;
}

.traffic::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
  filter: brightness(2.5);
}

.traffic.green {
  background: var(--green);
}

.traffic.yellow {
  background: var(--yellow);
}

.traffic.red {
  background: var(--red);
}

.traffic.darkred {
  background: var(--darkred);
}

.traffic.unknown {
  background: var(--muted);
}

.monitor-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 14px;
  color: var(--white);
  font-weight: 800;
  text-transform: uppercase;
}

.monitor-badge.ok {
  background: var(--green);
}

.monitor-badge.warning {
  background: var(--yellow);
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.trend-badge.up {
  color: var(--green);
  background: #e8f6f0;
}

.trend-badge.down {
  color: var(--red);
  background: #fdeaea;
}

.trend-badge.flat {
  color: var(--muted);
  background: #eef2f7;
}

.status-badge,
.management-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge.active,
.management-badge.hold {
  color: var(--green);
  background: #e8f6f0;
}

.status-badge.pending,
.management-badge.watch {
  color: var(--yellow);
  background: #fff4d8;
}

.status-badge.blocked,
.management-badge.sell {
  color: var(--red);
  background: #fdeaea;
}

.management-badge.time_exit {
  color: var(--green);
  background: #def7ea;
}

.management-badge.unknown {
  color: var(--muted);
  background: #eef2f7;
}

.management-sell td {
  background: #fff1f1;
}

.management-watch td {
  background: #fff8ef;
}

.management-time td {
  background: #effbf4;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.warnings {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.warnings p {
  margin: 0;
  border-left: 4px solid var(--yellow);
  padding: 10px 12px;
  background: #fff8e6;
  color: #6f4900;
  font-weight: 700;
}

.log-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  background: #fbfcff;
}

.log-block summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--navy);
  font-weight: 800;
}

.log-block pre {
  max-height: 280px;
  overflow: auto;
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  color: #344054;
  white-space: pre-wrap;
}

.stop-theory {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.stop-theory summary {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(110px, auto) minmax(110px, auto);
  gap: 12px;
  align-items: center;
  cursor: pointer;
  padding: 14px;
  color: var(--navy);
  font-weight: 800;
}

.stop-theory summary strong,
.stop-theory summary small {
  display: block;
}

.stop-theory summary small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stop-theory .summary-metric {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #ffffff;
  color: var(--navy);
  font-size: 13px;
}

.stop-theory > .metric-note,
.stop-theory > .metrics,
.stop-theory > .audit-subhead,
.stop-theory > .table-wrap {
  margin: 0 14px 14px;
}

.audit-years {
  display: grid;
  gap: 10px;
}

.trade-years {
  display: grid;
  gap: 10px;
}

.audit-year {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.trade-year {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.audit-year summary {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(8, minmax(78px, 0.6fr));
  gap: 12px;
  align-items: center;
  cursor: pointer;
  padding: 13px 14px;
  color: var(--navy);
  font-weight: 800;
}

.trade-year summary {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(110px, 0.35fr) minmax(86px, 0.3fr);
  gap: 12px;
  align-items: center;
  cursor: pointer;
  padding: 13px 14px;
  color: var(--navy);
  font-weight: 800;
}

.audit-year-main {
  display: grid;
  gap: 3px;
}

.trade-year-main {
  display: grid;
  gap: 3px;
}

.audit-year-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.trade-year-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.audit-detail {
  border-width: 1px 0 0;
  border-radius: 0 0 8px 8px;
}

.trade-split {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-bottom: 10px;
}

.trade-split section {
  min-width: 0;
}

.trade-split .table-wrap {
  margin-bottom: 0;
  border-left-width: 0;
  border-right-width: 0;
  border-radius: 0;
}

.trade-split .metric-note {
  margin: 0 14px 10px;
}

.audit-subhead {
  margin: 16px 14px 8px;
  font-size: 13px;
  color: var(--navy);
  text-transform: uppercase;
}

.date-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.trade-detail {
  border-width: 1px 0 0;
  border-radius: 0 0 8px 8px;
}

.traffic-badge,
.entry-reason {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.traffic-badge.green,
.entry-reason.entry {
  color: var(--green);
  background: #e8f6f0;
}

.traffic-badge.yellow {
  color: var(--yellow);
  background: #fff4d8;
}

.traffic-badge.red,
.traffic-badge.darkred,
.entry-reason.ampel {
  color: var(--red);
  background: #fdeaea;
}

.entry-reason.index {
  color: var(--muted);
  background: #eef2f7;
}

.entry-reason.no_signal,
.entry-reason.overheat {
  color: var(--muted);
  background: #eef2f7;
}

.entry-reason.no_slot {
  color: var(--navy);
  background: #e9efff;
}

.entry-reason.already_held {
  color: var(--blue);
  background: #eaf3ff;
}

.heatmap-block {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

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

.heatmap-head h3 {
  margin-bottom: 0;
}

.heatmap-head span,
.heatmap-legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rolling-heatmap {
  display: grid;
  grid-template-columns: 58px repeat(12, minmax(62px, 1fr));
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.heatmap-year,
.heatmap-month,
.heatmap-corner {
  min-height: 34px;
  display: grid;
  place-items: center;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.heatmap-year {
  justify-content: start;
}

.heat-cell {
  min-width: 62px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: var(--navy);
  font-size: 11px;
  font-weight: 900;
}

.heat-cell.low {
  background: #fdeaea;
  color: var(--red);
}

.heat-cell.mid {
  background: #fff4d8;
  color: var(--yellow);
}

.heat-cell.high {
  background: #dff5ea;
  color: var(--green);
}

.heat-cell.elite {
  background: var(--green);
  color: var(--white);
}

.heat-cell.empty {
  background: #eef2f7;
}

.heat-cell.blocked.ampel {
  background: #fdeaea;
  color: var(--red);
}

.heat-cell.blocked.no_signal,
.heat-cell.blocked.overheat,
.heat-cell.blocked.future,
.heat-cell.blocked.index,
.heat-cell.blocked.blocked {
  background: #eef2f7;
  color: var(--muted);
}

.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.heat {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.heat.ampel {
  background: #fdeaea;
}

.heat.blocked {
  background: #eef2f7;
}

.heat.future {
  background: #eef2f7;
}

.heat.low {
  background: #fdeaea;
}

.heat.mid {
  background: #fff4d8;
}

.heat.high {
  background: #dff5ea;
}

.heat.elite {
  background: var(--green);
}

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

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

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

th {
  color: var(--navy);
  background: #f8faff;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.disabled-row {
  color: #8a94a6;
  background: #fbfcff;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

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

.metric-note {
  margin: 12px 0 0;
  font-size: 13px;
}

.mini-date {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.positive {
  color: var(--green);
  font-weight: 800;
}

.negative {
  color: var(--red);
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.portfolio-tabs,
.demo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--white);
}

.auth-panel {
  width: min(480px, calc(100vw - 32px));
  margin: 64px auto;
  padding: 24px;
}

.chart {
  width: 100%;
  height: 260px;
}

.large-chart {
  min-width: 680px;
  height: 340px;
}

.pie {
  width: min(260px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 0 auto;
  background: conic-gradient(var(--navy) 0deg 120deg, var(--blue) 120deg 240deg, var(--cyan) 240deg 360deg);
}

.thresholds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.thresholds div {
  border-left: 4px solid var(--blue);
  padding: 10px 12px;
  background: #fbfcff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.42);
}

.modal {
  width: min(920px, 100%);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 18px;
  overflow-x: auto;
}

.briefing-backdrop {
  padding: clamp(12px, 3vw, 28px);
}

.briefing-modal {
  width: min(980px, 100%);
  max-height: min(860px, calc(100vh - 32px));
  overflow: hidden;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 34px 100px rgba(7, 21, 95, 0.28);
}

.briefing-hero {
  position: relative;
  min-height: 230px;
  display: flex;
  align-items: flex-end;
  padding: 28px;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(7, 21, 95, 0.86), rgba(7, 21, 95, 0.38) 48%, rgba(7, 21, 95, 0.08)),
    linear-gradient(0deg, rgba(7, 21, 95, 0.55), rgba(7, 21, 95, 0.04) 58%),
    url("/assets/briefing_mountain_panorama.jpg") center / cover no-repeat;
}

.briefing-hero h2 {
  margin: 4px 0 6px;
  color: var(--white);
  font-size: clamp(30px, 5vw, 52px);
}

.briefing-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
}

.briefing-kicker {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.briefing-hero .briefing-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.42);
}

.briefing-body {
  max-height: calc(100vh - 360px);
  overflow: auto;
  padding: 18px;
}

.briefing-grid,
.briefing-lists {
  display: grid;
  gap: 12px;
}

.briefing-grid {
  grid-template-columns: 1.15fr 1fr 0.8fr;
  margin-bottom: 16px;
}

.briefing-lists {
  grid-template-columns: 1fr 1fr;
}

.briefing-panel {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcff;
}

.briefing-panel-primary {
  background: #f7fbff;
}

.briefing-panel span,
.briefing-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.briefing-panel > strong {
  display: block;
  margin: 8px 0;
  color: var(--navy);
  font-size: 28px;
}

.briefing-metrics,
.briefing-traffic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.briefing-panel small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.briefing-list {
  display: grid;
  gap: 8px;
}

.briefing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--white);
}

.briefing-row strong {
  display: block;
  color: var(--navy);
}

.briefing-row em {
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.briefing-row em.ok {
  color: var(--green);
}

.briefing-row em.watch {
  color: var(--yellow);
}

.briefing-row em.danger {
  color: var(--red);
}

.briefing-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--navy);
  font-size: 24px;
  line-height: 1;
}

@media (max-width: 820px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
  }

  .brand img {
    width: 148px;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-head-main {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .page-title,
  .page-actions {
    grid-column: 1;
    justify-self: center;
  }

  .briefing-hero {
    min-height: 190px;
    padding: 22px;
  }

  .briefing-body {
    max-height: calc(100vh - 320px);
  }

  .briefing-grid,
  .briefing-lists {
    grid-template-columns: 1fr;
  }

  .audit-year summary {
    grid-template-columns: 1fr 1fr;
  }

  .trade-year summary {
    grid-template-columns: 1fr 1fr;
  }

  .audit-year-main {
    grid-column: 1 / -1;
  }

  .trade-year-main {
    grid-column: 1 / -1;
  }

  .briefing-actions {
    flex-wrap: wrap;
  }

  .briefing-actions button {
    flex: 1;
  }
}
