:root {
    --mf-primary: #4f46e5;
    --mf-primary-dark: #3730a3;
    --mf-primary-soft: #eef2ff;
    --mf-secondary: #0f766e;
    --mf-bg: #f5f7fb;
    --mf-surface: #ffffff;
    --mf-surface-soft: #f8fafc;
    --mf-text: #172033;
    --mf-text-muted: #526174;
    --mf-border: #e2e8f0;
    --mf-sidebar: #f8fafc;
    --mf-sidebar-soft: #eef2ff;
    --mf-success: #087f5b;
    --mf-success-soft: #ecfdf5;
    --mf-warning: #a15c00;
    --mf-warning-soft: #fff7e6;
    --mf-danger: #c62828;
    --mf-danger-soft: #fff1f2;
    --mf-info: #075f9c;
    --mf-info-soft: #eaf6ff;
    --mf-radius-sm: 10px;
    --mf-radius: 16px;
    --mf-radius-lg: 22px;
    --mf-shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .04);
    --mf-shadow: 0 18px 45px rgba(15, 23, 42, .09);
    --mf-sidebar-width: 272px;
    --mf-transition: 180ms ease;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

html {
    font-size: 16px;
}

body {
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    color: var(--mf-text);
    background: var(--mf-bg);
    font-family: "Noto Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.app-page .text-secondary,
.app-page .text-muted {
    color: var(--mf-text-muted) !important;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: var(--mf-primary);
    text-underline-offset: 3px;
}

a:hover {
    color: var(--mf-primary-dark);
}

:focus-visible {
    outline: 3px solid rgba(79, 70, 229, .32) !important;
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    z-index: 2000;
    top: 12px;
    left: 12px;
    padding: 10px 16px;
    color: #fff;
    background: var(--mf-primary-dark);
    border-radius: 8px;
    transform: translateY(-160%);
    transition: transform var(--mf-transition);
}

.skip-link:focus {
    color: #fff;
    transform: translateY(0);
}

.min-w-0 {
    min-width: 0;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--mf-primary);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.btn {
    min-height: 44px;
    padding: .58rem 1rem;
    border-radius: var(--mf-radius-sm);
    font-weight: 600;
    transition: background-color var(--mf-transition), border-color var(--mf-transition), color var(--mf-transition), box-shadow var(--mf-transition), transform var(--mf-transition);
    touch-action: manipulation;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-primary {
    --bs-btn-bg: var(--mf-primary);
    --bs-btn-border-color: var(--mf-primary);
    --bs-btn-hover-bg: var(--mf-primary-dark);
    --bs-btn-hover-border-color: var(--mf-primary-dark);
    --bs-btn-active-bg: var(--mf-primary-dark);
    --bs-btn-active-border-color: var(--mf-primary-dark);
    --bs-btn-disabled-bg: #8b86dd;
    --bs-btn-disabled-border-color: #8b86dd;
    box-shadow: 0 7px 16px rgba(79, 70, 229, .17);
}

.btn-outline-primary {
    --bs-btn-color: var(--mf-primary);
    --bs-btn-border-color: #a5b4fc;
    --bs-btn-hover-bg: var(--mf-primary-soft);
    --bs-btn-hover-border-color: var(--mf-primary);
    --bs-btn-hover-color: var(--mf-primary-dark);
    --bs-btn-active-bg: #e0e7ff;
    --bs-btn-active-border-color: var(--mf-primary);
    --bs-btn-active-color: var(--mf-primary-dark);
}

.btn-light,
.btn-soft {
    color: #334155;
    background: var(--mf-surface-soft);
    border-color: var(--mf-border);
    box-shadow: none;
}

.btn-light:hover,
.btn-soft:hover {
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
    border-color: #c7d2fe;
}

.btn-link {
    padding-inline: 8px;
    color: var(--mf-primary);
    text-decoration: none;
}

.btn-sm {
    min-height: 36px;
    padding: .38rem .7rem;
    font-size: .8125rem;
}

.btn-icon {
    display: inline-grid;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    place-items: center;
    color: #475569;
    background: transparent;
    border: 1px solid transparent;
}

.btn-icon:hover {
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-color: #d8ddff;
}

.btn-icon.btn-sm {
    width: 38px;
    height: 38px;
    min-height: 38px;
}

.form-label {
    margin-bottom: 7px;
    color: #334155;
    font-size: .875rem;
    font-weight: 600;
}

.form-control,
.form-select {
    min-height: 44px;
    color: var(--mf-text);
    background-color: #fff;
    border-color: #cbd5e1;
    border-radius: var(--mf-radius-sm);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .025);
}

.form-control:hover,
.form-select:hover {
    border-color: #a9b5c6;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 .23rem rgba(79, 70, 229, .14);
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-control[readonly] {
    color: #475569;
    background-color: #f8fafc;
}

.form-control-color {
    min-width: 48px;
    padding: 5px;
}

.form-text {
    margin-top: 6px;
    color: var(--mf-text-muted);
    font-size: .8125rem;
}

.form-check-input {
    width: 1.15em;
    height: 1.15em;
    margin-top: .18em;
}

.form-check-input:checked {
    background-color: var(--mf-primary);
    border-color: var(--mf-primary);
}

.dropdown-menu {
    padding: 8px;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
}

.dropdown-item {
    min-height: 40px;
    padding: 9px 11px;
    border-radius: 8px;
    font-size: .875rem;
}

.dropdown-item:active {
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
}

.modal-content {
    border: 0;
    border-radius: 18px;
    box-shadow: var(--mf-shadow);
}

.modal-header,
.modal-footer {
    padding: 20px 24px;
    border-color: var(--mf-border);
}

.modal-body {
    padding: 24px;
}

.toast {
    border: 0;
    border-radius: 14px;
    box-shadow: var(--mf-shadow);
}

/* App frame */
.app-sidebar {
    --bs-offcanvas-width: var(--mf-sidebar-width);
    color: #334155;
    background: var(--mf-sidebar);
    border: 0 !important;
    border-right: 1px solid var(--mf-border) !important;
}

.sidebar-mobile-header {
    min-height: 72px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--mf-border);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 24px 18px;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--mf-text);
    font-size: 1.22rem;
    font-weight: 700;
    text-decoration: none;
}

.brand-lockup:hover {
    color: var(--mf-primary-dark);
}

.brand-lockup-light,
.brand-lockup-light:hover {
    color: #fff;
}

.brand-mark {
    display: inline-grid;
    width: 40px;
    height: 40px;
    color: #fff;
    background: linear-gradient(135deg, #8179ff, #4f46e5 55%, #0d9488);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, .34);
    place-items: center;
}

.brand-mark i {
    font-size: 1.18rem;
}

.workspace-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    margin: 30px 0 24px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .04);
}

.workspace-avatar {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    color: #fff;
    background: #0f766e;
    border-radius: 10px;
    font-weight: 700;
    place-items: center;
}

.workspace-label,
.workspace-name {
    display: block;
}

.workspace-label {
    color: var(--mf-text-muted);
    font-size: .75rem;
}

.workspace-name {
    max-width: 120px;
    color: var(--mf-text);
    font-size: .875rem;
    font-weight: 600;
}

.workspace-chip > .bi {
    color: #64748b;
}

.nav-section-label {
    display: block;
    margin: 0 12px 8px;
    color: var(--mf-text-muted);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: grid;
    gap: 5px;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 46px;
    gap: 12px;
    padding: 10px 13px;
    color: #475569;
    border-radius: 11px;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--mf-transition), background-color var(--mf-transition);
}

.sidebar-link i {
    width: 22px;
    font-size: 1.05rem;
    color: #64748b;
    text-align: center;
}

.sidebar-link:hover {
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
}

.sidebar-link:hover i {
    color: var(--mf-primary);
}

.sidebar-link.active {
    color: #fff;
    background: linear-gradient(90deg, #4f46e5, #4338ca);
    box-shadow: 0 8px 20px rgba(79, 70, 229, .22);
}

.sidebar-link.active i,
.sidebar-link.active:hover,
.sidebar-link.active:hover i {
    color: #fff;
}

.sidebar-link.active::before {
    position: absolute;
    left: -18px;
    width: 4px;
    height: 24px;
    background: #a5b4fc;
    border-radius: 0 6px 6px 0;
    content: "";
}

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
}

.app-topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    gap: 16px;
    padding: 12px 22px;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid rgba(226, 232, 240, .9);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.topbar-title {
    max-width: 44vw;
    margin: 0;
    font-size: 1.13rem;
    font-weight: 700;
}

.app-topbar .eyebrow {
    font-size: .7rem;
}

.notification-dot {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 8px;
    height: 8px;
    background: #dc2626;
    border: 2px solid #fff;
    border-radius: 50%;
}

.demo-badge {
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    color: #6b4e00;
    background: #fff7d6;
    border: 1px solid #f5dc83;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
}

.profile-button {
    display: flex;
    align-items: center;
    min-height: 48px;
    gap: 10px;
    padding: 4px 6px;
    color: var(--mf-text);
    background: transparent;
    border: 0;
    border-radius: 12px;
}

.profile-button:hover {
    background: var(--mf-surface-soft);
}

.profile-avatar {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    color: #fff;
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    border-radius: 11px;
    font-weight: 700;
    place-items: center;
}

.profile-copy {
    max-width: 145px;
    text-align: left;
}

.profile-copy strong,
.profile-copy small {
    display: block;
}

.profile-copy strong {
    font-size: .8125rem;
}

.profile-copy small {
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.app-content {
    width: 100%;
    max-width: 1640px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

/* Shared page blocks */
.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-heading h2 {
    margin: 0;
    font-size: clamp(1.45rem, 2.5vw, 2rem);
    font-weight: 700;
    letter-spacing: -.02em;
}

.page-heading p:last-child {
    margin: 6px 0 0;
    color: var(--mf-text-muted);
    font-size: .9375rem;
}

.page-actions,
.builder-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.panel {
    background: var(--mf-surface);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius);
    box-shadow: var(--mf-shadow-sm);
}

.panel-header,
.panel-toolbar,
.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
}

.panel-header,
.panel-toolbar {
    border-bottom: 1px solid var(--mf-border);
}

.panel-header > div:first-child,
.panel-toolbar > div:first-child {
    min-width: 0;
}

.panel-footer {
    border-top: 1px solid var(--mf-border);
}

.panel h3,
.section-heading-row h3,
.builder-preview h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    display: flex;
    align-items: flex-start;
    min-width: 0;
    gap: 14px;
    padding: 20px;
    background: var(--mf-surface);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius);
    box-shadow: var(--mf-shadow-sm);
}

.metric-icon {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 12px;
    font-size: 1.16rem;
    place-items: center;
}

.metric-icon-blue { color: #1d4ed8; background: #eff6ff; }
.metric-icon-violet { color: #6d28d9; background: #f5f3ff; }
.metric-icon-green { color: var(--mf-success); background: var(--mf-success-soft); }
.metric-icon-amber { color: var(--mf-warning); background: var(--mf-warning-soft); }
.metric-icon-red { color: var(--mf-danger); background: var(--mf-danger-soft); }

.metric-copy {
    min-width: 0;
}

.metric-copy > span,
.metric-copy > strong,
.metric-copy > small {
    display: block;
}

.metric-copy > span {
    color: var(--mf-text-muted);
    font-size: .8125rem;
}

.metric-copy > strong {
    margin: 3px 0 2px;
    font-size: 1.6rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
}

.metric-copy > small {
    color: var(--mf-text-muted);
    font-size: .75rem;
}

.trend-up {
    color: var(--mf-success) !important;
}

.mini-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.mini-stat {
    display: flex;
    min-height: 106px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 13px;
}

.mini-stat span {
    color: var(--mf-text-muted);
    font-size: .8125rem;
}

.mini-stat strong {
    line-height: 1.2;
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}

.mini-stat small {
    color: var(--mf-text-muted);
    font-size: .75rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, .7fr);
    gap: 20px;
}

.chart-panel,
.health-panel {
    min-height: 370px;
}

.period-select {
    width: 100px;
}

.chart-summary {
    margin: 17px 22px 0;
    color: var(--mf-text-muted);
    font-size: .8125rem;
}

.bar-chart {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    align-items: end;
    height: 270px;
    gap: clamp(8px, 2.2vw, 26px);
    padding: 24px 28px 18px;
}

.bar-column {
    display: grid;
    grid-template-rows: 22px 1fr 24px;
    height: 100%;
    gap: 6px;
    text-align: center;
}

.bar-value {
    color: var(--mf-text-muted);
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
}

.bar-track {
    position: relative;
    align-self: stretch;
    overflow: hidden;
    background: #f1f5f9;
    border-radius: 8px 8px 4px 4px;
}

.bar-fill {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: var(--bar-height);
    background: linear-gradient(180deg, #818cf8, var(--mf-primary));
    border-radius: 7px 7px 3px 3px;
}

.bar-label {
    color: var(--mf-text-muted);
    font-size: .78rem;
    font-weight: 600;
}

.delivery-ring {
    display: grid;
    width: 155px;
    height: 155px;
    margin: 22px auto 18px;
    background: conic-gradient(var(--mf-success) 0 var(--delivery-rate, 0%), #e7edf3 var(--delivery-rate, 0%) 100%);
    border-radius: 50%;
    place-items: center;
}

.delivery-ring::before {
    grid-area: 1 / 1;
    width: 120px;
    height: 120px;
    background: #fff;
    border-radius: 50%;
    content: "";
}

.delivery-ring > div {
    z-index: 1;
    grid-area: 1 / 1;
    text-align: center;
}

.delivery-ring strong,
.delivery-ring span {
    display: block;
}

.delivery-ring strong {
    font-size: 1.45rem;
    font-variant-numeric: tabular-nums;
}

.delivery-ring span {
    color: var(--mf-text-muted);
    font-size: .78rem;
}

.health-panel {
    padding-bottom: 18px;
}

.health-panel > .btn {
    width: calc(100% - 40px) !important;
    margin: 0 20px;
}

.health-list {
    display: grid;
    gap: 8px;
    margin: 0 20px 18px;
}

.health-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--mf-text-muted);
    font-size: .8125rem;
}

.health-list dt {
    font-weight: 500;
}

.health-list dd {
    margin: 0;
    color: var(--mf-text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
}

/* Tables and states */
.app-table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: #fafbff;
    min-width: 860px;
}

.app-table > :not(caption) > * > * {
    padding: 14px 18px;
    border-bottom-color: #edf1f5;
}

.app-table thead th {
    color: #64748b;
    background: #f8fafc;
    border-bottom-width: 1px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .025em;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-table tbody td {
    font-size: .875rem;
}

.app-table tbody td > strong + small,
.app-table tbody td > span > strong + small {
    display: block;
    margin-top: 3px;
    color: var(--mf-text-muted);
    font-size: .72rem;
    font-weight: 400;
}

.number-cell {
    font-variant-numeric: tabular-nums;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-success { color: #076747; background: var(--mf-success-soft); border-color: #b9ecd7; }
.status-warning { color: #875000; background: var(--mf-warning-soft); border-color: #f4d99e; }
.status-danger { color: #ad1f2d; background: var(--mf-danger-soft); border-color: #fecdd3; }
.status-info { color: #075985; background: var(--mf-info-soft); border-color: #bae6fd; }
.status-neutral { color: #526172; background: #f1f5f9; border-color: #dce3eb; }

.empty-state,
.empty-page {
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    min-height: 250px;
    padding: 40px 24px;
    color: var(--mf-text-muted);
}

.empty-state.compact {
    min-height: 160px;
    padding-block: 28px;
}

.empty-state-icon,
.empty-page-icon {
    display: grid;
    width: 68px;
    height: 68px;
    margin-bottom: 15px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 20px;
    font-size: 1.6rem;
    place-items: center;
}

.empty-state h4,
.empty-page h2 {
    margin: 0 0 6px;
    color: var(--mf-text);
    font-size: 1.15rem;
    font-weight: 700;
}

.empty-state p,
.empty-page p {
    max-width: 520px;
    margin: 0 0 18px;
    text-align: center;
}

.empty-page {
    min-height: calc(100dvh - 150px);
}

.pagination {
    gap: 4px;
}

.page-link {
    display: grid;
    min-width: 34px;
    min-height: 34px;
    padding: 4px 8px;
    color: #475569;
    border-color: var(--mf-border);
    border-radius: 8px !important;
    place-items: center;
}

.active > .page-link,
.page-link.active {
    background: var(--mf-primary);
    border-color: var(--mf-primary);
}

.filter-bar,
.filter-grid {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-bar .form-select {
    width: 145px;
}

.search-input {
    position: relative;
}

.search-input > i {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 13px;
    color: #8492a6;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-input .form-control {
    min-width: 235px;
    padding-left: 39px;
}

/* Contacts */
.checkbox-cell {
    width: 48px;
    text-align: center;
}

.contacts-table {
    min-width: 1080px;
}

.bulk-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    min-height: 56px;
    padding: 8px 18px;
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
    border-bottom: 1px solid #d9ddff;
    font-size: .8rem;
}

.person-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.person-avatar {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    color: #3730a3;
    background: #e0e7ff;
    border-radius: 11px;
    font-weight: 700;
    place-items: center;
}

.person-avatar-small {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 9px;
}

.person-cell strong,
.person-cell small {
    display: block;
}

.person-cell small {
    color: var(--mf-text-muted);
    font-size: .7rem;
}

.tag-list {
    display: flex;
    max-width: 220px;
    gap: 5px;
    flex-wrap: wrap;
}

.contact-tag {
    padding: 3px 7px;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: .72rem;
    white-space: nowrap;
}

.source-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    white-space: nowrap;
}

.upload-dropzone {
    padding: 24px;
    text-align: center;
    background: #fafbff;
    border: 1px dashed #aeb9ca;
    border-radius: 14px;
}

.upload-dropzone > i {
    display: block;
    margin-bottom: 8px;
    color: var(--mf-primary);
    font-size: 2rem;
}

.upload-dropzone label {
    display: block;
    margin-bottom: 3px;
}

.upload-dropzone p {
    color: var(--mf-text-muted);
    font-size: .74rem;
}

/* Templates */
.starter-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    gap: 24px;
    margin-bottom: 30px;
    padding: 25px 28px;
    color: #fff;
    background: linear-gradient(115deg, #312e81, #4f46e5 58%, #0f766e 135%);
    border-radius: var(--mf-radius-lg);
    box-shadow: 0 16px 40px rgba(49, 46, 129, .18);
}

.starter-banner::after {
    position: absolute;
    top: -70px;
    right: 13%;
    width: 190px;
    height: 190px;
    background: rgba(255, 255, 255, .09);
    border-radius: 50%;
    content: "";
}

.starter-copy {
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 17px;
}

.starter-icon {
    display: grid;
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    background: rgba(255, 255, 255, .13);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 16px;
    font-size: 1.3rem;
    place-items: center;
}

.starter-banner .eyebrow {
    color: #c7d2fe;
}

.starter-banner h3 {
    margin: 0;
    font-size: 1.2rem;
}

.starter-banner p:last-child {
    margin: 4px 0 0;
    color: #d9def0;
    font-size: .82rem;
}

.starter-banner .btn {
    z-index: 1;
    flex: 0 0 auto;
}

.section-heading-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.section-heading-row p {
    margin: 4px 0 0;
    color: var(--mf-text-muted);
    font-size: .82rem;
}

.compact-search .form-control {
    min-width: 260px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.template-card {
    overflow: hidden;
    color: var(--mf-text);
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius);
    box-shadow: var(--mf-shadow-sm);
    text-decoration: none;
    transition: transform var(--mf-transition), box-shadow var(--mf-transition), border-color var(--mf-transition);
}

.template-card:hover {
    color: var(--mf-text);
    border-color: #bdc7ff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .1);
    transform: translateY(-2px);
}

.template-thumb {
    position: relative;
    height: 250px;
    overflow: hidden;
    padding: 18px 44px 0;
    background: #e9edf4;
}

.template-thumb-promotion { background: #f3e8ff; }
.template-thumb-welcome { background: #e0f2fe; }

.thumb-browser {
    display: flex;
    height: 18px;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
}

.thumb-browser i {
    width: 4px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 50%;
}

.thumb-email {
    display: flex;
    align-items: center;
    flex-direction: column;
    height: 235px;
    padding: 16px 20px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(15, 23, 42, .09);
}

.thumb-logo { width: 52px; height: 8px; margin-bottom: 12px; background: #c7d2fe; border-radius: 3px; }
.thumb-hero { width: 100%; height: 64px; margin-bottom: 13px; background: linear-gradient(120deg, #4f46e5, #818cf8); border-radius: 6px; }
.template-thumb-promotion .thumb-hero { background: linear-gradient(120deg, #7e22ce, #c084fc); }
.template-thumb-welcome .thumb-hero { background: linear-gradient(120deg, #0369a1, #38bdf8); }
.thumb-heading { width: 68%; height: 8px; margin-bottom: 9px; background: #334155; border-radius: 3px; }
.thumb-line { width: 88%; height: 5px; margin-bottom: 5px; background: #dbe2ea; border-radius: 3px; }
.thumb-line.short { width: 64%; }
.thumb-button { width: 64px; height: 19px; margin-top: 9px; background: #4f46e5; border-radius: 4px; }

.template-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    background: rgba(15, 23, 42, .52);
    opacity: 0;
    transition: opacity var(--mf-transition);
    place-items: center;
}

.template-card:hover .template-overlay,
.template-card:focus-within .template-overlay {
    opacity: 1;
}

.template-card-body {
    padding: 16px 18px;
}

.template-card-body h4 {
    margin: 0;
    font-size: .94rem;
    font-weight: 700;
}

.template-card-body p {
    max-width: 280px;
    margin: 4px 0 0;
    color: var(--mf-text-muted);
    font-size: .78rem;
    line-height: 1.55;
}

.template-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    color: var(--mf-text-muted);
    border-top: 1px solid #edf1f5;
    font-size: .75rem;
}

.template-add-card {
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    min-height: 347px;
    padding: 28px;
    background: rgba(255, 255, 255, .55);
    border: 1px dashed #aeb8ca;
    box-shadow: none;
    text-align: center;
}

.template-add-card > span {
    display: grid;
    width: 52px;
    height: 52px;
    margin-bottom: 13px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 15px;
    font-size: 1.2rem;
    place-items: center;
}

.template-add-card small {
    margin-top: 4px;
    color: var(--mf-text-muted);
}

/* Template builder */
.builder-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.builder-title-group {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.builder-title-group h2 {
    max-width: 48vw;
    margin: 0;
    overflow: hidden;
    font-size: 1.25rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.autosave-state {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.builder-layout {
    display: grid;
    grid-template-columns: minmax(420px, .88fr) minmax(500px, 1.12fr);
    align-items: start;
    gap: 20px;
}

.builder-editor,
.builder-preview {
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius);
    box-shadow: var(--mf-shadow-sm);
}

.builder-editor {
    max-height: calc(100dvh - 130px);
    overflow-y: auto;
}

.builder-section {
    padding: 22px;
    border-bottom: 1px solid var(--mf-border);
}

.builder-section:last-child {
    border-bottom: 0;
}

.builder-section-heading,
.form-panel-heading {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 18px;
}

.builder-section-heading h3,
.form-panel-heading h3 {
    margin: 0;
    font-size: .98rem;
    font-weight: 700;
}

.builder-section-heading p,
.form-panel-heading p {
    margin: 2px 0 0;
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.step-number,
.form-panel-heading > span:first-child {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
    border-radius: 8px;
    font-size: .74rem;
    font-weight: 700;
    place-items: center;
}

.starter-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.starter-option {
    position: relative;
    display: block;
    padding: 9px;
    cursor: pointer;
    border: 1px solid var(--mf-border);
    border-radius: 11px;
    transition: border-color var(--mf-transition), background-color var(--mf-transition);
}

.starter-option:hover {
    background: #fafbff;
    border-color: #b9c2d1;
}

.starter-option:has(input:checked) {
    background: var(--mf-primary-soft);
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, .1);
}

.starter-option input {
    position: absolute;
    top: 7px;
    right: 7px;
}

.starter-option > span:last-child strong,
.starter-option > span:last-child small {
    display: block;
}

.starter-option > span:last-child strong {
    margin-top: 7px;
    font-size: .72rem;
}

.starter-option > span:last-child small {
    color: var(--mf-text-muted);
    font-size: .7rem;
    line-height: 1.4;
}

.starter-mini {
    display: flex;
    align-items: center;
    flex-direction: column;
    height: 74px;
    gap: 5px;
    padding: 9px;
    background: #fff;
    border: 1px solid #e7ebf0;
    border-radius: 7px;
}

.starter-mini i { display: block; height: 6px; background: #cbd5e1; border-radius: 2px; }
.starter-mini i:nth-child(1) { width: 35%; }
.starter-mini i:nth-child(2) { width: 100%; height: 24px; background: #818cf8; }
.starter-mini i:nth-child(3) { width: 80%; }
.starter-mini i:nth-child(4) { width: 42%; background: #4f46e5; }
.starter-mini-promo i:nth-child(2) { height: 31px; background: #c084fc; }
.starter-mini-promo i:nth-child(3) { width: 55%; }
.starter-mini-note i:nth-child(2) { height: 8px; background: #38bdf8; }
.starter-mini-note i:nth-child(3) { width: 100%; height: 18px; }
.starter-mini-blank {
    justify-content: center;
    color: var(--mf-primary);
    background: #fafbff;
    border-style: dashed;
}
.starter-mini-blank i,
.starter-mini-blank i:nth-child(1) {
    display: grid;
    width: 32px;
    height: 32px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 50%;
    font-size: .85rem;
    place-items: center;
}

.input-with-counter {
    position: relative;
}

.input-with-counter .form-control {
    padding-right: 70px;
}

.input-with-counter > span {
    position: absolute;
    top: 50%;
    right: 12px;
    color: #8b98aa;
    font-size: .72rem;
    transform: translateY(-50%);
}

.input-with-counter b {
    font-weight: 600;
}

.color-control {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 7px;
}

.builder-style-grid,
.email-block-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
}

.block-library {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.block-library > button {
    display: flex;
    align-items: center;
    min-height: 62px;
    gap: 9px;
    padding: 9px 10px;
    color: var(--mf-text);
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: border-color var(--mf-transition), background-color var(--mf-transition), box-shadow var(--mf-transition);
}

.block-library > button:hover:not(:disabled) {
    background: #fafbff;
    border-color: #a5b4fc;
    box-shadow: 0 3px 10px rgba(79, 70, 229, .08);
}

.block-library > button:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.block-library > button > i {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 8px;
    place-items: center;
}

.block-library strong,
.block-library small {
    display: block;
}

.block-library strong {
    font-size: .78rem;
}

.block-library small {
    margin-top: 2px;
    color: var(--mf-text-muted);
    font-size: .7rem;
    line-height: 1.35;
}

.email-block-workspace {
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
}

.email-block-workspace-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--mf-border);
}

.email-block-workspace-head strong,
.email-block-workspace-head small {
    display: block;
}

.email-block-workspace-head strong {
    font-size: .72rem;
}

.email-block-workspace-head small {
    margin-top: 1px;
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.block-count {
    flex: 0 0 auto;
    padding: 4px 8px;
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}

.email-block-list {
    display: grid;
    gap: 5px;
    padding: 10px;
}

.email-block-insert {
    position: relative;
    display: grid;
    justify-items: center;
    min-height: 28px;
}

.email-block-insert::before {
    position: absolute;
    z-index: 0;
    top: 13px;
    right: 0;
    left: 0;
    height: 1px;
    content: '';
    background: #dfe5ec;
}

.email-block-insert-toggle {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    gap: 5px;
    padding: 3px 9px;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-size: .7rem;
    font-weight: 600;
    transition: color var(--mf-transition), background-color var(--mf-transition), border-color var(--mf-transition);
}

.email-block-insert-toggle:hover,
.email-block-insert-toggle[aria-expanded="true"] {
    color: var(--mf-primary-dark);
    background: #fff;
    border-color: #a5b4fc;
}

.email-block-insert-picker {
    position: relative;
    z-index: 2;
    display: grid;
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    margin-top: 5px;
    padding: 8px;
    background: #fff;
    border: 1px solid #cfd7e3;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .1);
}

.email-block-insert-picker[hidden] {
    display: none;
}

.email-block-insert-picker button {
    display: grid;
    min-width: 0;
    min-height: 48px;
    gap: 3px;
    padding: 6px 4px;
    color: #536277;
    background: #f8fafc;
    border: 1px solid #e5eaf0;
    border-radius: 7px;
    cursor: pointer;
    font-size: .7rem;
    place-items: center;
}

.email-block-insert-picker button:hover {
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
    border-color: #c7d2fe;
}

.email-block-insert-picker button i {
    color: var(--mf-primary);
    font-size: .8rem;
}

.email-block-card {
    overflow: hidden;
    background: #fff;
    border: 1px solid #dfe5ec;
    border-radius: 10px;
    transition: border-color var(--mf-transition), box-shadow var(--mf-transition), opacity var(--mf-transition);
}

.email-block-card:hover,
.email-block-card.is-expanded {
    border-color: #a5b4fc;
}

.email-block-card.is-expanded {
    box-shadow: 0 5px 16px rgba(15, 23, 42, .06);
}

.email-block-card.is-dragging {
    opacity: .45;
}

.email-block-card.is-drop-target {
    border-color: var(--mf-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .13);
}

.email-block-card-head {
    display: flex;
    align-items: center;
    min-height: 52px;
}

.email-block-toggle {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
    gap: 8px;
    padding: 8px 7px 8px 3px;
    color: var(--mf-text);
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
}

.email-block-toggle strong,
.email-block-toggle small {
    display: block;
}

.email-block-toggle strong {
    font-size: .78rem;
}

.email-block-toggle small {
    color: var(--mf-text-muted);
    font-size: .7rem;
}

.block-drag-handle {
    display: grid;
    min-width: 24px;
    min-height: 36px;
    color: #94a3b8;
    cursor: grab;
    place-items: center;
}

.block-type-icon {
    display: grid;
    width: 31px;
    height: 31px;
    flex: 0 0 31px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 8px;
    place-items: center;
}

.block-chevron {
    margin-left: auto;
    color: #94a3b8;
    transition: transform var(--mf-transition);
}

.email-block-card.is-expanded .block-chevron {
    transform: rotate(180deg);
}

.email-block-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
    padding-right: 6px;
}

.email-block-actions button {
    display: grid;
    width: 30px;
    height: 30px;
    color: #64748b;
    background: transparent;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    place-items: center;
}

.email-block-actions button:hover:not(:disabled) {
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
}

.email-block-actions button.is-danger:hover:not(:disabled) {
    color: #b42318;
    background: #fff1f0;
}

.email-block-actions button:disabled {
    opacity: .3;
}

.email-block-editor {
    padding: 14px;
    background: #fbfcfe;
    border-top: 1px solid #edf1f5;
}

.email-block-fields .form-label {
    margin-bottom: 4px;
    font-size: .75rem;
}

.email-block-fields .form-control,
.email-block-fields .form-select,
.email-block-fields .btn {
    min-height: 40px;
    font-size: .78rem;
}

.email-block-field-wide {
    grid-column: 1 / -1;
}

.email-block-style-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 15px 0 10px;
    color: var(--mf-text-muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.email-block-style-title::after {
    height: 1px;
    flex: 1;
    content: '';
    background: #e5eaf0;
}

.range-value {
    display: block;
    margin-top: 3px;
    color: var(--mf-text-muted);
    font-size: .72rem;
    text-align: right;
}

.email-block-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: 0;
    padding: 30px 18px;
    color: var(--mf-text-muted);
    font-size: .76rem;
    text-align: left;
}

.email-block-empty[hidden] {
    display: none;
}

.email-block-empty i {
    color: #94a3b8;
    font-size: 1.2rem;
}

.email-block-empty strong {
    display: block;
    color: var(--mf-text);
}

.visual-mode-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px;
    padding: 10px;
    color: #6b4d14;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 9px;
    font-size: .75rem;
}

.visual-mode-notice[hidden] {
    display: none;
}

.visual-mode-notice span {
    flex: 1;
}

.is-custom-source .email-block-list {
    opacity: .56;
}

.source-mode-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.source-mode-heading small {
    display: block;
    margin-top: 2px;
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.insert-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.toolbar-label {
    margin-right: 4px;
    color: var(--mf-text-muted);
    font-size: .7rem;
    font-weight: 600;
}

.variable-chip {
    min-height: 34px;
    padding: 5px 9px;
    color: #5b21b6;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.variable-chip:hover {
    background: #ede9fe;
}

.source-tabs {
    gap: 6px;
    padding: 4px;
    background: #f1f5f9;
    border-radius: 10px;
}

.source-tabs .nav-link {
    min-height: 36px;
    padding: 6px 11px;
    color: #64748b;
    border-radius: 7px;
    font-size: .72rem;
    font-weight: 600;
}

.source-tabs .nav-link.active {
    color: var(--mf-primary-dark);
    background: #fff;
    box-shadow: 0 2px 7px rgba(15, 23, 42, .08);
}

.content-guide,
.info-callout {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 15px;
    color: #36506a;
    background: #eff8ff;
    border: 1px solid #cde8fc;
    border-radius: 11px;
    font-size: .75rem;
}

.content-guide p,
.info-callout p {
    margin: 0;
}

.code-editor {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: .72rem;
    line-height: 1.6;
    tab-size: 2;
}

.builder-preview {
    position: sticky;
    top: 94px;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 70px;
    padding: 13px 17px;
    border-bottom: 1px solid var(--mf-border);
}

.device-switch {
    display: flex;
    padding: 3px;
    background: #eef1f6;
    border-radius: 9px;
}

.device-switch button {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    gap: 6px;
    padding: 5px 9px;
    color: #64748b;
    background: transparent;
    border: 0;
    border-radius: 7px;
    font-size: .75rem;
    font-weight: 600;
}

.device-switch button.active {
    color: var(--mf-primary-dark);
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .09);
}

.inbox-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 17px 10px;
    background: #f8fafc;
}

.inbox-preview-header {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 9px;
}

.inbox-preview-header strong,
.inbox-preview-header small {
    display: block;
}

.inbox-preview-header strong {
    font-size: .72rem;
}

.inbox-preview-header small {
    max-width: 240px;
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.mail-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 50%;
    place-items: center;
}

.inbox-subject {
    display: flex;
    gap: 6px;
    padding: 0 17px 13px 60px;
    overflow: hidden;
    background: #f8fafc;
    font-size: .75rem;
    white-space: nowrap;
}

.inbox-subject span {
    overflow: hidden;
    color: var(--mf-text-muted);
    text-overflow: ellipsis;
}

.email-stage {
    display: flex;
    justify-content: center;
    min-height: 620px;
    padding: 22px;
    overflow-x: auto;
    background: #e9edf4;
}

.email-device {
    width: 100%;
    max-width: 700px;
    min-height: 580px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #d9e0e8;
    border-radius: 9px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .11);
    transition: max-width 240ms ease;
}

.email-device[data-email-device="mobile"] {
    max-width: 390px;
}

.email-device iframe {
    display: block;
    width: 100%;
    height: 680px;
    border: 0;
}

.preview-safety {
    margin: 0;
    padding: 11px 17px;
    color: var(--mf-text-muted);
    background: #f8fafc;
    border-top: 1px solid var(--mf-border);
    font-size: .72rem;
    text-align: center;
}

/* Campaigns */
.campaign-list {
    display: grid;
}

.campaign-row {
    display: grid;
    grid-template-columns: minmax(270px, 1.6fr) minmax(260px, .9fr) auto;
    align-items: center;
    gap: 20px;
    padding: 18px 20px;
    border-bottom: 1px solid #edf1f5;
}

.campaign-row:last-child {
    border-bottom: 0;
}

.campaign-row:hover {
    background: #fafbff;
}

.campaign-main {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}

.campaign-icon {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 12px;
    place-items: center;
}

.campaign-name-line {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
}

.campaign-name-line h4 {
    min-width: 0;
    margin: 0;
    font-size: .87rem;
    font-weight: 700;
}

.campaign-main p {
    max-width: 520px;
    margin: 3px 0;
    color: var(--mf-text-muted);
    font-size: .78rem;
}

.campaign-main small {
    color: #7c899b;
    font-size: .74rem;
}

.campaign-numbers {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.campaign-numbers span,
.campaign-numbers strong {
    display: block;
    text-align: right;
}

.campaign-numbers span {
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.campaign-numbers strong {
    font-size: .84rem;
    font-variant-numeric: tabular-nums;
}

.campaign-progress {
    grid-column: 2;
    margin-top: -10px;
    font-size: .72rem;
}

.campaign-progress .progress {
    height: 6px;
    margin-top: 5px;
    background: #e8edf4;
}

.campaign-progress .progress-bar {
    background: var(--mf-primary);
}

.campaign-actions {
    grid-column: 3;
    grid-row: 1;
}

.composer-layout {
    display: grid;
    grid-template-columns: minmax(520px, 1.2fr) minmax(360px, .8fr);
    align-items: start;
    gap: 20px;
}

.composer-form {
    display: grid;
    gap: 16px;
}

.form-panel {
    padding: 22px;
}

.template-inline-actions {
    display: flex;
    gap: 18px;
    margin-top: 10px;
    font-size: .72rem;
}

.recipient-preview {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-top: 13px;
    padding: 12px;
    color: #334155;
    background: #f8fafc;
    border: 1px solid var(--mf-border);
    border-radius: 11px;
}

.recipient-icon {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    border-radius: 10px;
    place-items: center;
}

.recipient-preview small,
.recipient-preview strong {
    display: block;
}

.recipient-preview small {
    color: var(--mf-text-muted);
    font-size: .75rem;
}

.recipient-preview strong {
    font-size: .82rem;
    font-variant-numeric: tabular-nums;
}

.delivery-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.delivery-option {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 76px;
    gap: 11px;
    padding: 13px;
    cursor: pointer;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
}

.delivery-option:hover {
    border-color: #aeb9ca;
}

.delivery-option:has(input:checked) {
    background: var(--mf-primary-soft);
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, .08);
}

.delivery-option input {
    position: absolute;
    top: 10px;
    right: 10px;
}

.delivery-radio-icon {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    color: var(--mf-primary);
    background: #fff;
    border: 1px solid #d8ddff;
    border-radius: 11px;
    place-items: center;
}

.delivery-option strong,
.delivery-option small {
    display: block;
}

.delivery-option strong {
    font-size: .8rem;
}

.delivery-option small {
    color: var(--mf-text-muted);
    font-size: .74rem;
    line-height: 1.45;
}

.sticky-preview-panel {
    position: sticky;
    top: 94px;
    overflow: hidden;
}

/* Campaign analytics */
.analytics-heading {
    align-items: flex-end;
}

.back-link {
    color: var(--mf-text-muted);
    font-size: .76rem;
    font-weight: 600;
    text-decoration: none;
}

.back-link:hover {
    color: var(--mf-primary);
}

.analytics-metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.analytics-metric {
    display: flex;
    align-items: flex-start;
    min-width: 0;
    gap: 12px;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 13px;
}

.analytics-metric > div {
    min-width: 0;
}

.analytics-metric small,
.analytics-metric strong,
.analytics-metric div > span {
    display: block;
}

.analytics-metric small {
    color: var(--mf-text-muted);
    font-size: .72rem;
    font-weight: 600;
}

.analytics-metric strong {
    margin: 2px 0;
    font-size: 1.55rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
}

.analytics-metric div > span {
    overflow: hidden;
    color: var(--mf-text-muted);
    font-size: .74rem;
    line-height: 1.45;
    text-overflow: ellipsis;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 18px;
}

.panel-body {
    padding: 20px 22px;
}

.optimization-panel-body .optimization-stat {
    display: flex;
    min-height: 108px;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 16px;
    background: var(--mf-surface-soft);
    border: 1px solid var(--mf-border);
    border-radius: 12px;
}

.optimization-stat small {
    color: var(--mf-text-muted);
    line-height: 1.45;
}

.optimization-stat strong {
    font-size: 1.5rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.analytics-panel {
    min-height: 360px;
}

.analytics-funnel {
    display: grid;
    gap: 22px;
    padding: 24px;
}

.funnel-row > div:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: .76rem;
}

.funnel-row span {
    color: var(--mf-text-muted);
    font-variant-numeric: tabular-nums;
}

.funnel-row .progress {
    height: 10px;
    background: #edf1f5;
}

.analytics-rate-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 15px;
    color: #3730a3;
    background: var(--mf-primary-soft);
    border-radius: 10px;
    font-size: .76rem;
}

.analytics-rate-note strong {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.analytics-bars {
    display: grid;
    gap: 12px;
    padding: 22px 24px 12px;
}

.analytics-bar-row {
    display: grid;
    grid-template-columns: 42px minmax(80px, 1fr) 135px;
    align-items: center;
    gap: 10px;
}

.analytics-bar-row time,
.analytics-bar-row small {
    color: var(--mf-text-muted);
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
}

.analytics-bar-stack {
    display: grid;
    align-content: center;
    min-height: 28px;
    gap: 2px;
}

.analytics-bar-stack span {
    display: block;
    min-width: 2px;
    height: 5px;
    border-radius: 99px;
}

.analytics-bar-stack .is-delivered,
.analytics-legend .is-delivered { background: #22c55e; }
.analytics-bar-stack .is-opened,
.analytics-legend .is-opened { background: #6366f1; }
.analytics-bar-stack .is-clicked,
.analytics-legend .is-clicked { background: #0ea5e9; }

.analytics-legend {
    display: flex;
    gap: 16px;
    padding: 4px 24px 20px;
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.analytics-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.analytics-legend i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.analytics-table {
    min-width: 560px;
}

.analytics-url {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analytics-event-list {
    max-height: 430px;
    overflow-y: auto;
}

.analytics-event-list article {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    border-bottom: 1px solid #edf1f5;
}

.analytics-event-list article:last-child {
    border-bottom: 0;
}

.analytics-event-list strong,
.analytics-event-list small {
    display: block;
    font-size: .76rem;
}

.analytics-event-list small,
.analytics-event-list time {
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.analytics-privacy-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 18px;
    padding: 14px 16px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid var(--mf-border);
    border-radius: 11px;
    font-size: .78rem;
    line-height: 1.65;
}

.analytics-privacy-note > i {
    color: var(--mf-success);
}

.campaign-inbox-preview {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 13px 17px;
    background: #f8fafc;
    border-bottom: 1px solid var(--mf-border);
}

.campaign-inbox-preview strong,
.campaign-inbox-preview small {
    display: block;
}

.campaign-inbox-preview strong {
    font-size: .72rem;
}

.campaign-inbox-preview small {
    max-width: 360px;
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.campaign-frame-wrap {
    min-height: 490px;
    padding: 18px;
    background: #e9edf4;
}

.campaign-frame-wrap iframe {
    display: block;
    width: 100%;
    height: 470px;
    background: #fff;
    border: 1px solid #d7dee8;
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .1);
}

.preview-checklist {
    padding: 17px 20px;
    border-top: 1px solid var(--mf-border);
}

.preview-checklist h4 {
    margin: 0 0 10px;
    font-size: .78rem;
    font-weight: 700;
}

.preview-checklist ul {
    display: grid;
    gap: 7px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.preview-checklist li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mf-text-muted);
    font-size: .7rem;
}

.preview-checklist li.is-complete {
    color: var(--mf-success);
}

.mobile-sticky-actions {
    display: none;
}

/* Logs */
.filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 135px 145px 145px auto;
}

.filter-grid .search-input .form-control {
    min-width: 220px;
}

.delivery-detail {
    padding: 3px 6px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #edf1f5;
    border-radius: 5px;
    font-size: .75rem;
    white-space: nowrap;
}

.log-detail-row td {
    padding: 0 !important;
    background: #f8fafc;
}

.log-detail-list {
    display: flex;
    gap: 40px;
    margin: 0;
    padding: 15px 72px;
}

.log-detail-list div {
    display: grid;
    gap: 2px;
}

.log-detail-list dt {
    color: var(--mf-text-muted);
    font-size: .72rem;
}

.log-detail-list dd {
    margin: 0;
    font-size: .8rem;
}

/* Settings */
.settings-layout {
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
    align-items: start;
    gap: 20px;
}

.settings-nav {
    display: grid;
    gap: 5px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 15px;
    box-shadow: var(--mf-shadow-sm);
}

.settings-nav button {
    display: flex;
    align-items: center;
    min-height: 60px;
    gap: 10px;
    padding: 9px 10px;
    color: #475569;
    background: transparent;
    border: 0;
    border-radius: 10px;
    text-align: left;
}

.settings-nav button:hover {
    background: #f8fafc;
}

.settings-nav button.active {
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
}

.settings-nav button > span:first-child {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    background: #f1f5f9;
    border-radius: 9px;
    place-items: center;
}

.settings-nav button.active > span:first-child {
    background: #fff;
}

.settings-nav strong,
.settings-nav small {
    display: block;
}

.settings-nav strong {
    font-size: .77rem;
}

.settings-nav small {
    color: var(--mf-text-muted);
    font-size: .72rem;
    line-height: 1.4;
}

.settings-content {
    max-width: 920px;
}

.settings-panel {
    padding: 24px;
}

.settings-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--mf-border);
}

.settings-panel-header h3 {
    margin: 0;
    font-size: 1.08rem;
    font-weight: 700;
}

.settings-panel-header p:last-child {
    margin: 4px 0 0;
    color: var(--mf-text-muted);
    font-size: .76rem;
}

.smtp-provider-picker {
    padding: 0;
    margin: 0 0 22px;
    border: 0;
}

.smtp-provider-picker > legend {
    float: none;
    width: auto;
    margin-bottom: 9px;
    font-size: .78rem;
}

.smtp-provider-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.smtp-provider-option {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.smtp-provider-option > input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.smtp-provider-card-body {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 82px;
    padding: 14px 16px;
    color: var(--mf-text);
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.smtp-provider-card-body > span:nth-child(2) {
    min-width: 0;
}

.smtp-provider-card-body strong,
.smtp-provider-card-body small {
    display: block;
}

.smtp-provider-card-body strong {
    margin-bottom: 2px;
    font-size: .82rem;
}

.smtp-provider-card-body small {
    color: var(--mf-text-muted);
    font-size: .75rem;
    line-height: 1.45;
}

.smtp-provider-option:hover .smtp-provider-card-body {
    border-color: #b7c7f5;
    background: #fbfdff;
}

.smtp-provider-option > input:focus-visible + .smtp-provider-card-body {
    outline: 3px solid rgba(66, 91, 211, .22);
    outline-offset: 2px;
}

.smtp-provider-option > input:checked + .smtp-provider-card-body {
    background: var(--mf-primary-soft);
    border-color: var(--mf-primary);
    box-shadow: 0 0 0 1px rgba(66, 91, 211, .12);
}

.smtp-provider-icon {
    display: grid;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    color: var(--mf-primary);
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 11px;
    font-size: 1.05rem;
    place-items: center;
}

.smtp-provider-check {
    margin-left: auto;
    color: var(--mf-primary);
    opacity: 0;
    transition: opacity .2s ease;
}

.smtp-provider-option > input:checked + .smtp-provider-card-body .smtp-provider-check {
    opacity: 1;
}

.smtp-fixed-field[readonly] {
    color: #526174;
    background: #f8fafc;
}

.smtp-setup-guide {
    max-width: 920px;
    margin-top: 14px;
    padding: 22px 24px;
    background: #fff;
    border: 1px solid var(--mf-border);
    border-radius: 14px;
    box-shadow: var(--mf-shadow-sm);
}

.smtp-guide-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.smtp-guide-heading h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.smtp-guide-steps {
    display: grid;
    gap: 14px;
    padding: 0;
    margin: 0;
    list-style: none;
    counter-reset: smtp-step;
}

.smtp-guide-steps li {
    position: relative;
    min-height: 34px;
    padding-left: 46px;
    counter-increment: smtp-step;
}

.smtp-guide-steps li::before {
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    width: 32px;
    height: 32px;
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
    border-radius: 9px;
    font-size: .7rem;
    font-weight: 700;
    content: counter(smtp-step);
    place-items: center;
}

.smtp-guide-steps strong,
.smtp-guide-steps span {
    display: block;
}

.smtp-guide-steps strong {
    margin-bottom: 2px;
    color: var(--mf-text);
    font-size: .8rem;
}

.smtp-guide-steps span {
    color: var(--mf-text-muted);
    font-size: .77rem;
    line-height: 1.65;
}

.smtp-guide-steps code,
.smtp-guide-note strong {
    color: var(--mf-primary-dark);
}

.smtp-guide-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 18px;
    padding: 12px 14px;
    color: #78540a;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    font-size: .72rem;
    line-height: 1.6;
}

.smtp-guide-note > i {
    margin-top: 2px;
}

.smtp-guide-note-success {
    color: #17603a;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.settings-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--mf-border);
}

.input-icon-wrap,
.input-with-action {
    position: relative;
}

.input-icon-wrap > i {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 15px;
    color: #8492a6;
    transform: translateY(-50%);
}

.input-icon-wrap .form-control {
    padding-left: 45px;
}

.input-with-action .form-control {
    padding-right: 48px;
}

.input-action {
    position: absolute;
    z-index: 2;
    top: 50%;
    right: 5px;
    display: grid;
    width: 38px;
    height: 38px;
    color: #64748b;
    background: transparent;
    border: 0;
    border-radius: 8px;
    transform: translateY(-50%);
    place-items: center;
}

.input-action:hover {
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
}

.input-action.align-top {
    top: 5px;
    transform: none;
}

.secret-textarea {
    -webkit-text-security: disc;
}

.secret-textarea.is-visible {
    -webkit-text-security: none;
}

.info-callout {
    max-width: 920px;
    margin-top: 14px;
}

.code-callout {
    display: grid;
    gap: 8px;
    padding: 16px;
    color: #dce7f8;
    background: #172033;
    border-radius: 12px;
}

.code-callout span {
    color: #91a0b5;
    font-size: .72rem;
}

.code-callout code {
    overflow-wrap: anywhere;
    color: #d8b4fe;
    font-size: .74rem;
}

.security-checklist {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.security-checklist li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 0;
    border-bottom: 1px solid var(--mf-border);
}

.security-checklist li:last-child {
    border-bottom: 0;
}

.check-icon {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    color: var(--mf-success);
    background: var(--mf-success-soft);
    border-radius: 50%;
    place-items: center;
}

.security-checklist strong,
.security-checklist small {
    display: block;
}

.security-checklist strong {
    font-size: .8rem;
}

.security-checklist small {
    margin-top: 2px;
    color: var(--mf-text-muted);
    font-size: .75rem;
}

/* Login */
.auth-page {
    background: #fff;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(470px, 1.05fr) minmax(440px, .95fr);
    min-height: 100vh;
    min-height: 100dvh;
}

.auth-visual {
    position: relative;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    padding: 52px;
    color: #fff;
    background: radial-gradient(circle at 15% 15%, rgba(129, 140, 248, .35), transparent 28%), radial-gradient(circle at 90% 75%, rgba(20, 184, 166, .24), transparent 30%), linear-gradient(145deg, #0f172a, #25205e 62%, #173b48);
}

.auth-visual::before,
.auth-visual::after {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 50%;
    content: "";
}

.auth-visual::before {
    top: -180px;
    left: -200px;
    width: 520px;
    height: 520px;
}

.auth-visual::after {
    right: -230px;
    bottom: -230px;
    width: 580px;
    height: 580px;
}

.auth-visual-content {
    z-index: 1;
    width: min(100%, 610px);
}

.auth-message {
    margin: 10vh 0 42px;
}

.auth-kicker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 17px;
    padding: 6px 10px;
    color: #dddffd;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 999px;
    font-size: .72rem;
}

.auth-message h1 {
    max-width: 630px;
    margin: 0;
    font-size: clamp(2.4rem, 4.6vw, 4.4rem);
    font-weight: 700;
    letter-spacing: -.045em;
    line-height: 1.13;
}

.auth-message p {
    max-width: 520px;
    margin: 20px 0 0;
    color: #bdc7d8;
    font-size: .98rem;
}

.auth-preview-card {
    width: min(100%, 540px);
    overflow: hidden;
    background: rgba(255, 255, 255, .95);
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 17px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .27);
    transform: rotate(-1.5deg);
}

.auth-preview-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 13px 16px;
    border-bottom: 1px solid #e7ebf0;
}

.mini-brand {
    display: grid;
    width: 30px;
    height: 30px;
    color: #fff;
    background: var(--mf-primary);
    border-radius: 8px;
    place-items: center;
}

.preview-lines {
    display: grid;
    gap: 4px;
}

.preview-lines i {
    display: block;
    width: 72px;
    height: 5px;
    background: #334155;
    border-radius: 3px;
}

.preview-lines i:last-child {
    width: 48px;
    background: #cbd5e1;
}

.preview-pill {
    width: 42px;
    height: 16px;
    margin-left: auto;
    background: #dcfce7;
    border-radius: 999px;
}

.auth-preview-hero {
    display: flex;
    align-items: center;
    flex-direction: column;
    padding: 34px 30px 30px;
    background: linear-gradient(150deg, #eef2ff, #fff 55%, #ecfeff);
}

.preview-label { width: 70px; height: 8px; margin-bottom: 14px; background: #a5b4fc; border-radius: 4px; }
.preview-title { width: 73%; height: 14px; margin-bottom: 8px; background: #1e293b; border-radius: 4px; }
.preview-title.short { width: 48%; }
.preview-copy { width: 84%; height: 6px; margin: 10px 0 17px; background: #cbd5e1; border-radius: 3px; }
.preview-cta { width: 88px; height: 28px; background: var(--mf-primary); border-radius: 7px; }

.auth-preview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 17px 20px;
}

.auth-preview-stats span {
    height: 34px;
    background: #f1f5f9;
    border-radius: 8px;
}

.auth-form-pane {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px;
    background: #fff;
}

.auth-form-wrap {
    width: min(100%, 440px);
}

.auth-form-wrap .brand-lockup {
    color: var(--mf-text);
}

.auth-title {
    margin: 0 0 5px;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -.025em;
}

.auth-security-note {
    margin: 28px 0 0;
    color: var(--mf-text-muted);
    font-size: .7rem;
    text-align: center;
}

/* Responsive */
@media (min-width: 992px) {
    .app-sidebar {
        position: fixed;
        z-index: 50;
        inset: 0 auto 0 0;
        width: var(--mf-sidebar-width);
    }

    .app-shell {
        margin-left: var(--mf-sidebar-width);
    }

    .app-content {
        padding: 28px clamp(24px, 3vw, 42px) 56px;
    }
}

@media (max-width: 1199.98px) {
    .metric-grid,
    .mini-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .analytics-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .builder-layout {
        grid-template-columns: minmax(360px, .9fr) minmax(430px, 1.1fr);
    }

    .block-library {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .campaign-row {
        grid-template-columns: minmax(260px, 1.4fr) minmax(230px, .8fr) auto;
    }

    .filter-grid {
        width: 100%;
        grid-template-columns: minmax(210px, 1fr) 135px repeat(2, minmax(140px, .65fr)) auto;
    }

    .panel-toolbar:has(.filter-grid) {
        align-items: stretch !important;
        flex-direction: column;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        width: min(88vw, var(--mf-sidebar-width));
    }

    .sidebar-inner {
        min-height: calc(100% - 72px);
    }

    .dashboard-grid,
    .builder-layout,
    .composer-layout,
    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .builder-editor {
        max-height: none;
    }

    .builder-preview,
    .sticky-preview-panel {
        position: static;
    }

    .campaign-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .campaign-numbers {
        grid-column: 1;
        grid-row: 2;
        max-width: 360px;
    }

    .campaign-progress {
        grid-column: 1;
        grid-row: 3;
    }

    .campaign-actions {
        grid-column: 2;
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-nav {
        display: flex;
        overflow-x: auto;
    }

    .settings-nav button {
        min-width: 190px;
    }
}

@media (max-width: 767.98px) {
    .app-topbar {
        min-height: 68px;
        padding: 10px 14px;
    }

    .app-content {
        padding: 20px 14px 42px;
    }

    .topbar-title {
        max-width: 46vw;
        font-size: 1rem;
    }

    .page-heading,
    .builder-topbar,
    .panel-toolbar,
    .section-heading-row,
    .starter-banner {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading {
        margin-bottom: 20px;
    }

    .page-actions,
    .builder-actions {
        width: 100%;
    }

    .page-actions .btn,
    .builder-actions .btn {
        flex: 1 1 auto;
    }

    .page-heading > .btn {
        width: 100%;
    }

    .metric-grid,
    .mini-stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .metric-card {
        display: block;
        padding: 15px;
    }

    .metric-icon {
        width: 38px;
        height: 38px;
        margin-bottom: 10px;
    }

    .metric-copy > strong {
        font-size: 1.32rem;
    }

    .mini-stat {
        padding: 13px;
    }

    .bar-chart {
        height: 240px;
        gap: 8px;
        padding-inline: 17px;
    }

    .bar-value {
        display: none;
    }

    .bar-column {
        grid-template-rows: 1fr 24px;
    }

    .filter-bar,
    .filter-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .filter-bar .search-input,
    .filter-grid .search-input {
        grid-column: 1 / -1;
    }

    .filter-bar .form-select,
    .filter-grid .form-select,
    .search-input .form-control {
        width: 100%;
        min-width: 0;
    }

    .filter-bar .btn,
    .filter-grid .btn,
    .filter-bar .form-control,
    .filter-grid .form-control,
    .filter-bar .form-select,
    .filter-grid .form-select {
        min-height: 44px;
    }

    .panel-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .starter-banner {
        padding: 22px;
    }

    .starter-copy {
        align-items: flex-start;
    }

    .starter-banner .btn {
        align-self: flex-start;
    }

    .template-grid {
        grid-template-columns: 1fr;
    }

    .compact-search,
    .compact-search .form-control {
        width: 100%;
        min-width: 0;
    }

    .template-thumb {
        height: 280px;
        padding-inline: clamp(38px, 12vw, 90px);
    }

    .builder-actions .autosave-state {
        width: 100%;
    }

    .starter-options {
        grid-template-columns: 1fr;
    }

    .block-library {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .starter-option {
        display: grid;
        grid-template-columns: 100px 1fr;
        align-items: center;
        gap: 10px;
    }

    .starter-option > span:last-child strong {
        margin-top: 0;
    }

    .email-stage {
        min-height: 500px;
        padding: 12px;
    }

    .email-device,
    .email-device[data-email-device="mobile"] {
        max-width: 100%;
        min-height: 490px;
    }

    .email-device iframe {
        height: 590px;
    }

    .campaign-row {
        gap: 13px;
        padding: 16px;
    }

    .campaign-name-line {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .composer-topbar .builder-actions {
        display: none;
    }

    .mobile-sticky-actions {
        position: sticky;
        z-index: 20;
        bottom: 8px;
        display: grid;
        grid-template-columns: .8fr 1.2fr;
        gap: 8px;
        padding: 8px;
        background: rgba(255, 255, 255, .94);
        border: 1px solid var(--mf-border);
        border-radius: 13px;
        box-shadow: 0 10px 32px rgba(15, 23, 42, .18);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }

    .delivery-options {
        grid-template-columns: 1fr;
    }

    .settings-nav button {
        min-width: 155px;
    }

    .settings-nav button > span:first-child,
    .settings-nav button > .bi-chevron-right {
        display: none;
    }

    .settings-panel {
        padding: 18px;
    }

    .settings-panel-header,
    .settings-form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .smtp-provider-grid {
        grid-template-columns: 1fr;
    }

    .smtp-setup-guide {
        padding: 18px;
    }

    .settings-form-actions .btn {
        width: 100%;
    }

    .log-detail-list {
        gap: 16px;
        padding-inline: 24px;
        flex-wrap: wrap;
    }
}

@media (max-width: 575.98px) {
    .metric-grid,
    .mini-stat-grid,
    .analytics-metric-grid {
        grid-template-columns: 1fr;
    }

    .analytics-bar-row {
        grid-template-columns: 38px minmax(70px, 1fr);
    }

    .analytics-bar-row small {
        grid-column: 2;
    }

    .analytics-event-list article {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .analytics-event-list time {
        grid-column: 2;
    }

    .metric-card {
        display: flex;
    }

    .metric-icon {
        margin-bottom: 0;
    }

    .panel-header,
    .panel-toolbar,
    .panel-footer {
        padding: 17px;
    }

    .panel-body {
        padding: 17px;
    }

    .modal-footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
        min-height: 44px;
        margin: 0 !important;
    }

    .filter-bar,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar .search-input,
    .filter-grid .search-input {
        grid-column: 1;
    }

    .campaign-main {
        align-items: flex-start;
    }

    .campaign-icon {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
    }

    .campaign-numbers {
        max-width: none;
    }

    .campaign-numbers span,
    .campaign-numbers strong {
        text-align: left;
    }

    .builder-section,
    .form-panel {
        padding: 17px;
    }

    .insert-toolbar .btn {
        flex: 1 1 42%;
    }

    .block-library,
    .builder-style-grid,
    .email-block-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .email-block-insert-picker {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .email-block-insert-toggle {
        min-height: 36px;
    }

    .block-library > button {
        min-width: 0;
    }

    .email-block-card-head {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .email-block-toggle {
        min-height: 50px;
    }

    .email-block-actions {
        width: 100%;
        justify-content: flex-end;
        padding: 0 7px 7px;
    }

    .email-block-actions button {
        width: 38px;
        height: 38px;
    }

    .visual-mode-notice,
    .source-mode-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .template-inline-actions {
        flex-direction: column;
        gap: 8px;
    }

    .auth-form-pane {
        padding: 28px 18px;
    }

    .auth-title {
        font-size: 1.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (pointer: coarse) {
    .btn-sm,
    .btn-icon.btn-sm,
    .variable-chip,
    .device-switch button,
    .source-tabs .nav-link,
    .page-link {
        min-height: 44px;
    }

    .btn-icon.btn-sm {
        width: 44px;
        height: 44px;
    }

    .email-block-actions button,
    .block-library > button,
    .email-block-insert-toggle,
    .email-block-insert-picker button {
        min-height: 44px;
    }

    .page-link {
        min-width: 44px;
    }
}

@media (prefers-contrast: more) {
    :root {
        --mf-border: #94a3b8;
        --mf-text-muted: #475569;
    }

    .status-badge,
    .contact-tag,
    .panel,
    .metric-card {
        border-width: 2px;
    }
}

/* Automation workflow builder */
.automation-list {
    display: grid;
}

.automation-row {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(360px, .75fr) auto;
    gap: 22px;
    align-items: center;
    padding: 20px 24px;
    border-top: 1px solid var(--mf-border);
}

.automation-row:first-child {
    border-top: 0;
}

.automation-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.automation-main h4,
.automation-main p {
    margin: 0;
}

.automation-main p,
.automation-main small {
    color: var(--mf-text-muted);
}

.automation-icon,
.automation-step-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
}

.automation-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(70px, 1fr));
    gap: 12px;
}

.automation-metrics div {
    min-width: 0;
}

.automation-metrics span,
.automation-metrics strong {
    display: block;
    text-align: right;
}

.automation-metrics span {
    color: var(--mf-text-muted);
    font-size: .75rem;
}

.automation-metrics strong {
    margin-top: 3px;
    font-size: 1rem;
}

.automation-builder-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 24px;
}

.automation-builder-main {
    display: grid;
    gap: 24px;
}

.automation-config-panel,
.automation-workflow-panel,
.automation-rules-panel,
.sticky-summary {
    padding: 24px;
}

.automation-config-panel .panel-heading,
.automation-workflow-panel .panel-heading,
.automation-rules-panel .panel-heading {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 0 0 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--mf-border);
}

.automation-config-panel .panel-heading h3,
.automation-workflow-panel .panel-heading h3,
.automation-rules-panel .panel-heading h3 {
    margin: 0 0 4px;
    font-size: 1.1rem;
}

.automation-config-panel .panel-heading p,
.automation-workflow-panel .panel-heading p,
.automation-rules-panel .panel-heading p {
    margin: 0;
    color: var(--mf-text-muted);
    font-size: .875rem;
}

.step-number,
.automation-step-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    background: var(--mf-primary);
    font-size: .85rem;
    font-weight: 700;
}

.sticky-summary {
    position: sticky;
    top: 92px;
}

.automation-checklist {
    display: grid;
    gap: 12px;
    padding: 0;
    margin: 18px 0;
    list-style: none;
    color: var(--mf-text-muted);
    font-size: .875rem;
}

.automation-checklist li {
    display: flex;
    gap: 9px;
    align-items: flex-start;
}

.automation-checklist i {
    color: var(--mf-success);
}

.automation-insight-panel {
    overflow: hidden;
}

.automation-insight-panel .empty-state {
    min-height: 170px;
}

.automation-health-list {
    padding: 12px 22px 18px;
}

.automation-health-list dt,
.automation-health-list dd {
    margin: 0;
    border-bottom: 1px solid var(--mf-border);
}

.automation-health-list dt:nth-last-of-type(1),
.automation-health-list dd:nth-last-of-type(1) {
    border-bottom: 0;
}

.automation-step-list {
    display: grid;
    gap: 18px;
}

.automation-step-card {
    position: relative;
    border: 1px solid var(--mf-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .04);
}

.automation-step-card > header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--mf-border);
}

.automation-step-card > header strong,
.automation-step-card > header small {
    display: block;
}

.automation-step-card > header small {
    color: var(--mf-text-muted);
}

.automation-step-index {
    width: 28px;
    height: 28px;
    background: var(--mf-text);
}

.automation-step-type-icon {
    width: 38px;
    height: 38px;
}

.automation-step-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.automation-step-fields {
    padding: 18px;
}

.automation-repeat-settings {
    padding: 16px;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
    background: var(--mf-surface-soft);
}

.automation-repeat-settings legend {
    float: none;
    width: auto;
    padding: 0 6px;
    margin: 0 0 10px -6px;
    color: var(--mf-text);
    font-size: .9rem;
    font-weight: 700;
}

.automation-repeat-preview {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 12px 14px;
    margin-top: 14px;
    color: var(--mf-info);
    background: var(--mf-info-soft);
    border-radius: 10px;
    font-size: .82rem;
}

.automation-repeat-preview i {
    flex: 0 0 auto;
}

.automation-add-step {
    display: flex;
    justify-content: center;
    padding-top: 20px;
}

.automation-enroll-quick {
    white-space: nowrap;
}

.automation-manual-start {
    padding: 18px;
    border: 1px solid #c7d2fe;
    border-radius: 12px;
    background: var(--mf-primary-soft);
}

.automation-manual-start > legend {
    display: flex;
    align-items: center;
    width: auto;
    float: none;
    gap: 9px;
    margin-bottom: 14px;
    color: var(--mf-primary-dark);
    font-size: .95rem;
    font-weight: 700;
}

.automation-manual-start textarea {
    min-height: 124px;
    background: #fff;
    resize: vertical;
}

.automation-manual-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 13px;
    color: var(--mf-info);
    background: #fff;
    border-radius: 9px;
    font-size: .82rem;
    line-height: 1.55;
}

.automation-manual-note i {
    flex: 0 0 auto;
}

.campaign-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.audience-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 0;
    margin: 0;
    border: 0;
}

.audience-choice-grid > legend {
    float: none;
    width: 100%;
    margin-bottom: 8px;
}

.audience-choice {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 76px;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease;
}

.audience-choice:has(input:checked) {
    border-color: var(--mf-primary);
    background: var(--mf-primary-soft);
}

.audience-choice input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.audience-choice:focus-within {
    outline: 3px solid rgba(79, 70, 229, .2);
    outline-offset: 2px;
}

.audience-choice-icon,
.tag-manager-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    color: var(--mf-primary);
    background: #fff;
    border-radius: 10px;
}

.audience-choice strong,
.audience-choice small,
.tag-manager-row strong,
.tag-manager-row small {
    display: block;
}

.audience-choice small,
.tag-manager-row small {
    color: var(--mf-text-muted);
}

.automation-audience-summary {
    display: flex;
    gap: 9px;
    padding: 12px 14px;
    color: var(--mf-info);
    background: var(--mf-info-soft);
    border-radius: 10px;
    font-size: .875rem;
}

.automation-contact-picker {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
    overscroll-behavior: contain;
}

.automation-contact-option {
    display: flex;
    align-items: center;
    min-height: 54px;
    gap: 12px;
    padding: 9px 12px;
    border-top: 1px solid var(--mf-border);
    cursor: pointer;
}

.automation-contact-option:first-child {
    border-top: 0;
}

.automation-contact-option:hover,
.automation-contact-option:has(input:checked) {
    background: var(--mf-primary-soft);
}

.automation-contact-option strong,
.automation-contact-option small {
    display: block;
}

.automation-contact-option small {
    color: var(--mf-text-muted);
}

.automation-picker-state {
    padding: 20px;
    color: var(--mf-text-muted);
    text-align: center;
}

.tag-create-form {
    padding: 16px;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
    background: var(--mf-surface-soft);
}

.contact-tag-picker {
    padding: 0;
    border: 0;
}

.contact-tag-picker > legend {
    float: none;
    width: auto;
}

.contact-tag-choice-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 150px;
    padding: 10px;
    overflow-y: auto;
    border: 1px solid var(--mf-border);
    border-radius: 10px;
}

.contact-tag-choice {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--mf-border);
    border-radius: 999px;
    cursor: pointer;
}

.contact-tag-choice:has(input:checked) {
    color: var(--mf-primary);
    border-color: var(--mf-primary);
    background: var(--mf-primary-soft);
}

.contact-tag-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--mf-text-muted);
    background: var(--mf-surface-soft);
    border-radius: 10px;
}

.tag-manager-list {
    display: grid;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
    overflow: hidden;
}

.tag-manager-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    padding: 12px 14px;
    border-top: 1px solid var(--mf-border);
}

.tag-manager-row:first-child {
    border-top: 0;
}

.tag-manager-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.automation-empty-steps {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 190px;
    padding: 30px;
    color: var(--mf-text-muted);
    text-align: center;
    border: 2px dashed var(--mf-border);
    border-radius: 14px;
}

.automation-empty-steps i {
    margin-bottom: 10px;
    color: var(--mf-primary);
    font-size: 2rem;
}

.automation-rules-grid > div {
    display: flex;
}

.automation-rule-card {
    width: 100%;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--mf-border);
    border-radius: 14px;
    background: var(--mf-surface-soft);
}

.automation-rule-card > legend {
    float: none;
    width: auto;
    margin: 0 0 14px;
    color: var(--mf-text);
    font-size: .95rem;
    font-weight: 700;
}

.automation-rule-card .alert {
    padding: 12px 14px;
    font-size: .82rem;
    line-height: 1.55;
}

/* Marketing reports */
.report-filter-panel {
    padding: 20px 22px;
    margin-bottom: 20px;
}

.report-filter-form {
    --bs-gutter-y: 16px;
}

.report-quick-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.report-quick-ranges .btn {
    min-width: 58px;
}

.report-stat-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.report-stat-grid .mini-stat {
    display: flex;
    min-height: 116px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    padding: 17px 18px;
}

.report-stat-grid .mini-stat strong {
    margin: 2px 0;
    font-size: 1.55rem;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.report-stat-grid .mini-stat small {
    min-height: 2.7em;
    line-height: 1.35;
}

.report-split-row {
    align-items: flex-start;
}

.report-data-panel {
    overflow: hidden;
}

.report-panel-empty {
    min-height: 150px !important;
    padding: 28px 20px !important;
}

.report-panel-empty .empty-state-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    border-radius: 14px;
    font-size: 1.15rem;
}

.report-scheduled-panel .report-panel-empty {
    min-height: 170px !important;
}

.report-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--mf-text-muted);
    font-size: .82rem;
}

.report-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.legend-dot.is-sent,
.report-bar.is-sent { background: var(--mf-primary); }
.legend-dot.is-open,
.report-bar.is-open { background: var(--mf-success); }
.legend-dot.is-click,
.report-bar.is-click { background: var(--mf-warning); }

.report-chart {
    display: grid;
    grid-template-columns: repeat(var(--report-days, 31), minmax(22px, 1fr));
    min-width: 700px;
    min-height: 270px;
    gap: 6px;
    padding: 24px 20px 12px;
    overflow: visible;
    border-top: 1px solid var(--mf-border);
    background: linear-gradient(to top, rgba(226, 232, 240, .52) 1px, transparent 1px) 0 0 / 100% 25%;
}

.panel:has(.report-chart) {
    overflow-x: auto;
}

.report-chart-day {
    position: relative;
    display: grid;
    grid-template-rows: 210px 28px;
    align-items: end;
    min-width: 22px;
    border-radius: 8px;
}

.report-chart-day:focus-visible {
    outline-offset: 0 !important;
}

.report-chart-bars {
    display: flex;
    align-items: end;
    justify-content: center;
    height: 210px;
    gap: 2px;
}

.report-bar {
    width: min(8px, 30%);
    height: var(--bar-height);
    min-height: 0;
    border-radius: 4px 4px 1px 1px;
    transition: opacity var(--mf-transition), transform var(--mf-transition);
}

.report-chart-day:hover .report-bar,
.report-chart-day:focus .report-bar {
    transform: scaleX(1.15);
}

.report-chart-day > small {
    align-self: center;
    color: var(--mf-text-muted);
    font-size: .7rem;
    text-align: center;
}

.report-chart-tooltip {
    position: absolute;
    z-index: 10;
    bottom: calc(100% - 196px);
    left: 50%;
    width: max-content;
    max-width: 220px;
    padding: 7px 9px;
    color: #fff;
    background: var(--mf-text);
    border-radius: 8px;
    box-shadow: var(--mf-shadow-sm);
    font-size: .72rem;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -6px);
    transition: opacity var(--mf-transition), transform var(--mf-transition);
}

.report-chart-day:hover .report-chart-tooltip,
.report-chart-day:focus .report-chart-tooltip {
    opacity: 1;
    transform: translate(-50%, -12px);
}

.report-ranking-list,
.report-link-list {
    display: grid;
}

.report-ranking-list > a {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    min-height: 68px;
    gap: 12px;
    padding: 10px 18px;
    color: var(--mf-text);
    border-top: 1px solid var(--mf-border);
    text-decoration: none;
    transition: background-color var(--mf-transition);
}

.report-ranking-list > a:hover {
    background: var(--mf-surface-soft);
}

.rank-number,
.report-link-icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: var(--mf-primary-dark);
    background: var(--mf-primary-soft);
    border-radius: 10px;
    font-weight: 700;
}

.report-ranking-list small,
.report-link-list small,
.rank-metric small {
    display: block;
    color: var(--mf-text-muted);
    font-size: .75rem;
    font-weight: 400;
}

.rank-metric {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.report-link-list article {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    min-height: 68px;
    gap: 12px;
    padding: 10px 18px;
    border-top: 1px solid var(--mf-border);
}

.report-link-list article > strong {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.report-name-cell {
    max-width: 320px;
}

/* Automation safe simulation */
.simulation-choice {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 12px 11px 38px;
    border: 1px solid var(--mf-border);
    border-radius: 12px;
    background: var(--mf-surface-soft);
}

.simulation-choice:has(.form-check-input:checked) {
    border-color: var(--mf-primary);
    background: var(--mf-primary-soft);
}

.simulation-result {
    border: 1px solid var(--mf-border);
    border-radius: 16px;
    padding: 18px;
    background: linear-gradient(145deg, #f8faff, #fff);
}

.simulation-result-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.simulation-outcome-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    color: var(--mf-primary);
    background: var(--mf-primary-soft);
    font-size: 1.2rem;
}

.simulation-timeline {
    display: grid;
    gap: 8px;
    padding: 0;
    list-style: none;
}

.simulation-timeline > li {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 9px 10px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e8edf7;
}

.simulation-timeline small {
    display: block;
    color: var(--mf-text-muted);
}

.simulation-step-number {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--mf-primary-soft);
    color: var(--mf-primary);
    font-weight: 700;
}

.simulation-timeline > .simulation-empty {
    display: block;
    color: var(--mf-text-muted);
    text-align: center;
    padding: 18px;
}

@media (max-width: 575.98px) {
    .simulation-timeline > li {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .simulation-timeline .status-badge {
        grid-column: 2;
        justify-self: start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .report-bar,
    .report-chart-tooltip,
    .report-ranking-list > a {
        transition: none;
    }
}

@media (max-width: 1199.98px) {
    .report-stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .automation-row {
        grid-template-columns: minmax(260px, 1fr) minmax(300px, .8fr) auto;
    }

    .automation-builder-grid {
        grid-template-columns: minmax(0, 1fr) 280px;
    }
}

@media (max-width: 991.98px) {
    .report-filter-panel {
        padding: 18px;
    }

    .report-filter-form .btn[type="submit"] {
        width: 100%;
    }

    .report-chart {
        grid-template-columns: repeat(14, minmax(14px, 1fr));
        min-width: 0;
    }

    .report-chart-day:nth-last-child(n + 15) {
        display: none;
    }

    .automation-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .automation-metrics {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .automation-metrics span,
    .automation-metrics strong {
        text-align: left;
    }

    .automation-builder-grid {
        grid-template-columns: 1fr;
    }

    .sticky-summary {
        position: static;
    }
}

@media (max-width: 575.98px) {
    .report-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-legend {
        width: 100%;
        justify-content: flex-start;
    }

    .report-chart {
        grid-template-columns: repeat(7, minmax(20px, 1fr));
        gap: 4px;
        padding-inline: 12px;
    }

    .report-chart-day:nth-last-child(n + 8) {
        display: none;
    }
    .automation-row {
        gap: 14px;
        padding: 17px;
    }

    .automation-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .automation-config-panel,
    .automation-workflow-panel,
    .automation-rules-panel,
    .sticky-summary {
        padding: 17px;
    }

    .automation-rule-card {
        padding: 16px;
    }

    .automation-manual-start {
        padding: 14px;
    }

    .automation-step-card > header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .automation-step-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .audience-choice-grid {
        grid-template-columns: 1fr;
    }

    .tag-manager-row {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .tag-manager-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .automation-enroll-quick {
        display: none;
    }
}

@media (max-width: 575.98px) {
    .report-filter-panel {
        padding: 16px;
    }

    .report-quick-ranges {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .report-quick-ranges .btn {
        min-height: 44px;
        min-width: 0;
    }

    .report-stat-grid .mini-stat:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .report-stat-grid .mini-stat {
        min-height: 108px;
        padding: 15px;
    }

    .report-stat-grid .mini-stat small {
        min-height: 0;
    }

    .report-panel-empty,
    .report-scheduled-panel .report-panel-empty {
        min-height: 150px !important;
    }
}
