@import url("./maliou-tokens.css");

:root {
  --bg: var(--ml-canvas);
  --panel: var(--ml-surface);
  --panel-soft: var(--ml-surface-soft);
  --line: var(--ml-border);
  --text: var(--ml-text);
  --muted: var(--ml-text-muted);
  --green: var(--ml-success);
  --red: var(--ml-danger);
  --yellow: var(--ml-warning);
  --gold: var(--ml-accent);
  --blue: var(--ml-brand);
  --purple: var(--ml-info);
  --shadow: var(--ml-shadow-sm);
  --font-ui: var(--ml-font-ui);
  --font-num: var(--ml-font-data);
}

* {
  box-sizing: border-box;
  letter-spacing: 0 !important;
}

html,
body {
  min-width: 320px;
  overflow-x: hidden;
  background: var(--ml-canvas) !important;
  color: var(--ml-text) !important;
  font-family: var(--ml-font-ui) !important;
  line-height: 1.5;
}

body {
  margin: 0;
}

a {
  color: inherit;
}

button,
select,
input {
  font: inherit;
}

:where(a, button, select, input):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ml-focus) 40%, transparent);
  outline-offset: 2px;
}

.dashboard--poly {
  --page-accent: #4c62a2;
  --page-accent-soft: #eff2fb;
  --page-accent-line: #c7d1eb;
}

.dashboard--binance {
  --page-accent: #147a5a;
  --page-accent-soft: #edf8f3;
  --page-accent-line: #b9d9cb;
}

.shell {
  width: min(calc(100% - 40px), 1280px);
  margin: 0 auto;
  padding: 22px 0 48px;
}

.header {
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--ml-border);
  margin-bottom: 26px;
  padding: 4px 0 18px;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid var(--page-accent-line);
  border-radius: var(--ml-radius-sm);
  background: var(--page-accent-soft);
  color: var(--page-accent);
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
}

.brand .sub {
  margin-top: 3px;
  color: var(--ml-text-muted);
  font-size: 11px;
}

.nav {
  display: flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a,
.nav .nav-btn {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-sm);
  padding: 6px 11px;
  background: transparent;
  color: var(--ml-text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover,
.nav .nav-btn:hover,
.nav .nav-btn.active {
  border-color: var(--page-accent-line);
  background: var(--page-accent-soft);
  color: var(--page-accent);
}

.nav-mark {
  color: var(--ml-text-faint);
  font-family: var(--font-num);
  font-size: 10px;
}

.nav .nav-btn.active .nav-mark,
.nav a:hover .nav-mark {
  color: var(--page-accent);
}

.dashboard-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--page-accent);
  font-family: var(--font-num);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em !important;
  text-transform: uppercase;
}

.dashboard-intro h2 {
  margin: 0;
  color: var(--ml-text);
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 900;
  letter-spacing: 0 !important;
  line-height: 1.15;
}

.dashboard-intro p:not(.eyebrow) {
  margin: 7px 0 0;
  color: var(--ml-text-muted);
  font-size: 12px;
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 3px;
  color: var(--ml-text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.sync-badge small {
  padding-left: 8px;
  border-left: 1px solid var(--ml-border);
  color: var(--ml-text-faint);
  font-family: var(--font-num);
  font-size: 10px;
}

.health-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 14px;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-md);
  background: var(--ml-surface);
  box-shadow: var(--ml-shadow-sm);
}

.health-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 11px 14px;
  border-right: 1px solid var(--ml-border);
}

.health-item:last-child {
  border-right: 0;
}

.health-label {
  color: var(--ml-text-faint);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.health-value {
  overflow: hidden;
  color: var(--ml-text);
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health-value.live {
  color: var(--ml-success);
}

.hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.hero-card,
.panel {
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-md);
  background: var(--ml-surface);
  box-shadow: var(--ml-shadow-sm);
}

.hero-card {
  min-height: 104px;
  padding: 15px 16px;
}

.hero-card:first-child {
  border-color: var(--page-accent-line);
  box-shadow: inset 3px 0 var(--page-accent), var(--ml-shadow-sm);
}

.hero-card .label {
  color: var(--ml-text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-card .value {
  margin-top: 10px;
  color: var(--ml-text);
  font-family: var(--font-num);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.hero-card:first-child .value {
  color: var(--page-accent);
}

.panel {
  min-width: 0;
  margin-bottom: 14px;
  overflow: hidden;
}

.panel .title {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--ml-border);
  padding: 12px 15px;
  background: var(--ml-surface-soft);
  color: var(--ml-text);
  font-size: 13px;
  font-weight: 900;
}

.panel .title::first-letter {
  color: var(--page-accent);
}

.subtitle {
  color: var(--ml-text-muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.panel-pad {
  padding: 14px;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 14px;
  align-items: start;
}

.primary-column,
.secondary-column {
  min-width: 0;
}

.overview-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr);
  gap: 14px;
}

.overview-note {
  display: grid;
  gap: 10px;
}

.overview-note__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--ml-border);
  font-size: 12px;
}

.overview-note__row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.overview-note__row span:first-child {
  color: var(--ml-text-muted);
}

.overview-note__row strong {
  color: var(--ml-text);
  font-family: var(--font-num);
  font-size: 11px;
  text-align: right;
}

.summary-callout {
  display: grid;
  gap: 6px;
  min-height: 112px;
  align-content: center;
  border: 1px solid var(--page-accent-line);
  border-radius: var(--ml-radius-sm);
  padding: 14px;
  background: var(--page-accent-soft);
}

.summary-callout strong {
  color: var(--page-accent);
  font-size: 16px;
}

.summary-callout span {
  color: var(--ml-text-muted);
  font-size: 11px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

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

td,
th {
  border-bottom: 1px solid var(--ml-border);
  padding: 9px 12px;
  text-align: left;
  font-size: 12px;
  vertical-align: middle;
}

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

th {
  background: var(--ml-surface-soft);
  color: var(--ml-text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

td.num,
th.num,
.log-box {
  font-family: var(--font-num);
  text-align: right;
}

#strat-box table {
  min-width: 0;
}

#strat-box th {
  width: 82px;
  background: transparent;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--ml-border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.tag-on,
.tag-buy,
.tag-spot {
  border-color: color-mix(in srgb, var(--ml-success) 28%, var(--ml-border));
  background: var(--ml-success-soft);
  color: var(--ml-success);
}

.tag-off,
.tag-sell {
  border-color: color-mix(in srgb, var(--ml-danger) 28%, var(--ml-border));
  background: var(--ml-danger-soft);
  color: var(--ml-danger);
}

.tag-fut,
.tag-cat {
  border-color: color-mix(in srgb, var(--ml-warning) 28%, var(--ml-border));
  background: var(--ml-warning-soft);
  color: var(--ml-warning);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.dot-live {
  background: var(--ml-success);
  box-shadow: 0 0 8px color-mix(in srgb, var(--ml-success) 55%, transparent);
  animation: pulse 2s ease-in-out infinite;
}

.dot-off {
  background: var(--ml-text-faint);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.stat {
  min-width: 0;
  border-left: 3px solid var(--page-accent);
  border-radius: 0 var(--ml-radius-sm) var(--ml-radius-sm) 0;
  padding: 10px 11px;
  background: var(--ml-surface-soft);
}

.stat b {
  display: block;
  overflow: hidden;
  color: var(--ml-text);
  font-family: var(--font-num);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat span {
  display: block;
  margin-top: 3px;
  color: var(--ml-text-muted);
  font-size: 10px;
}

.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cat-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--ml-border);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--ml-surface-soft);
  color: var(--ml-text-muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.cat-filter:hover,
.cat-filter.active {
  border-color: var(--page-accent-line);
  background: var(--page-accent-soft);
  color: var(--page-accent);
}

.cat-chip {
  border: 1px solid var(--ml-border);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--ml-surface-soft);
  color: var(--ml-text-muted);
  font-size: 10px;
}

.cat-chip b {
  color: var(--ml-text);
  font-family: var(--font-num);
}

.cat-filter b {
  color: inherit;
  font-family: var(--font-num);
}

.filter-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 4px;
}

.filter-label {
  flex: 0 0 auto;
  padding-top: 6px;
  color: var(--ml-text-muted);
  font-size: 11px;
  font-weight: 800;
}

.filter-toolbar .cat-chips {
  min-width: 0;
}

.filter-result {
  color: var(--ml-text-faint);
  font-family: var(--font-num);
  font-size: 10px;
}

.log-box {
  min-height: 180px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #293548;
  border-radius: var(--ml-radius-sm);
  padding: 12px;
  background: #10151d;
  color: #aab6c4;
  font-size: 11px;
  line-height: 1.65;
  text-align: left;
  white-space: pre-wrap;
}

.loading {
  color: var(--ml-text-muted);
  padding: 24px 12px;
  text-align: center;
}

.ml-state {
  display: grid;
  min-height: 124px;
  place-items: center;
  gap: 6px;
  color: var(--ml-text-muted);
  text-align: center;
}

.ml-state__title {
  color: var(--ml-text);
  font-size: 13px;
  font-weight: 800;
}

.ml-state__detail {
  max-width: 420px;
  font-size: 11px;
}

.hero > .ml-state {
  grid-column: 1 / -1;
}

.ml-button {
  min-height: 34px;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-sm);
  padding: 6px 10px;
  background: var(--ml-surface-soft);
  color: var(--ml-text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

select,
input {
  min-height: 34px;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-sm);
  padding: 6px 10px;
  background: var(--ml-surface);
  color: var(--ml-text);
  font-size: 12px;
}

.kline-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.kline-controls .nav-btn {
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-sm);
  padding: 6px 11px;
  background: var(--page-accent-soft);
  color: var(--page-accent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.footer {
  padding: 22px 0 0;
  color: var(--ml-text-faint);
  font-size: 10px;
  text-align: center;
}

.footer a {
  color: var(--page-accent);
  font-weight: 700;
  text-decoration: none;
}

.green {
  color: var(--ml-success) !important;
}

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

.page {
  display: none;
}

.page.active {
  display: block;
}

@media (max-width: 900px) {
  .header {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
  }

  .dash-grid,
  .overview-bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(calc(100% - 24px), 1280px);
    padding-top: 14px;
  }

  .header {
    margin-bottom: 20px;
  }

  .dashboard-intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

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

  .health-item:nth-child(2) {
    border-right: 0;
  }

  .health-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--ml-border);
  }

  .hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .hero-card {
    min-height: 92px;
    padding: 13px;
  }

  .hero-card .value {
    font-size: 18px;
  }

  .two-col,
  .stat-row {
    grid-template-columns: 1fr;
  }

  .filter-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .panel .title {
    min-height: 46px;
    padding: 11px 12px;
  }

  .panel-pad {
    padding: 11px;
  }

  .subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sync-badge {
    padding-bottom: 0;
  }
}
