:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3348;
  --text: #e8eaf0;
  --text-muted: #7b82a0;
  --accent: #4f8ef7;
  --accent-dim: #1e3a6e;
  --green: #2ecc71;
  --green-dim: #1a4a2e;
  --red: #e74c3c;
  --red-dim: #4a1a1a;
  --yellow: #f1c40f;
  --yellow-dim: #3d3000;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  transition: opacity 0.15s, background 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }
.btn-sell { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.sell-desc { color: var(--text-muted); font-size: 13px; margin: -10px 0 16px; }

/* Summary */
.summary-section {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 24px;
}
.summary-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  flex: 1;
}
.summary-card .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.summary-card .value {
  font-size: 22px;
  font-weight: 700;
}
.summary-actions {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: flex-start;
}
.refresh-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.last-updated {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Charts row */
.charts-row {
  max-width: 1400px;
  margin: 0 auto 24px;
  padding: 0 24px;
  display: flex;
  gap: 16px;
  align-items: stretch;
}
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.chart-main {
  flex: 1;
  min-width: 0;
}
.chart-main canvas { max-height: 300px; }
.chart-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.filter-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-btn:hover { color: var(--text); border-color: var(--accent); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.chart-allocation {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* Donut chart */
.donut-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center span:first-child {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.donut-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#allocation-chart { width: 100% !important; height: 100% !important; }

/* Allocation legend */
.allocation-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}
.allocation-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-name { flex: 1; }
.legend-pct {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

/* Table */
.table-section {
  max-width: 1400px;
  margin: 0 auto 24px;
  padding: 0 24px;
}
.table-section h2,
.news-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}
tbody tr {
  border-top: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 10px 14px;
  white-space: nowrap;
}
.empty-row { color: var(--text-muted); text-align: center; padding: 32px; }

.ticker-badge {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
}
.intent-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.intent-long { background: var(--green-dim); color: var(--green); }
.intent-short { background: var(--yellow-dim); color: var(--yellow); }

.pnl-pos { color: var(--green); font-weight: 600; }
.pnl-neg { color: var(--red); font-weight: 600; }
.pnl-neu { color: var(--text-muted); }

/* News */
.news-section {
  max-width: 1400px;
  margin: 0 auto 40px;
  padding: 0 24px;
}
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.news-placeholder { color: var(--text-muted); }
.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.news-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.news-card-ticker {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
}
.news-item {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.news-item:first-of-type { border-top: none; padding-top: 0; }
.news-headline {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.sentiment-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.sentiment-positive { background: var(--green); }
.sentiment-neutral  { background: var(--text-muted); }
.sentiment-negative { background: var(--red); }
.news-summary { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.news-loading { color: var(--text-muted); font-style: italic; font-size: 13px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 20px; font-size: 18px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
input, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-muted); }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Ticker lookup link */
.ticker-lookup-link {
  color: var(--accent);
  text-decoration: none;
}
.ticker-lookup-link:hover { text-decoration: underline; }

/* Form field hint */
.field-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

/* EUR equivalent inline label */
.eur-equiv {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

/* Row action buttons */
.row-actions { display: flex; gap: 6px; }

/* Positive/negative summary values */
.val-pos { color: var(--green); }
.val-neg { color: var(--red); }

/* Spinner on buttons */
.loading { opacity: 0.6; pointer-events: none; }
