:root {
  color-scheme: dark;
  --bg: #0b0f19;
  --panel: #111827;
  --panel-2: #1f2937;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --line: #374151;
  --blue: #0ea5e9;
  --blue-hover: #38bdf8;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --orange: #f59e0b;
  --orange-bg: rgba(245, 158, 11, 0.12);
  --accent: #6366f1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at left, #1e293b 0%, #0f172a 100%, var(--bg)) no-repeat fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.inline-form { display: inline; }
button, .chip {
  border: 1px solid var(--line);
  background: #111827;
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

button:hover, .chip:hover, .chip.selected {
  border-color: var(--blue);
  color: #fff;
  background: rgba(14, 165, 233, 0.1);
}

.chip.selected {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.page {
  max-width: 95.5%;
  margin: 0 auto;
  padding: 0.5% 0;
}

.utility-actions {
  position: fixed;
  top: 10px;
  right: 5px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.icon-action,
.health-indicator {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.icon-action {
  padding: 0;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
}

.icon-action:hover,
.health-indicator:hover {
  border-color: var(--blue);
  background: rgba(14, 165, 233, 0.13);
  color: #fff;
  transform: translateY(-1px);
}

.logout-action:hover {
  border-color: var(--red);
  background: var(--red-bg);
  color: #fca5a5;
}

.health-indicator {
  cursor: pointer;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 8px currentColor;
}

.health-dot--healthy {
  background: var(--green);
  color: var(--green);
}

.health-dot--unhealthy {
  background: var(--red);
  color: var(--red);
}

/* Dashboard Header & Stats */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  height: 58px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-card {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--line);
  padding: 8px 16px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-width: 105px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.stat-label {
  font-size: 0.725rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.positive-text { color: var(--green) !important; }
.negative-text { color: var(--red) !important; }

/* Filters */
.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group {
  display: flex;
  gap: 8px;
  height: 100%;
}

.filter-group .chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  font-size: 0.95rem;
}

.filter-group .section-link {
  margin-left: 18px;
}

.refresh-btn {
  background: var(--panel);
  border-color: var(--line);
}

/* Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 1150px) {
  .dashboard-grid {
    /* grid-template-columns: 3fr 2fr; */
    grid-template-columns: minmax(0, 3.5fr) minmax(0, 2fr);
    align-items: start;
  }
}

.table-column {
  min-width: 0; /* Prevents flex/grid blowouts */
}

.detail-column {
  position: fixed;
  top: 0.5vw;
  right: 2.25%;
  width: calc((95.5% - 20px) * 2 / 5.5);
  height: calc(100vh - 1vw);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-stats {
  width: 100%;
  height: 58px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  flex: 0 0 auto;
}

.sidebar-stats .stat-card {
  min-width: 0;
  padding: 8px 10px;
}

.sidebar-stats .stat-value {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panels */
.panel {
  background: rgba(17, 24, 39, 0.75);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
}

.compact-table-panel {
  padding: 0;
}

/* Compact Table Styles */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 0.85rem;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: rgba(17, 24, 39, 0.95);
  position: sticky;
  top: 0;
  z-index: 10;
}

tr.clickable {
  cursor: pointer;
  transition: background-color 0.15s, border-left 0.1s;
}

tr.clickable:hover {
  background: rgba(56, 189, 248, 0.04);
}

tr[id^="signal-"] {
  scroll-margin-top: 84px;
}

tr.active-asset-group {
  /* background: rgba(99, 102, 241, 0.11); */
  background: rgba(20, 29, 48, 1.0)
}

tr.active-asset-group td {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Active row indicator styling */
tr.active-row {
  background: rgba(14, 165, 233, 0.08) !important;
}

tr.active-row td {
  border-bottom-color: rgba(14, 165, 233, 0.3);
}

td strong {
  font-size: 0.9rem;
  color: #fff;
}

td small {
  display: inline-block;
  background: rgba(55, 65, 81, 0.5);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  margin-left: 6px;
  text-transform: uppercase;
}

td small.asset-group-count {
  background: rgba(99, 102, 241, 0.22);
  color: #c4b5fd;
}

/* Badges & Accents */
.side {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
}
.side.long { background: var(--green-bg); color: #6ee7b7; }
.side.short { background: var(--red-bg); color: #fca5a5; }

.status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
}
.status.active { background: rgba(14, 165, 233, 0.15); color: #7dd3fc; }
.status.closed { background: var(--orange-bg); color: #fcd34d; }

.pnl {
  font-weight: 600;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
}
.pnl.positive { background: var(--green-bg); color: #34d399; }
.pnl.negative { background: var(--red-bg); color: #f87171; }
.pnl.flat { background: rgba(156, 163, 175, 0.15); color: #d1d5db; }

.save-toggle-form {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.save-toggle {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
  color: #94a3b8;
  font-size: 1rem;
  line-height: 1;
}

.save-toggle:hover,
.save-toggle.is-saved {
  border-color: #facc15;
  background: rgba(250, 204, 21, 0.14);
  color: #fde047;
}

.empty, .error {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

/* Details Sidebar / View */
.detail-sidebar-panel {
  padding: 20px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.detail-sidebar-panel .inline-chart-wrap {
  height: auto;
  min-height: 280px;
  flex: 1 1 auto;
}

/* Empty State Styling */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-grow: 1;
  padding: 40px 20px;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.65;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  color: #fff;
  font-weight: 700;
}

.empty-state p {
  max-width: 320px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Inline Detail Info Styling */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.detail-header h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pair-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.timeframe-badge {
  font-size: 0.75rem;
  background: #374151;
  padding: 2px 8px;
  border-radius: 6px;
  color: #e5e7eb;
}

.btn-link {
  font-size: 0.85rem;
  color: var(--blue);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.4);
  transition: all 0.2s;
}

.btn-link:hover {
  border-color: var(--blue);
  color: #fff;
  background: rgba(14, 165, 233, 0.1);
}

.detail-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.status-badge, .pnl-badge, .score-badge, .rr-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
}

.status-badge.active { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.status-badge.closed { background: var(--orange-bg); color: #f59e0b; }

.pnl-badge.positive { background: var(--green-bg); color: #10b981; }
.pnl-badge.negative { background: var(--red-bg); color: #ef4444; }
.pnl-badge.flat { background: rgba(156, 163, 175, 0.15); color: #9ca3af; }

.rr-badge.positive { background: var(--green-bg); color: #10b981; }
.rr-badge.negative { background: var(--red-bg); color: #ef4444; }
.rr-badge.flat { background: rgba(156, 163, 175, 0.15); color: #9ca3af; }

.score-badge {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.notify-toggle-card {
  display: inline-flex;
  align-items: center;
  margin: 0 0 0 auto;
}

.notify-toggle-card.is-disabled {
  opacity: 0.72;
}

.notify-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}

.notify-checkbox input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--green);
  cursor: pointer;
}

.notify-checkbox:has(input:checked) {
  color: #d1fae5;
}

.notify-checkbox input:disabled {
  cursor: not-allowed;
}

.notify-checkbox:has(input:disabled) {
  cursor: not-allowed;
}

/* Inline Chart Wrapper */
.inline-chart-wrap {
  width: 100%;
  height: 380px;
  background: #0b0f19;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
}

.coin-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.screener-chart-panel .chart-header {
  justify-content: flex-start;
}

.screener-chart-panel .chart-header .timeframes {
  margin-left: auto;
}

.coin-action {
  align-items: center;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 6px;
  color: #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.95rem;
  font-weight: 700;
  height: 26px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 26px;
}

.coin-action:hover {
  background: rgba(14, 165, 233, 0.18);
  border-color: #38bdf8;
  color: #f8fafc;
}

.coinglass-action {
  font-size: 0.7rem;
}

.coin-action-toast {
  background: #0f172a;
  border: 1px solid #38bdf8;
  border-radius: 8px;
  bottom: 20px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  color: #e2e8f0;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  right: 20px;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
}

.coin-action-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.coin-action-toast.is-error {
  border-color: #f87171;
}

.tiger-symbol-menu {
  background: #111827;
  border: 1px solid #475569;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  color: #e2e8f0;
  display: none;
  padding: 10px;
  position: fixed;
  width: 252px;
  z-index: 100;
}

.tiger-symbol-menu.is-visible {
  display: block;
}

.tiger-symbol-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.tiger-symbol-option {
  align-items: center;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #f8fafc;
  cursor: pointer;
  display: flex;
  font-size: 0.8rem;
  font-weight: 800;
  gap: 5px;
  justify-content: center;
  min-height: 30px;
}

.tiger-symbol-option::before {
  background: var(--tiger-group-color, #94a3b8);
  border-radius: 3px;
  content: "";
  height: 12px;
  width: 12px;
}

.tiger-symbol-option:hover {
  border-color: var(--tiger-group-color, #94a3b8);
  background: #334155;
}

#chart {
  width: 100%;
  height: min(68vh, 720px);
  min-height: 420px;
  position: relative;
  display: grid;
  grid-template-rows: minmax(220px, 2.2fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr);
}

.inline-chart-wrap #chart {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(200px, 2.25fr) minmax(80px, 0.85fr) minmax(80px, 0.85fr);
}

.strategy-chart-pane {
  min-height: 0;
  position: relative;
  border-bottom: 1px solid #293241;
}

.strategy-pane-label {
  color: #94a3b8;
  font-size: 0.68rem;
  left: 8px;
  pointer-events: none;
  position: absolute;
  top: 5px;
  z-index: 4;
}

.strategy-chart-crosshair {
  background: repeating-linear-gradient(to bottom, #9598a1 0 6px, transparent 6px 12px);
  bottom: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translateX(-9999px);
  width: 1px;
  z-index: 8;
}

.strategy-chart-crosshair[hidden] {
  display: none;
}

.chart-price-measure {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #475569;
  border-radius: 10px;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  left: 1px;
  padding: 5px 8px;
  pointer-events: none;
  position: absolute;
  top: 1px;
  z-index: 10;
}

.chart-price-measure:empty {
  display: none;
}

.chart-price-measure.is-pending {
  border-color: #38bdf8;
  color: #bae6fd;
}

.pattern-label-layer {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: 5;
}

.hold-marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.hold-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(56, 189, 248, 0.85);
  transform: translateX(-0.5px);
}

.pattern-label {
  color: #f8fafc;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  position: absolute;
  text-shadow: 0 1px 3px #020617, 0 0 8px #020617;
}

.pattern-label.above {
  transform: translate(-50%, -100%);
}

.pattern-label.below {
  transform: translate(-50%, 0);
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 0.9rem;
}

/* Inline Metrics Grid */
.inline-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.metric-card {
  background: rgba(17, 24, 39, 0.4);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.metric-card.span-2 {
  grid-column: span 2;
}

.metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.metric-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e5e7eb;
}

.price-val {
  font-family: monospace;
  font-size: 0.95rem;
}

.stop-color { color: #fca5a5; }
.target-color { color: #86efac; }
.warn-color { color: var(--orange); }

/* Details Grid for full view detail.html */
.details-grid {
  margin-top: 18px;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.details-grid div {
  background: rgba(31, 41, 55, 0.5);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--line);
}

.details-grid strong {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.details-grid span {
  font-size: 1rem;
  font-weight: 600;
}

.detail-actions {
  margin-top: 18px;
  padding: 16px;
}

.detail-actions .notify-toggle-card {
  margin-bottom: 0;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.hero h1 {
  margin: 10px 0 4px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.1;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.return-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
}

/* Full Chart view details */
.chart-panel {
  padding: 16px;
}

/* Login Panel */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 32px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}

.login-card label {
  display: block;
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b0f19;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.login-card input:focus {
  border-color: var(--blue);
  outline: none;
}

.login-card button {
  width: 100%;
  margin-top: 12px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  border: none;
  padding: 12px;
}

.login-card button:hover {
  background: var(--blue-hover);
}

/* Responsive adjustment */
@media (max-width: 1149px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    height: auto;
    margin-bottom: 16px;
  }
  
  .stats {
    width: 100%;
  }

  .stat-card {
    flex-grow: 1;
  }
  
  .detail-column {
    margin-top: 10px;
    position: static;
    right: auto;
    width: auto;
    height: auto;
  }

  .sidebar-stats {
    height: auto;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  }

  .detail-sidebar-panel .inline-chart-wrap {
    height: 380px;
    flex: none;
  }
}

