:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --panel: #ffffff;
  --ink: #16201f;
  --subtle: #65706e;
  --line: #d9dfdb;
  --accent: #0d7d78;
  --accent-strong: #085c59;
  --warn: #b45309;
  --buy: #087f5b;
  --sell: #b42318;
  --hold: #53616a;
  --shadow: 0 12px 26px rgba(22, 32, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--accent-strong);
}

button.service-button.start {
  background: #e8f8ef;
  border-color: #74c69d;
  color: var(--buy);
}

button.service-button.start.enabled {
  background: var(--buy);
  border-color: var(--buy);
  color: #ffffff;
}

button.service-button.stop {
  background: #fee4df;
  border-color: #f2a199;
  color: var(--sell);
}

button.service-button.stop.enabled {
  background: var(--sell);
  border-color: var(--sell);
  color: #ffffff;
}

button.service-button:disabled {
  background: #e5e9e7;
  border-color: var(--line);
  color: #6b7472;
  opacity: 1;
  cursor: not-allowed;
}

button.top-action {
  min-height: 34px;
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.32);
}

button.top-action:hover {
  border-color: #9ed6d2;
}

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

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar {
  min-height: 116px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(18px, 4vw, 48px);
  background: #13201f;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #9ed6d2;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

main {
  padding: 22px clamp(18px, 4vw, 48px) 42px;
}

.window-menu,
.tabbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.window-link,
.tab-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--subtle);
  font-weight: 850;
  padding: 0 14px;
  text-decoration: none;
}

.window-link:hover,
.tab-button:hover {
  color: var(--ink);
  border-bottom-color: #9ed6d2;
}

.window-link.active,
.tab-button.active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
}

.window-surface {
  min-height: 540px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.status-strip,
.control-band,
.summary-grid,
.workspace,
.section-heading,
.card-top,
.signal-row,
.activity-top {
  display: flex;
  align-items: center;
}

.status-strip {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ccefe9;
  color: #064d49;
  font-size: 13px;
  font-weight: 800;
}

.badge.muted {
  background: #e5e9e7;
  color: #40504d;
}

.badge.warn {
  background: #fef3c7;
  color: var(--warn);
}

.control-band {
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-group {
  flex: 1 1 240px;
}

.control-group.compact {
  flex: 0 1 150px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.summary-grid article {
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-grid span {
  display: block;
  color: var(--subtle);
  font-size: 13px;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.bot-status-panel {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.bot-status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.bot-status-grid article {
  min-height: 86px;
  padding: 14px;
  border-radius: 8px;
  background: #f4f6f2;
  border: 1px solid var(--line);
}

.bot-status-grid span {
  display: block;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.bot-status-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.workspace {
  align-items: flex-start;
  gap: 18px;
}

.settings-band {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.trading-window {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chart-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chart-frame {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f9fbf8;
}

#tradeChart {
  display: block;
  width: 100%;
  height: 420px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--subtle);
  font-weight: 800;
  background: rgba(249, 251, 248, 0.82);
}

.chart-empty.hidden {
  display: none;
}

.marker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.marker-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4f1;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.marker-chip.entry {
  background: #dff8eb;
  color: var(--buy);
}

.marker-chip.exit,
.marker-chip.sell_signal {
  background: #fee4df;
  color: var(--sell);
}

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

.warn-text {
  color: var(--warn);
}

.workspace > div {
  flex: 1 1 auto;
  min-width: 0;
}

.activity-panel {
  width: min(410px, 100%);
  position: sticky;
  top: 14px;
}

.section-heading {
  justify-content: space-between;
  gap: 14px;
  margin: 12px 0;
}

.section-heading span {
  color: var(--subtle);
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

.symbol-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.symbol-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  font-weight: 850;
}

.symbol-pill.muted {
  color: var(--subtle);
  font-weight: 700;
}

.pair-card,
.activity-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.pair-card {
  min-height: 230px;
  padding: 16px;
}

.card-top,
.signal-row,
.activity-top {
  justify-content: space-between;
  gap: 12px;
}

.symbol {
  font-size: 24px;
  font-weight: 850;
}

.strategy {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 13px;
  font-weight: 700;
}

.card-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.card-meta div {
  min-height: 54px;
  padding: 10px;
  border-radius: 7px;
  background: #f4f6f2;
}

.card-meta span {
  display: block;
  color: var(--subtle);
  font-size: 12px;
}

.card-meta strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.signal {
  min-width: 58px;
  text-align: center;
  border-radius: 999px;
  padding: 6px 10px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.signal.buy {
  background: var(--buy);
}

.signal.sell {
  background: var(--sell);
}

.signal.hold {
  background: var(--hold);
}

.message {
  color: var(--subtle);
  font-size: 14px;
  line-height: 1.45;
}

.run-pair {
  width: 100%;
  margin-top: 12px;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  padding: 14px;
}

.activity-top strong {
  font-size: 14px;
}

.activity-item p {
  margin: 8px 0 0;
  color: var(--subtle);
  font-size: 13px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #16201f;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-page {
  min-height: 100vh;
  background: #13201f;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-panel {
  width: min(430px, 100%);
  padding: 30px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.24);
}

.login-panel .eyebrow {
  color: var(--accent);
}

.login-panel h1 {
  color: var(--ink);
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form button {
  margin-top: 6px;
}

.login-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--warn);
  font-weight: 700;
}

@media (max-width: 880px) {
  .topbar,
  .workspace {
    display: block;
  }

  .status-strip {
    justify-content: flex-start;
    margin-top: 16px;
  }

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

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

  .api-form {
    grid-template-columns: 1fr;
  }

  .chart-toolbar {
    align-items: stretch;
  }

  .activity-panel {
    width: 100%;
    position: static;
    margin-top: 20px;
  }
}

@media (max-width: 560px) {
  main {
    padding-inline: 14px;
  }

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

  .bot-status-grid {
    grid-template-columns: 1fr;
  }

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