:root {
  color-scheme: dark;
  --subchart-height: 190px;
  --bg: #0d1218;
  --surface: #151c24;
  --surface-2: #1a232d;
  --line: rgba(172, 188, 205, 0.18);
  --text: #e9eef6;
  --muted: #98a7b8;
  --accent: #44d08a;
  --accent-2: #64a6ff;
  --warning: #f2bd4b;
  --danger: #ff6268;
  --up: #ff6268;
  --down: #44d08a;
  --purple: #c084fc;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid rgba(68, 208, 138, 0.42);
  background: rgba(68, 208, 138, 0.18);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  min-height: 38px;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(5, 9, 14, 0.58);
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}

h1,
h2,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #000;
  padding: 32px 18px;
  overflow: hidden;
}

.login-bg-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-bg-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.48);
}

.login-panel {
  position: relative;
  z-index: 2;
  width: min(420px, calc(100vw - 36px));
  display: grid;
  gap: 0;
  padding: 40px 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  text-align: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.login-panel h1 {
  color: #fff;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
  margin-bottom: 10px;
}

.login-panel p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 30px;
}

.login-panel label {
  display: block;
  margin: 0 0 8px;
  color: #fff;
  font-size: 14px;
  letter-spacing: 1px;
  text-align: left;
}

.login-panel input {
  width: 100%;
  height: 42px;
  margin-bottom: 20px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: #fff;
  color: #111827;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
}

.login-panel input::placeholder {
  color: #7b8496;
}

.login-panel input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.58);
  outline-offset: 2px;
}

.login-panel button {
  width: auto;
  min-width: 128px;
  height: 40px;
  margin-top: 10px;
  border: 0;
  border-radius: 4px;
  background: #fff;
  box-shadow: none;
  color: #333;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.login-panel button:hover,
.login-panel button:focus-visible {
  background: #e0e0e0;
  color: #333;
}

.login-error {
  min-height: 22px;
  margin-top: 18px;
  color: #ff3f5f;
  font-size: 15px;
  font-weight: 800;
}

.role-badge {
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 7px 10px;
}

.workspace {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 16px;
}

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

.brand h1 {
  font-size: 24px;
  line-height: 1.2;
}

.brand p {
  color: var(--muted);
  margin-top: 4px;
}

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

.icon-btn {
  min-width: 48px;
}

.search-band {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin-bottom: 12px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 138px 72px;
  gap: 8px;
  align-items: end;
}

.search-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
}

.search-results {
  position: absolute;
  z-index: 30;
  top: 70px;
  left: 12px;
  display: grid;
  gap: 4px;
  width: min(520px, calc(100vw - 32px));
  max-height: 300px;
  overflow: auto;
  padding: 6px;
  background: #111820;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.result-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--line);
  min-height: 34px;
  padding: 6px 10px;
  text-align: left;
  width: 100%;
}

.result-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(68, 208, 138, 0.14);
}

.search-empty {
  color: var(--muted);
  padding: 8px;
}

.strategy-strip {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.view-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tool-toggle,
.tool-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 7px 10px;
}

.tool-toggle {
  cursor: pointer;
}

.tool-toggle input {
  width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  accent-color: var(--accent);
}

.tool-toggle:has(input:checked) {
  border-color: rgba(100, 166, 255, 0.56);
  background: rgba(100, 166, 255, 0.16);
  color: var(--text);
}

.tool-btn {
  cursor: pointer;
}

.strategy-btn {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 8px 10px;
  cursor: pointer;
}

.strategy-btn input {
  width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.strategy-btn span,
.strategy-btn strong {
  white-space: nowrap;
}

.strategy-btn strong {
  color: var(--text);
  font-size: 15px;
}

.strategy-btn.is-active {
  border-color: rgba(68, 208, 138, 0.56);
  background: rgba(68, 208, 138, 0.14);
  color: var(--text);
}

.status-row {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr 1.2fr 1.2fr;
  gap: 10px;
  margin-bottom: 12px;
}

.status-row div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}

.status-row span,
.panel-head span,
.section-head span {
  color: var(--muted);
  font-size: 12px;
}

.status-row strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: stretch;
}

.chart-section {
  min-width: 0;
}

.chart-wrap {
  position: relative;
  height: 700px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.price-stack {
  position: absolute;
  inset: 0;
  bottom: var(--subchart-height);
  min-height: 360px;
}

.chart {
  position: absolute;
  inset: 0;
}

.subchart {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--subchart-height);
  border-top: 1px solid var(--line);
}

.gap-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.gap-zone {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(233, 238, 246, 0.04);
}

.gap-zone[data-direction="up"] {
  background: rgba(180, 35, 45, 0.11);
  border-color: rgba(180, 35, 45, 0.28);
}

.gap-zone[data-direction="down"] {
  background: rgba(22, 129, 83, 0.12);
  border-color: rgba(22, 129, 83, 0.28);
}

.chart-legend {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 8;
  width: min(430px, calc(100% - 24px));
  background: rgba(15, 22, 30, 0.88);
  border: 1px solid rgba(172, 188, 205, 0.22);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  pointer-events: none;
}

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

.legend-head strong {
  font-size: 13px;
}

.legend-head span {
  min-height: 16px;
  color: var(--warning);
  font-size: 12px;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(10, auto);
  gap: 4px 8px;
  align-items: baseline;
}

.legend-grid span {
  color: var(--muted);
  font-size: 11px;
}

.legend-grid strong {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.measure-panel {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 7;
  min-width: 250px;
  max-width: min(420px, calc(100% - 24px));
  background: rgba(15, 22, 30, 0.92);
  border: 1px solid rgba(100, 166, 255, 0.42);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.measure-panel strong {
  color: var(--text);
}

.measure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
  margin-top: 8px;
}

.measure-grid span {
  color: var(--muted);
  font-size: 12px;
  display: block;
}

.measure-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(13, 18, 24, 0.86);
  z-index: 6;
}

.side-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.panel,
.cycles-section,
.events-section,
.health-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 12px;
}

.panel-head,
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel h2,
.section-head h2 {
  font-size: 16px;
}

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

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

.strategy-focus-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 6px 10px;
  align-items: start;
  padding: 9px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.strategy-focus-row > div:first-child {
  grid-row: span 2;
}

.strategy-focus-row strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.strategy-focus-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.strategy-focus-row[data-strategy="cb"] {
  border-color: rgba(167, 139, 250, 0.36);
}

.strategy-focus-row[data-strategy="seo"] {
  border-color: rgba(251, 113, 133, 0.36);
}

.strategy-focus-row[data-strategy="private_placement"] {
  border-color: rgba(56, 189, 248, 0.34);
}

.strategy-focus-row[data-strategy="capital_reduction"] {
  border-color: rgba(249, 115, 22, 0.36);
}

.strategy-focus-row[data-strategy="insider_transfer"] {
  border-color: rgba(234, 179, 8, 0.34);
}

.strategy-focus-row[data-strategy="conference"] {
  border-color: rgba(100, 166, 255, 0.34);
}

.strategy-focus-row[data-strategy="shareholder"] {
  border-color: rgba(242, 189, 75, 0.34);
}

.strategy-focus-row[data-strategy="ex_dividend"] {
  border-color: rgba(45, 212, 191, 0.34);
}

.strategy-focus-row[data-strategy="gap"] {
  border-color: rgba(255, 255, 255, 0.24);
}

.metric {
  display: grid;
  grid-template-columns: 86px repeat(4, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
  padding: 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.metric strong {
  font-size: 13px;
}

.table-mini {
  overflow: auto;
}

.table-mini table,
.event-table table {
  width: 100%;
  border-collapse: collapse;
}

.table-mini th,
.table-mini td,
.event-table th,
.event-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

.table-mini th,
.event-table th {
  background: rgba(100, 166, 255, 0.08);
  color: #c4ceda;
  white-space: nowrap;
}

.pos {
  color: var(--up);
}

.neg {
  color: var(--down);
}

.cycles-section,
.events-section {
  margin-top: 12px;
  padding: 12px;
}

.cycle-board {
  display: grid;
  gap: 10px;
}

.cycle-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.cycle-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.cycle-label strong {
  display: block;
}

.cycle-label span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.cycle-events {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cycle-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 6px;
  padding: 7px 8px;
  max-width: 360px;
}

.cycle-chip strong {
  display: block;
  font-size: 12px;
}

.cycle-chip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.cycle-chip[data-tone="fundraising"] {
  border-color: rgba(109, 66, 184, 0.32);
}

.cycle-chip[data-tone="cb"] {
  border-color: rgba(167, 139, 250, 0.42);
}

.cycle-chip[data-tone="investor"] {
  border-color: rgba(47, 91, 156, 0.32);
}

.cycle-chip[data-tone="exdiv"] {
  border-color: rgba(23, 107, 95, 0.32);
}

.cycle-chip[data-tone="signal"] {
  border-color: rgba(183, 121, 31, 0.38);
}

.cycle-chip[data-tone="gap"],
.cycle-chip[data-tone="low"] {
  border-color: rgba(255, 255, 255, 0.24);
}

.health-panel {
  margin-top: 12px;
  padding: 12px;
  white-space: pre-wrap;
  overflow: auto;
  max-height: 300px;
  color: var(--muted);
}

.timeframe-control {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  gap: 6px;
  align-items: end;
}

.tf-btn {
  min-height: 38px;
  padding: 8px 0;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.tf-btn.is-active {
  border-color: rgba(100, 166, 255, 0.56);
  background: rgba(100, 166, 255, 0.16);
  color: var(--text);
}

@media (max-width: 1080px) {
  .login-panel {
    padding: 34px 24px;
  }

  .login-panel h1 {
    font-size: 26px;
  }

  .search-form,
  .status-row,
  .main-grid {
    grid-template-columns: 1fr;
  }

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

  .chart-wrap {
    --subchart-height: 170px;
    height: 620px;
  }

  .legend-grid {
    grid-template-columns: repeat(4, auto);
  }

  .cycle-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .screen-only,
  .actions,
  .health-panel {
    display: none !important;
  }

  .workspace {
    width: 100%;
    padding: 0;
  }

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

  .chart-wrap,
  .panel,
  .cycles-section,
  .events-section,
  .status-row div {
    box-shadow: none;
    break-inside: avoid;
  }

  .chart-wrap {
    --subchart-height: 130px;
    height: 500px;
  }

  .side-panel {
    grid-template-columns: 1fr 1fr;
  }
}
