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

:root {
  --bg:          #0f1117;
  --bg-card:     #1a1d27;
  --bg-elevated: #22263a;
  --border:      #2a2f45;
  --text:        #e8eaf0;
  --text-muted:  #7b82a0;
  --blue:        #4f8ef7;
  --green:       #22c55e;
  --red:         #ef4444;
  --yellow:      #f59e0b;
  --radius:      10px;
  --shadow:      0 2px 16px rgba(0,0,0,0.4);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-right { display: flex; gap: 10px; }

section {
  padding: 0 24px;
  margin-top: 20px;
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ─── Summary Cards ─────────────────────────────────────────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.summary-card {
  padding: 16px 20px;
}

.card-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.card-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-currency-group {
  display: flex;
  gap: 8px;
}

.input-currency-group .form-input {
  flex: 1;
}

.input-currency-group .select-currency {
  width: 70px !important;
  min-width: 70px;
  flex: 0 0 70px;
  padding-left: 6px;
  padding-right: 4px;
}

/* ─── Charts ─────────────────────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 30fr 70fr;
  gap: 14px;
}

.chart-wrapper { position: relative; height: 220px; }
.chart-card--donut .chart-wrapper { height: 200px; }

.period-buttons { display: flex; gap: 4px; }

.period-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}

.period-btn.active, .period-btn:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ─── Table ──────────────────────────────────────────────────────────────────── */
.table-card { padding: 18px 0 0; }
.table-card .card-title { padding: 0 20px; }

.table-wrapper { overflow-x: auto; }

.positions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.positions-table th {
  text-align: left;
  padding: 8px 16px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.positions-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.positions-table tbody tr:last-child td { border-bottom: none; }
.positions-table tbody tr:hover { background: var(--bg-elevated); }

.positions-table .group-header-row td {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.positions-table .group-header-row:hover { background: var(--bg-card); }

.asset-cell { display: flex; flex-direction: column; gap: 2px; }
.asset-ticker { font-weight: 600; font-size: 14px; }
.asset-name { color: var(--text-muted); font-size: 12px; }

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.type-stock  { background: rgba(79,142,247,0.15); color: var(--blue); }
.type-crypto { background: rgba(245,158,11,0.15); color: var(--yellow); }
.type-private { background: rgba(122,122,122,0.15); color: var(--text-muted); }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral  { color: var(--text-muted); }

.action-buttons { display: flex; gap: 6px; }

/* ─── Bottom Row ─────────────────────────────────────────────────────────────── */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}

/* ─── Analyst Panel ──────────────────────────────────────────────────────────── */
.analyst-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.analyst-result {
  overflow-y: auto;
  max-height: 420px;
  font-size: 13px;
  line-height: 1.7;
}

.analyst-result h2, .analyst-result h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  margin: 12px 0 6px;
}

.analyst-result p { margin-bottom: 8px; }
.analyst-result ul, .analyst-result ol {
  padding-left: 18px;
  margin-bottom: 8px;
}
.analyst-result li { margin-bottom: 4px; }

.recommendation-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
}
.rec-buy  { background: rgba(34,197,94,0.15);  color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.rec-sell { background: rgba(239,68,68,0.15);  color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }
.rec-hold { background: rgba(245,158,11,0.15); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }

/* ─── News Feed ──────────────────────────────────────────────────────────────── */
.news-feed {
  overflow-y: auto;
  max-height: 460px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.news-item {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: 7px;
  border-left: 3px solid var(--blue);
  cursor: pointer;
  transition: background 0.15s;
}

.news-item:hover { background: #2a3050; }

.news-item-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.news-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.news-item-ticker {
  background: rgba(79,142,247,0.2);
  color: var(--blue);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 7px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #6fa3ff; }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #2e3450; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); }

/* ─── Form / Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 460px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-weight: 700; font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-form { padding: 18px 20px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }

.form-input, .select-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .select-input:focus { border-color: var(--blue); }
.select-input { cursor: pointer; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 2000;
  animation: slideIn 0.2s ease;
}
.toast.toast-success { border-left: 4px solid var(--green); }
.toast.toast-error   { border-left: 4px solid var(--red); }
.toast.toast-info    { border-left: 4px solid var(--blue); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Loading Spinner ────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  color: var(--text-muted);
}

/* ─── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 16px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .charts-row    { grid-template-columns: 1fr; }
  .bottom-row    { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  section { padding: 0 12px; }
  .header { padding: 12px 14px; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
}

/* ─── Login Overlay ──────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.login-title {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 12px;
}

/* ─── Dividends ──────────────────────────────────────────────────────────────── */
.dividends-card { margin: 0 24px 20px; }

.div-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.div-summary-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
}

.div-summary-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.div-summary-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
}

.text-muted { color: var(--text-muted); font-size: 12px; }

@media (max-width: 700px) {
  .div-summary { grid-template-columns: repeat(2, 1fr); }
}
