/* ==========================================================================
   PALANTIR DESIGN SYSTEM (GROSVILLE MARKETING INTELLIGENCE)
   Aesthetics: Apple High-Craft, Emil Kowalski Polish, Glassmorphism, 8px Grid
   ========================================================================== */

:root {
    --bg-base: #0a0d14;
    --bg-surface: rgba(18, 24, 38, 0.75);
    --bg-surface-hover: rgba(28, 38, 58, 0.85);
    --bg-glass-card: rgba(20, 28, 45, 0.6);
    --bg-glass-input: rgba(12, 17, 29, 0.8);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(14, 165, 233, 0.3);
    --border-focus: rgba(16, 185, 129, 0.5);

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --accent-primary: #0ea5e9;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;
    --accent-gold: #fbbf24;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow-emerald: 0 0 24px rgba(16, 185, 129, 0.25);
    --shadow-glow-blue: 0 0 24px rgba(14, 165, 233, 0.25);

    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 1. Base Reset & Layout & Custom Scrollbars */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(14, 165, 233, 0.35) rgba(10, 13, 20, 0.6);
}

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

::-webkit-scrollbar-track {
    background: rgba(10, 13, 20, 0.6);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.5), rgba(16, 185, 129, 0.5));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 165, 233, 0.8);
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

/* 2. Ambient Glow Background */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(140px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.25), transparent 70%);
    top: -200px;
    left: -100px;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2), transparent 70%);
    bottom: -150px;
    right: -100px;
}

.glow-3 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.15), transparent 70%);
    top: 40%;
    left: 40%;
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    box-shadow: var(--shadow-glass);
}

/* 3. Auth Screen (Login Screen centered globally) */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    min-height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(7, 10, 19, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.auth-card {
    width: 100%;
    max-width: 460px;
    padding: 2.5rem 2rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 1.25rem;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 32px rgba(14, 165, 233, 0.15);
    background: rgba(18, 24, 38, 0.95);
    animation: fadeInScale 0.4s var(--ease-spring);
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-logo-orb {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(16, 185, 129, 0.2));
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    box-shadow: var(--shadow-glow-blue);
}

.auth-card h1 {
    font-size: 1.875rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.35rem;
}

.auth-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.auth-form .form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon input,
.form-control,
.form-select {
    width: 100%;
    height: 2.75rem;
    padding: 0 1rem;
    background: var(--bg-glass-input);
    border: 1px solid var(--border-subtle);
    border-radius: 0.625rem;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    outline: none;
    transition: all 0.2s var(--ease-spring);
}

.input-with-icon input:focus,
.form-control:focus,
.form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.icon-btn {
    position: absolute;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
}

.auth-footer {
    margin-top: 2rem;
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* 4. App Layout */
.app-layout {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
    padding: 1.5rem 2rem 4rem;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-left .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-orb {
    font-size: 1.5rem;
}

.brand-name {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #ffffff;
}

.brand-badge {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent-primary);
    border: 1px solid var(--border-accent);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    letter-spacing: 0.05em;
}

.header-filters {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-item label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-item select {
    height: 2.25rem;
    font-size: 0.875rem;
    padding: 0 0.75rem;
    min-width: 160px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* 4.1. Dashboard Horizontal Tabs (В строку, Apple Glass Segmented Control) */
.dashboard-tabs,
.app-tabs {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    background: rgba(13, 19, 32, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.875rem;
    padding: 0.375rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dashboard-tabs::-webkit-scrollbar,
.app-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6875rem 1.375rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.625rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s var(--ease-spring);
    white-space: nowrap;
    user-select: none;
}

.tab-btn svg {
    color: var(--text-dim);
    transition: color 0.2s;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.tab-btn:hover svg {
    color: var(--accent-primary);
}

.tab-btn.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.28), rgba(16, 185, 129, 0.2));
    border-color: rgba(14, 165, 233, 0.45);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.25);
}

.tab-btn.active svg {
    color: #38bdf8;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s var(--ease-spring);
}

.tab-content.active {
    display: block;
}

/* 5. KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s var(--ease-spring), border-color 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.18);
}

.kpi-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.kpi-sub strong {
    color: var(--text-main);
}

.kpi-accent {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.08), rgba(20, 28, 45, 0.6));
}

.kpi-warning {
    border-color: rgba(244, 63, 94, 0.3);
    background: linear-gradient(180deg, rgba(244, 63, 94, 0.08), rgba(20, 28, 45, 0.6));
}

.kpi-gold {
    border-color: rgba(251, 191, 36, 0.3);
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.08), rgba(20, 28, 45, 0.6));
}

.kpi-highlight {
    border-color: rgba(14, 165, 233, 0.4);
    background: linear-gradient(180deg, rgba(14, 165, 233, 0.12), rgba(20, 28, 45, 0.6));
}

.text-glow {
    color: var(--accent-emerald) !important;
    text-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

.text-success { color: var(--accent-emerald) !important; }
.text-danger { color: var(--accent-rose) !important; }
.text-gold { color: var(--accent-gold) !important; }

/* 6. Funnel Section & Section Headers */
.funnel-container {
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.section-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.section-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    max-width: 520px;
    line-height: 1.45;
}

.section-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(14, 165, 233, 0.12);
    color: var(--accent-primary);
    border: 1px solid rgba(14, 165, 233, 0.25);
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    margin-top: 0.35rem;
}

.funnel-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.funnel-step {
    flex: 1;
    min-width: 140px;
    background: rgba(12, 17, 29, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
    position: relative;
    transition: transform 0.2s var(--ease-spring);
}

.funnel-step:hover {
    transform: translateY(-2px);
}

.step-num {
    position: absolute;
    top: -8px;
    left: 12px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.step-value {
    font-size: 1.35rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: #ffffff;
    margin-bottom: 0.25rem;
}

.step-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.step-highlight {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

.step-won {
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.08);
}

.funnel-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0.25rem;
}

.conv-pct {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.15);
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    margin-bottom: 0.15rem;
}

.arrow-symbol {
    color: var(--text-dim);
    font-size: 1rem;
}

/* 7. Tables */
.table-container {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.responsive-table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th {
    background: rgba(12, 17, 29, 0.8);
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Cohort Matrix Table */
.cohort-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.cohort-title-area h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.cohort-title-area .subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.cohort-metric-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cohort-metric-switcher label {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.btn-group {
    display: flex;
    background: var(--bg-glass-input);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    padding: 0.2rem;
}

.btn-group .btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: all 0.2s;
}

.btn-group .btn-sm.active {
    background: var(--accent-primary);
    color: #fff;
}

.cohort-cell {
    text-align: center;
    border-radius: 0.375rem;
    padding: 0.5rem;
    font-family: var(--font-mono);
    font-weight: 600;
}

.cell-heat-0 { background: rgba(255, 255, 255, 0.02); color: var(--text-dim); }
.cell-heat-1 { background: rgba(16, 185, 129, 0.15); color: #a7f3d0; }
.cell-heat-2 { background: rgba(16, 185, 129, 0.3); color: #6ee7b7; }
.cell-heat-3 { background: rgba(16, 185, 129, 0.45); color: #34d399; font-weight: 700; }
.cell-heat-4 { background: rgba(16, 185, 129, 0.65); color: #ffffff; font-weight: 800; text-shadow: 0 0 8px rgba(0,0,0,0.5); }

/* 8. Drill-Down Tree */
.tree-header {
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.tree-container {
    padding: 1.5rem;
}

.tree-node {
    margin-bottom: 0.5rem;
}

.node-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(12, 17, 29, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s var(--ease-spring);
}

.node-row:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
}

.node-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.node-toggle {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 1.2rem;
    text-align: center;
}

.node-title {
    font-weight: 600;
    color: #ffffff;
}

.node-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.8125rem;
    font-family: var(--font-mono);
}

.tree-children {
    padding-left: 2rem;
    margin-top: 0.5rem;
    border-left: 1px dashed rgba(255, 255, 255, 0.1);
    margin-left: 1rem;
}

/* 9. Buttons & Controls */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0 1.25rem;
    border-radius: 0.625rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s var(--ease-spring);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-accent);
    color: var(--accent-primary);
}

.btn-outline:hover {
    background: rgba(14, 165, 233, 0.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.btn-icon {
    min-height: 2.75rem;
    min-width: 2.75rem;
    padding: 0;
    border-radius: 0.625rem;
    background: var(--bg-glass-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

/* 10. Native Modal Dialogs (<dialog>) */
dialog.glass-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    background: rgba(15, 21, 33, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 1.25rem;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75), 0 0 32px rgba(14, 165, 233, 0.15);
    color: var(--text-main);
    width: 92%;
    max-width: 600px;
    padding: 0;
    outline: none;
    overflow: hidden;
    z-index: 10000;
    animation: dialogPopIn 0.3s var(--ease-spring);
}

@keyframes dialogPopIn {
    from {
        opacity: 0;
        transform: translate(-50%, -46%) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

dialog::backdrop {
    background: rgba(4, 7, 13, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.dialog-title {
    font-size: 1.125rem;
    font-weight: 700;
}

.dialog-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.dialog-body {
    padding: 1.5rem;
    max-height: 75vh;
    overflow-y: auto;
}

.settings-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.set-tab-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.375rem;
    white-space: nowrap;
}

.set-tab-btn.active {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent-primary);
}

.settings-content {
    display: none;
}

.settings-content.active {
    display: block;
}

.setting-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.col-half {
    flex: 1;
}

/* 11. Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: rgba(15, 21, 33, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    padding: 0.875rem 1.25rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    color: #ffffff;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastSlideIn 0.3s var(--ease-spring);
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); }
.toast.error { border-color: rgba(244, 63, 94, 0.4); }

/* Webhook Cards */
.webhook-card {
    background: rgba(12, 17, 29, 0.7);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    padding: 1rem;
}

.webhook-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

.font-mono {
    font-family: var(--font-mono) !important;
    font-size: 0.8125rem !important;
}

.copy-btn {
    position: absolute;
    right: 0.5rem;
    top: 0.35rem;
    height: 2rem;
    min-height: auto;
    font-size: 0.75rem;
    padding: 0 0.75rem;
}

/* 11. Interactive Chart & Weekly Reports */
.chart-container {
    margin-bottom: 2rem;
    padding: 1.5rem;
}

.chart-controls {
    display: flex;
    gap: 0.5rem;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 320px;
    margin-top: 1rem;
}

#marketingChart {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.weekly-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 1.5rem;
}

.weekly-period-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 1.25rem;
    padding: 1.75rem 2rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.weekly-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    gap: 1rem;
    flex-wrap: wrap;
}

.weekly-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(14, 165, 233, 0.12);
    color: var(--accent-primary);
    border: 1px solid rgba(14, 165, 233, 0.25);
    letter-spacing: 0.02em;
}

.weekly-table th:first-child,
.weekly-table td:first-child {
    position: sticky;
    left: 0;
    background: #0d1322;
    z-index: 2;
    font-weight: 700;
}

.weekly-total-row {
    background: rgba(14, 165, 233, 0.08) !important;
    font-weight: 700;
}

.weekly-total-row td {
    color: #fff;
    border-top: 1px solid rgba(14, 165, 233, 0.3);
    border-bottom: 1px solid rgba(14, 165, 233, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}

.btn-outline:hover {
    background: rgba(59, 130, 246, 0.15);
}


/* 12. Utilities & Responsive Constraints */
.hidden { display: none !important; }
.text-center { text-align: center; }
.p-4 { padding: 1.5rem; }

.error-banner {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fecdd3;
    font-size: 0.8125rem;
}

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Mobile Breakpoint: < 768px (Rule: 90-95% width) */
@media (max-width: 768px) {
    .app-layout {
        width: 95%;
        padding: 1rem 0.5rem 3rem;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }

    .header-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-item {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        justify-content: space-between;
        margin-top: 0.5rem;
    }

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

    .node-stats {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.25rem;
    }

    dialog.glass-dialog {
        width: 95%;
    }
}
