@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/dashboard/fonts/IBMPlexSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/dashboard/fonts/IBMPlexSans-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/dashboard/fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/dashboard/fonts/IBMPlexMono-Medium.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --accent: #6d5efc;
  --accent-rgb: 109 94 252;
  --on-accent: #ffffff;
  --bg: #0c0e14;
  --bg-rgb: 12 14 20;
  --text: #f5f1fb;
  --muted: #b7b0c6;
  --soft: #8e879d;
  --line: rgb(255 255 255 / 0.14);
  --ok: #8ee7b0;
  --danger: #ffb4ab;
  --radius: 28px;
  --row: 92px;
  --gap: 14px;
  --glass: rgb(24 20 36 / 0.62);
  --shadow: 0 16px 40px rgb(0 0 0 / 0.28);
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
::selection { background: rgb(var(--accent-rgb) / 0.45); color: var(--text); }

body.dashboard-page,
body.login-page {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(980px 520px at 0% -10%, rgb(var(--accent-rgb) / 0.46), transparent 58%),
    radial-gradient(760px 460px at 110% -8%, rgb(var(--accent-rgb) / 0.24), transparent 52%),
    radial-gradient(640px 420px at 70% 120%, rgb(var(--accent-rgb) / 0.16), transparent 50%);
  background-repeat: no-repeat;
  animation: wash 46s ease-in-out infinite;
}
@keyframes wash {
  0%, 100% { background-position: 0% 0%, 100% 0%, 70% 100%; }
  50% { background-position: 8% 6%, 88% 10%, 60% 90%; }
}

.app {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.topbar,
.tile,
.catalog,
.login-panel {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.45);
  -webkit-backdrop-filter: blur(22px) saturate(1.45);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px 14px 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgb(var(--accent-rgb) / 0.22);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: -0.04em;
}
.brand-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.topbar-copy { min-width: 0; }
.eyebrow, .topbar-status, .topbar-date {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.ghost-button, .solid-button, .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.04);
}
.ghost-button:hover { background: rgb(255 255 255 / 0.08); }
.solid-button, .primary-button, .ha-primary {
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.solid-button:hover, .primary-button:hover, .ha-primary:hover { filter: brightness(1.08); }
.solid-button:disabled, .primary-button:disabled, .ha-primary:disabled { opacity: 0.55; cursor: wait; }
.count-pill {
  min-width: 1.4em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

.page-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 2px 14px;
}
.page-tabs {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 2px;
}
.page-tab {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.page-tab.is-active,
.page-tab-input {
  background: rgb(var(--accent-rgb) / 0.2);
  color: var(--text);
}
.page-tab.is-drop { outline: 2px solid var(--accent); }
.page-tab-input {
  width: 9rem;
  border: 0;
  font: inherit;
  font-weight: 600;
}
.edit-actions { display: flex; gap: 8px; flex: none; }

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}
body.is-editing .workspace { grid-template-columns: minmax(0, 1fr) 300px; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: var(--row);
  gap: var(--gap);
  align-content: start;
  min-height: 280px;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 16px 16px 14px;
  overflow: hidden;
}
body.is-editing .tile { touch-action: none; user-select: none; }
.tile.is-dragging { z-index: 3; opacity: 0.92; }
.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.tile-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.tile-body {
  min-height: 0;
  flex: 1;
  overflow: auto;
}
body.is-editing .tile-body { pointer-events: none; }
.tile-missing .tile-body { color: var(--muted); }

.tile-remove, .tile-resize, .tile-nudge { display: none; }
body.is-editing .tile-remove,
body.is-editing .tile-resize { display: grid; place-items: center; }
.tile-remove, .tile-nudge {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(12 10 18 / 0.45);
  font-size: 12px;
}
.tile-resize {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background:
    linear-gradient(135deg, transparent 50%, rgb(var(--accent-rgb) / 0.9) 50%);
  cursor: nwse-resize;
}
.tile-nudges { display: flex; gap: 4px; }

.stat-tile { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.stat-value {
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 1;
}
.spark { width: 100%; height: 42px; }
.stat-detail { margin: 0; color: var(--muted); font-size: 13px; }
.uptime-rule {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(var(--accent-rgb) / 0.15), var(--accent));
}

.route-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
}
.route-top { display: flex; align-items: center; justify-content: space-between; }
.route-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgb(var(--accent-rgb) / 0.18);
  color: var(--accent);
}
.icon { width: 22px; height: 22px; }
.route-go { color: var(--soft); }
.route-link h3 { margin: 0; font-size: 22px; letter-spacing: -0.04em; }
.route-link p { margin: 0; color: var(--muted); font-size: 13px; }
.route-bottom { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; font-size: 12px; }
.route-category { color: var(--soft); }
.reach.is-up { color: var(--ok); }
.reach.is-down { color: var(--danger); }

.endpoint-list { display: grid; gap: 8px; }
.endpoint-row {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: 16px;
  background: rgb(255 255 255 / 0.04);
}
.endpoint-row strong { font-size: 14px; }
.endpoint-row small, .endpoint-note { color: var(--muted); font-size: 12px; }
.endpoint-row code {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}
.endpoint-note { margin: 10px 0 0; }

.catalog { padding: 18px; max-height: calc(100vh - 150px); overflow: auto; }
.catalog-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.catalog-head p { margin: 6px 0 14px; color: var(--muted); font-size: 13px; }
.catalog-list { display: grid; gap: 8px; }
.catalog-list h3 {
  margin: 10px 0 0;
  color: var(--soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 255 255 / 0.04);
  text-align: left;
}
.catalog-item:hover { border-color: rgb(var(--accent-rgb) / 0.7); }
.catalog-add {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgb(var(--accent-rgb) / 0.2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.empty-page, .empty-copy {
  margin: 0;
  color: var(--muted);
  text-align: center;
}
.empty-page { grid-column: 1 / -1; padding: 48px 12px; }
.layout-message { min-height: 1.2em; margin: 12px 4px 0; color: var(--muted); font-size: 13px; }
.footer {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  color: var(--soft);
  font-size: 12px;
}

.stealth-list { margin: 0; padding: 0; list-style: none; }
.stealth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.stealth-row:last-child { border-bottom: 0; }
.stealth-row strong { display: block; font-size: 14px; }
.stealth-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.stealth-toggle { position: relative; display: inline-flex; width: 48px; height: 28px; flex: none; }
.stealth-toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.stealth-toggle span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.16);
}
.stealth-toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.stealth-toggle input:checked + span { background: var(--accent); }
.stealth-toggle input:checked + span::after { transform: translateX(20px); }
.stealth-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.stealth-message { min-height: 1.2em; margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.ha-host { display: flex; flex-direction: column; }
.ha-tile { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.ha-setup, .ha-connected { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.ha-panel-intro h3 { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
.ha-panel-intro p, .ha-message { margin: 0; color: var(--muted); font-size: 13px; }
.ha-message { color: var(--danger); min-height: 1.2em; }
.ha-connect-form, .ha-toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.ha-connect-form label, .ha-search { display: grid; gap: 6px; flex: 1 1 180px; font-size: 12px; font-weight: 600; }
.ha-connect-form input, .ha-search input, .input-wrap input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(255 255 255 / 0.05);
  color: var(--text);
}
.ha-toolbar { align-items: center; justify-content: space-between; }
.ha-toolbar strong { display: block; overflow-wrap: anywhere; }
.ha-toolbar small { color: var(--muted); }
.ha-toolbar-actions, .ha-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ha-toolbar-actions button, .ha-actions button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.04);
  font-size: 12px;
}
.ha-actions button:disabled { opacity: 0.45; }
.ha-entities {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: auto;
}
.ha-entity {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgb(255 255 255 / 0.04);
}
.ha-entity-details { min-width: 0; }
.ha-entity-details strong, .ha-entity-details small { display: block; overflow-wrap: anywhere; }
.ha-entity-details small { margin-top: 2px; color: var(--soft); font-family: var(--mono); font-size: 10px; }
.ha-entity-side { display: grid; justify-items: end; gap: 6px; }
.ha-state { font-size: 13px; text-align: right; }
.ha-state.unavailable, .ha-empty { color: var(--soft); }
.ha-empty { grid-column: 1 / -1; margin: 0; text-align: center; }

.downloads-host { display: flex; flex-direction: column; min-height: 0; }
.downloads-tile { display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; }
.downloads-intro h3 { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
.downloads-intro p, .downloads-message { margin: 0; color: var(--muted); font-size: 13px; }
.downloads-message { min-height: 1.2em; }
.downloads-message.is-error { color: var(--danger); }
.downloads-toolbar { display: flex; justify-content: flex-end; }
.downloads-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}
.downloads-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgb(255 255 255 / 0.04);
}
.downloads-copy { min-width: 0; }
.downloads-copy strong { display: block; font-size: 14px; }
.downloads-copy p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.downloads-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--soft);
  font-family: var(--mono);
  font-size: 10px;
}
.downloads-actions { display: flex; align-items: center; }
.downloads-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.login-page { display: grid; place-items: center; }
.login-shell { width: min(100%, 440px); padding: 24px; }
.login-panel { padding: 28px; }
.login-header, .login-panel h1, .login-intro, .login-kicker { margin: 0; }
.login-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.login-kicker, .login-intro { color: var(--muted); }
.login-kicker { font-size: 13px; }
.login-panel h1 { font-size: 32px; letter-spacing: -0.045em; }
.login-intro { margin: 8px 0 22px; font-size: 14px; }
.login-panel label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.input-wrap {
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 255 255 / 0.05);
}
.input-wrap input { border: 0; background: transparent; }
.input-wrap button { border: 0; background: transparent; color: var(--muted); padding: 0 12px; font-weight: 600; }
.primary-button { width: 100%; margin-top: 16px; min-height: 48px; }
.form-error { margin: 10px 0 0; color: var(--danger); font-size: 13px; }

@media (prefers-reduced-transparency: reduce) {
  .topbar, .tile, .catalog, .login-panel {
    background: #1b1826;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.dashboard-page, body.login-page { background-image: none; }
}
@media (prefers-reduced-motion: reduce) {
  body.dashboard-page, body.login-page,
  .stealth-toggle span::after { animation: none; transition: none; }
}
@media (max-width: 980px) {
  body.is-editing .workspace { grid-template-columns: 1fr; }
  .catalog { max-height: none; }
}
@media (max-width: 900px) {
  .tile-grid { display: flex; flex-direction: column; }
  .tile { min-height: 168px; }
  body.is-editing .tile-resize { display: none; }
  body.is-editing .tile-nudge { display: inline-flex; }
  .tile[data-module="home.assistant"] { min-height: 70vh; }
  .topbar { flex-wrap: wrap; }
  .topbar-date { display: none; }
  .page-bar { align-items: stretch; flex-direction: column; }
  .edit-actions { flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .app { width: min(100% - 16px, 1440px); }
  .login-panel { padding: 22px; }
}

/* Stealth Aw Snap disguise */
html.stealth-snap-pending,
.login-page.stealth-snap-mode { color-scheme: light; }
html.stealth-snap-pending .login-shell {
  display: none;
}
html.stealth-snap-pending body.login-page,
.login-page.stealth-snap-mode {
  display: block;
  background: #fff;
  place-items: unset;
}
.login-page.stealth-snap-mode .login-shell {
  display: none;
}
html.stealth-snap-pending #stealth-snap[hidden] {
  display: block !important;
}
.stealth-snap {
  min-height: 100vh;
  box-sizing: border-box;
  padding: 14vh 48px 48px;
  background: #fff;
  color: #202124;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.stealth-snap[hidden] {
  display: none !important;
}
.stealth-snap-inner {
  max-width: 540px;
}
.stealth-snap-icon {
  display: block;
  margin: 0 0 28px;
}
.snap-eyes {
  transform-origin: 34px 48px;
}
.stealth-snap-icon.eyes-blink .snap-eyes {
  animation: snap-eye-blink 180ms ease-in-out 1;
}
@keyframes snap-eye-blink {
  0%, 100% { opacity: 1; transform: scaleY(1); }
  45%, 55% { opacity: 0; transform: scaleY(0.15); }
}
.stealth-snap-title {
  margin: 0 0 18px;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.2;
  color: #202124;
  letter-spacing: 0;
}
.stealth-snap-copy {
  margin: 0 0 36px;
  font-size: 15px;
  line-height: 1.5;
  color: #5f6368;
  font-weight: 400;
}
.stealth-snap-link {
  color: #1a73e8;
  font-size: 15px;
  text-decoration: none;
}
.stealth-snap-link:hover {
  text-decoration: underline;
}
.stealth-snap-form {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}
