/* ==========================================================================
   Carman 车辆数据处理中心 - 史诗级移动端优化 CSS
   断点体系: XS(<375) | SM(375-413) | MD(414-767) | LG(768-1023) | XL(1024+)
   间距基准: 4px 体系 | 触控标准: ≥48dp | 动效标准: 200-350ms
   ========================================================================== */

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

:root {
    /* === 色彩体系 === */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #f8fafc;
    --secondary-hover: #e2e8f0;
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --danger-color: #ef4444;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;

    /* === 圆角 === */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* === 阴影 === */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* === 4px基准间距系统 === */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* === 字体层级 === */
    --font-h1: 1.25rem;
    --font-h2: 1.0625rem;
    --font-h3: 0.9375rem;
    --font-body: 0.875rem;
    --font-caption: 0.75rem;
    --font-price: 1.125rem;

    /* === 动效体系 === */
    --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);        /* 页面转场/弹窗进入 */
    --ease-in-expo: cubic-bezier(0.4, 0, 1, 1);              /* 弹窗退出 */
    --ease-standard: cubic-bezier(0, 0, 0.2, 1);              /* 元素出现/隐出 */
    --ease-emphasized: cubic-bezier(0.4, 0, 0.2, 1);          /* 微交互反馈 */
    
    --duration-page-in: 250ms;
    --duration-page-out: 200ms;
    --duration-element: 200ms;
    --duration-micro: 120ms;
    --duration-toast: 300ms;
    --duration-stagger: 40ms;

    /* === 安全区 (iPhone X+ 刘海/灵动岛适配) === */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);

    /* === 触控标准 === */
    --touch-target-min: 48px;
    --touch-spacing-min: 8px;
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ==========================================================================
   Keyframes - 标准化动效
   ========================================================================== */
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0%   { opacity: 0; transform: scale(0.92); }
    100% { opacity: 1; transform: scale(1); }
}

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

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse-border {
    0%   { border-color: rgba(139, 92, 246, 0.4); }
    50%  { border-color: rgba(139, 92, 246, 1); }
    100% { border-color: rgba(139, 92, 246, 0.4); }
}

@keyframes shrinkOut {
    0%   { opacity: 1; transform: scaleY(1); max-height: 200px; }
    100% { opacity: 0; transform: scaleY(0); max-height: 0; margin: 0; padding: 0; border: none; }
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-16px) scale(0.95); }
}

@keyframes bottomSheetUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@keyframes bottomSheetDown {
    from { transform: translateY(0); }
    to   { transform: translateY(100%); }
}

/* Reduced Motion - 无障碍支持 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ==========================================================================
   Switch UI - 触控区域增强至48dp
   ========================================================================== */
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    cursor: pointer;
}

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

.slider {
    position: relative;
    width: 44px;
    height: 26px;
    background-color: #ccc;
    transition: background-color 200ms var(--ease-standard);
    border-radius: 26px;
    will-change: background-color;
}

.slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: transform 200ms var(--ease-standard);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    will-change: transform;
}

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

input:focus-visible + .slider {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

input:checked + .slider::before {
    transform: translateX(18px);
}

/* ==========================================================================
   Alert Modal
   ========================================================================== */
.alert-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-page-in) var(--ease-out-expo);
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
}

.alert-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.alert-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    width: calc(100% - var(--space-xl) * 2);
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    transform: scale(0.92);
    transition: transform var(--duration-page-in) var(--ease-out-expo);
    text-align: center;
}

.alert-modal.show .alert-modal-content {
    transform: scale(1);
}

.alert-modal-text {
    font-size: var(--font-body);
    color: var(--text-main);
    margin-bottom: 20px;
    white-space: pre-wrap;
    line-height: 1.6;
}

.alert-modal-btn {
    width: 100%;
    padding: 12px;
    min-height: var(--touch-target-min);
}

/* ==========================================================================
   Layout - 响应式流体布局
   ========================================================================== */
.app-container {
    max-width: 100%;
    margin: 0;
    padding: 0 var(--space-lg);
    padding-top: 0;
    animation: slideUpFade 300ms var(--ease-out-expo);
    padding-bottom: calc(var(--safe-area-bottom) + 64px); /* 为底部Tab Bar留空间 */
}

.app-main {
    max-width: 900px;
    margin: 0 auto;
}

/* Header - Glassmorphism */
.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    margin-bottom: var(--space-lg);
    padding-top: var(--safe-area-top);
}

.app-header-content {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
    margin: 0 auto;
    padding: 14px var(--space-lg);
    gap: var(--space-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.brand h1 {
    font-size: var(--font-h1);
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.header-actions .btn {
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 6px 10px;
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

/* 余额徽章 */
.balance-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.08);
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
    cursor: default;
    transition: all 0.2s;
    white-space: nowrap;
}
.balance-badge:hover {
    background: rgba(15, 23, 42, 0.07);
}
.balance-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #94a3b8;
}
.balance-dot.balance-ok {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}
.balance-dot.balance-low {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}
.balance-dot.balance-error {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}
.balance-dot.balance-loading {
    background: #6366f1;
    animation: balancePulse 1s ease-in-out infinite;
}
@keyframes balancePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.balance-text {
    letter-spacing: 0.01em;
}
.balance-refresh-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}
.balance-refresh-btn:hover {
    color: #6366f1;
}

.login-status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: 12px 14px;
    margin-bottom: var(--space-md);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(37, 99, 235, 0.14);
    color: var(--text-main);
}

.auth-modal-content {
    max-width: 420px;
}

.auth-modal-subtitle {
    color: var(--text-muted);
    font-size: var(--font-body);
    margin: -8px 0 20px;
    line-height: 1.6;
}

/* ==========================================================================
   Locked State (未登录状态)
   ========================================================================== */
.app-main-locked .form-control {
    background-color: #f8fafc;
    color: #94a3b8;
    pointer-events: none;
    border-color: #e2e8f0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>');
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 36px;
}

.app-main-locked .btn:not(#btn-open-login) {
    background-color: #f1f5f9;
    color: #94a3b8;
    pointer-events: none;
    border-color: #e2e8f0;
    box-shadow: none;
}

.app-main-locked .form-group label {
    color: #94a3b8;
}

.app-main-locked .tag-btn {
    background-color: #f1f5f9;
    color: #94a3b8;
    pointer-events: none;
    border-color: #e2e8f0;
    position: relative;
    padding-right: 28px;
}

.app-main-locked .tag-btn::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>');
    background-repeat: no-repeat;
    background-size: contain;
}

/* ==========================================================================
   UI Icons
   ========================================================================== */
.ui-icon {
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.2em;
    display: inline-block;
    pointer-events: none;
}

.logo-icon img {
    width: 1.8rem;
    height: 1.8rem;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    transition: box-shadow 200ms var(--ease-standard);
    contain: layout style;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.card-header h3 {
    font-size: var(--font-h2);
    font-weight: 600;
    margin-bottom: 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: var(--font-body);
    font-weight: 500;
    margin-bottom: var(--space-sm);
    color: var(--text-muted);
    user-select: none;
}

.form-control {
    width: 100%;
    padding: 12px var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: var(--font-body);
    font-family: inherit;
    background-color: #fff;
    transition: border-color 120ms var(--ease-standard), box-shadow 120ms var(--ease-standard);
    outline: none;
    color: var(--text-main);
    min-height: var(--touch-target-min);
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control.input-error {
    background-color: #fee2e2;
    border-color: var(--danger-color);
}

.form-control.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

textarea.form-control {
    min-height: 180px;
    resize: none;
    max-height: 60vh;
    line-height: 1.5;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* ==========================================================================
   Buttons - 触控热区 ≥48dp
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 20px;
    font-size: var(--font-body);
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 120ms var(--ease-standard), 
                box-shadow 120ms var(--ease-standard),
                background-color 120ms var(--ease-standard);
    outline: none;
    text-decoration: none;
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.btn:active {
    transform: scale(0.96);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* 小按钮保留最小触控区域 */
.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

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

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

.btn-accent {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.2);
}

.btn-accent:hover:not(:disabled) {
    background-color: var(--accent-hover);
    box-shadow: 0 4px 8px rgba(139, 92, 246, 0.3);
}

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

.btn-outline:hover:not(:disabled) {
    background-color: var(--secondary-color);
    border-color: #94a3b8;
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    min-height: 52px;
}

/* 危险按钮增强触控 */
.btn-danger {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

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

/* ==========================================================================
   Action Area Grid
   ========================================================================== */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: 20px;
}

/* ==========================================================================
   Image Preview Grid - 流体自适应
   ========================================================================== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: var(--space-sm);
    min-height: 120px;
    background: var(--secondary-color);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: var(--space-sm);
    padding: var(--space-lg) 0;
}

.empty-state .icon {
    font-size: 2rem;
    opacity: 0.5;
}

/* 预览图项 - 使用aspect-ratio自适应 */
.preview-item {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    animation: popIn 200ms var(--ease-standard);
    background: #fff;
    will-change: transform;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 200ms var(--ease-standard);
}

/* 长按模式：移动端hover降级 */
@media (hover: hover) and (pointer: fine) {
    .preview-item:hover img {
        transform: scale(1.05);
    }
}

/* 预览按钮 - 48dp触控区域 */
.btn-preview-img {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    background: rgba(0, 0, 0, 0.55);
    color: white;
    border: none;
    border-radius: 50%;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 10;
    transition: background 120ms var(--ease-standard), transform 120ms var(--ease-standard);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    -webkit-tap-highlight-color: transparent;
}

.btn-preview-img:active {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(0.9);
}

/* 删除按钮 - 48dp触控区域 */
.btn-delete-img {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    background: rgba(239, 68, 68, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 10;
    transition: background 120ms var(--ease-standard), transform 120ms var(--ease-standard);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    -webkit-tap-highlight-color: transparent;
}

.btn-delete-img:active {
    background: var(--danger-color);
    transform: scale(0.9);
}

/* ==========================================================================
   History Cards & Modals
   ========================================================================== */
.history-action-row {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

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

.history-fullinfo-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 20px;
}

.history-fullinfo-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px var(--space-md);
}

.history-fullinfo-card h3 {
    margin: 0 0 10px;
    font-size: var(--font-body);
    color: #475569;
}

.history-fullinfo-item {
    color: var(--text-main);
    font-size: var(--font-body);
    line-height: 1.7;
}

.history-fullinfo-item strong {
    color: #334155;
}

.history-fullinfo-text {
    background: var(--text-main);
    color: #e2e8f0;
    border-radius: 12px;
    padding: var(--space-md);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.history-thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-md);
}

.history-thumb-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #e2e8f0;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    border: 1px solid #dbe2ea;
    transition: transform 150ms var(--ease-standard), box-shadow 150ms var(--ease-standard);
    will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
    .history-thumb-item:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
}

.history-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.history-thumb-tip {
    position: absolute;
    left: var(--space-sm);
    right: var(--space-sm);
    bottom: var(--space-sm);
    padding: 4px var(--space-sm);
    border-radius: 999px;
    font-size: 11px;
    text-align: center;
    color: #fff;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ==========================================================================
   Image Status Overlays
   ========================================================================== */
.preview-item.status-nameplate { border: 3px solid #3b82f6; }
.preview-item.status-nameplate::after {
    content: "车辆铭牌";
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 3px 0;
    z-index: 5;
}

.preview-item.status-dealer { border: 3px solid #ef4444; }
.preview-item.status-dealer::after {
    content: "存在经销商信息";
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 3px 0;
    z-index: 5;
}

.preview-item.status-valid { border: 3px solid #10b981; }
.preview-item.status-valid::after {
    content: "合格车辆照片";
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    background: rgba(16, 185, 129, 0.9);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 3px 0;
    z-index: 5;
}

.preview-item.status-unknown { border: 3px solid #9ca3af; }
.preview-item.status-unknown::after {
    content: "疑似无关信息";
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    background: rgba(156, 163, 175, 0.9);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 3px 0;
    z-index: 5;
}

.preview-item.status-processing::after {
    content: "AI识别中...";
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 3px 0;
    z-index: 5;
}

.preview-item.status-generating {
    border: 3px solid #8b5cf6;
    animation: pulse-border 1.5s infinite;
}
.preview-item.status-generating img {
    opacity: 0.6;
    filter: grayscale(30%) blur(1px);
}
.preview-item.status-generating::after {
    content: "豆包生图中...";
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    background: rgba(139, 92, 246, 0.9);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 3px 0;
    z-index: 5;
}

/* ==========================================================================
   Progress Bar - transform: scaleX 替代 width（GPU加速）
   ========================================================================== */
.progress-container {
    width: 100%;
    height: 8px;
    background-color: var(--secondary-hover);
    border-radius: 4px;
    margin-top: var(--space-md);
    overflow: hidden;
    display: none;
}

.progress-container.active {
    display: block;
}

.progress-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 300ms var(--ease-standard);
    will-change: transform;
    border-radius: 4px;
}

.progress-text {
    font-size: var(--font-caption);
    color: var(--text-muted);
    text-align: right;
    margin-top: var(--space-xs);
    display: none;
}

.progress-text.active {
    display: block;
}

/* ==========================================================================
   Modal - 居中弹窗
   ========================================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    background-color: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-page-in) var(--ease-out-expo),
                visibility var(--duration-page-in) var(--ease-out-expo);
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    width: calc(100% - var(--space-xl) * 2);
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    max-height: calc(90vh - var(--safe-area-top) - var(--safe-area-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-xl);
    transform: translateY(12px) scale(0.95);
    transition: transform var(--duration-page-in) var(--ease-out-expo);
    will-change: transform;
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0) scale(1);
}

.modal h2 {
    font-size: var(--font-h2);
    margin-bottom: var(--space-lg);
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

/* 关闭按钮 - 48dp触控区域 */
.close-btn {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 120ms var(--ease-standard);
    border-radius: 50%;
    border: none;
    background: transparent;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
}

.close-btn:active {
    color: var(--text-main);
    background: rgba(0,0,0,0.05);
}

/* ==========================================================================
   Bottom Sheet - 底部弹出面板
   ========================================================================== */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    background: rgba(15, 23, 42, 0.4);
    z-index: 2100;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-page-in) var(--ease-out-expo),
                visibility var(--duration-page-in) var(--ease-out-expo);
}

.bottom-sheet-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    z-index: 2101;
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-lg) + var(--safe-area-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform var(--duration-page-in) var(--ease-out-expo);
    will-change: transform;
}

.bottom-sheet-overlay:not(.hidden) .bottom-sheet {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0 auto var(--space-md);
    opacity: 0.6;
}

.bottom-sheet h2 {
    font-size: var(--font-h2);
    margin-bottom: var(--space-lg);
    color: var(--text-main);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   Contact Items
   ========================================================================== */
.contact-item {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    animation: fadeIn 200ms var(--ease-standard);
}

.contact-item .form-control {
    margin-bottom: 0;
}

.btn-remove-contact {
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    color: var(--danger-color);
    border-radius: var(--radius-sm);
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    cursor: pointer;
    transition: background 120ms var(--ease-standard);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.btn-remove-contact:active {
    background: #fee2e2;
    border-color: #fca5a5;
}

/* ==========================================================================
   Preset List
   ========================================================================== */
.preset-list-container {
    margin-top: var(--space-xl);
}

.preset-list-container h3 {
    font-size: var(--font-h3);
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

#preset-ul {
    list-style: none;
}

#preset-ul li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    transition: border-color 120ms var(--ease-standard);
}

#preset-ul li:active {
    border-color: var(--primary-color);
}

.preset-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.preset-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: var(--font-body);
}

.preset-tags {
    font-size: var(--font-caption);
    color: var(--text-muted);
}

.btn-del-preset {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    background: transparent;
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--font-caption);
    cursor: pointer;
    transition: background 120ms var(--ease-standard), color 120ms var(--ease-standard);
    -webkit-tap-highlight-color: transparent;
}

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

.btn-del-tag {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    background: transparent;
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--font-caption);
    cursor: pointer;
    transition: background 120ms var(--ease-standard), color 120ms var(--ease-standard);
    -webkit-tap-highlight-color: transparent;
}

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

/* ==========================================================================
   Tag Buttons - 触控增强
   ========================================================================== */
.tag-btn {
    padding: 8px 16px;
    background-color: var(--secondary-color);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: var(--font-caption);
    cursor: pointer;
    transition: transform 120ms var(--ease-standard),
                background-color 120ms var(--ease-standard),
                border-color 120ms var(--ease-standard);
    user-select: none;
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

.tag-btn:active {
    background-color: #e2e8f0;
    transform: scale(0.96);
}

.tag-btn.active {
    background-color: #e0f2fe;
    color: #0369a1;
    border-color: #7dd3fc;
}

/* ==========================================================================
   Hidden Utility
   ========================================================================== */
.hidden {
    display: none !important;
}

/* ==========================================================================
   Admin Dashboard
   ========================================================================== */
.admin-animate-in {
    animation: slideUpFade 300ms var(--ease-out-expo) forwards;
    opacity: 0;
}
.admin-animate-in:nth-child(1) { animation-delay: 50ms; }
.admin-animate-in:nth-child(2) { animation-delay: 100ms; }
.admin-animate-in:nth-child(3) { animation-delay: 150ms; }

.admin-header {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* Stat Cards */
.stat-card {
    transition: transform 200ms var(--ease-standard), box-shadow 200ms var(--ease-standard);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
    .stat-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }
}

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 100px;
    height: 100px;
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.05;
    pointer-events: none;
}

.stat-card-ai::after { background-image: url('../images/icons/icon-magic.png'); }
.stat-card-up::after { background-image: url('../images/icons/icon-camera.png'); }
.stat-card-ds::after { background-image: url('../images/icons/icon-setting.png'); }
.stat-card-qw::after { background-image: url('../images/icons/icon-preview.png'); }

/* ==========================================================================
   Segmented Control - 触控增强
   ========================================================================== */
.segmented-control {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 8px;
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto 20px auto;
    user-select: none;
}

.segmented-btn {
    flex: 1;
    text-align: center;
    padding: 10px var(--space-md);
    border-radius: 6px;
    font-size: var(--font-body);
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: color 200ms var(--ease-standard);
    z-index: 2;
    background: transparent;
    border: none;
    min-height: var(--touch-target-min);
    -webkit-tap-highlight-color: transparent;
}

.segmented-btn.active {
    color: var(--text-main);
}

.segmented-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / 3);
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 250ms var(--ease-out-expo);
    z-index: 1;
    will-change: transform;
}

/* ==========================================================================
   Admin Image Grid
   ========================================================================== */
.admin-image-item {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0;
    background: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 200ms var(--ease-standard), box-shadow 200ms var(--ease-standard);
    aspect-ratio: 1 / 1;
    will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
    .admin-image-item:hover {
        transform: scale(1.02);
        box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    }
    .admin-image-item:hover img {
        transform: scale(1.05);
    }
}

.admin-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 200ms var(--ease-standard);
}

.admin-image-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 200ms var(--ease-standard);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px;
    pointer-events: none;
}

.admin-image-item.selected .admin-image-overlay {
    opacity: 1;
    pointer-events: auto;
}

.admin-image-item.selected {
    border-color: var(--primary-color);
}

/* 管理员复选框 - 48dp触控区域 */
.admin-image-cb {
    width: 22px;
    height: 22px;
    cursor: pointer;
    margin: 0;
    accent-color: var(--primary-color);
}

/* 扩大复选框点击区域 */
.admin-image-overlay label,
.admin-image-overlay .admin-image-cb-wrapper {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
}

/* ==========================================================================
   Floating Action Bar - 安全区适配
   ========================================================================== */
.floating-action-bar {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 1100;
    transition: bottom 300ms var(--ease-out-expo);
    bottom: -100px;
}

.floating-action-bar.visible {
    bottom: calc(24px + var(--safe-area-bottom));
}

.admin-user-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.admin-user-hint {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: var(--font-body);
}

.admin-user-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: var(--space-lg);
}

.admin-user-form-card,
.admin-user-list-card {
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.admin-user-form-card h4,
.admin-user-list-card h4 {
    margin-bottom: var(--space-md);
    font-size: var(--font-h3);
    color: var(--text-main);
}

.admin-user-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.admin-user-count {
    font-size: var(--font-caption);
    color: var(--text-muted);
}

.admin-users-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.admin-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: white;
}

.admin-user-meta {
    min-width: 0;
}

.admin-user-name {
    font-size: var(--font-body);
    font-weight: 600;
    color: var(--text-main);
}

.admin-user-desc {
    margin-top: 4px;
    font-size: var(--font-caption);
    color: var(--text-muted);
    word-break: break-word;
}

/* ==========================================================================
   Table Enhancements
   ========================================================================== */
.admin-table-row {
    transition: background-color 150ms var(--ease-standard);
    position: relative;
}

.admin-table-row:nth-child(even) {
    background-color: #f8fafc;
}

.admin-table-row:active {
    background-color: #e2e8f0;
}

.admin-table-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--primary-color);
    transform: scaleY(0);
    transition: transform 150ms var(--ease-standard);
}

@media (hover: hover) and (pointer: fine) {
    .admin-table-row:hover {
        background-color: #e2e8f0;
    }
    .admin-table-row:hover::before {
        transform: scaleY(1);
    }
}

/* ==========================================================================
   Toast Notification - 序列化入场 + 安全区
   ========================================================================== */
.toast-container {
    position: fixed;
    top: calc(var(--safe-area-top) + 12px);
    right: max(var(--safe-area-right), 16px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

.toast {
    background: white;
    color: var(--text-main);
    padding: var(--space-md);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    border-left: 4px solid var(--primary-color);
    pointer-events: auto;
    font-size: var(--font-body);
    min-height: var(--touch-target-min);
    will-change: transform, opacity;
    animation: toastSlideIn var(--duration-toast) var(--ease-out-expo) forwards;
}

.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error { border-left-color: #ef4444; }

.toast.hide {
    animation: toastSlideOut var(--duration-page-out) var(--ease-in-expo) forwards;
}

/* ==========================================================================
   Custom Confirm Modal
   ========================================================================== */
.custom-confirm-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-page-in) var(--ease-out-expo),
                visibility var(--duration-page-in) var(--ease-out-expo);
    padding: var(--space-lg);
}

.custom-confirm-overlay.show {
    opacity: 1;
    visibility: visible;
}

.custom-confirm-box {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-xl);
    transform: scale(0.92);
    transition: transform var(--duration-page-in) var(--ease-out-expo);
}

.custom-confirm-overlay.show .custom-confirm-box {
    transform: scale(1);
}

.custom-confirm-title {
    font-size: var(--font-h2);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-main);
}

.custom-confirm-desc {
    font-size: var(--font-body);
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
}

.custom-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

/* ==========================================================================
   Delete Animation - GPU加速(move to max-height)
   ========================================================================== */
.item-deleting {
    animation: shrinkOut 300ms var(--ease-in-expo) forwards !important;
    overflow: hidden !important;
}

/* ==========================================================================
   Bottom Tab Bar - iOS风格
   ========================================================================== */
.bottom-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 500;
}

.bottom-tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    transition: color 150ms var(--ease-standard);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.bottom-tab-item .tab-icon {
    font-size: 22px;
    line-height: 1;
}

.bottom-tab-item.active {
    color: var(--primary-color);
}

/* ==========================================================================
   Floating Action Button (FAB) - 一键智能处理
   ========================================================================== */
.fab-main {
    position: fixed;
    bottom: calc(72px + var(--safe-area-bottom));
    right: max(var(--safe-area-right), var(--space-lg));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    cursor: pointer;
    z-index: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    transition: transform 150ms var(--ease-standard), box-shadow 150ms var(--ease-standard);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    will-change: transform;
}

.fab-main:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.fab-main:disabled {
    opacity: 0.5;
    transform: none;
    cursor: not-allowed;
}

.fab-main .fab-icon {
    font-size: 22px;
    line-height: 1;
}

/* ==========================================================================
   Skeleton Screen - 骨架屏
   ========================================================================== */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-sm);
    width: 80%;
}

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

.skeleton-image {
    aspect-ratio: 1 / 1;
    width: 100%;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Scroll Container Unified
   ========================================================================== */
.scroll-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Table horizontal scroll for mobile */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 4px, black calc(100% - 16px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 4px, black calc(100% - 16px), transparent 100%);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
    text-align: center;
    padding: var(--space-lg) var(--space-md);
    padding-bottom: calc(var(--space-lg) + var(--space-md));
    font-size: var(--font-caption);
    color: #94a3b8;
    margin-top: var(--space-sm);
}

/* ==========================================================================
   响应式断点体系
   ========================================================================== */

/* XS: iPhone SE, 小屏安卓 (<375px) */
@media (max-width: 374px) {
    .app-container {
        padding: 0 10px;
    }

    .app-header-content {
        padding: 8px 10px;
        gap: 6px;
    }

    .brand {
        gap: 4px;
    }

    .brand h1 {
        font-size: 0.9rem;
    }

    .logo-icon img {
        width: 1.2rem;
        height: 1.2rem;
    }

    .header-actions {
        gap: 4px;
    }

    .header-actions .btn {
        padding: 5px 8px;
        font-size: 0.7rem;
        min-height: 36px;
        min-width: 36px;
    }

    .login-status-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .balance-badge {
        padding: 2px 8px;
        font-size: 0.7rem;
    }

    .balance-refresh-btn {
        font-size: 0.75rem;
    }

    .card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .card-header {
        margin-bottom: 10px;
    }

    .card-header h3 {
        font-size: 0.9rem;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
        padding: 8px;
        gap: 6px;
    }

    .action-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .history-thumb-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    }

    textarea.form-control {
        min-height: 130px;
    }

    .modal-content {
        padding: var(--space-md);
        width: calc(100% - 20px);
    }

    .admin-user-layout {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .admin-user-item,
    .admin-user-list-header {
        flex-direction: column;
        align-items: stretch;
    }

    .bottom-sheet {
        padding: var(--space-md);
    }

    .fab-main {
        width: 48px;
        height: 48px;
        right: 10px;
        font-size: 10px;
    }

    .fab-main .fab-icon {
        font-size: 18px;
    }
}

/* SM: iPhone 6/7/8/X/11/12/13/14 Pro (375-413px) */
@media (min-width: 375px) and (max-width: 413px) {
    .app-container {
        padding: 0 12px;
    }

    .app-header-content {
        padding: 10px 12px;
        gap: 8px;
    }

    .card {
        padding: 14px;
        margin-bottom: 14px;
    }

    .card-header {
        margin-bottom: 10px;
    }

    .card-header h3 {
        font-size: 0.95rem;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
        padding: 10px;
        gap: 8px;
    }

    .action-grid {
        gap: var(--space-sm);
    }

    .history-thumb-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    }

    textarea.form-control {
        min-height: 140px;
    }

    .modal-content {
        padding: 20px;
        width: calc(100% - 24px);
    }

    .login-status-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-user-layout {
        grid-template-columns: 1fr;
    }
}

/* MD: iPhone Plus/Max, 大屏安卓 (414-767px) */
@media (min-width: 414px) and (max-width: 767px) {
    .app-container {
        padding: 0 16px;
    }

    .card {
        padding: var(--space-md);
        margin-bottom: var(--space-md);
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        padding: 12px;
        gap: 10px;
    }

    .history-thumb-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

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

    .history-fullinfo-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-user-layout {
        grid-template-columns: 1fr;
    }
}

/* 通用移动端 (≤767px) */
@media (max-width: 767px) {
    .app-header {
        margin-bottom: var(--space-md);
    }

    .app-header-content {
        width: 100%;
        max-width: 100%;
        padding: 10px 12px;
        gap: 8px;
    }

    .brand h1 {
        font-size: 1.05rem;
    }

    .logo-icon img {
        width: 1.4rem;
        height: 1.4rem;
    }

    .card-header .btn {
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    .btn-block {
        padding: 12px;
        font-size: 0.95rem;
    }

    .form-control {
        font-size: 0.9rem;
        padding: 10px 12px;
    }

    textarea.form-control {
        min-height: 140px;
    }

    /* 管理员统计卡片 */
    #admin-container .stat-card {
        padding: var(--space-md) !important;
    }

    #admin-container .stat-card > div:first-child {
        font-size: 24px !important;
    }

    /* 管理员表格横向滚动 */
    #admin-history-section > div:first-of-type {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #admin-history-section table {
        min-width: 600px;
    }

    /* 管理员图片网格 */
    #admin-images-list {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important;
        gap: 10px !important;
        max-height: 50vh !important;
    }

    /* 弹窗移动端优化 */
    .modal-content {
        padding: 20px;
        width: calc(100% - 24px);
        max-height: calc(85vh - var(--safe-area-top) - var(--safe-area-bottom));
    }

    .close-btn {
        top: 12px;
        right: 12px;
    }

    /* 分段控制器 */
    .segmented-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .floating-action-bar {
        padding: 10px 16px;
        gap: 12px;
        font-size: 0.85rem;
    }

    /* 减小图片预览区的按钮大小 */
    .btn-preview-img,
    .btn-delete-img {
        width: 32px;
        height: 32px;
        top: 6px;
    }
    .btn-preview-img .ui-icon,
    .btn-delete-img .ui-icon {
        width: 16px;
        height: 16px;
    }
    .btn-delete-img {
        right: 6px;
    }
    .btn-preview-img {
        left: 6px;
    }
}

/* Tablet & Small Desktop (768-1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .app-container {
        padding: 0 var(--space-lg);
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .history-fullinfo-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .app-container {
        padding: 0 var(--space-lg);
    }

    .app-header-content {
        flex-direction: row;
        justify-content: space-between;
        padding: 16px var(--space-lg);
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .history-fullinfo-grid {
        grid-template-columns: 1fr 1fr;
    }

    .history-thumb-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    /* 桌面端 hover 效果恢复 */
    .card:hover {
        box-shadow: var(--shadow-md);
    }

    .preview-item:hover img {
        transform: scale(1.05);
    }

    .admin-image-item:hover .admin-image-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}
