:root {
  color: #102a43;
  background: #f4f8fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #102a43;
  --muted: #627d98;
  --blue: #075985;
  --blue-deep: #082f49;
  --cyan: #0891b2;
  --line: #d9e5ed;
  --surface: #fff;
  --green: #14883b;
  --red: #d81920;
  --shadow: 0 12px 35px rgba(15, 55, 78, 0.09);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 10% 0%, rgba(14,165,233,.08), transparent 28%), #f4f8fb; }
button, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(8,145,178,.35); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.startup { min-height: 100vh; display: grid; place-content: center; gap: 12px; color: var(--muted); text-align: center; }
.startup.error button { border: 0; border-radius: 12px; padding: 12px 18px; background: var(--blue-deep); color: #fff; }

.topbar { height: 62px; padding: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; backdrop-filter: blur(16px); }
.logo { width: 92px; height: 28px; object-fit: contain; object-position: left center; }
.customer-name { font-size: .95rem; color: var(--blue-deep); justify-self: center; }
.dots-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; display: grid; place-content: center; gap: 3px; padding: 0; }
.dots-button:hover { background: #eaf5fa; }
.dots-button span { display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--blue-deep); }
.main-menu { justify-self: end; }
.menu-backdrop { position: fixed; inset: 62px 0 0; background: rgba(8,47,73,.18); z-index: 31; }
.operator-menu { position: fixed; right: 14px; top: 56px; width: min(340px, calc(100vw - 28px)); z-index: 32; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 22px 60px rgba(8,47,73,.24); overflow: hidden; }
.menu-heading { padding: 18px 20px 13px; display: grid; gap: 3px; border-bottom: 1px solid var(--line); }
.menu-heading small { color: var(--muted); }
.operator-menu fieldset { margin: 0; padding: 14px; border: 0; }
.operator-menu legend { padding: 0 6px 8px; color: var(--muted); font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.operator-menu label { min-height: 64px; border-radius: 13px; display: flex; gap: 12px; align-items: center; padding: 9px 12px; }
.operator-menu label:hover { background: #f0f8fb; }
.operator-menu input { width: 20px; height: 20px; accent-color: var(--blue); }
.operator-menu label span { display: grid; gap: 3px; }
.operator-menu label small { color: var(--muted); }

main { width: min(1500px, 100%); margin: 0 auto; padding: 16px clamp(14px, 3vw, 42px) 106px; }
.toolbar { position: relative; }
.filter-button { min-height: 50px; width: 100%; display: flex; align-items: center; gap: 10px; padding: 0 16px; border: 1px solid #b8ccd9; border-radius: 14px; background: #fff; color: var(--blue-deep); font-weight: 800; text-align: left; }
.filter-button svg { width: 21px; height: 21px; color: var(--blue); }
.filter-button span { flex: 1; }
.filter-button b { color: var(--muted); }
.filters { margin-top: 10px; border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 14px; display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)) auto; gap: 10px; box-shadow: var(--shadow); }
.filters label { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.filters select { min-height: 46px; border: 1px solid #c7d8e2; border-radius: 11px; background: #f9fcfd; color: var(--ink); padding: 0 34px 0 10px; }
.reset-button { align-self: end; min-height: 46px; border: 0; border-radius: 11px; padding: 0 16px; background: #eaf5fa; color: var(--blue); font-weight: 800; }
.summary { min-height: 54px; margin: 14px 0; padding: 0 4px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.summary span { color: var(--red); font-weight: 750; }

.device-grid { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 16px; }
.device-card { min-height: 390px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.card-head { display: flex; justify-content: space-between; gap: 8px; padding: 18px 16px 0 18px; }
.product { color: var(--blue); font-weight: 850; font-size: .82rem; letter-spacing: .02em; }
.card-head h2, .alert-card h2 { margin: 6px 0 3px; font-size: 1.12rem; color: var(--blue-deep); }
.card-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.card-menu { width: 36px; height: 36px; flex: 0 0 auto; }
.card-body { padding: 18px; flex: 1; display: grid; place-content: center; justify-items: center; gap: 15px; text-align: center; }
.gauge { width: 152px; height: 152px; display: grid; place-items: center; position: relative; }
.gauge > svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(135deg); }
.gauge circle { fill: none; stroke-width: 15; stroke-linecap: round; }
.gauge-track { stroke: #e3e9ed; stroke-dasharray: 75 100; }
.gauge-fill { stroke-dashoffset: 0; }
.gauge > div { position: relative; z-index: 1; display: grid; gap: 3px; }
.gauge strong { color: var(--blue-deep); font-size: 2rem; }
.gauge span, .threshold { color: var(--muted); }
.battery { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.battery svg { width: 29px; height: 29px; }
.battery.ok { color: var(--green); }
.battery.low { color: var(--red); }
.battery span { flex-basis: 100%; font-size: .82rem; font-weight: 750; }
.threshold { font-size: .78rem; }
.presence { display: grid; justify-items: center; gap: 18px; }
.presence svg { width: 105px; height: 105px; stroke-width: 0; fill: currentColor; }
.presence.present { color: #24a632; }
.presence.empty { color: #9aa7b3; }
.presence strong { color: var(--ink); }
.touch-status { display: grid; justify-items: center; gap: 8px; }
.touch-status > svg { width: 80px; height: 80px; color: var(--cyan); }
.touch-status span { color: var(--muted); }
.touch-status strong { color: var(--blue-deep); line-height: 1.4; }
.online { min-height: 45px; padding: 0 18px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); color: var(--green); font-size: .88rem; font-weight: 750; }
.online span { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }

.alerts-view { width: min(900px, 100%); margin: 0 auto; }
.alerts-intro { min-height: 64px; padding: 4px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.alerts-intro span { color: var(--muted); font-size: .9rem; }
.alert-list { display: grid; gap: 14px; }
.alert-card { border: 1px solid var(--line); border-left: 6px solid var(--red); border-radius: 17px; background: #fff; padding: 18px; display: grid; grid-template-columns: 54px 1fr; gap: 16px; box-shadow: var(--shadow); }
.alert-symbol { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; background: #fff0f0; color: var(--red); }
.alert-symbol svg { width: 27px; height: 27px; }
.alert-content h2 { margin-top: 4px; }
.alert-content p { color: var(--muted); margin: 7px 0; }
.alert-content .alert-device { color: var(--ink); font-weight: 750; }
.complete-button { min-width: 112px; min-height: 46px; margin-top: 7px; border: 0; border-radius: 12px; background: var(--blue-deep); color: #fff; font-weight: 850; }
.complete-button:disabled { opacity: .65; cursor: wait; }
.action-error { color: var(--red) !important; font-weight: 700; }
.empty-state { min-height: 260px; border: 1px dashed #b8ccd9; border-radius: 18px; background: rgba(255,255,255,.76); display: grid; place-content: center; gap: 6px; text-align: center; padding: 28px; color: var(--muted); }
.empty-state strong { color: var(--blue-deep); font-size: 1.25rem; }
.empty-state p { margin: 0; }
.empty-state.success { border-style: solid; border-color: #b6dec2; background: #f2fbf4; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; min-height: 70px; padding: 5px max(12px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); display: flex; justify-content: center; gap: min(16vw, 180px); }
.bottom-nav button { min-width: 95px; border: 0; background: transparent; color: var(--muted); display: grid; justify-items: center; align-content: center; gap: 2px; position: relative; font-size: .78rem; font-weight: 800; }
.bottom-nav button::before { content: ""; position: absolute; left: 15px; right: 15px; top: -5px; height: 3px; border-radius: 0 0 4px 4px; background: transparent; }
.bottom-nav button.active { color: var(--blue); }
.bottom-nav button.active::before { background: var(--cyan); }
.bottom-nav svg { width: 27px; height: 27px; }
.bottom-nav b { position: absolute; top: 2px; left: calc(50% + 10px); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; display: grid; place-items: center; font-size: .72rem; }

@media (max-width: 1120px) {
  .device-grid { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
}

@media (max-width: 780px) {
  main { padding: 12px 12px 98px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .device-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .device-card { min-height: 340px; border-radius: 15px; }
  .card-head { padding: 14px 10px 0 13px; }
  .card-head h2 { font-size: 1rem; }
  .card-head p { font-size: .77rem; }
  .card-body { padding: 12px 8px; }
  .gauge { width: 124px; height: 124px; }
  .gauge strong { font-size: 1.65rem; }
  .presence svg { width: 86px; height: 86px; }
  .touch-status > svg { width: 66px; height: 66px; }
  .summary { font-size: .86rem; }
  .alerts-intro { align-items: flex-start; flex-direction: column; padding: 10px 4px 14px; }
}

@media (max-width: 430px) {
  .topbar { height: 58px; }
  .logo { width: 82px; height: 24px; }
  .customer-name { font-size: .88rem; }
  .filters { grid-template-columns: 1fr; }
  .summary { margin: 8px 0; min-height: 45px; }
  .device-card { min-height: 325px; }
  .gauge { width: 112px; height: 112px; }
  .gauge strong { font-size: 1.45rem; }
  .gauge span { font-size: .78rem; }
  .presence { gap: 12px; }
  .presence svg { width: 76px; height: 76px; }
  .battery { font-size: .87rem; }
  .online { padding: 0 12px; font-size: .8rem; }
  .alert-card { grid-template-columns: 44px 1fr; padding: 14px; gap: 12px; }
  .alert-symbol { width: 42px; height: 42px; }
}
