/* ===== CSS 变量 ===== */
:root {
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --text: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8888aa;
    --border: #e8e8f0;
    --card-bg: #ffffff;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --radius: 12px;
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;
    --blue: #3b82f6;
}

.dark {
    --bg: #0a0a0f;
    --bg-secondary: #14141e;
    --text: #ededf0;
    --text-secondary: #a0a0b8;
    --text-muted: #6a6a82;
    --border: #2a2a3a;
    --card-bg: #14141e;
    --shadow: 0 2px 12px 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-secondary);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    transition: background 0.2s, color 0.2s;
}

.container {
    max-width: 720px;
    width: 100%;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 32px 36px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: background 0.2s, border 0.2s;
}

/* ===== 头部 ===== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.logo-area h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== 时间范围选择器 ===== */
.time-range-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 28px 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    appearance: none;
    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='%238888aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.2s, background-color 0.2s;
}
.time-range-select:hover {
    border-color: var(--text-muted);
}
.time-range-select:focus {
    outline: none;
    border-color: var(--text-secondary);
}
.dark .time-range-select {
    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='%236a6a82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.time-range-select option {
    background: var(--bg);
    color: var(--text);
}

/* ===== 主题切换按钮 ===== */
.icon-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.icon-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}
.icon-btn.sm {
    padding: 4px 6px;
}
.icon-btn.sm svg {
    width: 18px;
    height: 18px;
}
.icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* ===== 全局状态横幅 ===== */
.banner {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    transition: 0.2s;
}
.dark .banner {
    background: #0f2a1a;
    border-color: #22c55e44;
}
.banner-icon {
    font-size: 22px;
}
.banner-title {
    font-weight: 600;
    font-size: 17px;
    color: #15803d;
}
.banner-desc {
    font-size: 14px;
    color: var(--text-secondary);
}
.dark .banner-title {
    color: #86efac;
}

/* ===== 通用标签 ===== */
.section-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 14px;
}

/* ===== 系统状态标题 + 选择器 ===== */
.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

/* ===== 服务列表 ===== */
.service-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 32px;
}

.service-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid transparent;
    transition: 0.2s;
}
.service-item:hover {
    border-color: var(--border);
}

.service-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.service-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.service-dot.online {
    background: var(--green);
}
.service-dot.degraded {
    background: var(--yellow);
}
.service-dot.partial_outage {
    background: var(--orange);
}
.service-dot.full_outage {
    background: var(--red);
}
.service-dot.maintenance {
    background: var(--blue);
}

.service-name {
    font-weight: 500;
    font-size: 15px;
}
.service-addr {
    font-size: 13px;
    color: var(--text-muted);
    font-family: monospace;
    margin-left: 4px;
}

.service-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}
.service-uptime {
    font-weight: 500;
    color: var(--text-secondary);
}
.service-status-text {
    color: var(--text-muted);
}

/* ===== 历史趋势图 ===== */
.history-section {
    margin-bottom: 32px;
}
.history-section .section-label {
    margin-bottom: 10px;
}

.history-row {
    margin-bottom: 14px;
}
.history-row:last-child {
    margin-bottom: 0;
}

.history-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.history-label .name {
    font-weight: 500;
}
.history-label .uptime {
    color: var(--text-muted);
}

.history-bars {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    min-height: 26px;
    padding: 2px 0;
    align-content: flex-start;
}

.history-bar {
    height: 24px;
    border-radius: 2px;
    cursor: pointer;
    transition: opacity 0.15s;
    min-width: 3px;
}
.history-bar:hover {
    opacity: 0.7;
}

.history-bar.operational {
    background: var(--green);
}
.history-bar.degraded {
    background: var(--yellow);
}
.history-bar.partial_outage {
    background: var(--orange);
}
.history-bar.full_outage {
    background: var(--red);
}
.history-bar.maintenance {
    background: var(--blue);
}
.history-bar.empty {
    background: var(--text-muted);
    opacity: 0.15;
}

/* ===== 事件日历 ===== */
.calendar-section {
    border-top: 1px solid var(--border);
    padding-top: 20px;
    margin-bottom: 8px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.calendar-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* 视图切换按钮组 */
.view-switcher {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 2px;
    border: 1px solid var(--border);
}
.view-btn {
    background: transparent;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}
.view-btn:hover {
    color: var(--text-secondary);
}
.view-btn.active {
    background: var(--bg);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.calendar-nav span {
    font-size: 14px;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
}

/* 日历网格（月视图） */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 12px;
}
.calendar-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 0;
}
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.15s;
    position: relative;
}
.calendar-day:hover {
    background: var(--bg-secondary);
}
.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.3;
}
.calendar-day.today {
    font-weight: 700;
    border: 1px solid var(--text-muted);
}
.calendar-day.has-event::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--orange);
}
.calendar-day.has-event.resolved::after {
    background: var(--green);
}

/* 周视图 */
.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}
.week-day {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 8px 4px;
    text-align: center;
    cursor: pointer;
    transition: 0.15s;
    min-height: 70px;
}
.week-day:hover {
    background: var(--border);
}
.week-day .day-number {
    font-size: 18px;
    font-weight: 600;
}
.week-day .day-name {
    font-size: 12px;
    color: var(--text-muted);
}
.week-day .event-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--orange);
    margin-top: 4px;
}
.week-day .event-dot.resolved {
    background: var(--green);
}
.week-day.today {
    border: 1px solid var(--text-muted);
}

/* 年视图 */
.year-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}
.year-month {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: 0.15s;
}
.year-month:hover {
    background: var(--border);
}
.year-month .month-name {
    font-weight: 600;
    font-size: 14px;
}
.year-month .month-events {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.year-month.has-event .month-name {
    color: var(--orange);
}
.year-month.has-event.resolved .month-name {
    color: var(--green);
}

/* 日视图 */
.day-view {
    padding: 8px 0;
}
.day-view .day-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.day-view .event-item {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    align-items: flex-start;
}
.day-view .event-item:last-child {
    border-bottom: none;
}
.day-view .event-time {
    color: var(--text-muted);
    min-width: 60px;
    font-size: 13px;
}
.day-view .event-title {
    font-weight: 500;
}
.day-view .event-desc {
    color: var(--text-secondary);
    font-size: 13px;
}
.day-view .event-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 1px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 2px;
}
.day-view .event-badge.resolved {
    background: #dcfce7;
    color: #15803d;
}
.day-view .event-badge.ongoing {
    background: #fef9c3;
    color: #a16207;
}
.day-view .event-badge.degraded {
    background: #fef3c7;
    color: #b45309;
}
.dark .day-view .event-badge.resolved {
    background: #0f2a1a;
    color: #86efac;
}
.dark .day-view .event-badge.ongoing {
    background: #2a2510;
    color: #facc15;
}
.dark .day-view .event-badge.degraded {
    background: #2a1f10;
    color: #fb923c;
}

/* ===== 底部 ===== */
footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}
footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: 0.2s;
}
footer a:hover {
    color: var(--text);
}
.footer-links {
    display: flex;
    gap: 18px;
}

/* ===== 响应式 ===== */
@media (max-width: 600px) {
    .container {
        padding: 20px 16px;
    }
    .service-item {
        flex-wrap: wrap;
        gap: 6px;
    }
    .service-right {
        margin-left: 22px;
    }
    .banner {
        flex-wrap: wrap;
    }
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    .calendar-nav span {
        min-width: 80px;
        font-size: 13px;
    }
    .calendar-day {
        font-size: 13px;
    }
    .time-range-select {
        padding: 4px 24px 4px 10px;
        font-size: 12px;
    }
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .calendar-header-left {
        justify-content: space-between;
    }
    .week-day {
        min-height: 50px;
        padding: 4px 2px;
    }
    .week-day .day-number {
        font-size: 14px;
    }
    .year-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}