/* ===== CSS Variables ===== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --border-color: #2a2a3a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 70px;
    --header-height: 56px;
    --bg-secondary-rgb: 18, 18, 18;

    /* Scrollbar colors */
    --scrollbar-track: #1a1a24;
    --scrollbar-thumb: #3a3a4a;
    --scrollbar-thumb-hover: #5a5a6a;
}

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

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
    border: 2px solid var(--scrollbar-track);
}

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

::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

/* Firefox scrollbar */
@supports (scrollbar-width: thin) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    }
}


/* ===== Neon/Carbon Theme (Dark/High Contrast) ===== */
[data-theme="neon"] {
    --bg-primary: #050505;
    --bg-secondary: #0f0f0f;
    --bg-card: #181818;
    --bg-card-hover: #222222;
    --border-color: #333333;
    --text-primary: #ffffff;
    --text-secondary: #e5e5e5;
    --text-muted: #a3a3a3;
    --accent-primary: #525252;
    --accent-secondary: #737373;
    --accent-gradient: linear-gradient(135deg, #404040 0%, #525252 100%);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.6);
}

/* Restore bright text for KPIs in Carbon theme without affecting buttons */
[data-theme="neon"] .kpi-value {
    background: linear-gradient(135deg, #29dac5 0%, #1877f2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}



/* ===== Utility Classes ===== */
/* Width utilities */
.w-full {
    width: 100%;
}

/* Margin utilities */
.mb-2 {
    margin-bottom: 8px;
}

.mb-4 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-6 {
    margin-bottom: 24px;
}

/* Horizontal rule divider */
.hr-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

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

.mt-6 {
    margin-top: 24px;
}

/* Flex container for metadata header actions */
.metadata-header-actions {
    display: flex;
    gap: 8px;
}

/* Base colors for tables and regular text */
.text-secondary {
    color: var(--text-secondary) !important;
}

.text-success {
    color: var(--success) !important;
    -webkit-text-fill-color: var(--success) !important;
    background: none !important;
}

.text-warning {
    color: var(--warning) !important;
    -webkit-text-fill-color: var(--warning) !important;
    background: none !important;
}

.text-danger {
    color: var(--danger) !important;
    -webkit-text-fill-color: var(--danger) !important;
    background: none !important;
}

/* Gradient colors for KPI widgets only */
.kpi-card .text-success,
.kpi-value.text-success {
    background: linear-gradient(292deg, #7ad301 0%, #aaff63 90%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

.kpi-card .text-warning,
.kpi-value.text-warning {
    background: linear-gradient(360deg, #ffa700 0%, #ffc278 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

.kpi-card .text-danger,
.kpi-value.text-danger {
    background: linear-gradient(360deg, #ff0000 0%, #ff748c 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-icon {
    display: none;
    /* Hide old icon */
}

.logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.login-logo-img {
    height: 80px;
    width: auto;
    margin-bottom: 24px;
    object-fit: contain;
}

/* Brand Typography */
.brand-text {
    display: flex;
    align-items: baseline;
    gap: 0.3em;
}

.brand-roi {
    color: #14284b;
    font-weight: 800;
    font-size: 1.2em;
}

.brand-vision {
    color: #98d249;
    font-weight: 700;
    font-size: 1.2em;
}

/* Dark mode adjustments for brand text readability */
/* Dark mode adjustments for brand text readability */
[data-theme="dark"] .brand-roi,
[data-theme="neon"] .brand-roi,
[data-theme="midnight"] .brand-roi,
[data-theme="toxic"] .brand-roi,
[data-theme="lemon"] .brand-roi {
    color: #ffffff;
}



/* End of Brand Typography */


.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.5;
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* ===== Compact Sidebar Footer ===== */
.sidebar-footer.compact-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.footer-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: space-around;
}

.btn-icon-only {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-icon-only svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.5;
}

/* Optical balance for the specific sync icon which looks larger */
#syncBtn svg {
    width: 18px;
    height: 18px;
}

.btn-icon-only:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.sync-status-compact {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* Settings Popup */
.settings-popup {
    position: absolute;
    bottom: 100%;
    left: 12px;
    right: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
}

.settings-popup h4 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.theme-option {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.theme-option:hover,
.theme-option.active {
    background: var(--accent-gradient);
    border-color: transparent;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left var(--transition);
}

/* ===== Header ===== */
.header {
    height: var(--header-height);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    background: rgba(var(--bg-secondary-rgb), 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-top-row,
.header-bottom-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: auto;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

/* ===== Collapsed Sidebar Logic ===== */
/* Collapsed State (Desktop) */
.app.collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
    transform: none;
}

.app.collapsed .main-content {
    margin-left: var(--sidebar-width-collapsed) !important;
}

/* Adjust header padding in collapsed mode */
.app.collapsed .sidebar-header {
    padding: 20px 0;
    display: flex;
    justify-content: center;
}

.app.collapsed .logo {
    justify-content: center;
    gap: 0;
}

/* Hide text labels */
.app.collapsed .logo>span:not(.logo-icon),
.app.collapsed .nav-text,
.app.collapsed .sync-status-compact,
.app.collapsed .brand-text {
    display: none;
}

/* Center nav items */
.app.collapsed .sidebar-nav {
    padding: 16px 8px;
    align-items: center;
}

.app.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    width: 100%;
    margin-bottom: 4px;
}

/* Footer layout in collapsed mode */
.app.collapsed .sidebar-footer {
    padding: 12px 8px;
}

.app.collapsed .footer-actions {
    flex-direction: column;
    gap: 8px;
}

.app.collapsed .btn-icon-only {
    width: 100%;
    aspect-ratio: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}



/* Mobile styles */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .app.collapsed .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .app.collapsed .nav-text,
    .app.collapsed .logo>span:not(.logo-icon) {
        display: block;
    }

    .app.collapsed .nav-item {
        justify-content: flex-start;
        padding: 14px 16px;
    }

    .app.collapsed #syncBtn {
        width: 100% !important;
        padding: 10px 0 !important;
    }

    .main-content {
        margin-left: 0;
    }

    .header {
        height: auto;
        padding: 8px;
    }

    .header-top-row {
        display: none;
    }

    /* Simple flex row with wrap */
    .header-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 3px;
    }

    /* Burger */
    .sidebar-toggle {
        width: 28px;
        height: 28px;
        flex-shrink: 0;
        font-size: 0.9rem;
    }

    /* Hide label */
    .mode-label {
        display: none !important;
    }

    /* Limits 10-20-30 */
    .radio-group {
        display: flex !important;
        align-items: center;
        background: var(--bg-card);
        padding: 1px;
        border-radius: 4px;
        border: 1px solid var(--border-color);
        height: 28px;
        margin: 0 !important;
        flex-shrink: 0;
    }

    .radio-group label span {
        padding: 4px 6px;
        font-size: 0.65rem;
    }

    /* Quick dates 7д-30д-90д-180д */
    .quick-dates {
        display: flex !important;
        align-items: center;
        gap: 2px;
        margin: 0 !important;
    }

    .btn-quick {
        padding: 4px 6px;
        font-size: 0.65rem;
        height: 28px;
    }

    /* Date range - force new row */
    .date-range {
        flex-basis: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-card);
        padding: 4px 8px;
        border-radius: 6px;
        border: 1px solid var(--border-color);
        gap: 6px;
    }

    .date-range input[type="date"] {
        flex: 1;
        height: 32px;
        font-size: 0.8rem;
        background: transparent !important;
        border: none !important;
        color: var(--text-primary);
        max-width: none;
        padding: 4px;
    }

    .date-range span {
        font-size: 0.8rem;
        color: var(--text-muted);
    }

    .date-range .btn-icon-only {
        width: 28px !important;
        min-width: 28px;
        max-width: 28px;
        height: 28px;
        flex: 0 0 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--success);
        border: none;
        color: white;
        font-size: 0.85rem;
        border-radius: 4px;
    }
}



/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

/* ===== Inputs ===== */
.date-input,
.select-input {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

/* Custom arrow for native selects */
select.select-input {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 38px;
    cursor: pointer;
}

select.select-input::-ms-expand {
    display: none;
}

.date-input:focus,
.select-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* ===== Sections ===== */
.section {
    padding: 24px;
    flex: 1;
}

.section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* ===== KPI Grid ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-value {
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Charts Grid ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.chart-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.chart-card h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

.chart-large {
    grid-column: span 2;
}

.chart-card canvas,
.chart-mini canvas {
    width: 100% !important;
    max-height: 300px;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

.chart-mini {
    height: 240px;
    padding: 20px !important;
}

.chart-mini h3 {
    margin-bottom: 8px !important;
    font-size: 1rem !important;
}

.chart-mini .chart-container {
    height: 160px;
    position: relative;
}

/* ===== Tables ===== */
.table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    white-space: nowrap !important;
    padding: 8px 4px;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table td {
    color: var(--text-primary);
    font-size: 0.8rem;
    vertical-align: top;
    padding: 8px 4px;
    min-height: 60px;
}

/* Allow text wrapping in notes/banner columns */
.data-table td .col-notes,
.data-table td:nth-last-child(1) .truncate,
.data-table td:nth-last-child(2) .truncate {
    white-space: normal;
    max-width: 150px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.pagination button:hover,
.pagination button.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* ===== Settings ===== */
.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.settings-card h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.settings-card p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Collapsible Settings Card */
.collapsible-settings .settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 4px 0;
    -webkit-user-select: none;
    user-select: none;
}

.collapsible-settings .settings-header h3 {
    margin-bottom: 0;
}

.collapsible-settings .collapse-arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.collapsible-settings.collapsed .settings-body {
    display: none;
}

.collapsible-settings .settings-body {
    margin-top: 12px;
}

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

/* Segmented Radio Control */
.radio-group {
    display: flex;
    background: var(--bg-card);
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-right: 12px;
    align-items: center;
    height: 30px;
}

.mode-label {
    padding: 0 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    align-items: center;
}

.mode-label span {
    display: inline-block;
}

.mode-label .short-text {
    display: none;
}

@media (max-width: 480px) {
    .mode-label .full-text {
        display: none;
    }

    .mode-label .short-text {
        display: inline-block;
    }
}

.radio-group label {
    position: relative;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.radio-group label span {
    display: block;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    transition: var(--transition);
}

.radio-group input[type="radio"]:checked+span {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.radio-group label:hover span {
    color: var(--text-primary);
}

/* Quick Date Buttons */
.quick-dates {
    display: flex;
    gap: 4px;
    margin-right: 12px;
}

.btn-quick {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
}

.btn-quick:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-quick.active {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
}

/* Date Range Container */
.date-range {
    display: flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.3s ease;
}

.date-range input[type="date"] {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 4px 4px 8px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1;
    height: 30px;
    width: auto;
    max-width: 105px;
    cursor: pointer;
}

.date-range input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.date-range input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
    opacity: 0.8;
}

.date-range input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.date-range span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.date-range .btn-icon-only {
    height: 30px;
    width: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.date-range .btn-icon-only:hover {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
}

.toast.info {
    border-left: 4px solid var(--info);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ===== Loading ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Skeleton ===== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1em;
    width: 100%;
    margin-bottom: 0.5em;
}

.skeleton-h1 {
    height: 2rem;
    width: 50%;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--radius-lg);
}

/* Sortable Headers */
.sortable {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    padding-right: 24px !important;
}

.sortable:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.sortable::after {
    content: '↕';
    position: absolute;
    right: 8px;
    opacity: 0.3;
}

.sortable.text-center {
    padding-left: 24px !important;
}

.sortable.asc::after {
    content: '↑';
    opacity: 1;
    color: var(--accent-primary);
}

.sortable.desc::after {
    content: '↓';
    opacity: 1;
    color: var(--accent-primary);
}


/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .chart-large {
        grid-column: span 1;
    }

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



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

    .section {
        padding: 16px;
    }
}

/* Responsive Table & Utilities */
.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

.col-truncate {
    max-width: 120px;
    /* Increased slightly for better readability */
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;

    border-radius: var(--radius-md);
}

.data-table {
    width: 100%;
    table-layout: auto;
    /* Allow browser to squeeze columns */
}

.data-table th,
.data-table td {
    padding: 8px 4px;
    /* Very tight padding */
    font-size: 0.75rem;
    /* Compact font */
    white-space: nowrap;
}

.data-table th {
    white-space: normal;
    /* Allow headers to wrap */
    word-break: break-word;
    /* Break long words in headers */
    vertical-align: bottom;
    font-size: 0.7rem;
    /* Even smaller headers */
    line-height: 1.1;
}

/* Ensure sticky header stays on top */
.data-table th {
    z-index: 10;
}

@media (max-width: 1400px) {
    .col-truncate {
        max-width: 100px;
    }
}

@media (max-width: 768px) {

    .data-table th,
    .data-table td {
        padding: 6px 2px;
        font-size: 0.7rem;
    }

    .col-truncate {
        max-width: 70px;
    }

    .sortable {
        padding-right: 10px !important;
    }
}

/* Utilities */
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    /* Important for truncate to work */
}

.text-success {
    color: var(--success) !important;
    -webkit-text-fill-color: var(--success) !important;
    background: none !important;
}

.text-danger {
    color: var(--danger) !important;
    -webkit-text-fill-color: var(--danger) !important;
    background: none !important;
}

.text-warning {
    color: var(--warning) !important;
    -webkit-text-fill-color: var(--warning) !important;
    background: none !important;
}

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

.mini-kpi {
    margin-bottom: 16px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.mini-kpi .kpi-card {
    padding: 12px;
}

.mini-kpi .kpi-label {
    font-size: 0.75rem;
}

.mini-kpi .kpi-value {
    font-size: 1.25rem;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
}

.theme-btn {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.theme-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.theme-btn.active {
    background: var(--accent-gradient);
    border-color: var(--accent-primary);
    color: white;
}

/* Fix for html2canvas screenshot (gradient text support) */
.taking-screenshot .kpi-value {
    background: none !important;
    -webkit-text-fill-color: initial !important;
    -webkit-background-clip: border-box !important;
    background-clip: border-box !important;
    color: var(--accent-primary) !important;
    /* Fallback color */
}

/* Ensure colored text also reverts to solid colors during screenshot */
.taking-screenshot .text-success {
    background: none !important;
    -webkit-text-fill-color: initial !important;
    color: var(--success) !important;
}

.taking-screenshot .text-warning {
    background: none !important;
    -webkit-text-fill-color: initial !important;
    color: var(--warning) !important;
}

.taking-screenshot .text-danger {
    background: none !important;
    -webkit-text-fill-color: initial !important;
    color: var(--danger) !important;
}

/* Screenshot specific styles */
.taking-screenshot .sidebar,
.taking-screenshot .sidebar-toggle,
.taking-screenshot .toast-container,
.taking-screenshot #toastContainer,
.taking-screenshot .loading-overlay {
    display: none !important;
}

.taking-screenshot .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 100% !important;
    transform: none !important;
}

/* Threshold Settings */
.threshold-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 16px;
}

.threshold-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.threshold-group .select-input,
.threshold-card .select-input {
    width: 100%;
    text-align: center;
    padding: 6px;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.thresholds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.threshold-card {
    background: var(--bg-card-hover);
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.threshold-card h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 2px;
}

.threshold-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.threshold-row .label-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.threshold-row .input-wrapper {
    position: relative;
}

.threshold-row .input-wrapper span {
    position: absolute;
    bottom: -14px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.threshold-card .select-input {
    width: 100%;
    text-align: center;
    padding: 4px;
    font-size: 0.8rem;
    box-sizing: border-box;
    height: 28px;
}

.gap-setting {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.gap-setting+.gap-setting {
    margin-top: 4px;
    padding-top: 0;
    border-top: none;
}

/* Collapsible Table Header */
.table-header-collapsible {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    /* Ensure bg color */
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: var(--transition);
}

.table-header-collapsible:hover {
    background: var(--bg-card-hover);
}

.table-header-collapsible .arrow {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.table-header-collapsible .arrow.rotated {
    transform: rotate(-90deg);
}

/* Fix text overlap in conversion table */
.conversion-table th.col-wide {
    width: 15%;
    max-width: 120px;
}

.conversion-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    /* Default max-width for data cells */
    vertical-align: middle;
}

.conversion-table td.col-truncate {
    max-width: 140px;
    /* Reduced to save space while keeping names readable */
}

/* ===== Draggable Widget List ===== */
.draggable-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.draggable-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: var(--transition);
    -webkit-user-select: none;
    user-select: none;
}

.draggable-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
}

.draggable-item.dragging {
    opacity: 0.5;
    background: var(--bg-card);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.draggable-item .handle {
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: grab;
}

.draggable-item .widget-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.draggable-item .widget-visible {
    cursor: pointer;
}

/* Extended Widget Settings */
.draggable-item-extended {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: var(--transition);
}

.draggable-item-extended:hover {
    border-color: var(--accent-primary);
}

.draggable-item-extended.widget-hidden {
    opacity: 0.6;
}

.visibility-indicator {
    font-size: 0.9rem;
    margin-right: 4px;
}

.draggable-item-extended .widget-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.draggable-item-extended .handle {
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: grab;
}

.draggable-item-extended .widget-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.draggable-item-extended .widget-toggle-icon {
    color: var(--text-muted);
    font-size: 0.7rem;
    transition: var(--transition);
}

.widget-settings {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.widget-settings.collapsed {
    display: none !important;
}

.widget-setting-row {
    margin-top: 10px;
}

.widget-setting-row label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.widget-setting-row input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.widget-setting-row input[type="text"]:focus {
    border-color: var(--accent-primary);
    outline: none;
}

.widget-setting-row .checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
}

.widget-setting-row .checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

/* ===== Modal Styles ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    position: relative;
}


.modal-content-wide {
    max-width: 600px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-header .btn-icon-only {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    position: absolute;
    top: 12px;
    right: 12px;
}

.modal-header .btn-icon-only:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Link field delete button */
.link-field .btn-icon-only {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-field .btn-icon-only:hover {
    color: var(--danger);
}

/* ===== Form Styles ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.text-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: var(--transition);
}

.text-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* User actions in table */
.user-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit {
    background: var(--info);
    color: white;
    border: none;
}

.btn-edit:hover {
    opacity: 0.85;
}

.btn-delete {
    background: var(--danger);
    color: white;
    border: none;
}

.btn-delete:hover {
    opacity: 0.85;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-admin {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
}

.badge-user {
    background: rgba(160, 160, 176, 0.2);
    color: var(--text-secondary);
}

/* ===== Public Metadata Styles ===== */
.public-name-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.public-name-cell:hover {
    color: var(--accent-primary);
}

.meta-icons {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Link fields in modal */
.link-field {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.link-field .text-input {
    flex: 1;
}

.link-field .link-url {
    flex: 2;
}

/* Textarea styling */
textarea.text-input {
    min-height: 80px;
    resize: vertical;
}

/* Metadata links in tables */
.meta-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
}

.meta-link:hover {
    text-decoration: underline;
}

.col-truncate-links {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Public Metadata Block */
.metadata-block {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.metadata-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.metadata-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    word-break: break-word;
    flex: 1;
    max-width: 60%;
}

.metadata-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.metadata-notes,
.metadata-links {
    padding: 12px;
    background: var(--background-color);
    border-radius: 6px;
}

.metadata-notes strong,
.metadata-links strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.metadata-notes p {
    margin: 0;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.metadata-links a {
    display: inline-block;
    margin-right: 12px;
    margin-bottom: 4px;
    color: var(--primary-color);
    text-decoration: none;
}

.metadata-links a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .metadata-content {
        grid-template-columns: 1fr;
    }
}

/* Purchases page styles */
.purchases-block {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.purchases-header {
    padding: 12px 16px;
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.purchases-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.purchases-summary {
    margin-bottom: 24px;
}

.text-muted {
    color: var(--text-secondary);
    font-style: italic;
}

/* Count badge */
.count-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.purchases-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Upcoming table styling */
.upcoming-table tbody tr {
    background: rgba(var(--warning-rgb, 255, 193, 7), 0.1);
}

.upcoming-table tbody tr:hover {
    background: rgba(var(--warning-rgb, 255, 193, 7), 0.15);
}

/* Collapsible block styles */
.collapsible-block .collapsible-header {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.2s ease;
}

.collapsible-block .collapsible-header:hover {
    background: var(--hover-color);
}

.collapsible-block .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapsible-block .header-left h3 {
    margin: 0;
}

.collapsible-block .collapse-icon {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

.collapsible-block.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.collapsible-block .collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 500px;
    opacity: 1;
}

.collapsible-block.collapsed .collapsible-content {
    max-height: 0;
    opacity: 0;
}

/* ===== Enhanced Dashboard Styles ===== */

/* KPI Card with Trends */
.kpi-card .kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.kpi-card .kpi-trend {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.kpi-trend.trend-up {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.kpi-trend.trend-down {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.kpi-trend.trend-neutral {
    background: rgba(160, 160, 176, 0.15);
    color: var(--text-secondary);
}

.kpi-card .kpi-prev {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* Dashboard Panels (Alerts & Insights) */
.dashboard-panels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

.panel-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
}

.panel-card h3 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Alerts Panel */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.4;
}

.alert-item.loading {
    color: var(--text-muted);
    justify-content: center;
}

.alert-item.empty {
    color: var(--text-muted);
    justify-content: center;
    font-style: italic;
}

.alert-item.danger {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--danger);
}

.alert-item.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--warning);
}

.alert-item.success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--success);
}

.alert-item .alert-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.alert-item .alert-content {
    flex: 1;
}

.alert-item .alert-message {
    color: var(--text-primary);
    font-weight: 500;
}

.alert-item .alert-details {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 2px;
}

/* Insights Panel */
.insights-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
    transition: var(--transition);
}

.insight-item:hover {
    background: var(--bg-card-hover);
}

.insight-item.loading,
.insight-item.empty {
    color: var(--text-muted);
    justify-content: center;
}

.insight-item.empty {
    font-style: italic;
}

.insight-item .insight-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.insight-item .insight-content {
    flex: 1;
}

.insight-item .insight-title {
    color: var(--text-primary);
    font-weight: 500;
}

.insight-item .insight-description {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 2px;
}

.insight-item.scale {
    border-left: 3px solid var(--success);
}

.insight-item.disable {
    border-left: 3px solid var(--warning);
}

/* Period Info */
.period-info {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 16px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.period-info:empty {
    display: none;
}

/* Panel Header */
.panel-card .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-card .panel-header h3 {
    margin: 0;
}

.panel-card .panel-period {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Insight Categories */
.insight-item .insight-category {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

/* Insight Types */
.insight-item.trend-up {
    border-left: 3px solid var(--success);
}

.insight-item.trend-down {
    border-left: 3px solid var(--warning);
}

.insight-item.combo {
    border-left: 3px solid var(--info);
}

.insight-item.budget {
    border-left: 3px solid #a855f7;
}

.insight-item.testing {
    border-left: 3px solid var(--text-muted);
}

/* Larger insights panel */
.insights-panel .insights-list {
    max-height: 300px;
}

/* Full-width chart */
.chart-fullwidth {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.chart-fullwidth canvas {
    height: 350px !important;
}

.chart-fullwidth .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.chart-fullwidth .chart-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-fullwidth .chart-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-metric-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.chart-metric-select:hover {
    border-color: var(--accent-primary);
}

.chart-metric-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn-icon-small {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.btn-icon-small:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.chart-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 8px;
}

/* 3-column charts grid */
.charts-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1200px) {
    .charts-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .charts-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Period Toggle */
.chart-period-toggle {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.period-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

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

.period-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* Combined Panel (Alerts + Insights) */
.combined-panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.combined-columns {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    min-height: 200px;
}

.combined-column {
    padding: 1.25rem;
}

.combined-divider {
    width: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.combined-column .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.combined-column .panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.combined-column .panel-period {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.alerts-column .alerts-list,
.insights-column .insights-list {
    max-height: 250px;
    overflow-y: auto;
}

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

    .combined-divider {
        width: 100%;
        height: 1px;
        margin: 0 1rem;
    }
}

/* Unified Feed Panel */
.feed-panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

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

.feed-panel .panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.feed-panel .panel-period {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.unified-feed {
    padding: 0.75rem;
    max-height: 450px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.feed-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-color);
    transition: var(--transition);
}

.feed-item:hover {
    background: var(--bg-card-hover);
}

.feed-item.empty {
    justify-content: center;
    color: var(--text-muted);
    border-left-color: transparent;
}

.feed-item.alert {
    border-left-color: var(--danger);
}

.feed-item.alert.warning {
    border-left-color: var(--warning);
}

.feed-item.insight {
    border-left-color: var(--info);
}

.feed-item.insight.scaling,
.feed-item.insight.budget {
    border-left-color: var(--success);
}

.feed-item.insight.trend {
    border-left-color: var(--accent-primary);
}

.feed-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.feed-content {
    flex: 1;
    min-width: 0;
}

.feed-category {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.feed-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.feed-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ===== Additional Utility Classes ===== */
.mb-1 {
    margin-bottom: 4px;
}

/* ===== Public Search Input ===== */
#publicSearchInput {
    width: 300px;
    height: 42px;
}

/* ===== Scrollable Table Wrapper ===== */
.table-wrapper-scrollable {
    max-height: 400px;
    overflow-y: auto;
}

/* ===== Collapse Icon ===== */
.collapse-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}



.collapse-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: #a1a1aa;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ===== Table Header Collapsible Arrow ===== */
.table-header-collapsible .arrow {
    transition: transform 0.3s;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-header-collapsible .arrow svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: #a1a1aa;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.table-header-collapsible .arrow.rotated {
    transform: rotate(180deg);
}

.table-header-collapsible h3 {
    margin: 0;
    font-size: 1rem;
}

/* ===== Filter Elements ===== */
#filterPublic {
    display: none;
}

#landingToggle {
    width: 300px;
    height: 42px;
}

#landingToggle .col-truncate {
    max-width: 260px;
}

#limitModeDate {
    display: none;
}

.settings-card p {
    margin-bottom: 12px;
}

.settings-body p {
    color: var(--text-secondary);
}

/* ===== Alias Form ===== */
.alias-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}

.alias-form .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.alias-form label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.alias-form .select-input {
    width: 100%;
}

.alias-form .alias-arrow {
    display: inline-block;
    font-size: 1.5rem;
    color: var(--text-muted);
    padding-bottom: 8px;
}

.alias-form .btn {
    height: 38px;
}

#aliasesList {
    margin-top: 16px;
}

#aliasesList h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#aliasesListContent p {
    color: var(--text-muted);
}

.password-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}
/* Date Click Feature */
.clickable-date {
    cursor: pointer;
    color: var(--accent-primary);
    font-weight: 500;
    transition: var(--transition);
    display: inline-block;
}

.clickable-date:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.modal-header-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Placement Badge Styles */
.clickable-date {
    color: var(--text-primary) !important;
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.placement-badge {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.clickable-date:hover .placement-badge {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* Modal Summary Bar */
.modal-summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-item .value {
    font-size: 1.1rem;
    font-weight: 700;
}

/* UI Fine-tuning for Date Badge */
.clickable-date {
    font-weight: 400 !important;
    gap: 6px !important;
}

.placement-badge {
    font-weight: 400 !important;
    background: rgba(255, 255, 255, 0.1);
}

.placement-badge.single {
    background: rgba(16, 185, 129, 0.2); /* var(--success) with opacity */
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.clickable-date:hover .placement-badge.single {
    background: var(--success);
    color: white;
}
.public-name-cell {
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    white-space: nowrap;
}

/* Mobile Layout Fixes */
@media (max-width: 480px) {
    /* 3 widgets per row */
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px !important;
    }
    
    .kpi-card {
        padding: 8px !important;
        min-height: 70px;
    }
    
    .kpi-label {
        font-size: 0.65rem !important;
        line-height: 1.1;
    }
    
    .kpi-value {
        font-size: 0.95rem !important;
    }
    
    .kpi-prev, .kpi-trend {
        font-size: 0.6rem !important;
    }

    /* Table filters alignment */
    .filters {
        gap: 8px !important;
    }
    
    .filter-row {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        gap: 8px !important;
    }
    
    .searchable-select {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .btn-group {
        display: flex !important;
        gap: 4px !important;
        flex-shrink: 0 !important;
    }
    
    .btn-nav {
        padding: 4px 8px !important;
        font-size: 0.8rem !important;
        height: 38px !important;
    }
}

/* Table specific alignment fixes */
#tableSection .filters {
    flex-direction: column;
    align-items: stretch;
}

#tableSection .filter-row {
    display: flex;
    gap: 12px;
}

/* Fix for public name fonts appearing different */
.public-name-cell strong, 
.public-name-cell div {
    font-size: inherit !important;
    font-weight: inherit !important;
}
