.admin-body { min-height: 100vh; background: #eef3fb; }
.admin-login { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at top right, rgba(23,105,255,.18), transparent 38%), #f2f6fc; }
.login-card { width: min(440px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 26px; background: #fff; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 34px; }
.login-card h1 { margin: 10px 0 8px; color: var(--navy); font-size: 33px; line-height: 1.15; }
.login-card > p { margin: 0 0 24px; color: var(--muted); }
.login-card form { display: grid; gap: 15px; }
.form-error { margin: 0 !important; color: #c43c3c !important; font-size: 13px; }
.back-link { display: inline-block; margin-top: 22px; color: var(--blue); font-weight: 700; font-size: 14px; }

.admin-app { min-height: 100vh; display: grid; grid-template-columns: 360px 1fr; }
.admin-sidebar { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid #d8e1ee; background: #fff; }
.admin-sidebar-head { min-height: 78px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand-admin .brand-mark { width: 38px; height: 38px; font-size: 22px; }
.brand-admin .brand-name { font-size: 22px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; color: #54637b; background: #f8faff; cursor: pointer; }
.admin-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.admin-tab { min-height: 42px; border: 0; border-radius: 11px; color: #64728a; background: transparent; font-weight: 800; cursor: pointer; }
.admin-tab.active { color: var(--blue); background: #edf4ff; }
.visitor-panel { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.visitor-search { padding: 13px 14px; }
.visitor-list { min-height: 0; overflow-y: auto; }
.visitor-empty { padding: 30px 20px; text-align: center; color: var(--muted); }
.visitor-item { width: 100%; padding: 15px 18px; display: grid; grid-template-columns: 44px 1fr auto; gap: 11px; align-items: center; border: 0; border-top: 1px solid #eef2f7; color: inherit; background: #fff; text-align: left; cursor: pointer; }
.visitor-item:hover, .visitor-item.active { background: #f1f6ff; }
.visitor-avatar { position: relative; width: 44px; height: 44px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #1769ff, #6a4ce0); border-radius: 14px; font-weight: 900; }
.visitor-online { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: #b3bdcc; }
.visitor-online.online { background: #20bd74; }
.visitor-info { min-width: 0; }
.visitor-info strong { display: block; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visitor-info span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.visitor-meta { text-align: right; }
.visitor-meta time { display: block; color: #929daf; font-size: 10px; }
.unread-badge { min-width: 21px; height: 21px; margin-top: 6px; padding: 0 6px; display: inline-grid; place-items: center; color: #fff; background: var(--blue); border-radius: 999px; font-size: 10px; font-weight: 850; }

.admin-main { min-width: 0; min-height: 100vh; background: #f3f6fb; }
.admin-tab-content { display: none; min-height: 100vh; }
.admin-tab-content.active { display: block; }
.empty-chat { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-icon { width: 80px; height: 80px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 24px; background: #e5edfb; font-size: 35px; }
.empty-chat h2 { margin: 0; color: var(--navy); }
.empty-chat p { margin: 7px 0 0; }
.admin-chat { height: 100vh; display: flex; flex-direction: column; }
.admin-chat-header { min-height: 78px; padding: 14px 25px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: #fff; }
.admin-chat-header h2 { margin: 0; color: var(--navy); font-size: 21px; }
.admin-chat-header p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.connection-badge { padding: 6px 11px; border-radius: 999px; color: #68758b; background: #edf1f6; font-size: 12px; font-weight: 800; }
.connection-badge.online { color: #087e4a; background: #dcf8eb; }
.admin-messages { min-height: 0; flex: 1; overflow-y: auto; padding: 26px; background: #f3f6fb; }
.admin-message { max-width: 690px; margin-bottom: 14px; }
.admin-message.admin { margin-left: auto; }
.admin-message-bubble { padding: 12px 15px; border: 1px solid #e1e7f0; border-radius: 16px; color: #2f405d; background: #fff; box-shadow: 0 4px 12px rgba(27,47,77,.05); white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-message.admin .admin-message-bubble { color: #fff; background: var(--blue); border-color: var(--blue); border-bottom-right-radius: 5px; }
.admin-message.user .admin-message-bubble { border-bottom-left-radius: 5px; }
.admin-message-meta { margin-top: 5px; color: #8b96a8; font-size: 10px; }
.admin-message.admin .admin-message-meta { text-align: right; }
.admin-compose { padding: 16px 20px; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; border-top: 1px solid var(--line); background: #fff; }
.admin-compose textarea { min-height: 55px; max-height: 130px; resize: none; }

.settings-wrap { max-width: 1050px; margin: 0 auto; padding: 55px 32px 80px; }
.settings-heading h1 { margin: 8px 0; color: var(--navy); font-size: 38px; }
.settings-heading p { margin: 0 0 32px; color: var(--muted); }
.settings-form { display: grid; gap: 20px; }
.settings-card { padding: 25px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 7px 20px rgba(25,46,80,.05); }
.settings-card h2 { margin: 0 0 20px; color: var(--navy); }
.settings-card-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.settings-card-head span { color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field-full { grid-column: 1 / -1; }
.module-settings { display: grid; gap: 14px; }
.module-setting-row { padding: 17px; display: grid; grid-template-columns: 1.1fr 1.8fr 140px; gap: 13px; align-items: end; border: 1px solid #e5eaf2; border-radius: 15px; background: #f9fbfe; }
.module-setting-row select { min-height: 47px; padding: 0 12px; }
.settings-actions { display: flex; align-items: center; justify-content: flex-end; gap: 20px; }
#settings-message { color: #168454; font-weight: 700; font-size: 13px; }

@media (max-width: 900px) {
  .admin-app { grid-template-columns: 300px 1fr; }
  .module-setting-row { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .admin-app { display: block; }
  .admin-sidebar { height: 43vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-main { min-height: 57vh; }
  .admin-chat { height: 57vh; }
  .empty-chat { min-height: 57vh; }
  .admin-tab-content { min-height: 57vh; }
  .admin-compose { grid-template-columns: 1fr; }
  .settings-wrap { padding: 32px 16px 60px; }
  .form-grid { grid-template-columns: 1fr; }
}
