/* ─── Mailler — Dark Theme Stylesheet ───────────────────────────────── */

:root {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --bg-hover: #334155;
    --border: #334155;
    --border-light: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
    --transition: 0.2s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 14px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ─── Login Page ──────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
}

.login-container { width: 100%; max-width: 400px; padding: 1rem; }

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 2.5rem;
    box-shadow: var(--shadow);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.login-form .form-group { margin-bottom: 1.25rem; }

/* ─── Layout ──────────────────────────────────────────────────────── */
#app {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
    transition: width var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    border-right: 3px solid transparent;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.active {
    color: var(--accent);
    border-right-color: var(--accent);
    background: var(--accent-glow);
}

.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.5rem 0;
}

.logout-btn:hover { color: var(--error) !important; }

/* ─── Main Content ────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    padding: 2rem;
    max-width: 100%;
    transition: margin-right var(--transition);
    position: relative;
}

/* ─── Views ───────────────────────────────────────────────────────── */
.view {
    display: none;
    animation: fadeIn 0.25s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.view-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ─── Cards ───────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* ─── Forms ───────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    text-align: right;
}

.form-group label small {
    text-transform: none;
    font-weight: 400;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    padding-left: 2.5rem;
}

.form-textarea {
    min-height: 300px;
    resize: vertical;
    font-family: 'Inter', monospace;
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.flex-1 { flex: 1; }

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.btn-block { width: 100%; justify-content: center; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-send { min-width: 160px; justify-content: center; }

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Content Type Toggle ─────────────────────────────────────────── */
.content-type-toggle {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.content-type-toggle > label {
    margin-bottom: 0;
}

.toggle-group {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.toggle-btn {
    padding: 0.4rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.toggle-btn.active {
    background: var(--accent);
    color: white;
}

.tracking-toggle { margin-right: auto; }

/* ─── Checkbox ────────────────────────────────────────────────────── */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ─── Quill Editor ────────────────────────────────────────────────── */
#quill-editor, #quill-template-editor {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    color: var(--text-primary);
    min-height: 280px;
}

.ql-toolbar.ql-snow {
    background: var(--bg-card);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.ql-container.ql-snow {
    border: 1px solid var(--border) !important;
    border-top: none !important;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
}

.ql-editor {
    min-height: 250px;
    color: var(--text-primary);
}

.ql-editor.ql-blank::before {
    color: var(--text-muted);
    font-style: normal;
}

.ql-snow .ql-stroke { stroke: var(--text-secondary); }
.ql-snow .ql-fill { fill: var(--text-secondary); }
.ql-snow .ql-picker { color: var(--text-secondary); }
.ql-snow .ql-picker-options {
    background: var(--bg-card);
    border-color: var(--border);
}
.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker-item:hover { color: var(--accent); }
.ql-snow .ql-picker-label:hover .ql-stroke,
.ql-snow button:hover .ql-stroke { stroke: var(--accent); }
.ql-snow button:hover .ql-fill { fill: var(--accent); }
.ql-snow .ql-active .ql-stroke { stroke: var(--accent); }
.ql-snow .ql-active .ql-fill { fill: var(--accent); }
.ql-snow .ql-active { color: var(--accent); }
.ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-label { border-color: var(--border); }

.ql-snow .ql-tooltip {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-primary);
    box-shadow: var(--shadow);
}

.ql-snow .ql-tooltip input[type="text"] {
    background: var(--bg-input);
    border-color: var(--border);
    color: var(--text-primary);
}

/* ─── Editor Stats ────────────────────────────────────────────────── */
.editor-stats {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ─── File Upload ─────────────────────────────────────────────────── */
.file-upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}

.file-upload-area:hover, .file-upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-hover);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.attachment-remove {
    cursor: pointer;
    color: var(--error);
    font-weight: bold;
    background: none;
    border: none;
    font-size: 1rem;
    line-height: 1;
}

/* ─── Variable Inputs ─────────────────────────────────────────────── */
.variable-inputs {
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.variable-inputs > label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.variable-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.variable-field {
    flex: 1;
    min-width: 180px;
}

.variable-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.variable-field input {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
}

/* ─── Template Variables ──────────────────────────────────────────── */
.template-variables {
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.template-variables > label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.var-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.var-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--accent);
    color: white;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ─── Data Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: right;
    padding: 0.7rem 0.85rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}

.data-table tbody tr:hover { background: var(--bg-hover); }

.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.data-table tbody tr:nth-child(even):hover { background: var(--bg-hover); }

.loading-cell { padding: 1rem !important; }

/* ─── Status Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-sent {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-deferred {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-bounced {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-queued {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* ─── Filters Bar ─────────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-input {
    max-width: 200px;
}

.filter-select {
    max-width: 160px;
}

.filter-date {
    max-width: 160px;
}

/* ─── Pagination ──────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0 0;
}

.pagination button {
    padding: 0.35rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0.5rem;
}

/* ─── Modals ──────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-lg { max-width: 800px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ─── Domain Check Results ────────────────────────────────────────── */
.domain-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.domain-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: border-color var(--transition);
}

.domain-card.status-pass { border-right: 4px solid var(--success); }
.domain-card.status-warning { border-right: 4px solid var(--warning); }
.domain-card.status-fail { border-right: 4px solid var(--error); }

.domain-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.domain-card-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.status-pass .domain-card-icon { background: var(--success-bg); }
.status-warning .domain-card-icon { background: var(--warning-bg); }
.status-fail .domain-card-icon { background: var(--error-bg); }

.domain-card-title {
    font-weight: 600;
    font-size: 1rem;
}

.domain-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.domain-card-detail {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
    word-break: break-all;
    margin-top: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
}

.domain-card-detail .record-line {
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--border);
}

.domain-card-detail .record-line:last-child { border-bottom: none; }

.rbl-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-size: 0.85rem;
}

.rbl-clean { color: var(--success); }
.rbl-listed { color: var(--error); }

.spf-detail {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.spf-detail:last-child { border-bottom: none; }

.spf-mechanism {
    font-family: monospace;
    color: var(--accent);
    white-space: nowrap;
    min-width: 100px;
}

.spf-desc { color: var(--text-secondary); }

/* ─── Settings ────────────────────────────────────────────────────── */
.settings-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.settings-section-title:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.test-connection-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: auto;
}

.test-email-input {
    max-width: 220px;
}

/* ─── Template List ───────────────────────────────────────────────── */
.template-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.template-list-item:last-child { border-bottom: none; }

.template-list-item:hover { background: var(--bg-hover); margin: 0 -1.5rem; padding: 0.85rem 1.5rem; }

.template-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.template-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.template-actions {
    display: flex;
    gap: 0.4rem;
}

.template-actions .btn { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

/* ─── Log Detail ──────────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 0.5rem 1rem;
    font-size: 0.85rem;
}

.detail-label {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
}

.detail-value {
    color: var(--text-secondary);
    word-break: break-all;
}

.detail-section-title {
    grid-column: 1 / -1;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.detail-body-preview {
    grid-column: 1 / -1;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.detail-body-preview iframe {
    width: 100%;
    min-height: 200px;
    border: none;
    background: white;
    border-radius: var(--radius-sm);
}

.tracking-event-list {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
}

.tracking-event {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 0;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.tracking-event:last-child { border-bottom: none; }

.tracking-event-type {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    min-width: 50px;
}

.tracking-event-type.open { color: var(--accent); }
.tracking-event-type.click { color: var(--success); }

/* ─── Preview ─────────────────────────────────────────────────────── */
.preview-variables {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.preview-var-field {
    flex: 1;
    min-width: 150px;
}

.preview-var-field label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.preview-var-field input {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.preview-frame-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.preview-frame {
    width: 100%;
    min-height: 400px;
    border: none;
    background: white;
}

/* ─── Toast Notifications ─────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    font-size: 0.85rem;
}

.toast.removing {
    animation: toastOut 0.25s ease forwards;
}

.toast-success { border-right: 4px solid var(--success); }
.toast-error { border-right: 4px solid var(--error); }
.toast-warning { border-right: 4px solid var(--warning); }
.toast-info { border-right: 4px solid var(--accent); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--accent); }

.toast-message { flex: 1; color: var(--text-primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-40px); }
}

/* ─── Skeleton Loaders ────────────────────────────────────────────── */
.skeleton-loader { padding: 0.5rem 0; }

.skeleton-row {
    height: 16px;
    background: linear-gradient(90deg, var(--bg-hover) 25%, rgba(255,255,255,0.05) 50%, var(--bg-hover) 75%);
    background-size: 400% 100%;
    border-radius: 4px;
    margin-bottom: 1rem;
    animation: skeleton 1.4s ease infinite;
}

.skeleton-row:nth-child(2) { width: 75%; }
.skeleton-row:nth-child(3) { width: 60%; }

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Alerts ──────────────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* ─── Empty State ─────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 1rem; opacity: 0.4; }
.empty-state h4 { color: var(--text-secondary); margin-bottom: 0.5rem; }

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .sidebar-title,
    .nav-item span {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 0.7rem;
        border-right: none;
        border-bottom: 2px solid transparent;
    }

    .nav-item.active {
        border-right: none;
        border-bottom-color: var(--accent);
    }

    .sidebar-header {
        justify-content: center;
        padding: 1rem 0.5rem;
    }

    .main-content {
        margin-right: var(--sidebar-collapsed);
    }
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        width: 100% !important;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-bar {
        flex-direction: column;
    }

    .filter-input, .filter-select, .filter-date {
        max-width: 100%;
    }

    .test-connection-group {
        margin-right: 0;
        flex-wrap: wrap;
    }

    .domain-results {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 1rem;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-label {
        margin-top: 0.75rem;
    }
}

@media (max-width: 640px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        right: 0;
        flex-direction: row;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .sidebar-header { display: none; }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        padding: 0;
        overflow-x: auto;
        flex: 1;
    }

    .nav-item {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.7rem;
        border-right: none;
        border-top: 2px solid transparent;
    }

    .nav-item.active {
        border-right: none;
        border-top-color: var(--accent);
    }

    .nav-item span { display: block; font-size: 0.65rem; }

    .sidebar-footer { display: none; }

    .main-content {
        margin-right: 0;
        margin-bottom: 65px;
    }
}

/* ─── Domain Check Loading ────────────────────────────────────────── */
.domain-loading {
    display: flex;
    justify-content: center;
    padding: 3rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ─── Driver Fields Transition ────────────────────────────────────── */
.driver-fields {
    animation: fadeIn 0.25s ease;
}

/* ─── Domain Management ──────────────────────────────────────────── */
.domain-info-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.2);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.domain-info-banner svg {
    flex-shrink: 0;
}

.domains-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.domain-list-item {
    padding: 1.25rem;
}

.domain-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.domain-item-info h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.domain-item-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.domain-region {
    direction: ltr;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
}

.domain-date {
    color: var(--text-muted);
}

.domain-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.domain-status-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.domain-records-instructions {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.dns-records-table {
    overflow-x: auto;
    margin-top: 0.5rem;
}

.dns-records-table .data-table th,
.dns-records-table .data-table td {
    font-size: 0.8rem;
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}

.dns-value-cell {
    white-space: normal !important;
    max-width: 280px;
}

.dns-value-wrap {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    word-break: break-all;
    background: var(--bg-input);
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 0.35rem;
    line-height: 1.5;
    max-height: 80px;
    overflow-y: auto;
}

.dns-type-badge {
    display: inline-block;
    font-family: monospace;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.btn-copy {
    display: inline-block;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-copy:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-copy.copied {
    border-color: var(--success);
    color: var(--success);
}

.modal-xl {
    max-width: 950px;
}

@media (max-width: 768px) {
    .domain-item-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .domain-item-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .domain-item-meta {
        flex-wrap: wrap;
    }
}
