/* ==========================================================================
   Unify SocialCraft — application theme
   Loaded after adminlte.css; every page-level style lives in this file.

   1.  Design tokens
   2.  Base
   3.  App shell: topbar, sidebar, content, footer
   4.  Page header & flash messages
   5.  Cards
   6.  Buttons
   7.  Forms (incl. select2, FilePond, file inputs)
   8.  Tables & DataTables
   9.  Badges, pills, empty states, pagination
   10. Dashboard
   11. Templates gallery
   12. Campaign composer (single / bulk / group mail)
   13. Chat
   14. Profile & code snippets
   15. Auth pages (login, password reset)
   16. Public pages (thank you, unsubscribe, errors)
   17. Utilities & responsive
   ========================================================================== */

/* 1. Design tokens --------------------------------------------------------- */
:root {
    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-soft: #eef2ff;
    --brand-ring: rgba(79, 70, 229, .18);

    --ink: #0f172a;
    --text: #334155;
    --muted: #64748b;
    --subtle: #94a3b8;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-alt: #f8fafc;

    --success: #16a34a;
    --success-soft: #dcfce7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --info: #0284c7;
    --info-soft: #e0f2fe;

    --sidebar-bg: #0f172a;
    --sidebar-bg-2: #111c33;
    --sidebar-text: #a5b0c4;
    --sidebar-text-strong: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active: rgba(99, 102, 241, .18);
    --sidebar-width: 256px;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --topbar-height: 60px;
}

/* 2. Base ------------------------------------------------------------------ */
html,
body,
.wrapper {
    font-size: 14px;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font);
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -.01em;
}

a {
    color: var(--brand);
}

a:hover {
    color: var(--brand-hover);
    text-decoration: none;
}

label,
.col-form-label {
    font-weight: 500;
    color: var(--ink);
    font-size: 13px;
    margin-bottom: 6px;
}

code,
pre {
    font-family: var(--font-mono);
}

::selection {
    background: var(--brand-soft);
}

.text-muted {
    color: var(--muted) !important;
}

/* The preloader and debugbar are never shown */
.preloader,
.phpdebugbar.phpdebugbar-minimized.phpdebugbar-closed {
    display: none !important;
}

/* 3. App shell -------------------------------------------------------------- */

/* Topbar */
.main-header.app-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    height: var(--topbar-height);
    padding: 0 20px 0 12px;
}

.app-topbar .nav-link {
    color: var(--muted);
    height: 40px;
    display: flex;
    align-items: center;
    border-radius: var(--radius-sm);
}

.app-topbar .nav-link:hover {
    color: var(--ink);
    background: var(--surface-alt);
}

.app-topbar__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-topbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Notification bell (Vue component) */
.app-topbar .navbar-nav .nav-link i,
.app-topbar .navbar-nav .fa-bell {
    font-size: 16px;
}

.app-topbar .navbar-badge {
    top: 6px;
    right: 4px;
    font-size: 10px;
    padding: 2px 5px;
    background: var(--danger);
    color: #fff;
}

.app-topbar .dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

/* User menu: <details> based, no JS needed */
.user-menu {
    position: relative;
}

.user-menu > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}

.user-menu > summary::-webkit-details-marker {
    display: none;
}

.user-menu > summary:hover,
.user-menu[open] > summary {
    background: var(--surface-alt);
}

.user-menu__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--surface-alt);
}

.user-menu__name {
    font-weight: 500;
    color: var(--ink);
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu__caret {
    color: var(--subtle);
    font-size: 11px;
}

.user-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 1100;
}

.user-menu__header {
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.user-menu__header strong {
    display: block;
    color: var(--ink);
}

.user-menu__header span {
    color: var(--muted);
    font-size: 12px;
}

.user-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    text-align: left;
}

.user-menu__item i {
    width: 16px;
    color: var(--subtle);
}

.user-menu__item:hover {
    background: var(--surface-alt);
    color: var(--ink);
}

.user-menu__item--danger,
.user-menu__item--danger i {
    color: var(--danger);
}

/* Sidebar */
.main-sidebar.app-sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    box-shadow: none !important;
    border-right: 1px solid rgba(255, 255, 255, .04);
}

.app-sidebar .brand-link,
.layout-navbar-fixed .wrapper .app-sidebar .brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-height);
    padding: 0 20px;
    background: #5743e2; /* brand colour behind the logo */
    border-bottom: 1px solid rgba(255, 255, 255, .06) !important;
    color: var(--sidebar-text-strong) !important;
    pointer-events: none;
}

.app-sidebar .brand-link .brand-image {
    float: none;
    margin: 0;
    max-height: 32px;
    width: 32px;
    opacity: 1;
    box-shadow: none !important;
}

.app-sidebar .brand-text {
    font-weight: 600 !important;
    font-size: 16px;
    letter-spacing: -.01em;
}

.app-sidebar .sidebar {
    padding: 12px 12px 24px;
}

.app-sidebar .nav-sidebar .nav-header {
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 18px 12px 6px;
    background: transparent;
}

.app-sidebar .nav-sidebar > .nav-item {
    margin-bottom: 2px;
}

.app-sidebar .nav-sidebar .nav-link {
    color: var(--sidebar-text) !important;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: background .15s ease, color .15s ease;
}

.app-sidebar .nav-sidebar .nav-link p {
    flex: 1;
    margin: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-sidebar .nav-sidebar .nav-link .nav-icon {
    width: 20px;
    margin-right: 12px !important;
    font-size: 15px;
    text-align: center;
    color: #7b879c;
}

.app-sidebar .nav-sidebar .nav-link .right {
    position: static;
    font-size: 11px;
    transition: transform .2s ease;
}

.app-sidebar .nav-sidebar .menu-open > .nav-link .right {
    transform: rotate(-90deg);
}

.app-sidebar .nav-sidebar .nav-link:hover {
    background: var(--sidebar-hover) !important;
    color: var(--sidebar-text-strong) !important;
}

.app-sidebar .nav-sidebar .nav-link:hover .nav-icon {
    color: var(--sidebar-text-strong);
}

.app-sidebar .nav-sidebar > .nav-item > .nav-link.active,
.app-sidebar .nav-sidebar .nav-treeview .nav-link.active {
    background: var(--sidebar-active) !important;
    color: var(--sidebar-text-strong) !important;
    box-shadow: inset 3px 0 0 #818cf8 !important;
}

.app-sidebar .nav-sidebar .nav-link.active .nav-icon {
    color: #a5b4fc;
}

.app-sidebar .nav-sidebar .menu-open > .nav-link,
.app-sidebar .nav-sidebar .menu-is-opening > .nav-link {
    background: transparent !important;
    color: var(--sidebar-text-strong) !important;
}

.app-sidebar .nav-treeview {
    padding: 2px 0 6px;
}

.app-sidebar .nav-treeview > .nav-item > .nav-link {
    padding: 7px 12px 7px 44px;
    font-size: 13.5px;
    font-weight: 400;
}

.app-sidebar .nav-treeview > .nav-item > .nav-link .nav-icon {
    display: none;
}

/* Collapsed sidebar: keep icons centred */
.sidebar-collapse .app-sidebar:not(:hover) .nav-sidebar .nav-header {
    display: none;
}

.sidebar-collapse .app-sidebar:not(:hover) .nav-sidebar .nav-link {
    justify-content: center;
    padding: 10px 0;
}

.sidebar-collapse .app-sidebar:not(:hover) .nav-sidebar .nav-link .nav-icon {
    margin-right: 0 !important;
}

.sidebar-collapse .app-sidebar:not(:hover) .brand-link {
    justify-content: center;
    padding: 0;
}

/* Content area */
.content-wrapper {
    background: var(--bg) !important;
}

.layout-navbar-fixed .wrapper .content-wrapper {
    margin-top: var(--topbar-height);
}

.content-wrapper .content {
    padding: 24px 20px 32px;
}

.content-wrapper > .content-header {
    display: none; /* replaced by <x-page-header> */
}

/* Footer */
.main-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    padding: 12px 20px;
}

.main-footer a {
    color: var(--ink) !important;
    font-weight: 500;
}

/* 4. Page header & flash messages ------------------------------------------ */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-header__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    letter-spacing: -.02em;
}

.page-header__subtitle {
    color: var(--muted);
    margin: 4px 0 0;
    font-size: 14px;
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-header__back-btn {
    background-color: #ffffff;
    border: 1px solid var(--border, #e5e7eb);
    color: var(--ink, #1f2937);
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.page-header__back-btn:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
}

.page-header__lead {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert {
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 12px 16px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

.alert .close {
    margin-left: auto;
    order: 2;
    padding: 0 0 0 12px;
    position: static;
    text-shadow: none;
    opacity: .5;
}

.alert-success {
    background: var(--success-soft);
    border-color: #bbf7d0;
    color: #14532d;
}

.alert-danger {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: #7f1d1d;
}

.alert-warning {
    background: var(--warning-soft);
    border-color: #fde68a;
    color: #78350f;
}

.alert-info {
    background: var(--info-soft);
    border-color: #bae6fd;
    color: #0c4a6e;
}

.alert__icon {
    margin-top: 2px;
}

/* 5. Cards ------------------------------------------------------------------ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm) !important;
    margin-bottom: 20px;
}

.card.shadow,
.card.shadow-lg,
.card.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
}

.card-header {
    background: transparent !important;
    color: var(--ink) !important;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header::after {
    display: none; /* AdminLTE clearfix breaks flex */
}

.card-header .card-title,
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    float: none;
}

.card-subtitle {
    color: var(--muted);
    font-size: 13px;
    margin: 2px 0 0;
}

.card-header__actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.card-body {
    padding: 20px;
}

.card-body.p-0 {
    padding: 0 !important;
}

.card-footer {
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin: 8px 0 4px;
}

.section-hint {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 12px;
}

/* 6. Buttons ---------------------------------------------------------------- */
.btn {
    font-weight: 500;
    font-size: 14px;
    border-radius: 8px;
    padding: 8px 14px;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: none !important;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn-sm {
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 6px;
}

.btn-lg {
    font-size: 15px;
    padding: 11px 18px;
}

.btn:focus,
.btn.focus {
    box-shadow: 0 0 0 3px var(--brand-ring) !important;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    color: #fff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-secondary,
.btn-light,
.btn-default,
.btn-outline {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--ink);
}

.btn-secondary:hover,
.btn-light:hover,
.btn-default:hover,
.btn-outline:hover {
    background: var(--surface-alt);
    border-color: var(--subtle);
    color: var(--ink);
}

.btn-warning {
    background: var(--warning-soft);
    border-color: #fde68a;
    color: #92400e;
}

.btn-warning:hover {
    background: #fde68a;
    color: #78350f;
}

/* Soft buttons used in table rows and toolbars */
.btn-soft-danger {
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.btn-soft-danger:hover {
    background: #fecaca;
    color: #991b1b;
}

/* Social network buttons */
.btn-social {
    color: #fff !important;
    border: 0;
}

.btn-social:hover {
    filter: brightness(.92);
}

.btn-social--facebook { background: #1877f2; }
.btn-social--twitter { background: #1d9bf0; }
.btn-social--instagram { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }

/* Square icon buttons in tables and cards */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.btn-icon:hover {
    background: var(--surface-alt);
    color: var(--ink);
    border-color: var(--border-strong);
}

.btn-icon--danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #fecaca;
}

.btn-icon--primary:hover {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: #c7d2fe;
}

.action-group {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.action-group form {
    display: inline-flex;
    margin: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

/* 7. Forms ------------------------------------------------------------------ */
.form-group {
    margin-bottom: 16px;
}

.form-control,
.custom-select,
.form-select {
    height: 40px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--ink);
    background-color: var(--surface);
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea.form-control {
    height: auto;
    min-height: 120px;
}

textarea.form-control.code-input {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.55;
    min-height: 260px;
    background: var(--surface-alt);
}

.form-control::placeholder {
    color: var(--subtle);
}

.form-control:focus,
.custom-select:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
    outline: 0;
}

.form-control.is-invalid,
.form-control.error {
    border-color: var(--danger);
    color: var(--ink);
}

.form-control.is-invalid:focus,
.form-control.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}

label.error,
label.gp.error,
.invalid-feedback {
    color: var(--danger);
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
}

.form-text,
.help-text {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.form-control-sm {
    height: 34px;
    font-size: 13px;
    padding: 5px 10px;
}

/* Native file inputs */
input[type="file"].form-control,
input[type="file"].form-control-file {
    height: auto;
    padding: 6px;
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    background: var(--surface-alt);
    font-size: 13px;
    width: 100%;
    color: var(--muted);
}

input[type="file"]::file-selector-button {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    border-radius: 6px;
    padding: 6px 12px;
    margin-right: 12px;
    font-weight: 500;
    cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
    background: var(--surface-alt);
}

.custom-file-label {
    height: 40px;
    border-radius: 8px;
    border-color: var(--border-strong);
    padding: 8px 12px;
}

.custom-file-label::after {
    height: 38px;
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
}

/* Checkboxes */
.form-check-input,
input[type="checkbox"] {
    accent-color: var(--brand);
}

table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    cursor: pointer;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
    cursor: pointer;
    margin: 0;
}

.check-row input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.check-row__label {
    font-weight: 500;
    color: var(--ink);
}

.check-row__hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

/* select2 */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--border-strong) !important;
    border-radius: 8px !important;
    min-height: 40px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
    padding-left: 12px;
    color: var(--ink);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px;
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px var(--brand-ring);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--brand-soft);
    border: 1px solid #c7d2fe;
    color: var(--brand-hover);
    border-radius: 6px;
    margin-top: 6px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    cursor: default;
    padding-left: 22px !important;
    padding-right: 0;
    color: var(--brand-hover);
}

.select2-container.error .select2-selection {
    border-color: var(--danger) !important;
}

.select2-dropdown {
    border-color: var(--border-strong);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background: var(--brand);
}

/* FilePond attachment drop zone */
.filepond--root {
    font-family: var(--font);
    font-size: 13px;
    margin-bottom: 0;
    max-height: 140px;
}

.filepond--panel-root {
    background: var(--surface-alt);
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
}

.filepond--drop-label {
    color: var(--muted);
}

.filepond--label-action {
    color: var(--brand);
    text-decoration-color: var(--brand);
}

.filepond--item {
    width: 70px !important;
    height: 60px !important;
}

/* 8. Tables & DataTables ---------------------------------------------------- */
.table {
    color: var(--text);
    margin-bottom: 0;
    font-size: 14px;
}

.table thead th,
.table thead.thead-dark th {
    background: var(--surface-alt) !important;
    color: var(--muted) !important;
    border-color: var(--border) !important;
    border-top: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 12px 16px;
    white-space: nowrap;
    text-align: left !important;
    vertical-align: middle;
}

.table td {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    vertical-align: middle;
    text-align: left;
}

.table-bordered,
.table-bordered td,
.table-bordered th {
    border-left: 0 !important;
    border-right: 0 !important;
}

.table-bordered {
    border: 0;
}

.table-striped tbody tr:nth-of-type(odd) {
    background: transparent;
}

.table tbody tr {
    transition: background .1s ease;
}

.table tbody tr:hover {
    background: var(--surface-alt);
}

.table .col-check {
    width: 44px;
}

.table .col-index {
    width: 72px;
}

.table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.table td.col-actions {
    text-align: right;
}

.table .cell-strong {
    color: var(--ink);
    font-weight: 500;
}

.table .cell-muted {
    color: var(--muted);
    font-size: 13px;
}

.table .cell-nowrap {
    white-space: nowrap;
}

.table .cell-campaign {
    min-width: 180px;
}

.table .cell-truncate {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-responsive {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Toolbar above a table (search, filters, bulk actions) */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.table-toolbar__spacer {
    flex: 1;
}

.search-field {
    position: relative;
    min-width: 260px;
    flex: 0 1 340px;
}

.search-field i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--subtle);
    font-size: 13px;
}

.search-field .form-control {
    padding-left: 34px;
    height: 36px;
}

.filter-select {
    height: 36px;
    width: auto;
    min-width: 140px;
    max-width: 220px;
    font-size: 13px;
}

/* DataTables (jQuery) */
.dataTables_wrapper {
    font-size: 13px;
    color: var(--muted);
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 0 0 14px;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    height: 34px;
    padding: 4px 10px;
    color: var(--ink);
    background: var(--surface);
    margin: 0 6px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--brand);
    outline: 0;
    box-shadow: 0 0 0 3px var(--brand-ring);
}

table.dataTable {
    border-collapse: collapse !important;
    margin: 0 !important;
}

table.dataTable thead th,
table.dataTable thead td {
    border-bottom: 1px solid var(--border) !important;
}

table.dataTable.no-footer {
    border-bottom: 1px solid var(--border) !important;
}

.dataTables_wrapper .dataTables_info {
    padding-top: 14px;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 10px;
}

.content-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    background: var(--surface) !important;
    color: var(--text) !important;
    margin-left: 4px;
    padding: 4px 10px !important;
}

.content-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.content-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #fff !important;
}

.content-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--surface-alt) !important;
    color: var(--ink) !important;
}

.content-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.content-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    opacity: .5;
    background: var(--surface) !important;
    color: var(--muted) !important;
}

/* 9. Badges, pills, empty states, pagination -------------------------------- */
.badge {
    font-weight: 500;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
}

.badge-soft,
.badge-secondary {
    background: #f1f5f9;
    color: #475569;
}

.badge-primary,
.badge-soft-primary {
    background: var(--brand-soft);
    color: var(--brand-hover);
}

.badge-success,
.badge-soft-success {
    background: var(--success-soft);
    color: #15803d;
}

.badge-danger,
.badge-soft-danger {
    background: var(--danger-soft);
    color: #b91c1c;
}

.badge-warning,
.badge-soft-warning {
    background: var(--warning-soft);
    color: #b45309;
}

.badge-info,
.badge-soft-info {
    background: var(--info-soft);
    color: #0369a1;
}

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-hover);
    font-weight: 600;
    font-size: 12px;
}

a.count-pill:hover {
    background: var(--brand);
    color: #fff;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}

.empty-state i {
    font-size: 28px;
    color: var(--subtle);
    margin-bottom: 10px;
}

.empty-state h4 {
    font-size: 15px;
    margin: 0 0 4px;
}

.empty-state p {
    margin: 0;
    font-size: 13px;
}

.pagination {
    margin: 0;
    gap: 4px;
}

.pagination .page-link {
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    color: var(--text) !important;
    background: var(--surface) !important;
    padding: 5px 11px;
    font-size: 13px;
}

.pagination .page-item.active .page-link,
.accent-light .page-item.active .page-link,
.accent-light .page-item.active a {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #fff !important;
}

.pagination .page-item.disabled .page-link {
    opacity: .5;
}

/* 10. Dashboard ------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.stat-card__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    margin: 0 0 6px;
}

.stat-card__value {
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.1;
    letter-spacing: -.02em;
    margin: 0;
}

.stat-card__hint {
    font-size: 12px;
    color: var(--subtle);
    margin-top: 6px;
}

.stat-card__icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.stat-card__icon--brand { background: var(--brand-soft); color: var(--brand); }
.stat-card__icon--success { background: var(--success-soft); color: var(--success); }
.stat-card__icon--info { background: var(--info-soft); color: var(--info); }
.stat-card__icon--warning { background: var(--warning-soft); color: var(--warning); }
.stat-card__icon--danger { background: var(--danger-soft); color: var(--danger); }

.chart-box {
    width: 100%;
    min-height: 280px;
}

/* Dashboard sections (Email / WhatsApp) */
.dash-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 14px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
}

.dash-section .fa-whatsapp {
    color: #16a34a;
}

.dash-section--row {
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.dash-section--row .dash-section {
    margin: 0;
}

/* Campaign details page */
.stat-grid--6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: -8px 0 16px;
    font-size: 13px;
}

.detail-list {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 12px 16px;
    margin: 0;
}

.detail-list dt {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.detail-list dd {
    margin: 0;
    color: var(--ink);
    word-break: break-word;
}

.email-preview {
    display: block;
    width: 100%;
    height: 560px;
    border: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: #fff;
}

.preview-tabs .btn.is-active {
    background: var(--brand-soft);
    border-color: #c7d2fe;
    color: var(--brand-hover);
}

/* Table rows that open a detail page when clicked (tr[data-href]) */
.table tbody tr.row-link {
    cursor: pointer;
}

.table tbody tr.row-link:hover .cell-strong,
.table tbody tr.row-link:hover .row-link__anchor {
    color: var(--brand);
}

.row-link__anchor {
    color: inherit;
}

/* Campaign report: status badges and row actions */
.campaign-link {
    color: var(--ink);
}

.campaign-link:hover {
    color: var(--brand);
}

.status-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.status-stack .badge {
    white-space: nowrap;
}

.row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
}

.row-actions form {
    display: inline-flex;
    margin: 0;
}

.row-actions .btn {
    white-space: nowrap;
}

.row-actions__count {
    display: inline-block;
    min-width: 18px;
    margin-left: 2px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.btn-outline-primary:hover .row-actions__count {
    background: rgba(255, 255, 255, .25);
    color: #fff;
}

.table-report th,
.table-report td {
    padding-left: 8px;
    padding-right: 8px;
}

.table-report .cell-date {
    white-space: nowrap;
}

.table-report .col-num {
    width: 1%;
    text-align: center;
    white-space: nowrap;
}

.table-report .col-num {
    padding-left: 6px;
    padding-right: 6px;
}

.table-report th.col-num {
    font-size: 10.5px;
    letter-spacing: 0;
}

.cell-meta {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.table-report .cell-campaign {
    min-width: 150px;
}

.row-actions .btn-outline-primary .row-actions__count {
    margin-left: 4px;
}

/* Campaign quick view popup */
.quickview__status {
    margin: 0 0 16px;
}

.quickview__stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.quickview__stat {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.quickview__stat span {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.quickview__stat strong {
    font-size: 18px;
    color: var(--ink);
}

.quickview__stat--success strong { color: var(--success); }
.quickview__stat--danger strong { color: var(--danger); }
.quickview__stat--info strong { color: var(--info); }
.quickview__stat--brand strong { color: var(--brand); }

.quickview__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
}

.quickview__heading {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

.detail-list--compact {
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 8px 12px;
    margin-bottom: 20px;
    font-size: 13.5px;
}

.quickview__recipients {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.quickview__recipients li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    font-size: 13px;
}

.quickview__recipients li + li {
    border-top: 1px solid var(--border);
}

.quickview__who {
    min-width: 0;
    overflow-wrap: anywhere;
}

.quickview__flags {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.quickview__preview {
    display: block;
    width: 100%;
    height: 520px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.quickview__stat small {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

.quickview__heading--spaced {
    margin-top: 20px;
}

.followup-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.followup-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}

.followup-list li + li {
    border-top: 1px solid var(--border);
}

.followup-list__no {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 12px;
    font-weight: 600;
    line-height: 24px;
    text-align: center;
}

.followup-list__main {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.followup-list__stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.quickview__loading {
    padding: 48px 0;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 991.98px) {
    .quickview__stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .quickview__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* 11. Templates gallery ----------------------------------------------------- */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.template-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

.template-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.template-card__thumb {
    aspect-ratio: 4 / 3;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.template-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.template-card__body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.template-card__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-card__actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

.template-preview-thumb {
    width: 100%;
    max-width: 220px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

/* 12. Campaign composer ----------------------------------------------------- */
.composer-card .form-group,
.composer-card [class*="col-"] > label {
    margin-top: 0;
}

.composer-card .row > [class*="col-"] {
    margin-bottom: 14px;
}

.composer-send {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.composer-send > .flex-grow-1 {
    flex: 1;
}

.recipient-row + .recipient-row {
    margin-top: 4px;
}

.recipient-remove {
    display: flex;
    align-items: flex-end;
    padding-top: 26px;
}

.composer-add {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.editor-card {
    overflow: hidden;
}

.editor-card .card-body {
    padding: 0;
}

.editor-canvas {
    height: 640px;
    width: 100%;
}

.editor-canvas--tall {
    height: calc(100vh - 300px);
    min-height: 620px;
}

/* Template picker (modal) */
.modal-content {
    border: 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.templetename {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 14px;
}

.templetselete {
    padding: 8px;
    margin-bottom: 16px;
    text-align: center;
    cursor: pointer;
}

.template-label {
    display: block;
    margin: 0;
    cursor: pointer;
}

.image-container {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface);
    border: 2px solid var(--border);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.image-container:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.image-container img,
.img-responsive {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.image-title {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    top: auto;
    margin: 0;
    padding: 4px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: rgba(15, 23, 42, .72);
    border-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 1;
}

.custom-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.custom-radio:checked + .template-label .image-container,
.template-label .custom-radio:checked ~ .image-container,
.templetselete.selected .image-container,
.selected .image-container {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}

/* Lead file picker (group mail) */
.file-container {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    background: var(--surface);
    margin-bottom: 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.file-container:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.file-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
}

.file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    margin: 8px 0 4px;
}

.file-info {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

img.excelfile,
.excelfile {
    width: 32px;
    margin: 6px 0;
}

.custom-radio:checked + .file-card,
.file-container.selected,
.file-group.selected {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--ink);
}

.file-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--success-soft);
    color: var(--success);
    font-size: 16px;
}

.thumb-picker {
    display: flex;
    gap: 14px;
    align-items: center;
}

.thumb-picker__img {
    width: 96px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

/* Template Studio (HTML editor + live preview) */
.studio {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.studio__toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}

.studio__insert {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
    font-size: 13px;
}

.studio__insert .btn {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 3px 8px;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 8px;
    background: #e9edf3;
}

.segmented__btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.segmented__btn:hover {
    color: var(--ink);
}

.segmented__btn.is-active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: var(--shadow-sm);
}

.studio__hint {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    font-size: 12.5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.studio__hint i {
    color: var(--info);
}

.studio__element {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    background: var(--brand-soft);
    border-bottom: 1px solid #c7d2fe;
}

.studio__element .badge {
    align-self: center;
}

.studio__element-field {
    flex: 1 1 220px;
    min-width: 0;
}

.studio__element-field label {
    font-size: 12px;
    margin-bottom: 2px;
}

.studio__body {
    display: grid;
    grid-template-rows: minmax(0, 1fr); /* keep each pane at the studio's height so it scrolls inside */
    height: 72vh;
    min-height: 520px;
}

.studio__body[data-mode="split"] {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.studio__body[data-mode="visual"],
.studio__body[data-mode="code"] {
    grid-template-columns: minmax(0, 1fr);
}

.studio__body[data-mode="visual"] .studio__code,
.studio__body[data-mode="code"] .studio__preview {
    display: none;
}

.studio__code {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

.studio__code .CodeMirror {
    height: 100%;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
}

.studio__code .CodeMirror-gutters {
    background: var(--surface-alt);
    border-right: 1px solid var(--border);
}

.studio__preview {
    min-width: 0;
    min-height: 0;
    background: #eef1f6;
    overflow: auto;
    padding: 16px;
}

.studio__frame-wrap {
    height: 100%;
    margin: 0 auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: max-width .2s ease;
    max-width: 100%;
}

.studio__frame-wrap.is-mobile {
    max-width: 390px;
}

.studio__frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

@media (max-width: 991.98px) {
    .studio__body[data-mode="split"] {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    }

    .studio__code {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .studio__insert {
        margin-left: 0;
    }
}

/* 13. Chat ------------------------------------------------------------------ */
.chat-card {
    max-width: 760px;
    margin: 0 auto;
}

.chat-card .card-body {
    height: 440px;
    overflow-y: auto;
    background: var(--surface-alt);
    padding: 16px;
}

.chat-card .card-body p {
    border-radius: 12px !important;
    max-width: 70%;
    display: inline-block;
    word-break: break-word;
}

.chat-card .bg-primary {
    background: var(--brand) !important;
}

.chat-card .bg-body-tertiary {
    background: var(--surface) !important;
    border: 1px solid var(--border);
    color: var(--ink);
}

.chat-composer {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.chat-composer .form-control {
    height: 42px;
}

#emoji-picker {
    display: none;
    position: absolute;
    bottom: 56px;
    left: 0;
    z-index: 1000;
    max-width: 320px;
    background: var(--surface);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

#emoji-picker span,
.emoji {
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
}

/* 14. Profile & code snippets ----------------------------------------------- */
.code-snippet {
    background: var(--ink);
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 12.5px;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0 0 12px;
}

.code-snippet code {
    color: inherit;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 500;
    width: 100%;
    text-align: left;
}

.social-link:hover {
    background: var(--surface-alt);
    color: var(--ink);
}

.social-link i {
    width: 18px;
    text-align: center;
}

.social-link .fa-facebook-f { color: #1877f2; }
.social-link .fa-google { color: #ea4335; }

.social-link__status {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
}

/* 15. Auth pages ------------------------------------------------------------ */
body.auth-page {
    background: var(--bg);
    min-height: 100vh;
    margin: 0;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

.auth-aside {
    position: relative;
    overflow: hidden;
    background: radial-gradient(1200px 600px at -10% -20%, #6366f1 0%, transparent 55%),
                radial-gradient(900px 500px at 120% 120%, #0ea5e9 0%, transparent 50%),
                var(--sidebar-bg);
    color: #e2e8f0;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-aside__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 18px;
}

.auth-aside__brand img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.auth-aside__headline {
    font-size: 34px;
    line-height: 1.2;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.02em;
    margin: 0 0 16px;
    max-width: 460px;
}

.auth-aside__lead {
    color: #cbd5e1;
    font-size: 15px;
    max-width: 440px;
    margin: 0 0 28px;
}

.auth-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 14px;
}

.auth-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #e2e8f0;
}

.auth-features i {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #c7d2fe;
    font-size: 13px;
}

.auth-aside__footer {
    color: #94a3b8;
    font-size: 13px;
}

.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: var(--surface);
}

.auth-card {
    width: 100%;
    max-width: 380px;
}

.auth-card__brand {
    display: none; /* the aside shows the brand on wide screens */
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 17px;
    color: var(--ink);
    margin-bottom: 32px;
}

.auth-card__brand img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.auth-card__title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -.02em;
}

.auth-card__subtitle {
    color: var(--muted);
    margin: 0 0 28px;
}

.auth-card .form-control {
    height: 44px;
}

.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--subtle);
    font-size: 14px;
    pointer-events: none;
}

.input-icon > .form-control {
    padding-left: 40px;
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 0 20px;
    font-size: 13px;
}

.auth-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 400;
    color: var(--text);
}

.auth-submit {
    width: 100%;
    height: 44px;
    font-size: 15px;
}

.auth-footnote {
    margin-top: 24px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* 16. Public pages (thank you, unsubscribe, errors) ------------------------- */
body.public-page *,
body.public-page *::before,
body.public-page *::after {
    box-sizing: border-box;
}

body.public-page {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: var(--font);
    background: radial-gradient(900px 500px at 50% -10%, var(--brand-soft) 0%, transparent 60%), var(--bg);
    color: var(--text);
}

.public-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    text-align: center;
}

.public-card__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 18px;
    background: var(--brand-soft);
    color: var(--brand);
}

.public-card__icon--success { background: var(--success-soft); color: var(--success); }
.public-card__icon--danger { background: var(--danger-soft); color: var(--danger); }

.public-card h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 8px;
    letter-spacing: -.02em;
}

.public-card p {
    color: var(--muted);
    margin: 0 0 24px;
    font-size: 15px;
    line-height: 1.55;
}

.public-card .code {
    font-size: 56px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -.04em;
    line-height: 1;
    margin-bottom: 12px;
}

.public-form {
    display: grid;
    gap: 12px;
    text-align: left;
}

.public-form input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 0 12px;
    font: inherit;
    color: var(--ink);
    background: var(--surface-alt);
}

.public-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.public-btn:hover {
    background: var(--brand-hover);
    color: #fff;
}

.public-btn--danger {
    background: var(--danger);
}

.public-btn--danger:hover {
    background: #b91c1c;
}

.public-btn[disabled] {
    opacity: .6;
    cursor: default;
}

.public-message {
    display: none;
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
}

.public-message.is-visible {
    display: block;
}

.public-message--success {
    background: var(--success-soft);
    color: #14532d;
}

.public-message--error {
    background: var(--danger-soft);
    color: #7f1d1d;
}

.public-footer {
    margin-top: 28px;
    font-size: 12px;
    color: var(--subtle);
}

/* In-app error page (403 for logged-in users) */
.error-state {
    max-width: 480px;
    margin: 48px auto;
    text-align: center;
}

.error-state .code {
    font-size: 64px;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -.04em;
    line-height: 1;
}

.error-state h2 {
    font-size: 20px;
    margin: 12px 0 6px;
}

.error-state p {
    color: var(--muted);
    margin-bottom: 20px;
}

/* 16b. WhatsApp ------------------------------------------------------------- */
.wa-status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 16px 18px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.wa-status__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 24px;
    background: var(--surface-alt);
    color: var(--muted);
}

.wa-status--ok .wa-status__icon {
    background: #dcfce7;
    color: #16a34a;
}

.wa-status--off {
    border-color: #fde68a;
    background: #fffbeb;
}

.wa-status__text {
    flex: 1;
    min-width: 200px;
}

.wa-status__text strong,
.wa-status__text span {
    display: block;
}

.wa-status__text span {
    font-size: 13px;
    color: var(--muted);
}

.wa-status__actions {
    display: flex;
    gap: 8px;
}

.wa-status__actions form {
    margin: 0;
}

.copy-field {
    display: flex;
    gap: 8px;
}

.copy-field .form-control {
    font-family: var(--font-mono);
    font-size: 12.5px;
    background: var(--surface-alt);
}

.copy-field .btn {
    flex-shrink: 0;
}

.wa-steps {
    margin: 0 0 16px;
    padding-left: 20px;
    font-size: 13.5px;
    color: var(--ink);
}

.wa-steps li + li {
    margin-top: 8px;
}

.wa-steps:last-child {
    margin-bottom: 0;
}

.wa-recipients {
    font-family: var(--font-mono);
    font-size: 13px;
}

.wa-preview-sticky {
    position: sticky;
    top: 76px;
}

/* Phone-style preview of a WhatsApp message */
.wa-phone {
    max-width: 380px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 24px;
    overflow: hidden;
    background: #efeae2;
    box-shadow: var(--shadow);
}

.wa-phone--inline {
    max-width: none;
    border-radius: var(--radius);
    box-shadow: none;
}

.wa-phone__bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #075e54;
    color: #fff;
}

.wa-phone__bar strong,
.wa-phone__bar span {
    display: block;
    line-height: 1.25;
}

.wa-phone__bar span {
    font-size: 12px;
    opacity: .8;
}

.wa-phone__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 18px;
}

.wa-phone__chat {
    min-height: 260px;
    padding: 18px 14px;
}

.wa-phone--inline .wa-phone__chat {
    min-height: 0;
}

.wa-phone__empty {
    margin: 90px 0 0;
    text-align: center;
    font-size: 13px;
    color: #667781;
}

.wa-bubble {
    max-width: 92%;
    padding: 6px 7px 4px;
    border-radius: 0 8px 8px 8px;
    background: #fff;
    box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
    font-size: 14px;
    line-height: 1.4;
    color: #111b21;
}

.wa-bubble__media {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    margin-bottom: 6px;
    border-radius: 6px;
    overflow: hidden;
    background: #d1d7db;
    color: #fff;
    font-size: 34px;
}

.wa-bubble__media img {
    display: block;
    width: 100%;
    height: auto;
}

.wa-bubble__header {
    padding: 2px 3px 4px;
    font-weight: 700;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.wa-bubble__body {
    padding: 0 3px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.wa-bubble__footer {
    padding: 4px 3px 0;
    font-size: 12.5px;
    color: #667781;
}

.wa-bubble__time {
    margin-top: 2px;
    text-align: right;
    font-size: 11px;
    color: #667781;
}

.wa-bubble__buttons {
    max-width: 92%;
    margin-top: 2px;
}

.wa-bubble__button {
    margin-top: 2px;
    padding: 9px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
    text-align: center;
    font-size: 14px;
    color: #027eb5;
}

/* WhatsApp media library and the picker in the campaign form */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
}

.media-tile {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.media-tile__thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 34px;
}

.media-tile__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-tile__body {
    padding: 8px 10px 10px;
}

.media-tile__name {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-tile .cell-meta {
    white-space: normal;
}

.media-tile__delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--surface);
}

.media-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}

.media-picker__tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 110px;
    padding: 6px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 26px;
    cursor: pointer;
    overflow: hidden;
}

.media-picker__tile img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
}

.media-picker__tile span {
    max-width: 100%;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-picker__tile:hover {
    border-color: #c7d2fe;
}

.media-picker__tile.is-selected {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

.media-picker__tile--add {
    border-style: dashed;
    color: var(--brand);
    font-size: 20px;
}

/* Media library picker for the email editors (public/js/media-library.js) */
.media-modal {
    position: fixed;
    inset: 0;
    z-index: 100000; /* above the Unlayer editor */
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .55);
}

.media-modal.is-open {
    display: flex;
}

.media-modal__dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 860px;
    max-height: calc(100vh - 32px);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.media-modal__header,
.media-modal__footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
}

.media-modal__header {
    border-bottom: 1px solid var(--border);
}

.media-modal__header h5 {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.media-modal__manage {
    font-size: 13px;
}

.media-modal__body {
    flex: 1;
    min-height: 200px;
    padding: 16px 18px;
    overflow-y: auto;
}

.media-modal__body .media-picker {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.media-modal__body .media-picker__tile {
    height: 130px;
}

.media-modal__body .media-picker__tile img {
    height: 90px;
}

.media-modal__footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
}

.media-modal__footer .cell-muted {
    flex: 1;
    font-size: 12.5px;
}

.media-tile__copy {
    margin-top: 8px;
}

.wa-manual > summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--brand);
}

.wa-template-text {
    max-width: 360px;
    white-space: pre-line;
    font-size: 13px;
}

/* "Send again" dropdown on a WhatsApp campaign (a <details> like the user menu) */
.resend-menu > summary.btn {
    padding: 8px 14px;
    border-radius: var(--radius);
    gap: 8px;
}

.resend-menu > summary.btn .fa-chevron-down {
    font-size: 10px;
}

/* Template builder */
.segmented__btn input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented__btn {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.tpl-examples:empty {
    display: none;
}

.tpl-examples {
    margin-bottom: 16px;
    padding: 12px 14px 4px;
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.tpl-example {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.tpl-example label {
    flex: 0 0 48px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--brand);
}

.tpl-button {
    padding: 12px 14px 0;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tpl-button__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

@media (max-width: 991.98px) {
    .wa-preview-sticky {
        position: static;
        margin-bottom: 20px;
    }
}

/* 17. Utilities & responsive ------------------------------------------------ */
.is-hidden { display: none !important; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.min-w-0 { min-width: 0; }

.scroll-hide {
    overflow-y: auto;
    max-height: 500px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.scroll-hide::-webkit-scrollbar {
    display: none;
}

.border-left-primary { border-left: 3px solid var(--brand) !important; }
.border-left-success { border-left: 3px solid var(--success) !important; }
.border-left-info { border-left: 3px solid var(--info) !important; }
.border-left-warning { border-left: 3px solid var(--warning) !important; }

@media (max-width: 1199.98px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        display: none;
    }

    .auth-card__brand {
        display: flex;
    }

    .user-menu__name {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .stat-grid,
    .stat-grid--3,
    .stat-grid--6 {
        grid-template-columns: 1fr;
    }

    .detail-list {
        grid-template-columns: 1fr;
        gap: 2px 0;
    }

    .detail-list dd {
        margin-bottom: 10px;
    }

    .content-wrapper .content {
        padding: 16px 12px 24px;
    }

    .search-field {
        min-width: 0;
        flex: 1 1 100%;
    }

    .page-header__title {
        font-size: 19px;
    }
}
