:root {
    --bg: #0f0f23;
    --surface: #1a1a2e;
    --surface2: #16213e;
    --border: #2a2a4a;
    --text: #e0e0e0;
    --text-dim: #8888aa;
    --accent-dn: #4ecdc4;
    --accent-xb: #ff6b9d;
    --accent-urine: #ffd93d;
    --accent-poop: #c9a35e;
    --accent-warn: #ff6b6b;
    --accent-ok: #51cf66;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Header */
header {
    background: var(--surface);
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}
header h1 {
    font-size: 24px;
    margin-bottom: 12px;
}
.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.cat-switcher, .date-range {
    display: flex;
    gap: 4px;
}
.cat-btn, .range-btn, .year-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.cat-btn:hover, .range-btn:hover, .year-btn:hover {
    border-color: #4a4a6a;
    color: var(--text);
}
.cat-btn.active, .range-btn.active, .year-btn.active {
    background: #2a2a4a;
    border-color: #5a5a7a;
    color: var(--text);
}
.monitor-switcher {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}
.monitor-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.monitor-btn:hover {
    border-color: #4a4a6a;
    color: var(--text);
}
.monitor-btn.active {
    background: rgba(255,107,107,0.15);
    border-color: var(--accent-warn);
    color: var(--accent-warn);
}
.update-time {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-dim);
}
.refresh-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.refresh-btn:hover {
    border-color: #4a4a6a;
    color: var(--text);
}
.refresh-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Overview */
.overview {
    display: flex;
    gap: 20px;
    padding: 20px 30px;
}
.stat-card {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    overflow: hidden;
}
.stat-icon {
    width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.cat-大牛 .stat-icon { background: rgba(78,205,196,0.1); }
.cat-小斑 .stat-icon { background: rgba(255,107,157,0.1); }
.stat-content {
    flex: 1;
    padding: 14px;
}
.stat-content h3 {
    font-size: 15px;
    margin-bottom: 10px;
}
.cat-大牛 .stat-content h3 { color: var(--accent-dn); }
.cat-小斑 .stat-content h3 { color: var(--accent-xb); }
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.stat-item {
    text-align: center;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    display: block;
}
.cat-大牛 .stat-value { color: var(--accent-dn); }
.cat-小斑 .stat-value { color: var(--accent-xb); }
.stat-label {
    font-size: 11px;
    color: var(--text-dim);
    display: block;
    margin-top: 2px;
}
.stat-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 8px;
}

/* Quick Info */
.quick-info {
    display: flex;
    gap: 20px;
    padding: 0 30px 20px;
}
.info-card {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.info-card h2 {
    font-size: 15px;
    padding: 12px 16px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.info-body {
    padding: 14px 16px;
}
.info-card .cat-大牛 .stat-value { color: var(--accent-dn); }
.info-card .cat-小斑 .stat-value { color: var(--accent-xb); }
.stat-sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}
.diet-section { display: flex; gap: 20px; }
.diet-cat { flex: 1; }
.diet-cat-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: block;
    margin-bottom: 6px;
}
.diet-row {
    display: flex;
    gap: 8px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text);
}
.diet-label {
    white-space: nowrap;
    color: var(--text-dim);
}
.diet-info {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.diet-empty {
    color: var(--text-dim);
    font-size: 13px;
}

/* Calendar Legend */
.calendar-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 8px 0 4px;
    font-size: 12px;
    color: var(--text-dim);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

/* Charts */
.charts {
    padding: 0 30px 30px;
}
.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
.chart-box {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 16px;
}
.chart-box.wide {
    grid-column: 1 / -1;
}
.chart-box h2 {
    font-size: 15px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chart-hint {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: normal;
}
.year-selector {
    margin-left: auto;
    display: flex;
    gap: 4px;
}
.chart {
    height: 280px;
    width: 100%;
}
.chart-sm {
    height: 200px;
}

/* Timeline */
.timeline {
    max-height: 300px;
    overflow-y: auto;
}
.timeline-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.timeline-date {
    color: var(--text-dim);
    min-width: 50px;
}
.timeline-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.badge-大牛 { background: rgba(78,205,196,0.2); color: var(--accent-dn); }
.badge-小斑 { background: rgba(255,107,157,0.2); color: var(--accent-xb); }
.timeline-notes {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
}

/* Events */
.event-list {
    max-height: 300px;
    overflow-y: auto;
}
.event-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    font-size: 13px;
    background: rgba(255,107,107,0.08);
    border-left: 3px solid var(--accent-warn);
}
.event-item.ok {
    background: rgba(81,207,102,0.08);
    border-left-color: var(--accent-ok);
}
.event-cat {
    font-weight: 600;
}
.event-date {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 12px;
    border-top: 1px solid var(--border);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }

/* Responsive */
@media (max-width: 768px) {
    header { padding: 15px; }
    .controls { flex-direction: column; gap: 10px; }
    .update-time { margin-left: 0; }
    .overview { padding: 15px; flex-direction: column; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .charts { padding: 0 15px 15px; }
    .chart-row { grid-template-columns: 1fr; }
    .chart { height: 250px; }
    .quick-info { flex-direction: column; padding: 0 15px 15px; }
}

/* 摄像头监控 */
.camera-section {
    padding: 0 30px 20px;
}
.camera-section h2 {
    font-size: 15px;
    margin-bottom: 12px;
}
.camera-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.camera-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.camera-label {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.camera-img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: #000;
    display: block;
}

/* 猫砂盆事件 */
.litter-events-section {
    padding: 0 30px 20px;
}
.litter-events-section h2 {
    font-size: 15px;
    margin-bottom: 12px;
}
.litter-events-list {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}
.litter-event-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.litter-event-item:last-child {
    border-bottom: none;
}
.litter-event-time {
    color: var(--text-dim);
    min-width: 80px;
}
.litter-event-camera {
    color: var(--accent-dn);
    min-width: 100px;
}
.litter-event-label {
    color: var(--text);
}
