:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101923;
  color: #e8eef2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --muted: #82909b;
  --line: #25323d;
  --panel: #151f29;
  --teal: #54d6bc;
}

* { box-sizing: border-box; }

body {
  min-width: 360px;
  margin: 0;
  background:
    radial-gradient(ellipse at 87% 1%, rgba(35, 83, 83, .14), transparent 34rem),
    #101923;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }

.shell { max-width: 1320px; margin: 0 auto; padding: 0 54px 60px; }

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(133, 153, 165, .16);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; color: var(--teal); display: inline-flex; }
.brand-mark svg { width: 100%; }
.brand-name { font: 500 11px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .13em; color: #d7e1e7; }
.brand-divider { color: #52636f; padding: 0 7px; }
.topbar-right { display: flex; align-items: center; gap: 17px; color: var(--muted); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.environment { display: inline-flex; align-items: center; gap: 8px; color: #a7b5be; }
.environment-dot, .mini-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.environment-dot { background: #63d4aa; box-shadow: 0 0 9px rgba(99, 212, 170, .42); }
.topbar-separator { height: 16px; border-left: 1px solid var(--line); }
.updated { min-width: 110px; text-align: right; }
.page-nav { display: flex; gap: 20px; margin-top: 20px; }
.page-nav a { color: var(--muted); text-decoration: none; padding: 8px 0; font-size: 13px; border-bottom: 2px solid transparent; }
.page-nav a:hover, .page-nav a[aria-current="page"] { color: var(--teal); border-bottom-color: var(--teal); }
.sensor-table { min-width: 700px; }
.gateway-link, .eyebrow a { color: inherit; text-decoration: none; }
.gateway-link:hover, .eyebrow a:hover { color: var(--teal); text-decoration: underline; }
.gateway-menu-link { display: block; padding: 10px; color: #cbd6dc; text-decoration: none; font-size: 12px; }
.gateway-menu-link:hover { background: #263642; }
.primary-button { border-color: #3e8779; color: var(--teal); }
.action-message { color: var(--teal); font-size: 13px; }
#provision-error { color: #f0b4a7; }
#gateway-serial { overflow-wrap: anywhere; }
.gateway-heading { flex-wrap: wrap; gap: 18px; }
dialog select { width: 100%; padding: 10px; border: 1px solid #52616c; border-radius: 5px; background: #101923; color: #e8eef2; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 47px 0 26px; }
.eyebrow { color: #7f909c; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; margin: 0 0 12px; }
.eyebrow span { color: #4b5c67; padding: 0 5px; }
h1 { margin: 0; color: #f0f4f6; font-size: clamp(29px, 3vw, 36px); letter-spacing: -.045em; font-weight: 600; }
.subheading { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.refresh-button {
  height: 37px;
  border: 1px solid #35434e;
  background: #19242e;
  color: #cbd6dc;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 0 13px;
  border-radius: 6px;
  font-size: 12px;
  transition: border-color .2s, background .2s;
}
.refresh-button:hover { border-color: #60737f; background: #1d2a35; }
.refresh-button svg { width: 16px; height: 16px; color: #9cabb4; }
.refresh-button.loading svg { animation: rotate .9s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card {
  min-height: 123px;
  border: 1px solid #283641;
  border-radius: 8px;
  background: linear-gradient(140deg, rgba(25, 38, 48, .96), rgba(20, 30, 39, .96));
  padding: 17px 19px 15px;
}
.metric-label { display: flex; align-items: center; justify-content: space-between; color: #8797a2; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .09em; }
.metric-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; font-size: 16px; }
.icon-total { color: #82a9c1; background: rgba(96, 142, 169, .12); }
.icon-claimed { color: #b09add; background: rgba(157, 125, 211, .13); }
.icon-online { color: #54d6bc; background: rgba(84, 214, 188, .12); }
.icon-offline { color: #ee9b87; background: rgba(238, 155, 135, .12); }
.metric-value { margin-top: 10px; color: #edf2f4; font: 500 27px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.04em; }
.metric-foot { display: flex; align-items: center; gap: 7px; margin-top: 4px; color: #82909b; font-size: 11px; }
.claimed-dot { background: #ad95dc; }
.online-dot { background: #54d6bc; }
.offline-dot { background: #e9957f; }

.fleet-panel { border: 1px solid #283641; border-radius: 8px; background: rgba(21, 31, 41, .88); overflow: hidden; }
.fleet-header { min-height: 88px; padding: 19px 21px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
h2 { color: #e6edf0; font-size: 15px; font-weight: 600; margin: 0; }
.table-count { color: #8797a2; background: #24323d; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 6px; border-radius: 4px; margin-left: 5px; vertical-align: 2px; }
.fleet-header p { color: #82909b; font-size: 11px; margin: 5px 0 0; }
.table-controls { display: flex; align-items: center; gap: 9px; }
.search-box {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  min-width: 190px;
  border: 1px solid #33414c;
  border-radius: 5px;
  background: #121b23;
  color: #81919b;
}
.search-box svg { width: 15px; height: 15px; flex: 0 0 auto; }
.search-box input { width: 100%; border: 0; outline: 0; color: #dbe3e7; background: transparent; font-size: 11px; }
.search-box input::placeholder { color: #74838e; }
.filter-label select {
  height: 34px;
  min-width: 125px;
  padding: 0 25px 0 10px;
  color: #c0cbd1;
  border: 1px solid #33414c;
  border-radius: 5px;
  background: #19242e;
  font-size: 11px;
}
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 790px; }
thead { background: rgba(17, 26, 34, .68); }
th {
  text-align: left;
  padding: 11px 20px;
  color: #758691;
  border-top: 1px solid #283641;
  border-bottom: 1px solid #283641;
  font: 9px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .09em;
  white-space: nowrap;
}
td { padding: 14px 20px; border-bottom: 1px solid rgba(40, 54, 65, .72); font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(36, 54, 66, .32); }
.gateway-cell { display: flex; align-items: center; gap: 11px; }
.gateway-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 6px; border: 1px solid #344550; background: #1e2d37; color: #83b9c3; }
.gateway-icon svg { width: 17px; height: 17px; }
.gateway-serial { color: #e3eaed; font: 500 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.gateway-model { margin-top: 3px; color: #7e8e98; font-size: 10px; }
.claim-badge, .connection-badge, .registration-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; }
.claim-badge { color: #b2a1d9; }
.claim-badge.unclaimed { color: #929fa8; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.connection-badge.online { color: #54d6bc; }
.connection-badge.offline { color: #e99a83; }
.connection-badge.unknown { color: #a2abb2; }
.registration-badge { color: #b6c2c9; }
.registration-badge.ready::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #7bcaa9; }
.registration-badge.pending::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #e6ba6c; }
.registration-badge.failed::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #e99a83; }
.last-event { color: #a6b2b9; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.state-cell { height: 100px; color: #8c9ba5; text-align: center; }
.device-child-row td:first-child { color: #a6b2b9; }
.empty-title { color: #d0d9de; font-size: 12px; margin-bottom: 5px; }
.empty-copy { color: #85949e; font-size: 11px; }
.loading-mark { display: inline-block; width: 12px; height: 12px; border: 1px solid #546873; border-top-color: var(--teal); border-radius: 50%; vertical-align: -2px; margin-right: 8px; animation: rotate .8s linear infinite; }
.panel-footer { height: 40px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; color: #788892; background: rgba(17, 26, 34, .5); border-top: 1px solid #283641; font-size: 10px; }
.panel-footer strong { color: #bfcbd1; font-weight: 500; }
.live-pulse { width: 6px; height: 6px; display: inline-block; margin-right: 6px; border-radius: 50%; background: #54d6bc; box-shadow: 0 0 0 3px rgba(84, 214, 188, .1); }
.disclaimer { margin: 14px 1px; color: #788892; font-size: 10px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(440px, calc(100vw - 48px)); padding: 12px 16px; border: 1px solid #714c4c; border-radius: 6px; background: #302326; color: #f1c4b8; font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.gateway-model { display: block; }
.gateway-actions { text-align: right; }
.options-button {
  width: 32px;
  height: 30px;
  border: 1px solid #35434e;
  border-radius: 5px;
  background: #19242e;
  color: #cbd6dc;
  font-weight: 700;
  letter-spacing: 2px;
}
.options-button:hover { background: #263642; }
.options-dropdown {
  position: fixed;
  inset: auto;
  width: 160px;
  margin: 0;
  padding: 5px;
  border: 1px solid #47515c;
  border-radius: 6px;
  background: #19242e;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.delete-menu-item {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #f0b4a7;
  text-align: left;
  font-size: 12px;
}
.delete-menu-item:hover { background: #352529; }
.delete-button {
  border: 1px solid #84534c;
  border-radius: 5px;
  padding: 8px 11px;
  color: #f0b4a7;
  background: #352529;
  font-size: 11px;
}
.delete-button:hover:not(:disabled) { background: #493034; border-color: #bf7a6e; }
button:disabled { cursor: not-allowed; opacity: .5; }
dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 25px;
  border: 1px solid #47515c;
  border-radius: 9px;
  background: #19242e;
  color: #dce5eb;
}
dialog::backdrop { background: rgba(5, 11, 17, .78); }
dialog h2 { font-size: 20px; }
dialog p { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
dialog label { display: block; font-size: 12px; margin-bottom: 8px; }
dialog input { width: 100%; padding: 10px; border: 1px solid #52616c; border-radius: 5px; background: #101923; color: #e8eef2; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#delete-error, #claim-error { color: #f0b4a7; }
#claim-code { text-transform: uppercase; letter-spacing: .2em; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

@media (max-width: 860px) {
  .shell { padding: 0 25px 40px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell { padding: 0 16px 30px; }
  .topbar { height: 62px; }
  .brand-name { font-size: 9px; }
  .topbar-right { gap: 8px; font-size: 8px; }
  .topbar-separator, .updated { display: none; }
  .page-heading { margin-top: 34px; align-items: flex-start; }
  .subheading { max-width: 245px; line-height: 1.5; }
  .refresh-button { padding: 0 9px; }
  .metrics { gap: 9px; }
  .metric-card { min-height: 112px; padding: 13px 12px; }
  .metric-label { font-size: 8px; }
  .fleet-header { align-items: flex-start; flex-direction: column; padding: 17px 14px; }
  .table-controls { width: 100%; }
  .search-box { flex: 1; min-width: 0; }
  .filter-label select { min-width: 115px; }
  .panel-footer { padding: 0 13px; font-size: 9px; }
}
