:root {
    --font-body: 'Manrope', 'Segoe UI', sans-serif;
    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --bg-body: #f1f5f9;
    --surface-bg: #ffffff;
    --surface-border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --info-text: #0284c7;
    --status-active-bg: #d1fae5;
    --status-active-text: #059669;
    --status-paused-bg: #ffe4e6;
    --status-paused-text: #e11d48;
    --status-error-bg: #dc2626;
    --status-error-text: #ffffff;
    --table-header: #f8fafc;
    --table-hover: #f1f5f9;
    --table-border: #e2e8f0;
    --row-level-1: #e2e8f0;
    --row-level-2: #f1f5f9;
    --row-level-3: #f8fafc;
    --row-level-4: #ffffff;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --color-scheme: light;
    --camp-color: #4f46e5;
    --adset-color: #0ea5e9;
    --col-struct-width: 560px;
}

[data-theme="dark"] {
    --bg-body: #090e17;
    --surface-bg: #111827;
    --surface-border: #1f2937;
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --primary-color: #818cf8;
    --primary-hover: #a5b4fc;
    --info-text: #38bdf8;
    --status-active-bg: rgba(16, 185, 129, 0.15);
    --status-active-text: #34d399;
    --status-paused-bg: rgba(244, 63, 94, 0.15);
    --status-paused-text: #fb7185;
    --status-error-bg: #991b1b;
    --status-error-text: #ffffff;
    --table-header: #0f172a;
    --table-hover: #26334a;
    --table-border: #1f2937;
    --row-level-1: #111827;
    --row-level-2: #162032;
    --row-level-3: #1a2333;
    --row-level-4: #1f2937;
    --input-bg: #111827;
    --input-border: #374151;
    --color-scheme: dark;
    --camp-color: #a5b4fc;
    --adset-color: #7dd3fc;
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

body {
    background-color: var(--bg-body);
    font-family: var(--font-body);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.8rem;
}

body.app-booting {
    overflow: hidden;
}

body.app-booting .dashboard-shell {
    opacity: 0;
    pointer-events: none;
}

body:not(.app-booting) .dashboard-shell {
    opacity: 1;
    transition: opacity 0.22s ease;
}

#bootSplash {
    position: fixed;
    inset: 0;
    z-index: 10200;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: all;
}

#bootSplash.is-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

#networkLoader {
    position: fixed;
    inset: 0;
    z-index: 10150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#networkLoader.is-visible {
    opacity: 1;
    pointer-events: all;
}

.network-loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 10, 18, 0.62);
    backdrop-filter: blur(3px);
}

.network-loader-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 430px);
    padding: 1.2rem 1.2rem 1.35rem;
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    background:
        radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.22), transparent 38%),
        linear-gradient(155deg, rgba(15, 23, 42, 0.97), rgba(11, 18, 36, 0.98));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
    text-align: center;
}

.network-loader-mascot {
    display: block;
    width: min(78vw, 260px);
    max-height: 300px;
    margin: -0.55rem auto 0.15rem;
    object-fit: contain;
    filter: drop-shadow(0 10px 30px rgba(56, 189, 248, 0.22));
}

.network-loader-title {
    color: #f8fafc;
    font-weight: 700;
    font-size: 1rem;
    margin-top: 0.15rem;
}

.network-loader-text {
    color: #bfdbfe;
    font-size: 0.8rem;
    margin-top: 0.32rem;
    line-height: 1.45;
}

.network-loader-rings {
    position: relative;
    width: 52px;
    height: 52px;
    margin: 0.15rem auto 0;
}

.network-loader-rings span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    border: 2px solid transparent;
    border-top-color: #60a5fa;
    border-right-color: #818cf8;
    animation: netRing 1.15s linear infinite;
}

.network-loader-rings span:nth-child(2) {
    inset: 6px;
    border-top-color: #38bdf8;
    border-right-color: #6366f1;
    animation-duration: 0.9s;
    animation-direction: reverse;
}

.network-loader-rings span:nth-child(3) {
    inset: 12px;
    border-top-color: #93c5fd;
    border-right-color: #a5b4fc;
    animation-duration: 0.68s;
}

@keyframes netRing {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.boot-splash-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(99,102,241,0.28), transparent 28%),
        radial-gradient(circle at 80% 25%, rgba(59,130,246,0.18), transparent 24%),
        radial-gradient(circle at 65% 80%, rgba(34,211,238,0.16), transparent 24%),
        linear-gradient(135deg, #08111d 0%, #0b1328 40%, #101935 100%);
}

.boot-splash-content {
    position: relative;
    z-index: 1;
    width: min(92vw, 620px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    text-align: center;
    color: #e2e8f0;
}

.boot-splash-zeus {
    display: block;
    width: min(78vw, 364px);
    max-height: 364px;
    margin: 0 auto 0.15rem;
    object-fit: contain;
    filter:
        drop-shadow(0 0 18px rgba(56, 189, 248, 0.18))
        drop-shadow(0 16px 40px rgba(37, 99, 235, 0.22));
}

.boot-logo {
    width: 74px;
    height: 74px;
    margin: 0 auto 1rem;
    border-radius: 22px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(129,140,248,0.32), rgba(56,189,248,0.18));
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 18px 45px rgba(0,0,0,0.35);
    font-size: 2rem;
    color: #c7d2fe;
}

.boot-splash-content h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2.5vw, 1.9rem);
    color: #fff;
    text-shadow: 0 10px 30px rgba(15, 23, 42, 0.45);
}

.boot-splash-content p {
    margin: 0 0 0.9rem;
    max-width: 520px;
    color: rgba(226,232,240,0.82);
    text-shadow: 0 8px 24px rgba(15, 23, 42, 0.4);
}

.boot-loader {
    display: inline-flex;
    gap: 0.45rem;
}

.boot-loader span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #818cf8;
    animation: bootBounce 0.9s infinite ease-in-out;
}

.boot-loader span:nth-child(2) { animation-delay: 0.12s; }
.boot-loader span:nth-child(3) { animation-delay: 0.24s; }

@keyframes bootBounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.45; }
    40% { transform: scale(1); opacity: 1; }
}

.dashboard-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

body.sidebar-collapsed .dashboard-shell {
    grid-template-columns: 92px minmax(0, 1fr);
}

.analytics-scope-chip {
    min-height: 31px;
    display: flex;
    align-items: center;
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.18);
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 600;
}

.overview-insight-strip {
    min-height: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.analytics-insight-item {
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.analytics-insight-wide {
    grid-column: 1 / -1;
}

.analytics-insight-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-bottom: 0.2rem;
}

.analytics-insight-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.analytics-insight-sub {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-top: 0.15rem;
}

.analytics-scoreboard-table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom-color: var(--table-border);
}

.analytics-scoreboard-table tbody tr {
    cursor: pointer;
    transition: background-color 0.18s ease;
}

.analytics-scoreboard-table tbody tr:hover,
.analytics-row-active {
    background: rgba(96, 165, 250, 0.08);
}

.analytics-empty-state {
    padding: 1.2rem 0.8rem;
    border-radius: 12px;
    border: 1px dashed rgba(148, 163, 184, 0.24);
    color: var(--text-muted);
    text-align: center;
}

.analytics-campaign-card {
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    border: 1px solid var(--surface-border);
    background: rgba(148, 163, 184, 0.05);
}

.analytics-card-header-row,
.analytics-card-footer-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.analytics-card-footer-row {
    align-items: center;
    margin-top: 0.9rem;
}

.analytics-card-side-meta {
    min-width: 170px;
}

.analytics-metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.55rem;
    margin-top: 0.85rem;
}

.analytics-metric-tile {
    padding: 0.6rem 0.7rem;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(148, 163, 184, 0.08));
    min-height: 84px;
}

.analytics-metric-tile.is-primary {
    border-color: rgba(14, 165, 233, 0.28);
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.12), rgba(14, 165, 233, 0.04));
}

.analytics-metric-tile.is-success {
    border-color: rgba(16, 185, 129, 0.24);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.04));
}

.analytics-metric-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.analytics-metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.analytics-metric-subvalue {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.analytics-metric-subvalue.is-emphasis {
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.35;
    color: var(--text-main);
}

.analytics-metric-subvalue.is-emphasis .metric-source-breakdown {
    font-size: 0.98rem;
}

.analytics-metric-subvalue.is-emphasis .metric-source-counts {
    font-size: 0.78rem;
}

.metric-source-breakdown {
    display: block;
    color: var(--text-main);
    font-weight: 800;
    line-height: 1.35;
}

.metric-source-counts {
    display: block;
    margin-top: 0.18rem;
    background: transparent;
    backdrop-filter: none;
}

.analytics-delta-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.34rem 0.62rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.keytaro-mapping-badge {
    min-width: 2rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.32rem 0.58rem;
    font-size: 0.72rem;
}

.keytaro-mapping-badge-dep {
    background: rgba(14, 165, 233, 0.16);
    color: #0f172a;
    border: 1px solid rgba(14, 165, 233, 0.28);
}

.keytaro-mapping-badge-sale {
    background: rgba(16, 185, 129, 0.16);
    color: #0f172a;
    border: 1px solid rgba(16, 185, 129, 0.28);
}

[data-theme="dark"] .keytaro-mapping-badge-dep {
    color: #e0f2fe;
    border-color: rgba(56, 189, 248, 0.28);
}

[data-theme="dark"] .keytaro-mapping-badge-sale {
    color: #dcfce7;
    border-color: rgba(52, 211, 153, 0.28);
}

.analytics-delta-pill.is-positive {
    color: #047857;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.22);
}

.analytics-delta-pill.is-negative {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.22);
}

.analytics-alert-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.analytics-alert-card {
    border-radius: 14px;
    padding: 0.85rem 0.9rem;
    border: 1px solid var(--surface-border);
    background: rgba(148, 163, 184, 0.05);
}

.analytics-alert-high {
    border-color: rgba(244, 63, 94, 0.35);
    background: rgba(244, 63, 94, 0.08);
}

.analytics-alert-medium {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
}

.analytics-alert-title {
    font-weight: 700;
    font-size: 0.82rem;
}

.analytics-alert-meta {
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.72rem;
}

@media (max-width: 991px) {
    .overview-insight-strip {
        grid-template-columns: 1fr;
    }

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

.app-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    padding: 1.25rem 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    border-right: 1px solid var(--surface-border);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
        var(--surface-bg);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    transition: transform 0.28s ease, width 0.28s ease, padding 0.28s ease;
}

body.sidebar-collapsed .app-sidebar {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

body.sidebar-collapsed .sidebar-brand-sub,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-nav-btn span,
body.sidebar-collapsed .sidebar-actions .btn-custom span,
body.sidebar-collapsed .sidebar-brand-title,
body.sidebar-collapsed #authBtn {
    display: none;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
}

body.sidebar-collapsed .sidebar-footer-actions {
    grid-template-columns: 1fr;
}

body.sidebar-collapsed .sidebar-nav-btn,
body.sidebar-collapsed .sidebar-actions .btn-custom,
body.sidebar-collapsed .sidebar-footer-actions .btn-custom {
    justify-content: center;
    padding-left: 0.6rem;
    padding-right: 0.6rem;
}

.app-main {
    min-width: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.sidebar-brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), #38bdf8);
    box-shadow: 0 12px 28px rgba(79,70,229,0.25);
}

.sidebar-brand-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.sidebar-brand-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sidebar-section-label {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 0.25rem;
}

.sidebar-nav,
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.sidebar-nav-btn,
.sidebar-actions .btn-custom,
.sidebar-footer-actions .btn-custom {
    justify-content: flex-start;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
}

.sidebar-nav-btn:hover {
    background: var(--table-hover);
    border-color: var(--surface-border);
}

.sidebar-nav-btn.text-info {
    color: var(--primary-color) !important;
}

.sidebar-service-link {
    text-decoration: none;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 16px;
    align-items: start;
    gap: 0.7rem;
}

.sidebar-service-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-service-title {
    font-weight: 700;
    line-height: 1.15;
}

.sidebar-service-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 0.12rem;
}

.sidebar-service-arrow {
    opacity: 0.7;
    margin-top: 0.18rem;
}

body.sidebar-collapsed .sidebar-service-copy,
body.sidebar-collapsed .sidebar-service-arrow {
    display: none;
}

body.sidebar-collapsed .sidebar-service-link {
    grid-template-columns: 1fr;
    justify-items: center;
}

.audit-diff-item {
    color: rgba(226,232,240,0.82);
    text-shadow: 0 8px 24px rgba(15, 23, 42, 0.4);
    grid-template-columns: minmax(72px, 120px) minmax(0, 1fr) 22px minmax(0, 1fr);
    gap: 0.35rem;
    align-items: center;
    font-size: 0.72rem;
}

.audit-diff-key {
    color: var(--text-muted);
    font-weight: 700;
    text-transform: lowercase;
}

.audit-diff-before,
.audit-diff-after {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--surface-border);
    background: var(--table-header);
    word-break: break-word;
}

.audit-diff-arrow {
    color: var(--text-muted);
    text-align: center;
    opacity: 0.8;
}

.audit-diff-after {
    border-color: rgba(34, 197, 94, 0.35);
}

.audit-diff-more {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 0.1rem;
}

.security-checklist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.security-checklist li {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: center;
    font-size: 0.8rem;
}

.sidebar-footer-actions {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr 48px;
    gap: 0.55rem;
    padding-top: 0.25rem;
}

.app-sidebar::-webkit-scrollbar {
    width: 10px;
}

.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.38);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.app-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.58);
    background-clip: padding-box;
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sidebar-toggle-btn {
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 14px;
    font-size: 1.05rem;
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.18);
}

.sidebar-toggle-btn-panel {
    align-self: flex-end;
    margin-bottom: 0.35rem;
    position: sticky;
    top: 0.55rem;
    z-index: 6;
}

body.sidebar-collapsed .sidebar-toggle-btn-panel {
    align-self: center;
}

.sidebar-toggle-btn-mobile {
    display: none;
}

.app-topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 56px;
    min-width: min(100%, 320px);
    padding: 0.5rem 0.75rem;
    border-radius: 16px;
}

.topbar-user-avatar {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.28);
    display: grid;
    place-items: center;
    color: #dbe6ff;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.topbar-user-copy {
    min-width: 0;
}

.topbar-user-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.82rem;
    line-height: 1.2;
}

.topbar-user-meta,
.topbar-user-scope {
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-decoy {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.token-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.token-input[readonly] {
    caret-color: transparent;
}

.token-textarea {
    min-height: 32px;
    max-height: 84px;
    resize: vertical;
    overflow-y: auto;
    line-height: 1.2;
}

#sidebarBackdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.58);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
    z-index: 998;
}

#authOverlay {
    display: none;
}

body.dragging,
body.dragging * {
    cursor: grabbing !important;
    user-select: none !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    letter-spacing: -0.015em;
    font-weight: 600;
    color: var(--text-main);
}

#pageTitle,
.sidebar-brand-title,
.kpi-value {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.saas-card {
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.btn-custom {
    border: 1px solid var(--surface-border);
    background: var(--surface-bg);
    color: var(--text-main);
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-weight: 500;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.btn-custom:hover {
    background: var(--table-hover);
    border-color: var(--text-muted);
    color: var(--text-main);
}

.btn-primary-saas {
    background: var(--primary-color);
    color: #fff;
    border: none;
}

.btn-primary-saas:hover {
    background: var(--primary-hover);
    color: #fff;
}

.btn-primary-saas:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-danger-saas {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(220, 38, 38, 0.18);
}

.btn-danger-saas:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
}

.btn-danger-saas:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.form-control,
.form-select {
    background-color: var(--input-bg);
    color: var(--text-main);
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 0.8rem;
    color-scheme: var(--color-scheme);
    padding: 0.25rem 0.5rem;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--input-bg);
    color: var(--text-main);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.file-upload-wrapper {
    position: relative;
    width: 100%;
    flex: 1;
}

.file-upload-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px dashed var(--input-border);
    color: var(--text-main);
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
    font-weight: 500;
    transition: all 0.2s ease;
    height: 100%;
    cursor: pointer;
}

[data-theme="dark"] .file-upload-label {
    background: rgba(255, 255, 255, 0.02);
}

.file-upload-wrapper:hover .file-upload-label {
    background: var(--table-hover);
    border-color: var(--primary-color);
}

.cabinet-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    --cab-col-struct-width: var(--col-struct-width);
}

.cabinet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--surface-border);
    background: linear-gradient(120deg, rgba(16, 185, 129, 0.1), rgba(14, 165, 233, 0.06) 50%, rgba(99, 102, 241, 0.05));
    z-index: 30;
}

#workspaceArea .btn,
#workspaceArea .btn-custom,
#workspaceArea .btn-primary-saas,
#workspaceArea .btn-outline-secondary,
#workspaceArea .btn-outline-info,
#workspaceArea .btn-outline-warning,
#workspaceArea .btn-outline-danger,
#workspaceArea .workspace-tabs-scroll-btn {
    border-radius: 10px !important;
}

.cabinet-header h6 {
    color: var(--text-main);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.cabinet-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.45rem;
}

.cabinet-header-meta__item {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #0f172a;
    font-size: 0.72rem;
    font-weight: 700;
}

[data-theme="dark"] .cabinet-header h6 {
    color: #f8fafc;
    text-shadow: none;
}

[data-theme="dark"] .cabinet-header-meta__item {
    background: rgba(15, 23, 42, 0.58);
    border-color: rgba(148, 163, 184, 0.22);
    color: #e2e8f0;
}

.cab-hide-inactive-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.5rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(15, 23, 42, 0.14);
    margin-left: 0.45rem;
}

.cab-hide-inactive-toggle .form-check-input {
    margin-top: 0;
}

.cab-hide-inactive-toggle .form-check-label {
    color: #0f172a;
    font-weight: 700;
}

[data-theme="dark"] .cab-hide-inactive-toggle {
    background: rgba(248, 250, 252, 0.08);
    border-color: rgba(248, 250, 252, 0.2);
}

[data-theme="dark"] .cab-hide-inactive-toggle .form-check-label {
    color: #f8fafc;
}

[data-theme="dark"] .tree-table th {
    color: #dbe7ff;
}

[data-theme="dark"] .tree-table td,
[data-theme="dark"] .metric-val,
[data-theme="dark"] .name-camp,
[data-theme="dark"] .name-adset {
    color: #edf4ff;
}

[data-theme="dark"] .tree-table td.text-muted,
[data-theme="dark"] .tree-table .text-muted {
    color: #c9d6ee !important;
}

[data-theme="dark"] .cabinet-header {
    background: linear-gradient(120deg, rgba(16, 185, 129, 0.22), rgba(14, 165, 233, 0.18) 52%, rgba(15, 23, 42, 0.45));
}

.fullscreen-mode,
.cabinet-card:fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: var(--bg-body) !important;
    display: flex;
    flex-direction: column;
}

.fullscreen-mode .table-container,
.cabinet-card:fullscreen .table-container {
    flex-grow: 1;
    min-height: 0;
    max-height: none !important;
    overflow: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
}

.table-container {
    width: 100%;
    max-height: calc(100vh - 250px);
    overflow: auto;
    background: var(--surface-bg);
    cursor: grab;
}

.cabinet-header .custom-select {
    min-width: 132px;
}

.cabinet-header .custom-select__trigger {
    min-height: 28px;
    border-radius: 999px;
    background: rgba(12, 23, 44, 0.82);
    border-color: rgba(129, 140, 248, 0.26);
    font-size: 0.74rem;
    padding: 0.24rem 0.55rem;
}

.cabinet-header .custom-select__dropdown {
    border-radius: 12px;
    z-index: 10030;
}

.cabinet-header .custom-select__option {
    font-size: 0.74rem;
}

.tree-table {
    width: 100%;
    min-width: 1680px;
    border-collapse: separate;
    border-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.tree-table th,
.tree-table td {
    padding: 0.32rem 0.5rem;
    border-bottom: 1px solid var(--table-border);
    white-space: nowrap;
    vertical-align: middle;
    line-height: 1.3;
    font-size: 0.78rem;
}

.tree-table th {
    background-color: var(--table-header);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 0 var(--table-border);
}

.tree-table tr:hover td {
    background-color: var(--table-hover) !important;
}

.level-1 {
    background-color: var(--row-level-1);
    font-weight: 600;
}

.level-1.row-total-sticky {
    position: sticky;
    top: var(--table-header-height, 40px);
    z-index: 19;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.level-1.row-total-sticky td {
    font-size: 0.83rem;
    font-weight: 700;
    color: var(--text-main);
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.08), rgba(16, 185, 129, 0.06));
}

.level-1.row-total-sticky .metric-val,
.level-1.row-total-sticky .metric-val .text-muted,
.level-1.row-total-sticky .val-info,
.level-1.row-total-sticky .val-success {
    color: #0f172a !important;
    font-weight: 800;
}

[data-theme="dark"] .level-1.row-total-sticky td {
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.2), rgba(16, 185, 129, 0.16));
}

[data-theme="dark"] .level-1.row-total-sticky .metric-val,
[data-theme="dark"] .level-1.row-total-sticky .metric-val .text-muted,
[data-theme="dark"] .level-1.row-total-sticky .val-info,
[data-theme="dark"] .level-1.row-total-sticky .val-success {
    color: #f8fafc !important;
}

.level-2 {
    background-color: var(--row-level-2);
    font-weight: 500;
    border-top: 2px solid var(--table-border);
    border-bottom: 1px solid var(--table-border);
}

.level-2:first-of-type {
    border-top: none;
}

.level-2:hover {
    background-color: var(--camp-color) !important;
    background-color: rgba(79, 70, 229, 0.06) !important;
}

.level-2 .col-struct {
    font-weight: 600;
    color: var(--camp-color);
}

.level-3 {
    background-color: var(--row-level-3);
    border-left: 3px solid var(--adset-color);
    padding-left: 0.4rem;
}

.level-4 {
    background-color: var(--row-level-4);
    border-left: 1px dotted var(--adset-color);
}

.col-cb {
    width: 26px;
    min-width: 26px;
    max-width: 26px;
    position: sticky;
    left: 0;
    z-index: 15;
    text-align: center;
    border-right: none !important;
}

.col-struct {
    width: var(--cab-col-struct-width, var(--col-struct-width));
    min-width: var(--cab-col-struct-width, var(--col-struct-width));
    max-width: var(--cab-col-struct-width, var(--col-struct-width));
    position: sticky;
    left: 26px;
    z-index: 15;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    border-right: 1px solid var(--table-border);
}

.col-toggle {
    width: 78px;
    min-width: 78px;
    max-width: 78px;
    text-align: center;
}

.tree-table .col-cb .form-check-input,
.tree-table .row-cb {
    width: 1.08rem;
    height: 1.08rem;
    margin: 0;
    border-radius: 0.34rem;
    border: 1px solid rgba(148, 163, 184, 0.72);
    background-color: rgba(255, 255, 255, 0.85);
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.14s ease;
    cursor: pointer;
    vertical-align: middle;
}

[data-theme="dark"] .tree-table .col-cb .form-check-input,
[data-theme="dark"] .tree-table .row-cb {
    background-color: rgba(15, 23, 42, 0.72);
    border-color: rgba(148, 163, 184, 0.56);
}

.tree-table .col-cb .form-check-input:hover,
.tree-table .row-cb:hover {
    border-color: rgba(14, 165, 233, 0.62);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.14);
    transform: translateY(-1px);
}

.tree-table .col-cb .form-check-input:checked,
.tree-table .row-cb:checked {
    background-color: #0ea5e9;
    border-color: #0284c7;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.22);
}

.tree-table .col-cb .form-check-input:focus,
.tree-table .row-cb:focus {
    border-color: rgba(14, 165, 233, 0.75);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}

.status-switch {
    cursor: pointer;
    width: 2.56rem !important;
    height: 1.38rem;
    border-radius: 999px !important;
    border: 1px solid rgba(148, 163, 184, 0.55);
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.14s ease;
    box-shadow: inset 0 0 0 1px rgba(2, 6, 23, 0.08);
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%) !important;
}

.status-switch:checked {
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%) !important;
    border-color: #16a34a !important;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.status-switch:not(:checked) {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.status-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 0.98rem;
    height: 0.98rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
    box-shadow: 0 3px 8px rgba(2, 6, 23, 0.25);
    transition: transform 0.2s ease, background 0.2s ease;
}

.status-switch:checked::after {
    transform: translateX(1.14rem);
}

.status-switch:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.3);
}

.status-switch:hover {
    transform: translateY(-1px);
}

.status-switch:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── Table Theme: KeyTaro (workspace table only) ───────────────────────── */

body.table-theme-keitaro {
    --col-struct-width: 500px;
}

body.table-theme-keitaro .cabinet-header {
    background: linear-gradient(120deg, #d8ecdd, #e7f2e8 55%, #eef7ef);
}

body.table-theme-keitaro .cabinet-header h6 {
    color: #214137;
    text-shadow: none;
}

body.table-theme-keitaro .cab-hide-inactive-toggle {
    background: rgba(33, 65, 55, 0.08);
    border-color: rgba(33, 65, 55, 0.2);
}

body.table-theme-keitaro .cab-hide-inactive-toggle .form-check-label {
    color: #214137;
}

body.table-theme-keitaro #workspaceArea,
body.table-theme-keitaro #integrationControlArea {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}

body.table-theme-keitaro #integrationControlArea {
    margin-bottom: 0.45rem !important;
}

body.table-theme-keitaro #workspaceArea .saas-card,
body.table-theme-keitaro #integrationControlArea .saas-card {
    background: #f3f3f4;
    border: 1px solid #d9d9dd;
    border-radius: 2px;
    box-shadow: none;
}

body.table-theme-keitaro #integrationControlArea .btn-custom,
body.table-theme-keitaro #integrationControlArea .btn-primary-saas,
body.table-theme-keitaro #integrationControlArea .form-select,
body.table-theme-keitaro #integrationControlArea .form-control,
body.table-theme-keitaro #integrationControlArea .custom-select__trigger {
    min-height: 30px;
    border-radius: 2px !important;
    border: 1px solid #cfd4dd;
    background: #f7f7f8;
    color: #2e3440;
    box-shadow: none;
    font-size: 0.74rem;
    font-weight: 500;
}

body.table-theme-keitaro #integrationControlArea .btn-custom:hover,
body.table-theme-keitaro #integrationControlArea .btn-primary-saas:hover,
body.table-theme-keitaro #integrationControlArea .custom-select__trigger:hover {
    background: #f1f3f6;
    border-color: #bcc5d2;
    color: #2d3440;
}

body.table-theme-keitaro #integrationControlArea .btn-primary-saas {
    background: #ecf1f8;
    border-color: #c4cfdf;
    color: #35517a;
}

body.table-theme-keitaro #integrationControlArea .form-check-input {
    width: 0.9rem;
    height: 0.9rem;
    margin-top: 0.08rem;
    border-radius: 0.14rem;
    border: 1px solid #b9c2cf;
}

body.table-theme-keitaro #integrationControlArea .form-check-label {
    color: #586273;
    font-size: 0.72rem;
}

body.table-theme-keitaro .table-container {
    background: #eef4ef;
    border: 1px solid #cfdccf;
    border-radius: 2px;
}

body.table-theme-keitaro .tree-table {
    min-width: 1640px;
    font-size: 0.73rem;
    border: 1px solid #cfdccf;
    border-radius: 0;
    background: #f9fdf9;
    box-shadow: none;
}

body.table-theme-keitaro .tree-table th,
body.table-theme-keitaro .tree-table td {
    border-bottom: 1px solid #d6e2d7;
    border-right: 1px solid #e6eee6;
    padding: 0.24rem 0.42rem;
    line-height: 1.2;
    color: #27343a;
}

body.table-theme-keitaro .tree-table td {
    font-weight: 400;
}

body.table-theme-keitaro .tree-table th:last-child,
body.table-theme-keitaro .tree-table td:last-child {
    border-right: none;
}

body.table-theme-keitaro .tree-table th {
    background: #e8f1ea;
    color: #4d6057;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 0 #cfdccf;
}

body.table-theme-keitaro .tree-table .sortable {
    color: #4d6057;
}

body.table-theme-keitaro .tree-table .sort-icon {
    opacity: 0.5;
}

body.table-theme-keitaro .tree-table tr:hover td {
    background-color: #f1f8f2 !important;
}

body.table-theme-keitaro .level-1 {
    background: linear-gradient(180deg, #e1f0e3, #e9f4ea);
    font-weight: 600;
}

body.table-theme-keitaro .level-1.row-total-sticky {
    box-shadow: 0 1px 0 #c3d7c6;
}

body.table-theme-keitaro .level-1.row-total-sticky td {
    font-size: 0.82rem;
    font-weight: 800;
    color: #173327 !important;
}

body.table-theme-keitaro .level-1.row-total-sticky .metric-val,
body.table-theme-keitaro .level-1.row-total-sticky .metric-val .text-muted,
body.table-theme-keitaro .level-1.row-total-sticky .val-info,
body.table-theme-keitaro .level-1.row-total-sticky .val-success,
body.table-theme-keitaro .level-1.row-total-sticky .new-value,
body.table-theme-keitaro .level-1.row-total-sticky .old-value,
body.table-theme-keitaro .level-1.row-total-sticky .badge {
    color: #2f6f53 !important;
    font-weight: 800;
    background: transparent !important;
    border: none !important;
}

body.table-theme-keitaro .level-2 {
    background-color: #f4faf5;
    border-top: 1px solid #d0dfd1;
    border-bottom: 1px solid #dbe7dc;
}

body.table-theme-keitaro .level-2:hover {
    background-color: #eef8f0 !important;
}

body.table-theme-keitaro .level-3 {
    background-color: #f9fcf9;
    border-left: 2px solid #a8c9af;
}

body.table-theme-keitaro .level-4 {
    background-color: #ffffff;
    border-left: 1px dotted #b5d0ba;
}

body.table-theme-keitaro .level-1 .col-cb,
body.table-theme-keitaro .level-1 .col-struct {
    background-color: #e5f1e7 !important;
}

body.table-theme-keitaro .level-2 .col-cb,
body.table-theme-keitaro .level-2 .col-struct {
    background-color: #f4faf5 !important;
}

body.table-theme-keitaro .level-3 .col-cb,
body.table-theme-keitaro .level-3 .col-struct {
    background-color: #f9fcf9 !important;
}

body.table-theme-keitaro .level-4 .col-cb,
body.table-theme-keitaro .level-4 .col-struct {
    background-color: #ffffff !important;
}

body.table-theme-keitaro .tree-table th.col-cb,
body.table-theme-keitaro .tree-table th.col-struct {
    background: #e8f1ea !important;
}

body.table-theme-keitaro .col-cb {
    width: 24px;
    min-width: 24px;
    max-width: 24px;
}

body.table-theme-keitaro .col-struct {
    left: 24px;
    border-right: 1px solid #cfdccf;
}

body.table-theme-keitaro .col-toggle {
    width: 72px;
    min-width: 72px;
    max-width: 72px;
}

body.table-theme-keitaro .col-status {
    min-width: 132px;
    max-width: 132px;
    text-align: left;
}

.status-cell-inner {
    display: inline-flex;
    align-items: center;
    gap: 0.22rem;
    width: 100%;
    min-width: 0;
}

.status-cell-inner .status-badge {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 24px);
}

.status-cell-inner .status-rule-btn {
    flex: 0 0 auto;
}

body.table-theme-keitaro .tree-table th.col-spend,
body.table-theme-keitaro .tree-table th.col-imp,
body.table-theme-keitaro .tree-table th.col-clicks,
body.table-theme-keitaro .tree-table th.col-cpc,
body.table-theme-keitaro .tree-table th.col-sub,
body.table-theme-keitaro .tree-table th.col-cps,
body.table-theme-keitaro .tree-table th.col-reg,
body.table-theme-keitaro .tree-table th.col-cpr,
body.table-theme-keitaro .tree-table th.col-dep,
body.table-theme-keitaro .tree-table th.col-cpd,
body.table-theme-keitaro .tree-table th.col-qua,
body.table-theme-keitaro .tree-table th.col-ctr,
body.table-theme-keitaro .tree-table th.col-i2r,
body.table-theme-keitaro .tree-table th.col-r2d,
body.table-theme-keitaro .tree-table th.col-rev,
body.table-theme-keitaro .tree-table th.col-roi,
body.table-theme-keitaro .tree-table td.col-spend,
body.table-theme-keitaro .tree-table td.col-imp,
body.table-theme-keitaro .tree-table td.col-clicks,
body.table-theme-keitaro .tree-table td.col-cpc,
body.table-theme-keitaro .tree-table td.col-sub,
body.table-theme-keitaro .tree-table td.col-cps,
body.table-theme-keitaro .tree-table td.col-reg,
body.table-theme-keitaro .tree-table td.col-cpr,
body.table-theme-keitaro .tree-table td.col-dep,
body.table-theme-keitaro .tree-table td.col-cpd,
body.table-theme-keitaro .tree-table td.col-qua,
body.table-theme-keitaro .tree-table td.col-ctr,
body.table-theme-keitaro .tree-table td.col-i2r,
body.table-theme-keitaro .tree-table td.col-r2d,
body.table-theme-keitaro .tree-table td.col-rev,
body.table-theme-keitaro .tree-table td.col-roi {
    min-width: 66px;
    max-width: 66px;
}

body.table-theme-keitaro .tree-table .col-cb .form-check-input,
body.table-theme-keitaro .tree-table .row-cb {
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 0.18rem;
    border: 1px solid #9ec3a5;
    background-color: #ffffff;
    box-shadow: none;
}

body.table-theme-keitaro .tree-table .col-cb .form-check-input:hover,
body.table-theme-keitaro .tree-table .row-cb:hover {
    border-color: #74a980;
    box-shadow: 0 0 0 2px rgba(81, 143, 94, 0.14);
    transform: none;
}

body.table-theme-keitaro .tree-table .col-cb .form-check-input:checked,
body.table-theme-keitaro .tree-table .row-cb:checked {
    background-color: #4b9a5a;
    border-color: #4b9a5a;
    box-shadow: 0 0 0 2px rgba(75, 154, 90, 0.18);
}

body.table-theme-keitaro .status-switch {
    width: 2.42rem !important;
    height: 1.3rem;
    border-color: #9fc1a7;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
    background: #d7e6da !important;
}

body.table-theme-keitaro .status-switch::after {
    width: 0.9rem;
    height: 0.9rem;
    top: 2px;
    left: 2px;
}

body.table-theme-keitaro .status-switch:checked::after {
    transform: translateX(1.08rem);
}

body.table-theme-keitaro .status-switch:checked {
    background: #5aa569 !important;
}

body.table-theme-keitaro .status-switch:focus-visible {
    box-shadow: 0 0 0 2px rgba(90, 108, 136, 0.24);
}

body.table-theme-keitaro .status-switch:hover {
    transform: none;
}

body.table-theme-keitaro .toggle-btn {
    color: #5d7168;
}

body.table-theme-keitaro .toggle-btn:hover {
    background: #e4efe6;
    color: #2e7d44;
}

body.table-theme-keitaro .name-camp {
    color: #1f5b3d;
    font-weight: 600;
}

body.table-theme-keitaro .name-adset {
    color: #315f54;
    font-weight: 600;
}

body.table-theme-keitaro .metric-val {
    font-size: 0.72rem;
    color: #21343e !important;
}

body.table-theme-keitaro .tree-table td.text-muted,
body.table-theme-keitaro .tree-table .text-muted {
    color: #3f5660 !important;
}

body.table-theme-keitaro .status-badge {
    font-size: 0.68rem;
    border-radius: 0;
    padding: 0;
    background: transparent !important;
    border: none !important;
    color: #394150 !important;
    font-weight: 500;
    text-transform: lowercase;
}

body.table-theme-keitaro .status-badge.status-active {
    color: #2b8e4a !important;
}

body.table-theme-keitaro .status-badge.status-paused {
    color: #8d6a2f !important;
}

body.table-theme-keitaro .status-badge.status-error {
    color: #8f4747 !important;
}

body.table-theme-keitaro .table-container::-webkit-scrollbar {
    height: 9px;
    width: 9px;
}

body.table-theme-keitaro .table-container::-webkit-scrollbar-thumb {
    background: #aeb5bf;
    border-radius: 8px;
}

body.table-theme-keitaro .table-container::-webkit-scrollbar-track {
    background: #e6e9ef;
}

@media (max-width: 992px) {
    .sidebar-toggle-btn-panel {
        display: none;
    }

    .sidebar-toggle-btn-mobile {
        display: inline-flex;
    }
}

.level-1 .col-cb,
.level-1 .col-struct {
    background-color: var(--row-level-1) !important;
}

.level-2 .col-cb,
.level-2 .col-struct {
    background-color: var(--row-level-2) !important;
}

.level-3 .col-cb,
.level-3 .col-struct {
    background-color: var(--row-level-3) !important;
}

.level-4 .col-cb,
.level-4 .col-struct {
    background-color: var(--row-level-4) !important;
}

.tree-table th.col-cb,
.tree-table th.col-struct {
    z-index: 21;
    background-color: var(--table-header) !important;
}

.col-status {
    min-width: 120px;
    max-width: 120px;
    text-align: center;
}

.tree-table th.col-spend,
.tree-table th.col-imp,
.tree-table th.col-clicks,
.tree-table th.col-cpc,
.tree-table th.col-sub,
.tree-table th.col-cps,
.tree-table th.col-reg,
.tree-table th.col-cpr,
.tree-table th.col-dep,
.tree-table th.col-cpd,
.tree-table th.col-qua,
.tree-table th.col-ctr,
.tree-table th.col-i2r,
.tree-table th.col-r2d,
.tree-table th.col-rev,
.tree-table th.col-roi,
.tree-table td.col-spend,
.tree-table td.col-imp,
.tree-table td.col-clicks,
.tree-table td.col-cpc,
.tree-table td.col-sub,
.tree-table td.col-cps,
.tree-table td.col-reg,
.tree-table td.col-cpr,
.tree-table td.col-dep,
.tree-table td.col-cpd,
.tree-table td.col-qua,
.tree-table td.col-ctr,
.tree-table td.col-i2r,
.tree-table td.col-r2d,
.tree-table td.col-rev,
.tree-table td.col-roi {
    text-align: center !important;
}

.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    white-space: normal;
    line-height: 1.1;
    max-width: 100%;
}

.status-active {
    background: var(--status-active-bg);
    color: var(--status-active-text);
}

.status-paused {
    background: var(--status-paused-bg);
    color: var(--status-paused-text);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.status-error {
    background: var(--status-error-bg);
    color: var(--status-error-text);
}

.status-neutral {
    background: rgba(148, 163, 184, 0.16);
    color: #475569;
    border: 1px solid rgba(148, 163, 184, 0.22);
}

[data-theme="dark"] .status-badge {
    border-color: rgba(148, 163, 184, 0.28);
}

[data-theme="dark"] .status-badge.status-active {
    background: rgba(16, 185, 129, 0.18);
    color: #6ee7b7;
}

[data-theme="dark"] .status-badge.status-paused {
    background: rgba(245, 158, 11, 0.16);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.26);
}

[data-theme="dark"] .status-badge.status-error,
[data-theme="dark"] .status-badge.status-neutral {
    color: #cbd5e1;
}

.toggle-btn {
    cursor: pointer;
    padding: 0 4px;
    margin-right: 4px;
    color: var(--text-muted);
    transition: transform 0.2s;
    display: inline-block;
    width: 20px;
    text-align: center;
    border-radius: 4px;
}

.toggle-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
}

.indent-1 {
    padding-left: 0.2rem !important;
}

.indent-2 {
    padding-left: 1.0rem !important;
}

.indent-3 {
    padding-left: 1.8rem !important;
}

.indent-4 {
    padding-left: 3.2rem !important;
}

.name-camp {
    color: var(--camp-color);
    font-weight: 600;
}

.name-adset {
    color: var(--adset-color);
    font-weight: 500;
}

.metric-val {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
}

.val-success {
    color: var(--success-text);
}

.val-danger {
    color: var(--danger-text);
}

.val-info {
    color: var(--info-text);
}

.old-value {
    opacity: 0.5;
    text-decoration: line-through;
    font-size: 0.65rem;
    display: block;
    line-height: 1;
}

.new-value {
    font-weight: 600;
    color: var(--primary-color);
    display: block;
    line-height: 1;
}

.metric-kt-value {
    color: #0f6cbd;
    font-weight: 700;
}

.keytaro-upload-impact {
    margin-top: 0.45rem;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    border: 1px solid rgba(15, 108, 189, 0.18);
    background: linear-gradient(180deg, rgba(224, 242, 254, 0.9), rgba(239, 246, 255, 0.95));
}

.keytaro-upload-impact-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: #075985;
    font-size: 0.78rem;
    font-weight: 800;
    margin-bottom: 0.28rem;
}

.keytaro-upload-impact-line {
    color: #0f172a;
    font-size: 0.75rem;
    line-height: 1.4;
}

[data-theme="dark"] .metric-kt-value {
    color: #7dd3fc;
}

[data-theme="dark"] .keytaro-upload-impact {
    border-color: rgba(56, 189, 248, 0.24);
    background: linear-gradient(180deg, rgba(8, 47, 73, 0.78), rgba(15, 23, 42, 0.92));
}

[data-theme="dark"] .keytaro-upload-impact-title {
    color: #bae6fd;
}

[data-theme="dark"] .keytaro-upload-impact-line {
    color: #e2e8f0;
}

.sortable {
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.sortable:hover {
    background-color: var(--surface-border) !important;
    color: var(--primary-color);
}

.sort-icon {
    font-size: 0.65rem;
    opacity: 0.4;
    margin-left: 2px;
}

.sortable.active .sort-icon {
    opacity: 1;
    color: var(--primary-color);
}

#teamManagementArea .nav-pills .nav-link {
    border: 1px solid var(--surface-border);
    color: var(--text-muted);
    background: transparent;
    font-size: 0.76rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 0.32rem 0.75rem;
}

#teamManagementArea .nav-pills .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    border-color: transparent;
}

#teamManagementArea .table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--table-border);
}

#teamManagementArea .table td {
    font-size: 0.76rem;
    border-color: var(--table-border);
}

#teamManagementArea .table tbody tr:hover td {
    background: var(--table-hover);
}

body.hide-col-imp .col-imp {
    display: none !important;
}

body.hide-col-clicks .col-clicks {
    display: none !important;
}

body.hide-col-cpc .col-cpc {
    display: none !important;
}

body.hide-col-sub .col-sub {
    display: none !important;
}

body.hide-col-cps .col-cps {
    display: none !important;
}

body.hide-col-reg .col-reg {
    display: none !important;
}

body.hide-col-cpr .col-cpr {
    display: none !important;
}

body.hide-col-dep .col-dep {
    display: none !important;
}

body.hide-col-cpd .col-cpd {
    display: none !important;
}

body.hide-col-qua .col-qua {
    display: none !important;
}

body.hide-col-ctr .col-ctr {
    display: none !important;
}

body.hide-col-i2r .col-i2r {
    display: none !important;
}

body.hide-col-r2d .col-r2d {
    display: none !important;
}

.dropdown-menu.col-toggle-menu {
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
}

.dropdown-menu.col-toggle-menu .form-check-label {
    color: var(--text-main);
    font-size: 0.8rem;
    cursor: pointer;
}

.dropdown-menu.col-toggle-menu .form-check-input {
    cursor: pointer;
}

.modal-content {
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    color: var(--text-main);
}

.modal.in-fullscreen-host {
    background: rgba(15, 23, 42, 0.38);
}

.modal.in-fullscreen-host .modal-content {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
    box-shadow: 0 18px 48px rgba(2, 6, 23, 0.42);
}

[data-theme="dark"] .modal.in-fullscreen-host .modal-content {
    background: #0b1220 !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

#decompositionModal .modal-content,
#campaignDetailsModal .modal-content {
    background: #ffffff;
    opacity: 1;
}

[data-theme="dark"] #decompositionModal .modal-content,
[data-theme="dark"] #campaignDetailsModal .modal-content {
    background: #0b1220;
}

.modal-header {
    border-bottom: 1px solid var(--surface-border);
    padding: 0.5rem 1rem;
}

.modal-body {
    padding: 0.5rem 1rem;
}

.modal-readonly-note {
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: var(--text-main);
}

[data-theme="dark"] .modal-readonly-note {
    background: rgba(30, 41, 59, 0.68);
    border-color: rgba(71, 85, 105, 0.6);
    color: var(--text-main);
}

.btn-close {
    filter: invert(var(--invert-icon, 0));
}

[data-theme="dark"] {
    --invert-icon: 1;
}

.modal-backdrop {
    z-index: 10000 !important;
}

.modal {
    z-index: 10001 !important;
}

.tooltip.saas-tooltip {
    --bs-tooltip-bg: var(--surface-bg);
    --bs-tooltip-color: var(--text-main);
    --bs-tooltip-opacity: 1;
    --bs-tooltip-max-width: min(320px, calc(100vw - 24px));
    z-index: 13050 !important;
    pointer-events: none;
}

.tooltip.saas-tooltip .tooltip-inner {
    background: var(--surface-bg);
    color: var(--text-main);
    border: 1px solid var(--surface-border);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
    text-align: left;
    font-size: 0.74rem;
    line-height: 1.4;
    padding: 0.55rem 0.7rem;
    max-width: min(320px, calc(100vw - 24px));
}

[data-theme="dark"] .tooltip.saas-tooltip .tooltip-inner {
    box-shadow: 0 16px 34px rgba(2, 6, 23, 0.42);
}

[data-theme="light"] #integrationsManagementArea .text-muted,
[data-theme="light"] #tokensManagementArea .text-muted,
[data-theme="light"] #teamManagementArea .text-muted,
[data-theme="light"] #settingsArea .text-muted {
    color: #475569 !important;
}

[data-theme="light"] #integrationsManagementArea .saas-card,
[data-theme="light"] #tokensManagementArea .saas-card,
[data-theme="light"] #teamManagementArea .saas-card,
[data-theme="light"] #settingsArea .saas-card {
    background: #ffffff !important;
    border-color: #dbe5f1 !important;
}

[data-theme="light"] #inviteTokenOutput,
[data-theme="light"] #metaApiToken,
[data-theme="light"] #integrationsHealthArea .health-card,
[data-theme="light"] #teamManagementArea .table td,
[data-theme="light"] #teamManagementArea .table th {
    color: #0f172a !important;
}

[data-theme="light"] #inviteTokenOutput {
    background: #ffffff !important;
    border-color: #d7e3ef !important;
    box-shadow: none !important;
}

.invite-link-panel {
    background: rgba(15, 23, 42, 0.48);
    border: 1px solid rgba(71, 85, 105, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.team-toolbar-actions {
    flex-wrap: wrap;
}

.team-icon-btn {
    min-width: 38px;
    min-height: 36px;
    border-radius: 10px;
    padding: 0.25rem 0.55rem;
}

.team-card {
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    padding: 0.75rem 0.8rem;
    background: rgba(15, 23, 42, 0.74);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
}

.team-card__meta {
    min-width: 0;
    flex: 1 1 auto;
}

.team-card__title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.2;
}

.team-card__sub {
    font-size: 0.73rem;
    color: var(--text-muted);
    word-break: break-all;
}

.team-card__actions,
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    justify-content: flex-end;
}

.table-actions {
    min-width: 172px;
}

.team-action-btn {
    border-radius: 10px;
    padding: 0.38rem 0.72rem;
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1;
    min-height: 34px;
}

.team-copy-btn {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.24);
    color: #0369a1;
}

.team-copy-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(14, 165, 233, 0.32);
    color: #075985;
}

.team-danger-btn {
    box-shadow: none;
}

.team-badge {
    border-radius: 999px;
    padding: 0.36rem 0.6rem;
    font-size: 0.68rem;
    font-weight: 700;
}

[data-theme="dark"] .team-copy-btn {
    background: rgba(56, 189, 248, 0.14);
    border-color: rgba(56, 189, 248, 0.22);
    color: #bae6fd;
}

[data-theme="dark"] .team-copy-btn:hover {
    background: rgba(56, 189, 248, 0.24);
    border-color: rgba(125, 211, 252, 0.35);
    color: #e0f2fe;
}

[data-theme="dark"] #inviteTokenOutput {
    background: rgba(71, 85, 105, 0.78) !important;
    border-color: rgba(100, 116, 139, 0.52) !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] #inviteTokenOutput::placeholder {
    color: #cbd5e1 !important;
}

.action-confirm-wrap {
    border-top: 1px solid var(--surface-border);
    padding-top: 0.8rem;
}

.action-confirm-expected-row {
    display: flex;
    gap: 0.55rem;
    align-items: center;
}

#actionConfirmExpectedValue {
    font-weight: 700;
    background: rgba(255, 255, 255, 0.86);
}

[data-theme="light"] #teamManagementArea .team-card {
    background: #ffffff;
    border-color: #d9e3ee;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .invite-link-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(248, 251, 255, 0.94) 100%);
    border-color: #d7e3ef;
}

@media (max-width: 991px) {
    .team-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .team-card__actions,
    .table-actions {
        justify-content: flex-start;
        width: 100%;
    }
}

.decomp-table-compact {
    width: 100%;
    border-collapse: collapse;
}

.decomp-table-compact td,
.decomp-table-compact th {
    border: 1px solid var(--surface-border);
    padding: 0.15rem 0.4rem;
    vertical-align: middle;
    font-size: 0.75rem;
    color: var(--text-main);
}

.decomp-table-compact thead th {
    background: var(--table-header);
    color: var(--text-muted);
    padding: 0.3rem 0.4rem;
    font-size: 0.65rem;
    text-transform: uppercase;
}

.bg-row-subtle {
    background-color: var(--row-level-1);
}

.bg-row-highlight {
    background-color: rgba(99, 102, 241, 0.05);
}

.decomp-table-compact .form-control {
    border-radius: 4px;
    text-align: center;
    font-weight: 600;
    height: 22px;
    padding: 0px 4px;
    font-size: 0.75rem;
}

.decomp-table-compact input[readonly] {
    background: transparent !important;
    border: none !important;
    color: var(--text-main) !important;
    font-size: 0.8rem;
    font-weight: 700;
}

.decomp-cab-id {
    color: #2f8a56 !important;
    font-weight: 800;
}

body.table-theme-keitaro #decompositionModal .modal-content {
    background: #f4fbf5;
    border: 1px solid #c7dccb;
    color: #1f3b2d;
}

body.table-theme-keitaro #decompositionModal .modal-header {
    background: linear-gradient(180deg, #d9ebdd, #e4f2e7);
    border-bottom: 1px solid #c2d7c6;
}

body.table-theme-keitaro #decompositionModal .modal-title {
    color: #1e5e3e;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact {
    background: #fbfefb;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact td,
body.table-theme-keitaro #decompositionModal .decomp-table-compact th {
    border-color: #d1e1d4;
    color: #243b2f;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact thead th {
    background: #e8f2ea;
    color: #4d695b;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact .bg-row-subtle {
    background-color: #edf6ef;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact .bg-row-highlight {
    background-color: rgba(91, 165, 106, 0.12);
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact .form-control,
body.table-theme-keitaro #decompositionModal .decomp-table-compact input[readonly] {
    background: #ffffff !important;
    border: 1px solid #bfd7c4 !important;
    color: #1e3329 !important;
    font-weight: 700;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact input[readonly] {
    background: #f5fbf6 !important;
}

[data-theme="light"] .decomp-table-compact input[readonly] {
    color: #0f172a !important;
}

[data-theme="light"] .decomp-table-compact .bg-row-highlight {
    background-color: rgba(14, 165, 233, 0.1);
}

[data-theme="light"] .decomp-table-compact .form-control {
    color: #0f172a !important;
    border-color: rgba(15, 23, 42, 0.2) !important;
}

body.table-theme-keitaro #decompositionModal .modal-content {
    background: #f8f9fb;
    border: 1px solid #d6dbe4;
    color: #1f2b3d;
}

body.table-theme-keitaro #decompositionModal .modal-header {
    background: #eef2f7;
    border-bottom: 1px solid #d6dbe4;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact td,
body.table-theme-keitaro #decompositionModal .decomp-table-compact th {
    border-color: #d6dbe4;
    color: #1f2b3d;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact thead th {
    background: #edf1f6;
    color: #566173;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact input[readonly],
body.table-theme-keitaro #decompositionModal .decomp-table-compact .form-control {
    color: #1f2b3d !important;
}

/* Final override: keep decomposition fully in Keitaro green palette */
body.table-theme-keitaro #decompositionModal .modal-content {
    background: #f4fbf5 !important;
    border: 1px solid #c7dccb !important;
    color: #1f3b2d !important;
}

body.table-theme-keitaro #decompositionModal .modal-header {
    background: linear-gradient(180deg, #d9ebdd, #e4f2e7) !important;
    border-bottom: 1px solid #c2d7c6 !important;
}

body.table-theme-keitaro #decompositionModal .modal-title,
body.table-theme-keitaro #decompositionModal .decomp-cab-id {
    color: #2f8a56 !important;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact td,
body.table-theme-keitaro #decompositionModal .decomp-table-compact th {
    border-color: #d1e1d4 !important;
    color: #243b2f !important;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact thead th {
    background: #e8f2ea !important;
    color: #4d695b !important;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact .bg-row-subtle {
    background-color: #edf6ef !important;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact .bg-row-highlight {
    background-color: rgba(91, 165, 106, 0.12) !important;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact .form-control,
body.table-theme-keitaro #decompositionModal .decomp-table-compact input[readonly] {
    background: #ffffff !important;
    border: 1px solid #bfd7c4 !important;
    color: #1e3329 !important;
    font-weight: 700;
}

body.table-theme-keitaro #decompositionModal .decomp-table-compact input[readonly] {
    background: #f5fbf6 !important;
}

/* ─── KPI Cards ─────────────────────────────────────────────────────────── */

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 1rem 1.25rem;
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.kpi-icon {
    margin-bottom: 4px;
    line-height: 1;
}

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

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.4;
    color: var(--text-main);
    margin-top: 2px;
}

.kpi-sub .metric-source-breakdown {
    font-size: 1rem;
}

.kpi-sub .metric-source-counts {
    font-size: 0.72rem;
}

/* ─── Auth Modal (old styles — kept for profile modal) ──────────────────── */

/* ─── AUTH OVERLAY ───────────────────────────────────────────────────────── */

#authOverlay {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.auth-overlay-bg {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0d0b1e 0%, #1a1040 35%, #0f1a3d 65%, #0d0b1e 100%);
    background-size: 400% 400%;
    animation: authBgShift 14s ease infinite;
    z-index: 0;
}

@keyframes authBgShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.auth-orb {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

.auth-orb-1 {
    width: 520px; height: 520px;
    background: radial-gradient(circle, rgba(99,102,241,0.45) 0%, transparent 70%);
    top: -140px; left: -140px;
    animation: orbFloat1 11s ease-in-out infinite;
}

.auth-orb-2 {
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(139,92,246,0.4) 0%, transparent 70%);
    bottom: -100px; right: -80px;
    animation: orbFloat2 13s ease-in-out infinite;
}

.auth-orb-3 {
    width: 260px; height: 260px;
    background: radial-gradient(circle, rgba(34,211,238,0.3) 0%, transparent 70%);
    top: 45%; left: 55%;
    animation: orbFloat1 9s ease-in-out infinite reverse;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    35%  { transform: translate(28px, -22px) scale(1.06); }
    70%  { transform: translate(-18px, 28px) scale(0.94); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(-38px, -28px) scale(1.09); }
}

.auth-overlay-grid {
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,0.035) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: 0;
}

.auth-overlay-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 940px;
    padding: 2rem 1.5rem;
    gap: 3.5rem;
    min-height: 100vh;
}

/* ─── Brand panel (left side, desktop) ──────────────────────────────────── */

.auth-brand-panel {
    flex: 1;
    color: #fff;
    display: none;
}

@media (min-width: 992px) {
    .auth-brand-panel { display: block; }
}

.auth-brand-icon {
    font-size: 3.2rem;
    color: #818cf8;
    display: block;
    margin-bottom: 1.25rem;
    animation: brandIconPulse 3s ease-in-out infinite;
}

@keyframes brandIconPulse {
    0%, 100% { text-shadow: 0 0 20px rgba(129,140,248,0.4); }
    50%       { text-shadow: 0 0 40px rgba(129,140,248,0.8), 0 0 80px rgba(129,140,248,0.3); }
}

.auth-brand-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(to right, #e0e7ff, #c7d2fe, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-brand-sub {
    color: rgba(255,255,255,0.6);
    font-size: 0.95rem;
    margin-bottom: 2rem;
    line-height: 1.65;
}

.auth-feature-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    margin-bottom: 0.9rem;
}

.auth-feature-item i {
    color: #818cf8;
    font-size: 1.05rem;
    flex-shrink: 0;
}

/* ─── Auth form card ─────────────────────────────────────────────────────── */

.auth-form-card {
    width: 100%;
    max-width: 410px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 1.4rem;
    padding: 2.25rem 2rem;
    box-shadow: 0 30px 60px rgba(0,0,0,0.45), 0 0 0 1px rgba(129,140,248,0.08);
}

.auth-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255,255,255,0.75);
    margin-bottom: 0.35rem;
}

.auth-input.form-control,
.auth-input.form-select {
    background: rgba(255,255,255,0.07) !important;
    border: 1px solid rgba(255,255,255,0.14) !important;
    color: #fff !important;
    border-radius: 0.65rem !important;
}

.auth-input.form-control::placeholder {
    color: rgba(255,255,255,0.3) !important;
}

.auth-input.form-control:focus,
.auth-input.form-select:focus {
    background: rgba(255,255,255,0.1) !important;
    border-color: rgba(129,140,248,0.65) !important;
    box-shadow: 0 0 0 3px rgba(129,140,248,0.2) !important;
    color: #fff !important;
}

.auth-input.form-select option {
    background: #1e1a3e;
    color: #fff;
}

.auth-eye-btn {
    background: rgba(255,255,255,0.07) !important;
    border: 1px solid rgba(255,255,255,0.14) !important;
    border-left: none !important;
    color: rgba(255,255,255,0.6) !important;
    border-radius: 0 0.65rem 0.65rem 0 !important;
    padding: 0 0.75rem;
    transition: color 0.2s, background 0.2s;
}

.auth-eye-btn:hover {
    background: rgba(255,255,255,0.12) !important;
    color: #fff !important;
}

.auth-hr {
    border-color: rgba(255,255,255,0.1);
    margin: 1.25rem 0;
}

.auth-link-muted {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-link-muted:hover {
    color: rgba(255,255,255,0.85);
}

.auth-link-accent {
    color: #818cf8;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-link-accent:hover {
    color: #a5b4fc;
}

.auth-alert-danger {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
    border-radius: 0.6rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    text-align: center;
}

/* Input-group inside auth card: left input corner fix */
.auth-form-card .input-group .auth-input.form-control {
    border-radius: 0.65rem 0 0 0.65rem !important;
}

/* ─── Fade-in animation for the card ────────────────────────────────────── */

.auth-form-card {
    animation: cardSlideUp 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes cardSlideUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
    .auth-overlay-content {
        padding: 1.5rem 1rem;
        min-height: 100vh;
        align-items: flex-start;
        padding-top: 2rem;
    }
    .auth-form-card {
        padding: 1.75rem 1.25rem;
    }
}

/* ─── Profile Avatar ─────────────────────────────────────────────────────── */

#profileAvatarImg {
    border: 3px solid var(--surface-border);
    transition: border-color 0.2s;
}

#profileAvatarImg:hover {
    border-color: var(--primary-color);
}

/* ─── Nav Buttons ────────────────────────────────────────────────────────── */

.sidebar-nav-btn.text-info {
    color: var(--primary-color) !important;
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--primary-color);
}

/* ─── Overview period button active state ────────────────────────────────── */

.overview-period-btn.active,
.overview-period-btn.btn-primary-saas {
    background: var(--primary-color) !important;
    color: #fff !important;
    border-color: var(--primary-color) !important;
}
.spendy-period-btn.active,
.spendy-period-btn.btn-primary-saas {
    background: var(--primary-color) !important;
    color: #fff !important;
    border-color: var(--primary-color) !important;
}

.spendy-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.85rem;
}

.spendy-summary-card {
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.08), rgba(255, 255, 255, 0.02));
}

.spendy-summary-card__label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
}

.spendy-summary-card__value {
    font-size: clamp(1.35rem, 3vw, 2rem);
    font-weight: 800;
    color: var(--text-main);
}

.spendy-summary-card__sub {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.spendy-visible-integrations-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.spendy-visible-integration-chip {
    display: inline-flex;
    flex-direction: column;
    gap: 0.12rem;
    border: 1px solid var(--surface-border);
    border-radius: 14px;
    padding: 0.55rem 0.75rem;
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.05), rgba(255, 255, 255, 0.02));
    min-width: 180px;
}

.spendy-visible-integration-chip__title {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-main);
}

.spendy-visible-integration-chip__meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.spendy-visible-integration-chip__status {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
}

.spendy-top-alert-card {
    border: 1px solid rgba(245, 158, 11, 0.2);
    background: rgba(245, 158, 11, 0.05);
    border-radius: 14px;
    padding: 0.8rem;
    min-height: 100%;
}

.spendy-top-alert-card.is-success {
    border-color: rgba(34, 197, 94, 0.26);
    background: rgba(34, 197, 94, 0.08);
}

.spendy-top-alert-card__ok {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #15803d;
    font-size: 0.8rem;
    font-weight: 700;
}

.spendy-grid {
    display: grid;
    gap: 1rem;
}

.spendy-offer-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
}

.spendy-offer-breakdown-card {
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    padding: 0.95rem;
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.06), rgba(255, 255, 255, 0.02));
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.spendy-offer-breakdown-card__title {
    font-weight: 800;
    color: var(--text-main);
}

.spendy-offer-breakdown-card__value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-top: 0.35rem;
}

.spendy-offer-breakdown-card__meta {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.spendy-offer-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
    gap: 0.55rem;
    margin-top: 0.85rem;
}

.spendy-offer-metric-chip {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    padding: 0.55rem 0.65rem;
    background: rgba(255, 255, 255, 0.46);
    min-height: 74px;
}

.spendy-offer-metric-chip__label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 800;
}

.spendy-offer-metric-chip__value {
    margin-top: 0.18rem;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
}

.spendy-offer-metric-chip__subvalue {
    margin-top: 0.12rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.spendy-offer-buyer-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.8rem;
}

.spendy-offer-buyer-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.28rem 0.58rem;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(79, 70, 229, 0.1);
    color: var(--text-main);
}

.spendy-company-row__actions {
    margin-top: 0.55rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.spendy-company-row__status {
    min-height: 1.1rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.spendy-company-row__status.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.spendy-company-row__status.is-success {
    color: #15803d;
}

.spendy-company-row__status.is-error {
    color: #b91c1c;
}

.spendy-card {
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    padding: 1rem;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.02), rgba(79, 70, 229, 0.03));
}

.spendy-card__header {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: flex-start;
    margin-bottom: 0.8rem;
}

.spendy-card__title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-main);
}

.spendy-card__meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.spendy-card__value {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: 800;
    color: var(--primary-color);
    white-space: nowrap;
}

.spendy-offer-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
}

.spendy-offer-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.3rem 0.6rem;
    font-size: 0.74rem;
    font-weight: 700;
    background: rgba(14, 165, 233, 0.12);
    color: #0f766e;
}

.spendy-offer-chip--unknown {
    background: rgba(245, 158, 11, 0.14);
    color: #b45309;
}

.spendy-warning {
    border: 1px solid rgba(245, 158, 11, 0.28);
    background: rgba(245, 158, 11, 0.08);
    color: #b45309;
    border-radius: 14px;
    padding: 0.65rem 0.75rem;
    font-size: 0.78rem;
    margin-bottom: 0.75rem;
}

.spendy-unknown-alert {
    margin-top: 0.75rem;
    margin-bottom: 0;
}

.spendy-header-insights {
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 0.85rem;
    background: rgba(148, 163, 184, 0.05);
}

.spendy-unknown-alert__meta {
    font-weight: 700;
    line-height: 1.45;
}

.spendy-unknown-company-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.6rem;
}

.spendy-unknown-company-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    appearance: none;
    font-family: inherit;
    cursor: pointer;
    border-radius: 999px;
    border: 1px solid rgba(245, 158, 11, 0.32);
    background: rgba(255, 255, 255, 0.45);
    color: #b45309;
    padding: 0.32rem 0.62rem;
    font-size: 0.72rem;
    font-weight: 600;
}

.spendy-company-list {
    display: grid;
    gap: 0.55rem;
}

.spendy-account-list {
    display: grid;
    gap: 0.8rem;
}

.spendy-account-block {
    display: grid;
    gap: 0.6rem;
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 0.8rem;
    background: rgba(148, 163, 184, 0.06);
}

.spendy-account-block__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.spendy-account-block__title {
    font-weight: 800;
    color: var(--text-main);
}

.spendy-account-block__id {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 0.35rem;
}

.spendy-account-block__meta {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 0.18rem;
}

.spendy-account-block__value {
    font-weight: 800;
    white-space: nowrap;
    color: var(--text-main);
}

.spendy-hidden-account-list {
    display: grid;
    gap: 0.8rem;
}

.spendy-hidden-account-card {
    border: 1px solid rgba(245, 158, 11, 0.24);
    border-radius: 16px;
    padding: 0.85rem;
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), rgba(255, 255, 255, 0.02));
}

.spendy-hidden-account-card__header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
}

.spendy-hidden-account-card__title {
    font-weight: 800;
    color: var(--text-main);
}

.spendy-hidden-account-card__meta {
    margin-top: 0.18rem;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.spendy-hidden-account-card__value {
    font-weight: 800;
    color: #b45309;
    white-space: nowrap;
}

.spendy-hidden-account-card__reason {
    margin-top: 0.55rem;
    font-size: 0.76rem;
    color: var(--text-main);
}

.spendy-hidden-account-card__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.65rem;
}

.spendy-hidden-account-card__chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-main);
}

.spendy-hidden-account-card__actions {
    margin-top: 0.7rem;
}

.spendy-hidden-account-card--neutral {
    border-color: rgba(148, 163, 184, 0.24);
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.08), rgba(255, 255, 255, 0.02));
}

.spendy-hidden-account-card--neutral .spendy-hidden-account-card__value {
    color: var(--text-muted);
}

.spendy-company-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(420px, 520px) auto;
    gap: 0.85rem;
    align-items: start;
    border-radius: 14px;
    padding: 0.75rem 0.85rem;
    background: var(--table-header);
    border: 1px solid var(--surface-border);
}

.spendy-company-row.is-saving {
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
    animation: spendyRowPulse 1.1s ease-in-out infinite;
}

.spendy-company-row.is-saving .spendy-company-row__actions {
    opacity: 0.92;
}

.spendy-company-row.is-saved {
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.18);
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.06), var(--table-header));
}

@keyframes spendyRowPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.14);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.22);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.14);
    }
}

.spendy-company-row__main {
    min-width: 0;
}

.spendy-company-row__title {
    font-weight: 700;
    color: var(--text-main);
}

.spendy-company-row__meta {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.spendy-company-row__meta--warning {
    color: #b45309;
    font-weight: 700;
}

[data-theme="dark"] .spendy-company-row__meta--warning {
    color: #fbbf24;
}

.spendy-company-row__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 0.5rem;
    align-self: center;
}

.spendy-company-metric {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.56);
    min-width: 0;
}

[data-theme="dark"] .spendy-company-metric {
    background: rgba(15, 23, 42, 0.34);
    border-color: rgba(148, 163, 184, 0.22);
}

.spendy-company-metric--info {
    border-color: rgba(37, 99, 235, 0.22);
    background: rgba(59, 130, 246, 0.06);
}

.spendy-company-metric--success {
    border-color: rgba(22, 163, 74, 0.22);
    background: rgba(34, 197, 94, 0.06);
}

.spendy-company-metric__label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.spendy-company-metric__value {
    margin-top: 0.18rem;
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.spendy-company-metric__subvalue {
    margin-top: 0.18rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.spendy-company-metric__subvalue .metric-source-breakdown,
.spendy-company-metric__subvalue .metric-source-counts {
    display: block;
}

.spendy-company-row__value {
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    align-self: center;
    justify-self: end;
}

.spendy-keytaro-card--readonly {
    opacity: 0.92;
}

.overview-custom-range {
    display: none;
    align-items: center;
    gap: 0.45rem;
    padding-left: 0.3rem;
}

.overview-custom-range.is-visible {
    display: inline-flex;
}

.overview-custom-range .form-control {
    min-width: 148px;
    border-radius: 12px;
}

/* ─── Chart containers ───────────────────────────────────────────────────── */

#chartSpendByDay,
#chartSpendByAccount {
    width: 100%;
    min-height: 200px;
}

/* ─── Alert styles for auth forms ───────────────────────────────────────── */

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: 6px;
}

/* ─── Responsive small screen  ───────────────────────────────────────────── */

@media (max-width: 576px) {
    .kpi-value {
        font-size: 1.2rem;
    }
    .kpi-card {
        padding: 0.75rem;
    }
}

@media (max-width: 992px) {
    .dashboard-shell {
        grid-template-columns: 1fr;
    }
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(320px, 88vw);
        min-height: 100vh;
        min-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        z-index: 999;
        transform: translateX(-100%);
        border-right: 1px solid var(--surface-border);
        border-bottom: none;
        box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    }
    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }
    body.sidebar-mobile-open #sidebarBackdrop {
        opacity: 1;
        pointer-events: auto;
    }
    body.sidebar-collapsed .dashboard-shell {
        grid-template-columns: 1fr;
    }
    body.sidebar-collapsed .sidebar-brand-sub,
    body.sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-nav-btn span,
    body.sidebar-collapsed .sidebar-actions .btn-custom span,
    body.sidebar-collapsed .sidebar-brand-title,
    body.sidebar-collapsed #authBtn {
        display: initial;
    }
    .sidebar-footer-actions {
        grid-template-columns: 1fr 52px;
    }
}

@media (max-height: 860px) {
    .app-sidebar {
        gap: 0.75rem;
        padding-top: 1rem;
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    }

    .sidebar-brand {
        gap: 0.7rem;
    }

    .sidebar-brand-mark {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .sidebar-nav,
    .sidebar-actions {
        gap: 0.45rem;
    }

    .sidebar-nav-btn,
    .sidebar-actions .btn-custom,
    .sidebar-footer-actions .btn-custom {
        padding-top: 0.6rem;
        padding-bottom: 0.6rem;
    }

    .sidebar-section-label {
        margin-top: 0.1rem;
    }
}

@media (max-width: 768px) {
    .app-topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .app-topbar-user {
        white-space: normal;
    }
    .profile-settings-grid {
        flex-direction: column;
        align-items: flex-start;
    }
}

.metric-val {
    font-size: 0.8rem;
}

.kpi-delta {
    margin-top: 0.35rem;
    min-height: 1rem;
    font-size: 0.72rem;
    font-weight: 600;
}

.analytics-inline-select {
    min-width: 145px;
}

.analytics-multi-select {
    min-height: 132px;
    border-radius: 12px;
    padding: 0.35rem;
    font-size: 0.82rem;
}

.analytics-multi-select option {
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    margin-bottom: 2px;
}

.dashboard-view-list {
    display: grid;
    gap: 10px;
}

.dashboard-view-group {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}

.dashboard-view-group:last-child {
    margin-bottom: 0;
}

.dashboard-view-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.dashboard-view-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 14px;
    background: rgba(148, 163, 184, 0.08);
}

.overview-custom-apply-btn {
    height: 31px;
    padding: 0 0.72rem;
    border-radius: 10px;
    font-size: 0.75rem;
    line-height: 1;
    white-space: nowrap;
}

.analytics-campaign-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.analytics-account-overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

[data-theme="dark"] .dashboard-view-card {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.dashboard-view-card.is-active {
    border-color: rgba(13, 202, 240, 0.55);
    box-shadow: 0 0 0 1px rgba(13, 202, 240, 0.18) inset;
}

.dashboard-view-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

@media (max-width: 991px) {
    .analytics-campaign-grid,
    .analytics-account-overview-grid {
        grid-template-columns: 1fr;
    }

    .spendy-card__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .spendy-account-block__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .spendy-company-row {
        grid-template-columns: 1fr;
    }

    .spendy-company-row__stats,
    .spendy-company-row__value {
        align-self: start;
        justify-self: start;
    }
    }

.analytics-action-btn {
    white-space: nowrap;
}

.analytics-jump-highlight {
    animation: analyticsJumpPulse 1.8s ease;
}

@media (max-width: 1200px) {
    .analytics-account-detail-grid,
    .analytics-campaign-deep-grid,
    .analytics-metric-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1399px) {
    .analytics-metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

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

.analytics-account-detail-panel {
    border-top: 1px solid var(--surface-border);
    padding-top: 12px;
}

/* ─── Unified Aurora Theme (service-wide) ───────────────────────────────── */

[data-theme="dark"] {
    --bg-body: #090f1f;
    --surface-bg: rgba(15, 23, 42, 0.78);
    --surface-border: rgba(148, 163, 184, 0.26);
    --text-main: #e6ecff;
    --text-muted: #aeb9da;
    --shadow-sm: 0 14px 30px rgba(3, 7, 18, 0.42), 0 2px 10px rgba(30, 58, 138, 0.18);
    --primary-color: #7c86ff;
    --primary-hover: #98a2ff;
    --info-text: #8cc6ff;
    --table-header: rgba(15, 23, 42, 0.62);
    --table-hover: rgba(129, 140, 248, 0.14);
    --table-border: rgba(148, 163, 184, 0.2);
    --row-level-1: rgba(15, 23, 42, 0.74);
    --row-level-2: rgba(22, 33, 62, 0.7);
    --row-level-3: rgba(26, 38, 71, 0.66);
    --row-level-4: rgba(31, 47, 85, 0.62);
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(148, 163, 184, 0.26);
    --color-scheme: dark;
    --camp-color: #98a2ff;
    --adset-color: #7dd3fc;
}

body {
    background:
        radial-gradient(circle at 10% 12%, rgba(99, 102, 241, 0.24) 0%, transparent 34%),
        radial-gradient(circle at 88% 14%, rgba(59, 130, 246, 0.19) 0%, transparent 30%),
        radial-gradient(circle at 82% 78%, rgba(34, 211, 238, 0.15) 0%, transparent 30%),
        linear-gradient(150deg, #070d1a 0%, #0a1122 46%, #0a1430 100%);
    background-attachment: fixed;
}

.dashboard-shell {
    backdrop-filter: blur(2px);
}

.app-sidebar {
    background:
        linear-gradient(180deg, rgba(129, 140, 248, 0.08), rgba(14, 24, 46, 0.5) 42%, rgba(10, 18, 36, 0.8)),
        rgba(8, 14, 30, 0.9);
    border-right: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

.sidebar-brand-mark {
    background: linear-gradient(135deg, #6d7dff 0%, #4f9bff 48%, #4dd7e8 100%);
    box-shadow: 0 14px 30px rgba(79, 70, 229, 0.35);
}

.sidebar-user-card {
    display: none;
}

.sidebar-nav-btn {
    border: 1px solid transparent;
    background: transparent;
    color: #dbe6ff;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    transition: all 0.2s ease;
}

.sidebar-nav-btn:hover {
    background: rgba(129, 140, 248, 0.12);
    border-color: rgba(129, 140, 248, 0.24);
}

.sidebar-nav-btn.text-info {
    color: #dfe6ff !important;
    background: linear-gradient(135deg, rgba(109, 125, 255, 0.3), rgba(75, 157, 255, 0.2));
    border-color: rgba(144, 160, 255, 0.45);
    box-shadow: inset 0 0 0 1px rgba(199, 210, 254, 0.15);
}

.saas-card {
    background: linear-gradient(155deg, rgba(15, 23, 42, 0.78), rgba(14, 26, 50, 0.72));
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 16px;
    box-shadow: 0 14px 34px rgba(3, 7, 18, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.app-topbar-user {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(129, 140, 248, 0.28);
    color: #dbe6ff;
}

.btn-custom {
    background: linear-gradient(180deg, rgba(30, 41, 69, 0.8), rgba(18, 29, 54, 0.82));
    border: 1px solid rgba(148, 163, 184, 0.28);
    color: #e5edff;
    border-radius: 11px;
}

.btn-custom:hover {
    background: linear-gradient(180deg, rgba(45, 59, 93, 0.88), rgba(30, 45, 77, 0.9));
    border-color: rgba(168, 184, 255, 0.46);
    color: #f1f5ff;
}

.btn-primary-saas {
    background: linear-gradient(135deg, #6e79ff 0%, #5a93ff 50%, #45c8ea 100%);
    color: #fff;
    border: none;
    box-shadow: 0 12px 26px rgba(86, 118, 255, 0.35);
}

.btn-primary-saas:hover {
    background: linear-gradient(135deg, #7e88ff 0%, #69a3ff 50%, #57d3ee 100%);
    color: #fff;
}

.form-control,
.form-select {
    background: rgba(15, 23, 42, 0.62);
    border: 1px solid rgba(148, 163, 184, 0.25);
    color: #e6ecff;
    border-radius: 10px;
}

.form-control::placeholder {
    color: rgba(196, 209, 241, 0.55);
}

.form-control:focus,
.form-select:focus {
    background: rgba(18, 27, 50, 0.74);
    border-color: rgba(129, 140, 248, 0.62);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.22);
    color: #f3f7ff;
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background: rgba(29, 41, 72, 0.6) !important;
    color: #e6ecff !important;
    border-color: rgba(148, 163, 184, 0.24) !important;
    opacity: 0.95;
}

.form-select {
    padding-right: 2rem;
    background-image: linear-gradient(45deg, transparent 50%, #9db0eb 50%), linear-gradient(135deg, #9db0eb 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% - 3px), calc(100% - 11px) calc(50% - 3px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.form-select option,
#kingSelect option,
#overviewOrgSelect option,
#overviewTeamSelect option,
#buyerFilterSelect option,
#buyerSortSelect option {
    background: #0e1731;
    color: #e6ecff;
}

#kingSelect {
    min-height: 38px;
    border-radius: 12px;
    font-weight: 600;
}

#kingSelect + .custom-select .custom-select__trigger {
    min-height: 38px;
    border-radius: 999px;
    border-color: rgba(129, 140, 248, 0.34);
    background: linear-gradient(135deg, rgba(18, 33, 66, 0.9), rgba(13, 24, 46, 0.94));
    box-shadow: inset 0 0 0 1px rgba(199, 210, 254, 0.09);
    font-weight: 700;
}

#kingSelect + .custom-select .custom-select__value {
    color: #eaf1ff;
}

#kingSelect + .custom-select .custom-select__dropdown {
    border-radius: 16px;
    border-color: rgba(129, 140, 248, 0.34);
}

#kingSelect + .custom-select .custom-select__option {
    border-radius: 10px;
    padding: 0.42rem 0.56rem;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-main);
    --bs-table-border-color: rgba(148, 163, 184, 0.2);
    --bs-table-striped-bg: rgba(99, 102, 241, 0.06);
    --bs-table-hover-bg: rgba(129, 140, 248, 0.12);
}

.analytics-campaign-card,
.analytics-alert-card,
.dashboard-view-card,
.analytics-empty-state,
.analytics-insight-item {
    background: rgba(16, 28, 52, 0.58);
    border-color: rgba(148, 163, 184, 0.24);
    border-radius: 14px;
}

.kpi-card {
    border-radius: 16px;
}

.kpi-card::after {
    content: '';
    position: absolute;
    right: -28px;
    top: -28px;
    width: 90px;
    height: 90px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(129, 140, 248, 0.24), transparent 65%);
    pointer-events: none;
}

.theme-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 0.96rem;
}

[data-theme="light"] {
    --font-body: 'Manrope', 'Segoe UI', sans-serif;
    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --bg-body: #eef4fb;
    --surface-bg: rgba(255, 255, 255, 0.88);
    --surface-border: rgba(15, 23, 42, 0.11);
    --text-main: #0f172a;
    --text-muted: #475569;
    --shadow-sm: 0 12px 32px rgba(15, 23, 42, 0.08), 0 3px 12px rgba(56, 189, 248, 0.08);
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --info-text: #0369a1;
    --table-header: rgba(241, 245, 249, 0.92);
    --table-hover: rgba(14, 165, 233, 0.08);
    --table-border: rgba(15, 23, 42, 0.1);
    --row-level-1: rgba(255, 255, 255, 0.96);
    --row-level-2: rgba(247, 250, 252, 0.98);
    --row-level-3: rgba(241, 245, 249, 0.94);
    --row-level-4: rgba(234, 241, 249, 0.92);
    --input-bg: rgba(255, 255, 255, 0.95);
    --input-border: rgba(15, 23, 42, 0.16);
    --color-scheme: light;
    --camp-color: #0f766e;
    --adset-color: #0284c7;
}

[data-theme="light"] body {
    background:
        radial-gradient(circle at 6% 10%, rgba(14, 165, 233, 0.16) 0%, transparent 30%),
        radial-gradient(circle at 94% 18%, rgba(16, 185, 129, 0.12) 0%, transparent 28%),
        radial-gradient(circle at 85% 88%, rgba(14, 116, 144, 0.09) 0%, transparent 30%),
        linear-gradient(160deg, #f7fbff 0%, #ecf5ff 48%, #eef8f9 100%);
    background-attachment: fixed;
}

[data-theme="light"] .app-sidebar {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 248, 255, 0.92) 44%, rgba(235, 245, 255, 0.95)),
        #f6faff;
    border-right: 1px solid rgba(15, 23, 42, 0.1);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.85), 16px 0 28px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .sidebar-brand-mark {
    background: linear-gradient(135deg, #0891b2 0%, #0ea5e9 48%, #34d399 100%);
    box-shadow: 0 12px 26px rgba(14, 116, 144, 0.24);
}

[data-theme="light"] .sidebar-nav-btn {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 255, 0.94));
    border-color: rgba(15, 23, 42, 0.18);
    color: #0f172a;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .sidebar-nav-btn:hover {
    background: linear-gradient(180deg, rgba(244, 251, 255, 0.98), rgba(235, 247, 255, 0.96));
    border-color: rgba(14, 165, 233, 0.24);
}

[data-theme="light"] .sidebar-nav-btn.text-info {
    color: #0f172a !important;
    background: linear-gradient(135deg, rgba(184, 239, 248, 0.95), rgba(203, 247, 232, 0.92));
    border-color: rgba(71, 193, 210, 0.42);
    box-shadow: 0 8px 18px rgba(56, 189, 248, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

[data-theme="light"] .sidebar-service-desc {
    color: #526173;
}

[data-theme="light"] .sidebar-footer-actions .btn-custom,
[data-theme="light"] .sidebar-actions .btn-custom {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 255, 0.94));
    border-color: rgba(15, 23, 42, 0.14);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .sidebar-footer-actions .btn-custom:hover,
[data-theme="light"] .sidebar-actions .btn-custom:hover {
    background: linear-gradient(180deg, rgba(244, 251, 255, 0.98), rgba(235, 247, 255, 0.96));
    border-color: rgba(14, 165, 233, 0.24);
}

[data-theme="light"] .theme-toggle {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(243, 248, 255, 0.95));
    border: 1px solid rgba(15, 23, 42, 0.14);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .saas-card {
    background: linear-gradient(152deg, rgba(255, 255, 255, 0.92), rgba(245, 251, 255, 0.86));
    border: 1px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .kpi-card {
    background:
        radial-gradient(circle at 100% 0%, rgba(14, 165, 233, 0.16), transparent 42%),
        linear-gradient(152deg, rgba(255, 255, 255, 0.95), rgba(239, 249, 255, 0.92));
    border-color: rgba(14, 165, 233, 0.18);
}

[data-theme="light"] #overviewArea .saas-card,
[data-theme="light"] #workspaceArea .saas-card {
    position: relative;
    overflow: hidden;
}

[data-theme="light"] #overviewArea .saas-card::before,
[data-theme="light"] #workspaceArea .saas-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.8), rgba(16, 185, 129, 0.72), rgba(56, 189, 248, 0.72));
    opacity: 0.85;
    pointer-events: none;
}

[data-theme="light"] body:not(.app-booting) #overviewArea .saas-card,
[data-theme="light"] body:not(.app-booting) #workspaceArea .saas-card,
[data-theme="light"] body:not(.app-booting) #integrationsArea .saas-card {
    animation: lightCardReveal 0.56s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

[data-theme="light"] body:not(.app-booting) #overviewArea .row > [class*="col"]:nth-child(1) .saas-card,
[data-theme="light"] body:not(.app-booting) #workspaceArea .row > [class*="col"]:nth-child(1) .saas-card { animation-delay: 0.03s; }
[data-theme="light"] body:not(.app-booting) #overviewArea .row > [class*="col"]:nth-child(2) .saas-card,
[data-theme="light"] body:not(.app-booting) #workspaceArea .row > [class*="col"]:nth-child(2) .saas-card { animation-delay: 0.08s; }
[data-theme="light"] body:not(.app-booting) #overviewArea .row > [class*="col"]:nth-child(3) .saas-card,
[data-theme="light"] body:not(.app-booting) #workspaceArea .row > [class*="col"]:nth-child(3) .saas-card { animation-delay: 0.13s; }
[data-theme="light"] body:not(.app-booting) #overviewArea .row > [class*="col"]:nth-child(4) .saas-card,
[data-theme="light"] body:not(.app-booting) #workspaceArea .row > [class*="col"]:nth-child(4) .saas-card { animation-delay: 0.18s; }

@keyframes lightCardReveal {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.992);
        filter: saturate(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: saturate(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    [data-theme="light"] body:not(.app-booting) #overviewArea .saas-card,
    [data-theme="light"] body:not(.app-booting) #workspaceArea .saas-card,
    [data-theme="light"] body:not(.app-booting) #integrationsArea .saas-card {
        animation: none !important;
    }
}

[data-theme="light"] .app-topbar-user {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(14, 165, 233, 0.26);
    color: #0f172a;
}

[data-theme="light"] .btn-custom {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(241, 245, 249, 0.95));
    border: 1px solid rgba(15, 23, 42, 0.14);
    color: #0f172a;
}

[data-theme="light"] .btn-custom:hover {
    background: linear-gradient(180deg, rgba(226, 247, 255, 0.98), rgba(235, 249, 255, 0.99));
    border-color: rgba(14, 165, 233, 0.35);
    color: #0f172a;
}

[data-theme="light"] .btn-primary-saas {
    background: linear-gradient(135deg, #0891b2 0%, #0ea5e9 55%, #10b981 100%);
    color: #ffffff;
    border: none;
}

[data-theme="light"] .btn-primary-saas:hover {
    background: linear-gradient(135deg, #0e7490 0%, #0284c7 55%, #059669 100%);
    color: #ffffff;
}

[data-theme="light"] .form-control,
[data-theme="light"] .form-select {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.16);
    color: #0f172a;
}

[data-theme="light"] .form-control:focus,
[data-theme="light"] .form-select:focus {
    background: #ffffff;
    border-color: rgba(14, 165, 233, 0.65);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
    color: #0f172a;
}

[data-theme="light"] .form-control::placeholder {
    color: rgba(71, 85, 105, 0.72);
}

[data-theme="light"] .form-select option,
[data-theme="light"] #kingSelect option,
[data-theme="light"] #overviewOrgSelect option,
[data-theme="light"] #overviewTeamSelect option,
[data-theme="light"] #buyerFilterSelect option,
[data-theme="light"] #buyerSortSelect option {
    background: #ffffff;
    color: #0f172a;
}

[data-theme="light"] #kingSelect + .custom-select .custom-select__trigger {
    border-color: rgba(14, 165, 233, 0.28);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 249, 255, 0.96));
    box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.08);
}

[data-theme="light"] #kingSelect + .custom-select .custom-select__value {
    color: #0f172a;
}

[data-theme="light"] #kingSelect + .custom-select .custom-select__dropdown {
    background: #ffffff;
    border-color: rgba(14, 165, 233, 0.22);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.14);
}

[data-theme="light"] #kingSelect + .custom-select .custom-select__option {
    color: #334155;
    border-radius: 10px;
}

[data-theme="light"] #kingSelect + .custom-select .custom-select__option:hover,
[data-theme="light"] #kingSelect + .custom-select .custom-select__option.is-selected {
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.22);
    color: #0f172a;
}

[data-theme="light"] .table {
    --bs-table-border-color: rgba(15, 23, 42, 0.1);
    --bs-table-striped-bg: rgba(14, 165, 233, 0.05);
    --bs-table-hover-bg: rgba(14, 165, 233, 0.08);
}

[data-theme="light"] .analytics-campaign-card,
[data-theme="light"] .analytics-alert-card,
[data-theme="light"] .dashboard-view-card,
[data-theme="light"] .analytics-empty-state,
[data-theme="light"] .analytics-insight-item {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .analytics-metric-tile {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(240, 249, 255, 0.95));
    border-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .analytics-metric-tile.is-primary {
    border-color: rgba(14, 165, 233, 0.22);
    background: linear-gradient(180deg, rgba(224, 242, 254, 0.95), rgba(240, 249, 255, 0.98));
}

[data-theme="light"] .analytics-metric-tile.is-success {
    border-color: rgba(16, 185, 129, 0.2);
    background: linear-gradient(180deg, rgba(220, 252, 231, 0.9), rgba(240, 253, 244, 0.96));
}

[data-theme="light"] .notification-item {
    background: rgba(255, 255, 255, 0.96);
    color: #0f172a;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14);
}

[data-theme="light"] .notification-item__close {
    color: rgba(15, 23, 42, 0.8);
}

#overviewAlertBadge {
    background: linear-gradient(135deg, #fb7185, #ef4444) !important;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.24);
}

@media (max-width: 992px) {
    .app-sidebar {
        background: linear-gradient(165deg, rgba(10, 18, 34, 0.98), rgba(9, 15, 28, 0.98));
    }
}

.analytics-account-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

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

.analytics-account-summary-card.is-selected {
    border-color: rgba(14, 165, 233, 0.4);
    box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.16) inset;
}

.overview-company-card {
    padding: 1.1rem;
    border-radius: 18px;
    border-width: 1px;
    background:
        radial-gradient(circle at 92% 16%, rgba(14, 165, 233, 0.16), transparent 36%),
        radial-gradient(circle at 8% 88%, rgba(16, 185, 129, 0.1), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(148, 163, 184, 0.08));
}

.overview-company-card .analytics-metric-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-top: 1rem;
}

.overview-company-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.95rem;
}

.overview-buyer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.95rem;
}

.overview-buyer-card {
    text-align: left;
    width: 100%;
    cursor: pointer;
}

.overview-account-card {
    background:
        radial-gradient(circle at 90% 14%, rgba(59, 130, 246, 0.14), transparent 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(148, 163, 184, 0.08));
}

.overview-account-card .analytics-metric-grid,
.overview-buyer-card .analytics-metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.overview-company-title {
    font-size: 1.03rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.overview-account-title {
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.overview-company-header-sub {
    margin-top: 0.42rem;
    font-size: 0.76rem;
    color: var(--text-muted);
}

@media (max-width: 1399px) {
    .overview-company-card .analytics-metric-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 992px) {
    .overview-buyer-grid {
        grid-template-columns: 1fr;
    }

    .overview-company-card .analytics-metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .overview-company-card .analytics-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.analytics-account-campaign-card {
    border: 1px solid rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .analytics-account-campaign-card {
    border-color: rgba(255, 255, 255, 0.08);
}

.analytics-adset-strip {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.analytics-adset-chip {
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(148, 163, 184, 0.08);
}

[data-theme="dark"] .analytics-adset-chip {
    background: rgba(255, 255, 255, 0.04);
}

.analytics-campaign-deep-panel {
    border-top: 1px solid var(--surface-border);
    padding-top: 12px;
}

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

.analytics-adset-deep-card {
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(148, 163, 184, 0.05);
}

[data-theme="dark"] .analytics-adset-deep-card {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.analytics-ad-grid {
    display: grid;
    gap: 8px;
}

.analytics-ad-chip {
    border-radius: 12px;
    padding: 9px 11px;
    background: rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] .analytics-ad-chip {
    background: rgba(255, 255, 255, 0.04);
}

.integration-access-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
}

.integration-access-chip--primary {
    background: rgba(59, 130, 246, 0.14);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.22);
}

.integration-access-chip--shared {
    background: rgba(248, 250, 252, 0.96);
    color: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.45);
}

.integration-access-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    min-width: 1.2rem;
    border-radius: 999px;
    padding: 0;
    margin-left: 0.1rem;
    color: #dc2626;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
}

.integration-access-remove:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

[data-theme="dark"] .integration-access-chip--primary {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border-color: rgba(96, 165, 250, 0.34);
}

[data-theme="dark"] .integration-access-chip--shared {
    background: rgba(30, 41, 59, 0.88);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.34);
}

@keyframes analyticsJumpPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.45);
        transform: translateY(0);
    }
    35% {
        box-shadow: 0 0 0 8px rgba(14, 165, 233, 0.12);
        transform: translateY(-2px);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(14, 165, 233, 0);
        transform: translateY(0);
    }
}

.notification-center {
    position: fixed;
    top: 18px;
    right: max(14px, env(safe-area-inset-right));
    width: min(96vw, 680px);
    z-index: 12000;
    display: grid;
    gap: 8px;
}

.notification-item {
    display: grid;
    grid-template-columns: 20px 1fr 18px;
    gap: 8px;
    align-items: start;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(12, 18, 34, 0.94);
    color: #dbe6ff;
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.45);
    animation: notifIn 0.2s ease;
}

.notification-item.is-success { border-color: rgba(16, 185, 129, 0.48); }
.notification-item.is-error { border-color: rgba(244, 63, 94, 0.55); }
.notification-item.is-warning { border-color: rgba(245, 158, 11, 0.55); }
.notification-item.is-info { border-color: rgba(56, 189, 248, 0.45); }

.analytics-meta-section {
    border-top: 1px solid var(--surface-border);
    padding-top: 10px;
}

.analytics-meta-chip {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(148, 163, 184, 0.08);
    font-size: 0.76rem;
    line-height: 1.35;
}

[data-theme="dark"] .analytics-meta-chip {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(148, 163, 184, 0.3);
}

.notification-item__icon { margin-top: 1px; }
.notification-item__text {
    font-size: 0.78rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.notification-item__close {
    background: transparent;
    border: none;
    color: rgba(219, 230, 255, 0.8);
    padding: 0;
    line-height: 1;
}

.notification-item.is-leaving {
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.18s ease;
}

.keytaro-payout-editor-cell {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.keytaro-payout-summary-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.keytaro-payout-editor-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 112px;
    justify-content: space-between;
}

.keytaro-payout-editor-toggle.is-active {
    border-color: rgba(79, 70, 229, 0.48);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.keytaro-payout-summary-value {
    font-weight: 700;
}

.keytaro-payout-editor {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    width: min(260px, 78vw);
}

.keytaro-payout-editor-card {
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: var(--surface-bg);
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.18);
    text-align: left;
}

.keytaro-payout-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.keytaro-payout-editor-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-main);
}

.keytaro-payout-editor-meta {
    font-size: 0.7rem;
    line-height: 1.35;
    color: var(--text-muted);
    margin-top: 8px;
}

#spendyKeytaroCard .table-responsive {
    overflow: visible;
}

@keyframes notifIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.custom-select-native {
    position: absolute !important;
    inset: auto;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.custom-select {
    position: relative;
    width: 100%;
    min-width: 120px;
}

.saas-card.custom-select-open {
    overflow: visible !important;
    z-index: 80;
}

#overviewArea .saas-card.custom-select-open,
#integrationControlArea .saas-card.custom-select-open,
#teamManagementArea .saas-card.custom-select-open,
#settingsArea .saas-card.custom-select-open {
    position: relative;
}

.custom-select__trigger {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.62);
    color: #e6ecff;
    padding: 0.42rem 0.68rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.79rem;
    min-height: 36px;
}

.custom-select__trigger i {
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.custom-select.is-static .custom-select__trigger {
    cursor: default;
}

.custom-select.is-static .custom-select__trigger i {
    opacity: 0;
    display: none;
}

.custom-select__trigger:disabled {
    cursor: default;
}

#overviewArea .btn,
#overviewArea .btn-custom,
#overviewArea .btn-primary-saas,
#overviewArea .btn-outline-secondary,
#overviewArea .btn-outline-info,
#overviewArea .btn-outline-warning,
#overviewArea .btn-outline-danger,
#workspaceArea .btn,
#workspaceArea .btn-custom,
#workspaceArea .btn-primary-saas,
#workspaceArea .btn-outline-secondary,
#workspaceArea .btn-outline-info,
#workspaceArea .btn-outline-warning,
#workspaceArea .btn-outline-danger,
#integrationsManagementArea .btn,
#integrationsManagementArea .btn-custom,
#integrationsManagementArea .btn-primary-saas,
#integrationsManagementArea .btn-outline-secondary,
#integrationsManagementArea .btn-outline-info,
#integrationsManagementArea .btn-outline-warning,
#integrationsManagementArea .btn-outline-danger,
.overview-period-btn,
.overview-custom-apply-btn,
.dashboard-view-card .btn,
.analytics-action-btn {
    border-radius: 10px !important;
}

#overviewArea .btn,
#workspaceArea .btn,
#integrationsManagementArea .btn,
.overview-period-btn,
.dashboard-view-card .btn {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
}

.custom-select__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(10, 18, 36, 0.98);
    box-shadow: 0 16px 34px rgba(2, 6, 23, 0.44);
    max-height: 220px;
    overflow: auto;
    display: none;
    z-index: 2500;
}

.custom-select__trigger:focus-visible {
    outline: none;
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.custom-select__option {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    text-align: left;
    border-radius: 10px;
    padding: 0.44rem 0.56rem;
    font-size: 0.78rem;
}

.custom-select__option:hover,
.custom-select__option.is-selected {
    background: rgba(129, 140, 248, 0.18);
    border-color: rgba(129, 140, 248, 0.35);
}

[data-theme="light"] .custom-select__trigger {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(241, 245, 249, 0.96));
    border-color: rgba(15, 23, 42, 0.16);
    color: #0f172a;
}

[data-theme="light"] .custom-select__dropdown {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.16);
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
}

[data-theme="light"] .custom-select__option {
    color: #334155;
}

[data-theme="light"] .custom-select__option:hover,
[data-theme="light"] .custom-select__option.is-selected {
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.24);
    color: #0f172a;
}

#statsTableThemeSelect + .custom-select {
    width: 132px;
    min-width: 132px;
}

#statsTableThemeSelect + .custom-select .custom-select__trigger {
    min-height: 30px;
    border-radius: 999px;
    padding: 0.28rem 0.62rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.95));
    border-color: rgba(148, 163, 184, 0.42);
    color: #334155;
    font-weight: 700;
}

#statsTableThemeSelect + .custom-select .custom-select__dropdown {
    border-radius: 14px;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
}

#statsTableThemeSelect + .custom-select .custom-select__option {
    border-radius: 10px;
    color: #334155;
    font-weight: 600;
}

#statsTableThemeSelect + .custom-select .custom-select__option:hover,
#statsTableThemeSelect + .custom-select .custom-select__option.is-selected {
    background: rgba(56, 189, 248, 0.14);
    border-color: rgba(56, 189, 248, 0.32);
}

[data-theme="dark"] #statsTableThemeSelect + .custom-select .custom-select__trigger {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border-color: rgba(148, 163, 184, 0.35);
    color: #e2e8f0;
}

[data-theme="dark"] #statsTableThemeSelect + .custom-select .custom-select__dropdown {
    background: #0b1222;
    border-color: rgba(148, 163, 184, 0.35);
}

[data-theme="dark"] #statsTableThemeSelect + .custom-select .custom-select__option {
    color: #dbe6ff;
}

body.table-theme-keitaro #statsTableThemeSelect + .custom-select .custom-select__trigger {
    background: linear-gradient(180deg, #f7f9fc 0%, #edf2f8 100%);
    border-color: #89a4cf;
    color: #43526a;
}

body.table-theme-keitaro #statsTableThemeSelect + .custom-select .custom-select__dropdown {
    background: #f8fafc;
    border-color: #b6c7dd;
}

body.table-theme-keitaro #statsTableThemeSelect + .custom-select .custom-select__option {
    color: #3f526d;
}

.custom-select.is-open .custom-select__dropdown { display: block; }
.custom-select.is-open .custom-select__trigger i { transform: rotate(180deg); }

.custom-select__list {
    display: grid;
    gap: 2px;
    padding: 6px;
}

.custom-select__option {
    text-align: left;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #dbe6ff;
    padding: 0.3rem 0.45rem;
    font-size: 0.76rem;
}

.custom-select__option:hover,
.custom-select__option.is-selected {
    background: rgba(129, 140, 248, 0.18);
    border-color: rgba(129, 140, 248, 0.32);
}

.member-avatar,
.scoreboard-avatar {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid rgba(148, 163, 184, 0.3);
    margin-right: 8px;
}

.member-identity,
.scoreboard-identity {
    display: flex;
    align-items: center;
    min-width: 0;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.health-card {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(14, 24, 46, 0.62);
    padding: 10px 11px;
}

[data-theme="light"] .health-card {
    background: #ffffff !important;
    border-color: #d6e1ee !important;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .health-card__title {
    color: #0f172a;
}

[data-theme="light"] .health-card__meta {
    color: #475569;
}

.health-card__title {
    font-weight: 700;
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.health-card__meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.wizard-step {
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.62);
}

.wizard-step__counter {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-bottom: 4px;
}

.wizard-step__title {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.wizard-step__body {
    font-size: 0.78rem;
    color: #dbe6ff;
}

#statsTableThemeSelect {
    min-height: 30px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    padding-left: 0.62rem;
    padding-right: 1.6rem;
}

body.table-theme-keitaro #statsTableThemeSelect {
    border-color: #89a4cf;
    background: linear-gradient(180deg, #f7f9fc 0%, #edf2f8 100%);
    color: #43526a;
}

.cab-selection-badge {
    font-size: 0.69rem;
    color: #1f5b3d;
    background: rgba(75, 154, 90, 0.14);
    border: 1px solid rgba(75, 154, 90, 0.32);
    border-radius: 999px;
    padding: 0.12rem 0.45rem;
    vertical-align: middle;
}

.cab-rule-indicators {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.cab-rule-chip {
    display: inline-flex;
    align-items: center;
    font-size: 0.67rem;
    color: #204a35;
    border: 1px solid #b4d3bb;
    background: #edf7ef;
    border-radius: 999px;
    padding: 0.12rem 0.45rem;
}

.cab-rule-chip-muted {
    color: var(--text-muted);
    border-color: var(--surface-border);
    background: var(--table-header);
}

.quick-rule-campaign-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.quick-rule-campaign-picker {
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    padding: 0.5rem;
    background: color-mix(in srgb, var(--surface-bg) 88%, #94a3b8 12%);
}

.quick-rule-campaign-list {
    max-height: 170px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
}

.quick-rule-campaign-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 0.3rem 0.45rem;
    font-size: 0.74rem;
    background: var(--surface-bg);
}

.quick-rule-campaign-item:hover {
    border-color: color-mix(in srgb, var(--primary-color) 40%, var(--surface-border) 60%);
    background: color-mix(in srgb, var(--surface-bg) 82%, var(--primary-color) 18%);
}

.quick-rule-campaign-empty {
    color: var(--text-muted);
    font-size: 0.74rem;
    text-align: center;
    padding: 0.6rem 0;
}

.quick-rule-campaign-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid #b5c7dd;
    background: #f0f5fc;
    color: #27415f;
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
    font-size: 0.68rem;
    cursor: pointer;
}

#campaignDetailsModal .modal-content {
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
}

#campaignDetailsModal .modal-header {
    border-bottom: 1px solid var(--surface-border);
    background: color-mix(in srgb, var(--surface-bg) 78%, #64748b 22%);
}

#campaignDetailsModal .modal-title,
#campaignDetailsModal .analytics-meta-section h6,
#campaignDetailsModal .analytics-meta-chip div {
    color: var(--text-main);
}

#campaignDetailsModal .btn-close {
    opacity: 0.8;
}

[data-theme="dark"] #campaignDetailsModal .btn-close {
    filter: invert(1) grayscale(100%);
}

#campaignDetailsModal .analytics-meta-chip .text-muted {
    color: color-mix(in srgb, var(--text-muted) 88%, var(--text-main) 12%) !important;
}

body.table-theme-keitaro #campaignDetailsModal .modal-content {
    background: #f2f7f2;
    border: 1px solid #cddfcf;
    color: #243938;
}

body.table-theme-keitaro #campaignDetailsModal .modal-header {
    background: #e6f0e7;
    border-bottom: 1px solid #c3d6c6;
}

body.table-theme-keitaro #campaignDetailsModal .analytics-meta-chip {
    background: #f7fbf7;
    border-color: #d0e1d1;
    color: #2f4a44;
}

body.table-theme-keitaro #campaignDetailsModal .modal-title,
body.table-theme-keitaro #campaignDetailsModal .analytics-meta-section h6,
body.table-theme-keitaro #campaignDetailsModal .analytics-meta-chip div {
    color: #2f4a44;
}

body.table-theme-keitaro #campaignDetailsModal .analytics-meta-chip .text-muted {
    color: #55716a !important;
}