:root {
  color-scheme: light;
  --ink: #182025;
  --muted: #65717a;
  --line: #d8e0e4;
  --surface: #f4f7f8;
  --panel: #ffffff;
  --green: #1f7a4d;
  --red: #b63d3d;
  --blue: #2769a6;
  --amber: #9a6a12;
  --focus: #2c77b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.loginShell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f7f9fa;
}

.loginPanel {
  display: grid;
  justify-items: center;
}

.loginPanel .primaryButton {
  min-width: 184px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbarActions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.authStatus {
  max-width: 260px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 720;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 720;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 720;
}

.topbar p,
.hint,
.message,
.meta,
.detailText {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.shell {
  width: min(1500px, 100%);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 20px 24px 32px;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.deviceListPanel,
.detailPanel {
  min-height: 620px;
}

.sectionHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

label span {
  display: block;
  margin-bottom: 5px;
  color: #3c484f;
  font-size: 12px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid #cbd4d8;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(44, 119, 184, 0.16);
}

button {
  height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.primaryButton {
  background: var(--blue);
  color: #fff;
}

.secondaryButton {
  background: #edf2f5;
  border-color: #cbd7dd;
  color: #24313a;
}

.dangerButton {
  background: #fff2f0;
  border-color: #e2b6ae;
  color: #94312f;
}

.iconButton {
  width: 38px;
  padding: 0;
  background: #eef3f5;
  color: #1f303a;
  font-size: 18px;
}

.primaryIconButton {
  background: var(--blue);
  color: #fff;
}

.message {
  min-height: 20px;
  margin-top: 12px;
}

.message.error {
  color: var(--red);
}

.message.success {
  color: var(--green);
}

.deviceList {
  display: grid;
}

.deviceListItem {
  width: 100%;
  height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 16px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.deviceListItem:last-child {
  border-bottom: 0;
}

.deviceListItem:hover,
.deviceListItem.selected {
  background: #f0f5f8;
}

.deviceListItem.selected {
  box-shadow: inset 3px 0 0 var(--blue);
}

.deviceName {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 760;
  line-height: 1.25;
}

.deviceMeta {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
}

.deviceStatus {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  text-transform: uppercase;
}

.statusDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8a969e;
}

.statusDot.status-online {
  background: var(--green);
}

.statusDot.status-degraded {
  background: var(--amber);
}

.hubDetail {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.signedOutPanel {
  display: grid;
  max-width: 520px;
  gap: 14px;
  padding: 28px;
}

.signedOutPanel h2 {
  font-size: 24px;
}

.signedOutPanel .primaryButton {
  justify-self: start;
}

.detailHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
}

.detailTitle {
  min-width: 0;
}

.detailTitle h2 {
  overflow-wrap: anywhere;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 790;
}

.detailTitle p {
  margin-top: 10px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 620;
}

.statusPill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-width: 86px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.status-online {
  background: #e2f4ea;
  color: var(--green);
}

.status-degraded {
  background: #fff2d6;
  color: var(--amber);
}

.status-offline,
.status-starting,
.status-stopping {
  background: #edf1f3;
  color: #46545d;
}

.tabList {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.tabButton {
  height: 46px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.tabButton.selected {
  border-bottom-color: var(--blue);
  color: var(--ink);
}

.tabPanel {
  flex: 1;
  padding: 20px 24px 24px;
}

.configurationTab {
  display: grid;
  gap: 18px;
}

.detailActions,
.editActions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.detailText {
  overflow-wrap: anywhere;
}

.configGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  margin: 0;
}

.configGrid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #dce4e8;
  border-radius: 6px;
  background: #fbfcfd;
}

.configGrid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.configGrid dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #26333a;
  font-size: 14px;
  line-height: 1.45;
}

.editForm,
.hubForm {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  width: 100%;
}

.hubForm {
  grid-template-columns: 1fr 1fr;
}

.hubForm label:nth-child(1),
.hubForm label:nth-child(4),
.hubForm label:nth-child(5),
.hubForm label:nth-child(6),
.hubForm label:nth-child(7),
.hubForm .primaryButton {
  grid-column: 1 / -1;
}

.editHeader {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.editHeader strong {
  font-size: 15px;
}

.editForm label,
.hubForm label {
  min-width: 0;
}

.editForm label:nth-child(4),
.editForm label:nth-child(5) {
  grid-column: span 2;
}

.editActions {
  grid-column: 1 / -1;
}

.messageLog {
  display: grid;
  gap: 10px;
}

.deviceTab {
  display: grid;
  gap: 16px;
}

.deviceTabHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.deviceTabHeader h3 {
  margin-bottom: 4px;
}

.modeList {
  display: grid;
  gap: 10px;
}

.modeRow,
.accessoryRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dce4e8;
  border-radius: 6px;
  background: #fbfcfd;
}

.modeRow strong,
.modeRow span,
.modeRow time,
.accessoryRow strong,
.accessoryRow span,
.accessoryRow time {
  display: block;
}

.modeRow strong,
.accessoryRow strong {
  margin-bottom: 4px;
  font-size: 14px;
}

.modeRow div span,
.modeRow time,
.accessoryRow div span,
.accessoryRow time {
  color: var(--muted);
  font-size: 13px;
}

.accessoryPanel {
  display: grid;
  gap: 12px;
  padding-top: 2px;
}

.accessoryToolbar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.accessoryList {
  display: grid;
  gap: 10px;
}

.accessoryRow {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.accessoryActions {
  display: inline-flex;
  gap: 8px;
}

.accessoryActions button {
  min-width: 74px;
}

.modeBadge {
  min-width: 112px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  text-transform: uppercase;
}

.mode-disarmed {
  background: #e2f4ea;
  color: var(--green);
}

.mode-away {
  background: #fff2d6;
  color: var(--amber);
}

.mode-home {
  background: #e8f0fb;
  color: var(--blue);
}

.accessory-open {
  background: #fff2d6;
  color: var(--amber);
}

.accessory-closed {
  background: #e2f4ea;
  color: var(--green);
}

.accessory-motion {
  background: #fff2d6;
  color: var(--amber);
}

.accessory-noMotion {
  background: #e2f4ea;
  color: var(--green);
}

.mode-unknown {
  background: #edf1f3;
  color: #46545d;
}

.messageLogHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.messageLogHeader strong {
  font-size: 14px;
}

.messageLogActions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.messageRefreshButton {
  width: 30px;
  height: 30px;
  min-height: 30px;
  font-size: 13px;
}

.logEntry {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid #dce4e8;
  border-left-width: 4px;
  border-radius: 6px;
  background: #fff;
}

.logEntry.direction-inbound {
  border-left-color: var(--blue);
}

.logEntry.direction-outbound {
  border-left-color: var(--green);
}

.logEntry.direction-system {
  border-left-color: var(--amber);
}

.logEntry p {
  color: #2f3a40;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.logMeta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.logMeta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.logEntry pre {
  max-height: 260px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid #dce4e8;
  border-radius: 6px;
  background: #f4f7f8;
  color: #1f2a30;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.placeholderPanel {
  display: grid;
  gap: 8px;
  padding: 24px;
  border: 1px dashed #c7d2d8;
  border-radius: 8px;
  background: #fbfcfd;
}

.compactPanel {
  padding: 18px;
}

.placeholderPanel p {
  color: var(--muted);
  font-size: 14px;
}

.emptyState {
  padding: 44px 18px;
  color: var(--muted);
  text-align: center;
}

.emptyState.compact {
  padding: 20px 12px;
}

.hubDialog {
  width: min(680px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 22px 80px rgba(20, 31, 39, 0.28);
}

.hubDialog::backdrop {
  background: rgba(18, 30, 38, 0.42);
}

.dialogPanel {
  padding: 18px;
  background: var(--panel);
}

.dialogHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .deviceListPanel,
  .detailPanel {
    min-height: auto;
  }

  .detailTitle h2 {
    font-size: 26px;
  }

  .detailTitle p {
    font-size: 22px;
  }

  .configGrid,
  .editForm {
    grid-template-columns: 1fr 1fr;
  }

  .editForm label:nth-child(4),
  .editForm label:nth-child(5) {
    grid-column: 1 / -1;
  }

  .detailActions,
  .editActions {
    justify-content: flex-start;
  }

  .logMeta {
    flex-direction: column;
    gap: 4px;
  }

  .modeRow,
  .accessoryRow {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .accessoryActions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 14px 16px;
  }

  .shell {
    padding: 16px;
  }

  .detailHeader {
    display: grid;
    padding: 20px;
  }

  .detailTitle h2 {
    font-size: 24px;
  }

  .detailTitle p {
    font-size: 18px;
  }

  .tabList {
    padding: 0 16px;
    overflow-x: auto;
  }

  .tabPanel {
    padding: 16px;
  }

  .configGrid,
  .editForm,
  .hubForm {
    grid-template-columns: 1fr;
  }

  .hubForm label,
  .hubForm .primaryButton,
  .editForm label:nth-child(4),
  .editForm label:nth-child(5) {
    grid-column: auto;
  }

  .editHeader {
    display: grid;
  }
}
