/* ── MailerApp — Clean Professional Theme ── */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
    --white:   #ffffff;
    --bg:      #f5f6fa;
    --bg2:     #eef0f6;
    --card:    #ffffff;
    --border:  #e4e6ef;
    --border2: #c8cbda;
    --text:    #111827;
    --text2:   #6b7280;
    --text3:   #9ca3af;
    --accent:  #2563eb;
    --accent2: #1d4ed8;
    --accent-light: #eff6ff;
    --green:   #16a34a;
    --green-bg:#dcfce7;
    --red:     #dc2626;
    --red-bg:  #fee2e2;
    --amber:   #d97706;
    --amber-bg:#fef3c7;
    --radius:  10px;
    --radius-sm: 6px;
    --shadow:  0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
    --shadow-md: 0 4px 24px rgba(0,0,0,.10);
    --sidebar-w: 240px;
    --header-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── LAYOUT ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transition: transform .2s;
}

.sidebar-brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    font-family: 'Instrument Serif', serif;
    font-size: 20px;
    color: var(--text);
    letter-spacing: -.3px;
}

.sidebar-brand .brand-icon {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text3);
    padding: 8px 10px 4px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text2);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: 2px;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 14px 10px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
}

.sidebar-user:hover { background: var(--bg); }

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); text-transform: capitalize; }

/* ── MAIN CONTENT ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    height: var(--header-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky; top: 0; z-index: 40;
}

.top-bar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.top-bar-right { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 28px; flex: 1; }

/* ── CARDS ── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 20px; }

/* ── STAT CARDS ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow .15s, transform .15s;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: var(--accent-light); }
.stat-icon.green  { background: var(--green-bg); }
.stat-icon.red    { background: var(--red-bg); }
.stat-icon.amber  { background: var(--amber-bg); }

.stat-info .stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-info .stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled)  { background: var(--accent2); border-color: var(--accent2); }
.btn-outline  { background: #fff; color: var(--text2); border-color: var(--border2); }
.btn-outline:hover:not(:disabled)  { background: var(--bg); color: var(--text); border-color: var(--border2); }
.btn-danger   { background: var(--red-bg); color: var(--red); border-color: rgba(220,38,38,.2); }
.btn-danger:hover:not(:disabled)   { background: #fca5a5; }
.btn-success  { background: var(--green-bg); color: var(--green); border-color: rgba(22,163,74,.2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-gray   { background: var(--bg2); color: var(--text2); }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text2);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #fafafa 60%, #f0f9ff 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .logo-icon {
    width: 52px; height: 52px;
    background: var(--accent);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px;
    color: #fff;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-family: 'Instrument Serif', serif;
    font-size: 26px;
    color: var(--text);
    letter-spacing: -.3px;
}

.login-logo p { font-size: 13px; color: var(--text2); margin-top: 4px; }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-danger  { background: var(--red-bg);   color: var(--red);   border: 1px solid rgba(220,38,38,.2); }
.alert-success { background: var(--green-bg);  color: var(--green); border: 1px solid rgba(22,163,74,.2); }
.alert-info    { background: var(--accent-light); color: var(--accent); border: 1px solid rgba(37,99,235,.2); }

/* ── TAGS INPUT ── */
.tag-input-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    min-height: 42px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    background: var(--white);
    cursor: text;
    transition: border-color .15s, box-shadow .15s;
}
.tag-input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.rec-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--accent-light);
    border: 1px solid rgba(37,99,235,.2);
    border-radius: 20px;
    font-size: 12px;
    color: var(--accent);
    font-family: 'DM Mono', monospace;
}
.rec-tag .remove-tag { cursor: pointer; color: var(--text3); transition: color .1s; }
.rec-tag .remove-tag:hover { color: var(--red); }
#tagRealInput {
    border: none; outline: none;
    font-size: 13px; min-width: 180px;
    padding: 2px 4px; flex: 1;
    background: transparent;
    font-family: 'DM Mono', monospace;
    color: var(--text);
}

/* ── EDITOR ── */
.editor-toolbar {
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 6px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    align-items: center;
}
.tb-btn {
    width: 28px; height: 26px;
    background: none; border: none;
    border-radius: 4px; cursor: pointer;
    font-size: 12px; font-weight: 700;
    color: var(--text2);
    display: flex; align-items: center; justify-content: center;
    transition: all .1s;
}
.tb-btn:hover { background: var(--border); color: var(--text); }
.tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }
.toolbar-select {
    height: 26px; font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 4px; padding: 0 4px;
    outline: none; background: var(--white);
    font-family: inherit; cursor: pointer;
}
.toolbar-color { width: 28px; height: 26px; border: none; padding: 2px; cursor: pointer; border-radius: 4px; background: none; }
#emailBody {
    min-height: 300px;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 16px 18px;
    font-size: 14px; line-height: 1.8;
    outline: none; color: var(--text);
    background: var(--white);
}
#emailBody:empty:before { content: attr(data-placeholder); color: var(--text3); pointer-events: none; }

/* ── TEMPLATES ── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.template-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all .18s;
    background: var(--white);
}
.template-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.template-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.template-preview { height: 180px; overflow: hidden; position: relative; }
.template-preview iframe { width: 100%; height: 360px; border: none; transform: scale(.5); transform-origin: top left; pointer-events: none; }
.template-info { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.template-name { font-size: 13px; font-weight: 600; }

/* ── SENDER PILLS ── */
.sender-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border: 1.5px solid var(--border);
    border-radius: 50px; cursor: pointer;
    font-size: 12px; font-weight: 500;
    color: var(--text2); background: var(--bg);
    transition: all .15s; margin: 3px 3px 3px 0;
}
.sender-pill.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.sender-pill .pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .6; }

/* ── DRAFT LIST ── */
.draft-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background .12s;
}
.draft-item:hover { background: var(--bg); }
.draft-item:last-child { border-bottom: none; }
.draft-subject { font-size: 13px; font-weight: 600; flex: 1; }
.draft-date { font-size: 11px; color: var(--text3); white-space: nowrap; }

/* ── ATTACH ── */
.attach-drop {
    border: 2px dashed var(--border2);
    border-radius: var(--radius);
    padding: 18px; text-align: center;
    color: var(--text3); font-size: 13px;
    cursor: pointer; transition: all .15s; background: var(--bg);
}
.attach-drop:hover, .attach-drop.drag-over { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.attach-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 6px;
}
.attach-item .ai-name { flex: 1; font-size: 12px; font-family: 'DM Mono', monospace; }
.attach-item .ai-size { font-size: 11px; color: var(--text3); }

/* ── PROGRESS ── */
.progress { height: 5px; background: var(--bg2); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; width: 0; }

/* ── MODAL ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 200; display: flex;
    align-items: center; justify-content: center;
    padding: 20px; opacity: 0; pointer-events: none;
    transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
    background: var(--white);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    width: 100%; max-width: 680px;
    max-height: 90vh; display: flex; flex-direction: column;
    transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── TOAST ── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--text); color: #fff;
    padding: 11px 16px; border-radius: var(--radius);
    font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
    box-shadow: var(--shadow-md);
    transform: translateX(120%); transition: transform .25s;
    max-width: 320px;
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--accent); }

/* ── MISC ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 15px; font-weight: 700; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════
   v2 ADDITIONS — Scheduling, Tracking, Cron
═══════════════════════════════════════════ */

/* ── DATETIME INPUT ── */
input[type="datetime-local"].form-control {
    color-scheme: light;
    cursor: pointer;
}

/* ── NOTIFY TOGGLE ── */
.notify-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--accent-light);
    border: 1px solid rgba(37,99,235,.15);
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.notify-toggle:hover { background: #dbeafe; }
.notify-toggle input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── SPAM SCORE MODAL ── */
.spam-score-ring {
    width: 80px; height: 80px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    margin: 0 auto 12px;
    font-weight: 700;
}
.spam-issue-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.spam-issue-item:last-child { border-bottom: none; }
.spam-issue-icon { flex-shrink: 0; font-size: 14px; margin-top: 1px; }
.spam-pass-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 13px;
    color: var(--green);
}

/* ── CRON STATUS PAGE ── */
.cron-terminal {
    background: #0f172a;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 16px;
    max-height: 420px;
    overflow-y: auto;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    line-height: 1.8;
}
.cron-terminal .log-line-ok     { color: #4ade80; }
.cron-terminal .log-line-error  { color: #f87171; }
.cron-terminal .log-line-info   { color: #60a5fa; }
.cron-terminal .log-line-muted  { color: #94a3b8; }

.cron-setup-field {
    display: grid;
    grid-template-columns: 110px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}
.cron-setup-field label { color: var(--text2); font-weight: 600; }
.cron-setup-field code {
    background: var(--bg2);
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--accent);
}

.cron-url-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    word-break: break-all;
    color: var(--accent);
    margin-top: 8px;
}

/* ── SCHEDULED EMAIL QUEUE ── */
.scheduled-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.scheduled-item:last-child { border-bottom: none; }
.scheduled-time {
    font-size: 11px;
    color: var(--text2);
    font-family: 'DM Mono', monospace;
    white-space: nowrap;
}

/* ── OPEN TRACKING BADGE in history ── */
.opens-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--green-bg);
    color: var(--green);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.clicks-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

/* ── RESEND BUTTON ── */
.btn-resend {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(22,163,74,.2);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background .15s;
}
.btn-resend:hover { background: #bbf7d0; }

/* ── RECEIPT TEMPLATE STYLES (inside editor) ── */
#emailBody table { border-collapse: collapse; width: 100%; }
#emailBody th, #emailBody td { border: 1px solid var(--border); padding: 8px 12px; }
#emailBody th { background: var(--bg); font-weight: 600; }
#emailBody tfoot td { background: var(--accent-light); font-weight: 700; color: var(--accent); }

/* ── DASHBOARD CRON WIDGET ── */
.cron-widget-preview {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text2);
    line-height: 1.8;
    max-height: 120px;
    overflow: hidden;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

/* ── SCHEDULE FIELD HIGHLIGHT ── */
#scheduledAt:not(:placeholder-shown) {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

/* ── ALERT VARIANTS ── */
.alert-warning {
    background: var(--amber-bg);
    color: var(--amber);
    border: 1px solid rgba(217,119,6,.2);
}

/* ── CODE INLINE ── */
code {
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    background: var(--bg2);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

/* ── TRACKING PIXEL HIDDEN ── */
img[width="1"][height="1"] { display: none !important; }

/* ── MODAL LARGE ── */
.modal-box.modal-xl { max-width: 900px; }
.modal-box.modal-sm { max-width: 400px; }

/* ── FORM INLINE GROUP ── */
.form-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-inline .form-control { flex: 1; }

/* ── STATUS DOT ANIMATION ── */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}
.status-dot-live {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse-dot 1.8s ease-in-out infinite;
    margin-right: 4px;
}

/* ── RESPONSIVE UPDATES ── */
@media (max-width: 768px) {
    .cron-setup-field { grid-template-columns: 80px 1fr; }
    .modal-box.modal-xl { max-width: 100%; }
    #scheduledAt { font-size: 12px; }
}

/* ═══════════════════════════════════════════
   FULL MOBILE RESPONSIVE — All Breakpoints
═══════════════════════════════════════════ */

/* ── SIDEBAR OVERLAY ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 49;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {

    /* ── LAYOUT ── */
    .app-layout { flex-direction: column; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 50;
        width: 260px;
        min-width: 260px;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }
    .main-content { margin-left: 0 !important; width: 100%; }

    /* ── TOP BAR ── */
    .top-bar { padding: 0 16px; }
    .top-bar-title { font-size: 14px; }
    #sidebarToggle { display: flex !important; }

    /* ── PAGE BODY ── */
    .page-body { padding: 16px; }

    /* ── STAT GRID ── */
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
    .stat-card { padding: 14px; gap: 10px; }
    .stat-icon { width: 38px; height: 38px; font-size: 18px; border-radius: 10px; }
    .stat-info .stat-value { font-size: 22px; }
    .stat-info .stat-label { font-size: 11px; }

    /* ── DASHBOARD GRID ── */
    div[style*="grid-template-columns:1fr 1fr"] { display: block !important; }
    div[style*="grid-template-columns: 1fr 1fr"] { display: block !important; }

    /* ── MAILER COMPOSER ── */
    div[style*="grid-template-columns:260px 1fr"] { display: block !important; }
    div[style*="grid-template-columns: 260px 1fr"] { display: block !important; }

    /* ── FORMS ── */
    .form-row { grid-template-columns: 1fr !important; gap: 0; }
    .form-control { font-size: 16px; } /* Prevents iOS zoom */

    /* ── CARDS ── */
    .card { border-radius: 8px; }
    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }
    .card-title { font-size: 13px; }

    /* ── TABLES ── */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; }
    thead th { font-size: 10px; padding: 8px 10px; }
    tbody td { font-size: 12px; padding: 10px; }

    /* ── BUTTONS ── */
    .btn { padding: 7px 12px; font-size: 12px; }
    .btn-lg { padding: 12px 20px; font-size: 14px; }
    .btn-block { width: 100%; justify-content: center; }

    /* ── EDITOR ── */
    .editor-toolbar { gap: 1px; padding: 5px 6px; overflow-x: auto; flex-wrap: nowrap; }
    .tb-btn { width: 26px; height: 26px; font-size: 11px; flex-shrink: 0; }
    .toolbar-select { height: 26px; font-size: 11px; flex-shrink: 0; }
    #emailBody { min-height: 200px; padding: 12px; font-size: 14px; }

    /* ── TAG INPUT ── */
    .tag-input-wrap { min-height: 40px; }
    #tagRealInput { min-width: 140px; font-size: 13px; }

    /* ── SENDER PILLS ── */
    .sender-pill { font-size: 11px; padding: 5px 10px 5px 8px; }

    /* ── MODAL ── */
    .modal-overlay { padding: 10px; align-items: flex-end; }
    .modal-box { max-width: 100% !important; border-radius: 14px 14px 0 0; max-height: 92vh; }
    .modal-head { padding: 14px 16px; }
    .modal-body { padding: 16px; }
    .modal-foot { padding: 12px 16px; }

    /* ── PREVIEW MODAL ── */
    #pvIframe { min-height: 360px !important; }

    /* ── TEMPLATE GRID ── */
    .template-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .template-card .template-info { padding: 8px 10px; flex-direction: column; align-items: flex-start; gap: 6px; }
    .template-name { font-size: 12px; }
    .template-preview { height: 130px; }

    /* ── HISTORY PAGE ── */
    .badge { font-size: 10px; padding: 2px 6px; }

    /* ── DASHBOARD SPECIFIC ── */
    div[style*="grid-template-columns:1fr 340px"] { display: block !important; }
    div[style*="grid-template-columns: 1fr 340px"] { display: block !important; }

    /* ── LOGIN ── */
    .login-card { padding: 28px 20px; }
    .login-logo h1 { font-size: 22px; }

    /* ── USERS PAGE ── */
    div[style*="grid-template-columns:1fr 340px"],
    div[style*="grid-template-columns: 1fr 340px"] { display: block !important; }

    /* ── SECTION HEADER ── */
    .section-header { flex-wrap: wrap; gap: 8px; }
    .section-header .btn { font-size: 11px; padding: 5px 8px; }

    /* ── ATTACH ── */
    .attach-drop { padding: 14px; font-size: 12px; }
    .attach-item { flex-wrap: wrap; }
    .attach-item .ai-name { min-width: 0; word-break: break-all; }

    /* ── CRON STATUS ── */
    .cron-setup-field { grid-template-columns: 80px 1fr; }
    .cron-terminal { font-size: 11px; max-height: 280px; }

    /* ── TOAST ── */
    .toast-wrap { bottom: 12px; right: 12px; left: 12px; }
    .toast { max-width: 100%; }

    /* ── FOOTER TABCODE ── */
    div[style*="text-align:center;padding:10px 20px;border-top"] {
        padding: 10px 16px !important;
        font-size: 10px !important;
    }
}

/* ── SMALL PHONES ── */
@media (max-width: 380px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-info .stat-value { font-size: 18px; }
    .template-grid { grid-template-columns: 1fr; }
    .hero-actions { flex-direction: column; }
    .page-body { padding: 12px; }
}

/* ── TABLET ── */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { width: 200px; min-width: 200px; }
    .main-content { margin-left: 200px; }
    --sidebar-w: 200px;
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .page-body { padding: 20px; }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── COMPOSER GRID MOBILE ── */
@media (max-width: 768px) {
    .composer-grid {
        grid-template-columns: 1fr !important;
    }
    .composer-grid > div:first-child {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .composer-grid > div:first-child > .card:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .composer-grid > div:first-child {
        grid-template-columns: 1fr;
    }
}

/* ── DASHBOARD GRID MOBILE ── */
@media (max-width: 768px) {
    .dash-grid {
        grid-template-columns: 1fr !important;
    }
}