:root {
  --bg: #f5f5f7;            /* Apple 官网近白底 */
  --card: #ffffff;
  --card-2: #fbfbfd;
  --text: #1d1d1f;          /* 主文字 */
  --text-2: #6e6e73;        /* 次要 */
  --text-3: #86868b;        /* 弱化 */
  --line: rgba(0, 0, 0, 0.08);
  --blue: #0071e3;          /* Apple 系统蓝 */
  --blue-deep: #0060c9;
  --green: #34c759;         /* 正收益 / 放电 */
  --red: #ff3b30;           /* 负收益 / 充电 */
  --orange: #ff9500;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.10);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ---------- 顶部毛玻璃导航 ---------- */
header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px; height: 60px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
header h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
header .sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; transition: background .3s var(--ease); }
.dot.idle { background: #d1d1d6; }
.dot.busy { background: var(--orange); animation: blink 1.1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- 顶部 WorkBuddy 登录态 ---------- */
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.wb-user { font-size: 13px; color: var(--text-2); font-weight: 500; display: inline-flex; align-items: center; gap: 7px; }
.wb-user .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #0071e3, #5ac8fa);
  color: #fff; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.wb-login-btn {
  border: none; background: rgba(0, 113, 227, 0.10); color: var(--blue);
  border-radius: 980px; padding: 7px 15px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .22s var(--ease);
}
.wb-login-btn:hover { background: rgba(0, 113, 227, 0.18); }

/* ---------- WorkBuddy 登录弹层 ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .25s var(--ease);
}
.login-overlay[hidden] { display: none; }
.login-card {
  position: relative; width: min(400px, calc(100vw - 40px));
  background: var(--card); border-radius: 24px;
  box-shadow: var(--shadow-lg); padding: 34px 30px 26px;
  text-align: center;
  animation: popIn .3s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: scale(0.94) translateY(8px); } to { opacity: 1; transform: none; } }
.login-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: #f0f0f2; color: var(--text-2); font-size: 14px;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.login-close:hover { background: #e4e4e8; color: var(--text); }
.login-logo {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px;
  background: linear-gradient(135deg, #0071e3, #5ac8fa);
  color: #fff; font-size: 30px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(0, 113, 227, 0.35);
}
.login-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.login-sub { font-size: 12.5px; color: var(--text-3); line-height: 1.7; margin: 8px 0 18px; }
.login-main { width: 100%; justify-content: center; padding: 12px 18px; font-size: 15px; }
.login-hint { font-size: 11.5px; color: var(--text-3); margin: 10px 0 0; }
.login-field { text-align: left; margin-bottom: 12px; font-size: 12px; color: var(--text-2); }
.login-note {
  font-size: 12.5px; color: #b3403a; text-align: left; line-height: 1.8;
  background: #fff5f5; border: 1px solid rgba(255, 59, 48, 0.22);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 6px;
}
.login-note code { font-size: 11px; }
.login-error { font-size: 12.5px; color: #ff3b30; margin: 10px 0 2px; text-align: center; }
.login-skip { margin-top: 14px; font-size: 13px; }
.login-card input { margin-top: 5px; }

/* ---------- 主布局 ---------- */
main { display: grid; grid-template-columns: 356px 1fr; gap: 22px; padding: 22px 28px 40px; max-width: 1560px; margin: 0 auto; }
@media (max-width: 980px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--line);
}
.panel h2 {
  font-size: 12px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 22px 0 12px;
}
.panel h2:first-child { margin-top: 0; }

/* ---------- 表单 ---------- */
.row { display: flex; gap: 10px; flex-wrap: wrap; }
button, .btn {
  font-family: var(--font);
  border: none; border-radius: 980px;          /* 胶囊 */
  padding: 10px 18px; cursor: pointer; font-size: 14px; font-weight: 500;
  transition: all .22s var(--ease);
  background: #e8e8ed; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover { background: #dcdce1; }
button.primary { background: var(--blue); color: #fff; box-shadow: 0 4px 14px rgba(0, 113, 227, 0.28); }
button.primary:hover { background: var(--blue-deep); }
button.ghost { background: transparent; color: var(--blue); }
button.ghost:hover { background: rgba(0, 113, 227, 0.08); }
button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn { border: 1px solid var(--line); background: #fff; }

label { font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; gap: 5px; }
label.full { margin-top: 12px; }
input, select {
  font-family: var(--font);
  background: #f5f5f7; border: 1px solid transparent; color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; width: 100%;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
input:focus, select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.14); background: #fff;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }

/* 12 个月分时电价表 */
.price-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.price-tbl th, .price-tbl td { padding: 3px 4px; text-align: center; }
.price-tbl th { color: var(--text-3); font-weight: 600; }
.price-tbl td:first-child { color: var(--text-2); text-align: left; white-space: nowrap; }
.price-tbl input { padding: 5px 6px; font-size: 12px; text-align: center; }

/* 分时时段 24h 条状图 */
.tou-bar { margin-bottom: 8px; }
.tou-bar-inner { display: flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.tou-cell { flex: 1; height: 30px; color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.tou-legend { display: flex; gap: 14px; margin-top: 6px; font-size: 11px; color: var(--text-3); }
.tou-legend span { display: inline-flex; align-items: center; gap: 4px; }
.tou-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
#price-msg a { color: var(--blue); text-decoration: none; }
#price-msg a:hover { text-decoration: underline; }
.actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }

.hint { font-size: 12px; color: var(--text-3); margin-top: 10px; min-height: 18px; line-height: 1.55; }

/* 客户信息（电费单 OCR 出） */
.customer-info {
  margin-top: 12px; padding: 10px 12px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  font-size: 12.5px; color: var(--text-2); line-height: 1.7;
}
.customer-info b { color: var(--text); font-weight: 600; }
.customer-info .addr { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.warn { color: #ff3b30; font-weight: 600; }

.ingest-warnings {
  margin-top: 12px; padding: 10px 12px;
  background: #fff5f5; border: 1px solid rgba(255, 59, 48, 0.25); border-radius: 12px;
  font-size: 12px; color: #b3403a; line-height: 1.8; max-height: 220px; overflow-y: auto;
}
.ingest-warnings div { white-space: normal; }

/* 分段控件（预留） */
.seg { display: inline-flex; background: #e8e8ed; border-radius: 980px; padding: 3px; }
.seg button { background: transparent; padding: 6px 14px; font-size: 13px; }
.seg button.active { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

/* ---------- 结果区 ---------- */
.result { min-height: 70vh; }
.placeholder { color: var(--text-3); padding: 80px 0; text-align: center; font-size: 15px; }

.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.result-title { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--card-2); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.card .k { font-size: 12px; color: var(--text-3); }
.card .v { font-size: 20px; font-weight: 600; margin-top: 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card .v.pos { color: var(--green); }
.card .v.neg { color: var(--red); }
.card .v.blue { color: var(--blue); }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-box { background: var(--card-2); border: 1px solid var(--line); border-radius: 16px; padding: 10px; }
.chart-box.wide { grid-column: 1 / -1; }
.chart-toolbar { display: flex; align-items: center; gap: 10px; padding: 2px 6px 8px; }
.chart-toolbar select { flex: 0 0 auto; width: auto; padding: 6px 10px; font-size: 12px; }
.chart-toolbar .hint { margin: 0; color: var(--text-2); }
.chart { width: 100%; height: 320px; }
.chart-box.wide .chart { height: 340px; }

.footnote { margin-top: 14px; font-size: 12px; color: var(--text-3); line-height: 1.7; }
.footnote b { color: var(--green); font-weight: 600; }

/* 骨架屏 */
.skeleton { background: linear-gradient(90deg, #eee 25%, #f7f7f8 50%, #eee 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 结果淡入 */
.fade-in { animation: fadeIn .5s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media print {
  header, .panel.input { display: none; }
  main { display: block; padding: 0; }
  .panel.result { box-shadow: none; border: none; padding: 0; }
}

/* ---------- 顶部 Tab ---------- */
.tabs { display: flex; gap: 6px; padding: 12px 28px 0; max-width: 1560px; margin: 0 auto; }
.tab {
  border: none; background: transparent; color: var(--text-2);
  padding: 8px 16px; font-size: 14px; font-weight: 500; border-radius: 980px; cursor: pointer;
  transition: all .22s var(--ease);
}
.tab:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.tab.active { background: var(--text); color: #fff; }

/* ---------- 原理说明页 ---------- */
.explain { max-width: 760px; margin: 0 auto; padding: 28px 24px 60px; }
.explain-inner { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 40px 44px; }
.exp-title { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.exp-lead { color: var(--text-3); font-size: 15px; margin: 8px 0 8px; }
.exp-section { margin-top: 36px; }
.exp-section h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 10px; }
.exp-section p { color: var(--text-2); line-height: 1.85; margin: 8px 0; }
.hl { color: var(--blue); font-weight: 600; }
.exp-list { color: var(--text-2); line-height: 2.1; padding-left: 22px; margin: 8px 0; }
.exp-note { font-size: 13px; color: var(--text-3); }

.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.flow-item { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 500; }
.flow .arrow { color: var(--text-3); font-size: 16px; }

.tou-demo { margin: 14px 0; }
.tou-demo-bar { display: flex; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.tou-demo-label { font-size: 12px; color: var(--text-3); margin-top: 8px; }

.demand-svg { background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin: 14px 0; }
.demand-svg svg { width: 100%; height: auto; display: block; }
.svg-label { font-size: 11px; fill: #8e8e93; }
.svg-blue { fill: #0071e3; }
.svg-legend { font-size: 11px; fill: #6e6e73; }

/* 原理页：步骤标题、公式、表格 */
.exp-step-head { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.exp-step-head h2 { margin: 0; }
.step-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.step-en { font-size: 12px; color: var(--text-3); font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
.exp-h3 { font-size: 14px; font-weight: 600; margin: 18px 0 8px; color: var(--text); }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, "SF Mono", Consolas, monospace;
  font-size: 12.5px; background: var(--card-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; color: #1d1d1f;
}
.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, "SF Mono", Consolas, monospace;
  font-size: 12.5px; line-height: 2.05; color: #1d1d1f;
  background: var(--card-2); border: 1px solid var(--line); border-left: 3px solid var(--blue);
  border-radius: 10px; padding: 12px 16px; margin: 12px 0; overflow-x: auto;
}
.formula .f-note { color: var(--text-3); font-size: 11.5px; font-family: var(--font); margin-left: 8px; }
.formula sub, .formula sup { font-size: 9.5px; }
.exp-table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 12px; }
.exp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.exp-table th, .exp-table td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line);
  color: var(--text-2); vertical-align: top;
}
.exp-table th { background: var(--card-2); color: var(--text); font-weight: 600; white-space: nowrap; }
.exp-table tr:last-child td { border-bottom: none; }
.exp-table td code { white-space: nowrap; }
@media (max-width: 640px) {
  .explain-inner { padding: 26px 20px; }
  .exp-title { font-size: 24px; }
}
