:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #0b0d10;
  color: #f3f4f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #0b0d10;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  border-bottom: 1px solid #262a31;
  background: #111419;
}

header div {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

header span {
  color: #9299a6;
}

header a {
  color: #d8dce3;
}

main {
  width: min(1450px, calc(100% - 32px));
  margin: 24px auto;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics article,
.panel,
.login-card {
  background: #13171d;
  border: 1px solid #282e37;
  border-radius: 12px;
}

.metrics article {
  padding: 18px;
}

.metrics span {
  display: block;
  color: #9299a6;
  margin-bottom: 8px;
}

.metrics strong {
  font-size: 1.55rem;
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.failover-panel {
  border-color: #31506a;
  background: linear-gradient(135deg, #131b24, #13171d 70%);
}

.failover-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.failover-grid div {
  padding: 12px;
  border: 1px solid #293746;
  border-radius: 9px;
  background: #10161d;
}

.failover-grid span {
  display: block;
  color: #8795a6;
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.failover-grid strong {
  font-size: 1.05rem;
}

.heartbeat-online {
  color: #53d391;
}

.heartbeat-missing {
  color: #ff6b78;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.status-ready {
  color: #08140e;
  background: #53d391;
}

.status-blocked {
  color: #210b0d;
  background: #ff6b78;
}

.status-protected {
  color: #1a1304;
  background: #ffcc66;
}

.failover-blockers {
  margin-top: 14px;
  color: #53d391;
  font-size: 0.88rem;
}

.failover-blockers.has-blockers {
  color: #ffb020;
}

.active-setups-panel {
  border-color: #2a4357;
  background: linear-gradient(135deg, #111a23, #13171d 68%);
}

.trailing-setup-panel {
  border-color: #314258;
}

.trailing-setup-table td {
  vertical-align: middle;
}

.trailing-window {
  min-width: 170px;
}

.trailing-window strong,
.trailing-window span {
  display: block;
}

.trailing-window strong {
  font-size: 0.95rem;
  margin-bottom: 3px;
}

.trailing-window span {
  color: #9ba8b6;
  font-size: 0.78rem;
  line-height: 1.45;
}

.trailing-window.empty {
  color: #7f8998;
  font-size: 0.84rem;
}

.setup-count {
  color: #091610;
  background: #53d391;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.active-setups-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.active-setups-grid article {
  min-height: 104px;
  padding: 13px;
  border: 1px solid #2a3b4b;
  border-radius: 9px;
  background: #0f151c;
}

.active-setups-grid strong,
.active-setups-grid span {
  display: block;
}

.active-setups-grid strong {
  color: #f1f4f8;
  font-size: 0.91rem;
  margin-bottom: 8px;
}

.active-setups-grid span {
  color: #9ba8b6;
  font-size: 0.83rem;
  line-height: 1.45;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notice {
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: #181d24;
}

.success,
.positive {
  color: #53d391;
}

.error,
.negative {
  color: #ff6b78;
}

.position {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid #282e37;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px;
  text-align: left;
  border-bottom: 1px solid #282e37;
  vertical-align: top;
}

th {
  color: #9299a6;
}

select,
input,
button {
  background: #0e1116;
  color: #f3f4f6;
  border: 1px solid #343b46;
  border-radius: 8px;
  padding: 10px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(390px, calc(100% - 32px));
  padding: 28px;
}

.login-card label {
  display: grid;
  gap: 7px;
  margin: 16px 0;
}

.login-card button {
  width: 100%;
}

#gexChart,
#spyChart {
  width: 100%;
}

@media (max-width: 850px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.panel-subtitle {
  color: #8791a1;
  font-size: 0.88rem;
  margin: 5px 0 0;
}

.session-notes-panel {
  border-color: #3d4b5e;
}

.session-notes-toolbar,
.session-notes-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.session-notes-toolbar {
  margin: 16px 0 10px;
}

.session-notes-toolbar label {
  color: #aeb7c4;
  font-size: 0.9rem;
}

.session-notes-status,
.session-notes-updated {
  color: #8f9aaa;
  font-size: 0.86rem;
}

#sessionNotesText {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 170px;
  background: #0e1116;
  color: #f3f4f6;
  border: 1px solid #343b46;
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  line-height: 1.5;
}

#sessionNotesText:focus {
  border-color: #55b8ff;
  outline: 2px solid rgba(85, 184, 255, 0.2);
}

.session-notes-actions {
  justify-content: space-between;
  margin-top: 10px;
}

#gexChart,
#spyChart {
  min-height: 660px;
  border: 1px solid #252c36;
  border-radius: 10px;
  overflow: hidden;
  background: #0e1218;
}

.empty-state {
  color: #8f98a7;
  padding: 8px 0;
}

.setup-label {
  display: block;
  color: #f1f4f8;
  font-weight: 650;
  white-space: nowrap;
}

td small {
  display: block;
  color: #7f8998;
  margin-top: 3px;
}

.entry-text {
  color: #ffb020;
  font-weight: 700;
}

.exit-text {
  color: #44c7f4;
  font-weight: 700;
}

.leg-side {
  display: inline-block;
  min-width: 38px;
  font-size: 0.72rem;
  font-weight: 750;
}

.leg-side.sell {
  color: #ff6675;
}

.leg-side.buy {
  color: #4cda93;
}

.structure-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.79rem;
  line-height: 1.55;
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

table tbody tr:hover {
  background: #181e26;
}

@media (max-width: 850px) {
  #spyChart {
    min-height: 520px;
  }

  .structure-cell {
    white-space: normal;
  }
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #a9b1bd;
  font-size: 0.88rem;
  cursor: pointer;
}

.toggle-control input {
  width: 17px;
  height: 17px;
  accent-color: #55b8ff;
}

.unfilled-row {
  opacity: 0.65;
}

.status-filled {
  color: #53d391;
  font-weight: 700;
}

.status-unfilled {
  color: #d6a84b;
  font-weight: 700;
}

.status-rejected {
  color: #ff6675;
  font-weight: 700;
}

#trades td,
#orders td {
  font-size: 0.84rem;
}

@media (max-width: 1100px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .failover-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 650px) {
  .failover-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .active-setups-grid {
    grid-template-columns: 1fr;
  }

  .panel-title {
    align-items: flex-start;
    gap: 12px;
  }
}
