:root {
  color-scheme: dark;
  --bg: #07090f;
  --surface: rgba(15, 20, 30, 0.8);
  --surface-strong: rgba(20, 26, 38, 0.92);
  --ink: #f8f1dc;
  --muted: #9ba7b8;
  --line: rgba(238, 202, 126, 0.24);
  --soft: rgba(255, 255, 255, 0.08);
  --gold: #f4c86a;
  --gold-2: #ffe7a8;
  --green: #22e6a2;
  --cyan: #46d5ff;
  --red: #ff5f72;
  --amber: #f0a94c;
  --black: #090b10;
  --shadow: 0 24px 90px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(115deg, rgba(244, 200, 106, 0.11), transparent 26%),
    linear-gradient(245deg, rgba(70, 213, 255, 0.12), transparent 30%),
    radial-gradient(circle at 50% 0%, rgba(255, 231, 168, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.86), transparent 88%);
}

button {
  border: 1px solid rgba(244, 200, 106, 0.5);
  border-radius: 6px;
  background: linear-gradient(135deg, #f8d57c, #9d6b25);
  box-shadow: 0 10px 28px rgba(244, 200, 106, 0.18);
  color: #120d05;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 38px;
  padding: 0 16px;
}

button:hover {
  background: linear-gradient(135deg, #fff0b8, #c88b35);
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.access-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.access-gate[hidden] {
  display: none;
}

.access-card {
  width: min(560px, 100%);
  border: 1px solid rgba(244, 200, 106, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(20, 26, 38, 0.94), rgba(8, 11, 18, 0.98)),
    var(--surface-strong);
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.56), 0 0 80px rgba(244, 200, 106, 0.16);
  padding: 34px;
}

.access-card h1 {
  font-size: 46px;
  margin-bottom: 22px;
}

.access-form {
  display: grid;
  gap: 10px;
}

.access-form label {
  color: var(--muted);
  font-size: 14px;
}

.access-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.access-input-row input {
  min-width: 0;
  min-height: 46px;
  border: 1px solid rgba(70, 213, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  outline: none;
  padding: 0 14px;
}

.access-input-row input:focus {
  border-color: rgba(244, 200, 106, 0.65);
  box-shadow: 0 0 0 3px rgba(244, 200, 106, 0.12);
}

.access-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.topbar,
.section-heading,
.metric-grid,
.detail-grid {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  padding: 10px 0 26px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(244, 200, 106, 0.35);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 42px;
  line-height: 1.1;
  background: linear-gradient(90deg, #fff8df, #f4c86a 46%, #46d5ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 18px 60px rgba(244, 200, 106, 0.22);
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 14px;
  padding: 0 14px;
  white-space: nowrap;
}

.status-pill.running {
  border-color: rgba(34, 230, 162, 0.48);
  color: var(--green);
  box-shadow: 0 0 24px rgba(34, 230, 162, 0.14);
}

.status-pill.stopped {
  border-color: rgba(255, 95, 114, 0.48);
  color: var(--red);
}

.status-pill.connecting {
  border-color: rgba(240, 169, 76, 0.48);
  color: var(--amber);
}

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

.metric,
.chart-section,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric {
  min-height: 96px;
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.metric::before,
.chart-section::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 34%);
}

.chart-section,
.panel {
  position: relative;
  overflow: hidden;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.metric strong {
  display: block;
  color: var(--gold-2);
  font-size: 27px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-shadow: 0 0 26px rgba(244, 200, 106, 0.22);
}

.chart-section {
  padding: 20px;
}

.section-heading {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 14px;
}

.section-heading p,
.path-text,
.inline-error {
  color: var(--muted);
  font-size: 13px;
}

.path-text {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.inline-error {
  color: var(--red);
}

.chart-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.tool-button {
  min-height: 32px;
  border-color: rgba(70, 213, 255, 0.38);
  background: rgba(70, 213, 255, 0.08);
  box-shadow: none;
  color: #d9f7ff;
  padding: 0 12px;
}

.tool-button:hover {
  background: rgba(70, 213, 255, 0.18);
}

.icon-tool-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
}

.icon-tool-button img {
  display: block;
  width: 25px;
  height: 25px;
  filter: drop-shadow(0 0 8px rgba(244, 200, 106, 0.42));
}

.alert-button {
  border-color: rgba(255, 95, 114, 0.5);
  background: rgba(255, 95, 114, 0.14);
  color: #ffd7de;
}

.alert-button:hover {
  background: rgba(255, 95, 114, 0.24);
}

.zoom-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 380px;
  border: 1px solid rgba(70, 213, 255, 0.2);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(7, 12, 20, 0.92), rgba(8, 10, 16, 0.96));
  box-shadow: inset 0 0 36px rgba(70, 213, 255, 0.06);
  cursor: crosshair;
  overflow: hidden;
}

.volume-wrap {
  height: 180px;
  margin-top: 12px;
}

.volume-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 132px;
  border: 1px solid rgba(244, 200, 106, 0.42);
  border-radius: 6px;
  background: rgba(10, 14, 22, 0.94);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38), 0 0 24px rgba(244, 200, 106, 0.12);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
  pointer-events: none;
}

.volume-tooltip strong {
  display: block;
  font-size: 13px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.strategy-panel {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.compact {
  margin-bottom: 12px;
}

.threshold-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.threshold-modal-list {
  margin-top: 18px;
}

.threshold-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  border: 1px solid rgba(244, 200, 106, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  padding: 0 14px;
}

.threshold-row span {
  color: var(--muted);
}

.threshold-row strong {
  color: var(--gold-2);
  font-size: 16px;
}

.strategy-list {
  overflow-x: auto;
}

.strategy-table-wrap {
  min-width: 700px;
}

.strategy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.strategy-table th,
.strategy-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 11px 8px;
  text-align: left;
  white-space: nowrap;
}

.strategy-table th {
  color: #d8bd7b;
  font-weight: 600;
}

.strategy-table tbody tr {
  transition: background 140ms ease, color 140ms ease;
}

.strategy-table tbody tr:hover {
  background: rgba(244, 200, 106, 0.08);
}

.strategy-table td:nth-child(3),
.strategy-table th:nth-child(3) {
  text-align: right;
}

.strategy-table tbody tr:last-child td {
  border-bottom: 0;
}

.empty-text {
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(3, 5, 10, 0.7);
  padding: 18px;
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
  display: none;
}

.strategy-modal {
  width: min(560px, 100%);
  border: 1px solid rgba(244, 200, 106, 0.5);
  border-radius: 8px;
  background: linear-gradient(150deg, rgba(20, 26, 38, 0.98), rgba(10, 13, 22, 0.98));
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62), 0 0 70px rgba(244, 200, 106, 0.2);
  padding: 22px;
  animation: modalEnter 260ms ease-out;
}

.modal-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: rgba(244, 200, 106, 0.14);
  color: var(--gold-2);
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.modal-details {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
}

.modal-details div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.modal-details dt {
  color: var(--muted);
}

.modal-details dd {
  margin: 0;
  color: var(--gold-2);
  font-weight: 700;
  overflow-wrap: anywhere;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 900px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    grid-template-columns: 1fr;
  }

  .chart-tools {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .actions {
    justify-content: space-between;
  }

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

  h1 {
    font-size: 32px;
  }

  .canvas-wrap {
    height: 310px;
  }

  .volume-wrap {
    height: 150px;
  }

  .strategy-table-wrap {
    min-width: 0;
  }

  .strategy-table,
  .strategy-table thead,
  .strategy-table tbody,
  .strategy-table tr,
  .strategy-table th,
  .strategy-table td {
    display: block;
  }

  .strategy-table thead {
    display: none;
  }

  .strategy-table tr {
    border-bottom: 1px solid var(--soft);
    padding: 10px 0;
  }

  .strategy-table td {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 10px;
    border-bottom: 0;
    padding: 4px 0;
    text-align: left;
    white-space: normal;
  }

  .strategy-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 500;
  }

  .strategy-table td:nth-child(3) {
    text-align: left;
  }
}

@media (max-width: 520px) {
  .access-card {
    padding: 24px;
  }

  .access-card h1 {
    font-size: 34px;
  }

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

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

  .metric {
    min-height: 82px;
  }

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

  .threshold-list {
    grid-template-columns: 1fr;
  }
}
