/* =========================================================================
   AI智护机器人健康风险预警与护理调度管理系统 —— 全局样式
   采用左侧导航 + 顶部栏 + 内容区的经典 B/S 管理后台布局。
   配色遵循数据可视化规范：状态色（红/橙/黄/蓝/绿）仅用于风险与状态表达，
   主色（青蓝）用于品牌与交互，文字使用中性墨色，图表网格保持克制。
   ========================================================================= */

:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --sidebar: #16263b;
    --sidebar-2: #1e3350;
    --sidebar-active: #0e7c86;
    --primary: #0e7c86;
    --primary-soft: #e3f4f5;
    --ink: #1a2433;
    --ink-2: #4a5768;
    --muted: #8a97a8;
    --border: #e2e8f0;
    /* 风险 / 状态色卡 */
    --risk-critical: #e5484d;
    --risk-high: #f76b15;
    --risk-medium: #e6a700;
    --risk-low: #3b82c4;
    --ok: #30a46c;
    --shadow: 0 1px 3px rgba(20, 40, 70, 0.08), 0 1px 2px rgba(20, 40, 70, 0.04);
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ---------------- 布局骨架 ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    background: var(--sidebar);
    color: #c6d2e0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}
.brand .logo {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 18px; font-weight: 700; color: #fff;
}
.brand .logo .dot {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, #0e7c86, #16a3b0);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
}
.brand .sub { font-size: 12px; margin-top: 6px; color: #8496ab; }

.nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-group-title {
    font-size: 11px; color: #6b7b90; padding: 12px 20px 6px;
    letter-spacing: 1px;
}
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 20px; color: #c6d2e0; font-size: 14px;
    border-left: 3px solid transparent;
}
.nav a .ico { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav a.active {
    background: rgba(14, 124, 134, 0.22);
    border-left-color: var(--sidebar-active);
    color: #fff; font-weight: 600;
}

.sidebar-foot {
    padding: 14px 20px; font-size: 12px; color: #6b7b90;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 60px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 17px; font-weight: 600; }
.topbar .page-title small { font-weight: 400; color: var(--muted); margin-left: 10px; font-size: 13px; }
.topbar .sys-fullname {
    flex: 1; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 16px;
}
.topbar .sys-fullname span { color: var(--muted); font-weight: 400; margin-left: 4px; }
@media (max-width: 1280px) { .topbar .sys-fullname { display: none; } }
.topbar .user-box { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.topbar .user-box .role-chip {
    background: var(--primary-soft); color: var(--primary);
    padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.topbar .user-box a.logout { color: var(--muted); }
.topbar .user-box a.logout:hover { color: var(--risk-critical); }

.content { padding: 22px 24px 40px; }

/* ---------------- 通用组件 ---------------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .card-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card .card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card .card-head .hint { font-size: 12px; color: var(--muted); }
.card .card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.col-span-2 { grid-column: span 2; }

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* 指标卡 */
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
    position: relative; overflow: hidden;
}
.stat .label { font-size: 13px; color: var(--ink-2); }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 6px; line-height: 1.1; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat .bar-ico {
    position: absolute; right: 14px; top: 14px; width: 40px; height: 40px;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 20px; background: var(--primary-soft); color: var(--primary);
}
.stat.danger .bar-ico { background: #fdecec; color: var(--risk-critical); }
.stat.warn .bar-ico { background: #fef4e6; color: var(--risk-high); }
.stat.ok .bar-ico { background: #e7f6ee; color: var(--ok); }

/* 徽标 */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
    white-space: nowrap;
}
.badge .d { width: 7px; height: 7px; border-radius: 50%; }
.badge-critical { background: #fdecec; color: var(--risk-critical); }
.badge-high { background: #fef1e7; color: var(--risk-high); }
.badge-medium { background: #fdf6e3; color: #b58600; }
.badge-low { background: #eaf2fb; color: var(--risk-low); }
.badge-online, .badge-completed, .badge-reviewed, .badge-resolved { background: #e7f6ee; color: var(--ok); }
.badge-offline, .badge-overdue { background: #fdecec; color: var(--risk-critical); }
.badge-warning, .badge-maintenance { background: #fef4e6; color: var(--risk-high); }
.badge-plain { background: var(--surface-2); color: var(--ink-2); }

/* 表格 */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left; color: var(--ink-2); font-weight: 600;
    padding: 10px 12px; border-bottom: 2px solid var(--border);
    background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { font-variant-numeric: tabular-nums; }

/* 按钮 */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--ink); font-size: 13px;
    cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #0a6a72; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: var(--risk-critical); border-color: #f3c9ca; }
.btn-danger:hover { background: #fdecec; color: var(--risk-critical); }

/* 筛选栏 */
.filterbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.filterbar select, .filterbar input {
    padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; background: var(--surface); color: var(--ink);
}
.filterbar .spacer { flex: 1; }

/* 进度条 */
.progress { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 6px; background: var(--primary); }

/* 时间线 */
.timeline { list-style: none; margin: 0; padding: 4px 0 0; position: relative; }
.timeline:before {
    content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px;
    width: 2px; background: var(--border);
}
.timeline li { position: relative; padding: 0 0 16px 30px; }
.timeline li .node {
    position: absolute; left: 2px; top: 3px; width: 14px; height: 14px;
    border-radius: 50%; background: var(--primary); border: 3px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
}
.timeline li .t { font-size: 12px; color: var(--muted); }
.timeline li .n { font-weight: 600; }

/* 提示条 */
.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.flash-success { background: #e7f6ee; color: #1e7a4d; }
.flash-error { background: #fdecec; color: var(--risk-critical); }
.flash-warning { background: #fef4e6; color: #b0570a; }

/* 图例 */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; }

.section-title { font-size: 15px; font-weight: 600; margin: 24px 0 12px; }
.muted { color: var(--muted); }
.mini { font-size: 12px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb0 { margin-bottom: 0; }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.tag {
    display: inline-block; padding: 2px 9px; margin: 2px 4px 2px 0;
    background: var(--primary-soft); color: var(--primary);
    border-radius: 6px; font-size: 12px;
}
.tag.warn { background: #fef4e6; color: #b0570a; }

/* 登录页 */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #16263b 0%, #0e7c86 100%);
}
.login-card {
    background: #fff; border-radius: 16px; padding: 36px 34px; width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card label { font-size: 13px; color: var(--ink-2); display: block; margin: 12px 0 6px; }
.login-card input {
    width: 100%; padding: 11px 13px; border: 1px solid var(--border);
    border-radius: 9px; font-size: 14px;
}
.login-card .btn-primary { width: 100%; justify-content: center; margin-top: 20px; padding: 11px; }
.demo-accounts { margin-top: 20px; border-top: 1px dashed var(--border); padding-top: 14px; }
.demo-accounts .t { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.demo-accounts .acc {
    display: inline-block; margin: 3px 5px 3px 0; padding: 4px 9px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 6px; font-size: 12px; cursor: pointer;
}
.demo-accounts .acc:hover { border-color: var(--primary); color: var(--primary); }

/* 图表容器 */
.chart-svg { width: 100%; height: auto; display: block; }
.heatcell { stroke: #fff; stroke-width: 2; }
.kanban { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 1300px) { .kanban { grid-template-columns: repeat(3, 1fr); } }
.kanban .col { background: var(--surface-2); border-radius: 10px; padding: 10px; min-height: 120px; }
.kanban .col h4 { margin: 0 0 10px; font-size: 13px; display: flex; justify-content: space-between; }
.kanban .col .cnt { color: var(--muted); font-weight: 400; }
.kanban .tk {
    background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--primary);
    border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; font-size: 12px;
}
.kanban .tk .tt { font-weight: 600; margin-bottom: 4px; }
.kanban .tk.critical { border-left-color: var(--risk-critical); }
.kanban .tk.high { border-left-color: var(--risk-high); }
.kanban .tk.medium { border-left-color: var(--risk-medium); }
.kanban .tk.low { border-left-color: var(--risk-low); }

/* 截图模式：隐藏交互控件，保证界面稳定 */
body.screenshot .topbar .logout,
body.screenshot .btn-refresh { display: none; }
body.screenshot .screenshot-badge {
    display: inline-block; margin-left: 12px; font-size: 12px;
    color: var(--muted); border: 1px dashed var(--border); padding: 2px 8px; border-radius: 6px;
}
.screenshot-badge { display: none; }
