/* ==========================================================
   ISSLB 源荷平衡智慧调度系统 — 全局样式
   深蓝科技风 / 工业监控台观感
   ========================================================== */
:root {
    --bg-deep: #0a1628;
    --bg-page: #f4f7fb;
    --bg-card: #ffffff;
    --bg-side: #0f2038;
    --bg-side-hover: #17304f;
    --brand: #1665d8;
    --brand-light: #3d8bf5;
    --brand-deep: #0b3f8f;
    --src: #f5a623;
    --load: #2f9e6e;
    --delta: #7c5cd6;
    --danger: #d9363e;
    --warn: #e8930c;
    --ok: #1f9254;
    --text: #1a2433;
    --text-2: #5b6b80;
    --text-3: #93a1b3;
    --border: #e2e8f0;
    --border-2: #cfd9e6;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 32, 56, .06), 0 6px 20px rgba(15, 32, 56, .05);
}

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

body {
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

.sidebar {
    width: 212px;
    flex: 0 0 212px;
    background: var(--bg-side);
    color: #c9d6e6;
    display: flex;
    flex-direction: column;
    position: relative;
}
.sidebar::after {
    content: "";
    position: absolute; right: 0; top: 0; bottom: 0; width: 1px;
    background: rgba(255, 255, 255, .06);
}
.logo {
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.logo-mark {
    display: flex; align-items: center; gap: 10px;
}
/* 竖版书法印块：保持原始比例，不压扁 */
.logo-img {
    height: 40px; width: auto; flex: 0 0 auto;
    display: block;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .35));
}
.logo-txt { display: flex; flex-direction: column; justify-content: center; }
.logo-text {
    font-size: 16px; font-weight: 700; color: #fff;
    letter-spacing: 1.2px; line-height: 1.15;
}
.logo-en {
    font-size: 9px; font-weight: 600; color: #4f9d6b;
    letter-spacing: 1.6px; margin-top: 2px;
}
.logo-sub {
    font-size: 11px; color: #7d90a8; margin-top: 9px; letter-spacing: .3px;
}

.nav { padding: 10px 0; flex: 1; }
.nav-group-title {
    font-size: 11px; color: #5f7591; padding: 12px 20px 6px; letter-spacing: .5px;
}
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    color: #b6c6d8; text-decoration: none; font-size: 13px;
    border-left: 2px solid transparent;
    transition: background .12s, color .12s;
}
.nav a:hover { background: var(--bg-side-hover); color: #e8f0fa; }
.nav a.active {
    background: rgba(61, 139, 245, .14);
    border-left-color: var(--brand-light);
    color: #fff; font-weight: 500;
}
.nav a .ni { width: 16px; text-align: center; opacity: .85; font-size: 14px; }

.side-foot {
    padding: 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    font-size: 11px; color: #647994;
}
.side-foot b { color: #93a9c2; font-weight: 500; }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 54px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 22px;
    gap: 16px;
}
.topbar h1 { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar .crumb { font-size: 12px; color: var(--text-3); }
.topbar .spacer { flex: 1; }
.topbar .clock {
    font-size: 12px; color: var(--text-2);
    font-variant-numeric: tabular-nums;
    padding: 4px 10px; background: #f4f7fb; border-radius: 6px;
}
.user-chip {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--text-2);
}
.avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: #e6f0fd; color: var(--brand);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.logout { color: var(--text-3); text-decoration: none; font-size: 12px; }
.logout:hover { color: var(--danger); }

.content { padding: 18px 22px 32px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.card-hd {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px;
}
.card-hd h2 { font-size: 14px; font-weight: 600; color: var(--text); }
.card-hd .sub { font-size: 12px; color: var(--text-3); }
.card-hd .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- 指标卡 ---------- */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 16px;
}
.metric {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow);
}
.metric::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--brand);
}
.metric.src::before { background: var(--src); }
.metric.load::before { background: var(--load); }
.metric.delta::before { background: var(--delta); }
.metric.energy::before { background: #3aa8c1; }
.metric .lbl {
    font-size: 12px; color: var(--text-2);
    display: flex; align-items: center; gap: 6px;
}
.metric .val {
    font-size: 25px; font-weight: 600; letter-spacing: -.5px;
    font-variant-numeric: tabular-nums;
    margin-top: 4px; line-height: 1.2;
}
.metric .val small { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 3px; }
.metric .hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.dot {
    width: 7px; height: 7px; border-radius: 50%; display: inline-block;
    background: var(--brand);
}

/* ---------- 表单控件 ---------- */
button, .btn {
    font-family: inherit; font-size: 12px;
    padding: 6px 13px;
    border: 1px solid var(--border-2);
    background: #fff; color: var(--text);
    border-radius: 6px; cursor: pointer;
    transition: all .12s;
    display: inline-flex; align-items: center; gap: 5px;
}
button:hover, .btn:hover { border-color: var(--brand-light); color: var(--brand); }
button.primary {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
button.primary:hover { background: #1157bd; border-color: #1157bd; color: #fff; }
button.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
button.ghost:hover { background: #f1f5fa; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { padding: 4px 9px; font-size: 11px; }

input, select {
    font-family: inherit; font-size: 12px;
    padding: 6px 9px;
    border: 1px solid var(--border-2);
    border-radius: 6px;
    color: var(--text); background: #fff;
    outline: none;
    transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus {
    border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(61, 139, 245, .12);
}
input[type=number] { width: 90px; font-variant-numeric: tabular-nums; }
label.fld {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-2);
}
.toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 10px 0 0;
}

/* ---------- 设备勾选面板 ---------- */
.pick-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pick-col h3 {
    font-size: 12px; font-weight: 500; color: var(--text-2);
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 7px;
}
.pick-col h3 .bar {
    width: 3px; height: 12px; border-radius: 2px; background: var(--src);
}
.pick-col.load h3 .bar { background: var(--load); }
.pick-list {
    display: flex; flex-wrap: wrap; gap: 7px;
}
.pick {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 11px 6px 9px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fafcff;
    cursor: pointer; user-select: none;
    font-size: 12px; color: var(--text-2);
    transition: all .12s;
}
.pick:hover { border-color: var(--border-2); background: #f3f8ff; }
.pick input { display: none; }
.pick .tick {
    width: 13px; height: 13px; border-radius: 4px;
    border: 1.5px solid var(--border-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; color: transparent;
    transition: all .12s;
}
.pick.on {
    border-color: var(--brand-light);
    background: #eaf3ff;
    color: var(--brand-deep);
    font-weight: 500;
}
.pick.on .tick { background: var(--brand); border-color: var(--brand); color: #fff; }
.pick .pw {
    font-size: 11px; color: var(--text-3);
    font-variant-numeric: tabular-nums;
    padding-left: 4px; border-left: 1px solid var(--border);
    margin-left: 2px;
}
.pick.on .pw { color: var(--brand); }

/* ---------- 曲线容器 ---------- */
.chart-box { width: 100%; height: 360px; }
.chart-box.tall { height: 420px; }
.chart-box.short { height: 260px; }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tbl th {
    text-align: left; font-weight: 500; color: var(--text-2);
    padding: 8px 10px; background: #f7f9fc;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.tbl td {
    padding: 8px 10px; border-bottom: 1px solid #f0f4f9;
    color: var(--text); font-variant-numeric: tabular-nums;
}
table.tbl tr:hover td { background: #fafcff; }
table.tbl td.num { text-align: right; }

.tag {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 500;
}
.tag.down { background: #fdeceb; color: var(--danger); }
.tag.up { background: #e8f6ee; color: var(--ok); }
.tag.hold { background: #f0f3f7; color: var(--text-2); }
.tag.info { background: #e6f0fd; color: var(--brand); }
.tag.warn { background: #fdf3e2; color: var(--warn); }

/* ---------- 折线图例 ---------- */
.legend {
    display: flex; flex-wrap: wrap; gap: 16px;
    font-size: 12px; color: var(--text-2);
    margin-bottom: 10px;
}
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i {
    width: 12px; height: 3px; border-radius: 2px; display: inline-block;
}

/* ---------- 登录页 ---------- */
.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 20% 20%, #16345c 0%, #0a1628 55%, #060f1c 100%);
    padding: 20px;
}
.login-card {
    width: 380px; background: #fff; border-radius: 14px;
    padding: 34px 32px 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.login-card .brand {
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
}
/* 登录页白底卡片：用原色完整版 logo */
.login-card .brand-logo {
    height: 120px; width: auto; display: block;
}
.login-card .brand-name {
    text-align: center;
    font-size: 19px; font-weight: 700; letter-spacing: 3px;
    color: #2f5233; margin-bottom: 4px;
}
.login-card .desc {
    font-size: 12px; color: var(--text-3); margin-bottom: 24px;
    padding-bottom: 18px; border-bottom: 1px solid var(--border);
    text-align: center;
}
.login-card .field { margin-bottom: 14px; }
.login-card .field label {
    display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px;
}
.login-card .field input { width: 100%; padding: 9px 11px; font-size: 13px; }
.login-card button {
    width: 100%; justify-content: center;
    padding: 10px; font-size: 13px; margin-top: 8px;
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.login-card button:hover { background: #1157bd; color: #fff; }
.login-err {
    font-size: 12px; color: var(--danger);
    min-height: 18px; margin-top: 10px;
}
.login-foot {
    font-size: 11px; color: var(--text-3);
    text-align: center; margin-top: 20px; line-height: 1.7;
}

/* ---------- 提示条 ---------- */
.notice {
    display: flex; gap: 9px; align-items: flex-start;
    padding: 10px 13px; border-radius: 8px;
    font-size: 12px; line-height: 1.65;
    background: #f0f6ff; border: 1px solid #d6e6fb; color: #2c4f7c;
    margin-bottom: 14px;
}
.notice.warn { background: #fff8ec; border-color: #f7dfb4; color: #7a5211; }
.notice .ic { flex: 0 0 auto; font-weight: 700; }
.notice code {
    background: rgba(0, 0, 0, .05); padding: 1px 5px; border-radius: 3px;
    font-family: Consolas, monospace; font-size: 11px;
}

/* ---------- 弹层 ---------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(10, 22, 40, .45);
    display: none; align-items: center; justify-content: center; z-index: 999;
}
.modal-mask.show { display: flex; }
.modal {
    background: #fff; border-radius: 12px; width: 480px; max-width: 92vw;
    padding: 20px 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
    max-height: 88vh; overflow: auto;
}
.modal h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.modal .row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 11px;
}
.modal .row label { width: 118px; font-size: 12px; color: var(--text-2); flex: 0 0 auto; }
.modal .row input, .modal .row select { flex: 1; }
.modal .foot {
    display: flex; justify-content: flex-end; gap: 9px;
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* ---------- 策略判定条 ---------- */
.verdict {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: 10px;
    background: #f7f9fc; border: 1px solid var(--border);
    margin-bottom: 14px;
}
.verdict .ico {
    width: 42px; height: 42px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px; flex: 0 0 auto;
}
.verdict .txt .t1 { font-size: 15px; font-weight: 600; }
.verdict .txt .t2 { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.verdict.down { background: #fef7f6; border-color: #f8d7d4; }
.verdict.down .ico { background: #fdeceb; color: var(--danger); }
.verdict.down .txt .t1 { color: var(--danger); }
.verdict.up { background: #f5fbf7; border-color: #d3ecdd; }
.verdict.up .ico { background: #e8f6ee; color: var(--ok); }
.verdict.up .txt .t1 { color: var(--ok); }
.verdict.hold .ico { background: #eef2f7; color: var(--text-2); }
.verdict .right { margin-left: auto; text-align: right; }

/* ---------- 滑块 ---------- */
.slider-row {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.slider-row label {
    width: 110px; font-size: 12px; color: var(--text-2); flex: 0 0 auto;
}
.slider-row input[type=range] {
    flex: 1; accent-color: var(--brand); padding: 0;
    border: none; background: transparent;
}
.slider-row input[type=number] { width: 82px; }
.slider-row .unit { font-size: 11px; color: var(--text-3); width: 32px; }

/* ---------- 网格 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 1180px) {
    .grid-2 { grid-template-columns: 1fr; }
    .pick-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar { display: none; }
    .grid-3 { grid-template-columns: 1fr; }
}

.empty {
    padding: 40px 20px; text-align: center;
    color: var(--text-3); font-size: 13px;
}
.spin {
    display: inline-block; width: 13px; height: 13px;
    border: 2px solid rgba(22, 101, 216, .25);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: sp .7s linear infinite;
    vertical-align: -2px;
}
@keyframes sp { to { transform: rotate(360deg); } }

.mono { font-family: Consolas, "Courier New", monospace; font-variant-numeric: tabular-nums; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
.flex { display: flex; align-items: center; gap: 8px; }

/* ===== 行政区划级联选择器 ===== */
.rg-sel {
    min-width: 92px;
    font-size: 12px;
    padding: 5px 6px;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.rg-sel:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(22, 101, 216, .12);
}
.rg-sel:disabled {
    opacity: .55;
    cursor: not-allowed;
    background: var(--bg-page);
}
.rg-row { width: 100%; }
#__rgbox { flex-wrap: wrap; }
.modal .row #fAddr { display: flex; gap: 6px; flex: 1; min-width: 0; }
.modal .row #fAddr .rg-sel { flex: 1; min-width: 0; }

/* ===== 设备勾选区里的地址筛选条 ===== */
.pick-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    margin-bottom: 8px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 8px;
    flex-wrap: wrap;
}
.pick-filter-lbl {
    font-size: 11px;
    color: var(--text-3);
    white-space: nowrap;
    flex: 0 0 auto;
}
.pick-filter > div { flex: 1; min-width: 0; }
.pick-filter .rg-row { gap: 5px; flex-wrap: wrap; }
.pick-filter .rg-sel { font-size: 11px; padding: 3px 4px; min-width: 74px; }
.pick-filter .sm { font-size: 11px; padding: 3px 8px; }

/* 设备勾选项里的街道标签 */
.pick-addr {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    font-size: 10px;
    line-height: 15px;
    color: var(--text-3);
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 3px;
    vertical-align: 1px;
}
.pick.on .pick-addr {
    color: var(--brand);
    background: rgba(22, 101, 216, .07);
    border-color: rgba(22, 101, 216, .25);
}

/* 预测页：已选设备摘要条 */
.fc-summary {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-2);
    background: rgba(22, 101, 216, .05);
    border-left: 3px solid var(--brand);
    border-radius: 0 6px 6px 0;
}
.fc-summary b { color: var(--brand); font-size: 13px; }
