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

:root {
  /* Grounds */
  --bg:          #0a0d13;
  --bg-primary:  #0a0d13;
  --bg-soft:     #0d111a;
  --bg-secondary:#141926;
  --bg-card:     #141926;
  --surface:     #141926;
  --surface-2:   #1a2130;
  --bg-elevated: #1a2130;
  /* Lines */
  --border:      #242b3c;
  --border-soft: #1d2433;
  /* Text */
  --text:          #eaeef6;
  --text-primary:  #eaeef6;
  --text-secondary:#aab2c7;
  --text-muted:    #8b95ad;
  --text-faint:    #586074;
  /* Accent (blue lineage, unified) */
  --blue:        #4f8ef7;
  --accent:      #4f8ef7;
  --accent-2:    #77a8ff;
  --accent-dim:  rgba(79,142,247,0.14);
  /* Semantic */
  --green:       #2dd48f;
  --red:         #f4616e;
  --yellow:      #f0a93b;
  --violet:      #8b7cff;
  --cyan:        #39c7d6;
  --gold:        #d3a24a;
  /* Shape */
  --radius:      13px;
  --radius-sm:   9px;
  --shadow:      0 10px 34px -14px rgba(0,0,0,0.65);
}

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;
}

body {
  background:
    radial-gradient(820px 460px at 0% -4%, rgba(79,142,247,0.10), transparent 58%),
    radial-gradient(760px 480px at 100% -6%, rgba(139,124,255,0.06), transparent 56%),
    var(--bg);
  background-attachment: fixed;
}

/* ─── App shell: sidebar + main column ──────────────────────────────────────── */
#app-body { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 218px;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand .brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--accent), #3f6ff0);
  box-shadow: 0 6px 16px -4px rgba(79,142,247,0.6);
  font-size: 17px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-foot .btn { width: 100%; justify-content: flex-start; }

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

/* ─── Main column: topbar + content ─────────────────────────────────────────── */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 28px;
  background: rgba(10,13,19,0.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}
.topbar-title { margin-right: auto; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.header-right { display: flex; gap: 10px; flex-wrap: wrap; }

.content { padding: 22px 28px 44px; }

section {
  padding: 0;
  margin-top: 18px;
}
.content > .tab-pane > section:first-child,
.tab-pane > .summary-cards:first-child { margin-top: 0; }

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

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  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(auto-fit, minmax(185px, 1fr));
  gap: 14px;
}

.summary-card {
  padding: 17px 20px;
  transition: border-color 0.15s, transform 0.15s;
}
.summary-card:hover { border-color: #313a52; transform: translateY(-1px); }

/* Hero summary card (first one) */
.summary-card--hero {
  grid-column: span 2;
  background:
    radial-gradient(120% 130% at 100% 0%, rgba(79,142,247,0.16), transparent 55%),
    linear-gradient(160deg, #171d2e, #111624);
  border-color: #283151;
}
.summary-card--hero .card-value { font-size: 38px; line-height: 1.05; }
@media (max-width: 720px) { .summary-card--hero { grid-column: span 1; } }

.card-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.card-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

.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: 35fr 65fr;
  gap: 14px;
}

.chart-wrapper { position: relative; height: 220px; }
.chart-card--donut { display: flex; flex-direction: column; align-items: center; }
.chart-card--donut .card-title { align-self: flex-start; }
.chart-card--donut .chart-wrapper { height: 180px; width: 100%; display: flex; justify-content: center; }
.chart-card--line { display: flex; flex-direction: column; }
.chart-card--line .chart-wrapper { flex: 1; min-height: 200px; }

#alloc-list { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; gap: 5px 20px; width: 100%; }
.alloc-row { display: flex; align-items: center; gap: 5px; font-size: 12px; width: fit-content; }
.alloc-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.alloc-ticker { font-weight: 600; color: var(--text-primary); min-width: 58px; flex-shrink: 0; }
.alloc-pct { color: var(--text-muted); min-width: 50px; flex-shrink: 0; }
.alloc-value { color: var(--text-secondary); white-space: nowrap; }

.alloc-row { position: relative; }
.alloc-tooltip {
  display: none;
  position: absolute;
  left: 0; top: calc(100% + 4px);
  background: #1a1d27;
  border: 1px solid #2a2f45;
  border-radius: 8px;
  padding: 8px 12px;
  z-index: 10;
  white-space: nowrap;
  pointer-events: none;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.alloc-tooltip strong { color: #e8eaf0; font-size: 13px; }
.alloc-tooltip span { color: #b0b7d0; }
.alloc-row:hover .alloc-tooltip { display: flex; }

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

.period-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

.period-btn:hover { color: var(--text); border-color: #313a52; }
.period-btn.active {
  background: var(--accent-dim);
  border-color: transparent;
  color: var(--accent-2);
}

/* ─── 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 12px;
  color: var(--text-faint);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.positions-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

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

.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: 700; font-size: 13.5px; }
.asset-name { color: var(--text-faint); font-size: 12px; }

.type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  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); }

/* ─── Feed Tabs ──────────────────────────────────────────────────────────────── */
.feed-tabs { display: flex; gap: 4px; }
.feed-tab {
  background: none; border: none; padding: 4px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.feed-tab:hover { background: var(--bg-elevated); color: var(--text); }
.feed-tab.active { background: rgba(79,142,247,0.15); color: var(--blue); }

/* ─── Analyst Feed Items ─────────────────────────────────────────────────────── */
.analyst-item {
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: 7px;
  border-left: 3px solid var(--blue);
  display: flex; align-items: center; gap: 12px;
}
.analyst-item-ticker { font-weight: 700; font-size: 13px; min-width: 50px; }
.analyst-item-name { font-size: 11px; color: var(--text-muted); flex: 1; }
.analyst-item-target { font-size: 11px; color: var(--text-muted); }
.analyst-item-time { font-size: 10px; color: var(--text-muted); white-space: nowrap; }

/* ─── 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: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(145deg, var(--accent), #3f6ff0);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(79,142,247,0.75);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #313a52; }
.btn-sm { padding: 5px 11px; 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) {
  .charts-row    { grid-template-columns: 1fr; }
  .bottom-row    { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  #app-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    overflow-x: auto;
  }
  .brand { padding: 0 8px 0 4px; white-space: nowrap; }
  .tab-nav { flex-direction: row; margin-top: 0; }
  .tab-btn { white-space: nowrap; padding: 8px 12px; }
  .tab-btn.active::before { display: none; }
  .sidebar-foot { margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; }
  .sidebar-foot .btn { width: auto; }
}

@media (max-width: 600px) {
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
}

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

.login-overlay {
  background:
    radial-gradient(700px 420px at 30% 0%, rgba(79,142,247,0.14), transparent 60%),
    radial-gradient(600px 400px at 100% 100%, rgba(139,124,255,0.08), transparent 60%),
    var(--bg);
}

.login-box {
  background: linear-gradient(160deg, #171d2e, #111624);
  border: 1px solid #283151;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 40px 90px -40px rgba(0,0,0,0.9);
}

.login-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  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: 18px 0 4px; }

.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); }
}

/* ─── Dividend Calendar ──────────────────────────────────────────────────────── */
.div-cal-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}
.div-cal-year {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 60px;
  text-align: center;
}
.div-cal-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.div-cal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.div-cal-month {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--border);
}
.div-cal-month-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  text-align: center;
}
.div-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.div-cal-weekdays span {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
  padding: 2px 0;
}
.div-cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}
.div-cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: default;
  min-height: 22px;
}
.div-cal-day.empty { background: transparent; }
.div-cal-day.today {
  outline: 2px solid var(--accent, #6366f1);
  outline-offset: -2px;
  border-radius: 4px;
}
.div-cal-day.today .div-cal-day-num {
  background: var(--accent, #6366f1);
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.div-cal-day.has-payment { background: rgba(34, 197, 94, 0.12); }
.div-cal-day.has-exdiv   { background: rgba(251, 146, 60, 0.12); }
.div-cal-day.has-payment.has-exdiv { background: rgba(99, 102, 241, 0.12); }
.div-cal-day-num {
  font-size: 9px;
  color: var(--text-secondary);
  line-height: 1;
}
.div-cal-dots {
  display: flex;
  gap: 1px;
  margin-top: 1px;
}
.div-cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}
.div-cal-dot.pay { background: #22c55e; }
.div-cal-dot.ex  { background: #fb923c; }
.div-cal-amt {
  font-size: 7px;
  color: #22c55e;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/* ─── Dividend Calendar Tooltip ──────────────────────────────────────────────── */
.div-cal-day.has-events { cursor: pointer; }
.div-cal-tooltip {
  display: none;
  position: fixed;
  z-index: 9999;
  background: var(--bg-primary, #1a1d2e);
  border: 1px solid var(--border, #2a2d3d);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none;
  font-size: 12px;
  color: var(--text-primary, #e2e8f0);
}
.tip-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #8892a4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.tip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
  border-bottom: 1px solid var(--border, #2a2d3d);
}
.tip-row:last-of-type { border-bottom: none; }
.tip-name {
  color: var(--text-secondary, #a0aec0);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tip-amt {
  font-weight: 700;
  color: #22c55e;
  white-space: nowrap;
}
.tip-total {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--border, #2a2d3d);
  font-weight: 700;
  color: #22c55e;
  text-align: right;
  font-size: 13px;
}

/* ─── Sidebar Navigation (vertical) ────────────────────────────────────────── */
.tab-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); background: var(--surface); }
.tab-btn.active {
  color: var(--accent-2);
  background: var(--accent-dim);
  font-weight: 600;
}
.tab-btn.active::before {
  content: "";
  position: absolute;
  left: 0; top: 9px; bottom: 9px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── AI Agent: Total Bar ──────────────────────────────────────────────────── */
.target-total-bar {
  position: relative;
  height: 28px;
  background: var(--bg-secondary, #1a1d2e);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border, #2a2d3d);
}
.target-total-fill {
  height: 100%;
  background: #f59e0b;
  transition: width 0.3s, background 0.3s;
}
.target-total-label {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-primary, #e2e8f0);
  text-shadow: 0 0 4px rgba(0,0,0,0.6);
}
.target-pct-input {
  background: var(--bg-secondary, #1a1d2e);
  border: 1px solid var(--border, #2a2d3d);
  color: var(--text-primary, #e2e8f0);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.target-pct-input:focus { outline: 2px solid var(--accent, #6366f1); }

/* ─── Deviation Indicators ─────────────────────────────────────────────────── */
.dev-ok    { color: #22c55e !important; }
.dev-warn  { color: #f59e0b !important; }
.dev-alert { color: #ef4444 !important; font-weight: 700; }

.deviation-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary, #1a1d2e);
  border-radius: 8px;
  border-left: 4px solid #f59e0b;
  margin-bottom: 8px;
}
.deviation-item.dev-warn  { border-left-color: #f59e0b; }
.deviation-item.dev-alert { border-left-color: #ef4444; }
.dev-icon { font-size: 24px; flex-shrink: 0; }
.dev-body { flex: 1; }
.dev-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 14px;
}
.dev-details {
  font-size: 12px;
  color: var(--text-muted, #8892a4);
  margin-bottom: 4px;
}
.dev-action {
  font-size: 13px;
  color: var(--text-primary, #e2e8f0);
}

/* ─── Strategy Result ──────────────────────────────────────────────────────── */
.strategy-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, #2a2d3d);
}
.urgency-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.strategy-summary {
  font-size: 14px;
  color: var(--text-primary, #e2e8f0);
  font-style: italic;
}
.strategy-body h3 {
  color: var(--accent, #6366f1);
  margin: 16px 0 8px 0;
  font-size: 16px;
}
.strategy-body h4 {
  color: var(--text-primary, #e2e8f0);
  margin: 12px 0 6px 0;
  font-size: 14px;
}
.strategy-body p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary, #a0aec0);
  margin: 4px 0;
}
.strategy-body li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary, #a0aec0);
  margin-left: 20px;
  list-style: disc;
}
.type-option   { background: rgba(168,85,247,0.15); color: #a855f7; }
.type-material { background: rgba(234,179,8,0.15);  color: #ca8a04; }

/* ─── Analyse Tab ──────────────────────────────────────────────────────────── */
.analysis-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.analysis-inputs .form-group {
  margin: 0;
}
.analysis-inputs label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
}
