:root {
  --bg: #070b13;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-strong: rgba(255, 255, 255, 0.06);
  --text: #e7ecf6;
  --muted: #a4adc0;
  --accent: #7ef29d;
  --accent-2: #6fd2ff;
  --danger: #ff7b7b;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 10% -10%, rgba(111, 210, 255, 0.15), transparent 35%),
    radial-gradient(circle at 90% 0%, rgba(126, 242, 157, 0.16), transparent 32%),
    linear-gradient(135deg, #050811 0%, #0b1222 100%);
  color: var(--text);
  min-height: 100vh;
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.top-nav nav { display: flex; gap: 12px; }
.top-nav a { color: var(--muted); text-decoration: none; font-weight: 700; }
.top-nav a:hover { color: var(--text); }
.brand { font-weight: 800; letter-spacing: 0.04em; color: var(--text); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.top-actions button { padding: 8px 12px; }

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: center;
  margin-bottom: 26px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  font-weight: 700;
  font-size: 12px;
  margin: 0 0 6px;
}

h1 {
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: clamp(30px, 4vw, 44px);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 16px;
  color: var(--muted);
  max-width: 520px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  color: #0b1222;
  background: var(--accent);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

button.primary { box-shadow: 0 12px 30px rgba(126, 242, 157, 0.35); }
button.ghost {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
}
button.danger { color: var(--danger); border-color: var(--danger); }
button.icon { padding: 6px 10px; background: transparent; color: var(--text); }
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

.hero-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat h2 { margin: 4px 0 6px; font-size: 32px; }
.stat p { margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat span { font-size: 18px; font-weight: 700; }

.grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.analytics-grid { 
  grid-template-columns: repeat(2, 1fr); 
  align-items: start; 
}
@media (max-width: 768px) {
  .analytics-grid { grid-template-columns: 1fr; }
}
.span-2 { grid-column: span 2; }
@media (max-width: 768px) {
  .span-2 { grid-column: span 1; }
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.hint { color: var(--muted); font-size: 13px; }

.time-filter {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* Visual separation between adjacent time filter groups */
.time-filter + .time-filter {
  border-left: 1px solid var(--border);
  padding-left: 12px;
  margin-left: 8px;
}

.filter-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn[data-chart-tab] {
  font-size: 14px;
  padding: 6px 14px;
}

.filter-btn:hover {
  background: var(--panel-strong);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.table-wrap { overflow: auto; margin-top: 12px; }

table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 10px; text-align: left; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
td { border-top: 1px solid var(--border); }
tr:hover td { background: var(--panel-strong); }

.tag { padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; display: inline-block; }
.tag.buy { background: rgba(126, 242, 157, 0.18); color: var(--accent); }
.tag.ipo { background: rgba(126, 242, 157, 0.18); color: var(--accent); }
.tag.sell { background: rgba(255, 123, 123, 0.14); color: var(--danger); }
.tag.buyback { background: rgba(255, 165, 0, 0.18); color: #ffa500; }
.tag.dividend { background: rgba(111, 210, 255, 0.18); color: var(--accent-2); }
.tag.split { background: rgba(229, 206, 108, 0.18); color: #e5ce6c; }
.tag.cash { background: rgba(210, 148, 255, 0.18); color: #d294ff; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.modal.open { display: flex; }

/* Ensure portfolio-modal (confirmation) appears above other modals */
#portfolio-modal {
  z-index: 20;
}

.modal-card {
  background: #0f1728;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  width: min(800px, 100%);
  box-shadow: var(--shadow);
}
.modal-content {
  background: #0f1728;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  width: min(1200px, 95vw);
  max-height: 90vh;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 0;
  padding: 18px 18px 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { margin: 0; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h3 { margin: 0; }

/* Alert buttons in modal header */
.alert-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.alert-btn.buy-alert {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.alert-btn.buy-alert:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.alert-btn.sell-alert {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.alert-btn.sell-alert:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.alert-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}


.modal-body {
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
form input, form select, .control {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 15px;
}
form select {
  cursor: pointer;
  background-color: rgba(15, 20, 30, 0.95);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a4adc0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
form select:hover {
  background-color: rgba(20, 25, 35, 0.95);
  border-color: rgba(255, 255, 255, 0.12);
}
form select option {
  background: #0f141e;
  color: var(--text);
  padding: 10px 12px;
}
/* Ensure dropdown options are visible and styled */
select option {
  background-color: #0f141e;
  color: #e7ecf6;
  padding: 10px 12px;
}
select option:checked {
  background-color: rgba(126, 242, 157, 0.15);
  color: var(--accent);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.inline { flex-direction: row; align-items: center; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.csv-import {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--panel);
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 12px;
}
.csv-controls { display: flex; flex-direction: column; gap: 8px; }
.csv-import textarea {
  min-height: 120px;
  resize: vertical;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  font-family: "Manrope", monospace;
  font-size: 14px;
}
.microcopy { margin: 2px 0; color: var(--muted); font-size: 12px; }
.chart-wrap { position: relative; padding: 6px 0; }
.benchmark-input { margin-top: 12px; display: grid; gap: 10px; }
.benchmark-input textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  font-family: "Manrope", monospace;
  font-size: 14px;
}

.import-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; align-items: start; }
.import-grid textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-family: "Manrope", monospace;
  font-size: 14px;
}
.import-actions { display: flex; flex-direction: column; gap: 12px; }
.import-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

/* Clickable symbol in positions table */
.clickable-symbol {
  cursor: pointer;
  color: var(--accent-2);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.clickable-symbol:hover {
  color: var(--accent);
  text-decoration-style: solid;
}

/* Cost basis modal summary */
.cost-basis-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 16px;
  background: var(--panel-strong);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.cost-basis-summary .stat {
  text-align: center;
}

.cost-basis-summary .stat p {
  margin: 0 0 8px;
  font-size: 12px;
}

.cost-basis-summary .stat span {
  display: block;
  font-size: 20px;
  font-weight: 700;
}

/* Transaction history chart responsive sizing */
#transaction-history-chart {
  min-height: 300px;
}

/* Ensure table wrapper within modals has controlled height */
.modal-body .table-wrap {
  max-height: none;
  overflow-x: auto;
}

/* Responsive improvements for all screen sizes */
@media (max-width: 1200px) {
  .page-shell {
    padding: 24px 16px 60px;
  }
}

@media (max-width: 1024px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .modal-content {
    width: 98vw;
  }
  
  #transaction-history-chart {
    height: 350px !important;
  }
  
  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  h1 {
    font-size: clamp(24px, 5vw, 36px);
  }
  
  .page-shell {
    padding: 20px 12px 60px;
  }
  
  table { 
    min-width: 100%;
    font-size: 14px;
  }
  
  table th, table td {
    padding: 10px 8px;
  }
  
  .import-grid { grid-template-columns: 1fr; }
  .csv-import { grid-template-columns: 1fr; }
  .cost-basis-summary { grid-template-columns: 1fr; }
  
  .modal-content {
    width: 100%;
    max-height: 95vh;
  }
  
  .modal-card {
    width: 100%;
    padding: 16px;
  }
  
  #transaction-history-chart {
    height: 300px !important;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .top-nav {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .top-nav nav {
    justify-content: center;
  }
  
  .top-actions {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 16px 8px 40px;
  }
  
  h1 {
    font-size: 22px;
  }
  
  .hero-actions {
    flex-direction: column;
  }
  
  .hero-actions button {
    width: 100%;
  }
  
  button {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .interval-buttons, .indicator-buttons, .timeframe-buttons {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .interval-btn, .indicator-btn, .timeframe-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .cost-basis-summary {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  #transaction-history-chart {
    height: 250px !important;
  }
  
  .hero-card {
    padding: 16px;
  }
  
  .stat h2 {
    font-size: 28px;
  }
  
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .card {
    padding: 16px;
  }
  
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .section-head > div {
    width: 100%;
  }
  
  .section-head button {
    width: 100%;
  }
  
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    font-size: 12px;
  }
  
  table th, table td {
    padding: 8px 6px;
    white-space: nowrap;
  }
  
  .modal-header h2 {
    font-size: 18px;
  }
  
  .modal-body {
    padding: 12px;
  }
  
  form label {
    font-size: 12px;
  }
  
  form input, form select {
    padding: 8px 10px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .page-shell {
    padding: 12px 8px 40px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  .eyebrow {
    font-size: 10px;
  }
  
  .lede {
    font-size: 14px;
  }
  
  .top-nav nav a {
    font-size: 14px;
  }
  
  .brand {
    font-size: 14px;
  }
  
  button {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .stat-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    width: 100%;
    max-height: 98vh;
    margin: 0;
  }
  
  .modal-header {
    padding: 12px 12px 10px 12px;
  }
  
  .modal-header h2 {
    font-size: 16px;
  }
  
  .alert-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  
  .cost-basis-summary .stat span {
    font-size: 16px;
  }
  
  #transaction-history-chart {
    height: 200px !important;
  }
}

/* Ensure footer is responsive */
footer {
  padding: 24px 12px !important;
}

footer p {
  font-size: 0.85em !important;
}

@media (max-width: 640px) {
  footer {
    padding: 20px 8px !important;
  }
  
  footer p {
    font-size: 0.75em !important;
  }
}
/* Signal Modal Specific Styles */
#signal-modal .modal-content {
  max-width: 600px;
}

#signal-form input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

#signal-form .form-grid label {
  color: var(--muted);
}

.cost-basis-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

/* Detail tabs styling */
.detail-tab {
  transition: all 0.2s ease;
}

.detail-tab:hover {
  color: var(--text) !important;
  transform: translateY(0) !important;
}

.detail-tab.active {
  color: var(--text) !important;
  border-bottom-color: var(--accent) !important;
}

.tab-content {
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
