/* ===== 水果检测系统 - 精致高级设计 ===== */
/* 克制的奢华 · 专业的质感 · 现代的优雅 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* 深色主题 - 精致中性色调 */
    --bg-primary: #0d0d0f;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --bg-card: #18181b;
    --bg-hover: #1f1f23;
    --bg-elevated: #27272a;

    /* 文字层级 */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --text-muted: #52525b;

    /* 强调色 - 克制的蓝绿色系 */
    --accent-primary: #06b6d4;
    --accent-primary-dark: #0891b2;
    --accent-primary-light: #22d3ee;

    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    /* 边框 */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    /* 精致阴影系统 */
    --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 16px -4px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
    --shadow-accent: 0 0 0 1px rgba(6, 182, 212, 0.2), 0 4px 12px -2px rgba(6, 182, 212, 0.15);

    /* 尺寸 */
    --sidebar-width: 260px;
    --topbar-height: 68px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* 字体 */
    --font-primary: 'Inter', -apple-system, system-ui, sans-serif;

    /* 动画 - 更快更流畅 */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 浅色主题 */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-card: #ffffff;
    --bg-hover: #f3f4f6;
    --bg-elevated: #ffffff;

    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-tertiary: #71717a;
    --text-muted: #a1a1aa;

    --border-subtle: rgba(0, 0, 0, 0.12);
    --border-medium: rgba(0, 0, 0, 0.18);
    --border-strong: rgba(0, 0, 0, 0.25);

    --shadow-subtle: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.1), 0 2px 4px -2px 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);
}

/* ===== 基础重置 ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ===== 应用布局 ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ===== 侧边栏 - 精致设计 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.logo i {
    font-size: 22px;
    color: var(--accent-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

/* 滚动条 */
.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 2px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item i {
    font-size: 17px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
}

.mode-switch-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.mode-switch-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
}

.version-info {
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== 主内容区域 ===== */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* ===== 顶部栏 ===== */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.menu-toggle:hover {
    background: var(--bg-hover);
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.user-info:hover {
    background: var(--bg-hover);
}

.user-info i {
    font-size: 18px;
    color: var(--text-secondary);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    margin-left: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.battery-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.battery-icon {
    display: flex;
    align-items: center;
}

.battery-body {
    width: 24px;
    height: 12px;
    border: 2px solid var(--text-tertiary);
    border-radius: 2px;
    position: relative;
    display: flex;
    align-items: center;
    padding: 1px;
}

.battery-tip {
    width: 2px;
    height: 6px;
    background: var(--text-tertiary);
    border-radius: 0 1px 1px 0;
}

.battery-level {
    height: 100%;
    background: var(--accent-success);
    border-radius: 1px;
    transition: width var(--transition-base), background var(--transition-base);
}

.battery-status[data-status="low"] .battery-level {
    background: var(--accent-danger);
}

.battery-status[data-status="medium"] .battery-level {
    background: var(--accent-warning);
}

.connection-status {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all var(--transition-base);
}

.connection-status.connected .status-dot {
    background: var(--accent-success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.connection-status.connected .status-text {
    color: var(--text-primary);
}

.current-time {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 600;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
}

/* ===== 主内容 ===== */
.main-content {
    flex: 1;
    padding: 28px;
    overflow-y: auto;
}

.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 10px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

.panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 卡片系统 ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-subtle);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
    transform: translateY(-1px);
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.card-header h3 i {
    color: var(--text-tertiary);
    font-size: 18px;
}

.card-body {
    padding: 20px;
}

/* ===== 检测总览 ===== */
.detection-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.fruit-selector-card,
.maturity-card,
.prediction-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
    transition: all var(--transition-smooth);
}

.fruit-selector-card:hover,
.maturity-card:hover,
.prediction-card:hover {
    box-shadow: var(--shadow-md);
}

/* 水果选择器 */
.fruit-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 10px;
    padding: 18px;
}

.fruit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.fruit-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
    transform: translateY(-2px);
}

.fruit-item.active {
    background: rgba(6, 182, 212, 0.12);
    border-color: rgba(6, 182, 212, 0.3);
    box-shadow: var(--shadow-accent);
}

.fruit-icon {
    font-size: 32px;
}

.fruit-name {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

/* 成熟度卡片 */
.maturity-card {
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.current-fruit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.fruit-icon-large {
    font-size: 52px;
}

.fruit-type {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.maturity-gauge {
    position: relative;
    width: 160px;
    height: 160px;
}

.maturity-gauge svg {
    transform: rotate(-90deg);
}

.gauge-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 12;
}

.gauge-fill {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 502;
    stroke-dashoffset: 502;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s ease;
}

.gauge-fill.warning {
    stroke: var(--accent-warning);
}

.gauge-fill.danger {
    stroke: var(--accent-danger);
}

.gauge-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-value {
    display: block;
    font-size: 38px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.gauge-label {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-top: 2px;
}

.maturity-status {
    text-align: center;
    width: 100%;
}

.status-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: 0.01em;
}

.status-badge.unripe {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.status-badge.optimal {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.overripe {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-desc {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
}

/* TinyML 预测 */
.prediction-content {
    padding: 18px 20px;
}

.prediction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.prediction-item:last-child {
    border-bottom: none;
}

.prediction-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.prediction-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ===== 区块标题 ===== */
.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
    letter-spacing: -0.01em;
}

.section-title i {
    color: var(--text-tertiary);
    font-size: 20px;
}

/* ===== 传感器网格 ===== */
.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}

.sensor-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-subtle);
    transition: all var(--transition-base);
}

.sensor-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
    transform: translateY(-2px);
}

.sensor-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.sensor-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    font-size: 18px;
}

.sensor-icon.ethanol { color: var(--accent-primary); }
.sensor-icon.ethylene { color: var(--accent-success); }
.sensor-icon.tvoc { color: #a855f7; }
.sensor-icon.hcho { color: var(--accent-danger); }
.sensor-icon.co2 { color: var(--accent-warning); }
.sensor-icon.aqi { color: var(--accent-success); }

.sensor-title {
    flex: 1;
}

.sensor-title .name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.sensor-title .unit {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 400;
    margin-top: 1px;
}

.sensor-value {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin-bottom: 12px;
}

.sensor-value .value {
    font-size: 30px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.sensor-value .unit {
    font-size: 14px;
    color: var(--text-tertiary);
    font-weight: 600;
}

.sensor-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.bar-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sensor-card[data-status="warning"] .bar-fill {
    background: var(--accent-warning);
}

.sensor-card[data-status="danger"] .bar-fill {
    background: var(--accent-danger);
}

.sensor-range {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== 环境监测 ===== */
.env-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}

.env-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-subtle);
    transition: all var(--transition-base);
}

.env-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-medium);
    transform: translateY(-2px);
}

.env-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    font-size: 26px;
}

.env-icon.temperature { color: var(--accent-danger); }
.env-icon.humidity { color: var(--accent-primary); }

.env-info {
    flex: 1;
}

.env-label {
    display: block;
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-bottom: 4px;
}

.env-value {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.env-value .value {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.env-value .unit {
    font-size: 16px;
    color: var(--text-tertiary);
    font-weight: 600;
}

.env-status {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.env-card[data-status="warning"] {
    border-color: rgba(245, 158, 11, 0.3);
}

.env-card[data-status="danger"] {
    border-color: rgba(239, 68, 68, 0.3);
}

/* ===== 更新信息 ===== */
.update-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-tertiary);
    box-shadow: var(--shadow-subtle);
}

/* ===== 表单元素 ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-variant-numeric: tabular-nums;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1);
}

.input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: var(--shadow-subtle);
}

.btn:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    border-color: var(--border-medium);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-subtle);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 1px 2px 0 rgba(6, 182, 212, 0.2);
}

.btn-primary:hover {
    background: var(--accent-primary-dark);
    border-color: var(--accent-primary-dark);
    box-shadow: 0 4px 8px 0 rgba(6, 182, 212, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    border-color: var(--border-medium);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
    border-color: var(--accent-danger);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-actions {
    display: flex;
    gap: 10px;
}

/* ===== 开关 ===== */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-info {
    flex: 1;
}

.setting-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

.setting-desc {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 13px;
    transition: all var(--transition-base);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: all var(--transition-base);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    background: white;
    transform: translateX(22px);
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-left: 3px solid;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 10px;
    min-width: 300px;
    max-width: 400px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left-color: var(--accent-success);
}

.toast.error {
    border-left-color: var(--accent-danger);
}

.toast.warning {
    border-left-color: var(--accent-warning);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== 模态框 ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    max-width: 520px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.modal-close {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

/* ===== 数据分析面板 ===== */
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.analysis-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.analysis-title-group h2 {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.current-fruit-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
}

.time-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.time-btn {
    padding: 6px 14px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.time-btn:hover {
    color: var(--text-primary);
}

.time-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-subtle);
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-subtle);
    transition: all var(--transition-smooth);
}

.stat-item:hover {
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    font-size: 24px;
}

.stat-info {
    flex: 1;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-bottom: 2px;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* 图表 */
.charts-grid {
    display: grid;
    gap: 20px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-subtle);
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.chart-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

.chart-wrapper {
    width: 100%;
}

/* ===== 历史记录 ===== */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.history-header h2 {
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.2;
}

.empty-state p {
    font-size: 15px;
    font-weight: 500;
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
    .detection-overview {
        grid-template-columns: 1fr;
    }

    .sensor-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .topbar {
        padding: 0 16px;
    }

    .main-content {
        padding: 20px 16px;
    }

    .detection-overview,
    .sensor-grid,
    .env-grid,
    .stats-summary {
        grid-template-columns: 1fr;
    }

    .current-time,
    .battery-status {
        display: none;
    }
}

/* ===== 预警弹窗 ===== */
.alert-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.alert-modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.alert-content {
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    padding: 40px 36px 32px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: alertSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.alert-icon-wrapper {
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
}

.alert-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.1));
    border: 3px solid rgba(239, 68, 68, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--accent-danger);
    position: relative;
    animation: iconPulse 2s ease-in-out infinite;
}

.alert-icon::before {
    content: '';
    position: absolute;
    inset: -8px;
    border: 2px solid rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    animation: iconRipple 2s ease-out infinite;
}

.alert-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.alert-message {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.7;
}

.alert-actions {
    display: flex;
    gap: 10px;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px 24px;
    font-size: 15px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes alertSlideUp {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes iconRipple {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* ===== 打印 ===== */
@media print {
    .sidebar,
    .topbar,
    .form-actions,
    .btn {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .card {
        box-shadow: none;
    }
}
