:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --sidebar: #111827;
    --sidebar-hover: #1f2937;
    --sidebar-text: #f9fafb;
    --sidebar-muted: #9ca3af;
    --text: #101828;
    --muted: #667085;
    --border: #e4e7ec;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --danger: #b42318;
    --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 28px 20px;
    color: var(--sidebar-text);
    background: var(--sidebar);
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px 28px;
}

.sidebar-brand-name {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.sidebar-brand-subtitle {
    color: var(--sidebar-muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: block;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--sidebar-muted);
    font-size: 0.94rem;
    font-weight: 600;
    transition:
        color 160ms ease,
        background 160ms ease;
}

.sidebar-link:hover,
.sidebar-link:focus-visible {
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
    outline: none;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 16px 36px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
}

.topbar-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-username {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.logout-form {
    margin: 0;
}

.logout-btn {
    padding: 8px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    background: var(--surface);
    font-weight: 650;
}

.logout-btn:hover,
.logout-btn:focus-visible {
    border-color: #c7cdd7;
    background: var(--surface-soft);
    outline: none;
}

.content {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 36px;
}

.dashboard-welcome {
    display: flex;
    justify-content: space-between;
    margin-bottom: 28px;
}

.section-eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.dashboard-greeting,
.section-title,
.placeholder-title {
    margin: 0;
    letter-spacing: -0.035em;
}

.dashboard-greeting {
    font-size: clamp(1.8rem, 4vw, 2.65rem);
}

.dashboard-intro,
.placeholder-text {
    margin: 8px 0 0;
    color: var(--muted);
}

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

.metric-card {
    display: flex;
    flex-direction: column;
    min-height: 178px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.03);
    transition:
        transform 160ms ease,
        box-shadow 160ms ease,
        border-color 160ms ease;
}

.metric-card:hover,
.metric-card:focus-visible {
    transform: translateY(-2px);
    border-color: #c7c9ff;
    box-shadow: var(--shadow);
    outline: none;
}

.metric-label {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.metric-value {
    margin-top: 14px;
    font-size: 2.6rem;
    line-height: 1;
    letter-spacing: -0.05em;
}

.metric-action {
    margin-top: auto;
    color: var(--accent);
    font-size: 0.86rem;
    font-weight: 700;
}

.operation-panel,
.placeholder-panel {
    margin-top: 28px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

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

.section-title {
    font-size: 1.4rem;
}

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

.shortcut-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.shortcut-card:hover,
.shortcut-card:focus-visible {
    border-color: #c7c9ff;
    background: #f5f5ff;
    outline: none;
}

.shortcut-card strong {
    font-size: 0.95rem;
}

.shortcut-card span {
    color: var(--muted);
    font-size: 0.84rem;
}

.placeholder-panel {
    max-width: 720px;
}

.placeholder-title {
    font-size: 2rem;
}

.placeholder-actions {
    margin-top: 24px;
}

.primary-link {
    display: inline-flex;
    padding: 10px 15px;
    border-radius: 10px;
    color: #ffffff;
    background: var(--accent);
    font-weight: 700;
}

.primary-link:hover,
.primary-link:focus-visible {
    background: var(--accent-hover);
    outline: none;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, #e7e5ff 0, transparent 34%),
        var(--bg);
}

.login-container {
    width: 100%;
    max-width: 430px;
}

.login-card {
    padding: 38px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-header {
    margin-bottom: 28px;
}

.login-eyebrow {
    display: block;
    margin-bottom: 9px;
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.login-brand {
    margin: 0;
    font-size: 2.1rem;
    letter-spacing: -0.05em;
}

.login-support {
    margin: 7px 0 0;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-label {
    font-size: 0.86rem;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    color: var(--text);
    background: var(--surface);
    outline: none;
}

.login-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.13);
}

.login-btn {
    width: 100%;
    padding: 12px 16px;
    border: 0;
    border-radius: 10px;
    color: #ffffff;
    background: var(--accent);
    font-weight: 750;
}

.login-btn:hover,
.login-btn:focus-visible {
    background: var(--accent-hover);
    outline: none;
}

.form-errors {
    padding: 12px 14px;
    border: 1px solid #fecdca;
    border-radius: 10px;
    background: #fef3f2;
}

.form-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.84rem;
}

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

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

@media (max-width: 760px) {
    .layout {
        display: block;
    }

    .sidebar {
        position: static;
        min-height: auto;
    }

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

    .sidebar-footer {
        margin-top: 20px;
    }

    .topbar {
        position: static;
        align-items: flex-start;
        gap: 14px;
        padding: 18px 20px;
    }

    .topbar-user {
        align-items: flex-end;
        flex-direction: column;
    }

    .content {
        padding: 24px 20px;
    }

    .metrics-grid,
    .shortcut-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .sidebar-nav {
        grid-template-columns: 1fr;
    }

    .topbar-username {
        display: none;
    }

    .login-card {
        padding: 28px 22px;
    }
}

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

.brand-card {
    display: flex;
    flex-direction: column;
    min-height: 230px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.03);
    transition:
        transform 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease;
}

.brand-card:hover,
.brand-card:focus-visible {
    transform: translateY(-2px);
    border-color: #c7c9ff;
    box-shadow: var(--shadow);
    outline: none;
}

.brand-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.brand-platform {
    display: block;
    margin-bottom: 7px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.brand-name {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: -0.035em;
}

.brand-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 750;
    white-space: nowrap;
}

.brand-status-active {
    color: #067647;
    background: #ecfdf3;
}

.brand-status-inactive {
    color: #b42318;
    background: #fef3f2;
}

.brand-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 28px 0;
}

.brand-meta div {
    min-width: 0;
}

.brand-meta dt {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.brand-meta dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    font-size: 0.88rem;
    font-weight: 650;
}

.brand-card .metric-action {
    margin-top: auto;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 36px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    background: var(--surface);
    text-align: center;
}

.empty-state h3 {
    margin: 0 0 7px;
    color: var(--text);
}

.empty-state p {
    margin: 0;
}

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

@media (max-width: 760px) {
    .brand-grid {
        grid-template-columns: 1fr;
    }
}

.brand-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.back-link {
    display: inline-flex;
    margin-bottom: 22px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.back-link:hover,
.back-link:focus-visible {
    color: var(--accent);
    outline: none;
}

.brand-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.detail-card {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-height: 132px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.detail-card-label {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.detail-card-value {
    overflow-wrap: anywhere;
    font-size: 1.05rem;
    line-height: 1.4;
}

.integration-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 750;
    white-space: nowrap;
}

.integration-status-pending {
    color: #b54708;
    background: #fffaeb;
}

.integration-status-connected {
    color: #067647;
    background: #ecfdf3;
}

.integration-status-error {
    color: #b42318;
    background: #fef3f2;
}

.integration-description {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
}

.external-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    color: var(--accent);
    font-weight: 750;
    overflow-wrap: anywhere;
}

.external-link:hover,
.external-link:focus-visible {
    color: var(--accent-hover);
    outline: none;
}

@media (max-width: 760px) {
    .brand-detail-header {
        flex-direction: column;
    }

    .brand-detail-header > .brand-status {
        align-self: flex-start;
    }
}

.scope-panel {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.scope-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.scope-panel-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.scope-count {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 750;
}

.scope-count-ok {
    color: #067647;
    background: #ecfdf3;
}

.scope-count-missing {
    color: #b54708;
    background: #fffaeb;
}

.scope-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scope-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

.scope-item-ok {
    color: #067647;
    background: #ecfdf3;
    border: 1px solid #abefc6;
}

.scope-item-missing {
    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fecdca;
}

.scope-absent-label {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.8;
}

.scope-ready {
    font-size: 0.85rem;
    font-weight: 700;
    color: #067647;
    margin: 0 0 8px 0;
}

.scope-warning {
    font-size: 0.85rem;
    color: #b54708;
    background: #fffaeb;
    border: 1px solid #fedf89;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 8px 0 0 0;
}

.scope-stale-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #b54708;
    margin: 0 0 10px 0;
}

.scope-not-checked {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

.scope-error-msg {
    font-size: 0.85rem;
    color: var(--danger);
    margin: 0;
}

/* ── Commercial summary ─────────────────────────────── */

/* base panel styling inherited from .operation-panel */

.commercial-summary-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.commercial-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 4px 0 0 0;
}

.kpi-currency-badge {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.summary-alert {
    font-size: 0.85rem;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 0 0 16px 0;
}

.summary-alert-warning {
    color: #b54708;
    background: #fffaeb;
    border: 1px solid #fedf89;
}

.summary-alert-info {
    color: #026aa2;
    background: #f0f9ff;
    border: 1px solid #b9e6fe;
}

.kpi-comparison-table {
    margin-top: 20px;
    overflow-x: auto;
}

.kpi-comparison-table table {
    width: 100%;
    border-collapse: collapse;
}

.kpi-metric-col {
    width: 36%;
}

.kpi-period-col {
    text-align: right;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0 14px 24px;
    white-space: nowrap;
}

.kpi-metric-name {
    font-size: 0.875rem;
    color: var(--muted);
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: middle;
}

.kpi-metric-value {
    text-align: right;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    padding: 11px 0 11px 24px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

.commercial-unavailable {
    margin-top: 28px;
    padding: 20px 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.commercial-unavailable-msg {
    font-size: 0.875rem;
    color: var(--muted);
    margin: 0;
}

.ranking-block {
    margin-top: 20px;
}

.ranking-title {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.ranking-th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.ranking-th-num {
    text-align: right;
}

.ranking-row:hover {
    background: var(--bg);
}

.ranking-td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
}

.ranking-td-muted {
    color: var(--muted);
}

.ranking-td-num {
    text-align: right;
    white-space: nowrap;
}

.ranking-sku {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
}

.product-title {
    display: block;
    font-weight: 600;
}

.variant-line {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 4px;
    padding-left: 4px;
}

.variant-line .ranking-sku {
    display: inline;
    margin-left: 4px;
}

.commercial-insight {
    margin-top: 16px;
    padding: 10px 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.commercial-insight-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-transform: uppercase;
    white-space: nowrap;
    padding-top: 3px;
    flex-shrink: 0;
}

.commercial-insight-text {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.45;
    margin: 0;
}

.brand-meta-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.ads-opportunities {
    border-top: 3px solid var(--accent);
}

.ads-opp-header-block {
    margin-bottom: 20px;
}

.ads-opportunity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.ads-opportunity-card {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ads-opportunity-card-winner {
    border-color: var(--accent);
    background: #f5f4ff;
}

.ads-opp-product-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.ads-opp-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.3;
}

.ads-opp-category {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    background: #ede9fe;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

.ads-opp-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ads-opp-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ads-opp-kpi-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.ads-opp-kpi-value {
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.ads-opp-variant {
    font-size: 0.8rem;
    color: var(--muted);
    padding: 6px 8px;
    background: var(--surface);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.ads-opp-variant-label {
    font-weight: 600;
    color: var(--text);
    margin-right: 4px;
}

.ads-opp-creative {
    padding: 8px 10px;
    background: var(--surface);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
}

.ads-opp-creative-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.ads-opp-creative-text {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.4;
    margin: 0;
}

/* ── Meta Ads panel ─────────────────────────────── */

.meta-ads-account-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-ads-account-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 0.25rem;
}

.meta-ads-account-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    color: var(--muted);
}

.meta-ads-account-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

.meta-ads-auth-mode {
    font-weight: 600;
}

.meta-ads-footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.meta-ads-sync-form {
    margin: 0;
}

.meta-ads-sync-date {
    opacity: 0.8;
}

.insights-error-hint {
    color: var(--muted);
    font-size: 0.78rem;
}

.meta-ads-disable-reason {
    color: var(--danger);
    font-weight: 600;
}

.meta-ads-health-grid {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.meta-ads-health-kpi {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 6rem;
}

.meta-ads-health-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.meta-ads-health-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Button utilities ───────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background 160ms ease,
        border-color 160ms ease;
}

.btn-primary {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    outline: none;
}

.btn-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
    background: var(--surface-soft);
    border-color: #c7cdd7;
    outline: none;
}

.mt-2 {
    margin-top: 16px;
}

/* ── Flash messages ──────────────────────────────────────────────────────── */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.flash-info    { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }

/* ── Funding — configuração de saldo ─────────────────────────────────────── */
.funding-config-section {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.funding-section-title {
    padding: 10px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    background: var(--surface-soft);
}
.funding-config-section[open] .funding-section-title {
    border-bottom: 1px solid var(--border);
}
.funding-config-form {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.funding-field-group { display: flex; flex-direction: column; gap: 6px; }
.funding-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-muted); }
.funding-input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
}
.funding-input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.funding-textarea {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--bg);
    color: var(--text);
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    font-family: inherit;
}
.funding-textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.funding-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8125rem;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.preset-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.funding-choices { display: flex; flex-wrap: wrap; gap: 12px; }
.choice-label { font-size: 0.875rem; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.btn-sm { padding: 7px 14px; font-size: 0.8125rem; }
.required-mark { color: var(--danger); }

/* ── Funding — controle de saldo ─────────────────────────────────────────── */
.funding-control-section {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.funding-control-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
}
.funding-control-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.funding-status-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.funding-status-ok         { background: #ecfdf5; color: #065f46; }
.funding-status-attention  { background: #fffbeb; color: #92400e; }
.funding-status-critical   { background: #fef2f2; color: #991b1b; }
.funding-status-unavailable { background: var(--surface-soft); color: var(--text-muted); }
.funding-control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.funding-control-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.funding-control-item:nth-child(2n) { border-right: none; }
.funding-control-item:last-child,
.funding-control-item:nth-last-child(-n+2):nth-child(odd) { border-bottom: none; }
.funding-ctrl-label { font-size: 0.75rem; color: var(--text-muted); }
.funding-ctrl-value { font-size: 0.9375rem; font-weight: 600; color: var(--text); }
.funding-recommended { grid-column: 1 / -1; }
.funding-recommended-value { color: var(--accent); font-size: 1.0625rem; }
.funding-request-form {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid var(--border);
}
.funding-unavailable-hint {
    padding: 12px 14px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Funding alert messages ──────────────────────────────────────────────── */
.funding-alert-msg {
    padding: 10px 14px;
    font-size: 0.8125rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}
.funding-alert-critical {
    color: #991b1b;
    background: #fff5f5;
}
.funding-ctrl-na {
    color: var(--text-muted);
    font-style: italic;
}

/* ── Plan tabs ───────────────────────────────────────────────────────────── */
.plan-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
    scrollbar-width: none;
}
.plan-tabs::-webkit-scrollbar { display: none; }

.plan-tab {
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 120ms ease, border-color 120ms ease;
}
.plan-tab:hover { color: var(--text); }
.plan-tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Scenario grid ───────────────────────────────────────────────────────── */
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
@media (max-width: 1050px) {
    .scenario-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .scenario-grid { grid-template-columns: 1fr; }
}

.scenario-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}
.scenario-card-current  { border-top: 3px solid #667085; }
.scenario-card-desired  { border-top: 3px solid var(--accent); }
.scenario-card-ideal    { border-top: 3px solid #059669; }

.scenario-card-header {
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--border);
}
.scenario-card-type {
    font-size: 0.8rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}
.scenario-card-current  .scenario-card-type { color: #667085; }
.scenario-card-desired  .scenario-card-type { color: var(--accent); }
.scenario-card-ideal    .scenario-card-type { color: #059669; }

/* KPI list inside scenario card */
.scenario-kpi-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}
.scenario-kpi-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8625rem;
}
.scenario-kpi-row:last-child { border-bottom: none; }
.scenario-kpi-row dt {
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}
.scenario-kpi-row dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
}
.scenario-kpi-highlight {
    background: var(--surface-soft);
}
.scenario-kpi-highlight dd {
    font-size: 1rem;
}
.scenario-kpi-divider {
    height: 6px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.scenario-notes {
    padding: 10px 18px;
    font-size: 0.8125rem;
    color: var(--muted);
    margin: 0;
    border-top: 1px solid var(--border);
    font-style: italic;
}

/* ── Scenario comparison strip ───────────────────────────────────────────── */
.scenario-comparison-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
@media (max-width: 900px) {
    .scenario-comparison-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .scenario-comparison-grid { grid-template-columns: 1fr; }
}
.comparison-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}
.comparison-item-label {
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}
.comparison-item-delta {
    font-size: 1.1rem;
    font-weight: 700;
}
.comparison-delta-positive { color: #059669; }
.comparison-delta-negative { color: var(--danger); }

/* ── Projection comparison table ─────────────────────────────────────────── */
.proj-compare-table-wrap {
    overflow-x: auto;
}
.proj-compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.proj-compare-table th,
.proj-compare-table td {
    padding: 9px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.proj-compare-table th {
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-soft);
}
.proj-compare-table td:first-child {
    color: var(--muted);
    font-weight: 500;
}
.proj-compare-table td:not(:first-child) {
    font-weight: 600;
}
.proj-table-section-divider {
    background: var(--bg);
    color: var(--muted);
    font-size: 0.8rem;
    font-style: italic;
    padding: 6px 14px;
}
.proj-row-highlight td {
    background: var(--surface-soft);
    font-weight: 700;
}

/* ── Planner edit form actions ───────────────────────────────────────────── */
.planner-edit-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 24px;
    padding-top: 16px;
}

/* ── Plan list scenario label ────────────────────────────────────────────── */
.plan-list-scenario-label {
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent);
}
