@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ==========================================================================
   AUTOTRADER DESIGN SYSTEM — LIGHT & DARK TOKENS
   Apple Minimalism + Stripe / Mercury Fintech Precision
   ========================================================================== */

:root {
    --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Canvas & Surfaces (Light) */
    --bg-canvas: #F5F7FB;
    --bg-canvas-glow: radial-gradient(ellipse 75% 42% at 50% -10%, rgba(37, 99, 235, 0.085), transparent 72%);
    --bg-surface: #FFFFFF;
    --bg-surface-subtle: #F8FAFC;
    --bg-surface-muted: #F1F5F9;
    --bg-surface-hover: #F3F6FA;
    --bg-glass: rgba(255, 255, 255, 0.84);
    --bg-input: #FFFFFF;
    --bg-input-disabled: #F8FAFC;
    --bg-control-track: #EEF2F7;
    --bg-control-active: #FFFFFF;
    --bg-backdrop: rgba(15, 23, 42, 0.44);

    /* Borders (Light) */
    --border-subtle: rgba(15, 23, 42, 0.075);
    --border-default: rgba(15, 23, 42, 0.12);
    --border-strong: rgba(15, 23, 42, 0.20);

    /* Typography (Light) */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #64748B;
    --text-muted: #94A3B8;

    /* Brand Blue Palette (Light) */
    --brand-500: #2563EB;
    --brand-600: #1D4ED8;
    --brand-700: #1E40AF;
    --brand-text: #1D4ED8;
    --brand-soft-bg: rgba(37, 99, 235, 0.075);
    --brand-soft-border: rgba(37, 99, 235, 0.20);
    --brand-row-bg: rgba(37, 99, 235, 0.055);
    --brand-row-hover: rgba(37, 99, 235, 0.09);
    --brand-ring: rgba(37, 99, 235, 0.18);
    --brand-hero-tint: linear-gradient(165deg, rgba(37, 99, 235, 0.045) 0%, rgba(255, 255, 255, 0) 58%);

    /* Semantic Financial Colors (Light) */
    --positive: #059669;
    --positive-strong: #047857;
    --positive-soft-bg: rgba(5, 150, 105, 0.085);
    --positive-soft-border: rgba(5, 150, 105, 0.22);

    --negative: #E11D48;
    --negative-strong: #BE123C;
    --negative-soft-bg: rgba(225, 29, 72, 0.08);
    --negative-soft-border: rgba(225, 29, 72, 0.22);

    --warning: #B45309;
    --warning-strong: #92400E;
    --warning-soft-bg: rgba(217, 119, 6, 0.095);
    --warning-soft-border: rgba(217, 119, 6, 0.24);

    --indigo: #4F46E5;
    --indigo-soft-bg: rgba(79, 70, 229, 0.085);
    --indigo-soft-border: rgba(79, 70, 229, 0.22);

    /* Elevation (Light) */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.035), 0 6px 20px -4px rgba(15, 23, 42, 0.045);
    --shadow-card-hover: 0 2px 4px rgba(15, 23, 42, 0.05), 0 12px 28px -6px rgba(15, 23, 42, 0.075);
    --shadow-control: 0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 1px rgba(15, 23, 42, 0.04);
    --shadow-modal: 0 24px 56px -12px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.06);
    --shadow-btn-primary: 0 1px 2px rgba(29, 78, 216, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);

    /* Scrollbar & Select Arrow (Light) */
    --scrollbar-thumb: rgba(15, 23, 42, 0.16);
    --scrollbar-thumb-hover: rgba(15, 23, 42, 0.28);
    --select-chevron: 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='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    /* Skeleton */
    --skeleton-base: #E8EEF5;
    --skeleton-shine: #F4F7FB;
}

[data-theme="dark"] {
    /* Canvas & Surfaces (Dark — Midnight Blue-Slate) */
    --bg-canvas: #090D16;
    --bg-canvas-glow: radial-gradient(ellipse 75% 42% at 50% -12%, rgba(59, 130, 246, 0.13), transparent 72%);
    --bg-surface: #111724;
    --bg-surface-subtle: #151C2C;
    --bg-surface-muted: #1A2336;
    --bg-surface-hover: rgba(148, 163, 184, 0.065);
    --bg-glass: rgba(13, 18, 30, 0.82);
    --bg-input: #0D121E;
    --bg-input-disabled: #121826;
    --bg-control-track: #0B101A;
    --bg-control-active: #1D263B;
    --bg-backdrop: rgba(3, 6, 14, 0.72);

    /* Borders (Dark) */
    --border-subtle: rgba(148, 163, 184, 0.10);
    --border-default: rgba(148, 163, 184, 0.16);
    --border-strong: rgba(148, 163, 184, 0.26);

    /* Typography (Dark) */
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-tertiary: #94A3B8;
    --text-muted: #64748B;

    /* Brand Blue Palette (Dark) */
    --brand-500: #3B82F6;
    --brand-600: #2563EB;
    --brand-700: #1D4ED8;
    --brand-text: #60A5FA;
    --brand-soft-bg: rgba(59, 130, 246, 0.13);
    --brand-soft-border: rgba(59, 130, 246, 0.28);
    --brand-row-bg: rgba(59, 130, 246, 0.09);
    --brand-row-hover: rgba(59, 130, 246, 0.14);
    --brand-ring: rgba(59, 130, 246, 0.28);
    --brand-hero-tint: linear-gradient(165deg, rgba(59, 130, 246, 0.10) 0%, rgba(17, 23, 36, 0) 60%);

    /* Semantic Financial Colors (Dark) */
    --positive: #34D399;
    --positive-strong: #6EE7B7;
    --positive-soft-bg: rgba(16, 185, 129, 0.13);
    --positive-soft-border: rgba(16, 185, 129, 0.26);

    --negative: #FB7185;
    --negative-strong: #FDA4AF;
    --negative-soft-bg: rgba(244, 63, 94, 0.13);
    --negative-soft-border: rgba(244, 63, 94, 0.26);

    --warning: #FBBF24;
    --warning-strong: #FCD34D;
    --warning-soft-bg: rgba(245, 158, 11, 0.13);
    --warning-soft-border: rgba(245, 158, 11, 0.26);

    --indigo: #818CF8;
    --indigo-soft-bg: rgba(99, 102, 241, 0.14);
    --indigo-soft-border: rgba(99, 102, 241, 0.28);

    /* Elevation (Dark) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 6px 24px -4px rgba(0, 0, 0, 0.36);
    --shadow-card-hover: inset 0 1px 0 rgba(255, 255, 255, 0.065), 0 12px 32px -4px rgba(0, 0, 0, 0.48);
    --shadow-control: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-modal: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 28px 64px -12px rgba(0, 0, 0, 0.72);
    --shadow-btn-primary: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);

    /* Scrollbar & Select Arrow (Dark) */
    --scrollbar-thumb: rgba(148, 163, 184, 0.22);
    --scrollbar-thumb-hover: rgba(148, 163, 184, 0.36);
    --select-chevron: 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='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    /* Skeleton */
    --skeleton-base: #182032;
    --skeleton-shine: #222C42;
}

/* ==========================================================================
   BASE RESET & TYPOGRAPHY
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background-color: var(--bg-canvas);
    background-image: var(--bg-canvas-glow);
    background-attachment: fixed;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    transition: background-color 200ms ease, color 200ms ease;
}

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

.num-tabular {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "cv05" 1;
}

/* Semantic Text Color Utilities (must override base td/kpi colors) */
.t-primary { color: var(--text-primary) !important; }
.t-secondary { color: var(--text-secondary) !important; }
.t-tertiary { color: var(--text-tertiary) !important; }
.t-muted { color: var(--text-muted) !important; }
.t-brand { color: var(--brand-text) !important; }
.t-positive { color: var(--positive) !important; }
.t-negative { color: var(--negative) !important; }
.t-warning { color: var(--warning) !important; }
.t-indigo { color: var(--indigo) !important; }

.at-link {
    color: var(--text-tertiary);
    transition: color 150ms ease;
}
.at-link:hover {
    color: var(--brand-text);
}

.at-link-neutral {
    color: var(--text-tertiary);
    transition: color 150ms ease;
}
.at-link-neutral:hover {
    color: var(--text-primary);
}

[hidden],
.at-nav-tab.hidden,
.at-counter-pill.hidden,
.at-badge.hidden,
.at-btn.hidden,
.at-icon-btn.hidden,
.at-select.hidden,
.at-segmented.hidden {
    display: none !important;
}

/* Monetary Display Refinement */
.usd-currency {
    font-weight: 500;
    opacity: 0.56;
    margin-right: 0.05em;
}

.usd-cents {
    font-size: 0.72em;
    font-weight: 600;
    opacity: 0.65;
}

/* Focus Accessibility */
:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

/* Scrollbars */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ==========================================================================
   BRAND MARK
   ========================================================================== */

.at-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(145deg, #2563EB 0%, #1D4ED8 100%);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.24);
    flex-shrink: 0;
}

.at-brand-mark-lg {
    width: 42px;
    height: 42px;
    border-radius: 12px;
}

/* ==========================================================================
   STICKY HEADER & TOP NAVIGATION (Apple / Stripe Glass Bar)
   ========================================================================== */

.at-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color 200ms ease, border-color 200ms ease;
}

.at-nav-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow-x: auto;
    margin-bottom: -1px;
}

.at-nav-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 44px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: color 160ms ease, background-color 160ms ease;
}

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

.at-nav-tab::after {
    content: "";
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--brand-500);
    transform: scaleX(0);
    opacity: 0;
    transition: transform 180ms cubic-bezier(0.2, 0, 0, 1), opacity 160ms ease;
}

.at-nav-tab.is-active {
    color: var(--brand-text);
    font-weight: 600;
}

.at-nav-tab.is-active::after {
    transform: scaleX(1);
    opacity: 1;
}

.at-nav-tab .at-nav-icon {
    width: 15px;
    height: 15px;
    opacity: 0.75;
    transition: opacity 150ms ease;
}

.at-nav-tab.is-active .at-nav-icon,
.at-nav-tab:hover .at-nav-icon {
    opacity: 1;
}

/* ==========================================================================
   CARDS & SURFACES
   ========================================================================== */

.at-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    transition: background-color 200ms ease, border-color 180ms ease, box-shadow 200ms ease;
}

.at-card-hero {
    background: var(--brand-hero-tint), var(--bg-surface);
    border-color: var(--border-default);
}

.at-card-interactive:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-card-hover);
}

.at-inset {
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}

.at-divider {
    border-color: var(--border-subtle) !important;
}

.at-callout-brand {
    background: var(--brand-soft-bg);
    border: 1px solid var(--brand-soft-border);
    border-radius: 14px;
}

.at-callout-indigo {
    background: var(--indigo-soft-bg);
    border: 1px solid var(--indigo-soft-border);
    border-radius: 14px;
}

.at-callout-warning {
    background: var(--warning-soft-bg);
    border: 1px solid var(--warning-soft-border);
    border-radius: 14px;
}

.at-callout-negative {
    background: var(--negative-soft-bg);
    border: 1px solid var(--negative-soft-border);
    border-radius: 12px;
    color: var(--negative);
}

/* ==========================================================================
   KPI & METRIC CARDS
   ========================================================================== */

.at-kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: -0.005em;
    line-height: 1.3;
}

.at-kpi-value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text-primary);
}

@media (min-width: 640px) {
    .at-kpi-value {
        font-size: 26px;
    }
}

.at-kpi-hero-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.08;
    color: var(--text-primary);
}

@media (min-width: 640px) {
    .at-kpi-hero-value {
        font-size: 40px;
    }
}

.at-kpi-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.at-kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-subtle);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.at-kpi-icon-brand {
    background: var(--brand-soft-bg);
    border-color: var(--brand-soft-border);
    color: var(--brand-text);
}

.at-kpi-icon-positive {
    background: var(--positive-soft-bg);
    border-color: var(--positive-soft-border);
    color: var(--positive);
}

.at-kpi-icon-warning {
    background: var(--warning-soft-bg);
    border-color: var(--warning-soft-border);
    color: var(--warning);
}

.at-kpi-icon-indigo {
    background: var(--indigo-soft-bg);
    border-color: var(--indigo-soft-border);
    color: var(--indigo);
}

/* ==========================================================================
   SEGMENTED CONTROLS (macOS / iOS Style)
   ========================================================================== */

.at-segmented {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border-radius: 10px;
    background: var(--bg-control-track);
    border: 1px solid var(--border-subtle);
    gap: 2px;
}

.at-segmented .at-segmented-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 28px;
    padding: 0 11px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    background-color: transparent;
    border: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.at-segmented .at-segmented-btn:hover:not(.is-active):not(.is-active-positive):not(.is-active-warning) {
    color: var(--text-primary);
}

.at-segmented .at-segmented-btn.is-active {
    background-color: var(--bg-control-active);
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: var(--shadow-control);
}

.at-segmented .at-segmented-btn.is-active-positive {
    background-color: #059669;
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.30);
}

.at-segmented .at-segmented-btn.is-active-warning {
    background-color: #D97706;
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.30);
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.at-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 100ms ease, opacity 150ms ease;
}

.at-btn:active:not(:disabled) {
    transform: scale(0.985);
}

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

.at-btn-xs {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 8px;
}

.at-btn-sm {
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 9px;
}

.at-btn-md {
    height: 38px;
    padding: 0 15px;
    font-size: 13px;
    border-radius: 10px;
}

.at-btn-lg {
    height: 44px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 11px;
}

.at-btn.at-btn-primary {
    background-color: var(--brand-500);
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: var(--shadow-btn-primary);
}

.at-btn.at-btn-primary:hover:not(:disabled) {
    background-color: var(--brand-600);
}

.at-btn.at-btn-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-default);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}

.at-btn.at-btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-strong);
}

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

.at-btn.at-btn-ghost:hover:not(:disabled) {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.at-btn.at-btn-brand-soft {
    background-color: var(--brand-soft-bg);
    border-color: var(--brand-soft-border);
    color: var(--brand-text);
    font-weight: 600;
}

.at-btn.at-btn-brand-soft:hover:not(:disabled) {
    background-color: var(--brand-500);
    border-color: var(--brand-500);
    color: #FFFFFF;
}

.at-btn.at-btn-positive {
    background-color: #059669;
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.at-btn.at-btn-positive:hover:not(:disabled) {
    background-color: #047857;
}

.at-btn.at-btn-warning {
    background-color: #D97706;
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(217, 119, 6, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.at-btn.at-btn-warning:hover:not(:disabled) {
    background-color: #B45309;
}

.at-btn.at-btn-danger-soft {
    background-color: var(--negative-soft-bg);
    border-color: transparent;
    color: var(--negative);
    font-weight: 500;
}

.at-btn.at-btn-danger-soft:hover:not(:disabled) {
    background-color: #E11D48;
    color: #FFFFFF;
}

.at-btn.at-btn-danger {
    background-color: #E11D48;
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(225, 29, 72, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.at-btn.at-btn-danger:hover:not(:disabled) {
    background-color: #BE123C;
}

button.at-icon-btn,
a.at-icon-btn,
.at-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

button.at-icon-btn:hover,
a.at-icon-btn:hover,
.at-icon-btn:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

button.at-icon-btn:active,
a.at-icon-btn:active,
.at-icon-btn:active {
    transform: scale(0.95);
}

button.at-icon-btn.at-icon-btn-danger:hover,
.at-icon-btn.at-icon-btn-danger:hover {
    background-color: var(--negative-soft-bg);
    border-color: var(--negative-soft-border);
    color: var(--negative);
}

/* ==========================================================================
   INPUTS, SELECTS & CHECKBOXES
   ========================================================================== */

.at-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.at-input,
.at-select {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.4;
    box-shadow: var(--shadow-xs);
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease, opacity 150ms ease;
}

@media (min-width: 640px) {
    .at-input,
    .at-select {
        font-size: 13px;
    }
}

.at-input::placeholder {
    color: var(--text-muted);
}

.at-input:hover:not(:disabled):not(:focus),
.at-select:hover:not(:disabled):not(:focus) {
    border-color: var(--border-strong);
}

.at-input:focus,
.at-select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-ring);
}

.at-input:disabled,
.at-select:disabled {
    background: var(--bg-input-disabled);
    opacity: 0.52;
    cursor: not-allowed;
}

.at-input-sm,
.at-select-sm {
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 9px;
}

.at-select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 32px;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 15px 15px;
    cursor: pointer;
}

.at-select-auto {
    width: auto;
    min-width: 118px;
}

input[type="date"].at-input {
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
}

input[type="date"].at-input::-webkit-date-and-time-value {
    text-align: left;
    margin: 0;
}

/* Input with prefix / suffix icon */
.at-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.at-input-prefix {
    position: absolute;
    left: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
    user-select: none;
}

.at-input-has-prefix {
    padding-left: 28px;
}

.at-input-suffix-btn {
    position: absolute;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 150ms ease, background-color 150ms ease;
}

.at-input-suffix-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.at-input-has-suffix {
    padding-right: 38px;
}

/* Custom Checkbox */
input.at-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 17px;
    height: 17px;
    border-radius: 5px;
    border: 1.5px solid var(--border-strong);
    background-color: var(--bg-input);
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

input.at-checkbox:hover {
    border-color: var(--brand-500);
}

input.at-checkbox:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-ring);
}

input.at-checkbox:checked {
    background-color: var(--brand-500);
    border-color: var(--brand-500);
}

input.at-checkbox:checked::after {
    content: "";
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* ==========================================================================
   BADGES & AVATARS
   ========================================================================== */

.at-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.005em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.at-badge-brand {
    background: var(--brand-soft-bg);
    border-color: var(--brand-soft-border);
    color: var(--brand-text);
}

.at-badge-positive {
    background: var(--positive-soft-bg);
    border-color: var(--positive-soft-border);
    color: var(--positive);
}

.at-badge-negative {
    background: var(--negative-soft-bg);
    border-color: var(--negative-soft-border);
    color: var(--negative);
}

.at-badge-warning {
    background: var(--warning-soft-bg);
    border-color: var(--warning-soft-border);
    color: var(--warning);
}

.at-badge-indigo {
    background: var(--indigo-soft-bg);
    border-color: var(--indigo-soft-border);
    color: var(--indigo);
}

.at-badge-neutral {
    background: var(--bg-surface-muted);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

.at-counter-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.at-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.01em;
    flex-shrink: 0;
    background: var(--bg-surface-muted);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.at-avatar-me {
    background: var(--brand-soft-bg);
    border-color: var(--brand-soft-border);
    color: var(--brand-text);
}

.at-avatar-manager {
    background: var(--warning-soft-bg);
    border-color: var(--warning-soft-border);
    color: var(--warning);
}

/* ==========================================================================
   TABLES (Fintech Precision)
   ========================================================================== */

.at-table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.at-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.at-table thead th {
    padding: 11px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    color: var(--text-tertiary);
    background: var(--bg-surface-subtle);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.at-table-compact thead th {
    padding: 9px 12px;
}

.at-table tbody td {
    padding: 13px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    white-space: nowrap;
}

.at-table-compact tbody td {
    padding: 10px 12px;
    font-size: 12.5px;
}

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

.at-table tbody tr {
    transition: background-color 140ms ease;
}

.at-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

.at-table tbody tr.is-me {
    background: var(--brand-row-bg);
}

.at-table tbody tr.is-me td:first-child {
    box-shadow: inset 3px 0 0 var(--brand-500);
}

.at-table tbody tr.is-me:hover {
    background: var(--brand-row-hover);
}

.at-table-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Clickable Row Link (Cotista / Afiliado Name) */
.at-row-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: color 140ms ease;
}

.at-row-link:hover {
    color: var(--brand-text);
}

.at-row-link .at-row-chevron {
    width: 13px;
    height: 13px;
    opacity: 0;
    transform: translateX(-3px);
    color: var(--brand-text);
    transition: opacity 140ms ease, transform 140ms ease;
}

.at-row-link:hover .at-row-chevron,
tr:hover .at-row-link .at-row-chevron {
    opacity: 1;
    transform: translateX(0);
}

/* Share Progress Bar */
.at-share-cell {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.at-share-track {
    width: 38px;
    height: 4px;
    border-radius: 9999px;
    background: var(--border-subtle);
    overflow: hidden;
    flex-shrink: 0;
}

.at-share-fill {
    height: 100%;
    border-radius: 9999px;
    background: var(--brand-500);
    transition: width 300ms ease;
}

/* Mobile Cotista Card */
.at-mobile-cotista {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow-xs);
    transition: border-color 160ms ease, background-color 160ms ease;
}

.at-mobile-cotista.is-me {
    background: var(--brand-row-bg);
    border-color: var(--brand-soft-border);
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.at-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg-backdrop);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
    opacity: 0;
    transition: opacity 180ms ease;
}

.at-modal-backdrop.is-open {
    display: flex;
    opacity: 1;
}

.at-modal-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    box-shadow: var(--shadow-modal);
    width: 100%;
    transform: scale(0.975) translateY(8px);
    opacity: 0;
    transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms ease;
}

.at-modal-backdrop.is-open .at-modal-panel {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

.at-toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
    width: calc(100% - 32px);
    pointer-events: none;
}

.at-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 13px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-modal);
    font-size: 13px;
    color: var(--text-primary);
    animation: atToastIn 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.at-toast.is-leaving {
    animation: atToastOut 180ms ease forwards;
}

@keyframes atToastIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes atToastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-6px) scale(0.97); }
}

/* ==========================================================================
   LOADING SKELETON & SPINNER
   ========================================================================== */

.at-skeleton {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: var(--skeleton-base);
    color: transparent !important;
    user-select: none;
}

.at-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, var(--skeleton-shine) 50%, transparent 100%);
    transform: translateX(-100%);
    animation: atShimmer 1.4s infinite;
}

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

.at-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 9999px;
    display: inline-block;
    animation: atSpin 650ms linear infinite;
}

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

/* Subtle Tab Content Reveal */
.at-view-enter {
    animation: atViewFade 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Statement Day Card */
.at-stmt-day {
    background: var(--bg-surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 14px 16px;
}

.at-stmt-trade-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 11px;
    padding: 12px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
