:root {
    --brand: #5b4bd6;
    --brand-dark: #4536b0;
    --brand-2: #7c6cf0;
    --bg: #f4f5fb;
    --surface: #ffffff;
    --text: #1f2330;
    --muted: #7a8194;
    --border: #e6e8f0;
    --danger: #d64545;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(30, 34, 60, .08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: .4rem; border: 1px solid transparent; border-radius: 10px;
    padding: .6rem 1rem; font-size: .95rem; font-weight: 600;
    cursor: pointer; transition: .15s;
}
.btn--sm { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: #f0f1f8; }

/* ---------- Login (two columns) ---------- */
.auth-body { margin: 0; }
.auth-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }

.auth-brand {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff; padding: 2rem;
}
.auth-brand__inner { max-width: 380px; }
.auth-brand__logo { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; }
.auth-brand__tagline { font-size: 1.15rem; font-weight: 600; margin: .5rem 0 1.5rem; opacity: .95; }
.auth-brand__desc { line-height: 1.7; opacity: .85; }

.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-form__card { width: 100%; max-width: 360px; }
.auth-form__title { font-size: 1.6rem; margin: 0 0 .3rem; }
.auth-form__sub { color: var(--muted); margin: 0 0 1.5rem; }

.form__label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: .9rem 0 .35rem; }
.form__input {
    width: 100%; padding: .7rem .9rem; border: 1px solid var(--border);
    border-radius: 10px; font-size: 1rem; background: #fbfbfe;
}
.form__input:focus { outline: none; border-color: var(--brand); background: #fff; }
.form .btn { margin-top: 1.4rem; }

.alert { padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; }
.alert--error { background: #fdecec; color: var(--danger); border: 1px solid #f6c9c9; }

@media (max-width: 780px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-brand { min-height: 34vh; }
}

/* ---------- App shell ---------- */
.app-header {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
    gap: .8rem; height: 60px; padding: 0 1.2rem; background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.app-header__menu { display: none; font-size: 1.3rem; background: none; border: none; cursor: pointer; }
.app-header__brand { font-weight: 800; font-size: 1.2rem; color: var(--brand); }
.app-header__spacer { flex: 1; }
.app-header__user { display: flex; align-items: center; gap: .8rem; }
.app-header__user-name { color: var(--muted); font-size: .9rem; }

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 60px); }

.app-sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .8rem; }
.side-nav { display: flex; flex-direction: column; gap: .3rem; }
.side-nav__item {
    display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem;
    border-radius: 10px; color: var(--muted); font-weight: 600;
}
.side-nav__item:hover { background: #f0f1f8; color: var(--text); }
.side-nav__item.is-active { background: #ece9fb; color: var(--brand-dark); }
.side-nav__icon { font-size: 1.1rem; }

.app-content { padding: 1.6rem; }

/* ---------- Content pieces ---------- */
.page-head { margin-bottom: 1.2rem; }
.page-head__title { margin: 0; font-size: 1.5rem; }
.page-head__sub { margin: .3rem 0 0; color: var(--muted); }
.back-link { color: var(--muted); font-size: .9rem; }

.stats { display: flex; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.4rem; min-width: 150px; box-shadow: var(--shadow);
}
.stat-card__value { font-size: 2rem; font-weight: 800; color: var(--brand); }
.stat-card__label { color: var(--muted); font-size: .9rem; }

.apikey { margin-bottom: 1.2rem; font-size: .9rem; color: var(--muted); }
.apikey__hint { margin: .6rem 0 .4rem; }
.apikey__value { display: inline-block; background: #eceafb; color: var(--brand-dark);
    padding: .5rem .7rem; border-radius: 8px; word-break: break-all; }

.card { background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; margin-bottom: 1.2rem; }
.card__title { margin: 0 0 .8rem; font-size: 1.1rem; }
.empty { padding: 2.5rem; text-align: center; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr:hover { background: #fafaff; }
.nowrap { white-space: nowrap; }
.ta-center { text-align: center; }
.ta-right { text-align: right; }
.muted { color: var(--muted); font-size: .88rem; }
.preview { color: #4a4f5e; max-width: 340px; }

.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.badge--call { background: #e5f0ff; color: #2a63c0; }
.badge--mic { background: #eafaf0; color: #2a9d5a; }

.transcript-flow { display: flex; flex-direction: column; gap: .9rem; }
.segment { border-left: 3px solid var(--brand-2); padding: .3rem 0 .3rem .9rem; }
.segment__meta { display: flex; gap: .8rem; color: var(--muted); font-size: .8rem; margin-bottom: .2rem; }
.segment__seq { font-weight: 700; color: var(--brand); }
.segment__text { line-height: 1.6; }
.fulltext { line-height: 1.8; }

.dl-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    flex-wrap: wrap; background: #ece9fb; color: var(--brand-dark);
    padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1.2rem; font-weight: 600; }

.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem; margin-bottom: 1.2rem; }
.dl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.1rem; display: flex; flex-direction: column; gap: .5rem; }
.dl-card__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.dl-card__icon { width: 56px; height: 56px; border-radius: 14px; flex: 0 0 auto;
    box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.dl-card__titlewrap { display: flex; flex-direction: column; gap: .15rem; min-width: 0; margin-right: auto; }
.dl-card__title { font-weight: 700; font-size: 1.05rem; min-width: 0; }
.dl-card__ver { font-size: .78rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.dl-card__note { color: var(--muted); font-size: .88rem; margin: 0; }
.dl-card__changes { background: #f6f8fb; border: 1px solid var(--border); border-radius: 10px;
    padding: .55rem .7rem; }
.dl-card__changes-h { font-size: .76rem; font-weight: 700; color: #3a3f4e; margin-bottom: .3rem; }
.dl-card__changes ul { margin: 0; padding-left: 1.05rem; }
.dl-card__changes li { font-size: .82rem; color: #4a4f5e; line-height: 1.55; }
/* 설명 길이와 무관하게 크기/빌드/버튼을 카드 하단에 정렬 */
.dl-card__meta { font-size: .82rem; color: var(--muted); margin-top: auto; margin-bottom: .5rem; }
.dl-card__size { font-size: .85rem; color: var(--muted); }
.notice { background: #fff7e6; border: 1px solid #f2d492; color: #6b4e12; border-radius: 10px;
    padding: .7rem .9rem; font-size: .86rem; line-height: 1.55; margin-bottom: 1rem; }
.cat-group { margin-bottom: .7rem; }
.cat-group > b { display: block; font-size: .78rem; color: var(--muted); margin: .2rem 0 .4rem; }
.cat-group .btn { margin: 0 .35rem .4rem 0; padding: .42rem .7rem; font-size: .85rem; }
.agent-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: #1f2937; color: #fff; padding: .65rem 1.1rem; border-radius: 10px; font-size: .9rem;
    opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 2000; max-width: 86%;
    box-shadow: 0 6px 20px rgba(0,0,0,.3); text-align: center; }
.agent-toast.show { opacity: 1; }
.agent-toast.err { background: #b91c1c; }
.steps { margin: 0; padding-left: 1.2rem; line-height: 1.9; color: #4a4f5e; }

@media (max-width: 820px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar { position: fixed; top: 60px; bottom: 0; left: 0; width: 240px;
        transform: translateX(-100%); transition: .2s; z-index: 15; }
    .app-sidebar.is-open { transform: translateX(0); }
    .app-header__menu { display: block; }
}

/* 앱 로그 뷰어 */
.log-filter { display:flex; gap:.5rem; align-items:center; margin-bottom:1rem; flex-wrap:wrap; }
.log-filter select { padding:.4rem .6rem; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:inherit; }
.log-table { display:flex; flex-direction:column; gap:.4rem; }
.log-row { display:flex; gap:.6rem; background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:.6rem .8rem; }
.log-lvl { flex-shrink:0; font-size:.7rem; font-weight:700; padding:.15rem .45rem; border-radius:6px; height:fit-content; }
.log-lvl--err { background:#fdecec; color:#c0392b; }
.log-lvl--warn { background:#fff5e6; color:#b3730b; }
.log-lvl--info { background:#eef2f7; color:#5a6472; }
.log-body { min-width:0; flex:1; }
.log-meta { font-size:.72rem; color:var(--muted); margin-bottom:.2rem; }
.log-tag { font-family:monospace; }
.log-msg { font-size:.86rem; white-space:pre-wrap; word-break:break-word; }
.log-extra { font-size:.72rem; color:var(--muted); background:var(--bg,#f7f7f8); border-radius:6px; padding:.4rem .5rem; margin:.35rem 0 0; overflow-x:auto; white-space:pre-wrap; }
