@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700&family=Pretendard:wght@400;500;600;700&display=swap');

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --card-hover: #fafbfc;
  --ink: #1f2937;
  --ink-strong: #0f172a;
  --ink-light: #4b5563;
  --dim: #94a3b8;
  --rule: #e5e7eb;
  --rule-soft: #f1f3f5;

  --accent: #3b82f6;
  --accent-soft: #eff6ff;
  --accent-strong: #1d4ed8;

  --success: #10b981;
  --success-soft: #ecfdf5;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;

  --up: #ef4444;
  --down: #3b82f6;

  --sans: 'Pretendard', 'Noto Sans KR', -apple-system, system-ui, sans-serif;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -10px rgba(15, 23, 42, 0.12), 0 4px 6px -4px rgba(15, 23, 42, 0.06);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  font-feature-settings: "tnum";
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

/* ===== LAYOUT ===== */

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.masthead__brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.masthead__logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink-strong);
}

.masthead__logo span { color: var(--accent); }

.masthead__sub {
  font-size: 13px;
  color: var(--dim);
}

.masthead__meta {
  font-size: 13px;
  color: var(--dim);
}

.masthead__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 500;
  margin-right: 10px;
}

.masthead__status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

/* ===== NAV ===== */

.nav {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  padding: 4px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--rule);
  width: fit-content;
}

.nav a {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-light);
  border-radius: 8px;
  transition: all 0.15s ease;
}

.nav a:hover {
  background: var(--rule-soft);
  color: var(--ink);
}

.nav a.active {
  background: var(--ink-strong);
  color: white;
}

/* ===== CARD ===== */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-strong);
}

.card__subtitle {
  font-size: 13px;
  color: var(--dim);
}

.card__action {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* ===== HERO ===== */

.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color: white;
  padding: 32px 28px;
  border-radius: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -60px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(255,255,255,0.12), transparent 70%);
  pointer-events: none;
}

.hero__label {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 8px;
}

.hero__value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.hero__sub {
  font-size: 14px;
  opacity: 0.9;
}

.hero__row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 24px;
  align-items: end;
}

.hero__stat {
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 20px;
}

.hero__stat-label {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.hero__stat-value {
  font-size: 20px;
  font-weight: 600;
}

/* ===== GRID ===== */

.grid {
  display: grid;
  gap: 16px;
}

.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: 2fr 1fr; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

/* ===== STAT ===== */

.stat-block {
  padding: 12px 0;
}

.stat-block__label {
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 4px;
}

.stat-block__value {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: -0.01em;
}

.stat-block__sub {
  font-size: 12px;
  color: var(--dim);
  margin-top: 2px;
}

.stat-block__delta--up { color: var(--up); }
.stat-block__delta--down { color: var(--down); }

/* ===== AGENT CARD ===== */

.agent-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.agent-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
  color: var(--ink);
}

.agent-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.agent-card__emoji {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rule-soft);
  border-radius: 10px;
}

.agent-card__name {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 2px;
}

.agent-card__step {
  font-size: 11px;
  color: var(--dim);
  font-weight: 500;
}

.agent-card__tagline {
  font-size: 14px;
  color: var(--ink-light);
  margin-bottom: 16px;
  line-height: 1.4;
}

.agent-card__metrics {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--rule-soft);
}

.agent-card__metric {
  font-size: 12px;
  color: var(--dim);
}

.agent-card__metric strong {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 2px;
}

.agent-card__error {
  color: var(--danger);
}

/* ===== FLOW ===== */

.flow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.flow__step {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  position: relative;
  transition: all 0.2s ease;
}

.flow__step:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.flow__step::after {
  content: '→';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  font-size: 14px;
  background: var(--bg);
  padding: 0 2px;
  z-index: 2;
}

.flow__step:last-child::after { content: ''; }

.flow__emoji {
  font-size: 22px;
  margin-bottom: 6px;
}

.flow__num {
  font-size: 10px;
  color: var(--dim);
  font-weight: 600;
  margin-bottom: 2px;
}

.flow__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 2px;
}

.flow__tagline {
  font-size: 11px;
  color: var(--dim);
  line-height: 1.3;
}

/* ===== AGENT DETAIL HEADER ===== */

.agent-header {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.agent-header__top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.agent-header__emoji {
  font-size: 40px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 14px;
}

.agent-header__name {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink-strong);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.agent-header__tagline {
  font-size: 15px;
  color: var(--ink-light);
}

.agent-header__role {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
  margin: 16px 0;
}

.agent-header__io {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.agent-header__io-label {
  font-size: 11px;
  color: var(--dim);
  font-weight: 600;
  margin-bottom: 4px;
}

.agent-header__io-value {
  font-size: 13px;
  color: var(--ink);
}

/* ===== TABLE ===== */

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

.table th, .table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule-soft);
}

.table th {
  font-size: 12px;
  color: var(--dim);
  font-weight: 600;
  background: var(--rule-soft);
}

.table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.table tbody tr:hover {
  background: var(--accent-soft);
}

.table tbody tr.selected {
  background: var(--accent-soft);
}

.table tbody tr.selected td {
  color: var(--accent-strong);
}

/* ===== PIPELINE STEP CARDS ===== */

.pipeline-step {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 60px 56px 1fr 100px 90px;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s;
}

.pipeline-step:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.pipeline-step__time {
  font-size: 12px;
  color: var(--dim);
  font-weight: 500;
}

.pipeline-step__emoji {
  font-size: 26px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 10px;
}

.pipeline-step__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 2px;
}

.pipeline-step__tagline {
  font-size: 12px;
  color: var(--dim);
}

.pipeline-step__bar {
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.pipeline-step__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.pipeline-step__bar-fill--error { background: var(--danger); }

.pipeline-step__duration {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
  text-align: right;
}

.pipeline-step__duration-label {
  font-size: 11px;
  color: var(--dim);
  text-align: right;
  margin-top: 2px;
}

/* ===== PAYLOAD ===== */

.payload {
  background: var(--rule-soft);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 500px;
  overflow-y: auto;
  color: var(--ink);
  font-family: 'SF Mono', 'Menlo', monospace;
}

.thesis-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.thesis-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.thesis-card__ticker {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-strong);
}

.thesis-section {
  margin-bottom: 14px;
}

.thesis-section__name {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.thesis-section__body {
  font-size: 13.5px;
  color: var(--ink-light);
  line-height: 1.65;
  padding-left: 16px;
  border-left: 2px solid var(--accent-soft);
}

/* ===== TAG / BADGE ===== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.badge--ok {
  background: var(--success-soft);
  color: var(--success);
}

.badge--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--active {
  background: var(--success-soft);
  color: var(--success);
}

.badge--candidate {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--archived {
  background: var(--rule-soft);
  color: var(--dim);
}

.badge--neutral {
  background: var(--rule-soft);
  color: var(--ink-light);
}

.badge--strong_buy { background: #fef2f2; color: #b91c1c; }
.badge--buy { background: #fff7ed; color: #c2410c; }
.badge--hold { background: var(--rule-soft); color: var(--dim); }
.badge--sell { background: #eff6ff; color: #1d4ed8; }
.badge--strong_sell { background: #eff6ff; color: #1e3a8a; }

/* ===== POLICY ===== */

.policy-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 80px 100px 80px 80px 1fr 120px;
  gap: 20px;
  align-items: center;
}

.policy-card__id {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.policy-card__params {
  font-size: 13px;
  color: var(--ink-light);
  line-height: 1.5;
}

.policy-card__params strong {
  color: var(--ink-strong);
  font-weight: 600;
}

.policy-card__reason {
  font-size: 12px;
  color: var(--dim);
  margin-top: 6px;
  font-style: italic;
}

.policy-card__reward {
  text-align: right;
}

.policy-card__reward-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink-strong);
}

.policy-card__reward--positive { color: var(--success); }
.policy-card__reward--negative { color: var(--danger); }

/* ===== MEMORY ===== */

.memory-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.memory-ns-list {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.memory-ns {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink);
  border-radius: 8px;
  margin-bottom: 2px;
}

.memory-ns:hover {
  background: var(--rule-soft);
}

.memory-ns.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 500;
}

.memory-ns__count {
  float: right;
  color: var(--dim);
  font-size: 12px;
}

.memory-item {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 10px;
}

.memory-item__meta {
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}

/* ===== LIVE ===== */

.live-feed {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.8;
  height: 600px;
  overflow-y: auto;
  padding: 20px;
  background: #fafbfc;
  border-radius: 8px;
}

.live-line {
  opacity: 0;
  animation: live-in 0.3s ease-out forwards;
  padding: 4px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.live-line__time { color: var(--dim); margin-right: 10px; }
.live-line__agent { color: var(--ink); font-weight: 500; }
.live-line__ok { color: var(--success); }
.live-line__error { color: var(--danger); }

@keyframes live-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== EMPTY ===== */

.empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--dim);
  font-size: 15px;
}

.empty__emoji {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

/* ===== UTIL ===== */

.dim { color: var(--dim); }
.ink-strong { color: var(--ink-strong); }
.accent { color: var(--accent); }
.success { color: var(--success); }
.danger { color: var(--danger); }
.mono { font-family: 'SF Mono', 'Menlo', monospace; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ===== SCROLLBAR ===== */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }
