:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #166534;
    --success-bg: #dcfce7;
    --danger-color: #dc3545;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --warning-color: #ffc107;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --info-color: #17a2b8;
    --info-bg: #e3f2fd;
    --info-border: #90caf9;
    --purple-color: #6f42c1;
    --teal-color: #00d1b2;
    --dark-bg: #2c3e50;
    --sidebar-width: 260px;
    --order-sidebar-width: 360px;
    --body-bg: #f4f7f6;
    --text-color: #333;
    --text-muted: #666;
    --border-color: #ddd;
    --white: #ffffff;
    --debug-color: #d63384;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--body-bg);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

a { text-decoration: none; color: var(--primary-color); }
a:hover { text-decoration: underline; }
ul { list-style: none; padding: 0; margin: 0; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-1 { flex: 1; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.align-end { align-items: flex-end; }
.gap-10 { gap: 10px; }
.gap-20 { gap: 20px; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-danger { color: var(--danger-color); }
.text-success { color: var(--success-color); }
.font-bold { font-weight: bold; }
.font-mono { font-family: monospace; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-lg { font-size: 16px; }
.mt-5 { margin-top: 5px; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mb-5 { margin-bottom: 5px; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.p-20 { padding: 20px; }
.pt-10 { padding-top: 10px; }
.cursor-pointer { cursor: pointer; }
.border-top { border-top: 1px solid #eee; }
.border-bottom { border-bottom: 1px solid #eee; }

body.auth-body {
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.auth-card {
    background: var(--white);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 450px;
    margin: 20px;
}

.auth-header { text-align: center; margin-bottom: 25px; }
.auth-header h2 { margin: 0; color: #333; }
.auth-header p { color: #888; font-size: 14px; margin-top: 5px; }

.section-title {
    font-size: 16px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-top: 20px;
    margin-bottom: 15px;
    color: #333;
}

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: #666; font-weight: 500; font-size: 14px; }
.form-group input[type="text"], 
.form-group input[type="email"], 
.form-group input[type="password"], 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    transition: border 0.2s;
}
.form-group input:focus { border-color: var(--primary-color); outline: none; }

.btn-auth {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-auth:hover { background: var(--primary-hover); }
.auth-footer { margin-top: 20px; text-align: center; font-size: 14px; }
.error-msg { background: var(--danger-bg); color: var(--danger-text); padding: 10px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; display: none; text-align: center; }
.status-msg { margin-top: 10px; padding: 10px; display: none; border-radius: 4px; }
.status-msg.success { background: var(--success-bg); color: var(--success-color); }
.status-msg.error { background: var(--danger-bg); color: var(--danger-text); }

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-width: 0;
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-bg);
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 2000;
}

.sidebar-header {
    padding: 20px;
    background: #1a252f;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header a { color: #e74c3c; font-size: 12px; }

.sidebar-section { padding: 15px 15px 5px 15px; }
.sidebar-section-divider { border-bottom: 1px solid #34495e; margin-bottom: 10px; padding-bottom: 10px; }
.sidebar-section-tight { padding-top: 5px; }
.sidebar-footer { margin-top: auto; padding: 10px; border-top: 1px solid #34495e; }

.folder-tree-container { flex: 1; overflow-y: auto; }
.folder-item { border-bottom: 1px solid #34495e; }
.folder-row { display: flex; align-items: stretch; transition: 0.2s; min-height: 40px; }
.folder-row:hover { background: #34495e; }

.folder-link {
    flex: 1; display: flex; align-items: center; padding: 8px 10px 8px 15px;
    color: #bdc3c7; text-decoration: none; font-size: 14px;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.folder-link:hover { color: #fff; }
.folder-link.active { background: #34495e; color: #fff; border-left: 4px solid #3498db; padding-left: 11px; }
.folder-link.btn-settings { justify-content: center; background: #34495e; border: 1px solid #4e6075; font-weight: bold; color: #ddd; }
.folder-link.btn-settings:hover { background: #3e5163; color: #fff; }

.folder-toggle {
    width: 30px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: #95a5a6; font-size: 10px;
    transition: 0.2s; border-left: 1px solid rgba(255,255,255,0.05);
}
.folder-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }
.folder-toggle.expanded .arrow { transform: rotate(90deg); }
.folder-toggle.empty { cursor: default; opacity: 0; pointer-events: none; }

.sub-menu { display: none; background: #233140; box-shadow: inset 0 3px 5px rgba(0,0,0,0.1); }
.sub-menu.open { display: block; }
.sub-menu .folder-link { padding-left: 30px; }
.sub-menu .sub-menu .folder-link { padding-left: 45px; }

.badge-queue { background: var(--warning-color); color: #333; padding: 2px 7px; border-radius: 10px; font-size: 11px; font-weight: bold; margin-left: auto; display: inline-block; }

.btn-compose {
    width: 100%; padding: 10px; background: var(--success-color); color: white;
    border: none; border-radius: 4px; cursor: pointer; font-weight: bold;
    display: flex; align-items: center; justify-content: center;
}
.btn-compose span { font-size: 16px; margin-right: 5px; }
.btn-compose:hover { opacity: 0.9; }

.user-profile-box { padding: 10px; background: #233140; color: white; font-size: 12px; margin-top: 10px; }
.mailbox-select { width: 100%; margin-top: 5px; color: black; padding: 2px; }
.mailbox-single-label { margin-top: 4px; opacity: 0.8; }
.loading-text { padding: 20px; color: #aaa; font-size: 12px; }

.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1999; }
.sidebar-overlay.show { display: block; }

.toolbar {
    padding: 12px 20px; border-bottom: 1px solid #e0e0e0; background: #f8f9fa;
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    height: 50px; flex-shrink: 0;
}
.hamburger-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; padding: 0 10px 0 0; color: #333; }
.search-form { display: flex; gap: 5px; flex: 1; max-width: 500px; }
.search-form input { flex: 1; padding: 6px 10px; border: 1px solid #ccc; border-radius: 4px; }
.reset-search { display: flex; align-items: center; justify-content: center; width: 20px; color: var(--danger-color); font-weight: bold; font-size: 16px; margin-left: 5px; cursor: pointer; }

.view-tabs { padding: 10px 20px; background: #f8f9fa; border-bottom: 1px solid #ddd; display: flex; gap: 10px; }
.view-tab { text-decoration: none; color: #555; padding: 5px 10px; border-radius: 4px; font-size: 13px; }
.view-tab.active { background: #e9ecef; color: #000; font-weight: bold; }
.view-tab:hover { background: #e2e6ea; }

.bulk-bar {
    background: var(--warning-bg); padding: 10px 20px; border-bottom: 1px solid #ffeeba;
    display: none; align-items: center; justify-content: space-between; height: 40px; flex-shrink: 0;
}

.email-list-container { flex: 1; overflow-y: auto; position: relative; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th {
    text-align: left; background: #fff; padding: 10px; border-bottom: 2px solid #ddd;
    position: sticky; top: 0; z-index: 10; font-size: 13px; color: #777; text-transform: uppercase; font-weight: 600;
}
td { padding: 10px; border-bottom: 1px solid #eee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; font-size: 14px; color: var(--text-color); }
tr:hover { background: #f5f5f5; }

.col-status { width: 100px; }
.col-status-lg { width: 120px; }
.col-from-lg { width: 150px; }
.col-action { width: 80px; }
.col-action-lg { width: 120px; }
.col-date { width: 140px; color: #666; font-size: 13px; text-align: right; }
.col-from { width: 220px; color: #444; }
.chk-col { width: 30px; text-align: center; cursor: default; }

.email-row-unread { background-color: var(--white); font-weight: bold; }
.email-row-read { background-color: #fcfcfc; color: #555; }
.email-row-priority { background-color: #fff9e6; border-left: 4px solid var(--warning-color); }

.folder-badge { display: inline-block; background-color: #e9ecef; color: #495057; border: 1px solid #ced4da; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-right: 6px; vertical-align: middle; }
.reply-badge { display:inline-block; background:#e8f0fe; color:#1a73e8; border-radius:3px; padding:1px 4px; margin-right:5px; font-size:12px; font-weight:bold; }
.status-badge { padding: 3px 8px; border-radius: 12px; color: white; font-size: 11px; font-weight: bold; text-transform: uppercase; display: inline-block; }
.status-paid, .status-completed { background: var(--success-color); }
.status-shipped { background: var(--info-color); }
.status-pending { background: var(--warning-color); color: #333; }
.status-backorder { background: #fd7e14; }

.pagination { padding: 10px; background: #f9f9f9; border-top: 1px solid #ddd; display: flex; justify-content: center; gap: 4px; flex-shrink: 0; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid #ccc; text-decoration: none; color: #333; border-radius: 3px; font-size: 13px; background: var(--white); }
.pagination a:hover { background: #eee; }
.pagination .active { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.pagination .disabled { color: #bbb; border-color: #eee; background: #f9f9f9; cursor: default; }

.detail-container { display: flex; flex: 1; overflow: hidden; height: 100%; }
.email-content { flex: 1; display: flex; flex-direction: column; padding: 20px; overflow-y: auto; border-right: 1px solid #ddd; background: #fff; }

.action-bar { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; }

.ai-input-bar {
    display: flex; gap: 10px; margin-bottom: 15px; background: #f1f8e9; padding: 10px;
    border: 1px solid #c5e1a5; border-radius: 6px; align-items: center;
}
.ai-input-bar input { flex: 1; padding: 8px 12px; border: 1px solid #bbb; border-radius: 4px; }
.ai-draft-box { display:none; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 6px; padding: 15px; margin-bottom: 20px; }
.ai-content { font-family:'Segoe UI', sans-serif; font-size:14px; background:var(--white); padding:10px; border:1px solid #eee; border-radius:4px; margin-bottom:10px; max-height:200px; overflow-y:auto; }
.ai-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.ai-title { color: var(--success-color); display:flex; align-items:center; gap:5px; font-weight: bold; }

.email-header { border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 15px; }
.email-header h2 { margin: 0 0 8px 0; color: #222; font-size: 20px; }
.email-meta { color: #555; font-size: 13px; line-height: 1.6; }
.email-body { flex: 1; border: 1px solid #e0e0e0; background: #fff; border-radius: 4px; box-shadow: inset 0 0 5px rgba(0,0,0,0.05); width: 100%; position: relative; }
.email-iframe { width: 100%; height: 100%; border: none; display: block; }

.attachments { margin-top: 15px; padding: 10px; background: #f8f9fa; border-radius: 5px; border: 1px solid #eee; }
.att-link { display: inline-block; margin-right: 15px; color: var(--primary-color); font-size: 13px; }

.delegation-block { padding: 15px; margin-bottom: 20px; border-radius: 5px; border-left-width: 5px; border-left-style: solid; }
.delegation-warning { background: var(--warning-bg); border-color: #ffeeba; border-left-color: var(--warning-color); color: var(--warning-text); }
.delegation-info { background: var(--info-bg); border-color: var(--info-border); border-left-color: #2196f3; display: flex; justify-content: space-between; align-items: center; }
.reply-info-block { background: #e8f0fe; border: 1px solid #d2e3fc; color: #174ea6; padding: 12px 15px; margin-bottom: 20px; border-radius: 6px; display: flex; align-items: center; gap: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.reply-icon { font-size: 20px; }

.order-sidebar {
    width: var(--order-sidebar-width); background: #f8f9fa; padding: 20px;
    overflow-y: auto; border-left: 1px solid #ddd; display: flex; flex-direction: column; gap: 15px; flex-shrink: 0;
}
.order-card {
    background: #fff; padding: 15px; border-radius: 6px; border: 1px solid #e1e1e1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); font-size: 13px;
}
.order-card.border-left-accent { border-left: 4px solid var(--teal-color); }
.order-card h4 { margin: 0 0 10px 0; border-bottom: 1px solid #eee; padding-bottom: 5px; color: #333; font-size: 14px; font-weight: bold; }
.order-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.lbl { color: #777; } .val { font-weight: 600; text-align: right; }

.product-item { display: flex; gap: 8px; border-bottom: 1px solid #f0f0f0; padding: 8px 0; }
.product-qty { font-weight: bold; color: var(--primary-color); min-width: 20px; }
.product-text-flex { flex: 1; font-size: 13px; }
.product-cause { background-color: #fff5f5; border-radius: 4px; border-bottom: none; margin-bottom: 2px; }
.product-cause-text { color: var(--danger-color); font-weight: bold; }
.stock-info { font-size: 11px; margin-top: 3px; color: #444; background: rgba(0,0,0,0.03); padding: 2px 5px; border-radius: 3px; display: inline-block; }

.debug-link { font-size: 11px; color: var(--debug-color); text-decoration: none; margin-right: 10px; font-family: monospace; }
.external-link { font-size: 11px; color: var(--primary-color); text-decoration: none; }
.ajax-msg { padding: 15px; color: #666; font-style: italic; }
.pnl-shipment { margin-bottom: 15px; border-bottom: 1px dashed #eee; padding-bottom: 10px; }
.pnl-phase-msg { font-weight: 600; color: #ed8c00; font-size: 13px; margin-top: 5px; }
.pnl-eta { margin-top: 5px; font-size: 12px; }
.pnl-timeline { margin-top: 8px; padding-left: 10px; border-left: 2px solid #eee; }
.pnl-event { font-size: 11px; margin-bottom: 5px; position: relative; padding-left: 10px; color: #666; }
.pnl-event.active { color: #000; font-weight: 600; }
.pnl-dot { width: 6px; height: 6px; background: #eee; border-radius: 50%; position: absolute; left: -14px; top: 4px; }
.pnl-event.active .pnl-dot { background: var(--success-color); }
.pnl-date { display: block; font-size: 10px; opacity: 0.7; }
.no-data-msg { padding: 15px; color: #666; font-style: italic; }

.settings-container { flex:1; display:flex; flex-direction:column; padding:20px; overflow-y:auto; }
.settings-header { margin-bottom:20px; border-bottom:1px solid #ddd; padding-bottom:10px; display:flex; justify-content:space-between; align-items:center;}

.tabs { display:flex; gap:10px; margin-bottom:20px; border-bottom:1px solid #ddd; flex-wrap: wrap; }
.tab { padding:10px 20px; cursor:pointer; background:#fff; border:1px solid #ddd; border-bottom:none; border-radius: 5px 5px 0 0; color:#555; user-select: none; }
.tab.active { background:var(--primary-color); color:white; border-color:var(--primary-color); font-weight: bold; }
.tab:hover:not(.active) { background-color: #f9f9f9; }
.tab-content { display:none; background:white; padding:25px; border-radius:0 5px 5px 5px; box-shadow:0 2px 5px rgba(0,0,0,0.05); }
.tab-content.active { display:block; }

.form-section { margin-bottom:30px; }
.form-section h3 { margin-top:0; color:#333; border-bottom:2px solid #f0f0f0; padding-bottom:10px; margin-bottom:15px; }
.form-row { display:flex; gap:20px; margin-bottom:15px; }

.footer-manager { display:flex; height:500px; border:1px solid #ddd; }
.footer-list { width:250px; border-right:1px solid #ddd; background:#f9f9f9; overflow-y:auto; }
.footer-item { padding:12px; cursor:pointer; border-bottom:1px solid #eee; font-size:14px; }
.footer-item:hover { background:#ececec; }
.footer-item.active { background:#e3f2fd; font-weight:bold; border-left:4px solid var(--primary-color); }
.footer-editor { flex:1; padding:20px; display:flex; flex-direction:column; gap:10px; }
.tag-shared { font-size:10px; background:var(--secondary-color); color:white; padding:2px 5px; border-radius:3px; float:right; }
.tag-personal { font-size:10px; background:var(--success-color); color:white; padding:2px 5px; border-radius:3px; float:right; }

.team-table { width:100%; border-collapse:collapse; background:white; font-size:14px; }
.team-table th { background:#f9f9f9; text-align:left; border-bottom:2px solid #eee; padding:10px; }
.team-table td { padding:10px; border-bottom:1px solid #eee; }

.prompt-item { margin-bottom: 25px; border-bottom: 1px dashed #eee; padding-bottom: 15px; }
.prompt-label { font-size: 14px; color: #333; display: block; }
.prompt-desc { font-size: 12px; color: #888; margin-bottom: 5px; }
.rules-textarea, .prompts-textarea { width: 100%; height: 200px; padding: 10px; border: 1px solid #ccc; font-family: sans-serif; }
.prompts-textarea { height: 100px; font-family: monospace; font-size: 12px; }

.missing-folders-list { text-align: left; background: #f9f9f9; padding: 10px 10px 10px 30px; border: 1px solid #eee; }

.btn { padding: 6px 12px; border-radius: 4px; border: none; cursor: pointer; color: white; text-decoration: none; font-size: 13px; margin-right: 5px; display: inline-flex; align-items: center; font-weight: bold; transition: opacity 0.2s; }
.btn:hover { opacity: 0.9; }
.btn-gray { background: var(--secondary-color); }
.btn-blue { background: var(--info-color); }
.btn-red { background: var(--danger-color); }
.btn-reply { background: var(--success-color); }
.btn-forward { background: var(--warning-color); color: #333; }
.btn-archive { background: var(--primary-color); }
.btn-trash { background: var(--danger-color); }
.btn-cancel { background: #95a5a6; color: white; }
.btn-send { background: var(--success-color); color: white; }
.btn-ai { background: var(--purple-color); }
.btn-purple { background: var(--purple-color); border-color: var(--purple-color); color: white; }
.btn-dark-green { background: #166534; color: white; }
.btn-sm { font-size: 11px; padding: 2px 6px; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 10000; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s; }
.modal-overlay.show { opacity: 1; }

.modal-confirm { height: auto !important; min-height: auto !important; width: 400px !important; text-align: center; padding-top: 30px; }
.modal-narrow { width: 450px !important; height: auto !important; }
.modal-footer.center { justify-content: center; }

.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 10001; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: #333; color: white; padding: 12px 20px; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); font-size: 14px; min-width: 250px; display: flex; align-items: center; animation: slideIn 0.3s forwards; pointer-events: auto; }
.toast.success { background: var(--success-color); border-left: 4px solid #14532d; }
.toast.error { background: var(--danger-color); border-left: 4px solid #bd2130; }
.toast.info { background: var(--info-color); border-left: 4px solid #117a8b; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.textarea-delegate { height: 80px; font-family: sans-serif; resize: vertical; width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box;}
.att-list-item { margin-top: 5px; font-size: 13px; }

.move-list-container { max-height: 300px; overflow-y: auto; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px; }
.move-list-item { padding: 8px; cursor: pointer; border-bottom: 1px solid #eee; font-size: 13px; display: flex; align-items: center; }
.move-list-item:hover { background: #f5f5f5; }

.tracking-body { background: #f4f6f8; font-family: sans-serif; display: block; height: auto; padding: 20px; }
.tracking-card { max-width: 600px; margin: 0 auto; background: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); overflow: hidden; }
.tracking-header { background: #ffc107; padding: 20px; color: #000; }
.tracking-header h1 { margin: 0; font-size: 20px; }
.tracking-timeline { margin-top: 20px; border-left: 2px solid #ddd; padding-left: 20px; margin-left: 10px; }
.event { position: relative; margin-bottom: 20px; }
.event .dot { position: absolute; left: -26px; top: 0; width: 10px; height: 10px; background: #000; border-radius: 50%; border: 2px solid #fff; }
.event.old { opacity: 0.6; }
.event.old .dot { background: #ccc; }
.tracking-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 20px; border-bottom: 1px solid #eee; }

.tox-tinymce { height: 100% !important; flex: 1 !important; }
.tox-tinymce-aux, .tox-dialog-wrap, .tox-dialog { z-index: 9999999 !important; }
.loader-spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary-color); border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#sync-status { position: fixed; bottom: 10px; right: 10px; background: #333; color: white; padding: 8px 15px; border-radius: 4px; font-size: 12px; z-index: 9999; display: none; }
#new-mail-alert {
    display: none;
    position: fixed;
    top: 20px;               /* Iets hoger */
    left: 50%;
    transform: translateX(-50%);
    background-color: #28a745; /* Groen voor succes */
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;     /* Pill shape */
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    cursor: pointer;
    z-index: 100000;         /* Extreem hoog om zeker boven alles te liggen */
    font-size: 14px;
    font-weight: bold;
    animation: slideDownFade 0.5s ease-out;
    border: 2px solid #fff;
}

@keyframes slideDownFade {
    from { top: -50px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

@media (max-width: 768px) {
    .modal { width: 100%; height: 100%; border-radius: 0; transform: none; }
    .form-row-aligned { flex-direction: column; align-items: stretch; gap: 10px; }
    .form-col.auto { width: 100% !important; }
}

/* ==========================================
   MODAL & FORM STYLING (FIXED)
   ========================================== */

/* 1. De Modal Container */
.modal {
    display: flex;
    flex-direction: column;
    height: 90vh;           /* Vaste hoogte */
    max-height: 90vh;
    background-color: #ffffff;
    width: 900px;
    max-width: 95vw;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    padding: 0;             
    overflow: hidden;       
    position: relative;
    z-index: 10001; /* Zorg dat hij boven alles ligt */
}

/* Titelbalk */
.modal h3 {
    padding: 15px 20px;
    margin: 0;
    flex-shrink: 0;         
    background-color: #f5f5f5; 
    border-bottom: 1px solid #ddd;
    color: #333;
    font-size: 18px;
}

/* 2. Formulier Layout (Flexbox) */
.modal-form {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Middenstuk (Scrollbaar) */
.modal-body-content {
    flex: 1;                
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;       /* Scroll alleen hier als nodig */
    overflow-x: hidden;
    gap: 15px;
}

/* Secties */
.inputs-section {
    flex: 0 0 auto;         /* Vaste hoogte */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.editor-section {
    flex: 2;                /* 2/3e van de ruimte */
    display: flex;
    flex-direction: column;
    min-height: 200px;      /* Minimaal formaat */
    border: 1px solid #ccc;
    border-radius: 4px;
}

.preview-section {
    flex: 1;                /* 1/3e van de ruimte */
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    min-height: 150px;
    margin-bottom: 5px;
}

.preview-header {
    padding: 5px 10px;
    background: #eee;
    font-size: 11px;
    font-weight: bold;
    color: #555;
    border-bottom: 1px solid #ddd;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.preview-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* TinyMCE Fix */
.tox-tinymce {
    border: none !important;
    height: 100% !important;
}

/* Footer (Vast onderaan) */
.modal-footer {
    flex-shrink: 0;
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    z-index: 10;
}

.modal-footer.center {
    justify-content: center;
}

/* 3. Input & Grid Styling */
.form-row-aligned {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.form-col {
    display: flex;
    flex-direction: column;
}
.form-col.grow { flex: 1; }
.form-col.auto { flex: 0 0 auto; }

.input-modal {
    width: 100%;
    padding: 0 10px;        /* Padding horizontaal */
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    height: 38px;           /* Vaste hoogte */
    line-height: 38px;
    box-sizing: border-box;
}

.checkbox-aligned {
    height: 38px;
    display: flex;
    align-items: center;
    background: #fff9e6;
    border: 1px solid #ffeeba;
    padding: 0 10px;
    border-radius: 4px;
    cursor: pointer;
    box-sizing: border-box;
    white-space: nowrap;
}
.checkbox-aligned input { margin-right: 8px; }
.text-danger { color: #dc3545; font-weight: bold; font-size: 13px; }

.toggle-link {
    font-size: 12px; color: var(--primary-color); cursor: pointer; text-decoration: underline;
    line-height: 38px; margin-left: 5px;
}

/* 4. Attachment Knop (+ Style) */
.attachment-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

.input-file-hidden {
    display: none !important;
}

.btn-attachment-plus {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    color: #6c757d;
    transition: all 0.2s;
    user-select: none;
    box-sizing: border-box;
    padding-bottom: 4px;
}

.btn-attachment-plus:hover {
    background-color: #e2e6ea;
    border-color: #adb5bd;
    color: #333;
}

.attachment-names {
    font-size: 13px;
    color: #888;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.file-upload-zone {
    border: 1px dashed #ccc;
    background: #f9f9f9;
    padding: 8px 10px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.file-upload-zone input[type="file"] {
    font-size: 12px;
}

/* ==========================================
   OUTLOOK STYLE TAG INPUTS
   ========================================== */
.tag-input-container {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    background-color: #fff;
    cursor: text;
    min-height: 38px;
    box-sizing: border-box;
    width: 100%;
}

.tag-input-container:focus-within {
    border-color: var(--primary-color);
    outline: none;
}

.tag-item {
    background-color: #f0f0f0; /* Outlook grijs/wit achtig */
    border: 1px solid #e1e1e1;
    border-radius: 12px; /* Mooie ronde hoekjes */
    padding: 2px 8px 2px 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    color: #333;
    user-select: none;
}

.tag-item .remove-tag {
    margin-left: 6px;
    cursor: pointer;
    color: #666;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.tag-item .remove-tag:hover {
    background-color: #ddd;
    color: #000;
}

.tag-input-typer {
    border: none;
    outline: none;
    flex: 1;
    min-width: 60px;
    font-size: 14px;
    padding: 4px;
    background: transparent;
}
/* Verberg de originele inputs, maar houd ze in de DOM voor form submit */
.input-modal.hidden-real-input {
    display: none !important;
}

/* Styling voor de bijlagen lijst in de composer */
.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.attachment-chip {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s;
    max-width: 220px; /* Zorgt dat lange namen niet de boel breken */
}

.attachment-chip:hover {
    border-color: #b0b0b0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Het linker blokje voor de preview of het icoon */
.attachment-preview {
    width: 36px;
    height: 36px;
    flex-shrink: 0; /* Mag niet kleiner worden */
    border-radius: 4px;
    overflow: hidden;
    background: #f4f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    border: 1px solid #eee;
}

/* Voor echte afbeeldingen */
.attachment-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Zorgt dat de afbeelding het vierkantje vult zonder vervorming */
}

/* Voor SVG iconen */
.attachment-preview svg {
    width: 24px;
    height: 24px;
}

/* Rechterkant: Naam en grootte */
.attachment-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Neemt resterende ruimte in */
    overflow: hidden;
    margin-right: 8px;
}

.attachment-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Puntjes bij te lange naam */
}

.attachment-size {
    font-size: 11px;
    color: #888;
}

/* Het kruisje */
.attachment-remove {
    cursor: pointer;
    color: #999;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.attachment-remove:hover {
    color: #dc3545;
    background-color: #fff0f0;
}

.input-file-hidden {
    display: none !important;
}