/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 15px; color: #1a1a2e; background: #f4f6fb; }
a { text-decoration: none; color: inherit; }

/* ===== VARIABLES ===== */
:root {
  --primary: #e63946;
  --primary-dark: #c1121f;
  --sidebar-w: 240px;
  --top-h: 60px;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e8eaf0;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

/* ===== LOGIN PAGE ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #e63946 100%); }
.login-container { background: white; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 32px; }
.logo-circle { width: 72px; height: 72px; border-radius: 50%; background: var(--primary); color: white; font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.logo-circle.small { width: 36px; height: 36px; font-size: 13px; flex-shrink: 0; }
.login-logo h1 { font-size: 24px; font-weight: 800; color: var(--text); }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.login-form input { width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: 10px; font-size: 15px; transition: border-color .2s; outline: none; }
.login-form input:focus { border-color: var(--primary); }
.error-msg { background: #fee2e2; color: var(--danger); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* ===== BUTTONS ===== */
.btn { padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f3f4f6; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
.btn-logout { background: transparent; color: #aaa; border: 1px solid #333; font-size: 12px; padding: 7px 14px; width: 100%; justify-content: center; }
.btn-logout:hover { background: #ff4444; color: white; border-color: #ff4444; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-page { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: #1a1a2e; color: white; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform .3s; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-header span { font-weight: 700; font-size: 16px; flex: 1; }
.sidebar-close { background: none; border: none; color: #aaa; cursor: pointer; font-size: 16px; display: none; }
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: rgba(255,255,255,.7); font-size: 14px; font-weight: 500; transition: all .15s; cursor: pointer; }
.nav-item:hover { background: rgba(255,255,255,.08); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.user-info { font-size: 12px; color: rgba(255,255,255,.5); margin-bottom: 10px; }
.user-info strong { display: block; color: rgba(255,255,255,.9); font-size: 14px; }

/* Main wrapper */
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* Top bar */
.top-bar { height: var(--top-h); background: white; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 50; }
.menu-toggle { background: none; border: none; font-size: 20px; cursor: pointer; display: none; }
.page-title { font-size: 18px; font-weight: 700; flex: 1; }
.bot-status-badge { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 20px; background: #f3f4f6; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; }
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--danger); }

/* Main content */
.main-content { flex: 1; padding: 28px 24px; }
.section { display: none; }
.section.active { display: block; }

/* ===== CARDS & STATS ===== */
.welcome-card { background: linear-gradient(135deg, #1a1a2e, #e63946); color: white; border-radius: 16px; padding: 32px; margin-bottom: 24px; }
.welcome-card h2 { font-size: 22px; margin-bottom: 8px; }
.welcome-card p { opacity: .85; font-size: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.stat-icon { font-size: 32px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text); margin-top: 2px; }

/* Quick actions */
.quick-actions h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.action-card { background: white; border: 2px solid var(--border); border-radius: 12px; padding: 20px 16px; text-align: center; cursor: pointer; transition: all .15s; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.action-card:hover { border-color: var(--primary); background: #fff5f5; color: var(--primary); }
.action-card span:first-child { font-size: 28px; }

/* ===== SECTION HEADERS ===== */
.section-header { margin-bottom: 24px; }
.section-header h2 { font-size: 20px; font-weight: 700; }
.section-header p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.section-header-row { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.section-header-row h2 { font-size: 20px; font-weight: 700; }
.section-header-row p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ===== CHATBOT SECTIONS ===== */
.chatbot-sections { display: flex; flex-direction: column; gap: 16px; }
.chatbot-card { background: white; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.chatbot-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: #f8f9fc; border-bottom: 1px solid var(--border); cursor: pointer; }
.chatbot-card-header h3 { font-size: 14px; font-weight: 700; }
.chatbot-card-body { padding: 20px; display: none; }
.chatbot-card.open .chatbot-card-body { display: block; }
.chatbot-card-header .toggle-icon { font-size: 12px; color: var(--text-muted); transition: transform .2s; }
.chatbot-card.open .toggle-icon { transform: rotate(180deg); }
.chatbot-card textarea { width: 100%; min-height: 160px; border: 2px solid var(--border); border-radius: 8px; padding: 12px; font-size: 13px; font-family: inherit; resize: vertical; outline: none; transition: border-color .2s; }
.chatbot-card textarea:focus { border-color: var(--primary); }
.chatbot-card-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.save-status { font-size: 12px; color: var(--success); }
.save-status.error { color: var(--danger); }

/* ===== PRODUCTS ===== */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.product-card { background: white; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; transition: box-shadow .15s; }
.product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.product-img { width: 100%; height: 160px; object-fit: cover; background: #f3f4f6; display: flex; align-items: center; justify-content: center; font-size: 40px; color: #ccc; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-info { padding: 14px 16px; }
.product-name { font-weight: 700; font-size: 15px; }
.product-cat { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin: 2px 0 6px; }
.product-price { font-size: 16px; font-weight: 800; color: var(--primary); }
.product-desc { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.product-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.product-inactive { opacity: .5; }
.product-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-left: 6px; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.img-url-copy { font-size: 11px; color: var(--primary); cursor: pointer; text-decoration: underline; }

/* ===== SETTINGS ===== */
.settings-form { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 24px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 24px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group small { font-size: 11px; color: var(--text-muted); }
.form-group input, .form-group textarea, .form-group select { padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; transition: border-color .2s; }
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-actions { display: flex; align-items: center; gap: 16px; border-top: 1px solid var(--border); padding-top: 20px; }

/* ===== INTEGRATIONS ===== */
.integration-card { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 24px; margin-bottom: 20px; }
.integration-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.integration-icon { font-size: 32px; }
.integration-header h3 { font-size: 16px; font-weight: 700; }
.integration-header p { font-size: 13px; color: var(--text-muted); }
.integration-status { margin-left: auto; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 20px; background: #f3f4f6; color: var(--text-muted); }
.integration-status.connected { background: #d1fae5; color: #065f46; }
.integration-steps { display: flex; flex-direction: column; gap: 20px; }
.step { display: flex; gap: 16px; }
.step-number { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: white; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }
.step-content strong { display: block; font-size: 14px; margin-bottom: 6px; }
.step-content p { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.step-content a { color: var(--primary); }
.wa-form { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.code-block { background: #1a1a2e; color: #7ee787; font-family: monospace; font-size: 13px; padding: 12px 16px; border-radius: 8px; margin: 8px 0; word-break: break-all; }
.hint { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* ===== REQUESTS ===== */
.requests-list { display: flex; flex-direction: column; gap: 12px; }
.request-item { background: white; border-radius: 12px; border: 1px solid var(--border); padding: 16px 20px; display: flex; align-items: flex-start; gap: 16px; }
.request-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 3px 10px; border-radius: 20px; background: #ede9fe; color: #5b21b6; white-space: nowrap; }
.request-body { flex: 1; }
.request-title { font-weight: 700; font-size: 14px; }
.request-desc { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.request-meta { font-size: 11px; color: #aaa; margin-top: 6px; }
.status-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-in_progress { background: #dbeafe; color: #1e40af; }
.status-done { background: #d1fae5; color: #065f46; }

/* ===== USERS ===== */
.users-list { display: flex; flex-direction: column; gap: 10px; }
.user-item { background: white; border-radius: 10px; border: 1px solid var(--border); padding: 14px 20px; display: flex; align-items: center; gap: 16px; }
.user-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: white; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.user-details { flex: 1; }
.user-name { font-weight: 700; font-size: 14px; }
.user-username { font-size: 12px; color: var(--text-muted); }
.role-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.role-admin { background: #fee2e2; color: #991b1b; }
.role-staff { background: #dbeafe; color: #1e40af; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: white; border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 24px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--border); }
.image-preview { width: 100%; max-height: 200px; object-fit: cover; border-radius: 8px; margin-top: 8px; border: 2px solid var(--border); }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1a1a2e; color: white; padding: 14px 20px; border-radius: 10px; font-size: 14px; z-index: 300; box-shadow: 0 4px 20px rgba(0,0,0,.3); animation: slideUp .2s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== LOADING & EMPTY ===== */
.loading { color: var(--text-muted); font-size: 14px; padding: 40px; text-align: center; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: block; }
  .main-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .actions-grid { grid-template-columns: 1fr 1fr; }
  .products-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .conv-messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 80px; }
  .conv-input-area { position: fixed; bottom: 0; left: 0; right: 0; z-index: 201; background: #1e1e2e !important; padding: 10px 12px; }
  .conv-back-btn { background: none; border: none; color: #6366f1; font-size: 22px; cursor: pointer; padding: 4px 8px; display: flex; align-items: center; }
}

/* ===== CONVERSATIONS ===== */
.conv-layout { display: flex; height: calc(100vh - 180px); min-height: 500px; background: white; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.conv-list { width: 300px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.conv-list-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: space-between; background: #f8f9fc; }
.conv-list-items { flex: 1; overflow-y: auto; }
.conv-item { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.conv-item:hover { background: #f8f9fc; }
.conv-item.active { background: #fff0f0; border-left: 3px solid var(--primary); }
.conv-item.paused { background: #fef3c7; }
.conv-item.unread { background: #f0f4ff; border-left: 3px solid #3b82f6; }
.conv-item.unread .conv-name { color: #1d4ed8; }
.conv-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.conv-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.conv-time { font-size: 11px; color: var(--text-muted); }
.conv-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-paused-badge { font-size: 10px; font-weight: 700; background: #f59e0b; color: white; padding: 2px 7px; border-radius: 20px; }
.unread-dot { display: inline-block; width: 8px; height: 8px; background: #3b82f6; border-radius: 50%; flex-shrink: 0; }

.conv-window { flex: 1; display: flex; flex-direction: column; }
.conv-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); font-size: 14px; gap: 12px; }
.conv-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; background: #f8f9fc; flex-shrink: 0; }
.conv-header-name { font-weight: 700; font-size: 15px; flex: 1; }
.conv-header-id { font-size: 11px; color: var(--text-muted); }
.conv-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.msg-user { background: #f3f4f6; color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg-bot { background: #e63946; color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-advisor { background: #1a1a2e; color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-meta { font-size: 10px; opacity: .7; margin-top: 4px; }
.conv-input-area { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; background: white; flex-shrink: 0; }
.conv-input-area.paused-mode { background: #fff8e1; border-top: 2px solid #f59e0b; }
.conv-input-area.bot-mode { background: #f8f9fc; }
.conv-textarea { flex: 1; border: 2px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 13px; font-family: inherit; resize: none; outline: none; min-height: 42px; max-height: 120px; transition: border-color .2s; }
.conv-textarea:focus { border-color: var(--primary); }
.conv-status-bar { padding: 8px 16px; font-size: 12px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); background: #f8f9fc; }
.conv-status-bar.paused { background: #fef3c7; }

.nav-badge { background: var(--primary); color: white; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 20px; margin-left: 6px; }

/* ===== CATALOG SECTION ===== */
.catalog-stats { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.cstat { background: white; border-radius: 10px; padding: 14px 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.06); min-width: 90px; }
.cstat span { font-size: 24px; font-weight: 800; }
.cstat small { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.cstat-ok span { color: var(--success); }
.cstat-warn span { color: var(--warning); }
.cstat-danger span { color: var(--danger); }

.catalog-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { padding: 9px 14px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border-color .15s; }
.search-input:focus { border-color: var(--primary); }
.filter-select { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; background: white; cursor: pointer; outline: none; }

.catalog-table-wrap { overflow-x: auto; background: white; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.catalog-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.catalog-table thead th { background: #f8f9fc; padding: 12px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); }
.catalog-table tbody td { padding: 10px 14px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.catalog-table tbody tr:last-child td { border-bottom: none; }
.catalog-table tbody tr:hover { background: #f8f9fc; }
.catalog-row.row-out { background: #fff5f5; }
.catalog-row.row-out:hover { background: #fee2e2; }
.catalog-row.row-low { background: #fffbeb; }
.catalog-row.row-low:hover { background: #fef3c7; }

.catalog-img-cell { width: 60px; }
.catalog-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.catalog-name { font-weight: 600; font-size: 13px; color: var(--text); }
.catalog-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.catalog-price { font-weight: 700; font-size: 13px; }

.stock-badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.stock-ok   { background: #d1fae5; color: #065f46; }
.stock-low  { background: #fef3c7; color: #92400e; }
.stock-out  { background: #fee2e2; color: #991b1b; }

.vis-badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.vis-yes { background: #d1fae5; color: #065f46; }
.vis-no  { background: #f3f4f6; color: #6b7280; }

.plan-badge { background: #ede9fe; color: #5b21b6; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* ===== MEMBERS SECTION ===== */
.members-summary { display: flex; gap: 12px; margin-bottom: 20px; }

/* ===== CONVERSATIONS TOOLBAR ===== */
.conv-toolbar { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: #f8f9fc; flex-wrap: wrap; }
.conv-list-header { padding: 10px 12px; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }

/* ===== NAV BADGE ===== */
.nav-badge { background: var(--danger); color: white; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px; margin-left: auto; }

/* ===== NOTICES SECTION ===== */
.notice-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.notice-card.active { border-left: 4px solid #10b981; }
.notice-card.inactive { border-left: 4px solid #d1d5db; opacity: .7; }
.notice-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; gap: 12px; }
.notice-title { font-weight: 700; font-size: 15px; margin-right: 8px; }
.notice-badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }
.notice-dates { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.notice-message { font-size: 13px; color: #374151; white-space: pre-wrap; background: #f9fafb; padding: 10px; border-radius: 6px; margin-top: 8px; }
.notice-img-preview img { max-height: 80px; border-radius: 6px; margin-bottom: 8px; }
.btn-danger { background: #ef4444; color: white; border: none; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

#mobileHomeBtn { display: none; }

/* ===== MOBILE CONVERSATIONS (must come after desktop rules) ===== */
@media (max-width: 768px) {
  .conv-layout { flex-direction: column !important; height: auto !important; min-height: 0 !important; background: transparent !important; border: none !important; border-radius: 0 !important; overflow: visible !important; }
  .conv-list { width: 100% !important; height: calc(100vh - 160px) !important; border-right: none !important; overflow-y: auto !important; }
  .conv-window { position: fixed !important; inset: 0 !important; z-index: 200 !important; display: none !important; flex-direction: column !important; height: 100dvh !important; background: #0f0f1a !important; }
  .conv-window.mobile-open { display: flex !important; }
  /* Mobile chat window: above banner */
  .conv-window.mobile-open { z-index: 10000 !important; }
  /* Mobile topbar inside chat window */
  .mobile-topbar { display: flex; flex-direction: column; align-items: stretch; background: #1e1e2e; border-bottom: 1px solid #333; padding: 10px 0 0 0; flex-shrink: 0; gap: 0; }
  .mobile-back-btn { background: none; border: none; color: #6366f1; font-size: 26px; cursor: pointer; padding: 0 8px; line-height: 1; flex-shrink: 0; }
  .mobile-topbar-toprow { display: flex; align-items: center; padding: 8px 12px 6px 4px; gap: 4px; width: 100%; box-sizing: border-box; }
  .mobile-topbar-name { font-weight: 700; color: #fff; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }
  .mobile-topbar-actions .btn { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
  /* Hide desktop header inside mobile chat */
  .conv-window.mobile-open .conv-header { display: none !important; }
  /* Messages area */
  .conv-window.mobile-open .conv-messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 10px 80px 10px; }
  /* Fix text overflow in messages */
  .conv-window.mobile-open .msg { max-width: 82% !important; word-break: break-word; overflow-wrap: break-word; }
  /* Status bar */
  .conv-window.mobile-open .conv-status-bar { font-size: 12px; padding: 6px 12px; flex-shrink: 0; }
  /* Input area fixed at bottom */
  .conv-window.mobile-open .conv-input-area { position: fixed !important; bottom: 0; left: 0; right: 0; z-index: 10001; background: #1e1e2e !important; padding: 10px 12px; border-top: 1px solid #333; }
  .conv-window.mobile-open .conv-input-area textarea { background: #2a2a3e; color: #fff; border-color: #444; }
  /* Red human alert banner on mobile */
  #humanAlertBanner { flex-wrap: wrap; padding: 8px 12px !important; gap: 6px !important; }
  #humanAlertBanner > div { min-width: 0; flex: 1 1 auto; }
  #humanAlertBanner > div > div { max-width: 100% !important; white-space: normal !important; font-size:.75rem !important; }
  #humanAlertBanner .human-alert-btn { flex-shrink: 0; padding: 5px 10px !important; font-size:.8rem !important; }
  /* Top bar on mobile */
  .top-bar { padding: 0 12px !important; }
  body.has-human-alert .main-content { margin-top: 70px !important; }
  /* Show home button on mobile */
  #mobileHomeBtn { display: block !important; }
  /* Fix horizontal overflow everywhere */
  .main-content { overflow-x: hidden !important; }
  .conv-list-header { font-size: 12px !important; padding: 8px 10px !important; }
  .conv-list-header .btn { font-size: 11px !important; padding: 4px 8px !important; }
  .conv-toolbar input { min-width: 0; flex: 1; font-size: 13px; }
  .conv-toolbar select { font-size: 13px; max-width: 110px; }
  /* Messages no overflow */
  .msg { word-break: break-word !important; overflow-wrap: break-word !important; max-width: 80% !important; }
  /* Mobile chat topbar right side buttons */
  .mobile-topbar-actions .btn { font-size: 11px !important; padding: 4px 8px !important; }
}
