:root {
    --bg-dark: #0f1115;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-primary: #6366f1;
    --accent-secondary: #ec4899;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.06);
    --success: #10b981;
    --warning: #f59e0b;
    --gradient-1: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Gradients */
.bg-gradient {
    position: fixed;
    top: -20%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(15, 17, 21, 0) 70%);
    z-index: -1;
    filter: blur(60px);
    animation: float 15s ease-in-out infinite alternate;
}

.bg-gradient-secondary {
    position: fixed;
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.1) 0%, rgba(15, 17, 21, 0) 70%);
    z-index: -1;
    filter: blur(80px);
    animation: float 20s ease-in-out infinite alternate-reverse;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(5%, 5%);
    }
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.app-header {
    text-align: center;
    margin-top: 1rem;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.app-header h1 span {
    background: var(--gradient-1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Dashboard Layout */
.dashboard {
    width: 100%;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    width: 100%;
}

@media (min-width: 992px) {
    .calc-grid {
        grid-template-columns: 350px 1fr;
    }
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

/* Tabs */
.tab-container {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 0.4rem;
    margin-bottom: 2rem;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.8rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.tab-btn.active {
    background: var(--glass-hover);
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1.2rem;
    animation: fadeIn 0.3s ease;
}

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

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
    cursor: help;
}

.input-highlight label {
    color: var(--accent-primary);
    font-weight: 500;
}

.input-group input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
}

.input-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.primary-btn {
    margin-top: 1.5rem;
    width: 100%;
    background: var(--gradient-1);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Results Content toggling */
.result-content {
    display: none;
    flex-direction: column;
    gap: 2.5rem;
}

.result-content.active-result {
    display: flex;
    animation: fadeIn 0.4s ease;
}

.kpi-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

/* Results Section */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    background: var(--glass-hover);
    transform: translateY(-5px);
}

.highlight-card {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.05);
}

.highlight-card .kpi-info h3 {
    color: var(--accent-primary);
}

.kpi-icon {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.05);
}

.roas-icon {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.cpa-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.cpm-icon {
    background: rgba(236, 72, 153, 0.15);
    color: #ec4899;
}

.ctr-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.cvr-icon {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

.cpc-icon {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.kpi-info h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    transition: color 0.3s ease, transform 0.2s;
}

.kpi-value.active-anim {
    color: var(--success);
    transform: scale(1.05);
}

.kpi-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kpi-card {
    animation: fadeInUp 0.5s ease-out backwards;
}

.kpi-card:nth-child(1) {
    animation-delay: 0.0s;
}

.kpi-card:nth-child(2) {
    animation-delay: 0.1s;
}

.kpi-card:nth-child(3) {
    animation-delay: 0.2s;
}

.kpi-card:nth-child(4) {
    animation-delay: 0.3s;
}

.kpi-card:nth-child(5) {
    animation-delay: 0.4s;
}

.kpi-card:nth-child(6) {
    animation-delay: 0.5s;
}

/* Action Buttons Grid */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-buttons button {
    margin-top: 0;
}

.secondary-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.secondary-btn:active {
    transform: translateY(0);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    width: 90%;
    max-width: 450px;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* Saved List Modal */
.list-modal {
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--accent-secondary);
}

.saved-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem;
}

.saved-item {
    padding: 1rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
}

.saved-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.saved-item-header h4 {
    font-size: 1.1rem;
    color: var(--accent-primary);
}

.saved-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-weight: 600;
}

.saved-badge.product {
    color: #10b981;
    background: rgba(16, 185, 129, 0.15);
}

.saved-badge.service {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.15);
}

.saved-item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.saved-item-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.sm-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 8px;
    width: auto;
    margin-top: 0;
}

/* Saved KPI Button */
.saved-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.6rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.saved-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Daily Campaign Tracker Styles --- */

.tracker-section {
    width: 100%;
    margin-top: 2rem;
    padding: 1.5rem;
    overflow: visible;
}

.tracker-header h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tracker-table-container {
    width: 100%;
    overflow-x: auto;
    /* Allow horizontal scroll for table */
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    margin-top: 1rem;
    padding-bottom: 0.5rem;
}

.tracker-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
    /* Force minimum width to enable scrolling */
    font-size: 0.9rem;
    text-align: right;
}

.tracker-table th,
.tracker-table td {
    padding: 0.8rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.02);
}

.tracker-table th {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    font-size: 0.8rem;
    white-space: nowrap;
}

.tracker-table td {
    color: var(--text-secondary);
}

/* Input Columns vs Calculated Columns */
.tracker-table th.input-col {
    background: rgba(59, 130, 246, 0.2);
    /* Blue tint */
    color: #93c5fd;
}

.tracker-table th.calc-col {
    background: rgba(0, 0, 0, 0.4);
    /* Dark tint */
}

.tracker-table td.input-col {
    background: rgba(59, 130, 246, 0.05);
    color: #bfdbfe;
}

.tracker-table td.calc-col {
    background: rgba(0, 0, 0, 0.2);
}

/* Column Overrides */
.tracker-table th.date-col,
.tracker-table td.date-col {
    text-align: left;
    padding-left: 1rem;
    min-width: 100px;
    color: var(--text-primary);
}

.tracker-table th.status-col,
.tracker-table td.status-col {
    text-align: center;
    white-space: nowrap;
}

.tracker-table th.comments-col,
.tracker-table td.comments-col {
    text-align: left;
    min-width: 200px;
}

/* Table Inputs */
.tracker-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #bfdbfe;
    text-align: right;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    border-bottom: 1px dashed transparent;
    padding: 2px 0;
}

.tracker-input:focus {
    border-bottom-color: var(--accent-primary);
}

.date-col .tracker-input,
.comments-col .tracker-input {
    text-align: left;
    color: var(--text-primary);
}

/* Aggregation Rows */
.month-header-row {
    background: rgba(255, 255, 255, 0.08);
}

.month-header-row td {
    text-align: left;
    font-weight: bold;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding: 1rem;
}

.week-total-row {
    background: rgba(99, 102, 241, 0.15);
    font-weight: 600;
}

.week-total-row td {
    color: var(--text-primary);
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.month-total-row {
    background: rgba(16, 185, 129, 0.15);
    font-weight: 600;
}

.month-total-row td {
    color: var(--text-primary);
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

/* Status Indicator */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.3);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.great {
    background: #10b981;
    box-shadow: 0 0 5px #10b981;
}

.dot.track {
    background: #3b82f6;
    box-shadow: 0 0 5px #3b82f6;
}

.dot.proj {
    background: #9ca3af;
}

.dot.bad {
    background: #ef4444;
    box-shadow: 0 0 5px #ef4444;
}

/* Top-Level Tabs */
.app-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

.top-tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 1.1rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.top-tab-btn:hover {
    color: var(--text-primary);
}

.top-tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.top-tab-content {
    display: none;
}

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

#calc-tab.active-top-tab {
    display: grid;
}

/* Month Tabs */
.month-tab-btn {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.month-tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.month-tab-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: #bfdbfe;
    border-color: rgba(59, 130, 246, 0.5);
}

.action-icon-btn {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.action-icon-btn:hover {
    opacity: 1;
}