:root {
  --icon: #111820;
  --sea-950: #16374b;
  --sea-900: #1d5673;
  --sea-800: #2e7fa8;
  --sea-700: #5ab9e6;
  --sea-600: #77c9ed;
  --sea-300: #acdff4;
  --sea-200: #ccecf9;
  --sea-100: #e7f6fd;
  --sea-50: #f5fbfe;
  --white: #ffffff;
  --gateway-green: #58bd85;
  --gateway-yellow: #f1c85b;
  --gauge-green: #9fd8b7;
  --gauge-red: #f2aaa5;
  --line: rgb(90 185 230 / 22%);
  --line-strong: rgb(90 185 230 / 38%);
  --shadow-sm: 0 12px 30px rgb(29 86 115 / 9%), 0 3px 10px rgb(90 185 230 / 9%);
  --shadow-lg: 0 26px 74px rgb(29 86 115 / 14%), 0 7px 24px rgb(90 185 230 / 11%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--sea-950);
  background: var(--sea-50);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--sea-50); }
body { min-width: 1180px; min-height: 100vh; margin: 0; background: var(--sea-50); color: var(--sea-950); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 90;
  top: calc(100% + 10px);
  left: 50%;
  width: max-content;
  max-width: 220px;
  transform: translate(-50%, -3px);
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
  color: var(--sea-900);
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Login */
.login-shell { min-height: 100vh; background: var(--sea-50); }
.login-panel { display: grid; min-height: 100vh; place-items: center; padding: 64px; }
.login-card {
  width: 430px;
  padding: 46px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--white);
  box-shadow: var(--shadow-lg);
}
.login-icon { display: block; margin-bottom: 24px; color: var(--sea-700); font-size: 34px; }
.login-card h1 { margin-bottom: 5px; color: var(--sea-950); font-size: 36px; font-weight: 730; }
.login-subtitle { margin-bottom: 34px; color: rgb(29 86 115 / 68%); font-size: 13px; font-weight: 650; }
label { color: var(--sea-900); font-size: 12px; font-weight: 760; }
input, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  outline: none;
  background: var(--white);
  color: var(--sea-950);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input { height: 50px; margin: 8px 0 20px; border-radius: 15px; padding: 0 15px; }
select {
  width: auto;
  min-width: 180px;
  height: 42px;
  border-radius: 999px;
  padding: 0 38px 0 15px;
  color: var(--sea-900);
  font-size: 12px;
  font-weight: 720;
}
input::placeholder { color: rgb(29 86 115 / 46%); }
input:focus, select:focus { border-color: var(--sea-700); box-shadow: 0 0 0 4px rgb(90 185 230 / 14%); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 54px; }
.input-action { position: absolute !important; top: 12px; right: 6px; }
.form-error {
  margin: -5px 0 16px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sea-50);
  color: var(--sea-900);
  font-size: 12px;
  line-height: 1.45;
}
.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 17px;
  font-size: 13px;
  font-weight: 760;
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
}
.button:active, .icon-button:active, .nav-item:active, .nav-action:active { transform: translateY(1px); }
.button-primary { background: var(--sea-700); color: var(--sea-950); box-shadow: 0 10px 24px rgb(90 185 230 / 24%); }
.button-primary:hover { background: var(--sea-800); }
.button-wide { width: 100%; min-height: 52px; justify-content: space-between; padding: 0 19px; }

/* Floating navigation */
.app-shell { min-height: 100vh; background: var(--sea-50); }
.glass-header {
  position: fixed;
  z-index: 50;
  inset: 0 0 auto;
  display: flex;
  justify-content: center;
  padding-top: 14px;
  pointer-events: none;
}
.glass-nav {
  display: flex;
  width: max-content;
  min-height: 58px;
  align-items: center;
  gap: 5px;
  padding: 7px;
  border: 1px solid rgb(90 185 230 / 26%);
  border-radius: 22px;
  background: rgb(255 255 255 / 82%);
  box-shadow: 0 14px 38px rgb(29 86 115 / 12%), 0 3px 12px rgb(90 185 230 / 10%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  backdrop-filter: blur(22px) saturate(130%);
  pointer-events: auto;
}
.top-nav { display: flex; align-items: center; gap: 4px; }
.nav-item,
.nav-action,
.nav-status,
.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--icon);
  font-size: 21px;
  transition: color .15s ease, background .15s ease, transform .14s ease;
}
.nav-item:hover,
.nav-action:hover,
.nav-status:hover,
.icon-button:hover { background: var(--sea-100); color: var(--icon); }
.nav-item.active {
  border-radius: 50%;
  background: var(--sea-700);
  color: var(--icon);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 72%), 0 7px 17px rgb(90 185 230 / 34%);
}
.nav-item:focus-visible,
.nav-action:focus-visible,
.icon-button:focus-visible { outline: 3px solid var(--sea-300); outline-offset: 2px; }
.nav-count {
  position: absolute;
  top: 4px;
  right: 3px;
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid var(--white);
  border-radius: 50%;
  padding: 0;
  background: var(--icon);
  color: var(--white);
  font-size: 8px;
  font-weight: 850;
}
.nav-item.active .nav-count { background: var(--icon); color: var(--white); }
.nav-separator { width: 1px; height: 28px; margin: 0 3px; background: var(--line); }
.nav-status { position: relative; cursor: default; }
.status-mark {
  position: absolute;
  top: 6px;
  right: 5px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--sea-300);
}
.status-mark.online { background: var(--gateway-green); }
.status-mark.offline { background: var(--gateway-yellow); }
.outlined { border: 1px solid var(--line-strong); background: var(--white); }

/* Layout */
.main-content { width: min(1320px, calc(100% - 64px)); min-height: 100vh; margin: 0 auto; padding: 90px 0 50px; }
.view { padding-top: 16px; }
.overview-toolbar { display: flex; min-height: 56px; align-items: center; justify-content: center; margin-bottom: 12px; }
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(231 246 253 / 78%);
}
.segmented button {
  min-width: 104px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 19px;
  background: transparent;
  color: var(--sea-800);
  font-size: 12px;
  font-weight: 780;
}
.segmented button:hover { background: rgb(255 255 255 / 72%); }
.segmented button.active { background: var(--sea-700); color: var(--sea-950); box-shadow: inset 0 1px 0 rgb(255 255 255 / 74%), 0 6px 18px rgb(90 185 230 / 25%); }
.house-summary { min-height: 684px; }
#view-overview {
  position: relative;
  isolation: isolate;
}
#view-overview::before {
  position: absolute;
  z-index: -1;
  inset: 20px -28px -22px;
  border-radius: 46px;
  background:
    radial-gradient(circle at 13% 8%, rgb(255 255 255 / 96%) 0 8%, transparent 30%),
    radial-gradient(circle at 86% 28%, rgb(90 185 230 / 15%) 0 10%, transparent 34%),
    linear-gradient(145deg, rgb(255 255 255 / 74%), rgb(231 246 253 / 42%));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 88%), 0 34px 82px rgb(29 86 115 / 8%);
  content: "";
  pointer-events: none;
}
.gauge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.gauge-tile {
  position: relative;
  min-width: 0;
  height: 220px;
  overflow: hidden;
  border: 1px solid rgb(90 185 230 / 24%);
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 4%, rgb(255 255 255 / 100%) 0 9%, transparent 38%),
    linear-gradient(148deg, var(--white) 0 50%, var(--sea-50) 78%, var(--sea-100) 100%);
  box-shadow:
    inset 1px 1px 0 rgb(255 255 255 / 100%),
    inset -1px -1px 0 rgb(90 185 230 / 12%),
    0 19px 42px rgb(29 86 115 / 11%),
    0 5px 14px rgb(90 185 230 / 13%);
  transition: box-shadow .18s ease, transform .18s ease;
}
.gauge-tile::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(125deg, rgb(255 255 255 / 42%) 0 12%, transparent 35% 100%);
  content: "";
  pointer-events: none;
}
.gauge-tile:hover {
  transform: translateY(-2px);
  box-shadow:
    inset 1px 1px 0 rgb(255 255 255 / 100%),
    inset -1px -1px 0 rgb(90 185 230 / 14%),
    0 24px 52px rgb(29 86 115 / 13%),
    0 8px 20px rgb(90 185 230 / 16%);
}
.gauge-host { position: relative; z-index: 1; width: 100%; height: 100%; }
.loading-panel {
  display: grid;
  min-height: 540px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--white);
  color: var(--sea-700);
  font-size: 26px;
  box-shadow: var(--shadow-sm);
}

/* Shared content views */
.section-heading { min-height: 60px; margin: 2px 0 20px; }
.section-heading h1 { margin: 0; color: var(--sea-950); font-size: 30px; font-weight: 730; }
.split-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-tools, .filter-row { display: flex; align-items: center; gap: 10px; }
.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.panel-heading {
  display: flex;
  min-height: 60px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2, .panel-heading h3 { margin: 0; color: var(--sea-950); font-size: 16px; font-weight: 760; }
.panel-heading > i { color: var(--sea-700); font-size: 18px; }
.empty-copy { margin: 0; padding: 30px; color: rgb(29 86 115 / 62%); font-size: 12px; line-height: 1.5; }

/* Alarms */
.alarm-list { display: grid; }
.alarm-row {
  display: grid;
  min-height: 68px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line);
}
.alarm-row:last-child { border-bottom: 0; }
.alarm-severity {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--sea-100);
  color: var(--sea-800);
  font-size: 15px;
  font-weight: 850;
}
.alarm-copy strong, .alarm-copy small { display: block; }
.alarm-copy strong { color: var(--sea-950); font-size: 12px; }
.alarm-copy small { margin-top: 4px; color: rgb(29 86 115 / 62%); font-size: 10px; }
.alarm-time { color: rgb(29 86 115 / 56%); font-size: 10px; font-weight: 650; }

/* Controller explorer */
.explorer-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); align-items: start; gap: 18px; }
.screen-browser { position: sticky; top: 92px; }
.search-wrap { position: relative; padding: 16px 16px 7px; }
.search-wrap > i { position: absolute; z-index: 1; top: 34px; left: 30px; color: var(--sea-700); font-size: 17px; }
.search-wrap input { margin: 0; padding-left: 40px; }
.screen-list { max-height: calc(100vh - 220px); overflow-y: auto; padding: 8px 12px 14px; }
.screen-group {
  padding: 15px 9px 6px;
  color: rgb(29 86 115 / 55%);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.screen-button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 13px;
  padding: 11px 12px;
  background: transparent;
  color: var(--sea-900);
  text-align: left;
}
.screen-button:hover { background: var(--sea-50); }
.screen-button.active { background: var(--sea-700); color: var(--sea-950); }
.screen-button span, .screen-button small { display: block; }
.screen-button span { overflow: hidden; font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.screen-button small { overflow: hidden; margin-top: 3px; color: currentColor; font-size: 8px; opacity: .66; text-overflow: ellipsis; white-space: nowrap; }
.screen-detail { min-height: 560px; }
.screen-empty { display: grid; min-height: 558px; place-items: center; padding: 40px; color: rgb(29 86 115 / 56%); text-align: center; }
.screen-empty h3 { margin: 0; color: var(--sea-800); font-size: 16px; font-weight: 700; }
.screen-titlebar {
  display: flex;
  min-height: 80px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 22px;
  border-bottom: 1px solid var(--line);
}
.screen-titlebar h3 { margin: 0; color: var(--sea-950); font-size: 19px; font-weight: 740; }
.screen-content { padding: 22px; }
.screen-subheading { margin: 2px 0 13px; }
.screen-subheading h4 { margin: 0; color: var(--sea-900); font-size: 11px; font-weight: 820; letter-spacing: .06em; text-transform: uppercase; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.field-card { min-height: 88px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--sea-50); }
.field-card small, .field-card strong { display: block; }
.field-card small { color: rgb(29 86 115 / 66%); font-size: 9px; font-weight: 700; }
.field-card strong { margin-top: 10px; color: var(--sea-950); font-size: 18px; font-weight: 760; }
.field-card strong em { color: var(--sea-700); font-size: 10px; font-style: normal; font-weight: 700; }
.history-section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.history-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.history-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 13px;
  background: var(--white);
  color: var(--sea-800);
  font-size: 10px;
  font-weight: 750;
}
.history-button:hover { background: var(--sea-100); }
.chart-host { margin-top: 15px; }
.chart-wrap { padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); }
.chart-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.chart-title strong { color: var(--sea-950); font-size: 11px; }
.chart-title small { color: rgb(29 86 115 / 58%); font-size: 9px; }
.chart { display: block; width: 100%; min-height: 280px; overflow: visible; }
.chart-axis { stroke: rgb(90 185 230 / 32%); stroke-width: 1; }
.chart-grid { stroke: rgb(90 185 230 / 14%); stroke-width: 1; }
.chart-label { fill: var(--sea-800); font-size: 9px; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; color: var(--sea-800); font-size: 9px; }
.chart-legend i { width: 13px; height: 2px; }

/* System */
.system-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.definition-list { display: grid; grid-template-columns: auto 1fr; gap: 14px 22px; margin: 0; padding: 22px; }
.definition-list dt { color: rgb(29 86 115 / 60%); font-size: 10px; }
.definition-list dd { margin: 0; color: var(--sea-950); font-size: 11px; font-weight: 740; text-align: right; }
.safety-list { display: grid; gap: 13px; margin: 0; padding: 22px; list-style: none; }
.safety-list li { display: flex; align-items: center; gap: 10px; color: var(--sea-900); font-size: 11px; }
.safety-list i { color: var(--sea-700); font-size: 18px; }
.device-panel { margin-top: 18px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 20px; border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; }
th { background: var(--sea-50); color: rgb(29 86 115 / 62%); font-size: 9px; font-weight: 820; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: rgb(29 86 115 / 52%); font-size: 9px; }
.access-pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: var(--sea-100); color: var(--sea-800); font-size: 9px; font-weight: 760; }

.toast-region { position: fixed; z-index: 100; right: 24px; bottom: 24px; display: grid; width: 340px; gap: 9px; }
.toast {
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--white);
  color: var(--sea-900);
  box-shadow: var(--shadow-lg);
  font-size: 11px;
  line-height: 1.5;
  animation: toast-in .2s ease-out;
}
.toast.error { background: var(--sea-100); color: var(--sea-950); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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