/* CTDApp - Stylesheet */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;

    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #1e40af;

    --text: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;

    --border: #e2e8f0;
    --border-focus: #2563eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --radius: 10px;
    --radius-sm: 6px;

    --sidebar-width: 250px;
    --header-height: 64px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.sidebar-logo .logo-icon svg { width: 22px; height: 22px; }

.logo-icon-lg {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}
.logo-icon-lg svg { width: 30px; height: 30px; }

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

.nav-section { padding: 8px 24px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: #475569; margin-top: 12px; font-weight: 600; }
.nav-section:first-child { margin-top: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    margin: 1px 12px;
    color: var(--text-sidebar);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13.5px;
    border-radius: 8px;
}

.nav-item:hover { background: var(--bg-sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: rgba(59,130,246,0.15); color: #60a5fa; }

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.sidebar-user {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.sidebar-user:hover { background: rgba(255,255,255,0.06); border-radius: 0; }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: 11px; color: var(--text-sidebar); text-transform: capitalize; }

.btn-logout {
    background: none;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    background: rgba(255,255,255,0.92);
}

.page-header h2 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; letter-spacing: -0.3px; }
.page-header h2 svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--primary); }
.page-header .subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.page-body { padding: 24px 32px; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px; font-weight: 500; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }
.stat-card.info { border-left: 4px solid var(--info); }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-card);
    color: var(--text);
    white-space: nowrap;
}

.btn:hover { border-color: #cbd5e1; background: #f8fafc; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(37,99,235,0.25); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { box-shadow: 0 2px 8px rgba(22,163,74,0.25); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 2px 8px rgba(220,38,38,0.25); }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 10px 24px; font-size: 15px; border-radius: 10px; }
.btn-icon { padding: 6px; border: none; background: none; cursor: pointer; color: var(--text-secondary); }
.btn-icon:hover { color: var(--text); }

.btn-group { display: flex; gap: 8px; }

/* Tables */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: #f8fafc;
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }
tbody tr { cursor: pointer; transition: background 0.1s; }

/* Badges / Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.badge-available { background: var(--success-light); color: var(--success); }
.badge-reserved { background: var(--warning-light); color: var(--warning); }
.badge-contracted { background: var(--info-light); color: var(--info); }
.badge-sold { background: var(--primary-light); color: var(--primary); }
.badge-unavailable { background: #f1f5f9; color: var(--text-secondary); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-planning { background: var(--info-light); color: var(--info); }
.badge-selling { background: var(--warning-light); color: var(--warning); }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-archived { background: #f1f5f9; color: var(--text-secondary); }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-approved { background: var(--info-light); color: var(--info); }
.badge-paid { background: var(--success-light); color: var(--success); }
.badge-individual { background: var(--primary-light); color: var(--primary); }
.badge-company { background: #fae8ff; color: #a21caf; }
.badge-new { background: var(--info-light); color: var(--info); }
.badge-accepted { background: var(--success-light); color: var(--success); }
.badge-rejected { background: #fee2e2; color: #dc2626; }
.badge-closed { background: #f1f5f9; color: var(--text-secondary); }
.badge-info { background: var(--info-light); color: var(--info); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* Search & Filter Bar */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.filter-bar input { padding-left: 36px; }

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.filter-bar select { width: auto; min-width: 140px; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 200;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal {
    background: var(--bg-card);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 640px;
    animation: modalIn 0.25s ease-out;
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 960px; }
.modal-sm { max-width: 480px; }

@keyframes modalIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    line-height: 1;
}
.close-btn:hover { color: var(--text); }

/* Detail Page */
.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.detail-title h2 { font-size: 24px; font-weight: 700; }
.detail-title .subtitle { color: var(--text-secondary); margin-top: 4px; }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.detail-section { margin-bottom: 24px; }
.detail-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.info-list { list-style: none; }
.info-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.info-list .label { color: var(--text-secondary); }
.info-list .value { font-weight: 500; text-align: right; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Progress bars */
.progress-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }

/* Chart-like bar */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 100px; font-size: 13px; color: var(--text-secondary); text-align: right; }
.bar-track { flex: 1; height: 24px; background: #f1f5f9; border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; font-size: 12px; color: #fff; font-weight: 500; min-width: fit-content; }
.bar-value { margin-left: 8px; font-size: 13px; font-weight: 500; white-space: nowrap; }

/* Activity Feed */
.activity-feed { list-style: none; }
.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}
.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 6px;
    flex-shrink: 0;
}
.activity-text { color: var(--text-secondary); }
.activity-text strong { color: var(--text); font-weight: 500; }
.activity-time { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59,130,246,0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(99,102,241,0.1), transparent);
}

.login-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.1);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
}

.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; text-align: center; letter-spacing: -0.5px; }
.login-card .subtitle { color: var(--text-secondary); text-align: center; margin-bottom: 32px; font-size: 14px; }
.login-card .logo-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 24px; }

.error-msg { background: var(--danger-light); color: var(--danger); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.3s ease-out;
    min-width: 250px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-info { background: var(--primary); color: #fff; }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1024px) {
    .grid-2, .detail-grid { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-body { padding: 16px; }
    .page-header { padding: 12px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Image Gallery */
.gallery { margin-bottom: 24px; }
.gallery-main { width: 100%; height: 400px; border-radius: 8px; overflow: hidden; background: #f1f5f9; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumb { width: 80px; height: 60px; border-radius: 4px; overflow: hidden; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s; position: relative; }
.gallery-thumb.active { border-color: var(--primary); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-placeholder { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-secondary); padding: 40px; }
.gallery-placeholder svg { width: 48px; height: 48px; opacity: 0.4; }
.gallery-actions { display: flex; gap: 8px; margin-top: 12px; }
.img-overlay { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.gallery-thumb:hover .img-overlay { opacity: 1; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--text); }

/* Loading */
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Utility */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-mono { font-family: 'SF Mono', Monaco, monospace; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Calendar */
.cal-grid { border-collapse: collapse; width: 100%; }
.cal-grid th, .cal-grid td { border: 1px solid var(--border); padding: 0; }
.cal-grid th { padding: 8px 4px; font-size: 0.85rem; background: var(--bg-secondary, #f8fafc); }
.cal-hour-label { font-size: 0.75rem; color: var(--text-secondary); text-align: right; padding: 2px 6px !important; width: 60px; white-space: nowrap; }
.cal-cell { height: 28px; cursor: pointer; transition: background 0.15s; position: relative; }
.cal-cell:hover { background: #f0f9ff; }
.cal-available { background: #bbf7d0 !important; }
.cal-available:hover { background: #86efac !important; }
.cal-booked { background: #bfdbfe !important; cursor: default; }
.cal-booking-label { font-size: 0.7rem; padding: 1px 4px; color: #1e40af; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-booking-link { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; }
.cal-booking-link:hover { color: var(--primary-dark); text-decoration-style: solid; }
.cal-slot-label { font-size: 0.7rem; padding: 1px 4px; color: #166534; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Newsletter / WYSIWYG Editor */
.nl-compose-subject { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; }
.nl-compose-subject svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.nl-compose-subject input { border: none; background: none; flex: 1; font-size: 1rem; font-weight: 500; outline: none; }
.nl-compose-subject input::placeholder { color: #94a3b8; }
.nl-compose-label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 6px; display: block; }
.wysiwyg-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.wysiwyg-toolbar { display: flex; flex-wrap: wrap; gap: 1px; padding: 6px 8px; background: linear-gradient(to bottom, #f8fafc, #f1f5f9); border-bottom: 1px solid var(--border); }
.wysiwyg-toolbar button { background: none; border: 1px solid transparent; border-radius: 6px; padding: 5px 7px; cursor: pointer; font-size: 0.85rem; color: #475569; min-width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.wysiwyg-toolbar button:hover { background: #e2e8f0; border-color: #cbd5e1; color: #1e293b; }
.wysiwyg-toolbar button.active { background: var(--primary); color: white; }
.wysiwyg-toolbar button svg { width: 15px; height: 15px; }
.wysiwyg-toolbar .sep { width: 1px; background: #e2e8f0; margin: 2px 4px; }
.wysiwyg-toolbar select { border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-size: 0.78rem; background: white; cursor: pointer; height: 30px; color: #475569; }
.wysiwyg-editor { min-height: 380px; padding: 20px 24px; outline: none; font-size: 0.95rem; line-height: 1.7; overflow-y: auto; background: white; }
.wysiwyg-editor:focus { background: #fefefe; }
.wysiwyg-editor img { max-width: 100%; border-radius: 6px; margin: 8px 0; }
.wysiwyg-editor table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.wysiwyg-editor td, .wysiwyg-editor th { border: 1px solid #d1d5db; padding: 8px; }
.nl-compose-footer { display: flex; gap: 8px; align-items: center; }
.nl-compose-footer .left { flex: 1; font-size: 0.78rem; color: var(--text-secondary); }
.nl-compose-footer .btn svg { width: 14px; height: 14px; }

/* Newsletter Tabs */
.nl-tabs { display: flex; gap: 4px; background: #f1f5f9; border-radius: 10px; padding: 4px; margin-bottom: 1.25rem; }
.nl-tab { padding: 9px 20px; cursor: pointer; border-radius: 8px; font-weight: 500; font-size: 0.9rem; color: var(--text-secondary); transition: all 0.2s; display: flex; align-items: center; gap: 8px; }
.nl-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.6); }
.nl-tab.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.nl-tab .tab-icon { width: 16px; height: 16px; display: inline-flex; }
.nl-tab .tab-icon svg { width: 16px; height: 16px; }
.nl-tab .tab-count { background: var(--primary-light); color: var(--primary); font-size: 0.7rem; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.nl-tab.active .tab-count { background: var(--primary); color: white; }

/* Newsletter Stats Row */
.nl-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 1.25rem; }
.nl-stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s; }
.nl-stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.nl-stat-card .stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nl-stat-card .stat-icon svg { width: 20px; height: 20px; }
.nl-stat-card .stat-icon.blue { background: #dbeafe; color: #2563eb; }
.nl-stat-card .stat-icon.green { background: #dcfce7; color: #16a34a; }
.nl-stat-card .stat-icon.amber { background: #fef3c7; color: #d97706; }
.nl-stat-card .stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.nl-stat-card .stat-body .num { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.nl-stat-card .stat-body .label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 1px; }

/* Newsletter Card Grid */
.nl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.nl-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; }
.nl-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.nl-card-header { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.nl-card-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nl-card-icon svg { width: 18px; height: 18px; }
.nl-card-icon.draft { background: #fef3c7; color: #d97706; }
.nl-card-icon.sent { background: #dcfce7; color: #16a34a; }
.nl-card-icon.sending { background: #dbeafe; color: #2563eb; }
.nl-card-title { font-weight: 600; font-size: 0.95rem; line-height: 1.3; cursor: pointer; flex: 1; }
.nl-card-title:hover { color: var(--primary); }
.nl-card-body { padding: 12px 18px; flex: 1; }
.nl-card-meta { display: flex; gap: 16px; font-size: 0.8rem; color: var(--text-secondary); }
.nl-card-meta span { display: flex; align-items: center; gap: 4px; }
.nl-card-meta svg { width: 14px; height: 14px; }
.nl-card-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 6px; justify-content: flex-end; background: #fafbfc; }

/* Subscriber Row */
.sub-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background 0.1s; }
.sub-row:last-child { border-bottom: none; }
.sub-row:hover { background: #f8fafc; }
.sub-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 600; color: white; flex-shrink: 0; }
.sub-info { flex: 1; min-width: 0; }
.sub-info .sub-email { font-weight: 500; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-info .sub-detail { font-size: 0.78rem; color: var(--text-secondary); display: flex; gap: 12px; margin-top: 2px; }

/* Inbox */
.inbox-layout { display: grid; grid-template-columns: 360px 1fr; gap: 0; min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.inbox-list { overflow-y: auto; max-height: 600px; background: white; border-right: 1px solid var(--border); }
.inbox-msg { padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; position: relative; }
.inbox-msg:hover { background: #f1f5f9; }
.inbox-msg.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.inbox-msg .from { font-weight: 600; font-size: 0.88rem; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-msg .subject { font-size: 0.82rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-msg .date { font-size: 0.72rem; color: var(--text-secondary); margin-top: 4px; }
.inbox-preview { padding: 20px 24px; background: white; overflow-y: auto; max-height: 600px; }
.inbox-preview-header { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.inbox-preview-header h4 { margin: 0 0 6px; font-size: 1.1rem; }
.inbox-preview-header .meta { font-size: 0.8rem; color: var(--text-secondary); }

/* Newsletter empty states */
.nl-empty { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.nl-empty .nl-empty-icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 16px; display: flex; align-items: center; justify-content: center; background: #f1f5f9; }
.nl-empty .nl-empty-icon svg { width: 32px; height: 32px; color: #94a3b8; }
.nl-empty h3 { font-size: 1rem; color: var(--text-primary); margin: 0 0 6px; }
.nl-empty p { font-size: 0.85rem; margin: 0; }

/* ── Chat Logs ────────────────────────────────────────────── */
.cl-controls { margin-bottom: 16px; }
.cl-search-wrap { display: flex; align-items: center; gap: 8px; max-width: 600px; }
.cl-search-wrap svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.cl-search-wrap .form-control { flex: 1; }

.cl-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; min-height: 500px; }
.cl-sessions { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow-y: auto; max-height: 70vh; }
.cl-sessions-header { padding: 12px 16px; font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card); z-index: 1; }
.cl-session-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.cl-session-item:hover { background: var(--bg-hover, #f8fafc); }
.cl-session-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.cl-session-agent { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); margin-bottom: 4px; }
.cl-session-meta { display: flex; gap: 12px; font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 2px; }
.cl-session-date { font-size: 0.75rem; color: var(--text-secondary); }

.cl-messages { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.cl-messages-header { padding: 12px 16px; font-size: 0.85rem; color: var(--text-secondary); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cl-messages-header code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; }
.cl-messages-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: 65vh; }

.cl-msg { padding: 10px 14px; border-radius: 10px; max-width: 85%; }
.cl-msg-question { background: #f1f5f9; align-self: flex-start; border-bottom-left-radius: 2px; }
.cl-msg-answer { background: var(--primary-light); align-self: flex-end; border-bottom-right-radius: 2px; }
.cl-msg-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 12px; }
.cl-msg-type { font-weight: 600; font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; }
.cl-msg-time { font-size: 0.7rem; color: var(--text-secondary); white-space: nowrap; }
.cl-msg-content { font-size: 0.875rem; line-height: 1.5; color: var(--text-primary); white-space: pre-wrap; word-break: break-word; }

.cl-empty { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--text-secondary); font-size: 0.9rem; }

@media (max-width: 768px) {
    .cl-layout { grid-template-columns: 1fr; }
    .cl-sessions { max-height: 250px; }
}
