html { background: #0c0d0c; }
body { background: #0c0d0c; color: #e9e9e7; font-family: Arial, Helvetica, sans-serif; }
button:focus-visible, a:focus-visible { outline-color: #91b354; }

.app-shell {
  display: block;
  width: min(720px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0;
  background: #111211;
  box-shadow: 0 0 80px #0008;
}
.main-wrap { min-height: 100dvh; padding-bottom: 91px; }

.phone-statusbar {
  height: 31px;
  padding: 7px 26px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #202121;
  color: #e4e4e2;
  font-size: 13px;
  font-weight: 700;
}
.phone-signals { display: flex; align-items: end; gap: 3px; height: 12px; }
.phone-signals i { width: 3px; background: #d9d9d7; border-radius: 1px; }
.phone-signals i:nth-child(1) { height: 5px; }
.phone-signals i:nth-child(2) { height: 8px; }
.phone-signals i:nth-child(3) { height: 11px; }
.phone-signals b { font-size: 11px; line-height: 11px; margin-left: 8px; }
.phone-signals em { width: 18px; height: 9px; margin-left: 7px; border: 1px solid #d9d9d7; border-radius: 2px; background: #d9d9d7; box-shadow: 2px 0 0 -1px #202121, 3px 0 0 -1px #d9d9d7; }

.topbar {
  position: sticky;
  z-index: 12;
  top: 0;
  height: 63px;
  padding: 0 22px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  background: #202121;
  border: 0;
}
.topbar-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #b7b8b5;
  cursor: pointer;
}
.topbar-icon:hover { color: #fff; }
.topbar-icon svg { width: 22px; height: 22px; }
.menu-lines { display: grid; gap: 5px; width: 25px; }
.menu-lines i { height: 2px; width: 25px; display: block; background: currentColor; }
.topbar-title { display: grid; justify-items: center; gap: 3px; min-width: 0; }
.topbar-title strong { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 800; }
.topbar-title small { color: #8b8c88; font-size: 9px; font-weight: 700; letter-spacing: 1.1px; }

.app-menu {
  position: absolute;
  z-index: 20;
  top: 94px;
  left: max(calc((100vw - 720px) / 2 + 16px), 16px);
  width: min(292px, calc(100vw - 32px));
  padding: 13px;
  border-radius: 10px;
  border: 1px solid #353735;
  background: #1d1f1d;
  box-shadow: 0 18px 40px #000b;
}
.app-menu[hidden] { display: none; }
.app-menu > div { display: flex; align-items: center; gap: 11px; padding: 5px 4px 15px; border-bottom: 1px solid #363836; }
.app-menu img { width: 38px; height: 38px; border-radius: 50%; }
.app-menu strong { display: block; font-size: 12px; }
.app-menu small { display: block; margin-top: 4px; color: #888b84; font-size: 10px; }
.menu-reset { width: 100%; padding: 13px 7px 5px; text-align: left; color: #c6c8c0; border: 0; background: transparent; font-size: 12px; cursor: pointer; }
.menu-reset:hover { color: #fff; }

.sidebar {
  position: fixed;
  z-index: 18;
  top: auto;
  bottom: 0;
  left: 50%;
  width: min(720px, 100%);
  height: 83px;
  padding: 8px 26px 10px;
  display: block;
  transform: translateX(-50%);
  background: #171918;
  border: 0;
  border-top: 1px solid #252725;
}
.nav-list { height: 100%; display: flex; justify-content: space-around; align-items: center; gap: 0; margin: 0; }
.nav-button,
.nav-button.active {
  width: 72px;
  min-height: 64px;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0 !important;
  background: transparent;
  color: #aaaead;
  font-size: 10px !important;
  letter-spacing: 0;
  text-align: center;
  cursor: pointer;
}
.nav-button:hover { background: transparent; color: #e1e5d9; }
.nav-button .nav-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2a2d2b;
  color: #d6d7d3;
  font-size: 23px;
  line-height: 1;
}
.nav-button.active .nav-icon { background: #6f8f3d; color: #f5f7e9; }
.nav-label { color: #7e827d; font-size: 9px; font-weight: 700; }
.nav-button.active .nav-label { color: #b3c78f; }

.app-shell main { max-width: none; margin: 0; padding: 0 22px 36px; }
.view { display: none; }
.view.active { display: block; }

.server-cover {
  position: relative;
  z-index: 5;
  height: 268px;
  margin: 0 -22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: linear-gradient(180deg,#10171385,#10110ffc 94%),url('assets/island-map.png') center 43% / cover;
  border-bottom: 1px solid #292d28;
}
.server-cover-glow { position: absolute; inset: 0; background: radial-gradient(circle at 50% 44%, #283d3022, #0c100cbb 75%); }
.server-cover-logo { z-index: 1; width: 68px; height: 68px; display: grid; place-items: center; border-radius: 50%; background: #d7472e; box-shadow: 0 0 0 6px #2b3029, 0 12px 25px #0009; overflow: hidden; }
.server-cover-logo img { width: 42px; height: 42px; object-fit: contain; }
.server-cover h1 { z-index: 1; margin: 17px 0 5px; color: #eceeeb; font-size: 19px; font-weight: 700; }
.server-cover p { z-index: 1; margin: 0; color: #a7aca4; font-size: 12px; }
.server-connect { position: relative; z-index: 1; min-width: 184px; min-height: 39px; margin-top: 18px; padding: 0 23px; border: 1px solid #91ad5f; border-radius: 4px; background: #5d7839; color: #e9f1dc; font-size: 11px; font-weight: 900; letter-spacing: 1.2px; cursor: pointer; box-shadow: 0 3px 0 #344627, 0 9px 20px #0007; }
.server-connect:hover { background: #709244; }
.server-picker-label { position: relative; z-index: 2; margin-top: 9px; color: #aabd89; font-size: 9px; font-weight: 800; letter-spacing: 1.3px; }
.server-select { position: relative; z-index: 4; width: min(350px, calc(100% - 36px)); margin-top: 7px; }
.server-picker { width: 100%; min-height: 42px; padding: 9px 13px 9px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #ffffff26; border-radius: 7px; background: linear-gradient(180deg,#1b211cd9,#101411e8); color: #f1f4ed; font: 700 12px Arial,sans-serif; cursor: pointer; box-shadow: 0 8px 25px #0005; text-align: left; }
.server-picker i { width: 8px; height: 8px; flex: none; border-right: 2px solid #aabd89; border-bottom: 2px solid #aabd89; transform: rotate(45deg) translateY(-2px); transition: transform .2s ease; }
.server-picker[aria-expanded="true"] i { transform: rotate(225deg) translate(-2px,-2px); }
.server-picker:disabled { opacity: .6; cursor: wait; }
.server-options { position: absolute; top: calc(100% + 7px); left: 0; width: 100%; padding: 12px; border: 1px solid #66785270; border-radius: 11px; background: #171b18fa; box-shadow: 0 20px 55px #000d; backdrop-filter: blur(16px); text-align: left; }
.server-options[hidden] { display: none; }
.server-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 2px 10px; }
.server-menu-head strong { color: #eef3e8; font-size: 12px; }
.server-menu-head span { color: #879777; font-size: 10px; }
.server-search { display: block; width: 100%; height: 38px; padding: 0 12px; border: 1px solid #4b5945; border-radius: 7px; outline: none; background: #101610; color: #f2f5ed; font: 12px Arial,sans-serif; }
.server-search:focus { border-color: #9ac260; box-shadow: 0 0 0 2px #9ac26022; }
.server-search::placeholder { color: #788575; }
.server-filters { display: flex; gap: 5px; margin: 10px 0 5px; }
.server-filters button { flex: 1; min-width: 0; min-height: 30px; padding: 5px 6px; border: 1px solid transparent; border-radius: 5px; background: #252d23; color: #aab6a0; font: 700 9px Arial,sans-serif; cursor: pointer; }
.server-filters button.active { border-color: #6f8c4e; background: #425a2e; color: #fff; }
.server-results { max-height: min(260px, calc(100dvh - 445px)); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #657b49 #202720; }
.server-empty { padding: 22px 10px; color: #8e9a87; font-size: 11px; text-align: center; }
.server-option-group + .server-option-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid #ffffff12; }
.server-option-group > span { display: block; padding: 5px 8px 7px; color: #82926d; font-size: 8px; font-weight: 900; letter-spacing: 1.5px; }
.server-option { width: 100%; padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0; border-radius: 6px; background: transparent; color: #dfe3db; cursor: pointer; text-align: left; }
.server-option:hover { background: #ffffff0d; }
.server-option.selected { background: #536c35; color: #fff; }
.server-option b { overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.server-option small { flex: none; color: #99b17e; font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
.server-option.selected small { color: #dce8cb; }
@media (max-width: 620px) {
  .server-options { position: fixed; top: auto; bottom: 73px; left: 12px; right: 12px; width: auto; max-height: calc(100dvh - 94px); }
  .server-results { max-height: min(45dvh, calc(100dvh - 260px)); }
}
.server-connect:active { transform: translateY(2px); box-shadow: 0 1px 0 #344627, 0 5px 12px #0007; }
.player-icon { color: #8d9389; margin-right: 3px; }

.server-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 18px 2px 17px;
  border-bottom: 1px solid #252825;
}
.server-details > div { min-height: 58px; display: grid; grid-template-columns: 39px 1fr; column-gap: 10px; align-content: center; }
.server-details .detail-icon { grid-row: 1 / 3; align-self: center; width: 35px; height: 35px; display: grid; place-items: center; border-radius: 7px; background: #202321; color: #858d82; font-size: 20px; }
.server-details strong { align-self: end; font-size: 13px; font-weight: 700; }
.server-details small { align-self: start; margin-top: 2px; color: #8b9089; font-size: 11px; }

.power-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin: 16px 0 0;
}
.power-summary > div { min-height: 76px; padding: 14px 15px; border-radius: 8px; background: #1b1e1a; }
.power-summary small { display: block; color: #818a79; font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.power-summary strong { display: block; margin-top: 8px; color: #dfe4d8; font-size: 18px; font-weight: 700; }
.power-summary #load-status, .power-summary #alerts-status { font-size: 13px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 13px; }
.section-head h2 { margin: 0; color: #737a74; font: 700 11px Arial,Helvetica,sans-serif; letter-spacing: 1.5px; }
.section-label { color: #666d65; font: 700 10px Arial,Helvetica,sans-serif; letter-spacing: 1px; }
.text-link { color: #a6bc7e; font-size: 10px; font-weight: 700; letter-spacing: .7px; }
.text-link b { font-size: 19px; margin-left: 4px; vertical-align: -2px; }

.device-grid, .device-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.device-card, .device-row,
.device-card.is-on, .device-row.is-on {
  min-height: 120px;
  padding: 12px 14px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  border: 0;
  border-radius: 10px;
  background: #1c1e1c;
  transition: background .18s ease;
}
.device-card.is-on, .device-row.is-on { background: #3f4f2d; }
.device-card:hover, .device-row:hover { border: 0; background: #252925; }
.device-card.is-on:hover, .device-row.is-on:hover { background: #4a6031; }
.device-art { width: 94px; height: 94px; flex: none; display: grid; place-items: center; }
.device-art img { width: 100%; height: 100%; object-fit: contain; transform: scale(1.12); filter: drop-shadow(2px 6px 4px #0009); }
.device-art img[src*="ceiling-light"] { transform: scale(1.3); }
.device-art img[src*="door-controller"] { transform: scale(1.2); }
.device-copy { min-width: 0; flex: 1; display: grid; gap: 9px; }
.device-copy strong { display: block; color: #f0f0ed; font-size: 17px; font-weight: 700; line-height: 1.15; }
.device-copy small { color: #8d928b; font-size: 11px; font-weight: 800; letter-spacing: 1.4px; }
.is-on .device-copy small { color: #a4b88a; }
.no-response .device-copy small { color: #d34830; }
.device-action { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: #161817; color: #d2d5ce; cursor: pointer; }
.is-on .device-action { background: #344425; }
.device-action:hover { background: #353a35; color: #fff; }
.device-action svg { width: 20px; height: 20px; }
.device-grip { width: 13px; flex: none; color: #898e86; font-size: 23px; line-height: 1; text-align: center; }

.map-preview { overflow: hidden; border-radius: 9px; background: #20221e; }
.map-image { height: 210px; }
.map-image img { filter: saturate(.6) brightness(.78); }
.map-marker { border-radius: 50px; background: #2e492adf; font-size: 9px; }
.activity-panel { min-height: 0; padding: 0 16px; border-radius: 9px; background: #1b1e1b; }
.event-list { padding: 0; }
.event { padding: 15px 0; border-top: 1px solid #30342e; }
.event:first-child { border-top: 0; }
.event-icon { border-radius: 6px; background: #2e3c27; }
.event strong { font-size: 11px; }

.page-heading { margin: 25px 0 19px; gap: 0; }
.page-heading .eyebrow, .page-heading .heading-signal { display: none; }
.page-heading h1 { margin: 0; font: 700 24px Arial,Helvetica,sans-serif; text-transform: none; letter-spacing: 0; }
.page-heading h1 em { color: inherit; }
.page-heading .heading-sub { margin-top: 8px; max-width: 560px; color: #8e948c; font-size: 12px; line-height: 1.5; }

#view-devices .devices-summary, #view-devices .section-head { display: none; }
#view-devices .device-list { padding-bottom: 20px; }

.circuit-toolbar { display: grid; gap: 13px; padding: 14px; border: 0; border-radius: 8px; background: #1c1e1b; }
.toolbar-group { gap: 13px; flex-wrap: wrap; line-height: 1.5; }
.toolbar-actions { gap: 9px; }
.control-button { padding: 10px 12px; border: 0; border-radius: 6px; background: #4b6232; color: #f4f5ee; font-size: 10px; }
.control-button.subtle { border: 0; background: #30342f; color: #ced3c6; }
.control-button:hover, .control-button[aria-pressed=true] { background: #688d3b; }
.circuit-panel { overflow: hidden; border: 0; border-radius: 9px; background: #1a1d19; }
.canvas-top, .canvas-bottom { background: #20231f; color: #929b8a; font-size: 9px; line-height: 1.35; }
.circuit-canvas { background-color: #171b17; }
.circuit-node { border-radius: 8px; background: #252a23; }
.circuit-node.powered { border-color: #698b42; background: #31442a; }
.circuit-info-grid { grid-template-columns: 1fr; gap: 10px; }
.detail-panel, .guide-panel { min-height: 0; padding: 19px; border: 0; border-radius: 9px; background: #1b1e1b; }
.detail-panel h2, .guide-panel h2 { font: 700 18px Arial,Helvetica,sans-serif; text-transform: none; }
.detail-metrics { gap: 30px; }
.guide-steps { flex-wrap: wrap; line-height: 1.6; }

.full-map-panel { max-width: none; margin: 0 -22px; border: 0; background: #141714; }
.full-map-top, .full-map-bottom { color: #adb4a4; background: #20231f; border-color: #343b31; font-size: 9px; line-height: 1.4; }
.full-map-image { aspect-ratio: 1; }
.full-map-image img { filter: saturate(.82) brightness(.86); }
.full-map-marker { background: #729c3f; }
.toast { z-index: 25; bottom: 97px; border: 0; border-radius: 9px; background: #2c3d25; }

.desktop-rail { display: none; }
@media (min-width: 1450px) {
  .desktop-rail {
    position: fixed;
    z-index: 2;
    top: 40px;
    width: clamp(220px, calc((100vw - 720px) / 2 - 62px), 300px);
    max-height: calc(100dvh - 70px);
    display: block;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #323a30 transparent;
  }
  .rail-left { right: calc(50% + 360px + 24px); }
  .rail-right { left: calc(50% + 360px + 24px); }
}
.rail-brand { display: block; width: 210px; max-width: 100%; height: auto; margin-bottom: 14px; }
.rail-caption { margin: 0 0 24px; color: #697368; font-size: 10px; font-weight: 800; letter-spacing: 2px; }
.rail-card { padding: 20px; margin-bottom: 12px; border-radius: 10px; border: 1px solid #292f29; background: #191c19; }
.rail-card small { display: block; color: #758171; font-size: 10px; font-weight: 800; letter-spacing: 1.4px; }
.rail-server strong { display: block; margin: 14px 0; color: #dce0d9; font-size: 16px; }
.rail-server > span { display: flex; align-items: center; gap: 7px; color: #a4bb83; font-size: 10px; font-weight: 800; letter-spacing: .8px; }
.rail-dot { width: 7px; height: 7px; border-radius: 50%; background: #94c24d; box-shadow: 0 0 8px #94c24d88; }
.rail-power strong { display: block; margin: 14px 0 11px; color: #eff3e9; font-size: 39px; font-weight: 700; line-height: 1; }
.rail-power em { color: #a5be79; font-size: 17px; font-style: normal; }
.rail-meter { height: 5px; overflow: hidden; border-radius: 4px; background: #30382d; }
.rail-meter span { display: block; height: 100%; width: 0; background: #8caf4c; transition: width .25s ease; }
.rail-power p { margin: 12px 0 0; color: #767f73; font-size: 11px; }
.rail-link { width: 100%; min-height: 66px; margin-top: 9px; padding: 10px 13px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 9px; background: #1b1e1b; color: #d9ddd4; text-align: left; cursor: pointer; }
.rail-link:hover { background: #2b3926; }
.rail-link > span { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 7px; background: #2b3928; color: #a7c278; font-size: 21px; }
.rail-link div { flex: 1; }
.rail-link strong, .rail-link small { display: block; }
.rail-link strong { font-size: 12px; }
.rail-link small { margin-top: 5px; color: #818a7b; font-size: 10px; }
.rail-link b { color: #8e9b80; font-size: 21px; }
.rail-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 0 13px; color: #9da899; font-size: 10px; font-weight: 800; letter-spacing: 1.3px; }
.rail-heading small { color: #707a6e; font-size: 9px; }
.rail-map { position: relative; width: 100%; height: 244px; overflow: hidden; padding: 0; border: 1px solid #3b4336; border-radius: 10px; background: #162326; cursor: pointer; }
.rail-map img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.73) brightness(.77); transition: transform .25s ease; }
.rail-map:hover img { transform: scale(1.04); }
.rail-map > span { position: absolute; left: 12px; bottom: 11px; padding: 7px 10px; border-radius: 5px; background: #31482de6; color: #e8f1dd; font-size: 9px; font-weight: 900; letter-spacing: .7px; }
.rail-heading-events { margin-top: 27px; }
.rail-heading-events button { border: 0; background: transparent; color: #a9be86; font-size: 10px; cursor: pointer; }
.rail-events { padding: 0 14px; border-radius: 10px; background: #191c19; }
.rail-events .event { gap: 8px; padding: 13px 0; }
.rail-events .event-icon { width: 24px; height: 24px; }
.rail-events .event strong { font-size: 10px; line-height: 1.3; }
.rail-events .event small { font-size: 9px; }
.rail-events .event time { font-size: 9px; }

@media (max-width: 620px) {
  .app-shell { padding: 0; }
  .main-wrap { padding-bottom: 80px; }
  .phone-statusbar { height: 28px; padding: 5px 19px 0; }
  .topbar { height: 57px; padding: 0 13px; }
  .topbar-title strong { font-size: 14px; }
  .sidebar { height: 74px; padding: 5px 9px 8px; }
  .nav-button, .nav-button.active { width: 57px; min-height: 59px; }
  .nav-button .nav-icon { width: 36px; height: 36px; font-size: 21px; }
  .nav-label { font-size: 8px; }
  .app-shell main { padding: 0 14px 27px; }
  .server-cover { height: 246px; margin: 0 -14px; }
  .server-details { padding: 12px 0; }
  .server-details > div { column-gap: 6px; }
  .server-details strong { font-size: 11px; }
  .server-details small { font-size: 10px; }
  .power-summary > div { padding: 12px; }
  .device-card, .device-row, .device-card.is-on, .device-row.is-on { min-height: 108px; padding: 9px; gap: 8px; }
  .device-art { width: 76px; height: 82px; }
  .device-art img { transform: scale(1.12); }
  .device-art img[src*="ceiling-light"] { transform: scale(1.28); }
  .device-art img[src*="door-controller"] { transform: scale(1.18); }
  .device-copy strong { font-size: 14px; }
  .device-copy small { font-size: 9px; }
  .device-action { width: 34px; height: 34px; }
  .device-action svg { width: 18px; height: 18px; }
  .device-grip { width: 10px; font-size: 19px; }
  .map-image { height: 175px; }
  .full-map-panel { margin: 0 -14px; }
  .full-map-top, .full-map-bottom { padding: 13px; }
  .canvas-top, .canvas-bottom { padding: 11px; }
  .toast { bottom: 83px; }
}
