/* ============================================
   SILUM - Premium Email Outreach Platform
   Design Philosophy: Minimal, Elegant, Natural
   ============================================ */

/* Visuelt Pro (prefers local installation, falls back to bundled files if provided) */
@font-face {
    font-family: 'Visuelt Pro';
    src: local('Visuelt Pro'),
         local('VisueltPro-Regular'),
         local('Visuelt Pro Regular'),
         url('/static/fonts/VisueltPro-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Visuelt Pro';
    src: local('Visuelt Pro'),
         local('VisueltPro-Medium'),
         local('Visuelt Pro Medium'),
         url('/static/fonts/VisueltPro-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Visuelt Pro';
    src: local('Visuelt Pro'),
         local('VisueltPro-Bold'),
         local('Visuelt Pro Bold'),
         url('/static/fonts/VisueltPro-Bold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Brand Base - monochrome */
    --silum-green: #1f2937;
    --silum-green-light: #4b5563;
    --silum-green-dark: #0f172a;
    --silum-sage: #d6dbe2;
    --silum-mint: #eef2f6;

    /* Semantic Colors */
    --success: #2e8b60;
    --danger: #c75b63;
    --warning: #c39a42;
    --info: #5f7fc5;
    --violet: #8c73c4;
    --icon-blue-bg: #e6eefc;
    --icon-blue-fg: #4e6fba;
    --icon-green-bg: #e5f4ec;
    --icon-green-fg: #2f8c61;
    --icon-red-bg: #f9e9eb;
    --icon-red-fg: #b95661;
    --icon-violet-bg: #eee8fb;
    --icon-violet-fg: #7f68ba;
    --icon-yellow-bg: #f8f0dc;
    --icon-yellow-fg: #b28730;

    /* Light Theme */
    --bg-primary: #f2f3f5;
    --bg-secondary: #eceef1;
    --bg-tertiary: #dde2e8;
    --surface: #f8f9fb;
    --surface-elevated: #ffffff;

    --text-primary: #1a1f27;
    --text-secondary: #5d6676;
    --text-tertiary: #8891a1;

    --border-light: #d9dfe8;
    --border-medium: #bec7d2;

    --variables-standard: #0f172a;
    --variables-custom: #2e8b60;

    --shadow-sm: 0 1px 2px rgba(12, 20, 32, 0.06);
    --shadow-md: 0 6px 20px rgba(12, 20, 32, 0.1);
    --shadow-lg: 0 16px 42px rgba(12, 20, 32, 0.14);

    /* Glass Effect */
    --glass-bg: rgba(248, 250, 252, 0.82);
    --glass-border: rgba(255, 255, 255, 0.38);

    /* Illustrations & Ornaments (monochrome) */
    --ornament-glow: rgba(114, 126, 145, 0.26);
    --ornament-line: rgba(106, 118, 136, 0.42);
    --ornament-fill: rgba(114, 126, 145, 0.2);
    --ornament-fade: 0.9;
    --ornament-linework-opacity: 0.92;

    /* Links */
    --link-fg: var(--icon-blue-fg);
    /* Keep hover in the same "link family" (avoid turning nearly-black). */
    --link-hover-fg: color-mix(in srgb, var(--icon-blue-fg) 78%, var(--silum-green-dark) 22%);

    /* Spacing */
    --sidebar-width: 240px;
    --sidebar-width-collapsed: 92px;
    --header-height: 64px;
    --layout-gutter: 20px;

    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #1b1b1b;
    --bg-secondary: #202020;
    --bg-tertiary: #2a2a2a;
    --surface: #232323;
    --surface-elevated: #2b2b2b;

    --text-primary: #e8ebf0;
    --text-secondary: #b2b9c5;
    --text-tertiary: #8a93a2;

    --border-light: #3b3b3b;
    --border-medium: #4a4a4a;

    --variables-standard: #e4e8ef;
    --variables-custom: #7cc8a4;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.34);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.56);

    --glass-bg: rgba(32, 32, 32, 0.78);
    --glass-border: rgba(255, 255, 255, 0.1);

    --silum-mint: #2b2b2b;

    --ornament-glow: rgba(205, 205, 205, 0.08);
    --ornament-line: rgba(188, 188, 188, 0.18);
    --ornament-fill: rgba(170, 170, 170, 0.12);

    /* Links (dark theme should be clearly readable) */
    --link-fg: #cdd9ff;
    --link-hover-fg: #ffffff;
    --ornament-linework-opacity: 0.68;
    --icon-blue-bg: #243347;
    --icon-blue-fg: #88a8e9;
    --icon-green-bg: #1f3b31;
    --icon-green-fg: #85cba8;
    --icon-red-bg: #3f2830;
    --icon-red-fg: #e19aa4;
    --icon-violet-bg: #312844;
    --icon-violet-fg: #b8a2ee;
    --icon-yellow-bg: #413824;
    --icon-yellow-fg: #e6ca80;
}

/* Typography */
body {
    font-family: 'Visuelt Pro', 'Avenir Next', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.55;
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Global links */
a {
    color: var(--link-fg);
    text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}

a:hover {
    color: var(--link-hover-fg);
    text-decoration: none;
}

a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent);
    border-radius: 6px;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    overflow-x: clip;
    background:
        radial-gradient(1200px 640px at 100% -10%, rgba(116, 130, 152, 0.12), transparent 56%),
        radial-gradient(980px 560px at -10% 100%, rgba(138, 149, 167, 0.1), transparent 60%),
        var(--bg-secondary);
    /* Keep background gradients anchored to the viewport (do not scroll with content). */
    background-attachment: fixed;
}

[data-theme="dark"] .app-layout {
    background:
        radial-gradient(1200px 640px at 100% -10%, rgba(255, 255, 255, 0.04), transparent 56%),
        radial-gradient(980px 560px at -10% 100%, rgba(255, 255, 255, 0.03), transparent 60%),
        var(--bg-secondary);
    background-attachment: fixed;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: var(--layout-gutter);
    top: var(--layout-gutter);
    bottom: var(--layout-gutter);
    width: var(--sidebar-width);
    /* Subtle glass to match header */
    background: color-mix(in srgb, var(--glass-bg) 86%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-light) 80%, transparent);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s ease;
    backdrop-filter: blur(14px) saturate(1.15);
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.sidebar-header {
    /* Align with nav-item padding (0.75rem) for a clean vertical grid */
    padding: 1.25rem 0.75rem 1.1rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.55), transparent);
}

[data-theme="dark"] .sidebar-header {
    background: linear-gradient(180deg, rgba(255,255,255,0.06), transparent);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: opacity 0.2s ease;
    will-change: opacity;
    transform: translateZ(0);
    flex: 1;
    min-width: 0;
}

.logo-container:hover {
    opacity: 0.7;
}

.logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    position: relative;
    overflow: visible;
    padding: 0;
    box-sizing: content-box;
}

.logo-icon img {
    /* reveal the glass/sheeen background behind the mark */
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.logo-img.logo-dark {
    display: none;
}

[data-theme="dark"] .logo-img.logo-light {
    display: none;
}

[data-theme="dark"] .logo-img.logo-dark {
    display: block;
}

.logo-text {
    font-size: 18px;
    line-height: 1;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.sidebar-collapse-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sidebar-collapse-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-collapse-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-collapse-icon {
    width: 16px;
    height: 16px;
}

.sidebar-collapse-icon.is-expand {
    display: none;
}

.main-content,
.page-ornaments {
    transition: margin-left 0.25s ease, left 0.25s ease;
}

html.sidebar-init-pending .sidebar,
html.sidebar-init-pending .main-content,
html.sidebar-init-pending .page-ornaments {
    transition: none !important;
}

@media (min-width: 769px) {
    :is(html, body).sidebar-collapsed .sidebar {
        width: var(--sidebar-width-collapsed);
    }

    :is(html, body).sidebar-collapsed .main-content {
        margin-left: calc(var(--sidebar-width-collapsed) + (2 * var(--layout-gutter)));
    }

    :is(html, body).sidebar-collapsed .page-ornaments {
        left: calc(var(--sidebar-width-collapsed) + (2 * var(--layout-gutter)));
    }

    :is(html, body).sidebar-collapsed .logo-text,
    :is(html, body).sidebar-collapsed .nav-section-title,
    :is(html, body).sidebar-collapsed .user-info,
    :is(html, body).sidebar-collapsed .nav-item span:not(.nav-badge) {
        display: none;
    }

    :is(html, body).sidebar-collapsed .logo-container {
        justify-content: center;
        width: 100%;
        flex: 0 0 auto;
    }

    :is(html, body).sidebar-collapsed .sidebar-header {
        display: grid;
        grid-template-columns: 1fr;
        justify-items: center;
        align-items: center;
        gap: 0.45rem;
        padding: 1rem 0.5rem 0.85rem;
    }

    :is(html, body).sidebar-collapsed .sidebar-collapse-btn {
        width: 24px;
        height: 24px;
        border-radius: 999px;
        background: var(--surface-elevated);
        border-color: color-mix(in srgb, var(--border-light) 75%, transparent);
    }

    :is(html, body).sidebar-collapsed .sidebar-collapse-icon.is-collapse {
        display: none;
    }

    :is(html, body).sidebar-collapsed .sidebar-collapse-icon.is-expand {
        display: block;
    }

    :is(html, body).sidebar-collapsed .nav-item {
        justify-content: center;
        padding: 0.625rem;
        position: relative;
    }

    :is(html, body).sidebar-collapsed .nav-badge {
        position: absolute;
        top: 4px;
        right: 4px;
        margin-left: 0;
    }

    :is(html, body).sidebar-collapsed .sidebar-footer {
        padding: 0.75rem 0.5rem;
    }

    :is(html, body).sidebar-collapsed .user-profile {
        justify-content: center;
        padding: 0.5rem;
    }
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.nav-badge {
    margin-left: auto;
    min-width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    /* Unread count badge: light theme uses white text, dark theme uses dark text. */
    background: var(--icon-green-fg);
    color: #fff;
    padding: 0;
    line-height: 1;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .nav-badge {
    color: rgba(10, 12, 16, 0.92);
}

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

.nav-item.active {
    background: var(--silum-mint);
    color: var(--text-primary);
    font-weight: 600;
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-light);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    transition: background 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
}

.user-profile:hover {
    background: var(--bg-tertiary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--silum-sage);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content */
.main-content {
    flex: 1;
    /* Sidebar is offset from the left by gutter, so add that to keep a true 20px gap */
    margin-left: calc(var(--sidebar-width) + (2 * var(--layout-gutter)));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content-header {
    /* Card-style header with subtle glass */
    background: color-mix(in srgb, var(--glass-bg) 86%, transparent);
    border: 1px solid color-mix(in srgb, var(--border-light) 80%, transparent);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    padding: 1rem 1.5rem;
    margin: var(--layout-gutter) var(--layout-gutter) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-height);
    position: sticky;
    top: var(--layout-gutter);
    z-index: 50;
    backdrop-filter: blur(14px) saturate(1.15);
    -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.header-messages {
    position: sticky;
    top: calc(var(--layout-gutter) + var(--header-height) + 12px);
    z-index: 49; /* just under the header (z=50) */
    margin: 12px var(--layout-gutter) 0 0;
    pointer-events: none; /* clicks go through unless the alert needs interaction */
}

.header-messages .alert {
    pointer-events: auto;
    margin-bottom: 0.75rem;
}

.page-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.title-icon-button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.title-icon-button:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.variables-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 0.5rem 0;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 320px;
    overflow-y: auto;
    min-width: 240px;
    max-width: min(360px, calc(100vw - 20px));
}

.variables-section-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.variables-section-divider {
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-light);
}

.variables-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.variables-item:hover {
    background: var(--bg-tertiary);
}

.variables-token {
    display: inline-block;
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.variables-token.standard {
    color: var(--variables-standard);
}

.variables-token.custom {
    color: var(--variables-custom);
}

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

.variables-meta {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.variables-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

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

.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    line-height: 0;
    padding: 0;
}

.theme-toggle:hover {
    background: transparent;
    color: var(--text-primary);
}

.bug-report-btn {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
    border-color: color-mix(in srgb, var(--icon-red-fg) 38%, transparent);
}

#language-icon {
    font-size: 1.25rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#theme-icon {
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#theme-icon svg,
#language-icon svg {
    display: block;
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
}

/* Tooltip styles for title attribute */
button[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10001;
    pointer-events: none;
    animation: tooltipFadeIn 0.2s ease-out;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.header-actions button {
    position: relative;
}

.content-body {
    flex: 1;
    padding: var(--layout-gutter) var(--layout-gutter) var(--layout-gutter) 0;
    max-width: none;
    width: auto;
    margin: 0;
    position: relative;
    overflow: visible;
}

.content-body > * {
    position: relative;
    z-index: 2;
}

.page-title-icon {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: var(--icon-violet-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-violet-fg);
    box-shadow: var(--shadow-sm);
}

.page-title-icon svg {
    width: 18px;
    height: 18px;
}

.page-ornaments {
    /* Keep ornaments fixed to the viewport; align to the main content area (exclude sidebar + gutters). */
    position: fixed;
    top: var(--layout-gutter);
    right: var(--layout-gutter);
    bottom: var(--layout-gutter);
    left: calc(var(--sidebar-width) + (2 * var(--layout-gutter)));
    pointer-events: none;
    z-index: 1;
    opacity: var(--ornament-fade);
}

.page-ornaments .orb {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--ornament-glow), transparent 70%);
    filter: blur(0.5px);
    animation: float 12s ease-in-out infinite;
}

.page-ornaments .orb.orb-1 {
    width: 220px;
    height: 220px;
    top: -60px;
    right: -40px;
    animation-delay: 0s;
}

.page-ornaments .orb.orb-2 {
    width: 160px;
    height: 160px;
    bottom: 40px;
    left: -50px;
    animation-delay: 1.5s;
}

.page-ornaments .linework {
    position: absolute;
    right: 6%;
    top: 24px;
    width: 180px;
    height: 180px;
    opacity: var(--ornament-linework-opacity);
}

/* Dashboard linework: keep it partially visible near stat cards */
.page-ornaments[data-ornament="dashboard"] .linework {
    right: -110px;
    top: 78px;
    width: 320px;
    height: 320px;
    opacity: min(1, calc(var(--ornament-linework-opacity) + 0.12));
}

.page-ornaments .linework path {
    stroke: var(--ornament-line);
    stroke-width: 1.2;
}

/* Cards with Glass Effect */
.card {
    background: var(--surface);
    border-radius: 18px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
    transition: all 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px) scale(1.001);
}

.card::after {
    content: '';
    position: absolute;
    inset: -40% -20% auto auto;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--ornament-fill), transparent 70%);
    opacity: 0.4;
    pointer-events: none;
}

.card.card-no-transform,
.card.card-no-transform:hover {
    transform: none !important;
    transition: none !important;
    box-shadow: none !important;
}

.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
}

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

.card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--font-size-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.card-title-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: var(--icon-blue-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-blue-fg);
    box-shadow: var(--shadow-sm);
}

.card-title-icon svg {
    width: 18px;
    height: 18px;
}

.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    transition: all 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, var(--ornament-fill), transparent 70%);
    opacity: 0.5;
}

.stat-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: var(--icon-blue-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-blue-fg);
    box-shadow: var(--shadow-sm);
}

.stat-icon.is-green,
.card-title-icon.is-green,
.page-title-icon.is-green {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.stat-icon.is-blue,
.card-title-icon.is-blue,
.page-title-icon.is-blue {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
}

.stat-icon.is-red,
.card-title-icon.is-red,
.page-title-icon.is-red {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
}

.stat-icon.is-violet,
.card-title-icon.is-violet,
.page-title-icon.is-violet {
    background: var(--icon-violet-bg);
    color: var(--icon-violet-fg);
}

.stat-icon.is-yellow,
.card-title-icon.is-yellow,
.page-title-icon.is-yellow {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.stat-icon svg {
    width: 22px;
    height: 22px;
    display: block;
    margin: auto;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.stat-value {
    /* Prevent overflow for larger values while keeping the same feel on desktop. */
    font-size: clamp(2.0rem, 4.2vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
    font-variant-numeric: tabular-nums;
}

.stat-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    position: relative;
    z-index: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
}

.btn .htmx-indicator {
    display: none;
}

.btn.htmx-request .htmx-indicator {
    display: inline-block;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--text-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #1e2734;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(20, 29, 42, 0.28);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-medium);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: color-mix(in srgb, var(--success) 80%, #000 20%);
}

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

.btn-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger) 78%, #000 22%);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: var(--font-size-base);
}

/* Stoic Header Buttons */
.btn-stoic {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    border-radius: 999px;
    padding: 0.5rem 1.1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.btn-stoic:hover:not(:disabled) {
    background: var(--surface-elevated);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-stoic svg {
    width: 16px;
    height: 16px;
}

.btn-stoic.btn-outline {
    background: transparent;
    border-color: var(--border-medium);
    color: var(--text-secondary);
}

.btn-stoic.btn-outline:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: none;
}

.btn-stoic.btn-danger {
    background: var(--icon-red-bg);
    border-color: color-mix(in srgb, var(--icon-red-fg) 42%, transparent);
    color: var(--icon-red-fg);
}

.btn-stoic.btn-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--icon-red-bg) 80%, var(--icon-red-fg) 20%);
    box-shadow: 0 6px 14px rgba(165, 77, 94, 0.2);
}

.btn-stoic.btn-success {
    background: var(--icon-green-bg);
    border-color: color-mix(in srgb, var(--icon-green-fg) 42%, transparent);
    color: var(--icon-green-fg);
}

.btn-stoic.btn-success:hover:not(:disabled) {
    background: color-mix(in srgb, var(--icon-green-bg) 78%, var(--icon-green-fg) 22%);
    box-shadow: 0 6px 14px rgba(46, 138, 96, 0.2);
}

.btn-stoic.btn-warning {
    background: var(--icon-yellow-bg);
    border-color: color-mix(in srgb, var(--icon-yellow-fg) 42%, transparent);
    color: var(--icon-yellow-fg);
}

.btn-stoic.btn-warning:hover:not(:disabled) {
    background: color-mix(in srgb, var(--icon-yellow-bg) 75%, var(--icon-yellow-fg) 25%);
    box-shadow: 0 6px 14px rgba(170, 130, 47, 0.2);
}

.btn-stoic.btn-info {
    background: var(--icon-blue-bg);
    border-color: color-mix(in srgb, var(--icon-blue-fg) 42%, transparent);
    color: var(--icon-blue-fg);
}

.btn-stoic.btn-info:hover:not(:disabled) {
    background: color-mix(in srgb, var(--icon-blue-bg) 75%, var(--icon-blue-fg) 25%);
    box-shadow: 0 6px 14px rgba(95, 127, 197, 0.2);
}

.btn-stoic.btn-violet {
    background: var(--icon-violet-bg);
    border-color: color-mix(in srgb, var(--icon-violet-fg) 42%, transparent);
    color: var(--icon-violet-fg);
}

.btn-stoic.btn-violet:hover:not(:disabled) {
    background: color-mix(in srgb, var(--icon-violet-bg) 74%, var(--icon-violet-fg) 26%);
    box-shadow: 0 6px 14px rgba(128, 103, 188, 0.2);
}

.oauth-brand-btn {
    background: #fff;
    color: #1f2937;
    border-color: #d1d5db;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.oauth-brand-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #cbd5e1;
    color: #111827;
}

.oauth-brand-btn-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.oauth-manual-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.phone-form-group {
    position: relative;
    z-index: 1;
}

.phone-form-group.phone-group-open {
    z-index: 2000;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
}

.section-title-icon {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--icon-blue-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-blue-fg);
}

.section-title-icon.is-violet {
    background: var(--icon-violet-bg);
    color: var(--icon-violet-fg);
}

.section-title-icon svg {
    width: 14px;
    height: 14px;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}


.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--surface);
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--silum-green);
    box-shadow: 0 0 0 4px rgba(127, 176, 105, 0.1);
}

.form-input-sm,
.form-select-sm {
    padding: 0.55rem 0.8rem;
    font-size: var(--font-size-sm);
}

.campaign-filters {
    padding: 0 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.campaign-filter {
    min-width: 180px;
}

.campaign-filter.is-search {
    min-width: 65px;
    flex: 1 1 65px;
}

.campaign-filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-label {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.filter-meta {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    padding-bottom: 0.2rem;
}

.campaign-filters {
    position: relative;
    z-index: 20;
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    padding: 0 1.5rem;
    border-bottom: 1px solid transparent;
    overflow: hidden;
    pointer-events: none;
    transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.18s ease, padding 0.18s ease, border-color 0.18s ease;
}

.campaign-filters.is-open {
    max-height: 320px;
    opacity: 1;
    transform: translateY(0);
    padding: 0 1.5rem 1rem 1.5rem;
    border-bottom-color: var(--border-light);
    pointer-events: auto;
    overflow: visible; /* allow custom select menus to escape the panel */
}

.card-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Custom select */
.custom-select {
    position: relative;
}

.custom-select-native {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.custom-select-trigger {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.8rem;
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background: var(--surface);
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 38px;
}

.custom-select-trigger:focus-visible {
    outline: none;
    border-color: var(--icon-blue-fg);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--icon-blue-fg) 18%, transparent);
}

.custom-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-chevron {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    flex: 0 0 auto;
    transition: transform 0.16s ease;
}

.custom-select-chevron svg {
    width: 16px;
    height: 16px;
    display: block;
}

.custom-select.is-open .custom-select-chevron {
    transform: rotate(180deg);
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface-elevated);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 0.35rem;
    display: none;
    z-index: 3200;
    max-height: 240px;
    overflow: auto;
}

.custom-select-menu.is-portal {
    position: fixed;
    left: 0;
    top: 0;
    right: auto;
    display: block;
    z-index: 4200; /* above tables/cards */
}

.custom-select.is-open .custom-select-menu {
    display: block;
}

.custom-select-option {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--text-primary);
    padding: 0.55rem 0.6rem;
    border-radius: 10px;
    font-size: var(--font-size-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.custom-select-option-label {
    flex: 1 1 auto;
    min-width: 0;
}

.custom-select-option-check {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    opacity: 0;
}

.custom-select-option-check svg {
    width: 16px;
    height: 16px;
    display: block;
}

.custom-select-option[aria-selected="true"] .custom-select-option-check {
    opacity: 1;
}

.custom-select-option:hover:not(:disabled) {
    background: color-mix(in srgb, var(--bg-tertiary) 70%, transparent);
}

.custom-select-option[aria-selected="true"] {
    background: color-mix(in srgb, var(--icon-blue-bg) 60%, transparent);
    color: var(--icon-blue-fg);
}

.custom-select-option:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Mailboxes status select (active/inactive). */
.custom-select[data-type="mailbox-status"][data-selected="all"] .custom-select-trigger {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.custom-select[data-type="mailbox-status"] .custom-select-option,
.custom-select-menu[data-type="mailbox-status"] .custom-select-option {
    border: 1px solid transparent;
    margin: 0.25rem 0;
}

.custom-select[data-type="mailbox-status"][data-selected="active"] .custom-select-trigger {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
    border-color: color-mix(in srgb, var(--icon-green-fg) 30%, transparent);
}

.custom-select[data-type="mailbox-status"][data-selected="inactive"] .custom-select-trigger {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
    border-color: color-mix(in srgb, var(--icon-yellow-fg) 30%, transparent);
}

.custom-select[data-type="mailbox-status"] .custom-select-option[data-value="active"],
.custom-select-menu[data-type="mailbox-status"] .custom-select-option[data-value="active"] {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.custom-select[data-type="mailbox-status"] .custom-select-option[data-value="inactive"],
.custom-select-menu[data-type="mailbox-status"] .custom-select-option[data-value="inactive"] {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.custom-select[data-type="mailbox-status"] .custom-select-option[data-value="all"],
.custom-select-menu[data-type="mailbox-status"] .custom-select-option[data-value="all"] {
    background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent);
    color: var(--text-primary);
}

/* Warmup filter (enabled/disabled). */
.custom-select[data-type="warmup"][data-selected="all"] .custom-select-trigger {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.custom-select[data-type="warmup"] .custom-select-option,
.custom-select-menu[data-type="warmup"] .custom-select-option {
    border: 1px solid transparent;
    margin: 0.25rem 0;
}

.custom-select[data-type="warmup"][data-selected="enabled"] .custom-select-trigger {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
    border-color: color-mix(in srgb, var(--icon-green-fg) 30%, transparent);
}

.custom-select[data-type="warmup"][data-selected="disabled"] .custom-select-trigger {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
    border-color: color-mix(in srgb, var(--icon-red-fg) 30%, transparent);
}

.custom-select[data-type="warmup"] .custom-select-option[data-value="enabled"],
.custom-select-menu[data-type="warmup"] .custom-select-option[data-value="enabled"] {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.custom-select[data-type="warmup"] .custom-select-option[data-value="disabled"],
.custom-select-menu[data-type="warmup"] .custom-select-option[data-value="disabled"] {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
}

.custom-select[data-type="warmup"] .custom-select-option[data-value="all"],
.custom-select-menu[data-type="warmup"] .custom-select-option[data-value="all"] {
    background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent);
    color: var(--text-primary);
}

/* Stop-list source filter (manual/csv/reply). */
.custom-select[data-type="stop-list-source"][data-selected="all"] .custom-select-trigger {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.custom-select[data-type="stop-list-source"][data-selected="mixed"] .custom-select-trigger {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.custom-select[data-type="stop-list-source"] .custom-select-option,
.custom-select-menu[data-type="stop-list-source"] .custom-select-option {
    border: 1px solid transparent;
    margin: 0.25rem 0;
}

.custom-select[data-type="stop-list-source"][data-selected="manual"] .custom-select-trigger {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
    border-color: color-mix(in srgb, var(--icon-blue-fg) 30%, transparent);
}

.custom-select[data-type="stop-list-source"][data-selected="csv"] .custom-select-trigger {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
    border-color: color-mix(in srgb, var(--icon-yellow-fg) 30%, transparent);
}

.custom-select[data-type="stop-list-source"][data-selected="reply"] .custom-select-trigger {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
    border-color: color-mix(in srgb, var(--icon-green-fg) 30%, transparent);
}

.custom-select[data-type="stop-list-source"][data-selected="bounce"] .custom-select-trigger {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
    border-color: color-mix(in srgb, var(--icon-red-fg) 30%, transparent);
}

.custom-select[data-type="stop-list-source"] .custom-select-option[data-value="manual"],
.custom-select-menu[data-type="stop-list-source"] .custom-select-option[data-value="manual"] {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
}

.custom-select[data-type="stop-list-source"] .custom-select-option[data-value="csv"],
.custom-select-menu[data-type="stop-list-source"] .custom-select-option[data-value="csv"] {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.custom-select[data-type="stop-list-source"] .custom-select-option[data-value="reply"],
.custom-select-menu[data-type="stop-list-source"] .custom-select-option[data-value="reply"] {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.custom-select[data-type="stop-list-source"] .custom-select-option[data-value="bounce"],
.custom-select-menu[data-type="stop-list-source"] .custom-select-option[data-value="bounce"] {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
}

.custom-select[data-type="stop-list-source"] .custom-select-option[data-value="all"],
.custom-select-menu[data-type="stop-list-source"] .custom-select-option[data-value="all"] {
    background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent);
    color: var(--text-primary);
}

.custom-select[data-type="stop-list-source"] .custom-select-option[aria-selected="true"],
.custom-select-menu[data-type="stop-list-source"] .custom-select-option[aria-selected="true"] {
    box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 28%, transparent);
}

/* Recipients status filter (pending/sent/bounced/replied/stopped). */
.custom-select[data-type="recipients-status"][data-selected="all"] .custom-select-trigger {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.custom-select[data-type="recipients-status"][data-selected="mixed"] .custom-select-trigger {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.custom-select[data-type="recipients-status"] .custom-select-option,
.custom-select-menu[data-type="recipients-status"] .custom-select-option {
    border: 1px solid transparent;
    margin: 0.25rem 0;
}

.custom-select[data-type="recipients-status"][data-selected="pending"] .custom-select-trigger {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
    border-color: color-mix(in srgb, var(--icon-blue-fg) 30%, transparent);
}

.custom-select[data-type="recipients-status"][data-selected="sent"] .custom-select-trigger {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
    border-color: color-mix(in srgb, var(--icon-green-fg) 30%, transparent);
}

.custom-select[data-type="recipients-status"][data-selected="bounced"] .custom-select-trigger {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
    border-color: color-mix(in srgb, var(--icon-red-fg) 30%, transparent);
}

.custom-select[data-type="recipients-status"][data-selected="replied"] .custom-select-trigger {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
    border-color: color-mix(in srgb, var(--icon-yellow-fg) 30%, transparent);
}

.custom-select[data-type="recipients-status"][data-selected="stopped"] .custom-select-trigger {
    background: var(--icon-violet-bg);
    color: var(--icon-violet-fg);
    border-color: color-mix(in srgb, var(--icon-violet-fg) 30%, transparent);
}

.custom-select[data-type="recipients-status"] .custom-select-option[data-value="pending"],
.custom-select-menu[data-type="recipients-status"] .custom-select-option[data-value="pending"] {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
}

.custom-select[data-type="recipients-status"] .custom-select-option[data-value="sent"],
.custom-select-menu[data-type="recipients-status"] .custom-select-option[data-value="sent"] {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.custom-select[data-type="recipients-status"] .custom-select-option[data-value="bounced"],
.custom-select-menu[data-type="recipients-status"] .custom-select-option[data-value="bounced"] {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
}

.custom-select[data-type="recipients-status"] .custom-select-option[data-value="replied"],
.custom-select-menu[data-type="recipients-status"] .custom-select-option[data-value="replied"] {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.custom-select[data-type="recipients-status"] .custom-select-option[data-value="stopped"],
.custom-select-menu[data-type="recipients-status"] .custom-select-option[data-value="stopped"] {
    background: var(--icon-violet-bg);
    color: var(--icon-violet-fg);
}

.custom-select[data-type="recipients-status"] .custom-select-option[data-value="all"],
.custom-select-menu[data-type="recipients-status"] .custom-select-option[data-value="all"] {
    background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent);
    color: var(--text-primary);
}

.custom-select[data-type="recipients-status"] .custom-select-option[aria-selected="true"],
.custom-select-menu[data-type="recipients-status"] .custom-select-option[aria-selected="true"] {
    box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 28%, transparent);
}

/* Status-colored options for campaign status multiselect. */
.custom-select[data-type="status"] .custom-select-menu,
.custom-select-menu[data-type="status"] {
    padding: 0.5rem;
    max-height: none;
    overflow: visible;
}

/* Status-colored trigger (the field itself). */
.custom-select[data-type="status"][data-selected="all"] .custom-select-trigger,
.custom-select[data-type="status"][data-selected="mixed"] .custom-select-trigger {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.custom-select[data-type="status"][data-selected="draft"] .custom-select-trigger {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: color-mix(in srgb, var(--border-light) 55%, transparent);
}

.custom-select[data-type="status"][data-selected="active"] .custom-select-trigger {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
    border-color: color-mix(in srgb, var(--icon-green-fg) 30%, transparent);
}

.custom-select[data-type="status"][data-selected="paused"] .custom-select-trigger {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
    border-color: color-mix(in srgb, var(--icon-yellow-fg) 30%, transparent);
}

.custom-select[data-type="status"][data-selected="finished"] .custom-select-trigger {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
    border-color: color-mix(in srgb, var(--icon-blue-fg) 30%, transparent);
}

.custom-select[data-type="status"][data-selected="mixed"] .custom-select-trigger {
    background: color-mix(in srgb, var(--surface) 80%, var(--bg-tertiary));
    border-color: color-mix(in srgb, var(--icon-blue-fg) 18%, var(--border-light));
}

.custom-select[data-type="status"] .custom-select-option,
.custom-select-menu[data-type="status"] .custom-select-option {
    border: 1px solid transparent;
    margin: 0.25rem 0;
}

.custom-select[data-type="status"] .custom-select-option:hover:not(:disabled),
.custom-select-menu[data-type="status"] .custom-select-option:hover:not(:disabled) {
    filter: brightness(0.98);
}

.custom-select[data-type="status"] .custom-select-option[aria-selected="true"],
.custom-select-menu[data-type="status"] .custom-select-option[aria-selected="true"] {
    /* Keep per-status colors; selection is indicated by a check + stronger border. */
    background: unset;
    color: unset;
}

.custom-select[data-type="status"] .custom-select-option[aria-selected="true"],
.custom-select-menu[data-type="status"] .custom-select-option[aria-selected="true"] {
    border-color: color-mix(in srgb, currentColor 35%, transparent);
}

.custom-select[data-type="status"] .custom-select-option[data-value="all"],
.custom-select-menu[data-type="status"] .custom-select-option[data-value="all"] {
    background: color-mix(in srgb, var(--bg-tertiary) 55%, transparent);
    color: var(--text-primary);
}

.custom-select[data-type="status"] .custom-select-option[data-value="draft"],
.custom-select-menu[data-type="status"] .custom-select-option[data-value="draft"] {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.custom-select[data-type="status"] .custom-select-option[data-value="active"],
.custom-select-menu[data-type="status"] .custom-select-option[data-value="active"] {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.custom-select[data-type="status"] .custom-select-option[data-value="paused"],
.custom-select-menu[data-type="status"] .custom-select-option[data-value="paused"] {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.custom-select[data-type="status"] .custom-select-option[data-value="finished"],
.custom-select-menu[data-type="status"] .custom-select-option[data-value="finished"] {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
}

.filters-badge {
    margin-left: 0.45rem;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: color-mix(in srgb, var(--icon-blue-bg) 70%, transparent);
    border: 1px solid color-mix(in srgb, var(--icon-blue-fg) 30%, transparent);
    color: var(--icon-blue-fg);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

.phone-input-combined {
    display: flex;
    align-items: center;
    gap: 0;
    max-width: 360px;
    border: 1.5px solid var(--border-light);
    border-radius: 12px;
    background: var(--surface);
    overflow: visible;
    position: relative;
    z-index: 1;
}

.phone-input-combined.phone-select-open {
    z-index: 5000;
}

.phone-input-combined:focus-within {
    border-color: var(--silum-green);
    box-shadow: 0 0 0 4px rgba(127, 176, 105, 0.1);
}

.phone-input-combined .form-input {
    flex: 1 1 auto;
    min-width: 0;
    padding-left: 0.5rem;
    border: none;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
}

.phone-country-select {
    position: relative;
    flex: 0 0 auto;
    border-right: 1px solid var(--border-light);
    z-index: 2;
}

.phone-country-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    min-width: 88px;
}

.phone-country-caret {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-secondary);
    margin-left: 0.1rem;
}

.phone-country-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    max-height: 280px;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 0.25rem 0;
    z-index: 3000;
    display: none;
}

.phone-country-select.open .phone-country-menu {
    display: block;
}

.phone-country-option {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.45rem 0.75rem;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
}

.phone-country-option:hover,
.phone-country-option[aria-selected="true"] {
    background: var(--bg-tertiary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Tables */
.table {
    width: 100%;
    /* Use separate borders so border-radius clips cleanly on all tables */
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    overflow: hidden;
    background: var(--surface-elevated);
}

/* Tables UX: show pointer cursor on table cells (avoid I-beam over table text). */
.table th,
.table td {
    cursor: pointer !important;
}

.table th,
.table td {
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.table th {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.table td {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.table tr:hover {
    background: var(--bg-tertiary);
}

.table tbody tr {
    transition: background 0.2s ease;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Dashboard tables: slightly larger left padding for the № column (no checkbox column on dashboard) */
.table.is-dashboard .row-number-col,
.table.is-dashboard .row-number-cell {
    padding-left: 0.9rem !important;
}

/* Table pagination (base style for all list pages) */
.table-pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0 0 0;
    flex-wrap: wrap;
}

.table-pagination-meta {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.table-pagination-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.table-pagination-page {
    min-width: 40px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 10px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    border: none;
}

.badge-draft {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-active {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.badge-inactive {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-paused {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.badge-warning {
    /* Generic warning badge (used e.g. for CSV stop-list source). */
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.badge-finished {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
}

.badge-pending {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
}

.badge-sent {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.badge-bounced {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
}

.badge-blocked {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
}

.badge-replied {
    /* Reply is a "success-ish" outcome; keep it distinct from Sent (green) by using amber. */
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.badge-stopped {
    /* Suppressed / stop-list recipient. Keep it neutral-distinct. */
    background: var(--icon-violet-bg);
    color: var(--icon-violet-fg);
}

.badge-waiting {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
}

.rep-score {
    font-weight: 700;
}

.rep-score.rep-red {
    color: var(--danger);
}

.rep-score.rep-orange {
    /* Slightly more orange than --warning (which is closer to yellow). */
    color: color-mix(in srgb, var(--danger) 35%, var(--warning) 65%);
}

.rep-score.rep-yellow {
    color: var(--icon-yellow-fg);
}

.rep-score.rep-green {
    color: var(--success);
}

.campaign-status-tags {
    display: inline-flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.2rem;
}

/* Mailboxes (status + warmup UI) */
.mailbox-status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    padding: 0.28rem 0.72rem;
    font-size: 0.84rem;
    font-weight: 600;
    border: none;
}

.mailbox-status-pill.active {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
}

.mailbox-status-pill.inactive {
    background: var(--icon-yellow-bg);
    color: var(--icon-yellow-fg);
}

.warmup-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.warmup-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.warmup-slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    border-radius: 999px;
    background: var(--border-medium);
    transition: 0.2s ease;
}

.warmup-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    transition: 0.2s ease;
}

.warmup-switch input:checked + .warmup-slider {
    background: var(--icon-green-fg);
}

.warmup-switch input:checked + .warmup-slider:before {
    transform: translateX(20px);
}

.warmup-modal-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(3, 8, 20, 0.55);
    z-index: 2000;
}

.warmup-modal {
    width: min(480px, calc(100vw - 2rem));
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.alert-close {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    color: currentColor;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
    flex: 0 0 auto;
    align-self: center;
    line-height: 1;
    font-size: 18px;
}

.alert-close:hover {
    opacity: 1;
    transform: translateY(-1px);
    background: color-mix(in srgb, var(--surface) 75%, transparent);
}

.alert-close:active {
    transform: translateY(0);
}

.alert-close:focus-visible {
    outline: 2px solid color-mix(in srgb, currentColor 55%, transparent);
    outline-offset: 2px;
}

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

.alert-success {
    background: var(--icon-green-bg);
    color: var(--icon-green-fg);
    border: 1px solid color-mix(in srgb, var(--icon-green-fg) 30%, transparent);
}

.alert-error {
    background: var(--icon-red-bg);
    color: var(--icon-red-fg);
    border: 1px solid color-mix(in srgb, var(--icon-red-fg) 30%, transparent);
}

.alert-info {
    background: var(--icon-blue-bg);
    color: var(--icon-blue-fg);
    border: 1px solid color-mix(in srgb, var(--icon-blue-fg) 30%, transparent);
}

/* Row numbering in tables */
.row-number-col {
    width: 34px;
    text-align: center;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    padding-left: 0.45rem !important;
    padding-right: 0.35rem !important;
}

.row-number-cell {
    text-align: center;
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-left: 0.45rem !important;
    padding-right: 0.35rem !important;
}

/* Reduce the visual gap between the № column and the next column. */
.row-number-col + th,
.row-number-cell + td {
    padding-left: 0.45rem !important;
}

/* Loading States */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline;
}

.spinner {
    border: 2px solid var(--border-light);
    border-top: 2px solid var(--icon-violet-fg);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Attachments chips (reused in campaign editor + inbox) */
.inbox-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.2rem 0.45rem 0.35rem;
}

.inbox-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
}

.inbox-attachment-remove {
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    width: 14px;
    height: 14px;
    line-height: 1;
    font-size: 0.8rem;
    padding: 0;
}

.inbox-attachment-remove:hover {
    color: var(--danger);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 18px;
    background: var(--bg-tertiary);
    color: var(--icon-blue-fg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.empty-state-icon svg {
    width: 32px;
    height: 32px;
}

.provider-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
}

.provider-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.provider-icon img {
    width: 20px;
    height: 20px;
    display: block;
    border-radius: 5px;
    object-fit: contain;
}

/* Consistent icon-only buttons (tables + bulk action bars) */
.btn-icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    line-height: 1;
}

/* Marker class for bulk action bar buttons (keeps styling consistent across pages). */
.bulk-action-btn {}

.has-tooltip {
    position: relative;
}

/* Theme-aware tooltip vars (used by JS tooltip). */
:root {
    /* Light theme tooltip: light surface, dark text */
    --tooltip-bg: rgba(255, 255, 255, 0.96);
    --tooltip-fg: rgba(10, 12, 16, 0.92);
    --tooltip-border: rgba(15, 23, 42, 0.12);
}

html[data-theme="dark"] {
    /* Dark theme tooltip: dark surface, white text */
    --tooltip-bg: rgba(10, 12, 16, 0.92);
    --tooltip-fg: #ffffff;
    --tooltip-border: rgba(255, 255, 255, 0.12);
}

.app-tooltip {
    position: fixed;
    max-width: 280px;
    background: var(--tooltip-bg);
    color: var(--tooltip-fg);
    border: 1px solid var(--tooltip-border);
    border-radius: 10px;
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    box-shadow: 0 10px 28px rgba(0,0,0,0.28);
    z-index: 4000;
    pointer-events: none;
}

.app-tooltip::before {
    content: "";
    position: absolute;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--tooltip-bg);
    border-left: 1px solid var(--tooltip-border);
    border-top: 1px solid var(--tooltip-border);
    transform: translateX(-50%) rotate(45deg);
}

.app-tooltip[data-placement="bottom"]::before {
    top: -5px;
}

.app-tooltip[data-placement="top"]::before {
    bottom: -5px;
    border-left: none;
    border-top: none;
    border-right: 1px solid var(--tooltip-border);
    border-bottom: 1px solid var(--tooltip-border);
}

.empty-state h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(140deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    background-attachment: fixed;
    padding: 2rem;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.auth-illustration {
    /* Keep auth page illustration anchored to viewport (do not scroll with content). */
    position: fixed;
    inset: 0;
    pointer-events: none;
    color: var(--text-secondary);
}

.auth-illustration svg {
    position: absolute;
    width: 260px;
    height: 260px;
    right: 6%;
    top: 8%;
    opacity: 0.8;
}

.auth-illustration .auth-orb {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--ornament-glow), transparent 70%);
    left: -80px;
    bottom: -80px;
    animation: float 14s ease-in-out infinite;
}

.auth-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    border: 1px solid var(--border-light);
    position: relative;
    z-index: 2;
}


.auth-logo {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-logo img {
    width: 64px;
    height: 64px;
    margin-bottom: 0;
    display: block;
}

.auth-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.auth-link a {
    color: var(--link-fg);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

.notfound-card {
    min-height: 440px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.notfound-code {
    font-size: clamp(2.8rem, 8vw, 4.5rem);
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.notfound-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.notfound-actions .btn {
    min-width: 190px;
    justify-content: center;
    text-decoration: none;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; }
.flex-gap { gap: 1rem; }
.items-center { align-items: center; }

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

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

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

    .content-body {
        padding: 1rem;
    }

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

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

    .page-ornaments,
    .auth-illustration {
        display: none;
    }
}

/* Smooth Transitions - only for specific properties */
a, button, .btn, .nav-item, .card, .stat-card {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Text Utilities with Opacity for Visual Hierarchy */
.text-secondary-soft {
    color: var(--text-secondary);
    opacity: 0.8;
}

.text-tertiary-soft {
    color: var(--text-tertiary);
    opacity: 0.7;
}

/* Table improvements */
.table tbody td {
    color: var(--text-primary);
}

.table tbody td[style*="var(--text-secondary)"] {
    opacity: 0.8;
}

.table tbody td[style*="var(--text-tertiary)"] {
    opacity: 0.7;
}

/* Stat subtitle with better hierarchy */
.stat-subtitle {
    color: var(--text-secondary);
    opacity: 0.75;
    font-size: var(--font-size-xs);
    margin-top: 0.5rem;
}

/* Card subtitle with opacity */
.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    opacity: 0.8;
    margin-top: 0.25rem;
}

/* Empty state text */
.empty-state p {
    color: var(--text-secondary);
    opacity: 0.75;
}

/* Custom Checkbox Styles */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-medium);
    border-radius: 5px;
    background: var(--surface);
    cursor: pointer;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

input[type="checkbox"]::after {
    /* Checkmark */
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    /* Slightly above true center looks visually centered for a checkmark glyph. */
    transform: translate(-50%, -58%) rotate(45deg) scale(0.6);
    opacity: 0;
    transition: opacity 0.12s ease, transform 0.12s ease;
}

input[type="checkbox"]:hover {
    border-color: color-mix(in srgb, var(--icon-blue-fg) 80%, var(--border-medium));
}

input[type="checkbox"]:checked {
    /* Match "Pending" (В очереди) color */
    background: var(--icon-blue-fg);
    border-color: var(--icon-blue-fg);
}

input[type="checkbox"]:checked::after {
    opacity: 1;
    transform: translate(-50%, -58%) rotate(45deg) scale(1);
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--icon-blue-fg) 22%, transparent);
}

input[type="checkbox"]:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Page Reveal Animations */
.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes float {
    0% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(0, -8px, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

/* ============================================
   MOBILE MENU
   ============================================ */

/* Mobile menu button - hidden on desktop */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 1rem;
    position: relative;
    z-index: 1001;
}

.hamburger-line {
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
}

.hamburger-line:nth-child(1) {
    transform: translateY(-6px);
}

.hamburger-line:nth-child(2) {
    transform: translateY(0);
}

.hamburger-line:nth-child(3) {
    transform: translateY(6px);
}

/* Animated hamburger to X */
.mobile-menu-btn.active .hamburger-line:nth-child(1) {
    transform: translateY(0) rotate(45deg);
}

.mobile-menu-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px);
}

.mobile-menu-btn.active .hamburger-line:nth-child(3) {
    transform: translateY(0) rotate(-45deg);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

.sidebar-hover-tooltip {
    position: fixed;
    z-index: 2000;
    background: var(--text-primary);
    color: var(--bg-primary);
    border-radius: 7px;
    padding: 0.38rem 0.52rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.08s ease;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.sidebar-hover-tooltip.is-visible {
    opacity: 1;
}

@media (max-width: 768px) {
    .sidebar-collapse-btn {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    }

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

    .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content-header {
        margin: 12px 12px 0;
        padding: 0.85rem 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    /* Adjust content padding on mobile */
    .content-body {
        padding: 1rem;
    }

    /* Stack stat cards on mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Adjust card padding on mobile */
    .card {
        padding: 1rem;
    }

    .card-header {
        padding: 0 0 1rem 0;
    }

    /* Make tables responsive */
    .table-container {
        overflow-x: auto;
    }
}

/* ============================================
   Bug Report Modal
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
}

.modal.modal-visible {
    display: flex;
    animation: modalFadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.modal-hidden {
    display: none;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    position: relative;
    background-color: var(--surface);
    border-radius: 16px;
    border: 1px solid var(--border-light);
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 10000;
}

.modal.modal-visible .modal-content {
    animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(24px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.bug-report-modal-content {
    padding: 0;
    position: relative;
    overflow: hidden;
}

/* Decorative gradient orb */
.bug-report-modal-content::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, var(--ornament-glow), transparent 70%);
    opacity: 0.6;
    pointer-events: none;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, transparent 100%);
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.modal-header h2::before {
    content: '';
    display: inline-flex;
    width: 28px;
    height: 28px;
    background: var(--silum-mint);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E8C61' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.modal-close {
    background: var(--bg-tertiary);
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close:hover {
    background: var(--border-light);
    color: var(--text-primary);
    transform: scale(1.05);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 120px);
}

.bug-report-modal-content .form-group {
    margin-bottom: 1.25rem;
}

.bug-report-modal-content label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.bug-report-modal-content textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    resize: vertical;
    min-height: 140px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.bug-report-modal-content textarea::placeholder {
    color: var(--text-tertiary);
}

.bug-report-modal-content textarea:focus {
    outline: none;
    border-color: var(--silum-green);
    box-shadow: 0 0 0 4px rgba(127, 176, 105, 0.1);
}

.form-hint {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.625rem;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.form-hint::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpath d='M12 16v-4'%3E%3C/path%3E%3Cpath d='M12 8h.01'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    flex-shrink: 0;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-light);
}

.success-message {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.success-message svg {
    color: var(--silum-green) !important;
    filter: drop-shadow(0 4px 12px rgba(127, 176, 105, 0.3));
}

.success-message h3 {
    margin: 0 0 0.5rem 0;
    font-size: var(--font-size-xl);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.success-message p {
    margin: 0 0 1.25rem 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.report-id {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 10px;
    margin: 1.25rem 0;
    font-size: var(--font-size-sm);
    border: 1px solid var(--border-light);
}

.report-id strong {
    color: var(--silum-green-dark);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: var(--font-size-base);
    letter-spacing: 0.02em;
}

/* Dark mode adjustments */
[data-theme="dark"] .modal {
    background-color: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-content {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .modal-header {
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, transparent 100%);
}

[data-theme="dark"] .modal-header h2::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239FC885' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");
}

[data-theme="dark"] .form-hint::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B6B70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpath d='M12 16v-4'%3E%3C/path%3E%3Cpath d='M12 8h.01'%3E%3C/path%3E%3C/svg%3E");
}

/* ============================================
   Cookie Consent Banner
   ============================================ */

.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-elevated);
    border-top: 1.5px solid var(--border-light);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 -8px 30px rgba(12, 20, 32, 0.12);
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
}

.cookie-consent.show {
    transform: translateY(0);
}

.cookie-consent-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.cookie-consent-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cookie-consent-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--silum-green);
}

.cookie-consent-icon svg {
    width: 22px;
    height: 22px;
}

.cookie-consent-text {
    flex: 1;
}

.cookie-consent-text p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.cookie-consent-text a {
    color: var(--link-fg);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.cookie-consent-text a:hover {
    color: var(--link-hover-fg);
    text-decoration: underline;
}

.cookie-consent-actions {
    flex-shrink: 0;
}

.cookie-consent-btn {
    padding: 0.75rem 1.75rem;
    background: var(--silum-green);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.15);
}

.cookie-consent-btn:hover {
    background: var(--silum-green-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(31, 41, 55, 0.2);
}

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

/* Dark theme adjustments */
[data-theme="dark"] .cookie-consent {
    background: var(--surface-elevated);
    border-top-color: var(--border-medium);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .cookie-consent-icon {
    background: var(--bg-tertiary);
    color: var(--silum-sage);
}

[data-theme="dark"] .cookie-consent-btn {
    /* High contrast CTA aligned with dark theme text (light button, dark text). */
    background: var(--text-primary);
    color: rgba(10, 12, 16, 0.92);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .cookie-consent-btn:hover {
    background: color-mix(in srgb, var(--text-primary) 85%, #ffffff 15%);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .cookie-consent-btn:active {
    transform: translateY(0);
}

[data-theme="dark"] .cookie-consent-text a:hover {
    color: var(--link-hover-fg);
}

/* Responsive Design */
@media (max-width: 768px) {
    .cookie-consent {
        padding: 1rem;
    }

    .cookie-consent-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .cookie-consent-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.875rem;
    }

    .cookie-consent-actions {
        width: 100%;
    }

    .cookie-consent-btn {
        width: 100%;
    }
}
