/* Global Variables & Theme */
:root {
    /* Color Palette - Dark & Modern */
    --bg-body: #020617;
    /* Slate 950 */
    --bg-card: rgba(15, 23, 42, 0.6);
    /* Slate 900 with opacity */
    --bg-card-hover: rgba(30, 41, 59, 0.7);
    /* Slate 800 with opacity */

    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary-color: #0ea5e9;
    /* Sky 500 */
    --accent-color: #d946ef;
    /* Fuchsia 500 */

    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */

    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);

    --success-color: #10b981;
    /* Emerald 500 */
    --warning-color: #f59e0b;
    /* Amber 500 */
    --danger-color: #ef4444;
    /* Red 500 */

    /* Spacing & Layout */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 24px;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px var(--primary-glow);

    --backdrop-blur: blur(12px);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    /* Subtle gradient background */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(217, 70, 239, 0.08), transparent 25%);
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--secondary-color);
}

code,
pre {
    font-family: 'JetBrains Mono', monospace;
}

/* Utilities */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Layout & Structure */
#root {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.app-header {
    margin-bottom: 2rem;
    position: relative;
    z-index: 10;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-card);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

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

.brand-logo {
    height: 40px;
    width: auto;
    max-width: 40px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* Navigation Tabs */
.app-tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.5);
    padding: 0.5rem;
    border-radius: 100px;
    border: 1px solid var(--border-color);
}

.app-tab {
    padding: 0.5rem 1.25rem;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

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

.app-tab.active {
    color: #fff;
    background: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Header Body */
.header-body {
    padding: 0 1rem;
    margin-bottom: 2rem;
}

.eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    font-size: 1.125rem;
    color: var(--text-muted);
    max-width: 600px;
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

/* Footer */
footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--text-muted);
    font-size: 0.875rem;
}

footer a:hover {
    color: var(--primary-color);
}

/* Components */

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button:not(.secondary):not(.danger) {
    background: linear-gradient(135deg, var(--primary-color), #4f46e5);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

button:not(.secondary):not(.danger):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

button.secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

button.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

button.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

/* Inputs */
input,
select,
textarea {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

/* Metric Pills */
.inline-metrics {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.metric-pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.metric-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
}

/* Status Messages */
.status {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status.success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status.loading {
    background: rgba(99, 102, 241, 0.1);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Email Viewer Specifics */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.cleanup-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.viewer-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.viewer-pill {
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: none;
    text-align: left;
}

.viewer-pill:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.viewer-pill.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Message Item (Email Card) */
.message-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all var(--transition-fast);
}

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

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.message-subject {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.message-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
}

.message-body {
    color: #cbd5e1;
    font-size: 0.9375rem;
    line-height: 1.7;
    white-space: pre-wrap;
}

.message-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Cleanup Specifics */
.cleanup-shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.shortcut-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.shortcut-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary-color);
}

/* Usage / analytics */
.usage-chart {
    width: 100%;
    min-height: 160px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.16), transparent 55%),
        radial-gradient(circle at 100% 100%, rgba(129, 140, 248, 0.22), transparent 55%),
        rgba(15, 23, 42, 0.9);
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-muted);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.75);
}

.usage-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.usage-breakdown-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.7);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.usage-breakdown-label {
    font-size: 13px;
    color: var(--text-muted);
}

.usage-breakdown-value {
    font-size: 15px;
    font-weight: 600;
}

.usage-breakdown-meter {
    position: relative;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(30, 64, 175, 0.5);
    overflow: hidden;
    margin-top: 2px;
}

.usage-breakdown-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, #22d3ee, #6366f1, #a855f7);
    box-shadow: 0 0 10px rgba(129, 140, 248, 0.7);
    transition: width 0.5s ease-out;
}

.usage-table {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.7);
    overflow-x: auto;
}

.usage-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.usage-table th,
.usage-table td {
    padding: 8px 10px;
    text-align: left;
}

.usage-table th {
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.usage-table tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.6);
}

/* Animations */
.slide-up {
    animation: slideUp 0.5s ease-out forwards;
}

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

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

.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

/* ========================================
   ENHANCED UI - Micro-interactions & Polish
   ======================================== */

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

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

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) rgba(255, 255, 255, 0.02);
}

/* Focus Visible for Accessibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    z-index: 100;
    border-radius: 0 0 var(--radius-md) 0;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
}

/* Enhanced Button States */
button {
    position: relative;
    overflow: hidden;
}

button:active:not(:disabled) {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Button Ripple Effect */
button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

button:active::after {
    width: 200px;
    height: 200px;
    opacity: 0;
}

/* Button Loading State */
button.loading {
    pointer-events: none;
    color: transparent !important;
}

button.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Enhanced Card Hover */
.card {
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

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

/* Message Card Enhancements */
.message-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: all var(--transition-normal);
    position: relative;
}

.message-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.message-card h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.message-card .message-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.message-card .message-summary {
    font-size: 0.875rem;
    color: #cbd5e1;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.message-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* Actions Row */
.actions-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1rem;
}

/* Button Link Style */
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.button-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
}

/* Enhanced Metric Pills */
.metric-pill {
    transition: all var(--transition-fast);
}

.metric-pill:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Pill Badge */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 100px;
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.pill.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.2);
}

.pill.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.2);
}

.pill.success {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.2);
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Enhanced Form Inputs with Gradient Focus */
input:focus,
select:focus,
textarea:focus {
    border-color: transparent;
    background: linear-gradient(var(--bg-card), var(--bg-card)) padding-box,
        linear-gradient(135deg, var(--primary-color), var(--accent-color)) border-box;
    border: 1px solid transparent;
}

/* Form Field Labels */
label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

/* Hint Text */
.hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Loading Skeleton */
.skeleton {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.08),
            transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-card {
    height: 120px;
    margin-bottom: 1rem;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    max-width: 400px;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.toast.show {
    transform: translateX(0);
}

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

.toast.error {
    border-left: 4px solid var(--danger-color);
}

/* Switch Toggle Enhanced */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

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

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 26px;
    transition: all 0.3s ease;
}

.switch-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked+.switch-slider {
    background: var(--primary-color);
}

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

.switch-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Slider/Range Input */
.slider-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    border-radius: 100px;
}

/* Log/Terminal Style */
.log {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
    color: #94a3b8;
}

.log-line {
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.log-line:last-child {
    border-bottom: none;
}

/* Automation Components */
.automation-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
    gap: 2rem;
    align-items: flex-start;
}

.automation-cost-card {
    margin-top: 1.5rem;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(99, 102, 241, 0.35);
    background: radial-gradient(circle at 10% 10%, rgba(99, 102, 241, 0.08), transparent 35%),
        radial-gradient(circle at 80% 30%, rgba(217, 70, 239, 0.07), transparent 40%),
        rgba(15, 23, 42, 0.65);
    box-shadow: var(--shadow-md);
}

.cost-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0.25rem 0 0.35rem 0;
}

.cost-value {
    font-size: 2rem;
    font-weight: 700;
    color: #c7d2fe;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.01em;
}

.cost-unit {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.automation-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.stat-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.5rem;
    text-align: left;
    min-width: 0;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'JetBrains Mono', monospace;
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

#automation-cost-note {
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: calc(1.5em * 3);
}

.highlight-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(217, 70, 239, 0.05));
    border-color: rgba(99, 102, 241, 0.2);
}

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

.automation-field {
    display: flex;
    flex-direction: column;
}

/* Criteria Section */
.automation-criteria,
.automation-actions-builder {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.criteria-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Chip Input */
.chip-input {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chip-input__label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 2rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 100px;
    font-size: 0.8125rem;
    color: #a5b4fc;
}

.chip button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.chip button:hover {
    opacity: 1;
}

.chip-input__controls {
    display: flex;
    gap: 0.5rem;
}

.chip-input__controls input {
    flex: 1;
}

.chip-input__controls button {
    flex-shrink: 0;
}

/* Action Grid */
.action-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.action-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: start;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

/* Age Grid */
.age-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.age-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.age-grid input {
    width: 100%;
}

/* Automation List */
.automation-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.automation-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

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

.automation-item.disabled {
    opacity: 0.5;
}

/* Criterion Item (Tags page) */
.criterion-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    transition: all var(--transition-fast);
}

.criterion-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Criteria List */
.criteria-list {
    display: flex;
    flex-direction: column;
}

/* Instruction Steps (Settings page) */
.instruction-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: var(--primary-color);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 50%;
}

.instruction-step p {
    margin: 0;
    padding-top: 0.25rem;
}

/* Viewer Body (email content) */
.viewer-body {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.75);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.viewer-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.viewer-html {
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    line-height: 1.7;
    overflow-x: auto;
}

.viewer-html h1,
.viewer-html h2,
.viewer-html h3,
.viewer-html h4 {
    margin: 0.25rem 0 0.35rem;
}

.viewer-html p {
    margin: 0 0 0.75rem 0;
    color: var(--text-main);
}

.viewer-html li,
.viewer-html td,
.viewer-html th {
    color: var(--text-main);
}

.viewer-html a {
    color: var(--secondary-color);
    word-break: break-word;
}

.viewer-html ul,
.viewer-html ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0 0.5rem 1rem;
}

.viewer-html table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}

.viewer-html table td,
.viewer-html table th {
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.5rem;
}

.viewer-html img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.viewer-html blockquote {
    border-left: 3px solid var(--primary-color);
    margin: 0.75rem 0;
    padding-left: 0.75rem;
    color: var(--text-muted);
}

.viewer-plain-text {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
}

.plain-text-toggle {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.plain-text-toggle summary {
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.plain-text-toggle[open] summary {
    color: var(--text-main);
}

.viewer-plain-only {
    margin-top: 0.25rem;
}

/* Reply Box */
.reply-box {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-md);
}

.reply-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.reply-status {
    margin-top: 0.75rem;
}

/* Count Items (cleanup summary) */
.counts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.count-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

.count-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'JetBrains Mono', monospace;
}

.count-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablets and smaller */
@media (max-width: 1024px) {
    #root {
        padding: 1.5rem;
    }

    .header-top {
        flex-direction: column;
        gap: 1rem;
    }

    .app-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }

    .automation-hero {
        grid-template-columns: 1fr;
    }

    .automation-stats {
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 768px) {
    #root {
        padding: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.375rem;
    }

    .card {
        padding: 1.25rem;
    }

    .header-top {
        padding: 0.75rem;
    }

    .app-tabs {
        width: 100%;
        border-radius: var(--radius-md);
        overflow-x: auto;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }

    .app-tab {
        padding: 0.5rem 1rem;
        white-space: nowrap;
        font-size: 0.8125rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cleanup-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .cleanup-controls button {
        flex: 1;
        min-width: 100px;
    }

    .message-card {
        padding: 1rem;
    }

    .actions-row {
        flex-direction: column;
    }

    .actions-row button,
    .actions-row .button-link {
        width: 100%;
    }

    .inline-metrics,
    .viewer-metrics {
        grid-template-columns: 1fr;
    }

    .metric-pill {
        text-align: center;
    }

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

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

    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        max-width: none;
    }

    .stat-card {
        min-width: 100px;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .brand-text {
        display: none;
    }

    .app-tabs {
        padding: 0.375rem;
    }

    .app-tab {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }

    button {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .automation-stats {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .stat-card {
        width: 100%;
    }
}

/* Touch Device Tap Targets */
@media (hover: none) and (pointer: coarse) {

    button,
    .app-tab,
    .button-link,
    input,
    select,
    textarea {
        min-height: 44px;
    }

    .chip button {
        min-width: 32px;
        min-height: 32px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .app-header,
    .app-tabs,
    button,
    footer {
        display: none !important;
    }

    .card {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }
}
