:root {
    --ink: #0d0d12;
    --paper: #f5f3ef;
    --cream: #ede9e1;
    --border: #d4cfc5;
    --accent: #1a56ff;
    --accent-light: #e8eeff;
    --accent-dark: #0033cc;
    --green: #0a7c5c;
    --green-light: #e6f5f0;
    --red: #c0392b;
    --red-light: #fdf0ef;
    --yellow: #b8860b;
    --yellow-light: #fef9e6;
    --text: #1a1a24;
    --text2: #5a5a72;
    --text3: #9a9ab0;
    --r: 10px;
    --shadow: 0 2px 12px rgba(0, 0, 0, .08), 0 1px 3px rgba(0, 0, 0, .05);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--paper);
    color: var(--text);
    font-family: 'Instrument Sans', sans-serif;
    min-height: 100vh;
    line-height: 1.5;
}

/* Grain overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: .025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 200px;
}

header {
    background: var(--ink);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid #333;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: stretch;
    gap: 0;
    height: 56px;
}

.logo {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 900;
    font-size: 1.25rem;
    letter-spacing: -.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 28px;
    border-right: 1px solid #2a2a3a;
}

.logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 6px;
}

.step-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .3px;
    border: 1px solid #2a2a3a;
    color: #888;
    transition: all .2s;
    cursor: default;
}

.step-pill.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.step-pill.done {
    background: #1a2a1a;
    border-color: #2a4a2a;
    color: #4ade80;
}

.step-arrow {
    color: #333;
    font-size: .8rem;
}

.header-right {
    display: flex;
    align-items: center;
    padding-left: 20px;
    border-left: 1px solid #2a2a3a;
    gap: 10px;
}

.auth-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .8rem;
    font-weight: 500;
}

.auth-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
}

.auth-dot.connected {
    background: #22c55e;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.wrap {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px 28px 48px;
}

/* Setup banner */
.setup-banner {
    background: var(--ink);
    color: #fff;
    border-radius: var(--r);
    padding: 0;
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid #1a1a2e;
}

.setup-banner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid #1a1a2e;
    cursor: pointer;
    user-select: none;
}

.setup-banner-header h2 {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.setup-banner-body {
    padding: 22px;
    display: none;
}

.setup-banner-body.open {
    display: block;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.step-card {
    background: #111122;
    border: 1px solid #1e1e34;
    border-radius: 8px;
    padding: 16px;
    position: relative;
}

.step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 900;
    font-size: .8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.step-card h3 {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: .88rem;
    font-weight: 700;
    color: #e8e8f5;
    margin-bottom: 6px;
}

.step-card p {
    font-size: .78rem;
    color: #8888aa;
    line-height: 1.6;
}

.step-card code {
    background: #0d0d20;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .75rem;
    color: #7eb8ff;
}

.step-card a {
    color: var(--accent);
    text-decoration: none;
}

.step-card a:hover {
    text-decoration: underline;
}

.copy-field {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #0d0d20;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    padding: 7px 10px;
    margin-top: 8px;
}

.copy-field span {
    flex: 1;
    font-family: monospace;
    font-size: .75rem;
    color: #7eb8ff;
    word-break: break-all;
}

.copy-btn {
    background: none;
    border: 1px solid #2a2a4a;
    color: #888;
    font-size: .72rem;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
}

.copy-btn:hover {
    background: #1a1a3a;
    color: #fff;
}

/* Config bar */
.config-bar {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 22px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    box-shadow: var(--shadow);
}

.config-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 200px;
}

.config-field label {
    font-size: .73rem;
    font-weight: 600;
    color: var(--text2);
    letter-spacing: .4px;
    text-transform: uppercase;
}


.config-field input {
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 9px 13px;
    font-size: .88rem;
    font-family: 'Instrument Sans', sans-serif;
    color: var(--text);
    outline: none;
    transition: all .2s;
}

.toggle-visibility {
    position: absolute;
    right: 10px;
    top: 33px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
}

.config-field input:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-connect {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .88rem;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 10px 22px;
    border-radius: 8px;
    letter-spacing: .3px;
    transition: all .2s;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(26, 86, 255, .3);
}

.btn-connect:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26, 86, 255, .4);
}

.btn-connect:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-disconnect {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .82rem;
    background: var(--red-light);
    color: var(--red);
    border: 1.5px solid #f5c6c2;
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
}

.btn-disconnect:hover {
    background: var(--red);
    color: #fff;
}

.btn-admin-link {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .78rem;
    background: rgba(26, 86, 255, .12);
    color: var(--accent);
    border: 1.5px solid rgba(26, 86, 255, .3);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    letter-spacing: .2px;
}

.btn-admin-link:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(26, 86, 255, .35);
}

/* Main layout */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
}

@media(max-width:1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--cream);
}

.card-icon {
    font-size: 1.1rem;
}

.card-title {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .92rem;
    letter-spacing: -.2px;
}

.card-body {
    padding: 20px;
}

/* Recipients */
.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 500px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    margin-bottom: 14px;
    padding-bottom: 60px;
    /* Space for dropdown in the last row */
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .83rem;
}

thead th {
    background: var(--cream);
    padding: 10px 12px;
    text-align: left;
    font-size: .71rem;
    font-weight: 700;
    color: var(--text2);
    letter-spacing: .5px;
    text-transform: uppercase;
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #f0ede8;
    transition: background .12s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: #faf9f7;
}

tbody td {
    padding: 6px 8px;
}

tbody td input {
    background: transparent;
    border: 1.5px solid transparent;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: .88rem;
    font-family: 'Instrument Sans', sans-serif;
    color: var(--text);
    outline: none;
    transition: all .15s;
    width: 100%;
    min-width: 120px;
}

tbody td input:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.del-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text3);
    padding: 4px 7px;
    border-radius: 5px;
    transition: all .15s;
    font-size: .88rem;
}

.del-btn:hover {
    color: var(--red);
    background: var(--red-light);
}

/* ══ TOOLBAR / RIBBON ══════════════════════════════════════ */
.toolbar {
    background: linear-gradient(180deg, #f9f7f4 0%, var(--cream) 100%);
    border: 1.5px solid var(--border);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tb-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
}

.tb-row + .tb-row {
    border-top: 1px solid var(--border);
    background: #faf8f5;
}

.tb-cluster {
    display: flex;
    align-items: center;
    gap: 1px;
}

/* Base button */
.tb {
    background: none;
    border: 1.5px solid transparent;
    color: var(--text2);
    cursor: pointer;
    padding: 5px 7px;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 600;
    font-family: 'Cabinet Grotesk', sans-serif;
    transition: background .12s, border-color .12s, color .12s, transform .1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
    white-space: nowrap;
    position: relative;
}

.tb svg {
    flex-shrink: 0;
    pointer-events: none;
}

.tb:hover {
    color: var(--text);
    background: #fff;
    border-color: var(--border);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
}

.tb:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Active / pressed state */
.tb.tb-active {
    color: var(--accent);
    background: var(--accent-light);
    border-color: rgba(26,86,255,.3);
}

.tb.tb-active:hover {
    background: #dce6ff;
}

/* Format buttons (B I U S) */
.tb.tb-fmt {
    min-width: 30px;
    font-size: .82rem;
}

/* Separator */
.tb-sep {
    width: 1px;
    background: var(--border);
    height: 20px;
    margin: 0 4px;
    flex-shrink: 0;
}

/* Group label */
.tb-group-label {
    font-size: .65rem;
    font-weight: 700;
    color: var(--text3);
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-right: 4px;
    white-space: nowrap;
    user-select: none;
}

/* Font/Size selects */
.tb-select {
    appearance: none;
    -webkit-appearance: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239a9ab0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 6px center;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-family: 'Instrument Sans', sans-serif;
    font-size: .78rem;
    font-weight: 500;
    padding: 4px 22px 4px 8px;
    height: 30px;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.tb-select:hover {
    border-color: #bbb;
}

.tb-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.tb-font-family {
    width: 148px;
}

.tb-font-size {
    width: 58px;
}

/* Color swatches row */
.tb-color-swatches {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Swatch button */
.tb.tb-swatch {
    width: 22px;
    height: 22px;
    min-width: 22px;
    padding: 0;
    border-radius: 5px;
    border: 2px solid rgba(0,0,0,.12);
    background: var(--sw, #ccc);
    transition: transform .12s, box-shadow .12s;
}

.tb.tb-swatch:hover {
    transform: scale(1.15) translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,.18);
    border-color: rgba(0,0,0,.25);
}

/* Clear swatch (✕ icon) */
.tb.tb-swatch-clear {
    background: #fff;
    border: 1.5px dashed var(--border);
    color: var(--text3);
}

.tb.tb-swatch-clear:hover {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-light);
}

/* Native color picker hidden inside a label */
.tb.tb-picker-btn {
    width: 22px;
    height: 22px;
    min-width: 22px;
    padding: 0;
    border-radius: 5px;
    border: 1.5px solid var(--border);
    background: linear-gradient(135deg, #f44 0%, #4f4 33%, #44f 66%, #ff4 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.tb.tb-picker-btn svg {
    opacity: 0;
    position: absolute;
}

.tb.tb-picker-btn input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: none;
    padding: 0;
}

.tb.tb-picker-btn:hover {
    transform: scale(1.15) translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,.2);
}

/* Insert buttons (icon + text) */
.tb.tb-insert {
    padding: 5px 9px;
    gap: 5px;
    border: 1.5px solid transparent;
    color: var(--text2);
    font-size: .76rem;
}

.tb.tb-insert:hover {
    color: var(--accent);
    background: var(--accent-light);
    border-color: rgba(26,86,255,.25);
}

/* Clear format button */
.tb.tb-clear {
    padding: 5px 9px;
    gap: 5px;
    font-size: .76rem;
    color: var(--text2);
}

.tb.tb-clear:hover {
    color: var(--red);
    background: var(--red-light);
    border-color: rgba(192,57,43,.2);
}

/* ══ MODAL — SHARED STYLES ════════════════════════════════ */
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-head-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .95rem;
    color: var(--text);
}

.modal-close-btn {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    color: var(--text3);
    cursor: pointer;
    font-size: .82rem;
    padding: 3px 8px;
    transition: all .15s;
    line-height: 1.4;
}

.modal-close-btn:hover {
    background: var(--red-light);
    border-color: var(--red);
    color: var(--red);
}

.modal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
}

.modal-label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text2);
    letter-spacing: .4px;
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
}

.modal-input {
    width: 100%;
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 9px 12px;
    font-size: .88rem;
    font-family: 'Instrument Sans', sans-serif;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}

.modal-input:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-light);
}

.modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--cream);
    border-radius: 0 0 12px 12px;
}

/* Primary button in modals */
.btn.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(26,86,255,.25);
}

.btn.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: 0 6px 18px rgba(26,86,255,.35);
}

/* Link / Image modal widths */
.link-modal-inner {
    max-width: 440px;
    width: 100%;
}

.img-modal-inner {
    max-width: 520px;
    width: 100%;
}

/* Image modal tabs */
.img-modal-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    background: var(--cream);
    border-radius: 8px;
    padding: 4px;
}

.img-tab {
    flex: 1;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: .8rem;
    font-weight: 600;
    font-family: 'Cabinet Grotesk', sans-serif;
    color: var(--text2);
    cursor: pointer;
    transition: all .15s;
}

.img-tab.active {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* Image drop zone in modal */
.img-drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--cream);
    margin-bottom: 10px;
}

.img-drop-zone:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* Image preview */
.img-preview-box {
    margin-top: 10px;
    padding: 10px;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    position: relative;
}

.img-preview-clear {
    display: block;
    margin: 8px auto 0;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 5px;
    padding: 3px 10px;
    font-size: .74rem;
    color: var(--red);
    cursor: pointer;
    transition: all .15s;
}

.img-preview-clear:hover {
    background: var(--red-light);
    border-color: var(--red);
}

/* URL preview auto-load */
#img-url-preview {
    margin-top: 10px;
}

/* ══ EDITOR IMAGE — selection ring & floating toolbar ══════ */

/* Ảnh đang được chọn */
#editor img.img-selected {
    outline: 2.5px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
    box-shadow: 0 0 0 4px var(--accent-light);
    cursor: default;
}

/* Floating toolbar hiện khi click ảnh */
.img-float-toolbar {
    position: absolute;
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 2px;
    background: var(--ink);
    border-radius: 8px;
    padding: 4px 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.22), 0 1px 4px rgba(0,0,0,.12);
    white-space: nowrap;
    animation: ftb-pop .14s ease-out;
}

@keyframes ftb-pop {
    from { opacity: 0; transform: translateY(4px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.img-ft-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 5px;
    color: #c8c8d8;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: .74rem;
    font-weight: 600;
    padding: 4px 8px;
    transition: background .12s, color .12s;
    line-height: 1;
    white-space: nowrap;
}

.img-ft-btn:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}

/* Nút xóa — màu đỏ nổi bật */
.img-ft-btn.img-ft-del {
    color: #ff7b72;
}

.img-ft-btn.img-ft-del:hover {
    background: rgba(255,80,80,.2);
    color: #ff4444;
}

.img-ft-sep {
    width: 1px;
    height: 16px;
    background: rgba(255,255,255,.15);
    margin: 0 2px;
    flex-shrink: 0;
}


#editor {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 0 0 8px 8px;
    min-height: 220px;
    padding: 14px 16px;
    color: var(--text);
    font-family: 'Instrument Sans', sans-serif;
    font-size: .9rem;
    line-height: 1.7;
    outline: none;
    margin-bottom: 14px;
    overflow-y: auto;
}

#editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text3);
    pointer-events: none;
}

#editor table {
    border-collapse: collapse;
    margin: 8px 0;
    width: auto;
}

#editor table td,
#editor table th {
    border: 1.5px solid var(--border);
    padding: 6px 12px;
    min-width: 80px;
}

#editor table th {
    background: var(--cream);
    font-weight: 700;
}

#editor a {
    color: var(--accent);
}

#editor img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* List styling - bullet and numbered lists in editor */
#editor ul,
#editor ol {
    margin: 10px 0 10px 20px;
    padding-left: 24px;
    line-height: 1.7;
}

#editor ul {
    list-style-type: disc;
}

#editor ol {
    list-style-type: decimal;
}

#editor li {
    margin-bottom: 6px;
}

#editor li:last-child {
    margin-bottom: 0;
}

.var-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 13px;
}

.chip {
    background: var(--accent-light);
    border: 1.5px solid #c0d0ff;
    color: var(--accent);
    font-size: .73rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
    letter-spacing: .2px;
}

.chip:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Attach */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    margin-bottom: 13px;
    background: var(--cream);
}

.drop-zone:hover,
.drop-zone.drag {
    border-color: var(--accent);
    background: var(--accent-light);
}

.drop-zone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    border: none;
    margin: 0;
    padding: 0;
}

.dz-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.dz-text {
    font-size: .8rem;
    color: var(--text2);
}

.file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 13px;
}

.fc {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 4px 10px;
    font-size: .76rem;
    color: var(--text2);
}

.fc span:first-of-type {
    cursor: pointer;
    text-decoration: none;
    transition: color .15s;
}

.fc span:first-of-type:hover {
    color: var(--accent);
    text-decoration: underline;
}

.fc button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text3);
    font-size: .85rem;
    padding: 0;
    transition: color .15s;
}

.fc button:hover {
    color: var(--red);
}

/* Right panel */
.right-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Send panel */
.send-card {
    background: var(--ink);
    border: 1px solid #1a1a2e;
    border-radius: var(--r);
    overflow: hidden;
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.send-header {
    padding: 14px 20px;
    border-bottom: 1px solid #1a1a2e;
    background: #111122;
}

.send-header h3 {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .92rem;
    color: #e8e8f5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.send-body {
    padding: 20px;
}

.send-stat {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.stat-box {
    background: #111122;
    border: 1px solid #1a1a2e;
    border-radius: 8px;
    padding: 12px 14px;
}

.stat-num {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 900;
    font-size: 1.6rem;
    color: #e8e8f5;
    line-height: 1;
}

.stat-label {
    font-size: .73rem;
    color: #8888aa;
    margin-top: 3px;
}

.send-config {
    margin-bottom: 18px;
}

.sc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #1a1a2e;
}

.sc-row:last-child {
    border-bottom: none;
}

.sc-label {
    font-size: .8rem;
    color: #8888aa;
}

.sc-val {
    font-size: .8rem;
    color: #e8e8f5;
    font-weight: 500;
}

.sc-input {
    background: #111122;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e8e8f5;
    font-family: 'Instrument Sans', sans-serif;
    font-size: .82rem;
    padding: 6px 10px;
    outline: none;
    width: 70px;
    text-align: center;
}

.sc-input:focus {
    border-color: var(--accent);
}

.btn-send {
    width: 100%;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 900;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent), #5b21b6);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 14px;
    border-radius: 9px;
    letter-spacing: .5px;
    transition: all .2s;
    box-shadow: 0 4px 20px rgba(26, 86, 255, .4);
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(26, 86, 255, .5);
}

.btn-send:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

/* Progress */
.progress-section {
    margin-top: 16px;
    display: none;
}

.progress-section.show {
    display: block;
}

.prog-label {
    font-size: .78rem;
    color: #8888aa;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.prog-bar {
    background: #1a1a2e;
    border-radius: 99px;
    height: 6px;
    overflow: hidden;
}

.prog-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), #7c3aed);
    transition: width .4s;
}

.log {
    margin-top: 12px;
    max-height: 200px;
    overflow-y: auto;
    background: #060610;
    border: 1px solid #1a1a2e;
    border-radius: 7px;
    padding: 10px 13px;
    font-family: monospace;
    font-size: .74rem;
}

.log-ok {
    color: #4ade80;
}

.log-err {
    color: #f87171;
}

.log-info {
    color: #8888aa;
}

.log-warn {
    color: #fbbf24;
}

/* Preview card */
.preview-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.preview-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--cream);
}

.ptab {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .78rem;
    color: var(--text2);
    padding: 11px 16px;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    letter-spacing: .3px;
}

.ptab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: #fff;
}

.psel-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

.psel-row label {
    font-size: .73rem;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}

.psel-row select {
    flex: 1;
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-family: 'Instrument Sans', sans-serif;
    font-size: .83rem;
    padding: 7px 11px;
    outline: none;
    margin: 0;
}

.psel-row select:focus {
    border-color: var(--accent);
}

.preview-body {
    padding: 18px;
    min-height: 300px;
    font-size: .87rem;
    line-height: 1.7;
}

.preview-body table {
    border-collapse: collapse;
    margin: 8px 0;
}

.preview-body table td,
.preview-body table th {
    border: 1.5px solid var(--border);
    padding: 6px 12px;
}

.preview-body table th {
    background: var(--cream);
    font-weight: 700;
}

.preview-body img {
    max-width: 100%;
    height: auto;
}

/* List styles — khớp với email client */
.preview-body ul,
.preview-body ol {
    padding-left: 1.6em;
    margin: 6px 0;
}
.preview-body ul {
    list-style-type: disc;
}
.preview-body ol {
    list-style-type: decimal;
}
.preview-body li {
    margin: 3px 0;
    line-height: 1.65;
}
.preview-body li ul { list-style-type: circle; }
.preview-body li li ul { list-style-type: square; }

/* Strong/italic trong preview */
.preview-body strong { font-weight: 700; }
.preview-body em     { font-style: italic; }
.preview-body u      { text-decoration: underline; }
.preview-body s      { text-decoration: line-through; }
.preview-body p      { margin: 0 0 8px; }
.preview-body blockquote {
    border-left: 3px solid var(--border);
    margin: 8px 0;
    padding-left: 12px;
    color: var(--text2);
}

.meta-row {
    margin-bottom: 12px;
}

.meta-label {
    font-size: .7rem;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 2px;
}

.meta-val {
    font-size: .87rem;
    color: var(--text);
    font-weight: 500;
}

.divider {
    border: none;
    border-top: 1.5px solid var(--border);
    margin: 14px 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Mailto list */
.ml-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.ml-item:last-child {
    border-bottom: none;
}

.sdot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text3);
    flex-shrink: 0;
}

.sdot.ok {
    background: var(--green);
}

.sdot.err {
    background: var(--red);
}

.sdot.sending {
    background: var(--accent);
    animation: pulse 1s infinite;
}

.ml-info {
    flex: 1;
    min-width: 0;
}

.ml-name {
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ml-email {
    font-size: .73rem;
    color: var(--text2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 700;
    font-size: .82rem;
    padding: 8px 16px;
    border-radius: 7px;
    transition: all .15s;
    letter-spacing: .2px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: .76rem;
    border-radius: 6px;
}

.btn-outline {
    background: #fff;
    color: var(--text2);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    color: var(--text);
    border-color: var(--accent);
}

.btn-danger {
    background: var(--red-light);
    color: var(--red);
    border: 1.5px solid #f5c6c2;
}

.btn-danger:hover {
    background: var(--red);
    color: #fff;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.btn-green {
    background: var(--green-light);
    color: var(--green);
    border: 1.5px solid #a7e8d8;
}

.btn-green:hover {
    background: var(--green);
    color: #fff;
}

/* Modal */
.modal-bg {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, .5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-bg.open {
    display: flex;
}

.modal {
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    width: 320px;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .97rem;
    margin-bottom: 16px;
    color: var(--text);
}

.modal label {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 5px;
    display: block;
}

.modal input,
.modal select {
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 9px 12px;
    font-family: 'Instrument Sans', sans-serif;
    font-size: .87rem;
    color: var(--text);
    outline: none;
    width: 100%;
    margin-bottom: 12px;
}

.modal input:focus,
.modal select:focus {
    border-color: var(--accent);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    background: var(--ink);
    color: #fff;
    border-radius: 10px;
    padding: 13px 20px;
    font-size: .85rem;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateY(80px);
    opacity: 0;
    transition: all .3s cubic-bezier(.34, 1.56, .64, 1);
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.ok {
    border-left: 4px solid #22c55e;
}

.toast.err {
    border-left: 4px solid #ef4444;
}

.toast.warn {
    border-left: 4px solid #f59e0b;
}

/* Import box */
.import-hint {
    background: var(--accent-light);
    border: 1.5px solid #c0d0ff;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 13px;
    font-size: .78rem;
    color: var(--accent);
    line-height: 1.6;
}

.import-hint code {
    background: rgba(26, 86, 255, .1);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: .74rem;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text3);
}

.badge-count {
    background: var(--accent);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

.spin {
    animation: spin .8s linear infinite;
    display: inline-block;
}

/* Tag Input System */
.tag-input-container {
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 4px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    min-height: 48px;
    cursor: text;
    transition: all .2s;
    width: 100%;
}

.tag-input-container:focus-within {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-light);
}

.tag-input-container input {
    background: transparent;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 4px;
    font-size: .88rem;
    font-family: inherit;
    color: var(--text);
    flex: 1;
    min-width: 120px;
}

.tag-chip {
    background: var(--accent);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: slideIn .2s ease-out;
}

.tag-chip-remove {
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: .8;
    transition: opacity .15s;
    margin-left: 2px;
}

.tag-chip-remove:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Suggestion Dropdown */
.suggestion-wrapper {
    position: relative;
    width: 100%;
}

/* Email cell invalid highlight */
.suggestion-wrapper input.email-invalid {
    border-color: var(--red, #e53e3e) !important;
    background: #fff5f5;
    color: #c53030;
    box-shadow: 0 0 0 2px rgba(229, 62, 62, .15);
    animation: shake-input .25s ease;
}
.suggestion-wrapper input.email-invalid:focus {
    box-shadow: 0 0 0 3px rgba(229, 62, 62, .25);
}

/* Ô thiếu dữ liệu biến — màu vàng amber */
#rb input.cell-missing {
    border-color: #f59e0b !important;
    background: #fffbeb;
    color: #92400e;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, .18);
}
#rb input.cell-missing:focus {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .3);
    outline: none;
}
#rb input.cell-missing::placeholder {
    color: #d97706;
}

@keyframes shake-input {
    0%   { transform: translateX(0); }
    25%  { transform: translateX(-4px); }
    50%  { transform: translateX(4px); }
    75%  { transform: translateX(-3px); }
    100% { transform: translateX(0); }
}

.suggestion-list {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.02);
    z-index: 10000;
    max-height: 280px;
    overflow-y: auto;
    width: max-content;
    min-width: 320px;
    max-width: 480px;
    display: none;
    animation: dropdownSlide .2s cubic-bezier(0, 0, 0.2, 1);
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.suggestion-list.show {
    display: block;
}

.suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    display: grid;
    grid-template-areas: "name source" "email source";
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    transition: all .15s;
    border-bottom: 1px solid rgba(245, 243, 239, 0.8);
    position: relative;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
    background: var(--accent-light);
}

.suggestion-item.searching {
    display: flex;
    justify-content: center;
    color: var(--text3);
    font-style: italic;
    padding: 20px;
}

.suggestion-name {
    grid-area: name;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-email {
    grid-area: email;
    font-size: .78rem;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-source {
    grid-area: source;
    align-self: center;
    font-size: .62rem;
    color: var(--text3);
    text-transform: uppercase;
    font-weight: 800;
    background: var(--paper);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: .5px;
}

/* Footer Branding */
.app-footer {
    text-align: center;
    padding: 30px 20px 40px;
    color: var(--text3);
    font-size: .85rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

.app-footer p {
    margin: 0;
}

.app-footer strong {
    color: var(--accent);
    font-weight: 600;
}

/* ── History Tab ──────────────────────────────────── */
.hist-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: .63rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 10px;
    padding: 0 4px;
    margin-left: 4px;
    vertical-align: middle;
    line-height: 1;
}

.hist-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--cream);
}

.hist-toolbar-title {
    font-size: .75rem;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* Session cards */
.hist-session-card {
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    transition: background .12s;
}

.hist-session-card:last-child { border-bottom: none; }

.hist-session-card:hover { background: #faf9f7; }

.hist-session-card.has-error {
    border-left: 3px solid var(--red);
    padding-left: 11px;
}

.hist-session-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.hist-session-info { flex: 1; min-width: 0; }

.hist-session-subj {
    font-size: .84rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.hist-session-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.hist-ts {
    font-size: .72rem;
    color: var(--text3);
}

.hist-sender {
    font-size: .72rem;
    color: var(--text2);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hist-session-stats {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-shrink: 0;
}

.hist-stat {
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
}

.ok-stat {
    background: var(--green-light);
    color: var(--green);
}

.err-stat {
    background: var(--red-light);
    color: var(--red);
}

.hist-session-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.hist-total {
    font-size: .72rem;
    color: var(--text3);
}

.hist-retry-btn {
    background: var(--red-light);
    color: var(--red);
    border: 1.5px solid #f5c6c2;
    font-size: .72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.hist-retry-btn:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* History detail modal */
.hist-modal-inner {
    width: min(560px, 95vw);
    padding: 0;
    overflow: hidden;
}

.hist-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--cream);
}

.hist-modal-title {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .95rem;
    color: var(--text);
    margin-bottom: 4px;
    word-break: break-word;
}

.hist-modal-meta {
    font-size: .75rem;
    color: var(--text2);
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.hist-modal-foot {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--cream);
    display: flex;
    justify-content: flex-end;
}

/* Per-row result rows in modal */
.hm-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-bottom: 1px solid #f0ede8;
    transition: background .1s;
}

.hm-row:last-child { border-bottom: none; }

.hm-row:hover { background: #faf9f7; }

.hm-ok { border-left: 3px solid var(--green); }
.hm-err { border-left: 3px solid var(--red); }

.hm-status-icon {
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.hm-ok .hm-status-icon { color: var(--green); }
.hm-err .hm-status-icon { color: var(--red); }

.hm-row-info { flex: 1; min-width: 0; }

.hm-row-name {
    font-size: .83rem;
    font-weight: 600;
    color: var(--text);
}

.hm-row-email {
    font-size: .75rem;
    color: var(--text2);
}

.hm-row-error {
    font-size: .72rem;
    color: var(--red);
    margin-top: 2px;
    font-style: italic;
    word-break: break-word;
}

.hm-row-subj {
    font-size: .73rem;
    color: var(--text2);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── History modal tabs ── */
.hm-tabs {
    display: flex;
    border-bottom: 1.5px solid var(--border);
    background: var(--cream);
    padding: 0 12px;
    gap: 2px;
}

.hm-tab {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .78rem;
    color: var(--text2);
    padding: 10px 14px;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    letter-spacing: .2px;
    margin-bottom: -1.5px;
}

.hm-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: #fff;
    border-radius: 6px 6px 0 0;
}

.hm-tab:hover:not(.active) { color: var(--text); background: rgba(0,0,0,.04); border-radius: 6px 6px 0 0; }

.hm-panel { display: block; }

/* ── History content tab ── */
.hm-content-meta {
    background: var(--cream);
    border-bottom: 1px solid var(--border);
    padding: 10px 18px 6px;
    font-size: .8rem;
    color: var(--text2);
}

.hm-content-row {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
    align-items: baseline;
}

.hm-content-label {
    font-weight: 700;
    color: var(--text);
    min-width: 80px;
    font-size: .78rem;
}

.hm-content-note {
    font-style: italic;
    font-size: .74rem;
    color: var(--text3);
    margin-top: 2px;
}

/* ── Inline stat badges trong history modal header ── */
.hist-badge-ok {
    font-size: .74rem;
    font-weight: 700;
    color: #059669;
    background: #d1fae5;
    padding: 2px 7px;
    border-radius: 20px;
}

.hist-badge-err {
    font-size: .74rem;
    font-weight: 700;
    color: #dc2626;
    background: #fee2e2;
    padding: 2px 7px;
    border-radius: 20px;
}

/* ── Admin per-row delete button ── */
.tbl-row-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1.5px solid transparent;
    background: none;
    color: var(--text3);
    font-size: .75rem;
    cursor: pointer;
    transition: all .15s;
    padding: 0;
}

.tbl-row-del:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ── Admin "xóa theo user" button ── */
.tbl-btn-user {
    background: #f5f3ff;
    color: #7c3aed;
    border: 1.5px solid #ddd6fe;
    border-radius: 7px;
    padding: 6px 12px;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
}
.tbl-btn-user:hover {
    background: #ede9fe;
    border-color: #c4b5fd;
}

/* ═══════════════════════════════════════════════════
   NEW UI OVERHAUL — v2 components
═══════════════════════════════════════════════════ */

/* ── page-wrap alias ── */
.page-wrap {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px 28px 48px;
}

/* ── New header step nav ── */
.step-nav {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 16px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    color: #666;
    border: 1px solid #2a2a3a;
    cursor: default;
    transition: all .2s;
    white-space: nowrap;
}

.step-item.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.step-item.done {
    background: #1a2a1a;
    border-color: #2a4a2a;
    color: #4ade80;
}

.step-num {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .68rem;
    font-weight: 800;
    flex-shrink: 0;
}

.step-item.active .step-num { background: rgba(255,255,255,.25); }
.step-item.done .step-num   { background: rgba(74,222,128,.25); color: #4ade80; }

.step-label { font-size: .73rem; }

.step-line {
    width: 24px;
    height: 1px;
    background: #2a2a3a;
    flex-shrink: 0;
}

/* ── New header right ── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 20px;
    border-left: 1px solid #2a2a3a;
}

.auth-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .78rem;
    font-weight: 500;
    color: #bbb;
    background: rgba(255,255,255,.05);
    border: 1px solid #2a2a3a;
    border-radius: 20px;
    padding: 5px 12px;
}

.btn-header-admin {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .75rem;
    background: rgba(26,86,255,.15);
    color: #7eb8ff;
    border: 1px solid rgba(26,86,255,.3);
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
}
.btn-header-admin:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-header-logout {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .75rem;
    background: rgba(192,57,43,.15);
    color: #f87171;
    border: 1px solid rgba(192,57,43,.3);
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
}
.btn-header-logout:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ── Left column ── */
.left-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Card header new layout ── */
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--cream);
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-header-right { display: flex; align-items: center; gap: 8px; }

.card-step-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 900;
    font-size: .82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(26,86,255,.35);
}

.card-subtitle {
    font-size: .72rem;
    color: var(--text3);
    margin-top: 1px;
}

.card-subtitle code {
    background: var(--accent-light);
    color: var(--accent);
    padding: 0 4px;
    border-radius: 3px;
    font-size: .7rem;
}

.count-pill {
    background: var(--ink);
    color: #fff;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .78rem;
    padding: 3px 10px;
    border-radius: 20px;
    min-width: 28px;
    text-align: center;
}

/* ── Card toolbar ── */
.card-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: #fdfcfa;
}

.tbtn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1.5px solid var(--border);
    color: var(--text2);
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 600;
    font-size: .78rem;
    padding: 6px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.tbtn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.tbtn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.tbtn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* Accent (biến) — tím nhạt */
.tbtn-accent {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}
.tbtn-accent:hover { background: #6d28d9; border-color: #6d28d9; color: #fff; }

/* Nhóm input + button liền nhau */
.tbtn-group {
    display: inline-flex;
    align-items: stretch;
}
.tbtn-group .tbtn {
    border-radius: 0 7px 7px 0;
    border-left: none;
}
.tbtn-group .tbtn:hover {
    border-left: none;
}

/* Input số (thêm dòng) */
.tbtn-number-input {
    width: 56px;
    padding: 0 6px;
    font-family: 'Instrument Sans', sans-serif;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text1);
    background: #fff;
    border: 1.5px solid var(--border);
    border-right: none;
    border-radius: 7px 0 0 7px;
    text-align: center;
    transition: border-color .15s;
    outline: none;
    /* Ẩn spinner mặc định */
    -moz-appearance: textfield;
}
.tbtn-number-input::-webkit-outer-spin-button,
.tbtn-number-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tbtn-number-input:focus { border-color: var(--accent); }

/* Input text (tên biến) */
.tbtn-text-input {
    width: 120px;
    padding: 0 10px;
    font-family: 'Instrument Sans', sans-serif;
    font-size: .78rem;
    color: var(--text1);
    background: #fff;
    border: 1.5px solid var(--border);
    border-right: none;
    border-radius: 7px 0 0 7px;
    transition: border-color .15s;
    outline: none;
}
.tbtn-text-input::placeholder { color: var(--text3); font-style: italic; }
.tbtn-text-input:focus { border-color: #7c3aed; }

.tbtn-danger-sm {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--red-light);
    border: 1.5px solid #f5c6c2;
    color: var(--red);
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 600;
    font-size: .73rem;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s;
}
.tbtn-danger-sm:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ── Variable hint bar ── */
.var-hint {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent-light);
    border-bottom: 1px solid #c0d0ff;
    font-size: .75rem;
    color: var(--accent);
}

.var-hint-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-size: .7rem;
    flex-shrink: 0;
}

.var-chips-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

/* ── Compose body ── */
.compose-body { padding: 20px; }

.field-group { margin-bottom: 14px; }

.field-label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .45px;
    margin-bottom: 6px;
}

.field-input {
    width: 100%;
    background: var(--cream);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .88rem;
    font-family: 'Instrument Sans', sans-serif;
    color: var(--text);
    outline: none;
    transition: all .2s;
}
.field-input:focus {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* ── Attach section ── */
.attach-section { margin-top: 20px; }

.dz-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    gap: 6px;
}

.dz-text {
    font-size: .8rem;
    color: var(--text2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-align: center;
}
.dz-text strong { color: var(--text); }
.dz-text span { font-size: .73rem; color: var(--text3); }

/* ── Send card new styles ── */
.send-header {
    padding: 18px 20px;
    border-bottom: 1px solid #1a1a2e;
    background: linear-gradient(135deg, #111122 0%, #0d0d20 100%);
}

.send-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.send-header-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.send-title {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 900;
    font-size: 1rem;
    color: #e8e8f5;
    letter-spacing: -.2px;
}

.send-subtitle {
    font-size: .75rem;
    color: #6666aa;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

/* ── Send stats ── */
.send-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

/* ── Config section in send card ── */
.config-section { margin-bottom: 18px; }

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #1a1a2e;
    gap: 10px;
}
.config-row:last-child { border-bottom: none; }

.config-label {
    font-size: .78rem;
    color: #8888aa;
    flex-shrink: 0;
}

.config-val {
    font-size: .8rem;
    color: #e8e8f5;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.delay-input {
    background: #111122;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e8e8f5;
    font-family: 'Instrument Sans', sans-serif;
    font-size: .82rem;
    padding: 6px 10px;
    outline: none;
    width: 68px;
    text-align: center;
}
.delay-input:focus { border-color: var(--accent); }

/* ── Send button ── */
.btn-send {
    width: 100%;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 900;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--accent) 0%, #5b21b6 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 14px 20px;
    border-radius: 10px;
    letter-spacing: .4px;
    transition: all .25s;
    box-shadow: 0 4px 20px rgba(26,86,255,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}
.btn-send:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(26,86,255,.55);
}
.btn-send:disabled { opacity: .35; cursor: not-allowed; transform: none; }

.send-btn-icon { font-size: 1.15rem; }

/* ── Quick action row ── */
.quick-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.qa-btn {
    flex: 1;
    min-width: 80px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #111122;
    border: 1px solid #2a2a4a;
    color: #8888aa;
    font-family: 'Instrument Sans', sans-serif;
    font-weight: 600;
    font-size: .74rem;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.qa-btn:hover           { border-color: #4a4a7a; color: #ccc; background: #1a1a2e; }
.qa-btn.qa-green:hover  { border-color: var(--green); color: #4ade80; background: rgba(10,124,92,.15); }
.qa-btn.qa-red:hover    { border-color: var(--red); color: #f87171; background: rgba(192,57,43,.15); }

/* ── Progress section ── */
.prog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .78rem;
    color: #8888aa;
    margin-bottom: 8px;
}

.prog-pct {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    color: var(--accent);
    font-size: .82rem;
}

/* ── Preview tabs ── */
.ptab {
    background: none;
    border: none;
    cursor: pointer;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .76rem;
    color: var(--text2);
    padding: 11px 14px;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    letter-spacing: .2px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ── Empty states ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    gap: 8px;
    min-height: 200px;
}

.empty-icon { font-size: 2.2rem; opacity: .5; }

.empty-title {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .88rem;
    color: var(--text2);
    margin-top: 4px;
}

.empty-desc {
    font-size: .78rem;
    color: var(--text3);
    max-width: 240px;
    line-height: 1.6;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
    .main-grid { grid-template-columns: 1fr; }
    .step-label { display: none; }
    .step-line { width: 12px; }
}

@media (max-width: 640px) {
    .page-wrap { padding: 16px 14px 40px; }
    .send-stats { grid-template-columns: 1fr 1fr; }
    .quick-actions { gap: 4px; }
    .qa-btn { font-size: .7rem; padding: 7px 8px; }
    .header-inner { padding: 0 14px; }
    .step-nav { display: none; }
}

/* ═══════════════════════════════════════════
   VARIABLE INSERT PANEL
═══════════════════════════════════════════ */

/* Subject label row — label + chips on same line */
.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.field-label-row .field-label { margin-bottom: 0; }

/* Mini chips next to subject label */
.subj-var-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.subj-var-chip {
    background: var(--accent-light);
    border: 1.5px solid rgba(26,86,255,.2);
    color: var(--accent);
    font-family: 'Instrument Sans', monospace;
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
    letter-spacing: .2px;
}
.subj-var-chip:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(26,86,255,.25);
}
.subj-var-chip:active { transform: translateY(0); }

/* Editor wrapper — positions autocomplete */
.editor-wrap {
    position: relative;
}

/* ── Quick-insert panel ── */
.var-panel {
    border: 1.5px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: linear-gradient(135deg, #fdfcfa 0%, var(--accent-light) 100%);
    padding: 10px 14px 12px;
    margin-top: 0;
}

.var-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.var-panel-title {
    font-size: .72rem;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.var-panel-hint {
    font-size: .7rem;
    color: var(--text3);
}

.var-panel-hint kbd {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 4px;
    font-size: .68rem;
    font-family: monospace;
    color: var(--text2);
}

.var-panel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Panel chips — bigger and more prominent than header chips */
.vp-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1.5px solid rgba(26,86,255,.25);
    color: var(--accent);
    font-family: monospace;
    font-size: .78rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .18s cubic-bezier(.34,1.56,.64,1);
    user-select: none;
    letter-spacing: .3px;
    box-shadow: 0 1px 4px rgba(26,86,255,.08);
}
.vp-chip::before {
    content: '⌥';
    font-size: .65rem;
    opacity: .5;
    font-family: sans-serif;
}
.vp-chip:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 18px rgba(26,86,255,.3);
}
.vp-chip:active {
    transform: translateY(0) scale(.98);
}
/* flash animation when chip is clicked */
@keyframes chipFlash {
    0%   { background: var(--accent); color: #fff; }
    100% { background: #fff; color: var(--accent); }
}
.vp-chip.flashing {
    animation: chipFlash .35s ease-out forwards reverse;
}

/* ── Autocomplete dropdown (triggered by {{ ) ── */
.var-autocomplete {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 14px;
    z-index: 9990;
    background: #fff;
    border: 1.5px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(26,86,255,.18), 0 2px 8px rgba(0,0,0,.08);
    min-width: 200px;
    display: none;
    overflow: hidden;
    animation: dropdownSlide .18s ease-out;
}
.var-autocomplete.open { display: block; }

.vac-header {
    background: var(--accent-light);
    padding: 7px 13px;
    font-size: .7rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid rgba(26,86,255,.15);
}

.vac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    cursor: pointer;
    transition: background .1s;
    border-bottom: 1px solid #f0ede8;
}
.vac-item:last-child { border-bottom: none; }
.vac-item:hover, .vac-item.vac-selected { background: var(--accent-light); }

.vac-var {
    font-family: monospace;
    font-size: .82rem;
    font-weight: 700;
    color: var(--accent);
    background: rgba(26,86,255,.1);
    padding: 2px 7px;
    border-radius: 5px;
    letter-spacing: .3px;
}

.vac-desc {
    font-size: .75rem;
    color: var(--text2);
}

/* ══ PRE-SEND VALIDATION MODAL ════════════════════════════════ */
.pre-send-modal-inner {
    width: 520px;
    max-width: calc(100vw - 40px);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    overflow: hidden;
}

.psm-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--cream);
}

.psm-head-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.psm-head-icon.has-error { background: var(--red-light); }
.psm-head-icon.warn-only { background: var(--yellow-light); }
.psm-head-icon.info-only { background: var(--green-light); }

.psm-head-text { flex: 1; }
.psm-head-title {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: -.2px;
}
.psm-head-sub {
    font-size: .78rem;
    color: var(--text2);
    margin-top: 2px;
}

.psm-body {
    padding: 18px 22px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.psm-issue {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid;
    animation: psmSlideIn .2s ease-out both;
}

@keyframes psmSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.psm-issue.psm-error {
    background: var(--red-light);
    border-color: #f5c6c2;
}
.psm-issue.psm-warn {
    background: var(--yellow-light);
    border-color: #f0d890;
}
.psm-issue.psm-info {
    background: var(--green-light);
    border-color: #a8dece;
}

.psm-issue-icon {
    font-size: 1rem;
    line-height: 1.5;
    flex-shrink: 0;
}

.psm-issue-body { flex: 1; min-width: 0; }

.psm-issue-title {
    font-weight: 700;
    font-size: .83rem;
    color: var(--text);
    margin-bottom: 2px;
}
.psm-issue.psm-error .psm-issue-title { color: var(--red); }
.psm-issue.psm-warn  .psm-issue-title { color: #7a5c00; }
.psm-issue.psm-info  .psm-issue-title { color: var(--green); }

.psm-issue-detail {
    font-size: .78rem;
    color: var(--text2);
    line-height: 1.5;
}
.psm-issue-detail code {
    font-family: monospace;
    background: rgba(0,0,0,.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: .76rem;
}

.psm-badge {
    font-size: .68rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
    letter-spacing: .3px;
    text-transform: uppercase;
    display: inline-block;
    margin-bottom: 4px;
}
.psm-error .psm-badge { background: var(--red); color: #fff; }
.psm-warn  .psm-badge { background: #c8940a; color: #fff; }
.psm-info  .psm-badge { background: var(--green); color: #fff; }

.psm-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    background: #faf9f7;
}

.psm-btn-cancel {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .84rem;
    background: var(--cream);
    border: 1.5px solid var(--border);
    color: var(--text2);
    padding: 9px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
}
.psm-btn-cancel:hover {
    background: var(--border);
    color: var(--text);
}

.psm-btn-proceed {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .84rem;
    background: var(--accent);
    border: none;
    color: #fff;
    padding: 9px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 4px 14px rgba(26,86,255,.3);
}
.psm-btn-proceed:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(26,86,255,.4);
}
.psm-btn-proceed:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.psm-summary-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.psm-summary-chip {
    font-size: .73rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.psm-summary-chip.err  { background: var(--red-light);    color: var(--red);   border: 1px solid #f5c6c2; }
.psm-summary-chip.warn { background: var(--yellow-light);  color: #7a5c00;      border: 1px solid #f0d890; }
.psm-summary-chip.info { background: var(--green-light);   color: var(--green); border: 1px solid #a8dece; }

/* Retry log style */
.log-retry {
    color: #b8860b;
    font-style: italic;
    font-size: .8rem;
    padding-left: 4px;
}

/* ══ FILE MODE TOGGLE (Attach vs OneDrive) ══════════════════════ */

/* File chip khi ở chế độ OneDrive */
.fc.fc-onedrive {
    background: #eef4ff;
    border-color: rgba(26, 86, 255, .2);
}

/* Toggle button base */
.fc-mode-btn {
    font-family: 'Instrument Sans', sans-serif;
    font-size: .72rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1.5px solid;
    line-height: 1.5;
}

/* Chế độ Đính kèm (mặc định) */
.fc-mode-attach {
    background: var(--cream);
    border-color: var(--border);
    color: var(--text2);
}
.fc-mode-attach:hover {
    background: var(--accent-light);
    border-color: rgba(26, 86, 255, .3);
    color: var(--accent);
}

/* Chế độ OneDrive */
.fc-mode-od {
    background: var(--accent-light);
    border-color: rgba(26, 86, 255, .3);
    color: var(--accent);
}
.fc-mode-od:hover {
    background: #dce6ff;
    border-color: rgba(26, 86, 255, .5);
    color: var(--accent-dark);
}

/* Log upload progress */
.log-upload {
    color: var(--accent);
    font-size: .8rem;
    padding-left: 4px;
}

/* ══ RESUME BANNER ══════════════════════════════════════════════ */
#resume-banner {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-bottom: 2px solid #f59e0b;
    position: sticky;
    top: 56px; /* below header */
    z-index: 500;
    animation: resumeSlideDown .3s ease-out;
}

@keyframes resumeSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.resume-banner-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 12px 28px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.resume-banner-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    animation: pulse 2s infinite;
}

.resume-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.resume-banner-text strong {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: .9rem;
    font-weight: 800;
    color: #92400e;
}

.resume-banner-text span {
    font-size: .8rem;
    color: #78350f;
}

.resume-banner-meta {
    font-size: .75rem !important;
    color: #a16207 !important;
    font-style: italic;
}

.resume-banner-warn {
    color: #b45309 !important;
    font-weight: 600 !important;
    font-size: .77rem !important;
    background: rgba(245, 158, 11, .15);
    padding: 3px 8px;
    border-radius: 4px;
    border-left: 3px solid #f59e0b;
    margin-top: 2px;
}

.resume-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.resume-btn-proceed {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 800;
    font-size: .84rem;
    background: #f59e0b;
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(245, 158, 11, .4);
}
.resume-btn-proceed:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, .5);
}

.resume-btn-discard {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 700;
    font-size: .82rem;
    background: rgba(0,0,0,.06);
    color: #78350f;
    border: 1.5px solid rgba(0,0,0,.12);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.resume-btn-discard:hover {
    background: rgba(0,0,0,.12);
    color: #451a03;
}
