.app-config-tabs {
    display: flex;
    overflow-x: auto;
    overflow-y: visible;
    white-space: nowrap;
    scrollbar-width: thin;
    padding-top: 0.25rem;
    margin-top: 0.45rem;
}

.app-config-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 2.9rem;
    padding: 0 0.85rem;
    border: 1px solid transparent;
    border-bottom: 1px solid var(--cs-border);
    color: var(--cs-text-muted);
    background: transparent;
    font-size: 0.84rem;
    font-weight: 600;
    transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.app-config-tab svg {
    width: 1rem;
    height: 1rem;
}

.app-config-tab.is-active {
    border-color: var(--cs-border);
    border-bottom-color: var(--cs-surface);
    border-radius: 0.55rem 0.55rem 0 0;
    color: var(--cs-text);
    background: var(--cs-surface);
}

.app-config-tab:not(.is-active):hover {
    border-color: color-mix(in srgb, var(--cs-text-muted) 24%, var(--cs-border));
    border-bottom-color: color-mix(in srgb, var(--cs-text-muted) 40%, var(--cs-border));
    border-radius: 0.5rem 0.5rem 0 0;
    background: color-mix(in srgb, var(--cs-btn-secondary-hover) 72%, var(--cs-surface));
    color: var(--cs-text);
    transform: translateY(-0.5px) scale(1.02);
    box-shadow: 0 10px 18px color-mix(in srgb, var(--cs-text) 12%, transparent);
}

.app-config-tab:not(.is-active):active {
    transform: translateY(0) scale(0.99);
    box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    .app-config-tab {
        transition: border-color 0ms linear, background 0ms linear, color 0ms linear, transform 0ms linear, box-shadow 0ms linear;
    }

    .app-config-tab:not(.is-active):hover,
    .app-config-tab:not(.is-active):active {
        transform: none;
        box-shadow: none;
    }
}

/* Flash no topo: mesma faixa em largura total que auth (`public_auth_forms.css`) e checkout (`sis_checkout.css`). */
.app-config-flash-strip {
    width: 100%;
    min-width: 0;
}

.app-config-flash-strip .cs-alert {
    width: 100%;
    max-width: 100%;
    display: flex;
    box-sizing: border-box;
}

.app-config-form-wrap {
    margin-top: 1.1rem;
    padding: 0;
    border: 0;
    background: transparent;
}

/* Blindagem visual: impede imagens "estouradas" na tela de configuracoes. */
.app-config-form-wrap img {
    max-width: 100%;
    max-height: 5rem;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Blindagem de SVG no formulario de configuracoes (evita icone gigante apos submits). */
.app-config-form-wrap svg {
    width: 1.25rem;
    height: 1.25rem;
    max-width: 1.25rem;
    max-height: 1.25rem;
}

/* Garantia para alerts de flash apos submit em qualquer aba de configuracoes. */
.app-card .cs-alert-icon {
    width: 1.25rem !important;
    height: 1.25rem !important;
    max-width: 1.25rem !important;
    max-height: 1.25rem !important;
}

.app-config-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: 1fr;
}

@media (min-width: 760px) {
    .app-config-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1240px) {
    .app-config-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.app-config-col-2 {
    grid-column: span 1;
}

@media (min-width: 760px) {
    .app-config-col-2 {
        grid-column: span 2;
    }
}

.app-config-col-4 {
    grid-column: 1 / -1;
}

.app-config-section-title {
    margin-top: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--cs-border);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--cs-text-muted);
}

.app-config-grid input[type='checkbox'].app-auth-input {
    width: 1rem;
    height: 1rem;
    min-height: 1rem;
    padding: 0;
}

.app-config-inline-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--cs-text);
}

.app-config-inline-check input[type='checkbox'] {
    width: 1rem;
    height: 1rem;
}

.app-config-image-preview-wrap {
    display: inline-flex;
    margin-bottom: 0.45rem;
    max-width: 14rem;
    border: 1px solid var(--cs-border);
    border-radius: 0.5rem;
    padding: 0.35rem;
    background: var(--cs-surface-elevated);
}

.app-config-image-preview {
    display: block;
    max-width: 100%;
    max-height: 4rem;
    object-fit: contain;
}

.app-config-textarea-lg {
    min-height: 8rem;
}

.app-config-password-wrap {
    position: relative;
    display: block;
}

.app-config-password-input {
    padding-right: 2.6rem;
}

.app-config-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.3rem;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
}

.app-config-smtp-log-wrap {
    margin-top: 0.15rem;
}

.app-config-smtp-log {
    margin: 0;
    border: 1px solid var(--cs-border);
    border-radius: 0.55rem;
    background: var(--cs-surface-elevated);
    padding: 0.65rem;
    max-height: 14rem;
    overflow: auto;
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--cs-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.app-config-tags-list {
    display: grid;
    gap: 0.45rem;
}

.app-config-template-edit-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.9rem;
}

@media (min-width: 1240px) {
    .app-config-template-edit-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}

.app-config-template-panel {
    border: 1px solid var(--cs-border);
    border-radius: 0.85rem;
    background: var(--cs-surface);
    overflow: hidden;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-config-template-panel--form,
.app-config-template-panel--tags {
    grid-column: span 12;
}

@media (min-width: 1240px) {
    .app-config-template-panel--form {
        grid-column: span 8;
    }

    .app-config-template-panel--tags {
        grid-column: span 4;
    }
}

.app-config-template-panel-head {
    padding: 1rem 1rem 0.9rem;
    border-bottom: 1px solid var(--cs-border);
}

.app-config-template-panel-body {
    padding: 0.95rem 1rem;
    display: grid;
    gap: 0.85rem;
    flex: 1;
    min-height: 0;
}

.app-config-template-panel-body--tags {
    height: 100%;
    overflow: auto;
}

.app-config-template-panel-foot {
    padding: 0.9rem 1rem;
    border-top: 1px solid var(--cs-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.app-config-template-html {
    min-height: 16rem;
}

.app-config-tag-item {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.8rem;
    color: var(--cs-text-muted);
}

.app-config-tag-item code {
    display: inline-flex;
    border: 1px solid var(--cs-border);
    border-radius: 0.4rem;
    padding: 0.1rem 0.35rem;
    background: var(--cs-surface-elevated);
    color: var(--cs-text);
    white-space: nowrap;
}

.app-config-template-listing-wrap {
    margin-top: 0.2rem;
}

.app-btn-preview {
    border: 1px solid transparent;
    background: #7c3aed;
    color: #ffffff;
}

.app-btn-preview:hover {
    background: #6d28d9;
}

.app-config-template-preview-modal-panel {
    max-width: min(62rem, calc(100vw - 1.5rem));
}

.app-config-template-preview-box {
    margin-top: 0.9rem;
    border: 1px solid var(--cs-border);
    border-radius: 0.75rem;
    background: var(--cs-surface-elevated);
    padding: 0.8rem;
}

.app-config-template-preview-subject-label {
    margin: 0 0 0.35rem 0;
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--cs-text-muted);
}

.app-config-template-preview-subject {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--cs-text);
}

.app-config-template-preview-frame {
    width: 100%;
    min-height: min(58vh, 38rem);
    border: 1px solid var(--cs-border);
    border-radius: 0.55rem;
    background: #ffffff;
}

.app-config-template-list-wrap {
    overflow-x: auto;
}

.app-config-flags-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

@media (min-width: 640px) {
    .app-config-flags-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1240px) {
    .app-config-flags-row--payments {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

