:root {
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #3b82f6;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #1e293b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --card-bg: #ffffff;
    --body-bg: #f1f5f9;
    --surface-bg: #ffffff;
    --surface-muted: #f8fafc;
    --surface-soft: #f1f5f9;
    --page-text: #1e293b;
    --heading-text: #0f172a;
    --field-bg: #ffffff;
    --field-border: #cbd5e1;
    --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04);
    --primary: #3b82f6;
}

body.theme-dark {
    --sidebar-bg: #080f1f;
    --sidebar-hover: #101a2f;
    --sidebar-active: #2563eb;
    --text-primary: #e5edf8;
    --text-secondary: #a7b4c7;
    --text-muted: #74839a;
    --border-color: #243148;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --danger: #f87171;
    --success: #34d399;
    --warning: #fbbf24;
    --card-bg: #111827;
    --body-bg: #0b1120;
    --surface-bg: #111827;
    --surface-muted: #172033;
    --surface-soft: #1e293b;
    --page-text: #d7e0ee;
    --heading-text: #f8fafc;
    --field-bg: #0f172a;
    --field-border: #334155;
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.28);
    --primary: #60a5fa;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--body-bg);
    color: var(--page-text);
    display: flex;
    min-height: 100vh;
}

body.auth-pending .sidebar,
body.auth-pending .main-content {
    opacity: 0;
    pointer-events: none;
}

/* ==================== SIDEBAR ==================== */

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 14px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -0.3px;
}

.sidebar-header small {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    padding: 16px 12px 8px;
    font-weight: 600;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sidebar-nav a .nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.sidebar-nav a.active .nav-icon {
    background: rgba(255,255,255,0.2);
}

.sidebar-nav a .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
}

.sidebar-footer .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-footer .user-name {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}

.sidebar-footer .user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ==================== MAIN CONTENT ==================== */

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.header h1 {
    font-size: 26px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.5px;
}

/* ==================== BUTTONS ==================== */

.btn-logout {
    padding: 10px 20px;
    background: #ffffff;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-logout:hover {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fecaca;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-info { background: #06b6d4; color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ==================== BADGES ==================== */

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fce4ec; color: #c62828; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* ==================== CONTENT SECTIONS ==================== */

.content-section {
    display: none;
    animation: fadeSlideIn 0.25s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== STATS ==================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    padding: 18px 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.stat-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.stat-card .stat-value {
    font-size: 30px;
    font-weight: 700;
    color: #0f172a;
}

.stat-card .stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 700;
    margin-top: 4px;
}

.stat-hint {
    color: #94a3b8;
    font-size: 12px;
    margin-top: 8px;
}

.dashboard-settings-grid,
.dashboard-insights-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.dashboard-panel,
.recent-activity-box {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dashboard-panel {
    margin-bottom: 20px;
}

.dashboard-insights-grid .dashboard-panel {
    margin-bottom: 0;
}

.dashboard-panel-content,
.section-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.section-panel-header {
    margin-bottom: 16px;
}

.section-panel-header h2,
.section-panel-header h3,
.panel-title {
    color: #0f172a;
    font-weight: 700;
}

.section-panel-header p,
.panel-description,
.panel-status {
    color: #64748b;
    font-size: 13px;
    line-height: 1.5;
    margin-top: 4px;
}

.panel-title {
    font-size: 15px;
}

.panel-status {
    border-top: 1px solid #f1f5f9;
    margin-top: 14px;
    padding-top: 12px;
}

.discount-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.discount-control input {
    width: 78px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    text-align: center;
}

.metric-row {
    margin-top: 14px;
}

.metric-row-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #334155;
    font-size: 13px;
}

.metric-row-label strong {
    color: #0f172a;
}

.metric-track {
    background: #e2e8f0;
    border-radius: 999px;
    height: 8px;
    margin-top: 8px;
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    border-radius: inherit;
    transition: width 0.4s ease;
}

.metric-fill-male { background: #2563eb; }
.metric-fill-female { background: #db2777; }

.activity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid #f1f5f9;
    padding: 12px 0;
}

.activity-row:first-child {
    border-top: 0;
}

.activity-row strong {
    display: block;
    color: #0f172a;
    font-size: 14px;
}

.activity-row span,
.activity-row time {
    color: #64748b;
    font-size: 12px;
}

/* ==================== TABLES ==================== */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* ==================== SEARCH BAR ==================== */

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-bar input, .search-bar select {
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    background: white;
    color: #1e293b;
    transition: all 0.2s;
}

.search-bar input:focus, .search-bar select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

/* ==================== MODAL ==================== */

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
    animation: modalIn 0.2s ease;
}

.admin-clickable-photo {
    cursor: zoom-in;
}

.image-viewer-modal {
    padding: 18px;
}

.image-viewer-content {
    background: var(--surface-bg);
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.28);
    max-height: calc(100vh - 36px);
    max-width: min(920px, calc(100vw - 36px));
    overflow: hidden;
    padding: 14px;
    width: auto;
}

.image-viewer-header {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.image-viewer-content img {
    border-radius: 10px;
    display: block;
    max-height: calc(100vh - 130px);
    max-width: min(860px, calc(100vw - 68px));
    object-fit: contain;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==================== CHAT LAYOUT ==================== */

.chats-container {
    display: flex;
    gap: 20px;
}

.chat-monitor-shell {
    align-items: stretch;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    height: min(720px, calc(100vh - 170px));
    min-height: 520px;
    overflow: hidden;
}

#section-chats > h2 {
    margin-bottom: 22px;
}

.chat-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid #e2e8f0;
    padding-right: 16px;
}

.chat-monitor-sidebar {
    background: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 18px;
    width: 360px;
}

.chat-monitor-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 18px;
}

.chat-pane-title {
    align-items: center;
    display: flex;
    flex-shrink: 0;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.chat-pane-title h3 {
    color: #0f172a;
    font-size: 15px;
}

.chat-pane-title span {
    color: #64748b;
    font-size: 12px;
}

.chat-toolbar {
    display: grid;
    flex-shrink: 0;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
    margin-bottom: 14px;
}

.chat-toolbar input {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    min-width: 0;
    padding: 9px 10px;
}

.chat-clean-button {
    grid-column: 1 / -1;
}

.chat-list {
    max-height: 500px;
    overflow-y: auto;
}

.chat-monitor-shell .chat-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    max-height: none;
    min-height: 0;
    overflow: hidden;
}

.chat-list-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.chat-item {
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.chat-item:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.chat-item.active {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.chat-monitor-item {
    border-color: #e2e8f0;
    margin-bottom: 10px;
    padding: 14px;
}

.chat-row-top {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.chat-row-title {
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    min-width: 0;
    overflow-wrap: anywhere;
}

.chat-row-title span {
    color: #94a3b8;
    font-weight: 500;
}

.chat-row-time,
.chat-row-meta,
.chat-row-preview {
    color: #64748b;
    font-size: 12px;
}

.chat-row-time {
    flex-shrink: 0;
    text-align: right;
}

.chat-row-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chat-row-preview {
    line-height: 1.45;
    margin-top: 10px;
    overflow-wrap: anywhere;
}

.chat-row-meta {
    margin-top: 8px;
}

.chat-messages-panel {
    flex: 1;
}

.chat-messages-box {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    background: #f8fafc;
}

.chat-monitor-shell .chat-messages-box {
    flex: 1;
    max-height: none;
    min-height: 0;
}

.chat-message {
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: 10px;
}

.chat-message-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
    margin-bottom: 0;
}

.chat-bubble-meta {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-bubble-meta strong {
    color: #0f172a;
    font-size: 13px;
}

.chat-bubble-meta span,
.chat-bubble-meta time {
    color: #64748b;
    font-size: 12px;
}

.chat-bubble .text {
    color: #1e293b;
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.chat-photo {
    border-radius: 10px;
    cursor: pointer;
    display: block;
    max-height: 320px;
    max-width: 320px;
}

#section-mail .chats-container {
    align-items: stretch;
    height: min(720px, calc(100vh - 170px));
    min-height: 520px;
}

#section-mail .chat-sidebar,
#section-mail .chat-messages-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#section-mail .chat-list,
#section-mail .chat-messages-box {
    flex: 1;
    max-height: none;
    min-height: 0;
}

#section-mail .chat-messages-box {
    display: flex;
    flex-direction: column;
}

.mail-chat-item {
    align-items: flex-start;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.mail-chat-item-main {
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.mail-chat-item-main strong,
.mail-chat-item-main small {
    display: block;
    overflow-wrap: anywhere;
}

.mail-chat-actions {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 8px;
}

.mail-chat-actions a {
    color: var(--primary);
    font-size: 11px;
    text-decoration: none;
}

.mail-messages-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.mail-message.is-admin {
    margin-left: auto;
    max-width: min(620px, 88%);
}

.mail-message.is-user {
    margin-right: auto;
    max-width: min(620px, 88%);
}

.mail-composer {
    border-top: 1px solid #e2e8f0;
    display: grid;
    flex-shrink: 0;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding-top: 14px;
}

.mail-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    grid-column: 1 / -1;
}

.mail-composer textarea {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    line-height: 1.5;
    max-height: 170px;
    min-height: 74px;
    min-width: 0;
    padding: 10px 12px;
    resize: vertical;
}

.mail-composer-actions {
    align-items: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mail-attachment-preview {
    align-items: center;
    display: flex;
    gap: 10px;
    grid-column: 1 / -1;
}

.mail-attachment-preview img,
.mail-attachment-preview video {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    height: 72px;
    object-fit: cover;
    width: 72px;
}

.mail-video {
    border-radius: 8px;
    display: block;
    max-height: 320px;
    max-width: 100%;
    width: min(420px, 100%);
}

.mail-document-link,
.mail-file-chip {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #0f172a;
    display: inline-flex;
    font-size: 13px;
    max-width: 100%;
    overflow-wrap: anywhere;
    padding: 9px 11px;
    text-decoration: none;
}

.mail-back-button {
    display: none;
}

.photo-missing {
    color: #64748b;
    font-size: 12px;
}

.match-info-header {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.chat-detail-header {
    background: #ffffff;
    border-color: #dbeafe;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
    position: sticky;
    top: 0;
    z-index: 2;
}

.chat-detail-main {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.chat-detail-kicker {
    color: #2563eb;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-detail-participants {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chat-detail-participants a {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 10px;
    text-decoration: none;
}

.chat-detail-participants span {
    color: #94a3b8;
}

.chat-detail-meta {
    color: #64748b;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    font-size: 12px;
}

.chat-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.empty-state {
    color: #64748b;
    padding: 20px;
    text-align: center;
}

.error-state {
    color: #dc2626;
}

/* ==================== PAGINATION ==================== */

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.pagination button.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pagination button:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

/* ==================== BROADCAST ==================== */

.broadcast-exclusions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.broadcast-exclusions label {
    display: block;
    margin-bottom: 8px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.broadcast-exclusion-search {
    display: flex;
    gap: 8px;
    align-items: center;
}

.broadcast-exclusion-search input {
    flex: 1;
    min-width: 220px;
    padding: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
}

.broadcast-exclude-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 28px;
    margin-top: 10px;
}

.broadcast-exclude-empty,
.broadcast-exclude-status {
    color: #64748b;
    font-size: 12px;
}

.broadcast-exclude-status {
    padding: 8px 0;
}

.broadcast-exclude-status.is-error {
    color: #dc2626;
}

.broadcast-exclude-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 12px;
}

.broadcast-exclude-chip small {
    color: #64748b;
}

.broadcast-exclude-chip button {
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: #dbeafe;
    color: #1e40af;
    cursor: pointer;
    line-height: 1;
}

.broadcast-exclude-results {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.broadcast-exclude-result {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    text-align: left;
}

.broadcast-exclude-result:hover {
    border-color: var(--accent);
    background: #f8fafc;
}

.broadcast-exclude-result span {
    color: #64748b;
    font-size: 12px;
}

.broadcast-editor {
    margin-bottom: 15px;
}

.broadcast-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
}

.broadcast-toolbar button {
    min-width: 34px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid #dbe3ef;
    border-radius: 6px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
}

.broadcast-toolbar button:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #eff6ff;
}

.broadcast-toolbar button.active {
    border-color: var(--accent);
    color: #ffffff;
    background: var(--accent);
}

.broadcast-textarea {
    width: 100%;
    min-width: 320px;
    min-height: 180px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 0 0 10px 10px;
    font-size: 14px;
    resize: both;
    font-family: inherit;
    line-height: 1.6;
    overflow: auto;
}

.broadcast-textarea.is-rtl {
    direction: rtl;
    text-align: right;
}

.broadcast-textarea.is-ltr {
    direction: ltr;
    text-align: left;
}

.broadcast-history-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.broadcast-history-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.broadcast-history-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.broadcast-history-date {
    margin-top: 3px;
    font-size: 12px;
    color: #64748b;
}

.broadcast-history-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.broadcast-history-stats span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
    font-size: 12px;
    font-weight: 600;
}

.broadcast-history-message {
    margin-top: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    color: #1e293b;
    font-size: 14px;
    line-height: 1.8;
    text-align: right;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.broadcast-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.broadcast-replies {
    margin-top: 12px;
}

.broadcast-replies-status {
    margin: 8px 0 0;
    color: #64748b;
    font-size: 13px;
}

.broadcast-replies-status.is-error {
    color: #dc2626;
}

.broadcast-thread-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    background: #ffffff;
}

.broadcast-thread-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: #0f172a;
}

.broadcast-thread-header span {
    color: #64748b;
    font-size: 12px;
}

.broadcast-thread-row {
    display: flex;
    margin: 7px 0;
}

.broadcast-thread-row.is-user {
    justify-content: flex-start;
}

.broadcast-thread-row.is-admin {
    justify-content: flex-end;
}

.broadcast-thread-bubble {
    max-width: 78%;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
}

.broadcast-thread-row.is-user .broadcast-thread-bubble {
    background: #f8fafc;
}

.broadcast-thread-row.is-admin .broadcast-thread-bubble {
    background: #dbeafe;
}

.broadcast-thread-meta {
    margin-bottom: 4px;
    color: #64748b;
    font-size: 12px;
    direction: ltr;
    text-align: left;
}

.broadcast-thread-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    text-align: right;
    line-height: 1.7;
}

.broadcast-thread-reply {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.broadcast-thread-reply textarea {
    flex: 1;
    min-height: 42px;
    resize: vertical;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    line-height: 1.6;
    text-align: right;
}

@media (max-width: 700px) {
    .broadcast-history-header,
    .broadcast-thread-header,
    .broadcast-thread-reply {
        align-items: stretch;
        flex-direction: column;
    }

    .broadcast-history-stats {
        justify-content: flex-start;
    }

    .broadcast-thread-bubble {
        max-width: 100%;
    }
}

/* ==================== AD REQUESTS ==================== */

.ad-request-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ad-request-layout {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.ad-request-main {
    flex: 1;
    min-width: 0;
}

.ad-request-user {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: #0f172a;
}

.ad-request-user span,
.ad-request-user small {
    color: #64748b;
    font-size: 12px;
}

.ad-request-message {
    margin-top: 10px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    color: #1e293b;
    font-size: 14px;
    line-height: 1.8;
    text-align: right;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ad-request-media {
    display: block;
    max-width: 220px;
    max-height: 220px;
    margin-top: 10px;
    border-radius: 8px;
    object-fit: cover;
}

.ad-request-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    color: #64748b;
    font-size: 12px;
}

.ad-request-meta span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #ffffff;
}

.ad-request-side {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.ad-status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 10px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}

.ad-status-badge.status-pending { background: #f59e0b; }
.ad-status-badge.status-approved { background: #3b82f6; }
.ad-status-badge.status-rejected { background: #ef4444; }
.ad-status-badge.status-sent { background: #22c55e; }
.ad-status-badge.status-unknown { background: #64748b; }

.ad-request-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.ad-edit-form {
    padding: 10px;
}

.ad-edit-form textarea {
    width: 100%;
    min-height: 120px;
    margin: 10px 0;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font: inherit;
    line-height: 1.7;
    resize: vertical;
    text-align: right;
}

@media (max-width: 700px) {
    .ad-request-layout {
        flex-direction: column;
    }

    .ad-request-side {
        align-items: stretch;
        width: 100%;
    }

    .ad-request-actions {
        justify-content: flex-start;
    }
}

/* ==================== APPROVAL CARDS ==================== */

.approval-card {
    display: flex;
    gap: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    background: white;
}

.approval-card img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
}

.approval-card .info {
    flex: 1;
}

/* ==================== DARK THEME ==================== */

.header-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.theme-toggle {
    align-items: center;
    background: var(--surface-bg);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

body.theme-dark .main-content,
body.theme-dark .content-section,
body.theme-dark .modal-content {
    color: var(--page-text);
}

body.theme-dark .header h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark h4,
body.theme-dark strong,
body.theme-dark .stat-card .stat-value,
body.theme-dark .section-panel-header h2,
body.theme-dark .section-panel-header h3,
body.theme-dark .panel-title,
body.theme-dark .metric-row-label strong,
body.theme-dark .activity-row strong,
body.theme-dark .chat-pane-title h3,
body.theme-dark .chat-row-title,
body.theme-dark .chat-bubble-meta strong,
body.theme-dark .broadcast-history-title,
body.theme-dark .broadcast-thread-header,
body.theme-dark .broadcast-exclusions label,
body.theme-dark .ad-request-user {
    color: var(--heading-text);
}

body.theme-dark .stat-card,
body.theme-dark .dashboard-panel,
body.theme-dark .recent-activity-box,
body.theme-dark .table,
body.theme-dark .modal-content,
body.theme-dark .image-viewer-content,
body.theme-dark .chat-monitor-shell,
body.theme-dark .chat-monitor-sidebar,
body.theme-dark .chat-detail-header,
body.theme-dark .chat-bubble,
body.theme-dark .broadcast-history-card,
body.theme-dark .broadcast-thread-card,
body.theme-dark .ad-request-card,
body.theme-dark .approval-card,
body.theme-dark .theme-toggle,
body.theme-dark .btn-logout {
    background: var(--surface-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-soft);
}

body.theme-dark .table th,
body.theme-dark .table tbody tr:hover,
body.theme-dark .chat-item:hover,
body.theme-dark .broadcast-toolbar,
body.theme-dark .broadcast-exclusions,
body.theme-dark .broadcast-history-stats span,
body.theme-dark .broadcast-history-message,
body.theme-dark .broadcast-thread-row.is-user .broadcast-thread-bubble,
body.theme-dark .ad-request-message,
body.theme-dark .ad-request-meta span,
body.theme-dark .match-info-header {
    background: var(--surface-muted);
    border-color: var(--border-color);
}

body.theme-dark .chat-item.active,
body.theme-dark .broadcast-thread-row.is-admin .broadcast-thread-bubble,
body.theme-dark .chat-detail-participants a {
    background: rgba(37, 99, 235, 0.18);
    border-color: rgba(96, 165, 250, 0.42);
}

body.theme-dark .chat-messages-box,
body.theme-dark .metric-track,
body.theme-dark .broadcast-textarea,
body.theme-dark .broadcast-exclusion-search input,
body.theme-dark .broadcast-exclude-result,
body.theme-dark .broadcast-toolbar button,
body.theme-dark .pagination button,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
    background: var(--field-bg);
    border-color: var(--field-border);
    color: var(--page-text);
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
    color: #72819a;
}

body.theme-dark .btn-logout,
body.theme-dark .theme-toggle,
body.theme-dark .table th,
body.theme-dark .stat-card .stat-label,
body.theme-dark .stat-hint,
body.theme-dark .section-panel-header p,
body.theme-dark .panel-description,
body.theme-dark .panel-status,
body.theme-dark .metric-row-label,
body.theme-dark .activity-row span,
body.theme-dark .activity-row time,
body.theme-dark .chat-pane-title span,
body.theme-dark .chat-row-time,
body.theme-dark .chat-row-meta,
body.theme-dark .chat-row-preview,
body.theme-dark .chat-row-title span,
body.theme-dark .chat-bubble-meta span,
body.theme-dark .chat-bubble-meta time,
body.theme-dark .chat-detail-meta,
body.theme-dark .empty-state,
body.theme-dark .loading,
body.theme-dark .broadcast-history-date,
body.theme-dark .broadcast-history-stats span,
body.theme-dark .broadcast-exclude-empty,
body.theme-dark .broadcast-exclude-status,
body.theme-dark .broadcast-exclude-result span,
body.theme-dark .broadcast-exclude-chip small,
body.theme-dark .broadcast-replies-status,
body.theme-dark .broadcast-thread-header span,
body.theme-dark .broadcast-thread-meta,
body.theme-dark .ad-request-user span,
body.theme-dark .ad-request-user small,
body.theme-dark .ad-request-meta,
body.theme-dark .photo-missing {
    color: var(--text-secondary);
}

body.theme-dark .btn:not(.btn-primary):not(.btn-success):not(.btn-warning):not(.btn-danger):not(.btn-info) {
    background: var(--surface-soft);
    border: 1px solid var(--field-border);
    color: var(--page-text);
}

body.theme-dark .chat-bubble .text,
body.theme-dark .broadcast-history-message,
body.theme-dark .broadcast-thread-text,
body.theme-dark .ad-request-message,
body.theme-dark .table td {
    color: var(--page-text);
}

body.theme-dark .mail-document-link,
body.theme-dark .mail-file-chip {
    background: var(--surface-soft);
    border-color: var(--field-border);
    color: var(--page-text);
}

body.theme-dark .activity-row,
body.theme-dark .panel-status,
body.theme-dark .table th,
body.theme-dark .table td,
body.theme-dark .broadcast-history-header,
body.theme-dark .chat-sidebar {
    border-color: var(--border-color);
}

body.theme-dark .badge-success { background: rgba(34, 197, 94, 0.18); color: #86efac; }
body.theme-dark .badge-warning { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
body.theme-dark .badge-danger { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
body.theme-dark .badge-info { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
body.theme-dark .badge-neutral { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }

body.theme-dark .btn-logout:hover {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fca5a5;
}

body.theme-dark .modal {
    background: rgba(3, 7, 18, 0.74);
}

body.theme-dark a {
    color: var(--primary) !important;
}

body.theme-dark [style*="background:white"],
body.theme-dark [style*="background: white"],
body.theme-dark [style*="background:#fff"],
body.theme-dark [style*="background: #fff"],
body.theme-dark [style*="background:#ffffff"],
body.theme-dark [style*="background: #ffffff"] {
    background: var(--surface-bg) !important;
}

body.theme-dark [style*="background:#f8fafc"],
body.theme-dark [style*="background: #f8fafc"],
body.theme-dark [style*="background:#f1f5f9"],
body.theme-dark [style*="background: #f1f5f9"],
body.theme-dark [style*="background:#f3f4f6"],
body.theme-dark [style*="background: #f3f4f6"],
body.theme-dark [style*="background:#fafafa"],
body.theme-dark [style*="background: #fafafa"],
body.theme-dark [style*="background:#f5f5f5"],
body.theme-dark [style*="background: #f5f5f5"],
body.theme-dark [style*="background:#f0f0f0"],
body.theme-dark [style*="background: #f0f0f0"],
body.theme-dark [style*="background:#fef3e0"],
body.theme-dark [style*="background: #fef3e0"],
body.theme-dark [style*="background:#f0fdf4"],
body.theme-dark [style*="background: #f0fdf4"] {
    background: var(--surface-muted) !important;
}

body.theme-dark [style*="background:#e3f2fd"],
body.theme-dark [style*="background: #e3f2fd"],
body.theme-dark [style*="background:#dbeafe"],
body.theme-dark [style*="background: #dbeafe"],
body.theme-dark [style*="background:#eff6ff"],
body.theme-dark [style*="background: #eff6ff"] {
    background: rgba(37, 99, 235, 0.18) !important;
}

body.theme-dark [style*="border:1px solid #e2e8f0"],
body.theme-dark [style*="border:1px solid #e5e7eb"],
body.theme-dark [style*="border:1px solid #ddd"],
body.theme-dark [style*="border:1px solid #bbf7d0"],
body.theme-dark [style*="border:2px solid #ddd"],
body.theme-dark [style*="border-bottom:1px solid #eee"],
body.theme-dark [style*="border-top:1px solid #ddd"] {
    border-color: var(--border-color) !important;
}

body.theme-dark [style*="color:#334155"],
body.theme-dark [style*="color: #334155"],
body.theme-dark [style*="color:#333"],
body.theme-dark [style*="color: #333"],
body.theme-dark [style*="color:#1e293b"],
body.theme-dark [style*="color: #1e293b"] {
    color: var(--page-text) !important;
}

body.theme-dark [style*="color:#64748b"],
body.theme-dark [style*="color: #64748b"],
body.theme-dark [style*="color:#6b7280"],
body.theme-dark [style*="color: #6b7280"],
body.theme-dark [style*="color:#9ca3af"],
body.theme-dark [style*="color: #9ca3af"],
body.theme-dark [style*="color:#999"],
body.theme-dark [style*="color: #999"],
body.theme-dark [style*="color:#aaa"],
body.theme-dark [style*="color: #aaa"],
body.theme-dark [style*="color:#666"],
body.theme-dark [style*="color: #666"] {
    color: var(--text-secondary) !important;
}

body.theme-dark [style*="color:red"] {
    color: #f87171 !important;
}

body.theme-dark [style*="border:1px solid #ddd"],
body.theme-dark [style*="border:2px solid #ddd"],
body.theme-dark [style*="border:1px solid #e5e7eb"],
body.theme-dark [style*="border:1px solid #e2e8f0"] {
    border-color: var(--field-border) !important;
}

body.theme-dark [style*="box-shadow"] {
    box-shadow: var(--shadow-soft) !important;
}

/* ==================== EMPTY STATES ==================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state .icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    min-height: 100vh;
    max-width: calc(100vw - 260px);
    overflow-x: hidden;
}

#usersTable {
    overflow-x: auto;
}

/* ==================== RESPONSIVE LAYOUT ==================== */

img, video {
    max-width: 100%;
    height: auto;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

.content-section {
    min-width: 0;
}

.content-section > div,
.chat-messages-panel,
.recent-activity-box {
    min-width: 0;
}

#usersTable,
#blockedBotUsersList,
#mediaGallery,
#broadcastHistory,
#broadcastRepliesContainer,
#adRequestsList,
#reportsList,
#paymentsList,
#matchesList,
#mailUsersList {
    max-width: 100%;
}

#usersTable,
#paymentsList,
#matchesList {
    overflow-x: auto;
}

@media (max-width: 1100px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
        max-width: calc(100vw - 220px);
        padding: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }

    .chat-sidebar {
        width: 240px;
    }

    .chat-monitor-sidebar {
        width: 320px;
    }
}

@media (max-width: 900px) {
    body {
        display: block;
    }

    .sidebar {
        position: sticky;
        top: 0;
        width: 100%;
        height: auto;
        max-height: 44vh;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
    }

    .sidebar-header .logo-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .sidebar-header h2 {
        font-size: 16px;
    }

    .sidebar-header small {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 10px 12px 12px;
        scroll-snap-type: x proximity;
    }

    .sidebar-nav .nav-section {
        display: none;
    }

    .sidebar-nav a {
        flex: 0 0 auto;
        margin-bottom: 0;
        white-space: nowrap;
        scroll-snap-align: start;
    }

    .sidebar-nav a .nav-icon {
        width: 28px;
        height: 28px;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 20px;
    }

    .header {
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .header h1 {
        font-size: 22px;
    }

    .chats-container {
        flex-direction: column;
    }

    .chat-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        padding-right: 0;
        padding-bottom: 12px;
    }

    .chat-list,
    .chat-messages-box {
        max-height: 420px;
    }

    .chat-messages-panel {
        min-width: 0;
    }

    .chat-monitor-shell {
        height: auto;
        min-height: 0;
    }

    .chat-monitor-sidebar {
        width: 100%;
    }

    .chat-monitor-shell .chat-list,
    .chat-monitor-shell .chat-messages-box {
        max-height: 440px;
    }

    #section-mail .chats-container {
        height: auto;
        min-height: 0;
    }

    #section-mail.mail-chat-open .chat-sidebar {
        display: none;
    }

    #section-mail.mail-chat-open .chat-messages-panel {
        display: flex;
        min-height: calc(100vh - 220px);
    }

    #section-mail .chat-messages-box {
        max-height: none;
    }

    .mail-back-button {
        display: inline-flex;
    }

    .dashboard-settings-grid,
    .dashboard-insights-grid {
        grid-template-columns: 1fr;
    }

    .approval-card {
        flex-direction: column;
    }

    .approval-card img {
        width: 100%;
        height: auto;
        max-height: 320px;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .search-bar input,
    .search-bar select {
        flex: 1 1 180px;
        min-width: 0;
    }

    .broadcast-history-header,
    .broadcast-thread-header,
    .ad-request-layout {
        align-items: stretch;
        flex-direction: column;
    }

    .broadcast-history-stats,
    .ad-request-actions {
        justify-content: flex-start;
    }

    .ad-request-side {
        align-items: stretch;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 14px;
    }

    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-logout {
        justify-content: center;
        width: 100%;
    }

    .header-actions,
    .theme-toggle {
        width: 100%;
    }

    .header-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .theme-toggle {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-panel-content,
    .section-panel-header,
    .chat-detail-main {
        align-items: stretch;
        flex-direction: column;
    }

    .discount-control,
    .chat-detail-actions {
        justify-content: flex-start;
    }

    .chat-toolbar {
        grid-template-columns: 1fr;
    }

    .mail-composer {
        grid-template-columns: 1fr;
    }

    .mail-composer-actions {
        flex-direction: row;
    }

    .mail-message.is-admin,
    .mail-message.is-user {
        max-width: 100%;
        width: 100%;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-value {
        font-size: 26px;
    }

    .modal {
        align-items: flex-start;
        padding: 10px;
    }

    .modal-content {
        width: 100%;
        max-width: none;
        max-height: calc(100vh - 20px);
        padding: 18px;
        border-radius: 12px;
    }

    .btn {
        justify-content: center;
    }

    .search-bar,
    .broadcast-toolbar,
    .broadcast-history-actions,
    .ad-request-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .search-bar .btn,
    .broadcast-toolbar button,
    .broadcast-history-actions .btn,
    .ad-request-actions .btn {
        width: 100%;
    }

    .content-section > div:first-child[style*="display:flex"],
    .content-section div[style*="display:flex"][style*="gap"],
    .match-info-header > div,
    .broadcast-thread-reply {
        flex-direction: column;
        align-items: stretch !important;
    }

    .content-section input,
    .content-section select,
    .content-section textarea,
    .content-section button {
        width: 100% !important;
        min-width: 0 !important;
    }

    .broadcast-textarea {
        min-width: 0;
        resize: vertical;
    }

    .pagination,
    .pagination > div {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .chat-item {
        overflow-wrap: anywhere;
    }

    .chat-message {
        overflow-wrap: anywhere;
    }

    .broadcast-thread-bubble {
        max-width: 100%;
    }

    .ad-request-media {
        max-width: 100%;
        width: 100%;
        max-height: 280px;
    }

    .approval-card .info {
        min-width: 0;
    }

    .broadcast-history-card,
    .ad-request-card,
    .recent-activity-box {
        padding: 14px;
    }
}

@media (max-width: 420px) {
    .sidebar-nav a {
        font-size: 12px;
        gap: 6px;
        padding: 8px 10px;
    }

    .sidebar-nav a .nav-icon {
        display: none;
    }

    .header h1 {
        font-size: 20px;
    }

    .modal-content {
        padding: 14px;
    }
}

body.theme-dark .broadcast-exclude-chip {
    border-color: #1d4ed8;
    background: #172554;
    color: #dbeafe;
}

body.theme-dark .broadcast-exclude-chip button {
    background: #1e40af;
    color: #dbeafe;
}

body.theme-dark .broadcast-exclude-result:hover {
    background: #111827;
}
