* { box-sizing: border-box; }
html, body { margin: 0; background: #0f0f10; color: #eaeaea;
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; background: #0f0f10ee; backdrop-filter: blur(8px);
  padding: calc(env(safe-area-inset-top) + 12px) 18px 10px; border-bottom: 1px solid #1f1f22; }
.top h1 { margin: 0; font-size: 20px; font-weight: 650; }

main { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(env(safe-area-inset-bottom) + 90px); }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex;
  background: #151517; border-top: 1px solid #242428; padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 9px 0 10px; font-size: 12px; color: #8a8a90; }
.tabs a .ico { display: block; font-size: 18px; line-height: 22px; }
.tabs a.on { color: #2ecc71; }

h2 { font-size: 18px; margin: 0 0 6px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #8a8a90;
  font-weight: 600; margin: 22px 0 8px; }
.muted { color: #8a8a90; font-size: 14px; line-height: 1.45; }
.small { font-size: 12px; }

.card { display: block; background: #18181b; border: 1px solid #232327; border-radius: 14px;
  padding: 14px; margin-bottom: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.name { font-size: 17px; font-weight: 600; }
.sub { font-size: 13px; color: #8a8a90; margin-top: 3px; }

.chip { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; background: #26262b;
  color: #ccc; white-space: nowrap; letter-spacing: .03em; }
.s-OPEN, .s-OPENING { background: #12392a; color: #2ecc71; }
.s-ARMED { background: #13304a; color: #4aa3f0; }
.s-CLOSING { background: #3a3110; color: #f1c40f; }
.s-FAULT, .s-ESD, .s-OFFLINE { background: #3d1515; color: #ff6b6b; }
.s-CLOSED { background: #26262b; color: #ddd; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #666;
  margin-right: 6px; vertical-align: 1px; }
.dot.on { background: #2ecc71; }
.dot.off { background: #ff6b6b; }

.stateBox { text-align: center; padding: 22px 12px; }
.stateBox .big { font-size: 34px; font-weight: 800; letter-spacing: .04em; }
.stateBox .sub { font-size: 15px; }
.big.s-OPEN, .big.s-OPENING { color: #2ecc71; background: none; }
.big.s-ARMED { color: #4aa3f0; background: none; }
.big.s-CLOSING { color: #f1c40f; background: none; }
.big.s-FAULT, .big.s-ESD, .big.s-OFFLINE { color: #ff6b6b; background: none; }
.big.s-CLOSED { color: #eee; background: none; }

input, select { width: 100%; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid #333;
  background: #0b0b0c; color: #fff; margin-bottom: 10px; -webkit-appearance: none; appearance: none; }
input.pin { font-size: 26px; text-align: center; letter-spacing: 8px; }
label.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 15px;
  border-bottom: 1px solid #222; }
label.check input { width: 22px; height: 22px; margin: 0; -webkit-appearance: checkbox; appearance: auto; }

.btn { display: block; width: 100%; font-size: 17px; font-weight: 650; padding: 15px; border: 0;
  border-radius: 12px; color: #fff; background: #2a2a2f; margin-bottom: 10px; cursor: pointer; }
.btn:disabled { opacity: .5; }
.btn.primary { background: #1d9e75; }
.btn.danger { background: #c0392b; }
.btn.small { display: inline-block; width: auto; font-size: 13px; padding: 7px 11px; margin: 6px 6px 0 0;
  border-radius: 8px; font-weight: 600; }
.btn.link { background: none; color: #8a8a90; font-weight: 500; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.msg { min-height: 20px; text-align: center; font-size: 14px; color: #aaa; margin: 4px 0 6px; }
.msg.err { color: #ff6b6b; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid #202024; font-size: 14px; display: flex; gap: 10px; }
.list li time { color: #8a8a90; min-width: 78px; font-size: 13px; }
.ev-bad { color: #ff6b6b; }
.ev-good { color: #2ecc71; }

.back { display: inline-block; color: #8a8a90; font-size: 15px; margin-bottom: 10px; }
.empty { text-align: center; padding: 40px 10px; }

.overlay { position: fixed; inset: 0; z-index: 20; background: #0f0f10; display: flex;
  align-items: center; justify-content: center; padding: 24px; }
.overlay .panel { width: 100%; max-width: 380px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 80px); transform: translateX(-50%);
  z-index: 30; background: #2a2a2f; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: 90%; text-align: center; }
.toast.err { background: #7a1f1f; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { display: block; background: #18181b; border: 1px solid #232327; border-radius: 10px; overflow: hidden; }
.thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #111; }
.thumb span { display: block; font-size: 11px; color: #8a8a90; padding: 5px 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.photo-link { color: #4aa3f0; font-size: 13px; white-space: nowrap; }
.viewer { position: fixed; inset: 0; z-index: 40; background: #000e; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 16px; text-align: center; }
.viewer img { max-width: 100%; max-height: 75vh; border-radius: 10px; background: #111; min-width: 60%; min-height: 30vh; }
.viewer .cap { font-size: 15px; color: #eee; }
