:root {
  --ink: #1f231f;
  --muted: #777d76;
  --paper: #f4f3ef;
  --card: rgba(255, 255, 255, 0.88);
  --orange: #ff6a2a;
  --orange-dark: #e95318;
  --green: #4f8065;
  --line: rgba(31, 35, 31, 0.09);
  --shadow: 0 22px 60px rgba(43, 45, 38, 0.1);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); overflow-x: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.ambient { position: fixed; border-radius: 50%; filter: blur(2px); pointer-events: none; z-index: 0; }
.ambient-one { width: 420px; height: 420px; background: rgba(255, 170, 116, 0.14); top: -180px; right: -80px; }
.ambient-two { width: 360px; height: 360px; background: rgba(121, 160, 133, 0.12); bottom: -180px; left: 20%; }

.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--orange); color: white; font-weight: 900; letter-spacing: -2px; box-shadow: 0 9px 20px rgba(255,106,42,.26); }
.brand-row strong, .brand-row span { display: block; }
.brand-row strong { font-size: 17px; letter-spacing: .08em; }
.brand-row span { font-size: 8px; letter-spacing: .24em; margin-top: 3px; color: var(--muted); }

.login-shell { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); padding: 22px; gap: 22px; }
.login-visual { position: relative; overflow: hidden; border-radius: 30px; padding: 38px 46px; background: linear-gradient(145deg, rgba(239,239,232,.92), rgba(226,231,219,.88)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.7); }
.login-visual::before { content: ""; position: absolute; width: 720px; height: 720px; border: 1px solid rgba(79,128,101,.12); border-radius: 50%; left: 38%; top: -250px; box-shadow: 0 0 0 90px rgba(255,255,255,.08), 0 0 0 180px rgba(255,255,255,.06); }
.login-visual::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(42,52,44,.09) .7px, transparent .7px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, transparent, #000); }
.login-visual > * { position: relative; z-index: 1; }
.hero-copy { margin-top: clamp(90px, 17vh, 190px); max-width: 650px; }
.eyebrow { font-size: 12px; letter-spacing: .16em; color: var(--green); font-weight: 700; display: flex; align-items: center; gap: 9px; }
.eyebrow i { width: 25px; height: 1px; background: var(--green); }
.hero-copy h1 { font-family: Georgia, "Songti SC", serif; font-size: clamp(48px, 6vw, 84px); line-height: 1.06; font-weight: 500; margin: 24px 0; letter-spacing: -.05em; }
.hero-copy h1 em { color: var(--orange); font-weight: 500; }
.hero-copy p { color: #626861; font-size: 16px; line-height: 1.8; max-width: 440px; }
.home-preview { position: absolute; left: 46px; right: 46px; bottom: 42px; padding: 24px 27px; background: rgba(255,255,255,.66); border: 1px solid rgba(255,255,255,.8); backdrop-filter: blur(18px); border-radius: 22px; box-shadow: 0 18px 50px rgba(56,64,54,.08); }
.preview-head { display: flex; justify-content: space-between; align-items: center; }
.preview-head small, .preview-head strong { display: block; }
.preview-head small { color: var(--muted); margin-bottom: 5px; }
.preview-head strong { font-family: Georgia, "Songti SC", serif; font-size: 21px; }
.live-dot { font-size: 11px; color: var(--green); }
.live-dot::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #5b9c75; margin-right: 7px; box-shadow: 0 0 0 4px rgba(91,156,117,.11); }
.preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; }
.preview-grid div { padding: 15px 17px; border-radius: 15px; background: rgba(247,247,243,.72); }
.preview-grid span, .preview-grid b { display: block; }
.preview-grid span { color: var(--muted); font-size: 11px; }
.preview-grid b { font-family: Georgia, serif; font-size: 25px; margin-top: 5px; }
.preview-grid b small { font-family: inherit; font-size: 12px; color: var(--muted); }

.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: min(100%, 420px); }
.mobile-brand { display: none; }
.secure-pill { display: inline-flex; align-items: center; background: #eef4ec; color: var(--green); border-radius: 99px; padding: 7px 12px; font-size: 11px; font-weight: 700; letter-spacing: .05em; }
.login-heading h2 { font-family: Georgia, "Songti SC", serif; font-size: 42px; font-weight: 500; margin: 18px 0 10px; }
.login-heading p { color: var(--muted); margin: 0 0 38px; }
.primary-button, .secondary-button { width: 100%; border: 0; cursor: pointer; border-radius: 15px; transition: transform .2s, box-shadow .2s, background .2s; }
.primary-button { min-height: 60px; display: grid; grid-template-columns: 34px 1fr 28px; align-items: center; text-align: left; padding: 9px 15px; background: var(--orange); color: white; box-shadow: 0 16px 34px rgba(255,106,42,.23); font-weight: 700; }
.primary-button:hover { background: var(--orange-dark); transform: translateY(-2px); box-shadow: 0 20px 38px rgba(255,106,42,.28); }
.primary-button + .primary-button { margin-top: 12px; }
.mi-symbol { width: 30px; height: 30px; display: grid; place-items: center; background: white; color: var(--orange); border-radius: 9px; font-size: 10px; font-weight: 900; }
.arrow { text-align: center; font-size: 21px; }
.secondary-button { margin-top: 12px; min-height: 49px; background: transparent; border: 1px solid var(--line); color: #666c65; }
.secondary-button:hover { background: white; }
.setup-notice { margin-top: 16px; padding: 15px 17px; border-radius: 14px; background: #fff6ed; color: #8b4a2d; border: 1px solid rgba(255,106,42,.15); }
.setup-notice strong { font-size: 13px; }
.setup-notice p { margin: 5px 0 0; font-size: 12px; line-height: 1.6; }
.privacy-note { display: flex; align-items: flex-start; gap: 13px; margin-top: 28px; padding-top: 25px; border-top: 1px solid var(--line); color: var(--muted); }
.privacy-note p { margin: 0; font-size: 12px; line-height: 1.65; }
.privacy-note strong { color: #555b55; }
.shield-icon { color: var(--green); font-size: 22px; transform: rotate(45deg); }
.terms { margin-top: 40px; font-size: 10px; color: #9a9e99; }

.app-shell { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 22px; display: flex; flex-direction: column; background: rgba(248,248,245,.84); border-right: 1px solid rgba(31,35,31,.07); backdrop-filter: blur(20px); }
.sidebar-brand { padding: 0 9px; }
.side-nav { display: grid; gap: 7px; margin-top: 62px; }
.nav-item { border: 0; background: transparent; border-radius: 13px; min-height: 47px; display: flex; align-items: center; gap: 13px; padding: 0 14px; color: #777d76; cursor: pointer; text-align: left; }
.nav-item span { font-size: 18px; width: 21px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.7); color: var(--ink); }
.nav-item.active { background: white; color: var(--ink); box-shadow: 0 8px 28px rgba(38,41,35,.07); font-weight: 700; }
.nav-item.active span { color: var(--orange); }
.sidebar-footer { margin-top: auto; }
.mini-weather { display: flex; gap: 12px; align-items: center; padding: 15px; border-radius: 15px; background: rgba(255,255,255,.72); }
.mini-weather > span { color: #e6a332; font-size: 25px; }
.mini-weather b, .mini-weather small { display: block; }
.mini-weather b { font-size: 14px; }
.mini-weather small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.logout-button { width: 100%; margin-top: 12px; border: 0; background: transparent; color: #929791; font-size: 12px; padding: 9px; cursor: pointer; }

.dashboard { padding: 31px clamp(24px, 4vw, 62px) 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.topbar p { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.topbar h1 { font-family: Georgia, "Songti SC", serif; margin: 0; font-size: 29px; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.icon-button, .menu-button { border: 1px solid var(--line); background: rgba(255,255,255,.7); cursor: pointer; border-radius: 50%; display: grid; place-items: center; }
.icon-button { width: 42px; height: 42px; font-size: 21px; }
.menu-button { display: none; width: 40px; height: 40px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 4px; }
.user-chip > span { width: 39px; height: 39px; border-radius: 50%; display: grid; place-items: center; background: #e5e8df; color: var(--green); font-weight: 800; }
.user-chip b, .user-chip small { display: block; }
.user-chip b { font-size: 12px; }
.user-chip small { font-size: 9px; color: var(--muted); margin-top: 3px; }

.overview-card { position: relative; overflow: hidden; min-height: 204px; margin-top: 34px; border-radius: 25px; padding: 34px 38px; display: flex; align-items: center; gap: clamp(35px, 6vw, 90px); background: linear-gradient(108deg, #667967 0%, #7e917e 55%, #9ca593 100%); color: white; box-shadow: 0 22px 46px rgba(70,88,71,.18); }
.overview-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% 10%, rgba(255,255,255,.18), transparent 35%), linear-gradient(120deg, rgba(255,255,255,.05), transparent); }
.overview-copy, .overview-stats { position: relative; z-index: 1; }
.overview-copy > span { font-size: 10px; letter-spacing: .08em; opacity: .7; }
.overview-copy h2 { font-family: Georgia, "Songti SC", serif; margin: 10px 0 17px; font-size: 28px; font-weight: 500; }
.overview-copy p { margin: 0; font-size: 11px; opacity: .85; }
.status-dot { display: inline-block; width: 6px; height: 6px; background: #c4e2b3; border-radius: 50%; margin-right: 7px; box-shadow: 0 0 0 4px rgba(196,226,179,.1); }
.overview-stats { display: grid; grid-template-columns: repeat(3, minmax(75px, 1fr)); gap: clamp(20px, 4vw, 60px); }
.overview-stats div { position: relative; }
.overview-stats div:not(:last-child)::after { content: ""; position: absolute; width: 1px; height: 42px; right: -30px; top: 7px; background: rgba(255,255,255,.18); }
.overview-stats span, .overview-stats b { display: block; }
.overview-stats span { font-size: 10px; opacity: .65; }
.overview-stats b { font-family: Georgia, serif; font-size: 30px; font-weight: 500; margin-top: 7px; }
.overview-stats small { font-size: 11px; font-weight: 400; opacity: .7; }
.sun-orbit { position: absolute; width: 210px; height: 210px; right: -35px; top: -70px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; box-shadow: 0 0 0 34px rgba(255,255,255,.03), 0 0 0 70px rgba(255,255,255,.025); }
.sun-orbit span { position: absolute; bottom: 23px; left: 5px; color: #f4d691; font-size: 25px; }

.device-section { margin-top: 34px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.section-heading h2 { font-family: Georgia, "Songti SC", serif; font-weight: 500; margin: 0 0 6px; font-size: 23px; }
.section-heading p { margin: 0; font-size: 11px; color: var(--muted); }
.room-filters { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.filter-button { border: 1px solid var(--line); background: rgba(255,255,255,.45); border-radius: 99px; padding: 8px 14px; font-size: 10px; cursor: pointer; color: var(--muted); }
.filter-button.active { background: var(--ink); color: white; border-color: var(--ink); }
.device-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 15px; margin-top: 22px; }
.device-card { position: relative; min-height: 218px; padding: 20px; border-radius: 20px; border: 1px solid rgba(255,255,255,.78); background: var(--card); box-shadow: 0 12px 38px rgba(49,51,45,.055); transition: transform .2s, box-shadow .2s; overflow: hidden; }
.device-card:hover { transform: translateY(-3px); box-shadow: 0 18px 44px rgba(49,51,45,.09); }
.device-card.offline { opacity: .62; filter: saturate(.7); }
.device-top { display: flex; justify-content: space-between; align-items: flex-start; }
.device-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 14px; background: #f0f2ed; color: var(--green); font-size: 21px; }
.device-card.is-on .device-icon { background: #fff1e7; color: var(--orange); }
.device-card h3 { font-size: 14px; margin: 17px 0 5px; }
.device-meta { color: var(--muted); font-size: 10px; }
.device-status { margin: 17px 0 0; font-size: 11px; color: #5b625a; }
.switch { position: relative; width: 39px; height: 23px; border: 0; border-radius: 99px; background: #d9ddd7; cursor: pointer; padding: 0; transition: background .2s; }
.switch::after { content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%; left: 3px; top: 3px; background: white; box-shadow: 0 2px 6px rgba(0,0,0,.18); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--orange); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:disabled { cursor: not-allowed; }
.control-row { display: flex; align-items: center; gap: 11px; margin-top: 18px; }
.control-row label { color: var(--muted); font-size: 9px; white-space: nowrap; }
.control-row output { font-size: 10px; min-width: 32px; text-align: right; color: #555c55; }
input[type="range"] { flex: 1; min-width: 0; height: 4px; appearance: none; background: #e1e3df; border-radius: 99px; accent-color: var(--orange); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: white; border: 4px solid var(--orange); box-shadow: 0 1px 5px rgba(0,0,0,.15); }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.action-button { border: 1px solid var(--line); background: #f7f7f4; border-radius: 10px; padding: 8px; cursor: pointer; font-size: 10px; }
.action-button.primary { background: #fff0e7; color: var(--orange-dark); border-color: rgba(255,106,42,.12); }
.empty-state { grid-column: 1 / -1; padding: 60px 20px; text-align: center; color: var(--muted); background: rgba(255,255,255,.5); border-radius: 20px; }
.skeleton { min-height: 218px; border-radius: 20px; background: linear-gradient(90deg, rgba(255,255,255,.45), rgba(255,255,255,.9), rgba(255,255,255,.45)); background-size: 220% 100%; animation: shimmer 1.4s infinite; }

.energy-view { margin-top: 34px; }
.energy-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.energy-toolbar h2 { font-family: Georgia, "Songti SC", serif; font-size: 25px; font-weight: 500; margin: 0 0 7px; }
.energy-toolbar p { color: var(--muted); font-size: 11px; margin: 0; }
.energy-controls { display: flex; align-items: center; gap: 12px; }
.period-switch { display: flex; padding: 4px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 12px; }
.period-switch button { border: 0; background: transparent; border-radius: 8px; padding: 8px 15px; font-size: 11px; color: var(--muted); cursor: pointer; }
.period-switch button.active { background: var(--ink); color: white; box-shadow: 0 5px 13px rgba(31,35,31,.16); }
.price-field { height: 42px; display: flex; align-items: center; gap: 7px; padding: 0 11px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: 12px; font-size: 10px; color: var(--muted); }
.price-field input { width: 55px; border: 0; border-bottom: 1px solid rgba(31,35,31,.14); outline: 0; background: transparent; color: var(--ink); text-align: right; font-weight: 700; }
.price-field span { white-space: nowrap; }
.energy-notice { margin-top: 18px; padding: 13px 16px; border: 1px solid rgba(255,106,42,.18); background: #fff4e9; color: #8a4b2d; border-radius: 13px; font-size: 11px; line-height: 1.6; }
.energy-notice.warning { border-color: rgba(207,145,42,.2); background: #fff9e9; color: #795b22; }
.energy-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 22px; }
.energy-metrics article { position: relative; overflow: hidden; min-height: 132px; padding: 23px; border: 1px solid rgba(255,255,255,.84); background: var(--card); border-radius: 19px; box-shadow: 0 12px 32px rgba(49,51,45,.05); }
.energy-metrics article::after { content: ""; position: absolute; width: 76px; height: 76px; right: -25px; bottom: -30px; border-radius: 50%; background: rgba(79,128,101,.08); }
.energy-metrics .cost-card { background: linear-gradient(135deg, #fff1e8, rgba(255,255,255,.9)); }
.energy-metrics .cost-card::after { background: rgba(255,106,42,.12); }
.energy-metrics span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 13px; }
.energy-metrics strong { font-family: Georgia, serif; font-size: clamp(25px, 3vw, 35px); font-weight: 500; }
.energy-metrics small { margin-left: 5px; color: var(--muted); font-size: 10px; }
.energy-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 15px; margin-top: 15px; }
.energy-panel { min-height: 360px; padding: 23px; border: 1px solid rgba(255,255,255,.82); background: var(--card); border-radius: 20px; box-shadow: 0 12px 38px rgba(49,51,45,.05); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.panel-heading h3 { font-size: 14px; margin: 0 0 5px; }
.panel-heading p { color: var(--muted); font-size: 10px; margin: 0; }
.mode-badge { padding: 6px 9px; border-radius: 99px; background: #eaf3eb; color: var(--green); font-size: 9px; font-weight: 700; }
.mode-badge.warning { background: #fff0dc; color: #9a5e24; }
.energy-chart { height: 270px; display: flex; align-items: flex-end; gap: clamp(3px, .7vw, 9px); padding: 38px 2px 1px; border-bottom: 1px solid var(--line); }
.chart-column { position: relative; flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.chart-column i { width: min(100%, 18px); min-height: 3px; display: block; border-radius: 6px 6px 2px 2px; background: linear-gradient(to top, #637c68, #9bb19d); transition: height .3s; }
.chart-column:hover i { background: linear-gradient(to top, var(--orange-dark), #ff9c68); }
.chart-column small { position: absolute; top: calc(100% + 8px); color: #969b95; font-size: 8px; white-space: nowrap; }
.chart-value { opacity: 0; position: absolute; z-index: 2; bottom: calc(var(--bar-height, 0%) + 5px); padding: 3px 5px; border-radius: 5px; background: var(--ink); color: white; font-size: 8px; pointer-events: none; }
.chart-column:hover .chart-value { opacity: 1; }
.energy-ranking { display: grid; gap: 18px; margin-top: 26px; }
.ranking-row { display: flex; gap: 11px; align-items: center; }
.ranking-index { width: 23px; height: 23px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; background: #eef0eb; color: var(--muted); font-size: 9px; font-weight: 700; }
.ranking-row:first-child .ranking-index { background: #fff0e5; color: var(--orange-dark); }
.ranking-main { flex: 1; min-width: 0; }
.ranking-main > div { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ranking-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.ranking-main span { white-space: nowrap; color: var(--muted); font-size: 9px; }
.ranking-main > i { height: 5px; display: block; overflow: hidden; background: #eceee9; border-radius: 99px; }
.ranking-main > i em { height: 100%; display: block; border-radius: inherit; background: linear-gradient(to right, #7d9881, #b1c2b0); }
.energy-loading, .energy-empty { width: 100%; padding: 70px 15px; text-align: center; color: var(--muted); font-size: 11px; }
@keyframes shimmer { to { background-position: -220% 0; } }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 28px; transform: translate(-50%, 120px); opacity: 0; padding: 12px 18px; border-radius: 12px; background: #242824; color: white; font-size: 12px; box-shadow: var(--shadow); transition: transform .3s, opacity .3s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #8b3f2e; }

@media (max-width: 1050px) {
  .login-shell { grid-template-columns: 1fr 410px; }
  .device-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .sun-orbit { display: none; }
  .overview-card { gap: 40px; }
  .energy-metrics { grid-template-columns: repeat(2, 1fr); }
  .energy-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login-shell { display: block; padding: 0; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 30px 24px; }
  .mobile-brand { display: flex; margin-bottom: 72px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; width: 245px; left: -260px; transition: left .25s; box-shadow: 20px 0 50px rgba(30,35,30,.12); }
  .sidebar.open { left: 0; }
  .dashboard { padding: 24px 20px 50px; }
  .topbar { gap: 12px; }
  .menu-button { display: grid; }
  .topbar > div:nth-child(2) { margin-right: auto; }
  .user-chip div { display: none; }
  .overview-card { display: block; padding: 28px; }
  .overview-stats { margin-top: 28px; max-width: 340px; }
  .energy-toolbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .login-heading h2 { font-size: 36px; }
  .overview-card { min-height: 250px; }
  .overview-stats { gap: 16px; }
  .overview-stats div:not(:last-child)::after { right: -8px; }
  .overview-stats b { font-size: 25px; }
  .section-heading { display: block; }
  .room-filters { justify-content: flex-start; margin-top: 18px; overflow-x: auto; flex-wrap: nowrap; }
  .filter-button { flex: 0 0 auto; }
  .device-grid { grid-template-columns: 1fr; }
  .energy-controls { width: 100%; align-items: stretch; flex-direction: column; }
  .period-switch button { flex: 1; }
  .price-field { justify-content: center; }
  .energy-metrics { grid-template-columns: 1fr 1fr; gap: 9px; }
  .energy-metrics article { min-height: 112px; padding: 18px; }
  .energy-panel { padding: 18px 14px; }
  .energy-chart { gap: 2px; }
  .chart-column small { font-size: 7px; transform: rotate(-45deg); transform-origin: left center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 米家风格界面 */
:root { --orange: #ff6900; --orange-dark: #e85f00; --paper: #f5f5f5; --card: #fff; }
body { background: #f5f5f5; }
.app-shell { grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { background: rgba(255,255,255,.96); border-right-color: rgba(0,0,0,.055); }
.brand-mark { background: var(--orange); border-radius: 12px; box-shadow: none; }
.side-nav { margin-top: 48px; }
.nav-item { min-height: 48px; border-radius: 14px; font-size: 13px; }
.nav-item.active { color: var(--orange); background: #fff4ec; box-shadow: none; }
.dashboard { width: 100%; max-width: 1460px; margin: 0 auto; padding-top: 26px; }
.topbar h1 { font-family: inherit; font-size: 25px; font-weight: 700; }
.topbar p { font-size: 12px; }
.overview-card { min-height: 184px; margin-top: 26px; padding: 30px 34px; background: linear-gradient(135deg, #829493, #a7b2af); box-shadow: none; }
.overview-copy h2 { font-family: inherit; font-weight: 700; font-size: 28px; }
.overview-stats b { font-family: inherit; font-size: 27px; font-weight: 600; }
.overview-stats small { font-size: 10px; }
.sun-orbit span { color: rgba(255,255,255,.9); }
.device-section { margin-top: 30px; }
.section-heading h2 { font-family: inherit; font-size: 20px; font-weight: 700; }
.room-filters { justify-content: flex-start; }
.filter-button { padding: 8px 17px; background: white; border: 0; font-size: 11px; }
.filter-button.active { background: var(--orange); }
.device-grid { grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 13px; }
.device-card { min-height: 170px; padding: 19px; border: 0; border-radius: 18px; background: white; box-shadow: 0 3px 14px rgba(0,0,0,.035); cursor: pointer; }
.device-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.07); }
.device-icon { width: 46px; height: 46px; border-radius: 15px; background: #f2f2f2; color: #737373; }
.device-card.is-on .device-icon { background: #fff1e6; color: var(--orange); }
.device-card h3 { margin-top: 18px; font-size: 14px; padding-right: 20px; }
.device-meta { font-size: 10px; }
.device-status { margin-top: 9px; color: #8b8b8b; }
.device-enter { position: absolute; right: 18px; bottom: 16px; color: #bbb; font-size: 22px; }
.switch[aria-checked="true"] { background: var(--orange); }
.mobile-bottom-nav { display: none; }
#appShell.hidden + .mobile-bottom-nav { display: none; }

body.sheet-open { overflow: hidden; }
.device-sheet { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 20px; }
.sheet-backdrop { position: absolute; inset: 0; border: 0; background: rgba(22,27,27,.46); backdrop-filter: blur(7px); }
.sheet-panel { position: relative; width: min(100%, 620px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 0 20px 26px; border-radius: 28px; background: linear-gradient(180deg, #899a99 0%, #9ca9a6 42%, #edf0ef 100%); color: white; box-shadow: 0 35px 90px rgba(0,0,0,.3); scrollbar-width: none; }
.sheet-panel::-webkit-scrollbar { display: none; }
.sheet-handle { width: 42px; height: 5px; margin: 10px auto 4px; border-radius: 99px; background: rgba(255,255,255,.42); }
.sheet-header { position: sticky; z-index: 3; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px 2px 10px; background: linear-gradient(#899a99 75%, transparent); }
.sheet-header p { margin: 0 0 4px; color: rgba(255,255,255,.68); font-size: 11px; }
.sheet-header h2 { margin: 0; font-size: 20px; font-weight: 600; }
.sheet-header-actions { display: flex; align-items: center; gap: 9px; }
.sheet-header-power, .sheet-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: white; font-size: 22px; cursor: pointer; }
.sheet-header-power.active { background: var(--orange); box-shadow: 0 6px 15px rgba(255,105,0,.25); }
.sheet-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: white; font-size: 25px; cursor: pointer; }
.sheet-device-state { padding: 24px 0 16px; text-align: center; }
.sheet-device-icon { width: 104px; height: 104px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.15); color: white; font-size: 48px; }
.sheet-device-icon.temperature-display { width: auto; height: 105px; background: transparent; font-size: 76px; font-weight: 300; letter-spacing: -5px; }
.sheet-device-state > p { margin: 0 0 24px; color: rgba(255,255,255,.9); font-size: 14px; }
.sheet-power { width: 100%; min-height: 88px; display: flex; align-items: center; gap: 18px; padding: 16px 22px; border: 0; border-radius: 17px; background: white; color: #222; cursor: pointer; text-align: left; }
.sheet-power span { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: #d6d6d6; color: white; font-size: 22px; }
.sheet-power.active span { background: var(--orange); box-shadow: 0 8px 20px rgba(255,105,0,.24); }
.sheet-power b { font-size: 18px; }
.sheet-controls { display: grid; gap: 14px; color: #222; }
.sheet-stats-card { display: grid; grid-template-columns: 1fr 1fr; min-height: 112px; overflow: hidden; border-radius: 17px; background: white; }
.sheet-stats-card > div { display: grid; place-content: center; text-align: center; }
.sheet-stats-card > div + div { border-left: 1px solid #e4e4e4; }
.sheet-stats-card strong { font-size: 31px; font-weight: 500; }
.sheet-stats-card span { margin-top: 7px; color: #8e8e8e; font-size: 11px; }
.sheet-control-card { padding: 20px; border-radius: 17px; background: rgba(255,255,255,.93); }
.control-card-title { display: flex; align-items: center; gap: 12px; margin-bottom: 19px; }
.control-card-title b { font-size: 15px; }
.control-card-title span { color: #999; font-size: 13px; }
.range-card input[type="range"] { width: 100%; height: 12px; background: #e8e8e8; accent-color: var(--orange); }
.range-card input[type="range"]::-webkit-slider-thumb { width: 30px; height: 30px; border: 8px solid white; background: var(--orange); box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.mode-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mode-options.climate-modes { grid-template-columns: repeat(5, 1fr); }
.mode-option { min-width: 0; display: grid; justify-items: center; gap: 8px; padding: 0; border: 0; background: transparent; color: #929292; cursor: pointer; }
.mode-option i { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: white; box-shadow: inset 0 0 0 1px #ececec; font-style: normal; font-size: 21px; }
.mode-option span { font-size: 11px; white-space: nowrap; }
.mode-option.active { color: var(--orange); }
.mode-option.active i { background: var(--orange); color: white; box-shadow: none; }
.single-toggle { display: flex; align-items: center; justify-content: space-between; font-size: 16px; }
.single-toggle .switch { width: 50px; height: 28px; }
.single-toggle .switch::after { width: 22px; height: 22px; }
.single-toggle .switch[aria-checked="true"]::after { transform: translateX(22px); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions button { min-height: 54px; border: 0; border-radius: 13px; background: #f2f2f2; cursor: pointer; }
.sheet-actions button:first-child { background: var(--orange); color: white; }
.device-feature-list { overflow: hidden; border-radius: 17px; background: white; }
.device-feature-list > button { width: 100%; min-height: 78px; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px; padding: 11px 20px; border: 0; border-bottom: 1px solid #ededed; background: white; color: #202020; text-align: left; cursor: pointer; }
.device-feature-list > button:last-child { border-bottom: 0; }
.device-feature-list > button:disabled { color: #c7c7c7; cursor: not-allowed; }
.device-feature-list > button > i { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #12bfc2; color: white; font-size: 22px; font-style: normal; }
.device-feature-list > button:disabled > i { background: #ededed; color: #c8c8c8; }
.device-feature-list span b, .device-feature-list span small { display: block; }
.device-feature-list span b { font-size: 15px; }
.device-feature-list span small { margin-top: 4px; color: #9a9a9a; font-size: 11px; }
.device-feature-list > button > em { color: #aaa; font-style: normal; font-size: 22px; }
.mini-switch { width: 45px; height: 25px; position: relative; border-radius: 99px; background: #ddd; }
.mini-switch::after { content: ""; position: absolute; width: 19px; height: 19px; left: 3px; top: 3px; border-radius: 50%; background: white; }
.mini-switch.on { background: #12bfc2; }
.mini-switch.on::after { transform: translateX(20px); }

.sheet-device-icon.plug-display { width: 330px; height: 330px; background: transparent; }
.socket-outline { position: relative; width: 270px; height: 270px; display: block; border: 4px solid rgba(225,232,239,.7); border-radius: 38%; box-shadow: inset 0 0 0 5px rgba(255,255,255,.07), 0 0 0 1px rgba(255,255,255,.18); }
.socket-outline i { position: absolute; display: block; width: 18px; height: 70px; border-radius: 4px; background: rgba(224,230,237,.75); }
.socket-outline i:nth-child(1) { left: 126px; top: 58px; }
.socket-outline i:nth-child(2) { left: 84px; top: 145px; transform: rotate(-29deg); }
.socket-outline i:nth-child(3) { right: 84px; top: 145px; transform: rotate(29deg); }
.plug-energy-summary { display: grid; grid-template-columns: repeat(3, 1fr); }
.plug-energy-summary > div { text-align: center; }
.plug-energy-summary strong, .plug-energy-summary span { display: block; }
.plug-energy-summary strong { font-size: 30px; font-weight: 500; }
.plug-energy-summary strong small { margin-left: 2px; font-size: 12px; }
.plug-energy-summary span { margin-top: 6px; color: #999; font-size: 11px; }

.device-variant-delixi-plug .sheet-panel { padding-bottom: 110px; background: linear-gradient(#3b5061, #30363d); }
.device-variant-delixi-plug .sheet-header { background: linear-gradient(#3b5061 78%, transparent); }
.device-variant-delixi-plug .sheet-device-state { padding-top: 8px; }
.device-variant-delixi-plug .sheet-device-state > p { margin-top: -12px; font-size: 20px; }
.device-variant-delixi-plug .dark-plug-stats { padding: 35px 20px 24px; border-radius: 18px; background: white; color: #111; }
.dark-plug-stats > button { grid-column: 1 / -1; min-height: 54px; margin-top: 28px; border: 0; border-radius: 30px; background: #f1f1f1; font-size: 16px; cursor: pointer; }
.plug-bottom-actions { position: sticky; z-index: 4; bottom: -26px; display: grid; grid-template-columns: repeat(3, 1fr); margin: 40px -20px -26px; padding: 18px 28px 28px; border-top: 1px solid rgba(255,255,255,.09); background: rgba(62,66,71,.96); }
.plug-bottom-actions button { display: grid; justify-items: center; gap: 8px; border: 0; background: transparent; color: white; cursor: pointer; }
.plug-bottom-actions i { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: #626970; font-style: normal; font-size: 26px; }
.plug-bottom-actions .main-power.active i { background: #ff6900; }
.plug-bottom-actions span { font-size: 12px; }

.device-variant-mijia-plug .sheet-panel { background: #f7f7f7; color: #111; }
.device-variant-mijia-plug .sheet-header { background: linear-gradient(#f7f7f7 78%, transparent); color: #111; }
.device-variant-mijia-plug .sheet-header p { color: #999; }
.device-variant-mijia-plug .sheet-close { background: #ececec; color: #333; }
.device-variant-mijia-plug .sheet-header-power { background: #ececec; color: #333; }
.device-variant-mijia-plug .sheet-device-state { text-align: left; padding-left: 20px; }
.device-variant-mijia-plug .sheet-device-icon.plug-display { width: 145px; height: 145px; margin: 4px 0 12px; }
.device-variant-mijia-plug .socket-outline { width: 125px; height: 125px; border-color: #e7e7e7; background: linear-gradient(145deg,#fff,#e9e9e9); box-shadow: 0 8px 25px rgba(0,0,0,.08); }
.device-variant-mijia-plug .socket-outline i { width: 7px; height: 28px; background: #333; }
.device-variant-mijia-plug .socket-outline i:nth-child(1) { left: 56px; top: 27px; }
.device-variant-mijia-plug .socket-outline i:nth-child(2) { left: 38px; top: 66px; }
.device-variant-mijia-plug .socket-outline i:nth-child(3) { right: 38px; top: 66px; }
.device-variant-mijia-plug .sheet-device-state > p { color: #222; font-size: 28px; font-weight: 500; }
.mijia-plug-power h3, .mijia-energy-card h3 { margin: 0 0 24px; font-size: 16px; }
.mijia-plug-power > div { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 15px; }
.mini-socket { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: #eee; }
.round-power { width: 58px; height: 58px; border: 0; border-radius: 50%; background: #ddd; color: white; font-size: 27px; cursor: pointer; }
.round-power.active { background: #4e8ff4; }
.mijia-delay-card > div { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; }
.mijia-delay-card > div > i { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: #4e8ff4; color: white; font-style: normal; font-size: 25px; }
.mijia-delay-card > button { width: 100%; display: flex; justify-content: space-between; margin-top: 28px; padding: 17px 0 0; border: 0; border-top: 1px solid #eee; background: transparent; color: #aaa; cursor: pointer; }
.mijia-delay-card > button em { font-style: normal; }
.mijia-energy-card h3 { display: flex; justify-content: space-between; }
.mijia-feature-list { background: transparent; display: grid; gap: 12px; }
.mijia-feature-list > button { border: 0; border-radius: 17px; }
.mijia-feature-list > button > i { background: #4e8ff4; }

.timer-dialog { position: fixed; z-index: 120; inset: 0; display: grid; place-items: center; padding: 20px; }
.timer-backdrop { position: absolute; inset: 0; border: 0; background: rgba(20,24,24,.58); backdrop-filter: blur(5px); }
.timer-panel { position: relative; width: min(100%, 430px); padding: 26px; border-radius: 22px; background: white; color: #222; box-shadow: 0 28px 80px rgba(0,0,0,.28); }
.timer-panel h2 { margin: 0; font-size: 21px; }
.timer-panel > p { margin: 8px 0 22px; color: #888; font-size: 12px; }
.timer-presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.timer-presets button { min-height: 48px; border: 1px solid #e8e8e8; border-radius: 12px; background: #f7f7f7; cursor: pointer; }
.timer-presets button.active { border-color: var(--orange); background: #fff2e9; color: var(--orange); }
.timer-panel label { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 18px; color: #666; font-size: 12px; }
.timer-panel input { width: 110px; height: 42px; padding: 0 10px; border: 1px solid #ddd; border-radius: 10px; text-align: center; }
.timer-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.timer-dialog-actions button { min-height: 48px; border: 0; border-radius: 12px; background: #f1f1f1; cursor: pointer; }
.timer-dialog-actions #confirmTimerButton,
.timer-dialog-actions #confirmScheduleButton { background: var(--orange); color: white; }
.schedule-time-row { padding: 14px 16px; border: 1px solid #ececec; border-radius: 14px; background: #fafafa; color: #333 !important; font-size: 14px !important; }
.schedule-time-row input { width: 132px; background: white; font-size: 16px; }
.schedule-action-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.schedule-action-options button { min-height: 48px; border: 1px solid #e8e8e8; border-radius: 12px; background: #f7f7f7; cursor: pointer; }
.schedule-action-options button.active { border-color: var(--orange); background: #fff2e9; color: var(--orange); }
.schedule-list-heading { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; font-size: 13px; }
.schedule-list-heading span { color: #999; font-size: 11px; }
.daily-schedule-list { display: grid; gap: 8px; max-height: 170px; margin-top: 10px; overflow: auto; }
.daily-schedule-empty { padding: 18px; border-radius: 12px; background: #f7f7f7; color: #999; text-align: center; font-size: 12px; }
.daily-schedule-item { display: grid; grid-template-columns: 62px 1fr auto; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid #ededed; border-radius: 12px; }
.daily-schedule-item strong { font-size: 17px; }
.daily-schedule-item span { color: #666; font-size: 12px; }
.daily-schedule-item button { border: 0; background: transparent; color: #e85d35; cursor: pointer; }

@media (max-width: 1180px) {
  .device-grid { grid-template-columns: repeat(3, minmax(190px, 1fr)); }
}

@media (max-width: 820px) {
  .dashboard { padding-bottom: 94px; }
  .overview-card { margin-top: 20px; }
  .device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .device-card { min-height: 160px; padding: 16px; }
  .mobile-bottom-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(68px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px 14px env(safe-area-inset-bottom); border-top: 1px solid rgba(0,0,0,.06); background: rgba(255,255,255,.96); backdrop-filter: blur(18px); }
  .mobile-bottom-nav button { display: grid; place-items: center; align-content: center; gap: 2px; border: 0; background: transparent; color: #969696; font-size: 9px; }
  .mobile-bottom-nav span { font-size: 20px; }
  .mobile-bottom-nav button.active { color: var(--orange); }
  .device-sheet { padding: 0; place-items: stretch; }
  .sheet-panel { width: 100%; max-height: 100vh; min-height: 100vh; border-radius: 0; padding: 0 16px 34px; }
  .sheet-handle { display: none; }
  .sheet-header { padding-top: calc(18px + env(safe-area-inset-top)); }
}

@media (max-width: 460px) {
  .overview-card { min-height: 210px; padding: 25px 22px; }
  .overview-stats { gap: 12px; }
  .overview-stats div:not(:last-child)::after { display: none; }
  .device-card h3 { font-size: 13px; }
  .mode-option i { width: 44px; height: 44px; }
  .mode-options, .mode-options.climate-modes { gap: 5px; }
  .sheet-stats-card strong { font-size: 27px; }
}
