:root {
  --navy: #232f3e;
  --orange: #ec7211;
  --blue: #0972d3;
  --blue-dark: #065299;
  --blue-light: #e6f2ff;
  --blue-border: #b5d6f4;
  --green: #037f0c;
  --green-light: #f3faf4;
  --green-border: #cfe8d2;
  --red: #d91515;
  --ink: #000716;
  --muted: #5f6b7a;
  --muted-2: #8a95a5;
  --border: #d5dbdb;
  --border-2: #e9ebed;
  --bg: #f2f3f3;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Noto Sans KR', 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  background: #ffffff;
}
button, input { font-family: inherit; }
.spacer { flex: 1; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.btn {
  border-radius: 8px;
  border: 2px solid transparent;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn:disabled { cursor: not-allowed; opacity: 0.6; }
.btn-pill { border-radius: 20px; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-outline { background: #fff; color: var(--blue); border-color: var(--blue); }
.btn-outline:hover:not(:disabled) { background: var(--blue-light); }
.btn-ghost-dark { background: transparent; color: #d1d8e0; border-color: #414d5a; }
.btn-ghost-dark:hover { background: #2b3948; }

/* ---------- 로그인 화면 ---------- */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}
.login-card {
  width: 340px;
  background: #fff;
  border-radius: 12px;
  padding: 28px 28px 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-badge {
  width: 28px; height: 28px; border-radius: 6px; background: var(--orange);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.login-title { font-weight: 700; font-size: 17px; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 6px 0 18px; }
.field-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.field-input {
  width: 100%; height: 38px; border: 2px solid #7d8998; border-radius: 8px;
  padding: 0 12px; font-size: 14px; margin-bottom: 14px; outline: none;
}
.field-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-border); }
.login-error {
  background: #fdf3f1; border: 1px solid #f8b4a8; color: var(--red);
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; margin-bottom: 12px;
}
.login-submit { width: 100%; height: 40px; margin-top: 4px; }

/* ---------- 앱 셸 ---------- */
.app-screen { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 44px; background: var(--navy); display: flex; align-items: center;
  padding: 0 16px; gap: 12px; flex: none;
}
.topbar-badge {
  width: 22px; height: 22px; border-radius: 4px; background: var(--orange);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  font-size: 12px; color: #fff;
}
.topbar-title { color: #fff; font-weight: 700; font-size: 14px; }
.topbar-sep { width: 1px; height: 18px; background: #414d5a; }
.topbar-sub { color: #95a5b8; font-size: 12.5px; }
.topbar-region { color: #95a5b8; font-size: 12px; }
.topbar-user { color: #d1d8e0; font-size: 12px; }

.tabbar {
  display: flex; background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 20px; flex: none; gap: 28px;
}
.tab {
  padding: 12px 4px; cursor: pointer; font-size: 14px; font-weight: 400;
  color: var(--ink); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-active { color: var(--blue); font-weight: 700; border-bottom-color: var(--blue); }

.tab-body { flex: 1; min-height: 0; position: relative; background: var(--bg); }
.view { position: absolute; inset: 0; }

/* ---------- 채팅 뷰 ---------- */
.view-chat { display: flex; }
.session-panel {
  width: 260px; flex: none; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.session-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border-bottom: 1px solid var(--border-2); flex: none; font-weight: 700;
}
.muted-count { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.session-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.session-item {
  padding: 9px 12px; margin: 2px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.session-item:hover { background: #f2f8fd; }
.session-item.active { background: #f2f8fd; border-color: var(--blue-border); }
.session-item-title { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item.active .session-item-title { font-weight: 700; }
.session-item-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.empty-hint { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.empty-hint.small { padding: 24px 12px; color: var(--muted-2); font-size: 12px; }

.chat-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.chat-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 11px 24px; border-bottom: 1px solid var(--border-2); }
.chat-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-online { background: var(--green); }
.status-busy { background: var(--blue); }
.status-text { font-size: 12px; color: var(--muted); }
.agent-badge {
  font-size: 11px; color: #8a95a5; background: var(--bg); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 1px 8px;
}
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 28px; }
.chat-empty {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.chat-empty-badge {
  width: 52px; height: 52px; border-radius: 50%; background: var(--blue-light); border: 1px solid var(--blue-border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--blue); font-size: 17px;
}
.chat-empty-title { font-size: 20px; font-weight: 700; margin-top: 8px; }
.chat-empty-sub { font-size: 13px; color: var(--muted); text-align: center; max-width: 360px; }

.msg-row { display: flex; gap: 10px; padding: 4px 0; max-width: 860px; margin: 0 auto; }
.msg-row.user { justify-content: flex-end; }
.msg-row.agent { justify-content: flex-start; }
.msg-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.msg-bubble {
  max-width: 620px; border-radius: 10px; padding: 10px 14px; white-space: pre-wrap; line-height: 1.65; font-size: 14px;
}
.msg-row.user .msg-bubble { background: var(--blue-light); border: 1px solid var(--blue-border); }
.msg-row.agent .msg-bubble { background: #fff; border: 1px solid var(--border-2); }
.msg-row.error .msg-bubble { background: #fdf3f1; border: 1px solid #f8b4a8; color: var(--red); }
.msg-cursor {
  display: inline-block; width: 8px; height: 14px; background: var(--blue); margin-left: 2px;
  vertical-align: text-bottom; animation: blink 0.8s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.chat-input-row { flex: none; border-top: 1px solid var(--border-2); padding: 14px 24px 10px; }
.chat-input-inner { display: flex; gap: 10px; align-items: center; max-width: 860px; margin: 0 auto; }
.chat-input {
  flex: 1; height: 40px; border: 2px solid #7d8998; border-radius: 8px; padding: 0 14px; font-size: 14px; outline: none;
}
.chat-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-border); }
.chat-input-footnote { text-align: center; font-size: 11px; color: var(--muted-2); margin-top: 8px; }

.memory-panel { width: 320px; flex: none; background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.memory-head { padding: 13px 16px; border-bottom: 1px solid var(--border-2); flex: none; }
.memory-head-title { font-size: 14px; font-weight: 700; }
.memory-head-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.memory-section { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); }
.memory-section:last-child { border-bottom: none; }
.memory-section-head {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 9px 16px;
  background: #fafbfc; border-bottom: 1px solid var(--border-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-blue { background: var(--blue); }
.dot-green { background: var(--green); }
.memory-section-title { font-size: 12.5px; font-weight: 700; color: #414d5c; }
.memory-section-sub { font-size: 11px; color: var(--muted-2); }
.count-badge { font-size: 11px; font-weight: 700; color: #414d5c; background: var(--border-2); border-radius: 10px; padding: 0 8px; }
.memory-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.memory-item { border-radius: 8px; padding: 8px 10px; }
.memory-item.short { background: #fafbfc; border: 1px solid var(--border-2); }
.memory-item.long { background: var(--green-light); border: 1px solid var(--green-border); }
.memory-item-text { font-size: 12.5px; line-height: 1.5; }
.memory-item-meta { font-size: 10.5px; color: var(--muted-2); margin-top: 3px; }
.memory-item.long .memory-item-meta { color: #6b8a6f; }

/* ---------- Runtime 테스트 뷰 ---------- */
.view-runtime { overflow-y: auto; padding: 20px 24px; }
.runtime-toolbar {
  background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 16px 24px;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap; margin-bottom: 16px;
}
.runtime-toolbar-title { font-size: 17px; font-weight: 700; }
.runtime-toolbar-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.runtime-stats { display: flex; gap: 26px; align-items: center; }
.stat-label { font-size: 11px; color: var(--muted); }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-good { color: var(--green); }
.stat-bad { color: var(--red); }
.stat-total { font-size: 12px; color: var(--muted-2); font-weight: 400; }
.runtime-actions { display: flex; gap: 10px; align-items: center; }

.runtime-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; padding-bottom: 24px; }
.rt-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px; min-height: 190px;
}
.rt-card-head { display: flex; align-items: center; gap: 8px; }
.rt-card-name { font-size: 12.5px; font-weight: 700; color: #414d5c; }
.rt-badge { font-size: 11px; font-weight: 700; color: #fff; border-radius: 10px; padding: 1px 9px; }
.rt-spinner {
  width: 12px; height: 12px; border: 2px solid var(--blue-border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.rt-question {
  font-size: 12px; color: #414d5c; background: var(--blue-light); border: 1px solid #d3e7f9;
  border-radius: 8px; padding: 7px 10px;
}
.rt-answer { flex: 1; font-size: 12.5px; line-height: 1.6; color: var(--muted-2); }
.rt-answer.done { color: var(--ink); }
.rt-answer.fail { color: var(--red); }
.rt-footer { display: flex; gap: 16px; border-top: 1px solid var(--border-2); padding-top: 8px; font-size: 11px; color: var(--muted); }
.rt-footer b { color: var(--ink); }
.rt-evidence {
  font-size: 10.5px; color: #6b8a6f; background: var(--green-light); border: 1px solid var(--green-border);
  border-radius: 6px; padding: 4px 8px; font-family: 'SFMono-Regular', Consolas, monospace;
}
