/* =====================================================================
 * 双合发电厂 · 电力交易驾驶舱 —— 样式
 * 深色大屏 / 响应式 / 无外部依赖
 * ===================================================================== */

:root {
  --bg: #070c16;
  --bg-2: #0b1220;
  --panel: #101a2e;
  --panel-2: #0d1626;
  --line: #1b2740;
  --line-2: #243353;
  --text: #e6edf7;
  --muted: #8aa0bf;
  --dim: #5d7595;

  --blue: #4d9fff;
  --green: #2ee6a8;
  --amber: #f5a623;
  --red: #e5484d;
  --purple: #9d7bff;
  --orange: #ff8a4d;
  --cyan: #38d6ff;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 12% -8%, rgba(77, 159, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(46, 230, 168, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  background: rgba(122, 162, 255, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
  color: var(--cyan);
}

/* ===================== 顶部栏 ===================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(8, 14, 26, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(77, 159, 255, 0.25), rgba(46, 230, 168, 0.18));
  border: 1px solid rgba(77, 159, 255, 0.35);
  box-shadow: 0 0 18px rgba(77, 159, 255, 0.25);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 切换按钮组 */
.scope-switch, .month-switch, .period-tabs, .day-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.scope-btn, .month-btn, .period-btn, .day-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-family: inherit;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.scope-btn:hover, .month-btn:hover, .period-btn:hover, .day-btn:hover {
  color: var(--text);
  background: rgba(122, 162, 255, 0.08);
}

.scope-btn.active, .month-btn.active, .period-btn.active, .day-btn.active {
  color: #04101f;
  background: linear-gradient(135deg, #7fc0ff, #3fe0b0);
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(77, 159, 255, 0.3);
}

.day-tabs { flex-wrap: wrap; max-width: 560px; }
.day-btn { padding: 4px 9px; font-size: 12px; }

.btn {
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover { border-color: var(--blue); color: #fff; box-shadow: 0 0 0 3px rgba(77, 159, 255, 0.12); }
.btn-primary { background: linear-gradient(135deg, rgba(77, 159, 255, 0.9), rgba(46, 230, 168, 0.8)); color: #04101f; border-color: transparent; font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 3px 9px; font-size: 11.5px; margin-left: 8px; }
.btn-close { padding: 4px 12px; font-size: 16px; line-height: 1; }

.clock { display: flex; flex-direction: column; align-items: flex-end; padding-left: 6px; }
.clock-time { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }
.clock-date { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ===================== 状态条 ===================== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 22px;
  background: linear-gradient(90deg, rgba(77, 159, 255, 0.06), transparent 40%);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.chip {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--muted);
  white-space: nowrap;
}

.chip-ok { color: #8ef0c6; border-color: rgba(46, 230, 168, 0.35); background: rgba(46, 230, 168, 0.08); }
.chip-warn { color: #ffc97a; border-color: rgba(245, 166, 35, 0.4); background: rgba(245, 166, 35, 0.09); }
.chip-muted { color: var(--dim); }

.status-tip {
  margin-left: auto;
  color: var(--dim);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

/* ===================== 主布局 ===================== */
.main {
  padding: 18px 22px 40px;
  max-width: 1900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section {
  background: linear-gradient(180deg, rgba(16, 26, 46, 0.92), rgba(10, 17, 30, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.head-left { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.section-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  position: relative;
  padding-left: 12px;
}

.section-title::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 15px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--blue), var(--green));
}

.section-sub { font-size: 11.5px; color: var(--muted); }

.badge {
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  background: var(--panel-2);
  white-space: nowrap;
}
.badge-ok { color: #8ef0c6; border-color: rgba(46, 230, 168, 0.35); background: rgba(46, 230, 168, 0.08); }
.badge-warn { color: #ffc97a; border-color: rgba(245, 166, 35, 0.4); background: rgba(245, 166, 35, 0.09); }

/* ===================== KPI 卡 ===================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}

.kpi-card {
  position: relative;
  padding: 13px 14px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, rgba(20, 32, 55, 0.95), rgba(12, 20, 35, 0.95));
  border: 1px solid var(--line);
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--kpi-glow, var(--blue)), transparent 85%);
}

.kpi-card:hover { transform: translateY(-2px); border-color: var(--line-2); }

.kpi-card.kpi-warn { border-color: rgba(229, 72, 77, 0.5); box-shadow: inset 0 0 24px rgba(229, 72, 77, 0.12); }
.kpi-card.kpi-empty { opacity: 0.62; }

.kpi-name { font-size: 12px; color: var(--muted); margin-bottom: 7px; letter-spacing: 0.2px; }

.kpi-value {
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.kpi-value .unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--dim);
  margin-left: 5px;
  letter-spacing: 0;
}

.kpi-note {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--dim);
  line-height: 1.4;
}


/* ===================== 查询栏（口径 + 日期） ===================== */
.query-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.query-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.query-label {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-right: 2px;
  white-space: nowrap;
}

.query-range {
  font-size: 10.5px;
  color: var(--dim);
  margin-left: 6px;
  white-space: nowrap;
}

.date-nav {
  appearance: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.date-nav:hover { color: var(--text); border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77, 159, 255, 0.12); }

input[type="date"] {
  appearance: none;
  font-family: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text);
  color-scheme: dark;
  cursor: pointer;
}

input[type="date"]:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(77, 159, 255, 0.15); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

@media (max-width: 900px) {
  .query-bar { gap: 10px; }
  .query-range { display: none; }
}

/* ===================== KPI 分组 + 期间徽标 ===================== */
.kpi-group {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 -4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.5px;
}

.kpi-group::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(56, 214, 255, 0.35), transparent);
}

.kpi-period {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 500;
  border-radius: 4px;
  vertical-align: 1px;
  letter-spacing: 0.2px;
}

.kpi-period-day { color: #9fe0ff; background: rgba(77, 159, 255, 0.16); }
.kpi-period-mtd { color: #ffd79a; background: rgba(245, 166, 35, 0.16); }
.kpi-period-ytd { color: #c9b6ff; background: rgba(157, 123, 255, 0.18); }

/* ===================== 图表容器 ===================== */
.chart-box {
  width: 100%;
  height: 260px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 4px;
}

.chart-box.tall { height: 320px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

/* ===================== 面板 / 表格 ===================== */
.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.panel-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
}

.panel-note {
  margin: 0 0 10px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
}

.bullet {
  margin: 0;
  padding-left: 18px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.7;
}
.bullet.warn { color: #ffc97a; }

.table-wrap { overflow: auto; max-height: 300px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.table-wrap.compact { max-height: 230px; margin-top: 10px; }

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.tbl thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #14203a;
  color: var(--muted);
  font-weight: 500;
  text-align: right;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}

.tbl thead th:first-child { text-align: left; }

.tbl tbody td {
  padding: 6px 9px;
  text-align: right;
  border-bottom: 1px solid rgba(27, 39, 64, 0.7);
  color: var(--text);
}

.tbl tbody td:first-child { text-align: left; color: var(--muted); }
.tbl tbody tr:hover td { background: rgba(77, 159, 255, 0.06); }
.tbl tbody tr.hl td { background: rgba(77, 159, 255, 0.1); font-weight: 600; }

.tbl td.pos { color: #6fe7b6; }
.tbl td.neg { color: #ff8f92; }
.tbl td.warnc { color: #ffc97a; }
.tbl td.mono { font-family: Consolas, monospace; font-size: 11px; }

/* ===================== 分时统计卡 ===================== */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mini-card {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, rgba(20, 32, 55, 0.9), rgba(12, 20, 35, 0.9));
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

.mini-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--mini-glow, var(--blue));
}

.mini-name { font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.mini-value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mini-value .unit { font-size: 10.5px; font-weight: 400; color: var(--dim); margin-left: 4px; }
.mini-sub { font-size: 10.5px; color: var(--dim); margin-top: 4px; }

/* ===================== 机组卡 ===================== */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.unit-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, rgba(20, 32, 55, 0.95), rgba(12, 20, 35, 0.95));
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

.unit-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--unit-color, var(--blue)), transparent 80%);
}

.unit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.unit-title { font-size: 14px; font-weight: 600; letter-spacing: 0.3px; }
.unit-status { font-size: 11.5px; color: var(--muted); }
.unit-status.on { color: #6fe7b6; }
.unit-status.off { color: #ff8f92; }

.unit-rows { display: flex; flex-direction: column; gap: 6px; }

.unit-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
}

.unit-row .label { color: var(--muted); }
.unit-row .val { font-variant-numeric: tabular-nums; font-weight: 500; }

.progress {
  height: 4px;
  border-radius: 2px;
  background: rgba(27, 39, 64, 0.9);
  margin-top: 12px;
  overflow: hidden;
}

.progress span { display: block; height: 100%; border-radius: 2px; transition: width 0.3s ease; }

/* ===================== 风险卡 ===================== */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.risk-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, rgba(20, 32, 55, 0.9), rgba(12, 20, 35, 0.92));
  border: 1px solid var(--line);
  border-left: 3px solid var(--risk-color, var(--blue));
}

.risk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.risk-level {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  color: #08111f;
  font-weight: 600;
  flex-shrink: 0;
}

.risk-title { font-size: 13.5px; font-weight: 600; letter-spacing: 0.2px; }

.risk-item { display: flex; gap: 8px; margin-bottom: 7px; font-size: 11.5px; line-height: 1.6; }

.rk {
  flex-shrink: 0;
  width: 34px;
  color: var(--dim);
  font-size: 11px;
}

.rv { color: var(--muted); }

/* ===================== 模态框 ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(3, 7, 14, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: min(1100px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 { margin: 0; font-size: 15px; }
.modal-sub { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }
.modal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.modal-body { padding: 16px 20px 22px; overflow: auto; }
.modal-h4 { margin: 18px 0 8px; font-size: 12.5px; font-weight: 600; color: var(--cyan); letter-spacing: 0.3px; }
.modal-h4:first-child { margin-top: 0; }

.modal-foot {
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
}

/* ===================== 页脚 ===================== */
.footer {
  padding: 14px 22px 26px;
  border-top: 1px solid var(--line);
  max-width: 1900px;
  margin: 0 auto;
}

.footer p { margin: 0; font-size: 11px; color: var(--dim); line-height: 1.7; }

/* ===================== 滚动条 ===================== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1f2d47; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #2b3d5f; }

/* ===================== 响应式 ===================== */
@media (max-width: 780px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .status-tip { display: none; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .chart-box { height: 230px; }
  .chart-box.tall { height: 280px; }
}
