* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
}
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 12px 20px;
  background: #2a2a2a;
  border-bottom: 1px solid #404040;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-brand { font-weight: 700; font-size: 1.1rem; color: #fff; }
.app-token select {
  background: #1a1a1a;
  color: #e0e0e0;
  border: 1px solid #505050;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.95rem;
}
.view-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.view-nav a {
  color: #b0b0b0;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.view-nav a.active, .view-nav a:hover { background: #404040; color: #fff; }
.app-main { padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto; }
.view-panel { display: none; }
.view-panel.active { display: block; }
.status { padding: 8px 12px; border-radius: 6px; margin: 8px 0 16px; font-size: 0.9rem; }
.status.success { background: rgba(81, 207, 102, 0.15); color: #51cf66; }
.status.error { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: #2a2a2a;
  border: 1px solid #404040;
  border-radius: 8px;
  padding: 14px 16px;
}
.card h3 { margin: 0 0 8px; font-size: 0.85rem; color: #909090; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.card .value { font-size: 1.15rem; font-weight: 600; }
.card .sub { font-size: 0.8rem; color: #909090; margin-top: 4px; }
.alert-warn {
  background: rgba(255, 212, 59, 0.12);
  border: 1px solid rgba(255, 212, 59, 0.35);
  color: #ffd43b;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.sub-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.sub-tabs button {
  background: #333;
  color: #ccc;
  border: 1px solid #505050;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}
.sub-tabs button.active { background: #4a9eff; color: #fff; border-color: #4a9eff; }
.pos-toolbar { margin: 0 0 12px; }
.toolbar-btn {
  background: #333;
  color: #e0e0e0;
  border: 1px solid #505050;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}
.toolbar-btn:hover:not(:disabled) { background: #404040; }
.toolbar-btn:disabled { opacity: 0.6; cursor: wait; }
.mark-side {
    color: #808080;
    font-size: 0.75rem;
    font-weight: 400;
}
.pnl-cell { min-width: 10rem; }
.pnl-close-primary { font-weight: 500; }
.pnl-quote-tag {
    color: #4a9eff;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.pnl-est-tag {
    color: #909090;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.mark-updated-at {
    color: #707070;
    font-size: 0.72rem;
    font-weight: 400;
    margin-top: 3px;
    line-height: 1.2;
}
.pnl-nav-est {
    color: #808080;
    font-size: 0.75rem;
    margin-top: 3px;
    line-height: 1.35;
}
.pnl-pending {
    color: #909090;
    font-size: 0.85rem;
    font-style: italic;
}
.close-ready {
    color: #51cf66;
    font-size: 0.7rem;
    font-weight: 600;
}
.close-hold {
    color: #ffd43b;
    font-size: 0.7rem;
    font-weight: 600;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th, .data-table td {
  border-bottom: 1px solid #404040;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.data-table th { color: #909090; font-weight: 600; background: #252525; position: sticky; top: 0; }
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table th.sortable:hover { color: #c0c0c0; }
.data-table th.sort-active { color: #e0e0e0; }
.table-wrap { overflow-x: auto; border: 1px solid #404040; border-radius: 8px; }
.dir-long { color: #51cf66; }
.dir-short { color: #ffd43b; }
.pnl-pos { color: #51cf66; }
.pnl-neg { color: #ff6b6b; }
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.status-open { background: rgba(81, 207, 102, 0.2); color: #51cf66; }
.status-closed { background: rgba(74, 158, 255, 0.2); color: #4a9eff; }
.status-reset { background: rgba(255, 107, 107, 0.2); color: #ff8787; }
.tx-link { color: #4a9eff; text-decoration: none; }
.tx-link:hover { text-decoration: underline; }
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding: 12px;
  background: #2a2a2a;
  border-radius: 8px;
  border: 1px solid #404040;
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}
.control-group label { display: block; font-size: 0.8rem; color: #909090; }
.control-group input, .control-group select, .control-group button {
  width: 100%;
  padding: 6px 8px;
  background: #1a1a1a;
  border: 1px solid #505050;
  color: #e0e0e0;
  border-radius: 4px;
}
.control-group button { cursor: pointer; background: #404040; }
.control-group button.reset { background: #333; margin-top: 6px; }
.chart-container { position: relative; margin-bottom: 16px; background: #2a2a2a; border: 1px solid #404040; border-radius: 8px; padding: 12px; overflow: visible; }
#marketChart { min-height: 720px; }
.fixed-tooltip {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0, 0, 0, 0.85); border: 1px solid #404040;
  border-radius: 6px; padding: 10px; font-size: 0.85rem; z-index: 1000;
  pointer-events: none; min-width: 200px;
}
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #2a2a2a; border: 1px solid #404040; border-radius: 8px; padding: 12px; }
.kpi .label { font-size: 0.75rem; color: #909090; }
.kpi .value { font-size: 1.2rem; font-weight: 600; margin-top: 4px; }
.positive { color: #51cf66; }
.negative { color: #ff6b6b; }
.side-buy { color: #51cf66; }
.side-sell { color: #ffd43b; }
.chart-block { margin-bottom: 20px; }
h2.view-title { margin: 0 0 12px; font-size: 1.25rem; }
.empty-msg { color: #909090; padding: 24px; text-align: center; }
.sub { font-size: 0.85rem; color: #909090; margin: 0 0 12px; }
.pager-info { align-self: center; color: #909090; font-size: 0.85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
#strategyCard { margin-bottom: 20px; }
#strategyCard h3 { margin: 0 0 12px; font-size: 1rem; font-weight: 600; }
.strategy-sections { display: flex; flex-direction: column; gap: 16px; margin-bottom: 8px; }
.strategy-section {
  background: #242424;
  border: 1px solid #404040;
  border-radius: 10px;
  padding: 14px 16px;
}
.section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #808080;
  margin-bottom: 12px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}
.stat {
  background: #2a2a2a;
  border: 1px solid #383838;
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #909090;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-primary {
  font-size: 1rem;
  font-weight: 600;
  color: #f0f0f0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-secondary {
  font-size: 0.82rem;
  color: #a0a0a0;
  margin-top: 4px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-secondary:empty { display: none; }
.sub-tabs button:disabled { opacity: 0.4; cursor: not-allowed; }
