/* FranklinWH App · EU Demo prototype — shared styles
   Colors follow Fleetview 2.0 tokens; series colors align with ai_card_colors (EV ≠ generator). */
:root {
  --primary: #EE8E25;
  --primary-weak: rgba(238, 142, 37, 0.12);
  --success: #10b981;
  --warning: #f97316;
  --danger: #F53F3F;
  --info: #0792FB;
  --text: #0D1316;
  --text-secondary: rgba(13, 19, 22, 0.55);
  --text-tertiary: rgba(13, 19, 22, 0.38);
  --bg-page: #F7F8FA;
  --bg-card: #FFFFFF;
  --border: #EEEEEE;
  --solar: #F5B400;
  --grid: #6B7280;
  --battery: #10b981;
  --ev: #0792FB;
  --heatpump: #8B5CF6;
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow: 0 1px 2px rgba(13, 19, 22, 0.06), 0 4px 16px rgba(13, 19, 22, 0.06);
  font-size: 16px;
}

/* ---------- Language switch (CSS-driven, JS only flips data-lang) ---------- */
html[data-lang="en"] [lang="zh"],
html[data-lang="zh"] [lang="en"] { display: none !important; }

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #E9ECF1;
  line-height: 1.45;
}
a { color: var(--info); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* ---------- Prototype chrome ---------- */
.proto-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--text); color: #fff;
}
.proto-bar h1 { font-size: 1rem; margin: 0; flex: 1; font-weight: 600; }
.proto-bar .back { color: rgba(255,255,255,.8); text-decoration: none; font-size: 0.875rem; }
.proto-bar .meta { font-size: 0.75rem; color: rgba(255,255,255,.6); }
.lang-toggle {
  border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff;
  border-radius: 999px; padding: 0.25rem 0.75rem; font-size: 0.8125rem;
}
.lang-toggle[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); }

.page-intro { max-width: 80rem; margin: 1.5rem auto 0; padding: 0 1.5rem; color: var(--text-secondary); font-size: 0.875rem; }
.page-intro strong { color: var(--text); }
.board {
  display: flex; flex-wrap: wrap; gap: 2rem; align-items: flex-start;
  max-width: 90rem; margin: 0 auto; padding: 1.5rem;
}
.shot { margin: 0; display: flex; flex-direction: column; gap: 0.75rem; align-items: center; }
.shot figcaption { max-width: 24rem; text-align: center; font-size: 0.8125rem; color: var(--text-secondary); }
.shot figcaption strong { display: block; color: var(--text); font-size: 0.875rem; margin-bottom: 0.125rem; }
.ref { display: inline-block; font-size: 0.6875rem; padding: 0 0.375rem; border-radius: 0.25rem; background: #DDE3EA; color: #3B4652; margin: 0.125rem; }

.anno {
  width: 18rem; background: #FFF8E6; border: 1px solid #F3D9A4; border-radius: var(--radius);
  padding: 1rem; font-size: 0.8125rem; color: #5B4A1E;
}
.anno h2, .anno h3 { margin: 0 0 0.5rem; font-size: 0.875rem; color: #3A2E0E; }
.anno ul { margin: 0; padding-left: 1.1rem; }
.anno li { margin-bottom: 0.375rem; }

/* ---------- Phone frame ---------- */
.phone {
  width: 375px; height: 780px; border-radius: 44px; background: #111;
  padding: 10px; box-shadow: 0 20px 50px rgba(13,19,22,.25);
}
.screen {
  position: relative; width: 100%; height: 100%; border-radius: 36px; overflow: hidden;
  background: var(--bg-page); display: flex; flex-direction: column;
}
.status {
  display: flex; justify-content: space-between; padding: 0.75rem 1.5rem 0.25rem;
  font-size: 0.8125rem; font-weight: 600;
}
.appbar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.appbar h2 { flex: 1; margin: 0; font-size: 1.0625rem; text-align: center; }
.appbar .icon-btn { width: 2.75rem; height: 2.75rem; border: 0; background: transparent; font-size: 1.125rem; border-radius: 50%; }
.content { flex: 1; overflow: hidden; padding: 0.75rem 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.tabbar {
  display: flex; justify-content: space-around; padding: 0.5rem 0 1.25rem;
  background: var(--bg-card); border-top: 1px solid var(--border); font-size: 0.6875rem; color: var(--text-tertiary);
}
.tabbar span { display: flex; flex-direction: column; align-items: center; gap: 0.125rem; }
.tabbar .on { color: var(--primary); font-weight: 600; }

/* ---------- Generic UI ---------- */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 0.875rem; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 0.5rem; font-size: 0.9375rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.muted { color: var(--text-secondary); font-size: 0.8125rem; }
.tiny { font-size: 0.6875rem; color: var(--text-tertiary); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 0.375rem 0.75rem; font-size: 0.8125rem; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.badge { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.6875rem; font-weight: 600; padding: 0.125rem 0.5rem; border-radius: 999px; background: var(--primary-weak); color: #B5650F; }
.badge.ok { background: rgba(16,185,129,.12); color: #047857; }
.badge.bad { background: rgba(245,63,63,.1); color: #B42318; }
.badge.grey { background: #EEF0F3; color: var(--text-secondary); }
.badge.info { background: rgba(7,146,251,.1); color: #0563AA; }
.est { font-size: 0.625rem; font-weight: 600; color: #8A6A2C; background: #FFF3D6; border-radius: 0.25rem; padding: 0 0.3rem; margin-left: 0.25rem; vertical-align: middle; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; min-height: 2.75rem; padding: 0 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 600; font-size: 0.875rem; text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.applied { background: #EEF0F3; color: var(--text-secondary); cursor: default; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 0.5rem; }
.btn-row .btn { flex: 1; }

/* ---------- Energy flow (EU topology) ---------- */
.flow { position: relative; height: 22rem; background: linear-gradient(180deg, #DDEBFA 0%, #F7F8FA 70%); border-radius: var(--radius); overflow: hidden; }
.flow svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.flow .line { stroke: #C9D2DC; stroke-width: 3; fill: none; }
.flow .line.live { stroke-dasharray: 6 8; animation: dash 1.2s linear infinite; }
.flow .line.solar { stroke: var(--solar); }
.flow .line.battery { stroke: var(--battery); }
.flow .line.grid { stroke: var(--grid); }
.flow .line.ev { stroke: var(--ev); }
.flow .line.hp { stroke: var(--heatpump); }
.flow .line.off { stroke: #E3E7EC; }
@keyframes dash { to { stroke-dashoffset: -28; } }
@media (prefers-reduced-motion: reduce) { .flow .line.live { animation: none; } }
.node { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 0.125rem; width: 6rem; transform: translate(-50%, -50%); text-align: center; font-size: 0.6875rem; color: var(--text-secondary); text-decoration: none; }
.node .bubble { width: 3.25rem; height: 3.25rem; border-radius: 50%; display: grid; place-items: center; background: #fff; box-shadow: var(--shadow); font-size: 1.375rem; }
.node b { color: var(--text); font-size: 0.8125rem; }
.node.hub .bubble { width: 4.5rem; height: 4.5rem; background: var(--text); color: #fff; font-size: 0.75rem; font-weight: 700; }
.node.dim { opacity: 0.45; }
.node.tap .bubble { outline: 2px solid var(--primary); outline-offset: 3px; }

/* ---------- Chat ---------- */
.chat { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 0.625rem; padding: 0.75rem 0.875rem; }
.msg-user { align-self: flex-end; max-width: 82%; }
.msg-user .bubble { background: var(--primary); color: #fff; padding: 0.625rem 0.75rem; border-radius: 0.875rem 0.875rem 0.25rem 0.875rem; font-size: 0.875rem; }
.msg-actions { display: flex; gap: 0.25rem; justify-content: flex-end; margin-top: 0.25rem; }
.msg-actions button, .ans-actions button { min-width: 2.75rem; min-height: 2.75rem; border: 0; background: transparent; color: var(--text-secondary); font-size: 0.75rem; border-radius: var(--radius-sm); }
.msg-actions button:hover, .ans-actions button:hover { background: #EEF0F3; }
.msg-ai { align-self: stretch; }
.msg-ai .text { background: var(--bg-card); border-radius: 0.875rem 0.875rem 0.875rem 0.25rem; padding: 0.625rem 0.75rem; font-size: 0.875rem; box-shadow: var(--shadow); }
.ans-actions { display: flex; align-items: center; gap: 0.125rem; }
.ans-actions .ai-tag { margin-left: auto; font-size: 0.625rem; color: var(--text-tertiary); }
.thinking { font-size: 0.75rem; color: var(--text-secondary); display: flex; align-items: center; gap: 0.375rem; }
.thumbs { display: flex; gap: 0.375rem; justify-content: flex-end; }
.thumb { width: 4.5rem; height: 4.5rem; border-radius: var(--radius-sm); background: repeating-linear-gradient(135deg, #E9EDF2 0 8px, #F4F6F8 8px 16px); display: grid; place-items: center; font-size: 1.25rem; position: relative; }
.thumb .prog { position: absolute; left: 0.25rem; right: 0.25rem; bottom: 0.25rem; height: 0.25rem; background: #fff; border-radius: 999px; overflow: hidden; }
.thumb .prog i { display: block; height: 100%; background: var(--primary); }
.thumb .x { position: absolute; top: -0.375rem; right: -0.375rem; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--text); color: #fff; font-size: 0.625rem; display: grid; place-items: center; }
.thumb.fail { outline: 2px solid var(--danger); }
.suggest { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.suggest button { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 0.5rem 0.75rem; min-height: 2.25rem; font-size: 0.75rem; color: var(--text); text-align: left; }
.sys-note { align-self: center; font-size: 0.6875rem; color: var(--text-tertiary); background: #EEF0F3; padding: 0.125rem 0.625rem; border-radius: 999px; }
.err-bubble { background: #FFF1F0; border: 1px solid #FFCCC7; border-radius: 0.75rem; padding: 0.625rem 0.75rem; font-size: 0.8125rem; color: #A8071A; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.to-bottom { position: absolute; right: 1rem; bottom: 6.5rem; width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow); font-size: 1.125rem; }

.composer { background: var(--bg-card); border-top: 1px solid var(--border); padding: 0.5rem 0.75rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.composer .bar { display: flex; align-items: center; gap: 0.375rem; }
.composer .plus, .composer .send, .composer .mic { width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 0; background: #EEF0F3; font-size: 1.125rem; flex-shrink: 0; }
.composer .send { background: var(--primary); color: #fff; }
.composer .send[disabled] { background: #F2C99A; }
.composer .input { flex: 1; min-height: 2.5rem; border: 1px solid var(--border); border-radius: 1.25rem; padding: 0.5rem 0.875rem; font-size: 0.875rem; color: var(--text-tertiary); background: var(--bg-page); }
.welcome { text-align: center; padding: 0.5rem 0 0.25rem; }
.welcome h3 { margin: 0.25rem 0; font-size: 1.125rem; }
.welcome .ai-disclose { font-size: 0.75rem; color: var(--text-secondary); }
.mode-tabs { display: flex; gap: 0.375rem; padding: 0 0.875rem 0.25rem; }
.mode-tabs span { font-size: 0.75rem; border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 0.25rem 0.625rem; }
.mode-tabs .on { border-color: var(--primary); background: var(--primary-weak); color: #B5650F; font-weight: 600; }

/* ---------- AI cards ---------- */
.ai-card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.75rem; font-size: 0.8125rem; display: flex; flex-direction: column; gap: 0.5rem; }
.ai-card header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.ai-card header h4 { margin: 0; font-size: 0.875rem; }
.chart { height: 7rem; width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.625rem; color: var(--text-secondary); }
.legend i { display: inline-block; width: 0.625rem; height: 0.25rem; border-radius: 1px; margin-right: 0.25rem; vertical-align: middle; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.375rem; }
.kpi { background: var(--bg-page); border-radius: var(--radius-sm); padding: 0.375rem 0.5rem; }
.kpi span { display: block; font-size: 0.625rem; color: var(--text-secondary); }
.kpi b { font-size: 0.875rem; }
.logic { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.logic li { font-size: 0.75rem; border-left: 3px solid var(--primary); padding-left: 0.5rem; }
.slider { height: 0.375rem; border-radius: 999px; background: #EEF0F3; position: relative; }
.slider i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--ev); }
.slider b { position: absolute; top: 50%; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transform: translate(-50%, -50%); border: 2px solid var(--ev); }
.check-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.25rem; }
.check-list li { display: grid; grid-template-columns: 1.25rem 1fr auto; gap: 0.375rem; align-items: start; font-size: 0.75rem; }
.check-list .hint { grid-column: 2 / 4; color: var(--text-secondary); font-size: 0.6875rem; }

/* ---------- Bottom sheet / dialog ---------- */
.scrim { position: absolute; inset: 0; background: rgba(13,19,22,.45); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 1.25rem 1.25rem 0 0; padding: 1rem 1rem 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.sheet .grab { width: 2.5rem; height: 0.25rem; background: #DDE1E6; border-radius: 999px; margin: 0 auto; }
.sheet h3 { margin: 0; font-size: 1rem; }
.diff { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.375rem; font-size: 0.8125rem; }
.diff li { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; padding: 0.5rem 0.625rem; background: var(--bg-page); border-radius: var(--radius-sm); }
.diff .from { color: var(--text-tertiary); text-decoration: line-through; margin-right: 0.25rem; }
.diff .to { font-weight: 700; }
.banner-warn { background: #FFF7E6; border: 1px solid #FFD591; color: #874D00; border-radius: var(--radius-sm); padding: 0.5rem 0.625rem; font-size: 0.75rem; }
.dialog { position: absolute; left: 1.5rem; right: 1.5rem; top: 40%; background: #fff; border-radius: 1rem; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dialog h3 { margin: 0; font-size: 1rem; }

/* ---------- Lists ---------- */
.list { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list .item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.875rem; border-bottom: 1px solid var(--border); min-height: 3.5rem; }
.list .item:last-child { border-bottom: 0; }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .title { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .item.swiped { transform: translateX(-5rem); position: relative; }
.list .del { position: absolute; right: -5rem; top: 0; bottom: 0; width: 5rem; background: var(--danger); color: #fff; display: grid; place-items: center; font-size: 0.8125rem; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field label { font-size: 0.8125rem; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 0.5rem; }
.stepper button { width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 1px solid var(--border); background: #fff; font-size: 1.125rem; }
.stepper output { flex: 1; text-align: center; font-size: 1.25rem; font-weight: 700; }
.edited { color: var(--primary); }

/* ---------- Index ---------- */
.hub { max-width: 72rem; margin: 0 auto; padding: 2rem 1.5rem 3rem; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.hub-card { display: flex; flex-direction: column; gap: 0.5rem; background: #fff; border-radius: var(--radius); padding: 1rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); border: 1px solid transparent; }
.hub-card:hover { border-color: var(--primary); }
.hub-card h3 { margin: 0; font-size: 1rem; }
.hub-card p { margin: 0; font-size: 0.8125rem; color: var(--text-secondary); }
.hub h2 { font-size: 1rem; margin: 2rem 0 0.75rem; }
.legend-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; font-size: 0.8125rem; }
.legend-table th, .legend-table td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.legend-table th { background: #F2F4F7; }

@media (max-width: 768px) {
  .board { padding: 1rem; gap: 1.5rem; justify-content: center; }
  .anno { width: 100%; }
}
