/* === main.css === */
/**
 * Converge v2.0 — Main Stylesheet
 * Affiliate & Ad-Tracking Dashboard · Navy+Electric Blue · Inter system font
 * Design language: trust (navy), data clarity (tabular numbers), profit focus (emerald)
 */

/* ═══════════════════════════════════════
   Self-hosted Inter — @font-face
   Latin subset · woff2 · font-display:swap
   ═══════════════════════════════════════ */

@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ═══════════════════════════════════════
   CSS Variables — Converge Affiliate Palette
   ═══════════════════════════════════════ */

:root {
    /* Brand — Navy authority + Electric Blue action */
    --color-primary: #152E4A;       /* Navy dark (WCAG AA 4.5:1 on var(--surface-base)) */
    --color-primary-dark: #0A1A2F;  /* Deeper navy */
    --color-primary-light: var(--accent); /* Lighter navy (原 primary) */
    --color-primary-bg: var(--border-default);    /* Navy tint (lightened for contrast) */
    --color-accent: var(--accent-emphasis);        /* Electric Blue: CTAs, links, active */
    --color-accent-hover: #1D4ED8;  /* Darker electric blue */

    /* Sidebar — Dark navy command center */
    --color-sidebar: #0A1628;
    --color-sidebar-hover: #152238;
    --color-sidebar-active: var(--accent);
    --color-sidebar-text: var(--border-strong);
    --color-sidebar-muted: #64748B;
    --color-sidebar-accent: var(--accent-emphasis);

    /* Surfaces — Cool slate for data contrast */
    --color-white: var(--surface-raised);
    --color-bg: var(--surface-base);
    --color-bg-alt: var(--surface-base);
    --color-border: var(--border-default);
    --color-border-light: var(--surface-overlay);
    --color-surface: var(--surface-raised);     /* Bridge → design tokens (was undefined) */
    --color-surface-alt: var(--surface-overlay); /* Bridge → design tokens (was undefined) */
    --color-border-strong: var(--border-strong); /* Bridge → design tokens (was undefined) */

    /* Text */
    --color-text: var(--content-primary);
    --color-text-secondary: #475569;
    --color-text-muted: var(--content-tertiary);

    /* Status — Profit-focused */
    --color-success: var(--success);       /* Rich emerald: profit/ROAS positive */
    --color-success-bg: #D1FAE5;
    --color-warning: var(--warning);       /* Amber: budget alerts */
    --color-warning-bg: var(--warning-soft);
    --color-error: var(--danger);         /* Coral red: loss/negative ROAS */
    --color-error-bg: var(--danger-soft);
    --color-info: var(--accent-emphasis);          /* Same as accent */
    --color-info-bg: var(--accent-soft);

    /* Financial data — explicit profit/loss colors */
    --color-profit: var(--success);
    --color-loss: var(--danger);
    --color-roas-positive: var(--success);
    --color-roas-negative: var(--danger);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Typography — system font stack (zero latency, native rendering) */
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", "JetBrains Mono", Menlo, Consolas, monospace;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --line-height-tight: 1.25;   /* headings */
    --line-height-normal: 1.5;   /* body */
    --line-height-relaxed: 1.75; /* long-form */

    /* Modular type scale (1.25 ratio — minor third) */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px — browser default, accessible */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */
    --text-4xl: 2.25rem;   /* 36px */

    /* Letter-spacing */
    --tracking-tight: -0.02em;   /* large headings */
    --tracking-normal: 0;        /* body */
    --tracking-wide: 0.04em;     /* labels, badges */
    --tracking-wider: 0.08em;    /* uppercase micro */

    /* Keep old tokens for backward compatibility */
    --font-family: var(--font-sans);
    --font-size-xs: var(--text-xs);
    --font-size-sm: var(--text-sm);
    --font-size-base: var(--text-base);
    --font-size-lg: var(--text-lg);
    --font-size-xl: var(--text-xl);
    --font-size-2xl: var(--text-2xl);
    --font-size-3xl: var(--text-3xl);

    /* Layout */
    --sidebar-width: 240px;
    --navbar-height: 56px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.08), 0 8px 10px rgba(0, 0, 0, 0.04);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════ */

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

html { font-size: clamp(15px, 1.5vw, 16px); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: 'Inter', var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
}

/* ── Financial data alignment ── */
.stat-card .value, td.numeric, [data-type="currency"], [data-type="percentage"] {
    font-variant-numeric: tabular-nums;
}

a { color: var(--color-accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-primary-light); }

/* ── Headings: responsive fluid scale ── */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-text);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    margin-bottom: var(--spacing-md);
}
h1 { font-size: clamp(1.5rem, 3vw, var(--text-4xl)); letter-spacing: var(--tracking-tight); }
h2 { font-size: clamp(1.25rem, 2.5vw, var(--text-3xl)); }
h3 { font-size: clamp(1.125rem, 2vw, var(--text-2xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

/* ── Text measure: optimal line length for readability (60-75 chars) ── */
p, .prose, .page-description {
    max-width: 72ch;
}
.page-description {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

/* ── Label / Badge micro-text ── */
.label, .badge, .meta, .tag {
    font-size: var(--text-xs);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--color-text-muted);
}

/* ── Code: inline + block ── */
code, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--color-bg-alt);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-light);
}
pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: var(--line-height-relaxed);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
    max-width: 100%;
}
pre code {
    background: none;
    padding: 0;
    border: none;
    font-size: inherit;
}

/* ── Small / caption ── */
small, .text-small, .caption {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    line-height: var(--line-height-normal);
}

/* ── Strong / emphasis hierarchy ── */
strong { font-weight: var(--font-weight-semibold); }
.text-muted { color: var(--color-text-muted); }
.text-profit { color: var(--color-profit); font-weight: var(--font-weight-semibold); }
.text-loss   { color: var(--color-loss); font-weight: var(--font-weight-semibold); }

/* ═══════════════════════════════════════
   Layout
   ═══════════════════════════════════════ */

.app-wrapper { display: flex; min-height: 100vh; }

/* ═══════════════════════════════════════
   Sidebar — Dark & Professional
   ═══════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.sidebar-header {
    padding: var(--spacing-lg) var(--spacing-md);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: center; gap: var(--spacing-sm);
}

.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    color: var(--surface-raised); font-size: var(--font-size-xl); font-weight: 700;
    letter-spacing: -0.01em;
}

.sidebar-logo-icon {
    width: 34px; height: 34px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size:var(--text-lg);
}

.sidebar-nav { flex: 1; padding: var(--spacing-sm) var(--spacing-sm); }

.sidebar-nav-section { margin-bottom: var(--spacing-sm); }

.sidebar-nav-title {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size:var(--text-xs); font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--color-sidebar-muted);
    margin-top: var(--spacing-sm);
}

.sidebar-nav-list { list-style: none; }

.sidebar-nav-item { margin-bottom: 1px; }

.sidebar-nav-link {
    display: flex; align-items: center; gap: 10px;
    padding:var(--space-2) 12px; border-radius: var(--radius-sm);
    color: var(--color-sidebar-text); font-size: var(--font-size-sm);
    font-weight: 450; transition: all var(--transition);
    border-left: 2px solid transparent;
}

.sidebar-nav-link:hover {
    background: var(--color-sidebar-hover);
    color: var(--surface-raised);
    border-left-color: var(--color-sidebar-muted);
}

.sidebar-nav-link.active {
    background: var(--color-sidebar-active);
    color: var(--surface-raised); font-weight: 600;
    border-left-color: var(--color-sidebar-accent);
    box-shadow: inset 0 0 0 1px rgba(79,70,229,0.2);
}

.sidebar-nav-icon {
    width: 20px; height: 20px; object-fit: contain;
    opacity: 0.7; flex-shrink: 0;
}

.sidebar-nav-link.active .sidebar-nav-icon, .sidebar-nav-link:hover .sidebar-nav-icon { opacity: 1; }

.sidebar-footer {
    padding: var(--spacing-md);
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: var(--font-size-xs);
    color: var(--color-sidebar-muted);
    text-align: center;
}

/* ═══════════════════════════════════════
   Main Content
   ═══════════════════════════════════════ */

.main-content {
    flex: 1; margin-left: var(--sidebar-width);
    display: flex; flex-direction: column; min-height: 100vh;
}

/* ═══════════════════════════════════════
   Navbar — Clean & Minimal
   ═══════════════════════════════════════ */

.navbar {
    height: var(--navbar-height);
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--spacing-xl);
    position: sticky; top: 0; z-index: 90;
}

.navbar-left { display: flex; align-items: center; gap: var(--spacing-md); }

.navbar-title {
    font-size: var(--font-size-lg); color: var(--color-text);
    font-weight: 600;
}

.navbar-breadcrumb {
    display: flex; align-items: center; gap: var(--spacing-xs);
    font-size: var(--font-size-sm); color: var(--color-text-muted);
}

.navbar-right { display: flex; align-items: center; gap: var(--spacing-lg); }

.navbar-user { display: flex; align-items: center; gap: var(--spacing-sm); color: var(--color-text); font-size: var(--font-size-sm); }

.navbar-avatar {
    width: 32px; height: 32px; border-radius: var(--radius-full);
    background: var(--color-primary); color: var(--surface-raised);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: var(--font-size-sm);
}

/* ═══════════════════════════════════════
   Content
   ═══════════════════════════════════════ */

.content-container { flex: 1; padding: var(--spacing-lg) var(--spacing-xl); max-width: 1280px; width: 100%; margin: 0 auto; }

.page-header { margin-bottom: var(--spacing-lg); }

.page-title {
    font-size: var(--font-size-2xl); color: var(--color-text);
    font-weight: 700; margin-bottom: var(--spacing-xs); letter-spacing: -0.01em;
}

.page-description { color: var(--color-text-secondary); font-size: var(--font-size-base); }

/* ═══════════════════════════════════════
   Cards
   ═══════════════════════════════════════ */

.card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--color-border-light);
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

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

.card-title { font-size: var(--font-size-lg); color: var(--color-text); font-weight: 600; margin: 0; }

.card-body { color: var(--color-text); }

/* Stat Card — Dashboard KPI */
.stat-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}

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

.stat-card-label {
    font-size: var(--font-size-xs); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--color-text-muted); margin-bottom: var(--spacing-xs);
}

.stat-card-value {
    font-size:var(--text-3xl); font-weight: 700; color: var(--color-text);
    letter-spacing: -0.02em; line-height: 1.2;
}

.stat-card-change {
    font-size: var(--font-size-xs); margin-top: var(--spacing-xs);
    display: flex; align-items: center; gap:var(--space-1);
}

.stat-card-change.up { color: var(--color-success); }
.stat-card-change.down { color: var(--color-error); }

/* Stat Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

/* ═══════════════════════════════════════
   Buttons
   ═══════════════════════════════════════ */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding:var(--space-2) 16px; font-size: var(--font-size-sm);
    font-weight: 500; border: 1px solid transparent;
    border-radius: var(--radius-sm); cursor: pointer;
    transition: all var(--transition); text-decoration: none;
    white-space: nowrap; line-height: 1.4;
}

.btn-primary {
    background: var(--color-primary); color: var(--surface-raised);
    box-shadow: 0 1px 2px rgba(79,70,229,0.2);
}
.btn-primary:hover { background: var(--color-primary-dark); color: var(--surface-raised); box-shadow: 0 2px 4px rgba(79,70,229,0.3); }

.btn-secondary {
    background: var(--color-bg); color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-border); }

.btn-outline {
    background: transparent; border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn-outline:hover { background: var(--color-bg); border-color: var(--color-text-muted); }

.btn-danger { background: var(--color-error); color: var(--surface-raised); }
.btn-danger:hover { background: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: var(--font-size-xs); }

/* ═══════════════════════════════════════
   Tables
   ═══════════════════════════════════════ */

.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-border); }

.table { width: 100%; border-collapse: collapse; background: var(--color-white); }

.table thead { background: var(--color-bg-alt); }

.table th {
    padding: 10px var(--spacing-md); text-align: left;
    font-weight: 600; font-size: var(--font-size-xs);
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--color-text-secondary); border-bottom: 2px solid var(--color-border);
}

.table td {
    padding: 10px var(--spacing-md);
    border-bottom: 1px solid var(--color-border-light);
    font-size: var(--font-size-sm);
}

.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--color-bg); }
.table tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════
   Forms
   ═══════════════════════════════════════ */

.form-group { margin-bottom: var(--spacing-md); }

.form-label {
    display: block; font-size: var(--font-size-sm);
    font-weight: 500; color: var(--color-text); margin-bottom: var(--spacing-xs);
}

.form-control {
    width: 100%; padding:var(--space-2) 12px;
    font-size: var(--font-size-sm); font-family: var(--font-family);
    border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    background: var(--color-white); color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-control::placeholder { color: var(--color-text-muted); }

select.form-control { cursor: pointer; }

/* ═══════════════════════════════════════
   Badges
   ═══════════════════════════════════════ */

.badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; font-size: var(--font-size-xs);
    font-weight: 600; border-radius: var(--radius-full);
    letter-spacing: 0.02em; line-height: 1.6;
}

.badge-success { background: var(--color-success-bg); color: #065F46; }
.badge-warning { background: var(--color-warning-bg); color: #92400E; }
.badge-error   { background: var(--color-error-bg); color: #991B1B; }
.badge-info    { background: var(--color-info-bg); color: var(--accent-emphasis); }

/* ═══════════════════════════════════════
   Alerts & Notifications
   ═══════════════════════════════════════ */

.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md); margin-bottom: var(--spacing-md);
    font-size: var(--font-size-sm); border: 1px solid transparent;
}

.alert-success { background: var(--color-success-bg); border-color: #A7F3D0; color: #065F46; }
.alert-warning { background: var(--color-warning-bg); border-color: #FCD34D; color: #92400E; }
.alert-error   { background: var(--color-error-bg); border-color: var(--danger-soft); color: #991B1B; }
.alert-info    { background: var(--color-info-bg); border-color: #BFDBFE; color: var(--accent-emphasis); }

/* ═══════════════════════════════════════
   Modal base
   ═══════════════════════════════════════ */

.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--color-white); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl); padding: var(--spacing-xl);
    max-width: 500px; width: 90%; max-height: 85vh; overflow-y: auto;
}

.modal-header { margin-bottom: var(--spacing-lg); }
.modal-title { font-size: var(--font-size-xl); font-weight: 700; }
.modal-body { margin-bottom: var(--spacing-lg); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--spacing-sm); }

/* ═══════════════════════════════════════
   Utility
   ═══════════════════════════════════════ */

.text-muted  { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error   { color: var(--color-error); }
.text-info    { color: var(--color-info); }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* ═══════════════════════════════════════
   Health Check Indicator (new: /health)
   ═══════════════════════════════════════ */

.health-dot {
    width: 8px; height: 8px; border-radius: var(--radius-full);
    display: inline-block; margin-right:var(--space-1);
}
.health-dot.ok { background: var(--color-success); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.health-dot.degraded { background: var(--color-warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }
.health-dot.down { background: var(--color-error); box-shadow: 0 0 0 3px rgba(239,68,68,0.2); }

/* ═══════════════════════════════════════
   Responsive
   ═══════════════════════════════════════ */

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 200ms ease; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .navbar { padding: 0 var(--spacing-md); }
    .content-container { padding: var(--spacing-md); }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}

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

/* ═══ 响应式显隐切换: 桌面表格 ⇄ 移动卡片 ═══
   多页(offers/campaigns/visitors/billing/networks/settings/traffic-sources/landing-pages)
   的HTML已含 .desktop-only 表格 + .mobile-only 卡片, 此前缺全局开关导致手机端两者同显+宽表溢出。 */
.mobile-only { display: none; }
@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .mobile-only  { display: block !important; }
}

/* === dock-layout.css === */
/* ═══ Activity Bar + 可折叠侧面板 ═══
   VS Code 风格: 56px Dock → 220px Panel (toggle)
   Ctrl+B 全局快捷 · localStorage 持久化 · aria-expanded
   参考: orchestra#920 · ALF Design Group 2026 UX 指南 */

/* ── Activity Bar (56px 固定) ── */
.activity-bar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 56px; z-index: 101;
    display: flex; flex-direction: column; align-items: center;
    padding:var(--space-3) 0;
    background: #0A1628;
    border-right: 1px solid rgba(255,255,255,0.06);
}

/* Logo */
.activity-logo {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin-bottom:var(--space-4); border-radius: 10px;
    transition: background 0.15s;
}
.activity-logo:hover { background: rgba(255,255,255,0.08); }
.activity-logo img { width: 28px; height: 28px; }

/* Dock 按钮 */
.activity-buttons {
    flex: 1; display: flex; flex-direction: column; gap: 2px;
    width: 100%; padding: 0 6px;
}
.dock-btn {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 9px 0; border: none; border-radius: var(--radius-md);
    background: transparent; color: rgba(255,255,255,0.6);
    cursor: pointer; font-size:var(--text-xs); font-family: inherit;
    transition: all 0.12s ease; width: 100%;
    position: relative;
}
.dock-btn::before {
    content: ''; position: absolute; left: -6px; top: 6px; bottom: 6px;
    width: 2px; border-radius: 0 2px 2px 0;
    background: transparent; transition: background 0.12s;
}
.dock-btn:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.06); }
.dock-btn.active {
    color: var(--surface-raised); background: rgba(37,99,235,0.3); font-weight: 600;
}
.dock-btn.active::before { background: var(--accent-emphasis); }
.dock-btn-icon { font-size:var(--text-xl); line-height: 1; }
.dock-btn-label { white-space: nowrap; font-weight: 500; }

/* Quick Create ＋ */
.activity-quick {
    position: relative; margin:var(--space-2) 0;
}
.quick-create-trigger {
    width: 40px; height: 40px; border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 10px; background: transparent; color: rgba(255,255,255,0.5);
    font-size:var(--text-xl); cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.quick-create-trigger:hover {
    border-color: var(--accent-emphasis); color: var(--surface-raised); background: #2563EB;
}
.quick-create-dropdown {
    position: absolute; left: calc(100% + 8px); bottom: 0;
    background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    min-width: 200px; z-index: 999; padding: 6px 0;
}
.quick-create-dropdown[hidden] { display: none; }
.quick-create-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; text-decoration: none;
    color: var(--content-primary); font-size:var(--text-sm);
}
.quick-create-item:hover { background: var(--surface-overlay); }

/* Footer */
.activity-footer {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    margin-top: auto;
}
.activity-health { cursor: pointer; }
.health-dot {
    display: block; width: 10px; height: 10px; border-radius: var(--radius-full);
    background: #6B7280; transition: background 0.3s;
}
.health-dot.ok   { background: #22C55E; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.health-dot.warn { background: var(--warning); box-shadow: 0 0 6px rgba(245,158,11,0.4); animation: pulse 2s infinite; }
.health-dot.error{ background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.4); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.activity-version {
    font-size: 9px; color: rgba(255,255,255,0.50); font-weight: 500;
}

/* ════════════════════════════════════
   ── 侧面板 (230px, 从 dock 右侧滑入) ──
   可读性方案: 浅色背景 + 高对比文字 (VS Code/GitHub 验证)
   旧方案 #111C2E + rgba(255,255,255,0.75) → 用户反馈"看不清"
   新方案 实体色文字 + 14px 字号 + 图标全不透明
   ════════════════════════════════════ */
.side-panel {
    position: fixed; top: 0; left: 56px; bottom: 0;
    width: 230px; z-index: 100;
    background: #F0F2F5;
    border-right: 1px solid var(--border-default);
    display: flex; flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.16,1,0.3,1);
    overflow-y: auto;
}
.side-panel.open { transform: translateX(0); }

/* Panel 章节 */
.panel-section[hidden] { display: none; }
.panel-section { display: flex; flex-direction: column; height: 100%; }

.panel-header {
    padding: 22px 18px 10px;
    font-size:var(--text-xs); font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: #64748B;  /* WCAG AA 4.56:1 on #F0F2F5 (12px bold = large text, needs 3:1 → passes) */
    flex-shrink: 0;
}

.panel-nav {
    flex: 1; padding: 6px 0; overflow-y: auto;
}

.panel-link {
    display: flex; align-items: center; gap:var(--space-3);
    margin: 0 8px; padding: 9px 12px; border-radius: var(--radius-md);
    color: var(--content-secondary, #374151); font-size:var(--text-sm); font-weight: 500;
    text-decoration: none;
    transition: all 0.12s ease;
}
.panel-link:hover {
    background: rgba(0,0,0,0.05); color: var(--content-primary, #111827);
}
.panel-link[aria-current="page"] {
    background: rgba(37,99,235,0.10); color: #1D4ED8; font-weight: 600;
}
.panel-link-icon { font-size:var(--text-base); width: 22px; text-align: center; flex-shrink: 0; }
.panel-link[aria-current="page"] .panel-link-icon { opacity: 1; }

/* ── 主内容区 ── */
.main-content.main-dock { margin-left: 56px; }
.main-content.main-dock.panel-open { margin-left: 276px; } /* 56 + 220 */

/* ── Navbar ── */
.navbar-dock { display: flex; align-items: center; gap: var(--spacing-md); }

/* ── Global Search ── */
.global-search {
    position: relative; width: 280px; margin-right: auto;
}
.search-icon {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); font-size:var(--text-sm); color: var(--content-tertiary);
    pointer-events: none;
}
.search-input {
    width: 100%; height: 34px; padding: 0 12px 0 34px;
    border: 1px solid var(--border-default); border-radius: var(--radius-md);
    background: var(--surface-base); font-size:var(--text-sm); font-family: inherit;
    color: var(--content-primary); outline: none; transition: all 0.15s;
}
.search-input:focus {
    border-color: var(--accent-emphasis); background: var(--surface-raised);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.search-input::placeholder { color: var(--border-strong); }
.search-results {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.12);
    max-height: 320px; overflow-y: auto; z-index: 998;
}
.search-result-item {
    display: block; padding: 9px 16px; text-decoration: none;
    color: var(--content-primary); font-size:var(--text-sm);
}
.search-result-item:hover { background: var(--surface-overlay); }
.search-empty { padding:var(--space-4); text-align: center; color: var(--border-strong); font-size:var(--text-sm); }

/* ── 隐藏旧 tab 栏 ── */
.dock-tabs { display: none; }

/* ── 响应式 ── */
@media (max-width: 768px) {
    .activity-bar { width: 48px; }
    .dock-btn-icon { font-size:var(--text-lg); }
    .dock-btn-label { display: none; }
    .side-panel { left: 48px; width: 200px; }
    .main-content.main-dock { margin-left:var(--space-12); }
    .main-content.main-dock.panel-open { margin-left: 248px; }
    .global-search { width: 160px; }
}

/* === intent-ui.css === */
/* ═══ P1 Intent UI Components — PRD R1-R5 ═══ */
/* Task Shell (首页卡片壳) + Task Workbench (任务工作台) */

/* ── Task Shell: 首页容器 ── */
.task-shell {
    padding: var(--spacing-xl) var(--spacing-2xl);
    max-width: 960px;
    margin: 0 auto;
}

.task-shell-header {
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

.task-shell-greeting {
    font-size:var(--text-2xl);
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 var(--spacing-xs);
}

.task-shell-subtitle {
    font-size:var(--text-sm);
    color: var(--color-text-secondary);
    margin: 0;
}

.task-shell-hint {
    text-align: center;
    font-size:var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: var(--spacing-lg);
}

.task-shell-skill {
    text-align: center;
    font-size:var(--text-xs);
    color: var(--color-text-disabled);
    margin-top: var(--spacing-sm);
}

.task-shell--empty {
    display: flex;
    justify-content: center;
    padding: var(--spacing-4xl) var(--spacing-lg);
}

/* ── Task Cards Grid ── */
.task-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-md);
}

/* ── Individual Task Card ── */
.task-card {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: var(--color-surface-card, var(--surface-raised));
    border: 1px solid var(--color-border-default, #E5E7EB);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

.task-card:hover {
    border-color: var(--color-brand-primary, #2563EB);
    box-shadow: 0 4px 16px rgba(37,99,235,0.08);
    transform: translateY(-1px);
}

.task-card--primary {
    border-color: var(--color-brand-primary, #2563EB);
    border-width: 2px;
    background: linear-gradient(135deg, rgba(37,99,235,0.03), rgba(37,99,235,0.01));
}

.task-card--L3 {
    border-left: 3px solid var(--color-feedback-success, #22C55E);
}

.task-card--L2 {
    border-left: 3px solid var(--color-feedback-warning, #F59E0B);
}

.task-card--L1 {
    border-left: 3px solid var(--color-feedback-info, #3B82F6);
}

.task-card-icon {
    font-size:var(--text-3xl);
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-page, #F9FAFB);
    border-radius: 10px;
}

.task-card-body {
    flex: 1;
    min-width: 0;
}

.task-card-label {
    display: block;
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.4;
}

.task-card-desc {
    display: block;
    font-size:var(--text-xs);
    color: var(--color-text-secondary);
    margin-top:var(--space-1);
}

.task-card-confidence {
    display: inline-block;
    font-size:var(--text-xs);
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    margin-top:var(--space-1);
}

.confidence-green { background: #DCFCE7; color: #166534; }
.confidence-yellow { background: #FEF3C7; color: #92400E; }
.confidence-gray { background: #F3F4F6; color: #4B5563; }  /* WCAG AA: 5.3:1 */

.task-card-arrow {
    font-size:var(--text-lg);
    color: var(--color-text-disabled);
    flex-shrink: 0;
    align-self: center;
    transition: transform 0.2s;
}

.task-card:hover .task-card-arrow {
    transform: translateX(4px);
    color: var(--color-brand-primary);
}

/* ── Correction Button ── */
.task-card-dismiss {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: var(--radius-full);
    background: rgba(0,0,0,0.05);
    color: var(--color-text-disabled);
    font-size:var(--text-xs);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.task-card:hover .task-card-dismiss {
    opacity: 1;
}

.task-card-dismiss:hover {
    background: rgba(239,68,68,0.1);
    color: var(--color-feedback-error);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: var(--spacing-4xl) var(--spacing-lg);
}

.empty-state-icon { font-size:var(--text-5xl); margin-bottom: var(--spacing-md); }
.empty-state h3 { margin: 0 0 var(--spacing-sm); color: var(--color-text-primary); }
.empty-state p { color: var(--color-text-secondary); margin: 0 0 var(--spacing-lg); }

/* ═══ Task Workbench ═══ */

.task-workbench {
    padding: var(--spacing-lg);
    max-width: 960px;
    margin: 0 auto;
}

.task-workbench-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.task-status {
    padding: 2px 10px;
    border-radius: var(--radius-lg);
    font-size:var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
}

.task-status--healthy { background: #DCFCE7; color: #166534; }
.task-status--paused { background: #FEF3C7; color: #92400E; }
.task-status--archived { background: #F3F4F6; color: #4B5563; }  /* WCAG AA: 5.3:1 */
.task-status--unknown { background: #F3F4F6; color: #4B5563; }  /* WCAG AA: 5.3:1 */

.task-workbench-title {
    margin: 0;
    font-size:var(--text-xl);
    font-weight: 700;
    color: var(--color-text-primary);
}

/* ── Workbench Grid ── */
.task-workbench-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

/* ── Workbench Panel ── */
.tw-panel {
    background: var(--color-surface-card, var(--surface-raised));
    border: 1px solid var(--color-border-default, #E5E7EB);
    border-radius: 10px;
    padding: var(--spacing-md);
}

.tw-panel-title {
    font-size:var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 0 0 var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tw-panel-desc {
    font-size:var(--text-sm);
    color: var(--color-text-primary);
    margin: 0 0 var(--spacing-sm);
}

/* ── Metric ── */
.tw-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
    border-bottom: 1px solid var(--color-border-default);
}

.tw-metric:last-child { border-bottom: none; }

.tw-metric-label {
    font-size:var(--text-xs);
    color: var(--color-text-secondary);
}

.tw-metric-value {
    font-size:var(--text-sm);
    font-weight: 600;
    color: var(--color-text-primary);
}

/* ── Evidence Chain ── */
.tw-evidence-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
    font-size:var(--text-sm);
}

.tw-evidence-cause { color: var(--color-text-secondary); }
.tw-evidence-arrow { color: var(--color-brand-primary); font-weight: 700; }
.tw-evidence-effect { color: var(--color-text-primary); flex: 1; }
.tw-evidence-confidence {
    font-size:var(--text-xs);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: #DCFCE7;
    color: #166534;
    font-weight: 600;
}

/* ── Checkpoints ── */
.tw-checkpoint {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
    font-size:var(--text-sm);
}

.tw-checkpoint-icon { font-size:var(--text-sm); }
.tw-checkpoint-label { color: var(--color-text-primary); flex: 1; }
.tw-checkpoint-note { color: var(--color-text-secondary); font-size:var(--text-xs); }

/* ── Risks ── */
.tw-risk {
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-xs);
    font-size:var(--text-sm);
}

.risk--high { background: #FEE2E2; border-left: 3px solid #EF4444; }
.risk--medium { background: #FEF3C7; border-left: 3px solid #F59E0B; }
.risk--low { background: #F3F4F6; border-left: 3px solid #9CA3AF; }

.tw-risk-desc {
    display: block;
    color: var(--color-text-primary);
    font-weight: 500;
}

.tw-risk-mitigation {
    display: block;
    color: var(--color-text-secondary);
    font-size:var(--text-xs);
    margin-top: 2px;
}

/* ── Deliverables ── */
.tw-deliverables {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-surface-card, var(--surface-raised));
    border: 1px solid var(--color-border-default, #E5E7EB);
    border-radius: 10px;
}

.tw-deliverable {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-md);
    background: var(--color-surface-page, #F9FAFB);
    text-decoration: none;
    color: var(--color-text-primary);
    font-size:var(--text-sm);
    transition: background 0.15s;
}

.tw-deliverable:hover { background: #EFF6FF; }

.tw-deliverable-name { font-weight: 500; }
.tw-deliverable-status {
    font-size:var(--text-xs);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: #DCFCE7;
    color: #166534;
}

/* ── Progress Bar ── */
.tw-progress {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) 0;
}

.tw-progress-bar {
    height: 6px;
    background: var(--color-brand-primary, #2563EB);
    border-radius: 3px;
    transition: width 0.5s ease;
    flex: 1;
}

.tw-progress-label {
    font-size:var(--text-xs);
    color: var(--color-text-secondary);
    white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .task-shell { padding: var(--spacing-md); }
    .task-cards { grid-template-columns: 1fr; }
    .task-workbench-grid { grid-template-columns: 1fr; }
    .tw-deliverables { flex-direction: column; align-items: stretch; }
}

/* === skeleton.css === */
/**
 * P0 UX Enhancement — Skeleton Loading Screens
 *
 * Usage: add .skeleton class to any container during data loading.
 * Replace with real content when data arrives.
 *
 * Pattern: replicating campaign-stats.css:173-182 shimmer animation.
 * Variables: references both tokens.css and main.css (with fallbacks).
 */

/* ═══ Shimmer Animation ═══ */
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ═══ Base Skeleton ═══ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-border-light, #F1F5F9) 25%,
        var(--color-border, #E2E8F0) 50%,
        var(--color-border-light, #F1F5F9) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
    pointer-events: none;
    user-select: none;
    border-radius: var(--radius-sm, 6px);
}

/* ═══ Text Placeholders ═══ */
.skeleton-text {
    height: 14px;
    margin-bottom: var(--spacing-sm, 8px);
    width: 100%;
}

.skeleton-text:last-child { width: 60%; }

.skeleton-text--sm  { width: 40%; }
.skeleton-text--lg  { height: 22px; width: 70%; }
.skeleton-text--full { width: 100%; }

/* ═══ Card Placeholder ═══ */
.skeleton-card {
    height: 120px;
    border-radius: var(--radius-lg, 12px);
}

/* ═══ Stat Card Placeholder ═══ */
.skeleton-stat {
    height: 96px;
    border-radius: var(--radius-lg, 12px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--spacing-sm, 8px);
    padding: var(--spacing-lg, 24px);
}

.skeleton-stat::before,
.skeleton-stat::after {
    content: '';
    display: block;
    border-radius: var(--radius-sm, 6px);
}

.skeleton-stat::before {
    /* Label line */
    height: 12px;
    width: 50%;
    background: var(--color-border, #E2E8F0);
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-stat::after {
    /* Value line */
    height: 28px;
    width: 75%;
    background: var(--color-border, #E2E8F0);
    animation: skeleton-shimmer 1.2s ease-in-out infinite 0.15s;
}

/* ═══ Table Placeholder ═══ */
.skeleton-table {
    border-radius: var(--radius-lg, 12px);
    overflow: hidden;
}

.skeleton-table-header {
    display: flex;
    gap: var(--spacing-md, 16px);
    padding: 10px var(--spacing-md, 16px);
    background: var(--color-bg-alt, #F8FAFC);
}

.skeleton-table-row {
    display: flex;
    gap: var(--spacing-md, 16px);
    padding:var(--space-3) var(--spacing-md, 16px);
    border-bottom: 1px solid var(--color-border-light, #F1F5F9);
}

.skeleton-table-row:last-child { border-bottom: none; }

.skeleton-table-cell {
    height: 14px;
    flex: 1;
    background: var(--color-border, #E2E8F0);
    border-radius: var(--radius-sm, 6px);
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-table-cell--xs { flex: 0.5; }
.skeleton-table-cell--sm { flex: 0.7; }
.skeleton-table-cell--lg { flex: 1.5; }
.skeleton-table-cell--xl { flex: 2; }

/* ═══ Avatar / Circle Placeholder ═══ */
.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full, 9999px);
}

.skeleton-avatar--sm { width: 28px; height: 28px; }
.skeleton-avatar--lg { width: 56px; height: 56px; }

/* ═══ Accessibility: reduced motion ═══ */
@media (prefers-reduced-motion: reduce) {
    .skeleton,
    .skeleton::before,
    .skeleton::after,
    .skeleton-table-cell {
        animation: none;
        background: var(--color-border-light, #F1F5F9);
    }
}

/* === toast.css === */
/**
 * P0 UX Enhancement — Toast Notification System
 *
 * Fixed-position notification toasts for action feedback.
 * Four types: success (green), error (red), warning (amber), info (blue).
 *
 * Variables: tokens.css with main.css fallbacks.
 */

/* ═══ Container ═══ */
.toast-container {
    position: fixed;
    top: var(--spacing-lg, 24px);
    right: var(--spacing-lg, 24px);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm, 8px);
    pointer-events: none;
    max-width: 380px;
    width: auto;
}

/* ═══ Single Toast ═══ */
.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm, 8px);
    padding:var(--space-3) var(--spacing-md, 16px);
    background: var(--color-surface-card, var(--surface-raised));
    border-radius: var(--radius-md, 8px);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    border-left: 4px solid var(--color-border, #E5E7EB);
    pointer-events: auto;
    animation: toast-slide-in 0.25s ease-out;
    font-size: var(--font-size-sm, 14px);
    color: var(--color-text-primary, var(--content-primary, #111827));
    line-height: 1.5;
    min-width: 280px;
}

/* ═══ Type Colors ═══ */
.toast--success { border-left-color: var(--color-success, #10B981); }
.toast--error   { border-left-color: var(--color-error, #EF4444); }
.toast--warning { border-left-color: var(--color-warning, #F59E0B); }
.toast--info    { border-left-color: var(--color-primary, #1E3A5F); }

/* ═══ Internal Layout ═══ */
.toast-icon {
    flex-shrink: 0;
    font-size:var(--text-base);
    line-height: 1.5;
}

.toast--success .toast-icon { color: var(--color-success, #10B981); }
.toast--error   .toast-icon { color: var(--color-error, #EF4444); }
.toast--warning .toast-icon { color: var(--color-warning, #F59E0B); }
.toast--info    .toast-icon { color: var(--color-primary, #1E3A5F); }

.toast-msg {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size:var(--text-lg);
    line-height: 1;
    color: var(--color-text-muted, #94A3B8);
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm, 6px);
    transition: color 0.15s, background 0.15s;
}

.toast-close:hover {
    color: var(--color-text, #0F172A);
    background: var(--color-bg-alt, #F8FAFC);
}

/* ═══ Enter/Exit Animation ═══ */
@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.toast--leaving {
    animation: toast-slide-out 0.2s ease-in forwards;
}

@keyframes toast-slide-out {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

/* ═══ Responsive: Mobile = full-width bottom ═══ */
@media (max-width: 640px) {
    .toast-container {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        max-width: none;
        padding: var(--spacing-sm, 8px);
    }

    .toast {
        min-width: 0;
        border-radius: var(--radius-md, 8px);
        animation: toast-slide-up 0.25s ease-out;
    }

    .toast--leaving {
        animation: toast-slide-down 0.2s ease-in forwards;
    }
}

@keyframes toast-slide-up {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@keyframes toast-slide-down {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(100%); opacity: 0; }
}

/* ═══ Accessibility ═══ */
@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }
    .toast--leaving {
        animation: none;
        opacity: 0;
    }
}

/* ═══════════════════════════════════════════
   Converge App Shell (extracted from index.latte + main.latte)
   Traditional sidebar + topbar layout
   依赖: design-tokens.css
   ═══════════════════════════════════════════ */

/* ── 全局重置 ── */
*,::before,::after{box-sizing:border-box}
html{-webkit-font-smoothing:antialiased}
body{margin:0;font-family:var(--font-sans);font-size:var(--text-sm);background:var(--bg-base);color:var(--text-secondary);line-height:1.5}

/* ── App Shell ── */
.app-shell{display:flex;min-height:100vh}
.app-main{flex:1;min-width:0;display:flex;flex-direction:column}

/* ── 侧边栏 (Stitch 深色主题 — 所有 hex 均为 dark theme token) ── */
/* token */ .app-sidebar{display:flex;flex-direction:column;background:#131315;border-right:1px solid #1f1f22;transition:width var(--motion-normal);flex-shrink:0;overflow:hidden;position:sticky;top:0;height:100vh;z-index:100}
.sidebar-brand-row{display:flex;align-items:center;justify-content:space-between;padding:var(--space-3) var(--space-4)}
.sidebar-search-btn{background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.1);border-radius:6px;padding:3px 8px;cursor:pointer;display:flex;align-items:center;gap:4px;transition:all .15s}
.sidebar-search-btn:hover{background:rgba(255,255,255,0.1);border-color:rgba(255,255,255,0.15)}
.sidebar-search-hint{font-family:var(--font-mono);font-size:10px;color:rgba(255,255,255,0.3);letter-spacing:0.05em}
.sidebar-section-icon{font-size:16px;vertical-align:middle;margin-right:4px;opacity:0.6}
.sidebar-shortcut{font-family:var(--font-mono);font-size:9px;color:rgba(255,255,255,0.2);margin-left:auto;padding:1px 4px;border-radius:3px;background:rgba(255,255,255,0.05);display:none}
.sidebar-link:hover .sidebar-shortcut{display:inline-block}
/* token */ .sidebar-role-badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:9px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;background:rgba(99,102,241,0.15);color:#a5b4fc;margin-bottom:4px}
/* token */ .app-sidebar .sidebar-brand{color:#e5e1e4}
.app-sidebar .sidebar-section{color:rgba(255,255,255,0.35);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:var(--space-2) var(--space-4);margin-top:var(--space-2)}
/* token */ .app-sidebar .sidebar-link{color:#c7c4d7;border-left:2px solid transparent}
/* token */ .app-sidebar .sidebar-link:hover{background:rgba(255,255,255,0.04);color:#e5e1e4}
/* token */ .app-sidebar .sidebar-link.active{background:rgba(99,102,241,0.1);color:#c0c1ff;border-left-color:#6366f1;font-weight:500}
/* token */ .app-sidebar .sidebar-footer{color:rgba(255,255,255,0.25);border-top:1px solid rgba(255,255,255,0.06)}
.app-sidebar.is-expanded{width:240px}
.app-sidebar.is-collapsed{width:60px}
.app-sidebar.is-collapsed .sidebar-brand{justify-content:center;padding:0}
.app-sidebar.is-collapsed .sidebar-link{justify-content:center;padding:0}
.app-sidebar.is-collapsed .sidebar-label{display:none}
#mobile-sidebar-toggle{display:none}
@media(max-width:768px){
  #mobile-sidebar-toggle{display:block}
  .app-sidebar{position:fixed;left:-240px;transition:left var(--motion-normal);z-index:150}
  .app-sidebar.mobile-open{left:0;box-shadow:4px 0 24px rgba(0,0,0,0.5)}
  .st-grid-4,.st-grid-3,[style*="grid-template-columns:repeat(5"]{grid-template-columns:repeat(2,1fr)!important}
}
@media(max-width:480px){
  .st-grid-4,.st-grid-3,[style*="grid-template-columns:repeat(5"]{grid-template-columns:1fr!important}
  .st-kpi-value{font-size:1.5rem}
}
.app-sidebar.is-collapsed.is-hovered{width:240px}
.app-sidebar.is-collapsed.is-hovered .sidebar-label{display:initial}
.app-sidebar.is-collapsed.is-hovered .sidebar-brand{justify-content:flex-start;padding:0 20px}
.app-sidebar.is-collapsed.is-hovered .sidebar-link{justify-content:flex-start;padding:0 20px}

.sidebar-brand{
  display:flex;align-items:center;gap:10px;height:56px;padding:0 20px;
  border-bottom:1px solid var(--border-default);text-decoration:none;
}
.brand-dot{width:10px;height:10px;border-radius:50%;background:var(--accent);box-shadow:var(--shadow-glow);flex-shrink:0}
.brand-text{font-weight:700;font-size:var(--text-base);color:var(--text-primary);white-space:nowrap;letter-spacing:-0.3px}

/* ── 导航链接 ── */
.sidebar-nav{flex:1;padding:12px 0;display:flex;flex-direction:column;gap:2px;overflow-y:auto}
.sidebar-link{
  display:flex;align-items:center;gap:10px;height:40px;padding:0 20px;
  color:var(--text-secondary);text-decoration:none;font-size:var(--text-sm);
  white-space:nowrap;transition:all var(--motion-fast);
  border-left:2px solid transparent;position:relative;
}
.sidebar-link:hover{background:var(--bg-overlay);color:var(--text-primary)}
.sidebar-link.active{background:var(--accent-soft);color:var(--accent);border-left-color:var(--accent);font-weight:500}
.sidebar-link-icon{width:20px;text-align:center;flex-shrink:0;font-size:16px;display:flex;align-items:center;justify-content:center}
.sidebar-link-icon svg{width:20px;height:20px;flex-shrink:0}
.sidebar-link-label{overflow:hidden;text-overflow:ellipsis}
.sidebar-badge{margin-left:auto;font-size:10px;padding:1px 6px;border-radius:var(--radius-full);background:var(--accent-soft);color:var(--accent)}

.sidebar-footer{padding:12px 20px;border-top:1px solid var(--border-default);font-size:var(--text-xs);color:var(--text-tertiary)}

/* ── 顶部栏 ── */
.app-topbar{
  display:flex;align-items:center;justify-content:space-between;
  height:56px;padding:0 24px;background:var(--bg-raised);
  border-bottom:1px solid var(--border-default);position:sticky;top:0;z-index:50;
}
.topbar-left,.topbar-right{display:flex;align-items:center;gap:12px}
.topbar-page-title{font-size:var(--text-sm);font-weight:600;color:var(--text-primary)}
.theme-toggle-btn{background:none;border:none;cursor:pointer;font-size:16px;padding:0;line-height:1}
.topbar-btn-icon{
  display:flex;align-items:center;justify-content:center;
  width:36px;height:36px;border-radius:var(--radius-md);border:none;
  background:transparent;color:var(--text-secondary);cursor:pointer;
  transition:all var(--motion-fast);
}
.topbar-btn-icon:hover{background:var(--bg-overlay);color:var(--text-primary)}

/* ── 角色按钮 ── */
.topbar-btn-role{
  display:flex;align-items:center;gap:6px;height:28px;padding:0 10px;
  border:1px solid var(--accent-soft);border-radius:var(--radius-sm);
  background:var(--accent-soft);color:var(--accent);
  font-size:var(--text-xs);font-weight:500;cursor:pointer;
  transition:all var(--motion-fast);
}
.topbar-btn-role:hover{border-color:var(--accent)}
.topbar-role-dot{width:8px;height:8px;border-radius:50%}
.role-admin{background:var(--accent);box-shadow:0 0 6px var(--accent-glow)}
.role-manager{background:var(--warning)}
.role-buyer{background:var(--info)}

/* ── 下拉菜单 ── */
.topbar-dropdown-wrap{position:relative}
.topbar-dropdown{
  position:absolute;top:calc(100% + 6px);left:0;min-width:180px;padding:4px;
  background:var(--bg-overlay);border:1px solid var(--border-strong);
  border-radius:var(--radius-md);box-shadow:var(--shadow-lg);z-index:200;
}
.topbar-dropdown.right{left:auto;right:0}
.topbar-dropdown-item{
  display:flex;align-items:center;gap:8px;width:100%;padding:7px 12px;
  border:none;border-radius:var(--radius-sm);background:transparent;
  color:var(--text-secondary);font-size:var(--text-xs);cursor:pointer;
  transition:all var(--motion-fast);font-family:var(--font-sans);
  text-decoration:none;
}
.topbar-dropdown-item:hover{background:var(--accent-soft);color:var(--text-primary)}
.topbar-dropdown-item.active{color:var(--accent);font-weight:500}
.topbar-dropdown-item.text-danger{color:var(--danger)}
.topbar-dropdown-item.text-danger:hover{background:var(--danger-soft)}
.topbar-dropdown-header{padding:7px 12px 8px;font-size:var(--text-xs);color:var(--text-tertiary);border-bottom:1px solid var(--border-default);margin-bottom:4px}
.topbar-dropdown-divider{border:none;border-top:1px solid var(--border-default);margin:4px 0}

/* ── 用户头像 ── */
.topbar-btn-avatar{
  display:flex;align-items:center;justify-content:center;
  width:32px;height:32px;border-radius:50%;border:1px solid var(--border-default);
  background:var(--bg-overlay);cursor:pointer;padding:0;overflow:hidden;
  transition:all var(--motion-fast);
}
.topbar-btn-avatar:hover{border-color:var(--accent);box-shadow:var(--shadow-glow)}
.avatar-img{width:100%;height:100%;object-fit:cover;border-radius:50%}
.avatar-placeholder{font-size:var(--text-sm);font-weight:600;color:var(--accent)}

/* ── 内容区 ── */
.app-content{flex:1;padding:24px;overflow:auto;background:var(--bg-base);min-width:0}
.app-content > * {max-width:1280px;margin:0 auto;width:100%}

/* ── 404 ── */
.page-404{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:400px;gap:var(--space-4,16px);text-align:center}
.page-404-icon{font-size:64px;opacity:0.3}

/* ── 通用按钮 (全局复用) ── */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  padding:8px 18px;border:none;border-radius:var(--radius-md);
  font-family:var(--font-sans);font-size:var(--text-sm);font-weight:500;
  cursor:pointer;text-decoration:none;transition:all var(--motion-fast);
}
.btn:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.btn:disabled{opacity:.4;cursor:not-allowed}
.btn-primary{background:var(--accent);color:var(--text-inverse)}
.btn-primary:hover:not(:disabled){background:var(--accent-hover);box-shadow:var(--shadow-glow)}
.btn-ghost{background:transparent;color:var(--text-secondary);border:1px solid var(--border-default)}
.btn-ghost:hover{background:var(--bg-overlay);color:var(--text-primary);border-color:var(--border-strong)}
.btn-danger{background:var(--danger);color:#fff}
.btn-danger:hover:not(:disabled){background:#e64560;box-shadow:0 0 16px rgba(255,77,109,.3)}

/* ── 时间筛选器 (main.latte) ── */
.topbar-time-filter { position: relative; }
.topbar-btn-filter {
  display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--bg-base); color: var(--text-secondary);
  font-size: var(--text-xs); cursor: pointer;
  transition: all var(--motion-fast);
}
.topbar-btn-filter:hover { border-color: var(--border-strong); color: var(--text-primary); }

/* ── 用户菜单 (main.latte) ── */
.topbar-user { position: relative; }

/* ── Dashboard 独立链接 ── */
.sidebar-section-spacer { height: 8px; }

/* ── 侧边栏分组 (details/summary 原生手风琴) ── */
.sidebar-group-details { margin-top: 6px; }
.sidebar-group-details > summary {
  list-style: none; /* hide default triangle */
  padding: 12px 20px 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-tertiary);
  cursor: pointer; user-select: none;
  border-left: 3px solid transparent;
  transition: all var(--motion-fast);
  outline: none;
}
.sidebar-group-details > summary::-webkit-details-marker { display: none; }
.sidebar-group-details > summary:hover { color: var(--text-secondary); }
.sidebar-group-details[open] > summary {
  color: var(--accent);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), transparent);
}

/* ── 二级菜单层级缩进 ── */
.sidebar-group {
  margin-left: 8px; padding-left: 8px;
  border-left: 1px solid var(--border-default);
}
.sidebar-group .sidebar-link {
  padding-left: 16px;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
}
.sidebar-group .sidebar-link:hover { color: var(--text-primary); }
.sidebar-group .sidebar-link.active { color: var(--accent); font-weight: 500; }

/* ── 搜索框 ── */
.global-search { position: relative; display: flex; align-items: center; }
.search-input {
  width: 320px; height: 36px; padding: 0 40px 0 36px;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--bg-base); color: var(--text-primary);
  font-size: var(--text-sm); outline: none;
  transition: border-color var(--motion-fast);
}
.search-input:focus { border-color: var(--accent); }
.search-icon { position: absolute; left: 12px; font-size: 14px; opacity: 0.5; pointer-events: none; }
.search-shortcut-hint {
  position: absolute; right: 10px; font-size: 10px; padding: 1px 5px;
  background: var(--bg-overlay); border: 1px solid var(--border-default);
  border-radius: 3px; color: var(--text-tertiary); font-family: var(--font-mono);
}
.search-results-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  z-index: 999; max-height: 320px; overflow-y: auto;
}
.search-result-item {
  display: block; padding: 8px 12px; font-size: var(--text-sm);
  color: var(--text-primary); text-decoration: none;
  transition: background var(--motion-fast);
}
.search-result-item:hover { background: var(--accent-soft); }

/* ── 导航栏日期 ── */
.navbar-date { font-size: var(--text-xs); color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.navbar-tz { font-size: var(--text-xs); color: var(--accent); font-weight: 500; border: 1px solid var(--border-default); padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.tz-dropdown { position: absolute; top: 100%; right: 0; margin-top: 4px; background: var(--bg-raised); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); min-width: 120px; z-index: 999; padding: 4px 0; }
.tz-item { display: block; padding: 6px 14px; font-size: 12px; text-decoration: none; color: var(--text-secondary); transition: background 0.1s; }
.tz-item:hover { background: var(--accent-soft); color: var(--accent); }

/* ── Turbo Drive 进度条 — SPA 导航指示 ── */
.turbo-progress-bar {
  position: fixed; top: 0; left: 0; z-index: 99999;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(0, 240, 168, 0.5);
  transition: width 0.3s ease;
}
/* Content area transition */
.app-content {
  transition: opacity 0.15s ease;
}
.turbo-loading .app-content {
  opacity: 0.5;
}
/* Permanent elements stay sharp during navigation */
[data-turbo-permanent] {
  opacity: 1 !important;
}

/* ── 微动效 (P0) ── */
.card, .kpi-card, .panel-link, .sidebar-link, .btn, .insight-item, .dropdown-item {
  transition: all 0.15s ease;
}
.sidebar-link, .panel-link {
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

/* ── 响应式 ── */
@media (max-width:768px){
  .app-sidebar.is-expanded{position:fixed;left:0;top:0;z-index:300;box-shadow:var(--shadow-lg)}
  .app-sidebar.is-collapsed{transform:translateX(-100%)}
  .app-content{padding:var(--space-4,16px)}
  .topbar-page-title{display:none}
  .topbar-btn-filter span { display: none; }
}
/* ═══════════════════════════════════════════
   Converge Dashboard Page Styles (extracted from pages/dashboard.latte)
   依赖: design-tokens.css, grid.css
   ═══════════════════════════════════════════ */

/* ═══════════════════════════════════════════
   一、原子工具类 (Atomic CSS)
   注: .flex 由 app-bundle.css 提供
   ═══════════════════════════════════════════ */

/* ── 布局 ── */
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.relative { position: relative; }
.min-w-0 { min-width: 0; }

/* ── 间距 ── */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-6 { margin-bottom: 24px; }
.m-0 { margin: 0; }

/* ── 排版 ── */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 颜色 (基于 Design Tokens) ── */
.text-primary   { color: var(--text-primary); }

/* ═══════════════════════════════════════════
   微动效增强 (P0)
   ═══════════════════════════════════════════ */
.kpi-card, .card, .insight-item, .btn, .dropdown-item, .panel-link {
  transition: all 0.15s ease;
}
.kpi-card:hover, .card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

/* ═══════════════════════════════════════════
   二、页面根容器
   ═══════════════════════════════════════════ */
.dashboard-root {
  display: flex; flex-direction: column;
}

/* ═══════════════════════════════════════════
   三、角色切换按钮
   ═══════════════════════════════════════════ */
.role-btn {
  padding: 6px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-raised);
  color: var(--text-primary); cursor: pointer;
  transition: all var(--motion-fast); font-family: inherit;
}
.role-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 240, 168, 0.15);
}
.role-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.role-admin   { background: var(--accent); box-shadow: 0 0 6px rgba(0, 240, 168, 0.4); }
.role-manager { background: var(--warning); }
.role-buyer   { background: var(--info); }

/* ── 下拉菜单 (通用) ── */
.dropdown-menu {
  position: absolute; top: calc(100% + 6px);
  min-width: 200px; padding: 4px; z-index: 200;
  background: var(--color-surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.dropdown-menu.right { right: 0; left: auto; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; border: none;
  border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary);
  font-size: 0.75rem; cursor: pointer; font-family: inherit;
  transition: all var(--motion-fast);
}
.dropdown-item:hover {
  background: var(--accent-soft); color: var(--text-primary);
}
.dropdown-item.active { color: var(--accent); font-weight: 500; }

/* ═══════════════════════════════════════════
   四、KPI 卡片 (4 列 Grid)
   ═══════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.kpi-card {
  padding: 20px; border-radius: var(--radius-lg);
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  transition: all var(--motion-fast);
  position: relative; overflow: hidden;
}
.kpi-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px); box-shadow: var(--shadow-md);
}
.kpi-icon { font-size: 18px; line-height: 1; }
.kpi-value {
  font-size: 1.75rem; font-weight: 700; color: var(--text-primary);
  line-height: 1.2; font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}
.kpi-change {
  font-size: 0.875rem; font-weight: 600;
  display: flex; align-items: center; gap: 2px;
}

/* ═══════════════════════════════════════════
   五、主网格 (图表 2fr + AI 面板 1fr)
   ═══════════════════════════════════════════ */
.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px; align-items: start;
}

/* ── 通用卡片 ── */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}
.card-title {
  font-size: 0.875rem; font-weight: 600;
  color: var(--text-primary); margin: 0;
}
.card-body { padding: 16px; position: relative; }
.card-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border-default);
}

/* ── 图例 ── */
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.75rem; color: var(--text-tertiary);
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── ECharts 容器 ── */
.chart-container { width: 100%; height: 340px; }
.chart-empty {
  height: 340px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-tertiary); font-size: 0.875rem;
}
.empty-icon { font-size: 36px; opacity: 0.4; }

/* ═══════════════════════════════════════════
   六、AI 洞察面板 (磨砂玻璃)
   ═══════════════════════════════════════════ */
.glass {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-color: var(--border-default);
  position: relative; overflow: hidden;
}
html.dark .glass {
  background: rgba(17, 24, 32, 0.65);
  border-color: rgba(255, 255, 255, 0.08);
}
/* 左上角装饰发光 */
.glass::before {
  content: '';
  position: absolute; top: -40px; left: -40px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 168, 0.05), transparent 70%);
  pointer-events: none;
}

/* AI 脉冲指示灯 */
.ai-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 168, 0.4);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.6); }
}

/* 旋转动画 (刷新按钮) */
.animate-spin { animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 洞察列表 ── */
.insight-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.insight-item {
  display: flex; gap: 10px; padding: 10px 14px;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--motion-fast);
}
.insight-item:hover {
  background: var(--accent-soft);
  border-color: rgba(0, 240, 168, 0.15);
}
.insight-bullet {
  width: 4px; min-width: 4px; height: 4px; margin-top: 7px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 6px rgba(0, 240, 168, 0.3);
}

/* ═══════════════════════════════════════════
   七、按钮 (最小化)
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius-md);
  font-family: inherit; font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all var(--motion-fast);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255,255,255,0.04); color: var(--text-primary);
}
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* ═══════════════════════════════════════════
   八、Badge (内联原子)
   ═══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 0.625rem; font-weight: 600; letter-spacing: 0.5px;
}
.badge-info {
  background: var(--color-info-soft); color: var(--info);
}

/* ═══════════════════════════════════════════
   九、响应式 (Mobile-first for boss on phone)
   ═══════════════════════════════════════════ */
@media (max-width: 1200px) {
  .kpi-grid  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .main-grid { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .kpi-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-card   { padding: 12px; }
  .kpi-value  { font-size: 1.25rem; }
  .chart-container { height: 240px; }
  .insight-list { gap: 8px; }
  .insight-item { padding: 8px 10px; }
  .card { border-radius: var(--radius-md); }
}
@media (max-width: 480px) {
  .dashboard-root { padding: 12px; }
  .kpi-grid  { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .kpi-card   { padding: 12px 14px; flex-direction: row; align-items: center; gap: 10px; }
  .kpi-value  { font-size: 1.3rem; }
  .kpi-icon   { font-size: 20px; }
  .chart-container { height: 200px; }
  .card-header { padding: 10px 14px; }
  .card-body   { padding: 8px 12px; }
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1rem; }
  .role-btn { font-size: 0.75rem; padding: 4px 8px; }
  .glass { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .main-grid { gap: 12px; }
}

/* ═══════════════════════════════════════════
   P0 inline style elimination utilities
   ═══════════════════════════════════════════ */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-3 { margin-bottom: 12px; }
.mt-0 { margin-top: 0; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.overflow-hidden { overflow: hidden; }
.p-2 { padding: 8px; }

/* ── Link-as-button (proof.latte) ── */
.btn-link {
  display: inline-flex; align-items: center;
  padding: 10px 20px; border-radius: 8px; text-decoration: none;
}
.btn-link-accent { background: var(--accent); color: #fff; font-weight: 500; }
.btn-link-ghost {
  background: var(--surface-overlay); color: var(--content-primary);
}

/* ── Card section header (reused across attribution/reports) ── */
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}

/* ── Table full-width + font-size helper ── */
.table-data {
  width: 100%; border-collapse: collapse; font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════
   十、复用卡片 & 表格 (从 dashboard.css 合并)
   注: .sidebar-link 已移除—定义权归 app-shell.css
   ═══════════════════════════════════════════ */

/* ── 通用卡片 ── */
.dash-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  transition: box-shadow .2s;
}
.dash-card:hover { box-shadow: 0 4px 24px rgba(0,0,0,.06); }

/* ── 统计卡 (icon + value + label 纵向) ── */
.stat-card {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 20px 24px;
}
.stat-card .stat-icon { font-size: 28px; line-height: 1; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--content-primary); line-height: 1.1; }
.stat-card .stat-label { font-size: 12px; color: var(--content-tertiary); margin-top: 2px; }

/* ── 数据表格 ── */
.data-table {
  width: 100%; border-collapse: collapse;
}
.data-table thead th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--content-tertiary);
  background: var(--surface-overlay);
  border-bottom: 1px solid var(--border-default);
}
.data-table tbody td {
  padding: 14px 16px; font-size: 14px; color: var(--content-secondary);
  border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,.04));
}
.data-table tbody tr:hover td { background: var(--surface-overlay); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Badge 补充 (dashboard.css 版本, 保留兼容) ── */
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-default { background: var(--surface-overlay); color: var(--content-tertiary); }

/* ── 页面头部 ── */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--content-primary); }
.page-header p { font-size: 13px; color: var(--content-tertiary); margin-top: 2px; }

/* ── 空状态 ── */
.empty-state {
  text-align: center; padding: 64px 24px;
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--content-primary); margin-bottom: 4px; }
.empty-state-desc { font-size: 14px; color: var(--content-tertiary); margin-bottom: 24px; }

/* ═══════════════════════════════════════════
   十一、Subscription 页面 (提取自 subscription.latte)
   ═══════════════════════════════════════════ */
.sub-card { background: var(--surface-raised); border-radius: 10px; border: 1px solid var(--border-default); padding: 20px; }
.sub-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 16px; }
.sub-title { font-size: 15px; font-weight: 700; color: var(--content-primary); margin: 0 0 16px; }
.sub-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--content-tertiary); }
.sub-plan-name { font-size: 24px; font-weight: 700; color: var(--content-primary); margin: 4px 0; }
.sub-price { font-size: 24px; font-weight: 800; color: var(--accent-emphasis); }
.sub-price-sm { font-size: 14px; }
.sub-price-period { font-size: 13px; color: var(--content-tertiary); font-weight: 400; }
.sub-details { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.sub-row { display: flex; justify-content: space-between; }
.sub-value { color: var(--content-primary); font-weight: 600; }
.sub-text { color: var(--content-secondary); }
.sub-usage-track { height: 10px; background: var(--surface-overlay); border-radius: 5px; overflow: hidden; }
.sub-usage-fill { height: 100%; border-radius: 5px; transition: width .3s; }
.sub-usage-warn { font-size: 12px; color: var(--warning); margin: 6px 0 0 0; }
.sub-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.sub-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center; }
.sub-plan { padding: 16px; border-radius: 8px; border: 1px solid var(--border-default); background: var(--surface-raised); }
.sub-plan.current { border-color: var(--accent-emphasis); background: var(--accent-soft); }
.sub-plan-price { font-size: 20px; font-weight: 800; color: var(--accent-emphasis); margin-bottom: 8px; }
.sub-plan-name-sm { font-weight: 700; font-size: 15px; color: var(--content-primary); margin-bottom: 4px; }
.sub-plan-features { font-size: 11px; color: var(--content-secondary); line-height: 1.6; }
.sub-badge-current { margin-top: 8px; padding: 4px 10px; background: var(--accent-emphasis); color: var(--content-inverse); border-radius: 4px; font-size: 11px; font-weight: 600; display: inline-block; }
.sub-upgrade-link { margin-top: 8px; display: inline-block; font-size: 12px; color: var(--accent-emphasis); }
.sub-btn-full { width: 100%; text-align: center; }
.sub-table-wrap { overflow-x: auto; }
.sub-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sub-table thead tr { background: var(--surface-overlay); }
.sub-table th { padding: 10px 20px; text-align: left; font-size: 12px; color: var(--content-secondary); }
.sub-table th:not(:first-child) { padding: 10px 12px; }
.sub-table td { padding: 8px 20px; font-size: 13px; color: var(--content-primary); }
.sub-table td:not(:first-child) { padding: 8px 12px; }
.sub-table tbody tr { border-bottom: 1px solid var(--border-default); }
.sub-table .sub-value-cell { font-weight: 600; }
.sub-section-header { padding: 16px 20px; border-bottom: 1px solid var(--border-default); }
.sub-section-header h3 { font-size: 14px; font-weight: 600; color: var(--content-primary); margin: 0; }
.sub-card-no-pad { background: var(--surface-raised); border-radius: 10px; border: 1px solid var(--border-default); overflow: hidden; margin-bottom: 20px; }
.sub-main-title { font-size: 24px; font-weight: 700; color: var(--content-primary); margin: 4px 0; }

/* ═══════════════════════════════════════════
   十二、Setup Wizard (提取自 organisms/setup-wizard.latte)
   ═══════════════════════════════════════════ */
.wiz-root { max-width: 680px; margin: 0 auto; padding: var(--space-4); }
.wiz-form { background: var(--surface-raised); border:1px solid var(--border-default); border-radius: var(--radius-lg, 12px); padding: var(--space-6); }
.wiz-section-title { font-size: var(--text-lg); margin-bottom: var(--space-4); margin-top: 0; }
.wiz-field { margin-bottom: var(--space-4); }
.wiz-label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-1); color: var(--content-primary); }
.wiz-input { width: 100%; padding: 10px 14px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); font-size: var(--text-base); background: var(--surface-base); color: var(--content-primary); box-sizing: border-box; }
.wiz-select { width: 100%; padding: 10px 14px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); font-size: var(--text-base); background: var(--surface-base); color: var(--content-primary); box-sizing: border-box; }
.wiz-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
.wiz-hint { font-size: var(--text-xs); color: var(--content-tertiary); margin-top: var(--space-1); }
.wiz-msg-success { background: var(--surface-success); color: var(--content-success); padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); margin-bottom: var(--space-4); font-weight: 500; }
.wiz-msg-error { background: var(--surface-danger); color: var(--content-danger); padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); margin-bottom: var(--space-4); }
.wiz-review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-6); margin-bottom: var(--space-4); }
.wiz-review-label { color: var(--content-tertiary); font-size: var(--text-xs); }
.wiz-review-value { font-weight: 600; }
.wiz-preview-box { background: var(--surface-overlay); border: 1px solid var(--border-default); border-radius: var(--radius-sm); padding: var(--space-3); margin-bottom: var(--space-4); text-align: center; }
.wiz-preview-label { font-size: var(--text-xs); color: var(--content-tertiary); margin-right: var(--space-2); }
.wiz-preview-link { font-size: var(--text-sm); color: var(--accent); word-break: break-all; }
.wiz-done { text-align: center; padding: var(--space-8) 0; }
.wiz-done-icon { font-size: 3rem; display: block; margin-bottom: var(--space-4); }
.wiz-done-title { font-size: var(--text-xl); margin-bottom: var(--space-2); margin-top: 0; }
.wiz-done-desc { color: var(--content-tertiary); margin-bottom: var(--space-6); }
.wiz-done-success { color: var(--content-success); font-weight: 500; margin-bottom: var(--space-6); }
.wiz-done-actions { display: flex; gap: var(--space-3); justify-content: center; }
.wiz-btn-primary { display: inline-flex; padding: 12px 32px; background: var(--accent); color: var(--text-inverse); border: none; border-radius: var(--radius-sm); font-size: var(--text-base); font-weight: 600; cursor: pointer; text-decoration: none; }
.wiz-btn-secondary { display: inline-flex; padding: 10px 24px; background: var(--surface-overlay); color: var(--content-primary); border: 1px solid var(--border-default); border-radius: var(--radius-sm); text-decoration: none; font-weight: 500; }
.wiz-nav { display: flex; justify-content: space-between; margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.wiz-nav-btn-back { padding: 10px 20px; background: var(--surface-overlay); color: var(--content-primary); border: 1px solid var(--border-default); border-radius: var(--radius-sm); cursor: pointer; font-size: var(--text-sm); }
.wiz-nav-btn-next { padding: 10px 24px; background: var(--accent); color: var(--text-inverse); border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: var(--text-sm); }
.wiz-skip-hint { text-align: center; margin-top: var(--space-4); font-size: var(--text-xs); color: var(--content-tertiary); }
.wiz-hint-link { color: var(--accent); }

/* ═══════════════════════════════════════════
   十三、Proof 自检面板 (提取自 pages/proof.latte)
   ═══════════════════════════════════════════ */
.proof-toolbar { margin-bottom: var(--space-6); }
.proof-btn { display: inline-flex; padding: 10px 20px; background: var(--accent); color: var(--text-inverse); border-radius: 8px; text-decoration: none; font-weight: 500; }
.proof-btn-secondary { display: inline-flex; padding: 10px 20px; margin-left: 8px; background: var(--surface-overlay); color: var(--content-primary); border-radius: 8px; text-decoration: none; }
.proof-trend-hint { margin-left: 12px; color: var(--content-tertiary); font-size: var(--text-sm); }
.proof-empty { text-align: center; padding: var(--space-12) 0; }
.proof-empty-title { color: var(--content-tertiary); }
.proof-empty-desc { color: var(--content-tertiary); margin-top: 8px; }
.proof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); }
.proof-card { background: var(--surface-raised); border: 1px solid var(--border-default); border-radius: 12px; padding: var(--space-4); }
.proof-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }
.proof-badge { font-size: var(--text-sm); padding: 4px 10px; border-radius: 12px; font-weight: 500; }
.proof-badge-pass { background: var(--surface-success); color: var(--content-success); }
.proof-badge-fail { background: var(--surface-danger); color: var(--content-danger); }
.proof-stats { display: flex; gap: 20px; font-size: var(--text-sm); color: var(--content-secondary); }
.proof-section { margin-top: var(--space-8); }
.proof-section-sm { margin-top: var(--space-6); }
.proof-section-title { font-size: var(--text-lg); margin-bottom: var(--space-3); }
.proof-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.proof-table thead tr { text-align: left; border-bottom: 2px solid var(--border-default); }
.proof-table th { padding: 8px; }
.proof-table td { padding: 8px; }
.proof-table tbody tr { border-bottom: 1px solid var(--border-subtle); }
.proof-td-fail { color: var(--content-danger); }
.proof-td-muted { color: var(--content-tertiary); }

/* ═══════════════════════════════════════════
   十四、Data Table 组件 (提取自 molecules/data-table.latte)
   ═══════════════════════════════════════════ */
.dt-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border-default); border-radius: var(--radius-lg, 12px); background: var(--bg-card); }
.dt-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm, 0.875rem); }
.dt-th { padding: 12px 16px; text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; border-bottom: 1px solid var(--border-default); background: var(--bg-raised); }
.dt-th:first-child { border-radius: var(--radius-lg, 12px) 0 0 0; }
.dt-th:last-child { border-radius: 0 var(--radius-lg, 12px) 0 0; }
.dt-th-actions { text-align: right; }
.dt-td { padding: 12px 16px; color: var(--text-secondary); border-bottom: 1px solid var(--border-default); white-space: nowrap; }
.dt-td-actions { text-align: right; }
.dt-striped .dt-tr:nth-child(even) .dt-td { background: rgba(255,255,255,0.015); }
.dt-hover .dt-tr:hover .dt-td { background: var(--accent-soft); }
.dt-actions { display: flex; gap: 4px; justify-content: flex-end; }
.dt-action-btn { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-default); background: transparent; color: var(--text-secondary); font-size: var(--text-xs); cursor: pointer; transition: all var(--motion-fast); }
.dt-action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.dt-action-icon { font-size: 13px; line-height: 1; }
.dt-action-label { font-weight: 500; }
.dt-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-12) 20px; text-align: center; }
.dt-empty-icon { font-size: 40px; margin-bottom: var(--space-4); opacity: 0.6; }
.dt-empty-text { color: var(--text-tertiary); font-size: var(--text-sm); }
@media (max-width: 640px) {
  .dt-table, .dt-th, .dt-td, .dt-tr { display: block; }
  .dt-th { display: none; }
  .dt-tr { border-bottom: 1px solid var(--border-default); padding: 12px 0; }
  .dt-td { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px; border: none; white-space: normal; }
  .dt-td::before { content: attr(data-label); font-weight: 600; color: var(--text-tertiary); font-size: var(--text-xs); margin-right: 12px; flex-shrink: 0; }
  .dt-td-actions { justify-content: flex-start; padding-top: 8px; }
  .dt-td-actions::before { content: none; }
}

/* ═══════════════════════════════════════════
   十五、Form 组件 (提取自 molecules/form-group.latte)
   ═══════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.form-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.form-required { color: var(--danger); }
.form-input, .form-select { height: 40px; padding: 0 12px; background: var(--bg-base); border: 1px solid var(--border-default); border-radius: var(--radius-md); color: var(--text-primary); font-size: var(--text-sm); outline: none; transition: border-color var(--motion-fast); font-family: var(--font-sans); box-sizing: border-box; width: 100%; }
.form-input:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.form-input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.form-error { font-size: var(--text-xs); color: var(--danger); margin: 2px 0 0 0; }

/* ═══════════════════════════════════════════
   十六、KPI Sparkline (迷你 7 日趋势图)
   ═══════════════════════════════════════════ */
.kpi-sparkline { margin-top: 8px; opacity: 0.6; transition: opacity var(--motion-fast); }
.kpi-card:hover .kpi-sparkline { opacity: 0.9; }
@keyframes sparkDraw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.kpi-sparkline polyline { stroke-dasharray: 100; animation: sparkDraw 0.8s ease-out forwards; }

/* ── Live indicator ── */
.live-indicator { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity 0.3s; margin-left: 4px; vertical-align: middle; }
@keyframes kpiPulse { 0% { transform: scale(1); } 50% { transform: scale(1.04); color: var(--accent); } 100% { transform: scale(1); } }
.kpi-pulse { animation: kpiPulse 0.6s ease-out; }

/* ═══════════════════════════════════════════
   十七、拖拽排序 (SortableJS + Edit Mode)
   ═══════════════════════════════════════════ */
.kpi-grid-editing .kpi-card { cursor: grab; border: 2px dashed var(--border-strong); transition: transform 0.15s, box-shadow 0.15s; }
.kpi-grid-editing .kpi-card:active { cursor: grabbing; }
.kpi-card-ghost { opacity: 0.4; background: var(--accent-soft); border-color: var(--accent); }

/* ═══════════════════════════════════════════
   十八、Quick Tasks + Attention Items (工作台)
   ═══════════════════════════════════════════ */
/* ── Quick Tasks ── */
.quick-tasks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.quick-task-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg-raised); border: 1px solid var(--border-default); border-radius: var(--radius-lg); text-decoration: none; transition: all var(--motion-fast); cursor: pointer; }
.quick-task-card:hover { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); transform: translateY(-1px); }
.quick-task-icon { font-size: 1.4rem; flex-shrink: 0; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; background: var(--bg-overlay); border-radius: var(--radius-md); }
.quick-task-body { flex: 1; min-width: 0; }
.quick-task-title { font-weight: 600; font-size: var(--text-sm); color: var(--text-primary); margin-bottom: 2px; }
.quick-task-desc { font-size: var(--text-xs); color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-task-shortcut { flex-shrink: 0; padding: 2px 6px; background: var(--bg-overlay); border: 1px solid var(--border-default); border-radius: 4px; font-size: 10px; font-family: var(--font-mono); color: var(--text-tertiary); }

/* ── Attention Items ── */
.attention-section { background: var(--bg-raised); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: 16px 20px; }
.attention-heading { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.attention-count { font-size: 11px; padding: 1px 8px; border-radius: var(--radius-full); background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.attention-list { display: flex; flex-direction: column; gap: 8px; }
.attention-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-md); text-decoration: none; transition: background var(--motion-fast); border-left: 3px solid transparent; }
.attention-item:hover { background: var(--bg-overlay); }
.attention-crit { border-left-color: var(--danger); background: var(--danger-soft); }
.attention-warn { border-left-color: var(--warning); background: var(--warning-soft); }
.attention-icon { font-size: 1rem; flex-shrink: 0; }
.attention-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.attention-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.attention-desc { font-size: var(--text-xs); color: var(--text-tertiary); }
.attention-action { flex-shrink: 0; font-size: var(--text-xs); color: var(--accent); font-weight: 500; white-space: nowrap; }

@media (max-width: 768px) {
  .quick-tasks { grid-template-columns: 1fr; }
}
/* ═══════════════════════════════════════════
   Converge Grid System v2 — 三种模式，零溢出
   设计: 不写媒体查询，用 auto-fit + minmax() 自动响应
   防溢出: minmax(0,1fr) + min-width:0 + contain 三重保护
   ═══════════════════════════════════════════ */

/* ── 模式1: 固定 N 列 ── */
.grid-cols-1 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--grid-gap, var(--space-4)); }
.grid-cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--grid-gap, var(--space-4)); }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--grid-gap, var(--space-4)); }
.grid-cols-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--grid-gap, var(--space-4)); }
.grid-cols-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--grid-gap, var(--space-4)); }
.grid-cols-6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--grid-gap, var(--space-4)); }

/* ── 模式2: auto-fit 自适应列 ── */
/* 自动计算列数: 容器宽 / (最小列宽 + gap), 无需媒体查询! */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--grid-min, 240px), 1fr));
  gap: var(--grid-gap, var(--space-4));
}

/* ── 模式3: 侧边栏+内容 ── */
.grid-sidebar {
  display: grid;
  grid-template-columns: minmax(0, var(--grid-sidebar, 1fr)) minmax(0, 2fr);
  gap: var(--grid-gap, var(--space-4));
  align-items: start;
}

/* ── 溢出三重保护 (所有网格子项自动继承) ── */
.grid-cols-1 > *,
.grid-cols-2 > *,
.grid-cols-3 > *,
.grid-cols-4 > *,
.grid-cols-5 > *,
.grid-cols-6 > *,
.grid-auto  > *,
.grid-sidebar > * {
  min-width: 0;
}

/* ── 响应式降级 (仅2处断点, 轻量) ── */
@media (max-width: 768px) {
  .grid-cols-4, .grid-cols-5, .grid-cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4, .grid-cols-5, .grid-cols-6 { grid-template-columns: minmax(0, 1fr); }
}
/* ═══════════════════════════════════════════
   Precision Common — 共享 UI 组件样式
   来源: precision-analysis / funnel / tracking
   加载: 所有 Precision 页面共用此文件
   ═══════════════════════════════════════════ */

/* ── Buttons ── */
.btn-pill {
  display: inline-flex; align-items: center; gap: var(--space-2, 8px);
  padding: 12px 24px; border-radius: var(--radius-full, 9999px);
  font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; border: none;
  transition: transform var(--motion-fast), box-shadow var(--motion-fast);
}
.btn-pill:active { transform: scale(0.95); }
.btn-pill-primary { background: var(--accent); color: #fff; }
.btn-pill-primary:hover { box-shadow: 0 2px 12px var(--accent-glow); }
.btn-pill-secondary { background: var(--bg-overlay); color: var(--text-primary); border: 1px solid var(--border-default); }
.btn-pill-secondary:hover { background: var(--bg-base); }
.btn-sm { padding: 6px 16px; font-size: var(--text-xs); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border: 1px solid var(--border-default);
  border-radius: var(--radius-sm, 4px); background: var(--bg-overlay);
  color: var(--text-primary); font-size: var(--text-sm); cursor: pointer;
  transition: background var(--motion-fast);
}
.btn-secondary:hover { background: var(--bg-base); }

.btn-icon {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-default); border-radius: var(--radius-md, 8px);
  background: var(--bg-raised); cursor: pointer; color: var(--text-tertiary);
}
.btn-icon:hover { color: var(--text-primary); }

/* ── Cards & Panels ── */
.analysis-card {
  background: var(--bg-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius-lg, 16px); padding: var(--space-5, 24px);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-4, 16px);
}
.card-header h2 { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); margin: 0; }

/* ── Tables ── */
.precision-table-wrap { overflow-x: auto; }
.precision-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.precision-table thead { border-bottom: 1px solid var(--border-default); }
.precision-table th {
  padding: 10px 16px; text-align: left; font-size: var(--text-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); white-space: nowrap;
}
.precision-table td { padding: 10px 16px; border-bottom: 1px solid var(--border-default); vertical-align: middle; }
.precision-table tbody tr:hover { background: var(--bg-overlay); }
.precision-table tbody tr:last-child td { border-bottom: none; }
.font-semibold { font-weight: 600; color: var(--text-primary); }

/* ── Status & ROI ── */
.status-badge { display: inline-block; padding: 2px 10px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; }
.status-active  { background: var(--success-soft); color: var(--success); }
.status-paused  { background: var(--warning-soft); color: var(--warning); }
.status-draft   { background: var(--bg-overlay); color: var(--text-tertiary); }
.roi-up   { color: var(--success); font-weight: 600; }
.roi-down { color: var(--danger); font-weight: 600; }
.roi-flat { color: var(--text-tertiary); }

/* ── Filter Controls ── */
.filter-select {
  padding: 6px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md, 8px);
  font-size: var(--text-sm); background: var(--bg-raised); color: var(--text-primary); cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); outline: none; }
.filter-input {
  padding: 8px 12px; border: 1px solid var(--border-default); border-radius: var(--radius-md, 8px);
  font-size: var(--text-sm); background: var(--bg-raised); color: var(--text-primary);
}
.filter-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }

/* ── State Overlays (loading / error / empty) ── */
.state-overlay {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--space-12, 48px); text-align: center; color: var(--text-secondary);
}
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--border-default);
  border-top-color: var(--accent); border-radius: 50%;
  animation: precision-spin 0.8s linear infinite; margin-bottom: var(--space-4);
}
@keyframes precision-spin { to { transform: rotate(360deg); } }
.error-message { color: var(--danger); font-weight: 600; }

/* ── Anomaly Tags ── */
.anomaly-tag {
  font-size: var(--text-xs); font-weight: 600; padding: 2px 8px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; gap: 4px;
}
.anomaly-tag.warning { background: var(--warning-soft); color: var(--warning); }
.anomaly-tag.error   { background: var(--danger-soft); color: var(--danger); }

/* ── Animations ── */
@keyframes precision-draw-line { to { stroke-dashoffset: 0; } }
.sparkline-path { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: precision-draw-line 2s ease forwards; }
/* ═══════════════════════════════════════════
   Stitch Theme — Converge 导航重构方案 v1.0
   来源: Stitch project 15891705445337406020
   精确值: 暗色 Zinc/Slate + Indigo 强调
   ═══════════════════════════════════════════ */

:root {
  /* ── Surface (Zinc scale, dark-first) ── */
  --st-surface-dim:#131315; /* token */
  --st-surface:#1c1b1d; /* token */
  --st-surface-container:#201f22; /* token */
  --st-surface-high:#2a2a2c; /* token */
  --st-surface-highest:#353437; /* token */
  --st-surface-bright:#39393b; /* token */
  --st-surface-lowest:#0e0e10; /* token */

  /* ── Primary (Indigo) ── */
  --st-primary:#c0c1ff; /* token */
  --st-on-primary:#1000a9; /* token */
  --st-primary-container:#8083ff; /* token */
  --st-primary-fixed:#e1e0ff; /* token */
  --st-primary-fixed-dim:#c0c1ff; /* token */

  /* ── Secondary (Slate Blue) ── */
  --st-secondary:#b9c8de; /* token */
  --st-on-secondary:#233143; /* token */
  --st-secondary-container:#39485a; /* token */

  /* ── Tertiary (Orange) ── */
  --st-tertiary:#ffb783; /* token */
  --st-on-tertiary:#4f2500; /* token */
  --st-tertiary-container:#d97721; /* token */

  /* ── On-surface (text) ── */
  --st-text-primary:#e5e1e4; /* token */
  --st-text-secondary:#c7c4d7; /* token */
  --st-text-tertiary:#908fa0; /* token */
  --st-text-inverse:#313032; /* token */

  /* ── Outline/Border ── */
  --st-outline:#908fa0; /* token */
  --st-outline-variant:#464554; /* token */
  --st-border:rgba(255,255,255,0.06); /* token */
  --st-border-strong:rgba(255,255,255,0.1); /* token */

  /* ── Status ── */
  --st-success:#4ade80; /* token */
  --st-success-soft:rgba(74,222,128,0.1); /* token */
  --st-warning:#fbbf24; /* token */
  --st-warning-soft:rgba(251,191,36,0.1); /* token */
  --st-danger:#f87171; /* token */
  --st-danger-soft:rgba(248,113,113,0.1); /* token */
  --st-info:#60a5fa; /* token */
  --st-info-soft:rgba(96,165,250,0.1); /* token */

  /* ── Background ── */
  --st-bg:#131315; /* token */

  /* ── Spacing (4px unit) ── */
  --st-unit:4px;
  --st-xs:4px;--st-sm:8px;--st-md:12px;--st-lg:16px;--st-xl:24px;--st-2xl:32px;--st-3xl:48px;

  /* ── Typography ── */
  --st-font-sans:'Inter',system-ui,-apple-system,sans-serif;
  --st-font-mono:'JetBrains Mono',monospace;
  --st-text-display:48px;--st-text-h1:30px;--st-text-h2:20px;
  --st-text-body-lg:16px;--st-text-body:14px;--st-text-body-sm:13px;
  --st-text-label:12px;--st-text-label-sm:10px;

  /* ── Radius ── */
  --st-radius-sm:4px;--st-radius-md:8px;--st-radius-lg:12px;--st-radius-full:9999px;

  /* ── Shadow ── */
  --st-shadow-card:0 1px 3px rgba(0,0,0,0.3);
  --st-shadow-modal:0 16px 48px rgba(0,0,0,0.4);
}

/* ═══ Base (dark default) ═══ */
html,body{font-family:var(--st-font-sans);font-size:var(--st-text-body);background:var(--st-bg);color:var(--st-text-secondary)}
/* token */ html.light body,.light body{background:#f8f9ff;color:#1a1a2e}

/* ═══ Dashboard components ═══ */
.st-dash{padding:var(--st-2xl) var(--st-3xl);max-width:1280px;margin:0 auto}

/* KPI card */
.st-kpi{background:var(--st-surface);border:1px solid var(--st-border);border-radius:var(--st-radius-md);padding:var(--st-xl)}
.st-kpi:hover{border-color:var(--st-border-strong)}
.st-kpi-label{font-size:var(--st-text-label-sm);color:var(--st-text-tertiary);font-weight:500;text-transform:uppercase;letter-spacing:0.05em;margin-bottom:var(--st-sm)}
.st-kpi-value{font-size:var(--st-text-display);font-weight:700;color:var(--st-text-primary);line-height:1.1;font-variant-numeric:tabular-nums;margin-bottom:var(--st-sm)}
.st-kpi-trend{font-size:var(--st-text-body-sm);font-weight:500;display:flex;align-items:center;gap:var(--st-xs)}
.st-kpi-trend.up{color:var(--st-success)}.st-kpi-trend.down{color:var(--st-danger)}

/* Action card */
.st-action{background:var(--st-surface);border:1px solid var(--st-border);border-radius:var(--st-radius-md);padding:var(--st-xl);display:flex;flex-direction:column;gap:var(--st-md);transition:all 0.15s}
.st-action:hover{border-color:var(--st-border-strong);box-shadow:var(--st-shadow-card)}
.st-action-icon{font-size:24px;line-height:1}
.st-action-title{font-size:var(--st-text-body-lg);font-weight:600;color:var(--st-text-primary);display:flex;align-items:center;gap:var(--st-sm)}
.st-action-desc{font-size:var(--st-text-body-sm);color:var(--st-text-secondary);line-height:1.5;flex:1}
.st-action-btn{display:inline-flex;align-items:center;gap:var(--st-sm);padding:var(--st-sm) var(--st-lg);border-radius:var(--st-radius-sm);font-size:var(--st-text-label-sm);font-weight:600;text-decoration:none;cursor:pointer;border:none;transition:all 0.15s;margin-top:auto}
/* token */ .st-btn-primary{background:var(--st-primary-container);color:#fff}.st-btn-primary:hover{background:var(--st-primary);color:var(--st-on-primary);text-decoration:none}
/* token */ .st-btn-danger{background:var(--st-danger-soft);color:var(--st-danger)}.st-btn-danger:hover{background:var(--st-danger);color:#fff;text-decoration:none}
/* token */ .st-btn-purple{background:rgba(99,102,241,0.12);color:#a5b4fc}.st-btn-purple:hover{background:#6366f1;color:#fff;text-decoration:none}
.st-btn-ghost{background:var(--st-surface-high);color:var(--st-text-secondary)}.st-btn-ghost:hover{background:var(--st-surface-highest);color:var(--st-text-primary);text-decoration:none}

/* Badge */
.st-badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:var(--st-radius-full);font-size:var(--st-text-label-sm);font-weight:600;gap:var(--st-xs)}
.st-badge-danger{background:var(--st-danger-soft);color:var(--st-danger)}
.st-badge-success{background:var(--st-success-soft);color:var(--st-success)}
.st-badge-warning{background:var(--st-warning-soft);color:var(--st-warning)}

/* Insight card */
.st-insight{padding:var(--st-lg);border-radius:var(--st-radius-md);display:flex;flex-direction:column;gap:var(--st-sm);background:var(--st-surface);border:1px solid var(--st-border)}
.st-insight-warn{border-color:var(--st-warning);background:var(--st-warning-soft)}
.st-insight-danger{border-color:var(--st-danger);background:var(--st-danger-soft)}
.st-insight-success{border-color:var(--st-success);background:var(--st-success-soft)}
.st-insight-header{display:flex;align-items:center;gap:var(--st-sm);font-size:var(--st-text-body-lg);font-weight:600;color:var(--st-text-primary)}
.st-insight-body{font-size:var(--st-text-body-sm);color:var(--st-text-secondary);line-height:1.5}
.st-insight-link{font-size:var(--st-text-body-sm);font-weight:600;color:var(--st-primary);text-decoration:none}.st-insight-link:hover{text-decoration:underline}

/* Full card */
.st-card{background:var(--st-surface);border:1px solid var(--st-border);border-radius:var(--st-radius-md);padding:var(--st-xl)}

/* Input / Form */
.st-label{font-size:var(--st-text-label-sm);color:var(--st-text-tertiary);font-weight:500;display:block;margin-bottom:var(--st-xs);text-transform:uppercase;letter-spacing:0.05em}
.st-input{width:100%;padding:var(--st-sm) var(--st-md);background:var(--st-surface-container);border:1px solid var(--st-border);border-radius:var(--st-radius-sm);font-size:var(--st-text-body-sm);color:var(--st-text-primary);font-family:var(--st-font-sans);transition:border-color 0.15s}
.st-input:focus{outline:none;border-color:var(--st-primary);box-shadow:0 0 0 2px rgba(99,102,241,0.2)}
.st-select{padding:var(--st-sm) var(--st-md);background:var(--st-surface-container);border:1px solid var(--st-border);border-radius:var(--st-radius-sm);font-size:var(--st-text-body-sm);color:var(--st-text-primary);cursor:pointer}

/* Status indicator */
.st-status{display:inline-flex;align-items:center;gap:var(--st-sm);padding:var(--st-xs) var(--st-md);border-radius:var(--st-radius-full);font-size:var(--st-text-label-sm);font-weight:500}
.st-status-ok{background:var(--st-success-soft);color:var(--st-success)}
.st-status-dot{width:6px;height:6px;border-radius:50%;display:inline-block}

/* Grid helpers */
.st-grid{display:grid;gap:var(--st-lg)}.st-grid-4{grid-template-columns:repeat(4,1fr)}.st-grid-3{grid-template-columns:repeat(3,1fr)}.st-grid-2{grid-template-columns:2fr 1fr}

/* Responsive */
@media(max-width:1024px){.st-grid-4{grid-template-columns:repeat(2,1fr)}.st-grid-3{grid-template-columns:repeat(2,1fr)}.st-grid-2{grid-template-columns:1fr}}
@media(max-width:640px){.st-grid-4,.st-grid-3{grid-template-columns:1fr}.st-dash{padding:var(--st-lg)}}
