/* ============================================================
   카이스 손해사정 AI — 프로토타입
   Design: Apple-like minimal · Google-like clarity · Calm AI
   Warm white background · Deep crimson accent · Soft rose glow
   ============================================================ */

/* hidden 속성 전역 방어 — author의 display 선언이 UA 기본 [hidden]{display:none}를 이겨
   hidden이 무력화되는 CSS 함정 차단. .login-notice/.app/.admin-gate 처럼 display:flex 를
   가진 요소는 hidden 을 붙여도 안 숨겨지므로(로그인 안내·관리자 게이트가 안 사라짐),
   !important 로 hidden 을 항상 우선시켜 JS의 .hidden 토글이 실제로 동작하게 한다. */
[hidden] { display: none !important; }

:root {
  /* warm neutrals */
  --bg: #fbfaf8;
  --bg-side: #faf8f5;
  --surface: #ffffff;
  --ink: #1d1b1a;
  --ink-soft: #4a4744;
  --muted: #8c8884;
  --faint: #b6b1ab;
  --line: #ece8e2;
  --line-soft: #f3efe9;

  /* deep crimson accent (used sparingly) */
  --crimson: #9e1b32;
  --crimson-2: #b0263f;
  --crimson-ink: #7a1526;
  --rose: #fbf1f2;
  --rose-line: #f0dfe1;
  --glow: rgba(158, 27, 50, 0.18);

  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(30, 20, 18, 0.04);
  --shadow: 0 4px 24px rgba(40, 25, 22, 0.06);
  --shadow-lg: 0 16px 50px rgba(40, 25, 22, 0.10);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html, body { height: 100%; }

body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, system-ui, "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ===================== 사이드바 ===================== */
.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 16px;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px; margin-bottom: 22px; }
.brand-logo { width: 34px; height: 34px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.35; }
.brand-text strong { font-size: 14px; letter-spacing: -0.2px; color: var(--ink); white-space: nowrap; }
.brand-text span { font-size: 12px; color: var(--muted); }

.new-chat-btn {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13.5px; font-weight: 500;
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s var(--ease);
}
.new-chat-btn:hover { border-color: var(--crimson); color: var(--crimson); transform: translateY(-1px); }
.new-chat-btn .ico { color: var(--crimson); font-weight: 600; }

.history { margin-top: 26px; }
.history-label {
  font-size: 11px; color: var(--faint);
  letter-spacing: 0.7px; text-transform: uppercase;
  margin: 0 0 8px 8px;
}
.history-item {
  list-style: none;
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-soft);
  padding: 9px 11px; border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}
.history-item:hover { background: var(--line-soft); }
.history-item.active { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--ink); font-weight: 500; }
.hi-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-del {
  flex-shrink: 0; opacity: 0; border: none; background: none; color: var(--faint);
  font-size: 11px; cursor: pointer; padding: 3px 5px; border-radius: 6px;
  transition: opacity 0.14s var(--ease), color 0.14s var(--ease), background 0.14s var(--ease);
}
.history-item:hover .hi-del { opacity: 1; }
.hi-del:hover { color: var(--crimson); background: var(--rose); }
.history-empty { list-style: none; font-size: 12.5px; color: var(--faint); padding: 9px 11px; line-height: 1.5; }

.sidebar-bottom { display: flex; flex-direction: column; gap: 12px; }
.usage-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}
.usage-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--muted); }
.usage-count { color: var(--ink-soft); }
.usage-count b { color: var(--crimson); font-weight: 600; }
.usage-bar { height: 5px; background: var(--line); border-radius: 999px; margin: 9px 0 9px; overflow: hidden; }
.usage-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--crimson), var(--crimson-2)); border-radius: 999px; transition: width 0.5s var(--ease); }
.usage-note { font-size: 11px; color: var(--faint); line-height: 1.5; }
.ghost-btn { align-self: flex-start; background: none; border: none; color: var(--muted); font-family: inherit; font-size: 12.5px; cursor: pointer; padding: 2px 4px; }
.ghost-btn:hover { color: var(--crimson); }

/* ===================== 메인 ===================== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.topbar-brand { display: flex; align-items: center; gap: 9px; opacity: 0; transform: translateY(-4px); transition: all 0.35s var(--ease); }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }
.topbar-brand span { font-size: 14px; font-weight: 500; color: var(--ink); }
.topbar-badge { font-size: 12px; color: var(--crimson); background: var(--rose); border: 1px solid var(--rose-line); padding: 5px 12px; border-radius: 999px; }

/* 모바일 메뉴 토글 / 백드롭 (데스크톱에서는 숨김) */
.nav-toggle {
  display: none; flex-shrink: 0; width: 38px; height: 38px; margin-right: 4px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 10px; cursor: pointer; align-items: center; justify-content: center;
}
.nav-toggle:hover { color: var(--crimson); border-color: var(--crimson); }
.nav-backdrop { display: none; }

/* 대화 시작 후: 상단바에 브랜드 노출 + 경계선 */
.app.chatting .topbar { border-bottom-color: var(--line); background: rgba(251, 250, 248, 0.85); backdrop-filter: blur(10px); }
.app.chatting .topbar-brand { opacity: 1; transform: none; }

/* ===================== 채팅/히어로 ===================== */
.chat {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 24px 0;
}

/* 히어로: 비어있을 때 수직 중앙 */
.hero {
  margin: auto;
  width: 100%; max-width: 680px;
  padding: 0 28px;
  text-align: center;
  animation: rise 0.7s var(--ease) both;
}
.app.chatting .hero { display: none; }

.logo-glow { position: relative; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 26px; }
.logo-glow .glow {
  position: absolute; width: 188px; height: 188px; border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, rgba(158,27,50,0.05) 45%, transparent 70%);
  filter: blur(6px);
  animation: pulse 5.5s ease-in-out infinite;
}
.hero-logo { position: relative; width: 76px; height: 76px; object-fit: contain; animation: float 6s ease-in-out infinite; }

.headline { font-size: 26px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.3; margin-bottom: 12px; }
.subhead { font-size: 14.5px; color: var(--muted); line-height: 1.75; margin-bottom: 26px; }

.privacy-card {
  display: flex; gap: 11px; text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  max-width: 520px; margin: 0 auto;
}
.privacy-ico {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--rose); color: var(--crimson);
}
.privacy-card p { font-size: 13px; color: var(--ink-soft); line-height: 1.7; }
.privacy-card b { color: var(--ink); font-weight: 600; }

/* 메시지 */
.msg-wrap { width: 100%; max-width: 680px; margin: 0 auto 20px; padding: 0 28px; animation: rise 0.45s var(--ease) both; }
.msg-wrap.user { display: flex; justify-content: flex-end; }
.bubble { font-size: 14.5px; line-height: 1.72; }
.msg-wrap.user .bubble {
  background: var(--crimson); color: #fff;
  padding: 12px 16px; border-radius: 16px 16px 4px 16px;
  max-width: 80%; white-space: pre-wrap; word-break: break-word;
  box-shadow: var(--shadow-sm);
}
.msg-wrap.ai .bubble {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px 16px 16px 16px;
  padding: 20px 22px; box-shadow: var(--shadow);
}

/* AI 리포트 형식 */
.bubble .lead { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.bubble h3 { font-size: 14px; color: var(--crimson-ink); margin: 18px 0 7px; font-weight: 600; }
.bubble h3 .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; margin-right: 7px; border-radius: 6px;
  background: var(--rose); color: var(--crimson); font-size: 11px; font-weight: 600;
}
.bubble ul, .bubble ol { margin: 4px 0 4px 4px; list-style: none; }
.bubble li { position: relative; padding-left: 16px; margin-bottom: 5px; color: var(--ink-soft); }
.bubble li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.bubble .divider { height: 1px; background: var(--line); border: none; margin: 18px 0; }
.bubble .soft { color: var(--muted); font-size: 13px; line-height: 1.7; }

.ai-meta { font-size: 11px; color: var(--faint); margin: 8px 0 0 2px; }

/* 상담 CTA */
.cta-box { margin-top: 16px; background: var(--rose); border: 1px solid var(--rose-line); border-radius: 14px; padding: 16px 18px; }
.cta-box p { font-size: 13px; color: var(--crimson-ink); line-height: 1.65; margin-bottom: 12px; }
.cta-buttons { display: flex; gap: 9px; flex-wrap: wrap; }
.cta-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; background: var(--crimson); color: #fff; text-decoration: none;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  padding: 11px 18px; border-radius: 11px; cursor: pointer;
  transition: all 0.18s var(--ease);
}
.cta-btn:hover { background: var(--crimson-ink); transform: translateY(-1px); }
.cta-btn.secondary { background: #fff; color: var(--crimson); border: 1px solid var(--rose-line); }
.cta-btn.secondary:hover { border-color: var(--crimson); background: #fff; }

/* 로딩 */
.loading .bubble { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.dots { display: inline-flex; gap: 5px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--crimson); animation: blink 1.3s infinite both; }
.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }

/* ===================== 입력 영역 ===================== */
.composer { flex-shrink: 0; padding: 8px 28px 20px; background: linear-gradient(180deg, transparent, var(--bg) 22%); }
.composer-inner { max-width: 680px; margin: 0 auto; }

.input-shell {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 13px 14px 11px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input-shell:focus-within { border-color: var(--crimson-2); box-shadow: 0 8px 30px var(--glow); }
.message-input {
  border: none; outline: none; resize: none;
  font-family: inherit; font-size: 14.5px; line-height: 1.6;
  max-height: 170px; padding: 2px 4px 0; background: transparent; color: var(--ink);
}
.message-input::placeholder { color: var(--faint); }
.message-input:disabled { color: var(--faint); cursor: not-allowed; }
.input-shell:has(.message-input:disabled) { background: var(--bg); }

/* 입력창 하단 툴바 */
.input-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; }
.toolbar-left { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }

/* 모델 선택 스타일의 선택기 (사고유형 / 계산기 / 사용설명서 공통) */
.type-selector { position: relative; }
.type-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--ink-soft); font-family: inherit; font-size: 12.5px; font-weight: 500;
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
  transition: all 0.16s var(--ease);
}
.type-trigger:hover { border-color: var(--crimson); color: var(--crimson); }
.type-trigger .tool-ico { color: var(--faint); transition: color 0.16s var(--ease); }
.type-trigger:hover .tool-ico { color: var(--crimson); }
.type-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); transition: background 0.16s var(--ease); }
.type-selector.has-value .type-dot { background: var(--crimson); }
.type-selector.has-value .type-trigger { color: var(--ink); border-color: var(--rose-line); }
.type-trigger .chev { color: var(--faint); transition: transform 0.2s var(--ease); }
.type-selector.open .type-trigger { border-color: var(--crimson); color: var(--crimson); }
.type-selector.open .chev { transform: rotate(180deg); color: var(--crimson); }

.type-menu {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  min-width: 184px; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(6px) scale(0.98);
  transform-origin: bottom left;
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease), visibility 0.16s;
  z-index: 30;
}
.type-selector.open .type-menu { opacity: 1; visibility: visible; transform: none; }
.type-option {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--ink-soft);
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  transition: background 0.12s var(--ease);
}
.type-option::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.type-option:hover { background: var(--line-soft); }
.type-option.selected { background: var(--rose); color: var(--crimson-ink); font-weight: 500; }
.type-option.selected::before { background: var(--crimson); }
.send-btn {
  flex-shrink: 0; width: 40px; height: 40px; border: none; border-radius: 12px;
  background: var(--crimson); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s var(--ease);
}
.send-btn:hover { background: var(--crimson-ink); transform: translateY(-1px); }
.send-btn:disabled { background: var(--line); color: var(--faint); cursor: not-allowed; transform: none; }

.composer-hint { font-size: 11.5px; color: var(--faint); text-align: center; margin-top: 12px; line-height: 1.5; }

.login-notice {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted); text-align: center;
  margin-bottom: 10px;
}
.login-notice-link { padding: 6px 14px; font-size: 12.5px; }

/* 스크롤바 */
.chat::-webkit-scrollbar { width: 9px; }
.chat::-webkit-scrollbar-thumb { background: #e3ded7; border-radius: 9px; border: 2px solid var(--bg); }
.chat::-webkit-scrollbar-thumb:hover { background: #d4cec5; }

/* ===================== 모션 ===================== */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes pulse { 0%, 100% { opacity: 0.7; transform: scale(0.96); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================================================
   로그인 / 회원가입 (login.html)
   ============================================================ */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 20px; position: relative; overflow: hidden;
}
.auth-glow {
  position: fixed; top: 50%; left: 50%; width: 520px; height: 520px;
  transform: translate(-50%, -54%); border-radius: 50%; z-index: 0;
  background: radial-gradient(circle, var(--glow) 0%, rgba(158,27,50,0.05) 42%, transparent 68%);
  filter: blur(8px); animation: pulse 6s ease-in-out infinite;
}
.auth-wrap { position: relative; z-index: 1; width: 100%; max-width: 396px; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 22px; }
.auth-brand img { width: 46px; height: 46px; object-fit: contain; }
.auth-brand strong { display: block; font-size: 15.5px; color: var(--ink); letter-spacing: -0.2px; }
.auth-brand span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.auth-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg); padding: 26px 26px 22px;
  animation: rise 0.55s var(--ease) both;
}
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.auth-tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--muted);
  padding: 9px 0; border-radius: 9px; transition: all 0.18s var(--ease);
}
.auth-tab.active { background: var(--surface); color: var(--crimson); box-shadow: var(--shadow-sm); }

.auth-form { display: none; flex-direction: column; gap: 14px; }
.auth-form.active { display: flex; animation: rise 0.4s var(--ease) both; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.field input {
  border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px;
  font-family: inherit; font-size: 14px; color: var(--ink); background: var(--bg);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.field input:focus { outline: none; border-color: var(--crimson-2); background: var(--surface); box-shadow: 0 4px 16px var(--glow); }
.field input::placeholder { color: var(--faint); }

.auth-row { display: flex; align-items: center; justify-content: space-between; }
.checkbox { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; }
.checkbox.stacked { align-items: flex-start; line-height: 1.5; }
.checkbox input { accent-color: var(--crimson); width: 15px; height: 15px; }
.auth-link { font-size: 12.5px; color: var(--crimson); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
.auth-note { font-size: 11.5px; color: var(--muted); line-height: 1.6; background: var(--rose); border: 1px solid var(--rose-line); border-radius: 10px; padding: 10px 12px; }
.auth-error { font-size: 12px; color: var(--crimson); line-height: 1.5; margin: -2px 0 0; }
.auth-error:empty { display: none; }

.auth-submit {
  margin-top: 4px; border: none; cursor: pointer;
  background: var(--crimson); color: #fff; font-family: inherit; font-size: 14.5px; font-weight: 500;
  padding: 13px 0; border-radius: 12px; transition: all 0.18s var(--ease);
}
.auth-submit:hover { background: var(--crimson-ink); transform: translateY(-1px); }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.auth-admin-link { display: block; text-align: center; margin-top: 18px; font-size: 12px; color: var(--faint); text-decoration: none; }
.auth-admin-link:hover { color: var(--crimson); }

/* ============================================================
   관리자 대시보드 (admin.html)
   ============================================================ */
.admin-sidebar { background: var(--bg-side); }
.admin-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 22px; }
.admin-nav-item {
  display: flex; align-items: center; gap: 11px; cursor: pointer; text-decoration: none;
  font-size: 13.5px; color: var(--ink-soft); padding: 10px 12px; border-radius: 10px;
  transition: background 0.14s var(--ease);
}
.admin-nav-item .ico { width: 18px; text-align: center; color: var(--faint); font-size: 13px; }
.admin-nav-item:hover { background: var(--line-soft); }
.admin-nav-item.active { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--crimson); font-weight: 500; }
.admin-nav-item.active .ico { color: var(--crimson); }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); overflow-y: auto; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(251,250,248,0.88); backdrop-filter: blur(10px); z-index: 5;
}
.admin-topbar h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.3px; }
.admin-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.admin-user { font-size: 13px; color: var(--ink-soft); }
.admin-user b { color: var(--crimson); }
.admin-topbar-right { display: flex; align-items: center; gap: 16px; }

/* 기간 필터 (UI만) */
.period-filter { display: flex; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.period-btn {
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 12.5px; color: var(--muted); padding: 6px 13px; border-radius: 8px;
  transition: all 0.16s var(--ease);
}
.period-btn:hover { color: var(--crimson); }
.period-btn.active { background: var(--rose); color: var(--crimson); font-weight: 500; }

.admin-content { padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 22px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 13px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 17px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm);
  animation: rise 0.5s var(--ease) both;
}
.kpi-card.accent { background: linear-gradient(160deg, #fff, var(--rose)); border-color: var(--rose-line); }
/* 검토 필요 답변: 경고색 대신 은은한 로즈 + 딥 크림슨 */
.kpi-card.watch { background: linear-gradient(160deg, #fff, var(--rose)); border-color: var(--rose-line); }
.kpi-card.watch .kpi-value { color: var(--crimson); }
.kpi-card.watch .kpi-delta { color: var(--crimson-ink); opacity: 0.85; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 25px; font-weight: 700; color: var(--ink); letter-spacing: -0.5px; font-family: "Pretendard Variable", Pretendard, sans-serif; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.kpi-delta { font-size: 11px; color: var(--muted); line-height: 1.4; }
.kpi-delta.up { color: #1a7f4b; }

/* 패널 */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 14.5px; font-weight: 600; color: var(--ink); margin-bottom: 14px; }
.panel h2 span { color: var(--crimson); font-size: 11px; background: var(--rose); padding: 2px 7px; border-radius: 999px; margin-left: 4px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 0; }
.panel-more { font-size: 12.5px; color: var(--crimson); text-decoration: none; }
.panel-more:hover { text-decoration: underline; }
.panel-desc { font-size: 11.5px; color: var(--muted); margin: -8px 0 14px; }

.rank-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.rank-list { list-style: none; display: flex; flex-direction: column; gap: 11px; }
.rank-list li { display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 10px; font-size: 13px; }
.rank-name { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 막대: 너무 진한 빨강 대신 딥 크림슨을 은은하게 */
.rank-list .bar { height: 7px; border-radius: 999px; background: linear-gradient(90deg, var(--crimson), var(--crimson-2)); width: var(--w); opacity: 0.62; }
.rank-list li:first-child .bar { opacity: 0.85; }
.rank-list b { text-align: right; color: var(--ink); font-weight: 600; font-size: 12.5px; }

/* 안전 로그 요약 카드 (조용한 운영 지표 톤) */
.safety-card { background: linear-gradient(150deg, #fff, var(--rose)); border: 1px solid var(--rose-line); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow-sm); }
.safety-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.safety-head h2 { font-size: 14.5px; font-weight: 600; color: var(--crimson-ink); }
.safety-body { display: flex; align-items: center; gap: 22px; }
.safety-count { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 78px; padding: 6px 0; border-right: 1px solid var(--rose-line); }
.safety-count b { font-size: 30px; font-weight: 700; color: var(--crimson); line-height: 1; font-family: "Pretendard Variable", Pretendard, sans-serif; }
.safety-count span { font-size: 11.5px; color: var(--crimson-ink); opacity: 0.8; margin-top: 5px; }
.safety-detail { flex: 1; }
.safety-terms { font-size: 12.5px; color: var(--crimson-ink); margin-bottom: 7px; }
.safety-terms .term { display: inline-block; background: rgba(255,255,255,0.7); border: 1px solid var(--rose-line); color: var(--crimson); font-size: 11.5px; padding: 3px 9px; border-radius: 999px; margin-left: 5px; }
.safety-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.6; }

/* 리포트 보기 링크 */
.report-link { display: inline-block; font-size: 12px; color: var(--crimson); text-decoration: none; border: 1px solid var(--rose-line); padding: 3px 11px; border-radius: 999px; transition: all 0.14s var(--ease); }
.report-link:hover { background: var(--rose); border-color: var(--crimson); }

/* 회원 관리 · 사용 횟수 조정 */
.member-adjust {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 14px; margin-bottom: 16px;
}
.member-input {
  flex: 1; min-width: 180px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 13px; font-family: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.member-input:focus { outline: none; border-color: var(--crimson-2); box-shadow: 0 3px 12px var(--glow); }
.member-input::placeholder { color: var(--faint); }
.member-remain { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.member-remain b { color: var(--crimson); font-size: 15px; font-weight: 700; font-family: "Pretendard Variable", Pretendard, sans-serif; }

.stepper { display: flex; align-items: center; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.step-btn { border: none; background: var(--surface); color: var(--crimson); width: 34px; height: 38px; font-size: 16px; cursor: pointer; transition: background 0.14s var(--ease); }
.step-btn:hover { background: var(--rose); }
.step-input { width: 52px; height: 38px; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; font-family: "Pretendard Variable", Pretendard, sans-serif; font-size: 14px; color: var(--ink); -moz-appearance: textfield; }
.step-input::-webkit-outer-spin-button, .step-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-input:focus { outline: none; }
.grant-btn { border: none; background: var(--crimson); color: #fff; font-family: inherit; font-size: 13px; font-weight: 500; padding: 0 18px; height: 38px; border-radius: 10px; cursor: pointer; transition: all 0.16s var(--ease); }
.grant-btn:hover { background: var(--crimson-ink); transform: translateY(-1px); }

.member-table tbody tr.sel { background: var(--rose); }
.member-table tbody tr.sel td:first-child { font-weight: 600; color: var(--crimson-ink); }

/* 테이블 */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink-soft); }
.admin-table tbody tr:hover { background: var(--line-soft); }
.admin-table .memo { color: var(--muted); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 4px 10px; border-radius: 999px; }
.badge.new { background: var(--rose); color: var(--crimson); }
.badge.consulting { background: #eef4ff; color: #2c5dd0; }
.badge.done { background: #eafaf0; color: #1a7f4b; }
.badge.hold { background: #f3f1ee; color: var(--muted); }
.code-chip { display: inline-block; font-size: 11px; color: var(--muted); background: var(--line-soft); padding: 1px 7px; border-radius: 6px; margin-left: 4px; }
.term { display: inline-block; background: var(--rose); border: 1px solid var(--rose-line); color: var(--crimson); font-size: 11.5px; padding: 3px 9px; border-radius: 999px; }
.empty-row { font-size: 13px; color: var(--muted); padding: 18px 4px; text-align: center; }

/* 뷰 전환 */
.admin-view { display: none; flex-direction: column; gap: 22px; }
.admin-view.active { display: flex; animation: rise 0.4s var(--ease) both; }

/* 모달 */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 12, 10, 0.42); }
.modal { position: relative; width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px 24px; animation: rise 0.3s var(--ease) both; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.modal-close { border: none; background: var(--bg); width: 30px; height: 30px; border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 13px; }
.modal-close:hover { background: var(--rose); color: var(--crimson); }
.rep-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.rep-meta span { background: var(--bg); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; }
.rep-section { margin-bottom: 16px; }
.rep-section h4 { font-size: 13.5px; color: var(--crimson-ink); margin-bottom: 6px; }
.rep-section p, .rep-section li { font-size: 13px; color: var(--ink-soft); line-height: 1.7; }
.rep-section ul { margin-left: 16px; }
.rep-foot { font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--line); padding-top: 12px; }
.safety-snippet { background: var(--rose); border: 1px solid var(--rose-line); border-radius: 12px; padding: 13px 15px; margin-bottom: 16px; }
.snip-label { font-size: 11.5px; color: var(--crimson); margin-bottom: 5px; }
.snip-text { font-size: 13px; color: var(--crimson-ink); line-height: 1.6; }

/* ===================== 반응형 ===================== */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .rank-grid { grid-template-columns: 1fr; }
  .safety-body { flex-direction: column; align-items: stretch; gap: 14px; }
  .safety-count { flex-direction: row; gap: 10px; border-right: none; border-bottom: 1px solid var(--rose-line); padding-bottom: 12px; justify-content: flex-start; min-width: 0; }
}
/* ===== 채팅(index) · 로그인 모바일 (관리자 대시보드 제외) ===== */
@media (max-width: 820px) {
  /* 사이드바 → 슬라이드 드로어 */
  .sidebar:not(.admin-sidebar) {
    position: fixed; top: 0; left: 0; height: 100%; width: 286px; z-index: 60;
    transform: translateX(-100%); transition: transform 0.28s var(--ease);
    box-shadow: 0 0 44px rgba(0, 0, 0, 0.2);
  }
  .app.nav-open .sidebar:not(.admin-sidebar) { transform: none; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(20, 12, 10, 0.34); opacity: 0; visibility: hidden;
    transition: opacity 0.25s var(--ease), visibility 0.25s;
  }
  .app.nav-open .nav-backdrop { opacity: 1; visibility: visible; }
  .nav-toggle { display: inline-flex; }

  /* 상단바: 햄버거 + 브랜드 항상 노출, 배지 숨김 */
  .topbar { justify-content: flex-start; gap: 10px; padding: 0 16px; height: 56px; }
  .topbar-brand { opacity: 1; transform: none; }
  .topbar-brand span { font-size: 13.5px; }
  .topbar-badge { display: none; }

  /* 히어로 축소 */
  .headline { font-size: 23px; }
  .subhead { font-size: 13.5px; }
  .hero-logo { width: 66px; height: 66px; }
  .logo-glow .glow { width: 150px; height: 150px; }

  /* 본문 여백 / 입력 */
  .composer, .msg-wrap, .hero { padding-left: 16px; padding-right: 16px; }
  .composer { padding-bottom: 16px; }
  .message-input { font-size: 16px; } /* iOS 자동 확대 방지 */
  .bubble { font-size: 14px; }
  .msg-wrap.ai .bubble { padding: 16px; }

  /* 로그인 카드 */
  .auth-card { padding: 22px 20px 20px; }
}

/* 아주 좁은 화면: 입력 툴바 버튼 압축 */
@media (max-width: 430px) {
  .type-trigger { padding: 6px 10px; font-size: 12px; gap: 5px; }
  .input-toolbar { gap: 8px; }
  .cta-btn { font-size: 13px; padding: 10px 14px; }
}

/* ===== 관리자 대시보드 (요청 범위 외 — 기존 동작 유지) ===== */
@media (max-width: 760px) {
  .sidebar.admin-sidebar { display: none; }
  .admin-topbar { padding: 16px 18px; }
  .admin-content { padding: 18px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   AI 소개 정적 섹션 (SEO — DOM에는 항상 존재, 기본은 숨김.
   "사용 설명서" 클릭 시에만 노출. 챗 시작 시에는 항상 숨김.)
   ============================================================ */
.ai-intro {
  display: none;
  width: 100%; max-width: 680px; margin: 56px auto 0;
  padding: 32px 28px 8px;
  text-align: left;
  border-top: 1px solid var(--line);
}
.ai-intro.open { display: block; }
.app.chatting .ai-intro { display: none; }

.ai-intro-eyebrow {
  font-size: 12px; font-weight: 600; color: var(--crimson);
  letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 8px;
}
.ai-intro-title { font-size: 19px; font-weight: 700; color: var(--ink); letter-spacing: -0.2px; margin-bottom: 22px; }

.ai-intro-block { margin-bottom: 22px; }
.ai-intro-block:last-child { margin-bottom: 0; }
.ai-intro-block h3 { font-size: 14.5px; font-weight: 600; color: var(--crimson-ink); margin-bottom: 8px; }
.ai-intro-block p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.75; }
.ai-intro-block ul { list-style: none; margin: 10px 0 0; padding: 0; }
.ai-intro-block li {
  position: relative; padding-left: 16px; margin-bottom: 6px;
  font-size: 13.5px; color: var(--ink-soft); line-height: 1.6;
}
.ai-intro-block li::before {
  content: ""; position: absolute; left: 2px; top: 8px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--faint);
}
.ai-intro-block a { color: var(--crimson); text-decoration: underline; text-underline-offset: 2px; }
.ai-intro-cta { margin-top: 14px; }
.ai-intro-link {
  display: inline-flex; align-items: center;
  font-size: 13.5px; font-weight: 500; color: var(--crimson);
  border: 1px solid var(--rose-line); background: var(--rose);
  padding: 9px 16px; border-radius: 999px; text-decoration: none;
  transition: all 0.16s var(--ease);
}
.ai-intro-link:hover { border-color: var(--crimson); background: #fff; }

@media (max-width: 820px) {
  .ai-intro { padding-left: 16px; padding-right: 16px; }
}
