/* 《供电所模拟器》v2 —— 浅色卡片皮肤（对齐参考游戏：米白底+绿主色+圆角卡片） */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body { font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f2f3ec; color: #2c3a2e; }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 1100px; margin: 0 auto; background: #f2f3ec; }

/* 加载页 */
#loading { position: fixed; inset: 0; z-index: 99; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: #10173a; }
#loading-title { width: min(76vw, 560px); border-radius: 14px; box-shadow: 0 18px 60px rgba(40,80,220,.45); }
.ld-bar { width: min(60vw, 320px); height: 8px; background: rgba(255,255,255,.15); border-radius: 4px; overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, #4caf50, #a5d6a7); border-radius: 4px; animation: ld 1.1s infinite; }
@keyframes ld { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.ld-txt { color: #b9c6ee; font-size: 14px; }

/* 顶栏 */
#topbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #fff; border-bottom: 1px solid #e2e6da; flex-wrap: wrap; }
.tb-group { display: flex; gap: 8px; align-items: center; }
.tb { font-size: 13px; color: #5d6b5f; white-space: nowrap; }
.tb-badge { font-size: 12px; font-weight: 700; color: #fff; background: #4a7c2f; border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.tb-res { margin-left: auto; }
.res-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; color: #33422f; background: #eef3e6; border: 1px solid #d7e2c4; border-radius: 8px; padding: 2px 7px; }
.res-chip img { width: 17px; height: 17px; object-fit: contain; }
.res-chip b { color: #2f6b1f; }
#t-sats { display: flex; gap: 6px; }
.sat-chip { font-size: 12px; text-align: center; color: #4c5a4e; }
.sat-chip.off { opacity: 0.4; }
.sat-bar { width: 40px; height: 4px; background: #e2e6da; border-radius: 2px; overflow: hidden; }
.sat-bar i { display: block; height: 100%; transition: width .4s; }
.icon-btn { background: #eef3e6; border: 1px solid #d7e2c4; color: #4c5a4e; border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 14px; }

/* 警告横幅（煤安全线/棕闪） */
#warnbar { background: #fdeaea; color: #c23a3a; font-size: 13px; font-weight: 600; text-align: center; padding: 5px 10px; border-bottom: 1px solid #f5cfcf; }

/* 舞台 */
#stage { position: relative; flex: 1; min-height: 0; }
#cv { width: 100%; height: 100%; display: block; background: #a5d68a; touch-action: manipulation; }

/* 底栏 */
#bottombar { display: flex; gap: 10px; padding: 8px 10px; background: #fff; border-top: 1px solid #e2e6da; }
.main-btn { flex: 1; padding: 12px; font-size: 16px; font-weight: 800; color: #fff; background: url('../assets/raw/ui_btn_green.png') center/100% 100%; border: none; border-radius: 12px; cursor: pointer; text-shadow: 0 1px 2px rgba(30,80,20,.4); }
.main-btn.alt { background: url('../assets/raw/ui_btn_green.png') center/100% 100%; filter: hue-rotate(-8deg) saturate(.85); }
.main-btn:active { transform: scale(0.98); }
.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(74,124,47,.5); } 50% { box-shadow: 0 0 0 9px rgba(74,124,47,0); } }

/* 事件卡 */
#cards { position: absolute; top: 8px; right: 8px; width: 274px; display: flex; flex-direction: column; gap: 8px; max-height: 80%; overflow: hidden; }
.card { background: url('../assets/raw/ui_card.png') center/100% 100%, #fff; border: 1px solid #dbe5cc; border-left: 5px solid #e04b3a; border-radius: 14px; padding: 9px 11px; box-shadow: 0 6px 18px rgba(60,90,40,.14); }
.card.pop { animation: cardin .3s ease-out; }
@keyframes cardin { from { transform: translateX(40px); opacity: 0; } }
.chead { display: flex; justify-content: space-between; font-size: 11px; color: #8a987f; margin-bottom: 3px; }
.ctime { color: #e04b3a; font-weight: 800; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .4; } }
.ctitle { font-size: 15px; font-weight: 800; color: #b8442f; }
.cbody { font-size: 12px; color: #5d6b5f; line-height: 1.5; margin: 3px 0 7px; }
.dead { height: 4px; background: #e8ecdd; border-radius: 2px; margin-bottom: 7px; }
.dead i { display: block; height: 100%; background: #e04b3a; border-radius: 2px; }
.copts { display: flex; flex-direction: column; gap: 5px; }
.opt { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 9px; border: 1px solid #dbe5cc; background: #fbfdf7; color: #33422f; cursor: pointer; font-size: 13px; text-align: left; }
.opt b { font-size: 13px; }
.opt span { font-size: 11px; color: #8a987f; }
.opt.money span { color: #c96a1f; }
.opt.ad { border-color: #9ecb8a; background: #f0f8ea; }
.opt.ad span { color: #4a7c2f; }
.opt:active { transform: scale(0.98); }
.card-queue { font-size: 11px; color: #8a987f; text-align: center; padding: 4px; background: rgba(255,255,255,.9); border-radius: 8px; }

/* 提示与浮字 */
#toasts { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 5px; align-items: center; pointer-events: none; z-index: 30; width: max-content; max-width: 92%; }
.toast { background: rgba(255,255,255,.96); border: 1px solid #dbe5cc; padding: 7px 14px; border-radius: 20px; font-size: 13px; animation: cardin .25s; transition: opacity .4s; box-shadow: 0 4px 14px rgba(60,90,40,.15); }
.toast.out { opacity: 0; }
#floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floaty { position: absolute; left: 58%; top: 46%; font-size: 14px; font-weight: 800; animation: floatup 2.3s ease-out forwards; text-shadow: 0 1px 3px rgba(255,255,255,.8); }
.floaty.good { color: #2f8f1f; } .floaty.bad { color: #d24a35; }
@keyframes floatup { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-70px); opacity: 0; } }
#hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.96); border: 1px solid #b9d29a; color: #3f601f; padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .4s; pointer-events: none; white-space: nowrap; }
#hint.show { opacity: 1; }

/* 仪式横幅 */
#ceremony { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; pointer-events: none; background: radial-gradient(circle, rgba(255,225,140,.25), transparent 65%); }
#ceremony.show { display: flex; }
.cer-text { text-align: center; font-size: 26px; font-weight: 900; color: #7a4a10; background: rgba(255,250,235,.92); padding: 18px 30px; border-radius: 18px; box-shadow: 0 10px 40px rgba(150,110,30,.3); animation: cerpop .8s ease-out; }
.cer-text small { display: block; font-size: 14px; font-weight: 400; color: #7d8a72; margin-top: 8px; }
@keyframes cerpop { from { transform: scale(0.6); opacity: 0; } }

/* 对象信息条（stage 内覆盖层，不改变画布尺寸） */
#infobar { position: absolute; left: 0; right: 0; bottom: 0; display: none; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(255,255,255,.96); border-top: 1px solid #dbe5cc; z-index: 25; box-shadow: 0 -4px 16px rgba(60,90,40,.12); }
#infobar.show { display: flex; flex-wrap: wrap; }
#info-body { font-size: 13px; color: #33422f; flex: 1; min-width: 140px; }
#info-body b { color: #2f6b1f; }
#info-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.i-btn { background: #4a7c2f; color: #fff; border: none; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.i-btn:disabled { background: #c2cdb6; }
#info-close { flex-shrink: 0; }

/* 模式条（stage 内覆盖层） */
#modebar { position: absolute; left: 0; right: 0; bottom: 0; display: none; align-items: center; justify-content: center; gap: 12px; padding: 8px; background: rgba(63,96,31,.94); color: #fff; font-size: 13px; font-weight: 600; z-index: 26; }
#modebar.show { display: flex; }
.mini-btn { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: 2px 10px; cursor: pointer; font-size: 12px; }

/* 建设面板（底部抽屉） */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 64%; background: #fff; border-top: 2px solid #b9d29a; border-radius: 18px 18px 0 0; transform: translateY(105%); transition: transform .25s ease-out; display: flex; flex-direction: column; z-index: 20; box-shadow: 0 -8px 30px rgba(60,90,40,.18); }
.sheet.open { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px 4px; }
#build-body { overflow-y: auto; padding: 6px 14px 16px; }
.b-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 11px 12px; margin: 5px 0; border-radius: 11px; border: 1px solid #dbe5cc; background: #fbfdf7; color: #33422f; cursor: pointer; }
.b-btn span { font-size: 12px; color: #8a987f; }
.b-btn:disabled { opacity: 0.45; }
.b-info { padding: 8px 4px 2px; color: #8a987f; font-size: 13px; border-top: 1px dashed #e2e6da; margin-top: 8px; }
.b-locked { padding: 9px 4px; color: #a9b39f; font-size: 13px; }
.b-toggle { display: flex; justify-content: space-between; padding: 11px 12px; border-radius: 11px; border: 1px solid #dbe5cc; background: #fbfdf7; cursor: pointer; margin: 5px 0; font-size: 14px; }
.b-toggle b { color: #a9b39f; } .b-toggle.on b { color: #2f8f1f; }
h3 { color: #4a7c2f; font-size: 15px; margin: 10px 0 2px; }

/* 电价滑杆 */
.price-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; font-size: 14px; }
.price-row input[type=range] { flex: 1; accent-color: #4a7c2f; }
.price-val { font-size: 17px; font-weight: 800; color: #2f6b1f; min-width: 74px; }
.price-note { font-size: 11px; color: #a9b39f; padding: 0 4px 6px; }
.pnl { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 6px 0; }
.pnl div { background: #f4f8ec; border: 1px solid #e2ecd2; border-radius: 9px; padding: 7px; text-align: center; font-size: 11px; color: #8a987f; }
.pnl b { display: block; font-size: 14px; color: #33422f; margin-top: 2px; }
.pnl b.up { color: #2f8f1f; } .pnl b.down { color: #d24a35; }

/* 调度·经营面板（右侧） */
.panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(350px, 90%); background: #fff; border-left: 1px solid #dbe5cc; transform: translateX(105%); transition: transform .25s ease-out; padding: 12px; overflow-y: auto; z-index: 22; box-shadow: -8px 0 30px rgba(60,90,40,.15); }
.panel.open { transform: translateX(0); }
.panel.left { right: auto; left: 0; border-left: none; border-right: 1px solid #dbe5cc; transform: translateX(-105%); box-shadow: 8px 0 30px rgba(60,90,40,.15); }
.panel.left.open { transform: translateX(0); }
.dp-title { text-align: center; color: #4a7c2f; font-weight: 900; letter-spacing: 5px; font-size: 16px; padding: 6px 0 10px; }
.dp-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #eef2e6; }
.dp-row.clickable { cursor: pointer; }
.dp-row.clickable:hover { background: #f6faf0; }
.dp-name { width: 58px; font-size: 13px; color: #5d6b5f; }
.dp-bar { flex: 1; height: 13px; background: #eef2e6; border-radius: 7px; overflow: hidden; }
.dp-bar i { display: block; height: 100%; border-radius: 7px; transition: width .5s; }
.dp-val { width: 88px; text-align: right; font-size: 12px; color: #4c5a4e; font-variant-numeric: tabular-nums; }
.dp-warn { color: #d24a35; font-size: 13px; padding: 7px 0; font-weight: 600; }
.dp-hint { color: #a9b39f; font-size: 11px; text-align: center; padding-top: 9px; }
.dp-sec { color: #4a7c2f; font-size: 13px; font-weight: 800; margin: 12px 0 2px; }
.log-line { font-size: 12px; color: #5d6b5f; padding: 5px 0; border-bottom: 1px dashed #eef2e6; line-height: 1.45; }
.log-line .lt { color: #a9b39f; margin-right: 6px; font-variant-numeric: tabular-nums; }

/* 调试面板 */
.dbg-title { color: #4a7c2f; font-weight: 800; padding-bottom: 8px; }
.dbg-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 12px; color: #5d6b5f; flex-wrap: wrap; }
.dbg-row.stat { color: #a9b39f; border-top: 1px dashed #e2e6da; margin-top: 8px; padding-top: 8px; }
.dbg-btn { background: #f4f8ec; color: #4c5a4e; border: 1px solid #dbe5cc; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 12px; }
.dbg-btn.on { border-color: #4a7c2f; color: #2f6b1f; font-weight: 700; }
.dbg-sec { color: #4a7c2f; font-size: 12px; margin-top: 10px; border-top: 1px dashed #e2e6da; padding-top: 8px; }
input[type=range] { width: 110px; accent-color: #4a7c2f; }
input[type=number] { background: #f4f8ec; color: #33422f; border: 1px solid #dbe5cc; border-radius: 6px; padding: 3px 6px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; margin: auto; width: min(430px, 92vw); height: fit-content; max-height: 84vh; overflow-y: auto; background: #fff; border: 1px solid #dbe5cc; border-radius: 18px; padding: 20px; display: none; z-index: 50; box-shadow: 0 24px 70px rgba(50,80,30,.3); }
.modal.show { display: block; animation: cardin .25s; }
.modal.small { width: min(340px, 90vw); }
.modal.dark { background: #10173a; border-color: #2a3a5c; color: #e8ecf4; }
.modal.dark .m-title { color: #ffe9a8; }
.m-title { font-size: 17px; font-weight: 800; color: #b8442f; margin-bottom: 10px; }
.m-btn { display: block; width: 100%; margin-top: 16px; padding: 12px; border-radius: 11px; border: none; background: linear-gradient(180deg, #5a9440, #3f6b26); color: #fff; font-size: 15px; font-weight: 800; cursor: pointer; }
.m-btn:disabled { opacity: .5; }
.st-line { font-size: 14px; padding: 4px 0; color: #4c5a4e; }
.st-line b { color: #2f6b1f; }
.st-line b.up { color: #2f8f1f; } .st-line b.down { color: #d24a35; }
.st-forecast { margin-top: 10px; padding: 9px; background: #f4f8ec; border-radius: 9px; font-size: 13px; color: #5d7a4a; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
th, td { padding: 5px; text-align: center; border-bottom: 1px solid #eef2e6; color: #4c5a4e; }
td.up { color: #2f8f1f; } td.down { color: #d24a35; }
.ex-line { font-size: 13px; padding: 4px 0; color: #4c5a4e; }
.ex-line b { color: #2f6b1f; }
.ex-verdict { margin-top: 10px; padding: 9px; border-radius: 9px; font-size: 13px; }
.ex-verdict.ok { background: #eaf6e4; color: #2f8f1f; }
.ex-verdict.warn { background: #fdf3dc; color: #b8862f; }
.ex-verdict.bad { background: #fdeaea; color: #d24a35; }

@media (max-width: 620px) {
  #cards { width: 228px; }
  .ctitle { font-size: 13px; }
  .cbody { font-size: 11px; }
  .tb { font-size: 11px; }
  .cer-text { font-size: 20px; }
  .res-chip { font-size: 11px; }
  .res-chip img { width: 14px; height: 14px; }
}
