/* ─── Design tokens ─── */
:root {
  --bg:        #080808;
  --bg2:       #0d0d0d;
  --glass:     rgba(255,255,255,0.04);
  --glass-b:   rgba(255,255,255,0.06);
  --border:    rgba(255,255,255,0.07);
  --border-t:  rgba(26,200,200,0.22);
  --teal:      #1ac8c8;
  --teal-dim:  rgba(26,200,200,0.15);
  --green:     #28c88a;
  --red:       #e05a40;
  --amber:     #d4923a;
  --text:      #c0ccd8;
  --text-dim:  #50606f;
  --text-mute: #2a3038;
  --r:         14px;
  --r-sm:      9px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image:
    radial-gradient(ellipse at 15% 10%, rgba(26,200,200,0.04) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 90%, rgba(40,80,200,0.03) 0%, transparent 45%);
}

/* ─── Glass card ─── */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

/* ─── Top Bar ─── */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(8,8,8,0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  font-size: 13px;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-right: 4px;
  white-space: nowrap;
}

.kpi-pills { display: flex; gap: 6px; }

.kpi-pill {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 11px;
  border-radius: 9px;
  background: var(--glass);
  border: 1px solid var(--border);
  min-width: 85px;
  cursor: default;
  animation: fadeSlideDown 0.4s ease both;
}
.kpi-pill:nth-child(1) { animation-delay: 0.05s; }
.kpi-pill:nth-child(2) { animation-delay: 0.10s; }
.kpi-pill:nth-child(3) { animation-delay: 0.15s; }
.kpi-pill:nth-child(4) { animation-delay: 0.20s; }
.kpi-pill:nth-child(5) { animation-delay: 0.25s; }

.kpi-lbl { font-size: 9px; font-weight: 600; color: var(--text-dim); letter-spacing: 0.8px; text-transform: uppercase; }
.kpi-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi-val.teal  { color: var(--teal); }
.kpi-val.green { color: var(--green); }
.kpi-val.red   { color: var(--red); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.state-badge {
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  animation: pulse 3s ease-in-out infinite;
}
.badge-healthy { background: rgba(40,200,138,0.1);  border: 1px solid rgba(40,200,138,0.25);  color: var(--green); }
.badge-caution { background: rgba(212,146,58,0.1);  border: 1px solid rgba(212,146,58,0.25);  color: var(--amber); }
.badge-danger  { background: rgba(224,90,64,0.1);   border: 1px solid rgba(224,90,64,0.25);   color: var(--red); }

.mode-toggle { display: flex; gap: 3px; padding: 3px; background: var(--bg2); border-radius: 9px; border: 1px solid var(--border); }
.mode-btn {
  padding: 4px 11px; border-radius: 7px; border: none; background: transparent;
  color: var(--text-dim); font-size: 11px; font-weight: 600; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.mode-btn.active { background: var(--teal-dim); color: var(--teal); }

/* ─── Holdings Strip ─── */
.holdings-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(6,6,6,0.8);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.holdings-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.holdings-label::before {
  content: '';
  width: 3px; height: 14px;
  background: var(--teal);
  border-radius: 2px;
  opacity: 0.6;
}

.scroll-arrow {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--border-t);
  color: var(--teal);
  font-size: 16px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.2s;
}
.scroll-arrow:hover    { background: rgba(26,200,200,0.12); }
.scroll-arrow:disabled { opacity: 0.2; cursor: default; }

.holdings-scroll {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scroll-behavior: smooth;
  flex: 1;
  scrollbar-width: none;
}
.holdings-scroll::-webkit-scrollbar { display: none; }

.holding-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  flex-shrink: 0;
  cursor: pointer;
  animation: fadeSlideUp 0.35s ease both;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.15s, transform 0.15s;
}
.holding-chip:hover { background: var(--glass-b); }

.hold-left   { display: flex; flex-direction: column; gap: 1px; }
.hold-ticker { font-size: 12px; font-weight: 800; color: #d4dce8; }
.hold-name   { font-size: 9px; color: var(--text-dim); }
.hold-right  { text-align: right; margin-left: 6px; }
.hold-val    { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.hold-pnl    { font-size: 9px; font-weight: 700; margin-top: 1px; }
.hold-pnl.up { color: var(--green); }
.hold-pnl.dn { color: var(--red); }
.hold-qty    { font-size: 8px; color: var(--text-mute); margin-top: 1px; }

/* ─── Main Grid ─── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 10px;
  padding: 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── Center Column ─── */
.center-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }

.chart-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  animation: fadeIn 0.5s ease both 0.1s;
}
.chart-header { display: flex; align-items: center; }
.chart-title  { font-size: 12px; font-weight: 700; color: #90a8b8; letter-spacing: 0.5px; }
.chart-sub    { font-size: 10px; color: var(--text-dim); margin-left: auto; }
.chart-container { flex: 1; min-height: 120px; border-radius: 10px; overflow: hidden; }

.trades-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  height: 155px;
  align-items: stretch;
  scrollbar-width: thin;
  scrollbar-color: rgba(26,200,200,0.12) transparent;
}
.trades-row::-webkit-scrollbar       { height: 3px; }
.trades-row::-webkit-scrollbar-thumb { background: rgba(26,200,200,0.15); border-radius: 2px; }

.trade-card {
  flex-shrink: 0;
  width: 172px;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: fadeSlideUp 0.35s ease both;
  transition: border-color 0.2s, box-shadow 0.15s, transform 0.15s;
  overflow: hidden;
}
.trade-card.pending {
  border-color: rgba(212,146,58,0.3);
  background: rgba(212,146,58,0.04);
}

.trade-card-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.trade-ticker { font-size: 13px; font-weight: 800; color: #ccd8e4; }
.trade-dir    { font-size: 9px;  color: var(--text-dim); }
.status-dot   { width: 7px; height: 7px; border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.dot-open    { background: var(--teal);  box-shadow: 0 0 6px var(--teal);  animation: pulseDot 2s ease-in-out infinite; }
.dot-pending { background: var(--amber); box-shadow: 0 0 6px var(--amber); animation: pulseDot 2s ease-in-out infinite; }
.dot-closed  { background: var(--text-dim); }

.trade-entry { font-size: 10px; color: var(--text-dim); margin-bottom: 3px; }
.trade-pnl   { font-size: 12px; font-weight: 700; }
.trade-pnl.green { color: var(--green); }
.trade-pnl.red   { color: var(--red); }
.trade-pnl.amber { color: var(--amber); }

.runner-badge {
  font-size: 8px; font-weight: 800; letter-spacing: 0.8px;
  background: rgba(212,146,58,0.15); color: var(--amber);
  border: 1px solid rgba(212,146,58,0.3); border-radius: 4px;
  padding: 1px 5px; text-transform: uppercase;
}
.hint-badge {
  font-size: 8px; font-weight: 700;
  background: rgba(40,200,138,0.1); color: var(--green);
  border: 1px solid rgba(40,200,138,0.2); border-radius: 4px;
  padding: 1px 5px;
}
.trade-reasoning {
  font-size: 9px; color: var(--text-dim); margin-top: 4px;
  line-height: 1.4; font-style: italic;
  border-top: 1px solid var(--border); padding-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.trade-card.runner { border-color: rgba(212,146,58,0.2); }

.runner-chip { border-color: rgba(212,146,58,0.25) !important; }
.hold-hint { font-size: 8px; color: var(--green); margin-top: 2px; display: block; }

.btn-row { display: flex; gap: 4px; margin-top: auto; padding-top: 8px; }
.btn-approve, .btn-reject {
  flex: 1; padding: 4px 0; border: 1px solid; border-radius: 6px;
  font-size: 10px; font-weight: 700; cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
}
.btn-approve:active, .btn-reject:active { transform: scale(0.97); }
.btn-approve { background: rgba(40,200,138,0.12); color: var(--green); border-color: rgba(40,200,138,0.25); }
.btn-reject  { background: rgba(224,90,64,0.1);   color: var(--red);   border-color: rgba(224,90,64,0.22); }

/* ─── Sidebar ─── */
.sidebar { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }

.sidebar-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  animation: fadeSlideLeft 0.4s ease both;
}
.sidebar-panel:nth-child(1) { flex-shrink: 0; animation-delay: 0.15s; }
.sidebar-panel:nth-child(2) { flex: 1;        animation-delay: 0.20s; }

.feed-panel { overflow: hidden; }

.panel-header {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.panel-title { font-size: 10px; font-weight: 700; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }
.panel-count {
  margin-left: auto;
  background: var(--teal-dim);
  color: var(--teal);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 9px;
  font-weight: 700;
}
.live-dot::before { content: '● '; font-size: 7px; }

.panel-body {
  padding: 8px;
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 110px;
  scrollbar-width: thin;
  scrollbar-color: rgba(26,200,200,0.1) transparent;
}
.panel-body::-webkit-scrollbar       { width: 3px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(26,200,200,0.12); border-radius: 2px; }

.closed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-bottom: 4px;
}
.closed-ticker { font-size: 12px; font-weight: 700; color: #c0d0de; }
.closed-dir    { font-size: 9px;  color: var(--text-dim); }
.closed-pnl    { margin-left: auto; font-size: 12px; font-weight: 700; }

/* ─── Discord Feed ─── */
.feed-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(26,200,200,0.1) transparent;
}
.feed-list::-webkit-scrollbar       { width: 3px; }
.feed-list::-webkit-scrollbar-thumb { background: rgba(26,200,200,0.12); border-radius: 2px; }

.feed-msg {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.55;
  color: #60707f;
  word-break: break-word;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  animation: feedIn 0.3s ease both;
}
.feed-msg:hover { background: rgba(255,255,255,0.04); color: #8090a0; }

.feed-msg.highlighted {
  background: rgba(26,200,200,0.07);
  border-left: 3px solid var(--teal);
  border-color: rgba(26,200,200,0.3);
  color: #b0ccd0;
  box-shadow: 0 0 14px rgba(26,200,200,0.05);
}

.feed-time  { font-size: 9px; color: var(--text-mute); margin-bottom: 3px; }
.feed-tag   { display: inline-block; background: rgba(26,200,200,0.12); color: var(--teal); border-radius: 3px; padding: 0 5px; font-size: 9px; font-weight: 800; margin-right: 3px; vertical-align: middle; }
.feed-taken { font-size: 9px; color: var(--teal); margin-top: 4px; opacity: 0.8; }
.feed-brain { font-size: 9px; margin-top: 5px; font-style: italic; min-height: 0; word-break: break-word; }
.feed-brain-take { color: var(--green); }
.feed-brain-skip { color: var(--text-dim); }

/* ─── P&L Footer ─── */
.pnl-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 8px 16px;
  background: rgba(6,6,6,0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  flex-shrink: 0;
}
.pnl-item    { display: flex; align-items: center; gap: 8px; }
.pnl-lbl     { font-size: 9px; font-weight: 600; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; }
.pnl-val     { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pnl-val.green { color: var(--green); }
.pnl-val.red   { color: var(--red); }
.pnl-divider { width: 1px; height: 14px; background: var(--border); }

/* ─── Mobile account card (desktop: hidden) ─── */
.mobile-account { display: none; }

/* ─── State dot (desktop: hidden, replaced by text badge) ─── */
.state-dot { display: none; }

/* ─── Mobile section labels (desktop: hidden) ─── */
.m-section-label {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 12px 2px 4px;
}
.m-section-label::before {
  content: '';
  width: 3px; height: 12px;
  background: var(--teal);
  border-radius: 2px;
  opacity: 0.6;
}
.m-section-count {
  background: rgba(212,146,58,0.2);
  color: var(--amber);
  border-radius: 99px;
  padding: 1px 6px;
  font-size: 8px;
  font-weight: 800;
}

/* ─── Empty states ─── */
.empty-msg { font-size: 11px; color: var(--text-dim); padding: 12px; text-align: center; width: 100%; }

/* ─── Animations ─── */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideLeft {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes feedIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.7; }
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; box-shadow: 0 0 2px currentColor; }
}

/* ─── Mobile ─── */
@media (max-width: 800px) {
  /* Body: full vertical scroll */
  body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* Topbar: sticky, compact single row */
  #topbar {
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-wrap: nowrap;
  }
  .brand { font-size: 20px; font-weight: 900; letter-spacing: 0; }
  .kpi-pills { display: none; }

  /* State badge: dot only */
  .state-badge { background: transparent; border: none; padding: 0; animation: none; }
  .state-text  { display: none; }
  .state-dot   {
    display: block;
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .badge-healthy .state-dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
  .badge-caution .state-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
  .badge-danger  .state-dot { background: var(--red);   box-shadow: 0 0 8px var(--red);   }

  /* Mobile account card */
  .mobile-account {
    display: block;
    order: 2;
    margin: 10px 10px 0;
    background: rgba(26,200,200,0.04);
    border: 1px solid rgba(26,200,200,0.15);
    border-radius: 14px;
    padding: 14px 16px;
  }
  .mac-balance-lbl {
    font-size: 9px; font-weight: 600; color: var(--text-dim);
    letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px;
  }
  .mac-balance {
    font-size: 28px; font-weight: 800; color: var(--teal);
    letter-spacing: -0.5px;
  }
  .mac-stats {
    display: flex; gap: 0;
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--border);
  }
  .mac-stat { flex: 1; padding-right: 8px; }
  .mac-stat-lbl { font-size: 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; }
  .mac-stat-val { font-size: 13px; font-weight: 700; margin-top: 2px; }
  .mac-stat-val.teal  { color: var(--teal); }
  .mac-stat-val.green { color: var(--green); }
  .mac-stat-val.red   { color: var(--red); }

  /* Layout order: topbar(0) → account(2) → main-grid(3) → holdings(4) → footer(hidden) */
  .mobile-account  { order: 2; }
  .main-grid       { order: 3; }
  .holdings-strip  { order: 4; }
  .pnl-footer      { display: none; }

  /* Main grid: single column, scrollable */
  .main-grid {
    grid-template-columns: 1fr;
    overflow: visible;
    height: auto;
    padding: 8px;
    gap: 8px;
  }
  .center-col { overflow: visible; height: auto; }

  /* Chart: fixed height */
  .chart-panel { flex: none; height: 200px; }

  /* Trades: vertical full-width stack */
  .trades-row {
    flex-direction: column;
    height: auto;
    overflow: visible;
    gap: 8px;
    padding-bottom: 4px;
  }
  .trade-card {
    width: 100%;
    flex-shrink: 0;
  }
  .btn-approve, .btn-reject { padding: 10px 0; font-size: 12px; }

  /* Section labels: show on mobile */
  .m-section-label { display: flex; }

  /* Holdings strip: horizontal scroll chips */
  .holdings-strip { padding: 10px 10px; }
  .holding-chip   { min-width: 100px; }

  /* Sidebar: show below chart */
  .sidebar { display: flex; height: auto; min-height: 0; }
  .sidebar-panel { height: auto; min-height: 0; }
  .sidebar-panel:nth-child(2) { min-height: 200px; }
  .panel-body { max-height: 160px; }
  .feed-list  { max-height: 240px; }
}
