:root {
  --ink: #142033;
  --muted: #5a6e84;
  --line: #d7e2ea;
  --paper: rgba(255, 255, 255, 0.92);
  --accent: #0f766e;
  --accent-soft: #d7f3ef;
  --warn: #b54708;
  --warn-soft: #ffefd7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --good: #15803d;
  --good-soft: #d6f3df;
  --shadow: 0 20px 45px rgba(17, 24, 39, 0.08);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.15), transparent 40%),
    linear-gradient(180deg, #f7fbfd 0%, #edf4f7 100%);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }

.shell-header,
.shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 18px;
}

.shell-header {
  padding-top: 28px;
}

.shell {
  padding-bottom: 64px;
  display: grid;
  gap: 18px;
}

#dashboard {
  display: grid;
  gap: 18px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-top: 18px;
}

.shell .card,
#dashboard .card {
  margin-top: 0;
}

.hero h1 {
  margin: 8px 0 10px;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 0.98;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  font-weight: 700;
}

.lede, .subtle {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 600;
}

input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: white;
  color: var(--ink);
}

button {
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  padding: 11px 16px;
  font-weight: 700;
}

button.secondary {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.message {
  margin-top: 14px;
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: pre-wrap;
}

.message.error {
  background: var(--warn-soft);
  color: var(--warn);
}

.actions-banner {
  margin-top: 14px;
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--warn-soft);
  color: var(--warn);
}

.actions-banner .actions-heading {
  margin: 0 0 6px;
  font-weight: 700;
}

.actions-banner ul {
  margin: 0;
  padding-left: 18px;
}

/*
 * The HTML `hidden` attribute is supposed to evaluate to display:none
 * via the user-agent stylesheet, but any authored CSS rule that sets
 * `display` on the same element will win and the element becomes
 * visible. Bug surfaced after #223 shipped: .pending-state had
 * `display: grid`, so #claim-pending and #claim-resume rendered
 * *immediately* on Add-a-kit click instead of staying hidden until
 * the JS chose which sub-state to show. The single rule below
 * restores the expected meaning for every [hidden] element on the
 * page; do not delete without replacing.
 */
[hidden] { display: none !important; }

.pending-state {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.pending-state .pending-heading {
  margin: 0;
  font-weight: 700;
  color: var(--accent);
}

.pending-state p {
  margin: 0;
}

.pending-state a {
  color: var(--accent);
}

/* My Boxes */

.device-list,
.peer-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.device-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.device-main {
  display: grid;
  gap: 4px;
}

.device-name {
  margin: 0;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.online { background: var(--good); }
.status-dot.offline { background: var(--line); border: 1px solid #b5c2cf; }

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-kit {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.badge-attention {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
  text-transform: none;
  letter-spacing: 0;
}

/* Update-available badge on the overview device cards. Distinct from
   badge-attention: an available update is informational, not an
   incident; render in the accent palette so it reads as "do this
   when convenient" instead of "fix this now." */
.badge-update {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  text-transform: none;
  letter-spacing: 0;
}

/* Update CTA on the device detail page. Sits below the summary
   list; primary-button styling matches the action buttons in the
   account/auth flows. */
.device-update-action,
.device-local-ui-action,
.device-detail-release {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-update-action .primary-button {
  align-self: flex-start;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}

.device-update-action .primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.device-detail-release .danger-button {
  align-self: flex-start;
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}

.device-detail-release .danger-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.device-local-ui-action .secondary-button {
  align-self: flex-start;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  text-decoration: none;
}

.device-update-note,
.device-local-ui-note,
.device-release-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Connected Homes */

.connected-section {
  margin-top: 16px;
}

.connected-section h3 {
  margin: 0 0 4px;
  font-size: 0.94rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.peer-row {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  display: grid;
  gap: 4px;
}

.peer-label {
  margin: 0;
  font-weight: 700;
}

.peer-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Clickable rows in My Boxes */

.device-row-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.05s ease;
}

.device-row-clickable:hover {
  border-color: var(--accent);
}

.device-row-clickable:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.device-row-clickable:active {
  transform: scale(0.998);
}

/* Device detail screen */

/*
 * Scope `display: grid` to the visible state. The repo-wide
 * `[hidden] { display: none !important; }` rule (line ~170) already
 * wins via !important, but the :not([hidden]) scoping here is
 * defense in depth — if someone removes the !important rule in the
 * future, this section still won't render until the JS makes it
 * visible. Same pattern is worth applying to any future hidden
 * card whose layout is `display: grid|flex|…`.
 */
#device-detail:not([hidden]) {
  display: grid;
  gap: 16px;
}

.device-detail-back-row {
  margin: 0;
}

.device-detail-back {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
}

.device-detail-back:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.device-detail-heading {
  margin: 0;
}

.device-detail-attention {
  margin-top: 0;
}

.device-detail-section {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.device-detail-section h3 {
  margin: 0 0 4px;
  font-size: 0.94rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.device-detail-dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 8px 16px;
}

.device-detail-dl dt {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.device-detail-dl dd {
  margin: 0;
  color: var(--ink);
}

.device-detail-kit-mate {
  margin: 0;
  color: var(--ink);
}
