/* 얼라이브 AI CRM — Shared design tokens + sidebar + app shell */

:root {
  --indigo:        #4F46E5;
  --indigo-600:    #4338CA;
  --indigo-50:     #EEF2FF;
  --indigo-100:    #E0E7FF;
  --ink:           #0F172A;
  --ink-2:         #1F2937;
  --muted:         #6B7280;
  --muted-2:       #9CA3AF;
  --line:          #E5E7EB;
  --line-soft:     #F1F2F4;
  --bg:            #FFFFFF;
  --bg-soft:       #F9FAFB;
  --bg-side:       #FAFAFA;
  --green:         #10B981;
  --green-soft:    #ECFDF5;
  --yellow:        #FBBF24;
  --yellow-soft:   #FEF3C7;
  --red:           #EF4444;
  --red-soft:      #FEF2F2;
  --gray-status:   #9CA3AF;
  --shadow-sm:     0 1px 2px rgba(15,23,42,0.04), 0 1px 1px rgba(15,23,42,0.03);
  --shadow-md:     0 4px 14px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg:     0 12px 32px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.06);
  --shadow-focus:  0 0 0 4px rgba(79,70,229,0.12);
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     14px;
  --radius-xl:     18px;

  --font-sans: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo",
               "Malgun Gothic", "맑은 고딕", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font-family: inherit; }
::selection { background: var(--indigo-100); }
a { color: inherit; text-decoration: none; }

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- Sidebar (shared) ---------- */
.side {
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.side__top { padding: 16px 14px 10px; display: flex; align-items: center; gap: 10px; }
.logo {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--indigo) 0%, #6D5DEC 100%);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 2px 6px rgba(79,70,229,0.30);
  flex: 0 0 auto;
}
.logo svg { width: 18px; height: 18px; }
.brand__name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand__sub  { font-size: 11px; color: var(--muted); margin-top: 1px; letter-spacing: 0.04em; }

.user {
  margin: 4px 8px 8px;
  padding: 8px 10px;
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  transition: background .15s;
}
.user:hover { background: rgba(15,23,42,0.04); }
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #DDE1EA;
  color: var(--ink-2);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  flex: 0 0 auto;
}
.user__name { font-size: 13.5px; font-weight: 500; flex: 1; }
.iconbtn {
  border: 0; background: transparent;
  width: 26px; height: 26px;
  border-radius: 7px;
  color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.iconbtn:hover { background: rgba(15,23,42,0.06); color: var(--ink); }

.nav { padding: 4px 8px; display: flex; flex-direction: column; gap: 1px; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  color: #334155;
  cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav__item:hover { background: rgba(15,23,42,0.05); }
.nav__item--active {
  background: var(--indigo-50);
  color: var(--indigo-600);
  font-weight: 600;
}
.nav__item--active:hover { background: var(--indigo-50); }
.nav__icon { width: 18px; height: 18px; display: grid; place-items: center; flex: 0 0 auto; }
.nav__icon svg { width: 16px; height: 16px; }
.nav__emoji { font-size: 14px; }

.side__divider { height: 1px; background: var(--line); margin: 10px 12px; }

.biz {
  margin: 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  transition: border-color .15s;
}
.biz:hover { border-color: #D6D9DF; }
.biz__label { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.biz__value { font-size: 13.5px; font-weight: 600; flex: 1; }
.biz__chev { color: var(--muted); }

.model-row { padding: 10px 12px 4px; }
.model-row__label { font-size: 11px; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.04em; }
.model-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px;
  background: var(--indigo-50);
  color: var(--indigo-600);
  border: 1px solid #DDE2FA;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.model-chip__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.18);
}

.recent-head { padding: 6px 14px; display: flex; align-items: center; justify-content: space-between; }
.recent-head__label { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.recent { padding: 0 8px 16px; flex: 1; min-height: 0; overflow-y: auto; }
.recent::-webkit-scrollbar { width: 8px; }
.recent::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.10); border-radius: 8px; }
.recent::-webkit-scrollbar-track { background: transparent; }

.session {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  transition: background .12s;
  line-height: 1.35;
}
.session:hover { background: rgba(15,23,42,0.04); color: var(--ink); }
.session__marker { width: 3px; height: 14px; border-radius: 3px; background: transparent; flex: 0 0 auto; }
.session--active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.session--active .session__marker { background: var(--indigo); }
.session__title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session__time { font-size: 11px; color: var(--muted-2); flex: 0 0 auto; }

/* ---------- Main column ---------- */
.main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  height: 100%;
  background: var(--bg);
  position: relative;
}
.scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.10); border-radius: 8px; }

/* Top bar shared */
.topbar {
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 16px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  z-index: 5;
}
.topbar__inner {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
}
.topbar__title {
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 8px;
}
.topbar__sub { font-size: 12.5px; color: var(--muted); }
.topbar__sub code {
  font-family: var(--font-mono); font-size: 11.5px;
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 5px; color: var(--ink-2);
}
.topbar__spacer { flex: 1; }

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 28px 60px;
}
.page--wide { max-width: 1080px; }

/* Cards / shared */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card--padded { padding: 18px; }
.card--hover:hover { box-shadow: var(--shadow-md); border-color: #D6D9DF; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .08s;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--indigo); color: #fff; box-shadow: 0 2px 6px rgba(79,70,229,0.25); }
.btn--primary:hover { background: var(--indigo-600); }
.btn--outline { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn--outline:hover { background: var(--bg-soft); border-color: #D6D9DF; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn--danger { background: #fff; color: var(--red); border-color: #FECACA; }
.btn--danger:hover { background: var(--red-soft); }
.btn--sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12px; color: var(--muted); font-weight: 500; }
.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: var(--shadow-focus);
}
.input::placeholder { color: var(--muted-2); }
textarea.input { font-family: inherit; resize: vertical; line-height: 1.55; }
.select {
  appearance: none;
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 10px center / 14px;
  padding-right: 32px;
}

/* Pills / chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.chip--green { background: var(--green-soft); border-color: #BBF7D0; color: #047857; }
.chip--yellow { background: var(--yellow-soft); border-color: #FDE68A; color: #92400E; }
.chip--red { background: var(--red-soft); border-color: #FECACA; color: #B91C1C; }
.chip--indigo { background: var(--indigo-50); border-color: #DDE2FA; color: var(--indigo-600); }
.chip--gray { background: var(--bg-soft); border-color: var(--line); color: var(--muted); }
.chip--mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: -0.01em; }

/* Progress bar */
.progress {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line-soft);
  box-shadow: inset 0 0 0 1px rgba(15,23,42,0.04);
}
.progress--lg { height: 10px; }
.progress__seg { height: 100%; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.progress__seg--green { background: var(--green); }
.progress__seg--yellow { background: var(--yellow); }
.progress__seg--gray { background: var(--gray-status); opacity: 0.55; }

/* Toggle switch */
.switch {
  position: relative;
  width: 36px; height: 20px;
  background: #D1D5DB;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
  flex: 0 0 auto;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: left .18s cubic-bezier(.2,.8,.2,1);
}
.switch--on { background: var(--indigo); }
.switch--on::after { left: 18px; }
.switch--disabled { opacity: 0.45; cursor: not-allowed; }

/* Section dividers in pages */
.page-section + .page-section { margin-top: 32px; padding-top: 32px; border-top: 1px solid var(--line); }
.page-section__title {
  font-size: 14px; font-weight: 600; margin: 0 0 14px;
  display: inline-flex; align-items: center; gap: 8px;
  letter-spacing: -0.005em;
}
.page-section__sub { font-size: 12.5px; color: var(--muted); margin-top: -10px; margin-bottom: 14px; }

/* Tables */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th, .tbl td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.tbl th {
  font-weight: 600;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-soft);
  position: sticky; top: 0;
}
.tbl tbody tr:hover { background: var(--bg-soft); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.mono { font-family: var(--font-mono); font-size: 12px; }

/* Tabs */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}
.tab {
  border: 0; background: transparent;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, color .12s;
}
.tab:hover { color: var(--ink-2); }
.tab--active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.tab__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: rgba(15,23,42,0.08);
  color: var(--ink-2);
  font-size: 10.5px; font-weight: 600;
  font-family: var(--font-mono);
}
.tab--active .tab__count { background: var(--indigo-50); color: var(--indigo-600); }

/* Quick utility */
.row { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: 12px; }
.h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; margin: 0; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
}

/* Code block */
.code-block {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  background: #0F172A;
  color: #E2E8F0;
  padding: 14px 16px;
  border-radius: 10px;
  overflow: auto;
  white-space: pre;
}
.code-block--light {
  background: var(--bg-soft);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
