/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
input[type="radio"] { accent-color: #4F8EF7; }
input[type="checkbox"] { accent-color: #4F8EF7; }

/* ── Design Tokens ── */
:root {
  --bg:            #0F0F0F;
  --surface:       #1A1A1A;
  --surface-2:     #242424;
  --border:        #2E2E2E;
  --border-strong: #3D3D3D;
  --text-primary:  #E8E8E8;
  --text-secondary:#A0A0A0;
  --text-muted:    #606060;
  --user-bubble:   #2563EB;
  --ai-bubble:     #1E2A3A;
  --alert-bg:      #2A1A00;
  --alert-border:  #F59E0B;
  --accent:               #4F8EF7;
  --accent-planning:      #4F8EF7;
  --accent-volatility:    #F59E0B;
  --accent-reflection:    #34D399;
  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 15px;
  --text-lg:   18px;
  --text-xl:   22px;
}

/* ── Base ── */
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  line-height: 1.75;
  letter-spacing: 0.01em;
}

/* ── Header ── */
header {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 12px;
}
.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.app-name {
  font-size: var(--text-base); font-weight: 500;
  letter-spacing: -0.01em; white-space: nowrap;
}
.version-badge {
  font-size: var(--text-xs); padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--border-strong); color: var(--text-secondary);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}

/* Phase dots */
.phase-indicator { display: flex; align-items: center; gap: 16px; }
.phase-dot { display: flex; align-items: center; gap: 6px; }
.phase-dot .dot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); transition: all 0.25s ease;
}
.phase-dot .dot.active    { border-color: var(--accent); background: var(--accent); }
.phase-dot .label         { font-size: var(--text-xs); color: var(--text-muted); transition: color 0.25s ease; }
.phase-dot.active .label  { color: var(--text-primary); font-weight: 500; }

/* Header buttons */
.hdr-btn {
  font-size: var(--text-xs); padding: 5px 10px; border-radius: 4px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-secondary); cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.hdr-btn:hover    { border-color: var(--border-strong); color: var(--text-primary); }
.hdr-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Alert Banner ── */
.alert-banner {
  background: var(--alert-bg); border-left: 3px solid var(--alert-border);
  padding: 10px 24px; font-size: var(--text-sm); color: var(--text-primary);
  flex-shrink: 0; display: none; align-items: center; gap: 8px;
}
.alert-banner.visible { display: flex; }

/* ── Layout ── */
main { display: flex; flex: 1; overflow: hidden; }

/* ── Conversation column ── */
.conversation-col {
  width: 65%; min-width: 340px; flex-shrink: 0; display: flex;
  flex-direction: column; border-right: 1px solid var(--border);
  background: var(--surface); position: relative;
}
.messages {
  flex: 1; overflow-y: auto; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth;
}
.messages::-webkit-scrollbar       { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Messages */
.message {
  display: flex; flex-direction: column; max-width: 85%;
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .message, .guide-panel { animation: none !important; } }

.message.ai   { align-self: flex-start; }
.message.user { align-self: flex-end; max-width: 75%; }

.bubble { padding: 10px 14px; font-size: var(--text-sm); line-height: 1.75; border-radius: 8px; }
.message.ai   .bubble { background: var(--ai-bubble);   border-radius: 8px 8px 8px 2px; color: var(--text-primary); }
.message.user .bubble { background: var(--user-bubble); border-radius: 8px 8px 2px 8px; color: #FFFFFF; }
.msg-time               { font-size: var(--text-xs); color: var(--text-muted); margin-top: 4px; padding: 0 4px; }
.message.user .msg-time { text-align: right; }

/* Typing indicator */
.typing-indicator {
  display: none; align-self: flex-start; padding: 10px 14px;
  background: var(--ai-bubble); border-radius: 8px 8px 8px 2px;
  gap: 4px; align-items: center; margin: 0 16px 4px;
}
.typing-indicator.visible { display: flex; }
.typing-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-muted); animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

/* Input bar */
.input-bar {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; background: var(--surface); flex-shrink: 0;
}
.input-bar input {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border-strong);
  border-radius: 4px; font-size: var(--text-sm); font-family: 'Inter', sans-serif;
  background: var(--surface-2); color: var(--text-primary); outline: none;
  transition: border-color 0.15s;
}
.input-bar input:focus       { border-color: var(--accent); }
.input-bar input::placeholder { color: var(--text-muted); }
.send-btn {
  padding: 8px 16px; border-radius: 4px; border: none;
  background: #2563EB; color: #fff; font-size: var(--text-sm);
  font-family: 'Inter', sans-serif; font-weight: 500; cursor: pointer;
  transition: background 0.15s;
}
.send-btn:hover    { background: #1D4ED8; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Guided input panel ── */
.guide-panel {
  position: absolute; bottom: 72px; right: 12px; left: 12px;
  background: #242424; border: 1px solid #3D3D3D;
  border-radius: 12px; padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 10; display: none;
  animation: slideUp 0.2s ease-out;
}
.guide-panel.visible { display: block; }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.guide-q {
  font-size: var(--text-sm); font-weight: 500;
  color: var(--text-primary); margin-bottom: 12px; line-height: 1.5;
}
.guide-options  { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.guide-opt {
  padding: 8px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--text-sm); color: var(--text-primary);
  cursor: pointer; text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.guide-opt:hover {
  border-color: #4F8EF7;
  background: rgba(79, 142, 247, 0.08);
}
.guide-opt.selected {
  border-color: #4F8EF7;
  background: rgba(79, 142, 247, 0.15);
  color: var(--text-primary);
  font-weight: 500;
}
.guide-divider  { font-size: var(--text-xs); color: var(--text-muted); text-align: center; margin: 6px 0; }
.guide-input-row { display: flex; gap: 6px; }
.guide-input {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: 4px; font-size: var(--text-sm); font-family: 'Inter', sans-serif;
  background: var(--surface-2); color: var(--text-primary); outline: none;
}
.guide-input:focus { border-color: var(--accent); }
.guide-submit {
  padding: 7px 14px; border-radius: 4px; border: none;
  background: #2563EB; color: #fff; font-size: var(--text-sm);
  font-weight: 500; cursor: pointer;
  transition: background 0.15s;
}
.guide-submit:hover { background: #1D4ED8; }
.guide-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.guide-close:hover { color: var(--text-primary); }
.guide-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.guide-skip {
  font-size: var(--text-xs); color: var(--text-muted);
  background: none; border: none; cursor: pointer;
}
.guide-skip:hover { color: var(--text-secondary); }
.guide-progress { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Right column ── */
.right-col { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Portfolio panel */
.portfolio-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--surface);
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-label {
  font-size: var(--text-xs); color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500;
}
/* ── Portfolio Details Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  z-index: 100; display: none; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
.modal-overlay.visible { display: flex; }
.modal-box {
  background: #1A1A1A; border: 1px solid var(--border);
  border-radius: 14px; width: 520px; max-width: 92vw; max-height: 86vh;
  overflow-y: auto; box-shadow: 0 20px 48px rgba(0,0,0,0.18);
  animation: slideUp 0.2s ease-out;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 14px; position: sticky; top: 0;
  background: #1A1A1A; border-bottom: 1px solid var(--border); z-index: 1;
}
.modal-title { font-size: var(--text-lg); font-weight: 500; }
.modal-body    { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.asset-risk-badge   { font-size: var(--text-xs); padding: 2px 8px; border-radius: 99px; font-weight: 500; }
.risk-low  { background: #064E3B; color: #6EE7B7; }
.risk-high { background: #450A0A; color: #FCA5A5; }

/* Modal footer */
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  position: sticky; bottom: 0; background: #1A1A1A;
}
.btn-secondary {
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary); font-size: var(--text-sm);
  font-family: 'Inter', sans-serif; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--border-strong); color: var(--text-primary); }
.btn-primary-modal {
  padding: 8px 20px; border-radius: 6px; border: none;
  background: #2563EB; color: #fff; font-size: var(--text-sm);
  font-family: 'Inter', sans-serif; font-weight: 500; cursor: pointer;
  transition: background 0.15s;
}
.btn-primary-modal:hover    { background: #1D4ED8; }
.btn-primary-modal:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Portfolio: single-asset states ── */
.portfolio-empty { padding: 24px 16px; text-align: center; }
.portfolio-empty-hint { font-size: var(--text-sm); color: var(--text-primary); margin-bottom: 6px; font-weight: 500; }
.portfolio-empty-sub { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.6; }

.asset-summary-card { padding: 16px; }
.asset-summary-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.asset-summary-name { font-size: var(--text-base); font-weight: 500; color: var(--text-primary); }
.asset-summary-tags { display: flex; gap: 6px; margin-bottom: 14px; }
.asset-tag { font-size: var(--text-xs); padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border-strong); color: var(--text-secondary); }

.asset-candidates { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.candidate-card { background: #1E1E1E; border: 1px solid var(--border); border-radius: 10px; padding: 14px; cursor: pointer; transition: border-color 0.15s; }
.candidate-card:hover { border-color: var(--accent); }
.candidate-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.candidate-name { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.candidate-desc { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.6; margin-bottom: 8px; }
.candidate-tags { display: flex; gap: 6px; margin-bottom: 10px; }
.candidate-select-btn { width: 100%; padding: 7px; border-radius: 6px; border: 1px solid #4F8EF7; background: rgba(79, 142, 247, 0.1); color: #4F8EF7; font-size: var(--text-xs); font-weight: 500; cursor: pointer; transition: background 0.15s, color 0.15s; }
.candidate-select-btn:hover { background: #2563EB; color: #fff; border-color: #2563EB; }

/* ── Portfolio: Phase 2 actions (Hold / Sell / Switch) ── */
.portfolio-actions { display: flex; gap: 8px; padding: 12px 16px 16px; position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 4px; margin-top: 8px; }
.action-btn { flex: 1; padding: 8px; border-radius: 6px; font-size: var(--text-xs); font-weight: 500; cursor: pointer; border: 1px solid; transition: background 0.15s, color 0.15s; }
.action-hold { border-color: var(--border-strong); background: transparent; color: var(--text-secondary); }
.action-hold:hover { background: var(--border); color: var(--text-primary); }
.action-sell { border-color: #FB923C; background: transparent; color: #FB923C; }
.action-sell:hover { background: #FB923C; color: #fff; }
.action-switch { border-color: #4F8EF7; background: transparent; color: #4F8EF7; }
.action-switch:hover { background: #4F8EF7; color: #fff; }

/* ── Survey: unanswered question highlight ── */
.survey-question-unanswered {
  border-left: 3px solid #C8860A;
  background: rgba(200, 134, 10, 0.07);
  border-radius: 0 6px 6px 0;
  padding-left: 12px;
  margin-left: -12px;
  transition: border-color 0.3s, background 0.3s;
}

/* ── Account overview ── */
.account-overview {
  padding: 14px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.account-overview-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.account-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
}
.account-row-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.account-row-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.account-total {
  font-size: var(--text-base);
  font-weight: 500;
}

/* ── Decision-gate ── */
.decision-ready-btn {
  width: calc(100% - 32px);
  margin: 8px 16px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #4F8EF7;
  background: rgba(79, 142, 247, 0.1);
  color: #4F8EF7;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.decision-ready-btn:hover {
  background: rgba(79, 142, 247, 0.2);
}
.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Performance / DCA details / checklist ── */
.perf-block { padding: 12px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.perf-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; display: block; }
.perf-row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; }
.perf-key { font-size: var(--text-sm); color: var(--text-secondary); }
.perf-val { font-family: 'JetBrains Mono', monospace; font-size: var(--text-sm); color: var(--text-primary); }
.dca-block { padding: 10px 0; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.dca-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; margin-bottom: 4px; }
.dca-toggle { font-size: 10px; color: var(--text-muted); }
.dca-insight { font-size: 11px; color: var(--text-secondary); line-height: 1.6; margin: 8px 0; padding: 8px; background: rgba(79,142,247,0.08); border-left: 2px solid #4F8EF7; border-radius: 0 4px 4px 0; }
.dca-breakdown { margin-top: 8px; }
.dca-breakdown-header { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); padding: 4px 0; border-bottom: 1px solid var(--border); }
.dca-breakdown-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); padding: 3px 0; font-family: 'JetBrains Mono', monospace; }
.dca-breakdown-toggle { width: 100%; margin-top: 6px; padding: 5px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-size: 10px; border-radius: 4px; cursor: pointer; }
.dca-steps { font-size: 11px; color: #4F8EF7; padding: 4px 0 8px; margin-bottom: 4px; }

/* ── Recommended asset tag ── */
.candidate-recommended {
  border-color: #4F8EF7;
  box-shadow: 0 0 0 1px #4F8EF7;
}
.recommend-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  color: #4F8EF7;
  background: rgba(79, 142, 247, 0.12);
  border: 1px solid rgba(79, 142, 247, 0.3);
  border-radius: 4px;
  padding: 2px 7px;
  margin-bottom: 6px;
}
