:root {
    --ink: #111827;
    --muted: #64748b;
    --line: #e5e7eb;
    --surface: #ffffff;
    --canvas: #f5f7fb;
    --primary: #6d5dfc;
    --primary-dark: #5545e8;
    --accent: #b7f34a;
    --danger: #e5484d;
    --success: #1f9d68;
    --shadow: 0 18px 60px rgba(15, 23, 42, .09);
    --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.eyebrow { margin: 0 0 7px; font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--primary); }
.muted { color: var(--muted); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 17px; background: var(--accent); color: #17210b; font-size: 24px; font-weight: 900; box-shadow: 0 8px 20px rgba(183, 243, 74, .25); }
.brand-mark.small { width: 36px; height: 36px; border-radius: 11px; font-size: 17px; }

.button { border: 0; border-radius: 12px; padding: 11px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; cursor: pointer; transition: transform .18s, box-shadow .18s, background .18s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { color: #fff; background: var(--primary); box-shadow: 0 10px 25px rgba(109, 93, 252, .22); }
.button.primary:hover:not(:disabled) { background: var(--primary-dark); }
.button.secondary { background: #edeaff; color: #4e3ee0; }
.button.light { background: #fff; color: #172033; box-shadow: 0 14px 36px rgba(0, 0, 0, .2); }
.button.danger { color: #b4232a; background: #feecee; }
.button.ghost { background: transparent; color: #475569; border: 1px solid var(--line); }
.button.compact { padding: 8px 12px; font-size: 13px; }
.button.large { padding: 15px 24px; border-radius: 15px; font-size: 16px; }
.button.full { width: 100%; }
.text-button { border: 0; padding: 5px; color: #8b95a7; background: none; cursor: pointer; }
.text-link { display: inline-block; margin-top: 22px; font-size: 13px; font-weight: 600; color: var(--primary); }
.icon-link { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }

input, textarea, select { width: 100%; border: 1px solid #dbe0e8; border-radius: 12px; padding: 11px 13px; color: var(--ink); background: #fff; outline: none; transition: border .18s, box-shadow .18s; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(109, 93, 252, .1); }
label { display: grid; gap: 7px; color: #475569; font-size: 13px; font-weight: 700; }
.stack-form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.alert { border-radius: 11px; padding: 11px 13px; margin: 14px 0; font-size: 13px; }
.alert-error { background: #fff0f1; color: #a1252b; }

/* Login */
.login-page { background: radial-gradient(circle at 10% 5%, #dcd7ff 0, transparent 32%), radial-gradient(circle at 90% 90%, #e9ffc4 0, transparent 32%), #f6f7fb; }
.login-shell { min-height: 100vh; padding: 28px; display: grid; place-items: center; }
.login-card { width: min(420px, 100%); padding: 42px; border: 1px solid rgba(255,255,255,.8); border-radius: 28px; background: rgba(255,255,255,.86); backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.login-card h1 { margin: 10px 0 8px; font-size: 29px; letter-spacing: -.03em; }

/* Main conversation */
.app-shell { min-height: 100vh; padding: 18px; }
.topbar { height: 60px; max-width: 1500px; margin: 0 auto 16px; display: flex; align-items: center; justify-content: space-between; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.connection-pill, .engine-chip { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 9px 13px; font-size: 12px; background: #fff; border: 1px solid var(--line); }
.connection-pill > span, .engine-chip > span { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
.connection-pill.online > span, .engine-chip.online > span { background: #20c477; box-shadow: 0 0 0 5px rgba(32,196,119,.12); }
.connection-pill.online { color: #15764c; }
.connection-pill.connecting > span, .engine-chip.loading > span { background: #f2a93b; animation: pulse 1s infinite; }
.conversation-layout { max-width: 1500px; height: calc(100vh - 94px); min-height: 620px; margin: auto; display: grid; grid-template-columns: minmax(340px, .8fr) minmax(580px, 1.2fr); gap: 16px; }
.chat-panel, .avatar-panel { min-width: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.chat-panel { background: #fff; display: grid; grid-template-rows: auto 1fr auto; }
.panel-heading { padding: 23px 24px 18px; border-bottom: 1px solid #edf0f4; display: flex; align-items: center; justify-content: space-between; }
.panel-heading h1 { margin: 0; font-size: 23px; letter-spacing: -.035em; }
.messages { min-height: 0; overflow-y: auto; padding: 22px 22px 12px; scroll-behavior: smooth; }
.empty-chat { height: 100%; display: grid; align-content: center; justify-items: center; text-align: center; color: #8792a4; padding: 30px; }
.empty-chat h3 { color: #344054; margin: 12px 0 5px; }
.empty-chat p { margin: 0; font-size: 13px; }
.empty-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; background: #f0eeff; color: var(--primary); font-size: 22px; }
.message { max-width: 84%; margin-bottom: 13px; animation: slide-up .25s ease; }
.message.user { margin-left: auto; }
.message .who { margin: 0 8px 5px; font-size: 10px; font-weight: 800; color: #8b95a7; letter-spacing: .08em; text-transform: uppercase; }
.message.user .who { text-align: right; }
.message .bubble { padding: 12px 14px; border-radius: 15px 15px 15px 4px; background: #f1f3f7; color: #283548; line-height: 1.5; font-size: 14px; white-space: pre-wrap; }
.message.user .bubble { background: var(--primary); color: #fff; border-radius: 15px 15px 4px 15px; }
.composer { margin: 14px; border: 1px solid #dfe4ec; border-radius: 16px; padding: 10px; background: #fafbfc; }
.composer textarea { min-height: 48px; max-height: 130px; padding: 7px 8px; border: 0; box-shadow: none; background: transparent; resize: none; }
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.round-button { width: 40px; height: 40px; border-radius: 12px; border: 0; background: #feecee; color: var(--danger); font-weight: 900; cursor: pointer; }
.round-button:disabled { opacity: .4; cursor: not-allowed; }
.avatar-panel { background: #101522; display: grid; grid-template-rows: 1fr auto; }
.video-stage { min-height: 0; position: relative; overflow: hidden; background: radial-gradient(circle at 50% 25%, #27304c, #0a0f1a 70%); }
.video-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.video-stage .idle-video { opacity: 1; }
.video-stage .speech-video { z-index: 1; opacity: 0; transition: opacity .06s linear; }
.video-stage .fallback-canvas { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; pointer-events: none; transition: opacity .06s linear; }
.video-stage.has-poster:not(.video-ready) .speech-video:not([src]) { opacity: .42; }
.video-stage.video-ready .speech-video.is-active { opacity: 1; }
.video-stage.fallback-active .speech-video { opacity: 0; }
.video-stage.fallback-active .fallback-canvas { opacity: 1; }
.video-stage.audio-speaking .idle-video { filter: saturate(1.04) brightness(1.02); }
.video-stage.audio-speaking.has-poster .speech-video:not([src]) { opacity: .52; }
.video-gradient { pointer-events: none; position: absolute; z-index: 2; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.25), transparent 25%, transparent 62%, rgba(0,0,0,.75)); }
.avatar-meta { position: absolute; z-index: 4; top: 20px; left: 20px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; color: #fff; background: rgba(11,16,29,.58); backdrop-filter: blur(10px); font-size: 12px; font-weight: 700; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #39d98a; }
.start-overlay { position: absolute; z-index: 10; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 30px; color: #fff; background: radial-gradient(circle at center, rgba(29,39,67,.3), rgba(8,12,22,.72)); transition: opacity .35s, visibility .35s; }
.start-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.start-overlay h2 { margin: 16px 0 6px; font-size: 28px; }
.start-overlay p { margin: 0 0 22px; color: #aeb8ca; }
.start-loading { display: none; place-items: center; gap: 12px; min-width: min(360px, 80vw); }
.start-loading b { font-size: 17px; }
.start-loading small { color: #aeb8ca; font-size: 12px; }
.start-overlay.loading > :not(.start-loading) { display: none; }
.start-overlay.loading .start-loading { display: grid; }
.avatar-placeholder { width: 92px; height: 92px; display: grid; place-items: center; border-radius: 29px; background: linear-gradient(145deg, var(--primary), #8e7eff); color: #fff; font-size: 38px; font-weight: 900; box-shadow: 0 22px 55px rgba(109,93,252,.35); }
.subtitle { position: absolute; z-index: 4; left: 8%; right: 8%; bottom: 42px; max-height: 30%; overflow: hidden; color: #fff; text-align: center; font-size: clamp(17px, 2vw, 27px); line-height: 1.4; font-weight: 700; text-shadow: 0 3px 12px #000; opacity: 0; transition: opacity .16s linear; pointer-events: none; }
.subtitle.show { opacity: 1; }
.speaking-state { display: none; position: absolute; z-index: 4; top: 20px; right: 20px; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 999px; background: var(--accent); color: #1c260b; font-size: 12px; }
.speaking-state.active { display: flex; }
.rendering-state { display: none; position: absolute; z-index: 4; inset: 0; place-content: center; justify-items: center; gap: 12px; color: #fff; background: rgba(8,12,22,.62); backdrop-filter: blur(3px); }
.rendering-state.active { display: grid; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.25); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.sound-bars { height: 16px; display: flex; align-items: center; gap: 2px; }
.sound-bars i { width: 2px; height: 6px; border-radius: 2px; background: currentColor; animation: sound .75s ease-in-out infinite alternate; }
.sound-bars i:nth-child(2) { animation-delay: .15s; }
.sound-bars i:nth-child(3) { animation-delay: .3s; }
.sound-bars i:nth-child(4) { animation-delay: .45s; }
.video-toolbar { min-height: 68px; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: #0a0f1a; border-top: 1px solid #222a3a; }
.video-toolbar > div { display: grid; gap: 3px; }
.status-label { font-size: 9px; letter-spacing: .13em; color: #7f899b; font-weight: 800; }
.video-toolbar strong { font-size: 12px; color: #d8deea; }

/* Admin */
.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; color: #d8deeb; background: #111725; display: grid; grid-template-rows: auto 1fr auto; }
.sidebar-brand { padding: 0 8px 28px; color: #fff; }
.side-nav { display: grid; align-content: start; gap: 7px; }
.nav-item { width: 100%; padding: 12px 14px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 12px; color: #9ca8bc; background: transparent; text-align: left; font-weight: 700; cursor: pointer; }
.nav-item span { width: 22px; text-align: center; font-size: 18px; }
.nav-item:hover { color: #fff; background: #1a2232; }
.nav-item.active { color: #fff; background: var(--primary); box-shadow: 0 10px 30px rgba(109,93,252,.25); }
.sidebar-footer { display: grid; gap: 14px; text-align: center; }
.sidebar .button.ghost { color: #c6cede; border-color: #30394a; }
.admin-content { min-width: 0; padding: 32px clamp(24px, 4vw, 56px) 60px; }
.admin-header { min-height: 74px; display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 25px; }
.admin-header h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.admin-section { display: none; }
.admin-section.active { display: block; animation: fade .22s ease; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card, .content-card { border: 1px solid #e6e9ef; border-radius: 18px; background: #fff; box-shadow: 0 8px 30px rgba(15,23,42,.045); }
.stat-card { min-width: 0; padding: 19px; display: grid; gap: 6px; }
.stat-card span, .stat-card small { color: var(--muted); font-size: 11px; }
.stat-card strong { font-size: 30px; letter-spacing: -.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .small-value { font-size: 19px; }
.content-card { padding: 23px; }
.welcome-preview { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 30px; background: linear-gradient(115deg, #fff, #f1efff); }
.welcome-preview h2, .card-heading h2, .section-title-row h2 { margin: 0 0 5px; font-size: 20px; }
.welcome-preview p:last-child { margin-bottom: 0; }
.section-grid { display: grid; grid-template-columns: minmax(310px, .7fr) minmax(450px, 1.3fr); gap: 22px; align-items: start; }
.section-title-row, .card-heading { margin-bottom: 17px; display: flex; align-items: center; justify-content: space-between; }
.asset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.asset-card { min-width: 0; padding: 17px; border: 1px solid #e2e6ed; border-radius: 16px; background: #fff; }
.asset-card.default { border-color: #8a7dff; box-shadow: 0 0 0 3px rgba(109,93,252,.09); }
.asset-preview { height: 150px; margin: -17px -17px 15px; overflow: hidden; display: grid; place-items: center; border-radius: 16px 16px 0 0; background: #151b29; }
.asset-preview img { width: 100%; height: 100%; object-fit: cover; }
.asset-preview .asset-avatar { width: 62px; height: 62px; font-size: 24px; }
.asset-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.asset-avatar { width: 46px; height: 46px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #7c6efc, #5445df); font-size: 18px; font-weight: 900; }
.asset-title { min-width: 0; flex: 1; }
.asset-title h3 { margin: 2px 0 4px; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-title p { margin: 0; color: var(--muted); font-size: 11px; }
.badge { padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.badge.success { color: #14764d; background: #e2f8ed; }
.badge.warning { color: #976013; background: #fff2d7; }
.badge.error { color: #a72d35; background: #ffe4e6; }
.badge.primary { color: #4d3cdc; background: #ebe8ff; }
.progress { height: 6px; margin: 14px 0 5px; overflow: hidden; border-radius: 999px; background: #edf0f4; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.asset-actions { margin-top: 14px; display: flex; gap: 7px; flex-wrap: wrap; }
.loading-card { padding: 35px; border: 1px dashed #d3d8e1; border-radius: 16px; color: var(--muted); text-align: center; }
.audio-list { display: grid; gap: 11px; }
.audio-item { padding: 15px; display: grid; grid-template-columns: 1fr minmax(140px, 220px) auto; align-items: center; gap: 15px; border: 1px solid #e2e6ed; border-radius: 15px; background: #fff; }
.audio-item h3 { margin: 0 0 4px; font-size: 14px; }
.audio-item p { margin: 0; color: var(--muted); font-size: 11px; }
.audio-item audio { width: 100%; height: 34px; }
.audio-actions { display: flex; gap: 6px; }
.settings-card { max-width: 820px; }
.switch-row { grid-template-columns: auto 1fr; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch-row span { display: grid; gap: 3px; }
.switch-row small { color: var(--muted); font-weight: 500; }
.compact-switch { padding: 10px 14px; }
.stack-column { display: grid; align-content: start; gap: 18px; }
.management-list { display: grid; gap: 10px; }
.management-list:not(:empty) { margin-top: 12px; }
.management-item { display: grid; gap: 8px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; background: #fafbfe; }
.management-item.inactive { opacity: .62; }
.management-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.management-item h3 { margin: 0; font-size: 14px; }
.management-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; white-space: pre-line; }
.management-item .asset-actions { margin-top: 2px; }
.management-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.management-meta span { padding: 3px 7px; border-radius: 999px; color: #5146bc; background: #efedff; font-size: 10px; font-weight: 800; }
.compact-list { max-height: 420px; overflow: auto; }
.avatar-profile-editor { max-width: 820px; margin-top: 22px; }
.company-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.company-card { display: grid; gap: 14px; }
.company-card h2 { margin: 4px 0 0; }
.company-card > p { margin: 0; line-height: 1.6; }
.integration-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.integration-card { display: grid; align-content: start; gap: 14px; }
.integration-card h2 { margin: 4px 0 0; }
.integration-card > p { margin: 0; line-height: 1.55; }
.integration-card > .button { margin-top: auto; }
.integration-editor-grid { grid-template-columns: minmax(320px, .82fr) minmax(380px, 1.18fr); margin-top: 18px; }
.integration-preview-card { min-width: 0; }
.integration-preview-card iframe { display: block; width: min(420px, 100%); height: 620px; margin: 0 auto; border: 0; border-radius: 18px; background: #101522; box-shadow: 0 15px 45px rgba(15,23,42,.18); }
.integration-preview-empty { min-height: 300px; display: grid; place-items: center; padding: 28px; border: 1px dashed #d3d8e1; border-radius: 16px; color: var(--muted); text-align: center; }
#integrationCodePanel { display: grid; gap: 12px; }
#integrationCodePanel textarea { color: #dce5f4; background: #111827; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
#integrationCodePanel code { font-size: 11px; }
.integration-copy { justify-self: start; margin-top: -5px; }
.company-action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.company-action-card { min-height: 210px; padding: 28px; display: grid; align-content: center; justify-items: start; gap: 10px; border: 1px solid #ded9ff; border-radius: 18px; color: var(--text); background: linear-gradient(145deg, #fff, #f3f1ff); text-align: left; cursor: pointer; box-shadow: 0 8px 30px rgba(15,23,42,.045); }
.company-action-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.company-action-card span { font-size: 32px; color: var(--primary); }
.company-action-card b { font-size: 20px; }
.company-action-card small { max-width: 420px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.knowledge-detail-heading { padding: 18px 20px; border: 1px solid #ded9ff; border-radius: 16px; background: linear-gradient(115deg, #fff, #f1efff); }
.knowledge-detail-title { min-width: 0; flex: 1; text-align: right; }
.knowledge-detail-title p { margin: 0; }
.admin-section [hidden] { display: none !important; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
summary { cursor: pointer; font-size: 13px; font-weight: 700; }
.detail-fields { margin-top: 13px; }
.form-help { margin: -4px 0 0; font-size: 12px; line-height: 1.5; }
.live-note { margin: 0; color: #4d3cdc; background: #f0eeff; line-height: 1.55; }
.live-control-card h2 { margin: 2px 0 8px; }
.mic-meter { height: 12px; margin: 24px 0; overflow: hidden; border-radius: 999px; background: #edf0f4; }
.mic-meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6d5dfc, #b7f34a); transition: width .12s linear; }
.live-detail-list { display: grid; gap: 0; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.live-detail-list > div { padding: 13px 14px; display: flex; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.live-detail-list > div:last-child { border-bottom: 0; }
.live-detail-list span { color: var(--muted); font-size: 12px; }
.live-detail-list strong { max-width: 60%; overflow: hidden; text-overflow: ellipsis; font-size: 12px; white-space: nowrap; }

.monitoring-stat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.monitoring-stat-grid .stat-card { padding: 17px; }
.monitoring-stat-grid .stat-card strong { font-size: 27px; }
.monitoring-stat-grid .stat-card .small-value { font-size: 16px; }
.monitoring-grid { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(420px, 1.28fr); gap: 18px; margin-top: 18px; align-items: start; }
.monitoring-grid.lower { grid-template-columns: minmax(300px, .8fr) minmax(460px, 1.2fr); }
.gpu-monitor-card { background: linear-gradient(145deg, #111827, #1d2740); color: #fff; border-color: #27334e; }
.gpu-monitor-card .muted { color: #9da9bd; }
.resource-meter { display: grid; gap: 8px; margin-top: 20px; }
.resource-meter > div:first-child { display: flex; justify-content: space-between; gap: 15px; font-size: 12px; }
.resource-track { height: 11px; overflow: hidden; border-radius: 999px; background: #303b51; }
.resource-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7668ff, #a99fff); transition: width .35s ease; }
.resource-track.memory span { background: linear-gradient(90deg, #39c68d, #b7f34a); }
.monitor-note { margin: 20px 0 0; font-size: 11px; line-height: 1.5; }
.monitor-list { display: grid; gap: 10px; }
.monitor-item { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fafbfe; }
.monitor-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.monitor-item-head > div, .monitor-device-body { min-width: 0; display: grid; gap: 3px; }
.monitor-item b { font-size: 13px; }
.monitor-item small { color: var(--muted); font-size: 10px; }
.monitor-item > p { margin: 10px 0; color: #4b5568; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.monitor-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.monitor-meta span { padding: 3px 7px; border-radius: 999px; color: #5146bc; background: #efedff; font-size: 9px; font-weight: 800; }
.monitor-empty { padding: 28px 16px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); text-align: center; font-size: 12px; }
.device-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; }
.monitor-device-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: #fff; background: #202a3d; font-size: 18px; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #25bd7b; box-shadow: 0 0 0 4px rgba(37,189,123,.12); }
.history-list { max-height: 680px; padding-right: 3px; overflow: auto; }
.history-preview { font-weight: 600; }
.conversation-open { margin-top: 11px; }
.conversation-detail { display: grid; gap: 8px; max-height: 420px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); overflow: auto; }
.history-message { max-width: 88%; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.history-message.user { justify-self: end; color: #fff; background: #6758ee; border-color: #6758ee; }
.history-message span { display: block; margin-bottom: 4px; color: #6d5dfc; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.history-message.user span, .history-message.user small { color: #ddd9ff; }
.history-message p { margin: 0 0 5px; font-size: 12px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.history-message small { display: block; text-align: right; }

.toast-stack { position: fixed; z-index: 1000; right: 22px; top: 22px; display: grid; gap: 9px; }
.toast { max-width: 370px; padding: 12px 16px; border-radius: 12px; color: #fff; background: #202938; box-shadow: 0 15px 40px rgba(0,0,0,.2); font-size: 13px; animation: toast-in .25s ease; }
.toast.success { background: #16865a; }
.toast.error { background: #bd343b; }

@keyframes pulse { 50% { opacity: .4; } }
@keyframes sound { to { height: 15px; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(7px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(15px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes avatar-speaking { to { transform: scale(1.018); filter: saturate(1.06) brightness(1.03); } }

@media (max-width: 1050px) {
    .monitoring-stat-grid { grid-template-columns: repeat(3, 1fr); }
    .monitoring-grid, .monitoring-grid.lower { grid-template-columns: 1fr; }
    .conversation-layout { grid-template-columns: minmax(320px, .85fr) minmax(440px, 1.15fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .section-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .app-shell { padding: 10px; }
    .topbar { height: 54px; margin-bottom: 10px; }
    .conversation-layout { height: auto; min-height: 0; display: flex; flex-direction: column-reverse; }
    .avatar-panel { height: min(70vh, 600px); min-height: 480px; }
    .chat-panel { min-height: 620px; }
    .connection-pill b { display: none; }
    .admin-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 14px; display: block; }
    .sidebar-brand { padding: 0 4px 14px; }
    .side-nav { display: flex; overflow-x: auto; }
    .nav-item { min-width: max-content; }
    .sidebar-footer { display: none; }
    .admin-content { padding: 22px 14px 45px; }
    .asset-grid { grid-template-columns: 1fr; }
    .company-grid, .company-action-grid { grid-template-columns: 1fr; }
    .integration-grid { grid-template-columns: 1fr; }
    .integration-preview-card iframe { height: min(70vh, 620px); }
    .audio-item { grid-template-columns: 1fr; }
    .knowledge-detail-heading { align-items: flex-start; flex-direction: column; }
    .knowledge-detail-title { text-align: left; }
}

@media (max-width: 520px) {
    .form-row, .stat-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 22px; }
    .avatar-panel { min-height: 440px; }
    .subtitle { left: 5%; right: 5%; bottom: 34px; max-height: 26%; font-size: clamp(15px, 4.3vw, 20px); }
}
