/* 天津分公司智能消防管理系统 — 共享样式 */
:root {
    --red: #d03b3b;
    --red-bg: #fdf2f2;
    --red-text: #991b1b;
    --red-badge: #f5d0d0;
    --orange: #ec835a;
    --orange-bg: #fff6f2;
    --orange-text: #92400e;
    --orange-badge: #fbe2d5;
    --yellow: #fab219;
    --yellow-bg: #fffaf0;
    --yellow-text: #92400e;
    --yellow-badge: #fbeec3;
    --green: #0ca30c;
    --green-bg: #f1faf1;
    --green-text: #166534;
    --green-badge: #cdeecd;
    --blue: #2a78d6;
    --blue-bg: #eef4fc;
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #1f2937;
    --text2: #6b7280;
    --text3: #9ca3af;
    --grid: #e5e7eb;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --chart-cat: #2a78d6, #1baf7a, #eda100, #008300, #4a3aa7, #e34948, #e87ba4, #eb6834;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    min-height: 100vh;
    padding-bottom: 40px;
    -webkit-font-smoothing: antialiased;
    color: var(--text);
}

/* ===== 顶部状态栏 ===== */
.top-bar {
    position: sticky; top: 0; z-index: 100;
    background: linear-gradient(135deg, #991b1b 0%, #dc2626 50%, #b91c1c 100%);
    color: #fff;
    padding: 14px 16px 12px;
    box-shadow: 0 2px 12px rgba(153, 27, 27, 0.35);
}
.top-bar .title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top-bar h1 { font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.top-bar h1 .icon { font-size: 22px; }
.title-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-group h1 { min-width: 0; }
.back-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff; border-radius: 8px; font-size: 20px; line-height: 1;
    text-decoration: none; transition: background 0.2s;
}
.back-btn:active { background: rgba(255, 255, 255, 0.35); }
.refresh-btn {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 7px 13px; border-radius: 8px;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background 0.2s;
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap;
}
.refresh-btn:active { background: rgba(255, 255, 255, 0.35); }
.refresh-btn.spinning .spinner { animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.top-meta {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px; font-size: 12px; color: rgba(255, 255, 255, 0.85);
    flex-wrap: wrap;
}
.stale-tag {
    background: #fff; color: var(--red); font-weight: 700;
    padding: 1px 7px; border-radius: 6px; font-size: 11px;
}

/* ===== 布局容器 ===== */
.container { max-width: 760px; margin: 0 auto; padding: 14px 14px 0; }

/* ===== KPI 统计卡 ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 12px 14px;
}
.kpi .kpi-label { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 5px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.kpi .kpi-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.kpi-critical .kpi-value { color: var(--red); }
.kpi-warning .kpi-value { color: var(--orange); }
.kpi-ok .kpi-value { color: var(--green); }
.kpi-inactive { grid-column: 1 / -1; }
.kpi-inactive .kpi-value { color: var(--text2); }

/* ===== 卡片 ===== */
.card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px;
}
.card-title {
    font-size: 14px; font-weight: 700; color: var(--text);
    margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between;
}
.card-title .sub { font-size: 11px; font-weight: 400; color: var(--text3); }
.chart-box { width: 100%; height: 300px; }
.chart-box.tall { height: 340px; }

/* ===== 工具栏：搜索 + 车站过滤 ===== */
.toolbar { margin-bottom: 14px; }
.search-input {
    width: 100%; padding: 10px 12px; font-size: 16px;
    border: 1px solid var(--grid); border-radius: 10px;
    background: var(--card); box-shadow: var(--shadow);
    outline: none;
}
.search-input:focus { border-color: var(--blue); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip {
    padding: 5px 12px; border-radius: 999px; font-size: 12px;
    background: var(--card); border: 1px solid var(--grid);
    color: var(--text2); cursor: pointer; transition: all 0.15s;
}
.chip.active { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
th {
    text-align: left; padding: 8px 10px; color: var(--text3); font-weight: 600;
    border-bottom: 2px solid var(--grid); white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
.row-over { background: #fdf7f7; }
td .muted { color: var(--text3); }

/* ===== 状态徽章 ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px;
    white-space: nowrap;
}
.badge.b-critical { color: var(--red-text); background: var(--red-badge); border: 1px solid var(--red); }
.badge.b-serious { color: var(--orange-text); background: var(--orange-badge); border: 1px solid var(--orange); }
.badge.b-warning { color: var(--yellow-text); background: var(--yellow-badge); border: 1px solid var(--yellow); }
.badge.b-good     { color: var(--green-text); background: var(--green-badge); border: 1px solid var(--green); }
.badge.b-normal   { color: var(--green-text); background: var(--green-badge); border: 1px solid var(--green); }
.badge.b-gray     { color: #4b5563; background: #f3f4f6; border: 1px solid #d1d5db; }
.row-inactive td { color: var(--text3); }

/* ===== 空态 / 加载 ===== */
.empty {
    text-align: center; padding: 40px 20px; color: var(--text2);
}
.empty .empty-icon { font-size: 40px; margin-bottom: 10px; }
.empty .empty-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty .empty-desc { font-size: 12px; line-height: 1.6; color: var(--text3); }
.content-loading { opacity: 0.55; transition: opacity 0.2s; }

/* ===== 导航首页 ===== */
.nav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.nav-card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 16px; text-decoration: none; color: var(--text);
    border: 2px solid transparent; transition: border-color 0.15s, transform 0.1s;
    display: block;
}
.nav-card:active { transform: scale(0.98); }
.nav-card .nav-icon { font-size: 26px; }
.nav-card .nav-title { font-size: 15px; font-weight: 700; margin-top: 8px; }
.nav-card .nav-desc { font-size: 12px; color: var(--text2); margin-top: 4px; line-height: 1.5; min-height: 34px; }
.nav-card .nav-meta { font-size: 11px; color: var(--text3); margin-top: 8px; }
.nav-card.home-banner {
    grid-column: 1 / -1; text-align: center; padding: 16px;
    background: linear-gradient(135deg, #991b1b 0%, #dc2626 50%, #b91c1c 100%);
    color: #fff;
}
.nav-card.home-banner .nav-title { font-size: 18px; margin-top: 4px; }
.nav-card.home-banner .nav-desc { color: rgba(255, 255, 255, 0.9); }

/* 首页 KPI 条 */
.index-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.index-stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 8px; text-align: center; }
.index-stat .v { font-size: 20px; font-weight: 700; }
.index-stat .l { font-size: 11px; color: var(--text2); margin-top: 2px; }
