:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #18243b;
  background: #f3f6fc;
  font-size: 16px;
  --primary: #20357a;
  --secondary: #648ee1;
  --primary-hover: #172961;
  --text-muted: #53617a;
  --line: #dce4f1;
  --surface: #fff;
  --blue-tint: #eef3fd;
  --shadow: 0 5px 18px rgb(32 53 122 / .05);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
.shell { width: min(100%, 74rem); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.75rem); }
main { padding-block: 1.5rem 5rem; }
.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: .25rem 1rem; flex-wrap: wrap; padding-block: .45rem; }
.brand, .account-bar { display: flex; align-items: center; gap: 1rem; }
.brand-logo { position: relative; display: block; width: 118px; height: 64px; overflow: hidden; }
.brand-logo img { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); }
.product { border-left: 1px solid var(--line); padding-left: 1rem; color: var(--primary); font-weight: 650; }
.account-bar { min-width: 0; justify-content: flex-end; color: var(--text-muted); font-size: .875rem; }
#signed-in { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
#sign-out { flex: none; }

h1, h2 { color: var(--primary); line-height: 1.15; letter-spacing: -.035em; }
h1 { font-size: clamp(1.65rem, 4vw, 2.1rem); margin: 0 0 1.25rem; font-weight: 720; }
h2 { font-size: 1.35rem; margin: 0 0 1rem; }
p { line-height: 1.55; }
.muted { color: var(--text-muted); }
a { color: var(--primary); }
label { display: block; font-size: .875rem; font-weight: 650; margin-bottom: .45rem; }
form { margin: 0; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
input, select, button { font: inherit; }
input, select {
  color: inherit;
  background: var(--surface);
  border: 1px solid #b8c6dd;
  border-radius: .5rem;
  min-height: 2.5rem;
  padding: .55rem .75rem;
  min-width: 0;
}
input { flex: 1; }
input::placeholder { color: var(--text-muted); }
button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 2.5rem;
  padding: .55rem .9rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  background: var(--primary);
  color: #fff;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
button:hover:not(:disabled) { background: var(--primary-hover); }
button:active:not(:disabled) { background: #132151; }
button:disabled { color: #53617a; background: #edf0f6; cursor: default; }
button.secondary, button.quiet { color: var(--primary); background: transparent; }
button.secondary { border-color: #b8c6dd; }
button.secondary:hover:not(:disabled), button.quiet:hover:not(:disabled) { background: var(--blue-tint); }
button.secondary:disabled { color: var(--text-muted); border-color: var(--line); }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 3px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.surface, .welcome {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .85rem;
  box-shadow: var(--shadow);
}
.welcome { max-width: 31rem; margin: clamp(1rem, 10vh, 5rem) auto 0; padding: clamp(1.25rem, 4vw, 2.25rem); }
#login { border-top: 3px solid var(--secondary); }
#portal-login { width: 100%; min-height: 2.875rem; }
#sign-in { display: grid; gap: .6rem; max-width: 25rem; }
#sign-in label { margin-bottom: 0; }
#sign-in button { justify-self: start; margin-top: .35rem; }

.panel-nav {
  display: flex;
  gap: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.75rem;
}
.panel-nav button, .panel-nav button.secondary {
  border: 0;
  border-radius: .4rem .4rem 0 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  background: transparent;
  padding: .5rem .65rem;
}
.panel-nav button[aria-pressed="true"] { color: var(--primary); border-bottom-color: var(--secondary); }
.panel-nav button:hover:not(:disabled) { background: var(--blue-tint); color: var(--primary); }
.section-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1.15rem; }
.section-heading h1 { margin: 0; }
.invitation-panel { padding: 1rem 1.15rem; margin-bottom: 1rem; }
#invitation { margin-top: .85rem; }
#link { min-width: min(100%, 15rem); }

.device-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .65rem 1rem;
  padding: .85rem 1rem;
}
.device-filters { display: flex; gap: .2rem; flex-wrap: wrap; }
.device-filters button {
  background: transparent;
  color: var(--text-muted);
  padding-inline: .65rem;
  gap: .4rem;
  min-height: 2.25rem;
  font-size: .8125rem;
}
.device-filters button:hover:not(:disabled) { background: var(--blue-tint); color: var(--primary); }
.device-filters button[aria-pressed="true"] { background: var(--blue-tint); color: var(--primary); border-color: #c9d7f5; }
.filter-count { color: inherit; opacity: .85; font-size: .75rem; font-variant-numeric: tabular-nums; }
.filter-count:empty { display: none; }
.device-view-options { display: flex; flex: 1 1 24rem; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.device-view-options:has(#device-group-filter[hidden]) { flex-basis: 12rem; }
#device-group-filter { max-width: min(100%, 13rem); font-size: .875rem; text-overflow: ellipsis; }
.device-search { flex: 1 1 11rem; max-width: 17rem; }
.device-search input { width: 100%; font-size: .875rem; }

.device-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(8rem, .4fr) 14rem; align-items: center; gap: .75rem; padding-inline: 1rem; }
.device-columns { min-height: 2.25rem; border-block: 1px solid var(--line); color: var(--text-muted); background: #f7f9fd; font-size: .75rem; font-weight: 650; }
.device-columns :last-child { text-align: right; }
.device-group-title {
  margin: 0;
  padding: .55rem 1rem;
  background: var(--blue-tint);
  color: var(--primary);
  font-size: .875rem;
  font-weight: 650;
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
.device-row { min-height: 4.4rem; padding-block: .75rem; }
.device-row + .device-row { border-top: 1px solid var(--line); }
.device-row:hover { background: #fafbff; }
.device-row:last-child { border-radius: 0 0 .85rem .85rem; }
.device-identity { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.device-identity > div { min-width: 0; }
.device-name, .device-details { display: block; overflow-wrap: anywhere; }
.device-name { font-weight: 660; line-height: 1.3; }
.device-details { margin-top: .2rem; color: var(--text-muted); font-size: .8125rem; line-height: 1.35; }
.device-icon { flex: 0 0 2.25rem; height: 2.25rem; position: relative; border-radius: .5rem; background: var(--blue-tint); color: var(--primary); }
.device-icon::before {
  content: "";
  position: absolute;
  inset: .6rem .55rem .75rem;
  border: 1.5px solid currentColor;
  border-radius: .14rem;
}
.device-icon::after {
  content: "";
  position: absolute;
  inset: auto .82rem .51rem;
  border-bottom: 1.5px solid currentColor;
}
.device-status, .history-state {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border-radius: .35rem;
  padding: .35rem .5rem;
  font-size: .75rem;
  font-weight: 650;
  line-height: 1.25;
  color: #4d5a71;
  background: #edf0f6;
}
.device-status::before {
  content: "";
  width: .4rem;
  height: .4rem;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
[data-state="available"] .device-status, .history-state[data-state="ended"] { color: #12613e; background: #e7f5ed; }
[data-state="connected"] .device-status, .history-state[data-state="active"] { color: var(--primary); background: #e8efff; }
.history-state[data-state="lost"], .history-state[data-state="unconfirmed"] { color: #784613; background: #fdf2e4; }
.device-actions { justify-content: flex-end; flex-wrap: nowrap; }
.device-actions button { font-size: .8125rem; }
.device-actions .quiet { padding-inline: .55rem; }
.device-actions .connect { min-width: 6.75rem; }
.empty-state { margin: 0; padding: 2rem 1rem; border-top: 1px solid var(--line); text-align: center; color: var(--text-muted); }

.history-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; }
.history-row + .history-row { border-top: 1px solid var(--line); }
.history-row span:not(.history-state) { display: block; margin-top: .25rem; color: var(--text-muted); font-size: .8125rem; overflow-wrap: anywhere; }
.history-row .history-state { flex: none; }
.history-pages { justify-content: flex-end; margin-top: .75rem; }

details { color: var(--text-muted); }
summary { cursor: pointer; color: var(--primary); font-weight: 650; }
#guest { max-width: 43rem; }
#downloads { display: flex; gap: .5rem; flex-wrap: wrap; list-style: none; padding: 0; }
#downloads a { display: block; padding: .6rem .75rem; border-radius: .5rem; background: var(--blue-tint); font-weight: 650; text-decoration: none; }
#downloads a:hover { text-decoration: underline; }

dialog { width: min(28rem, calc(100% - 2rem)); border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); color: inherit; padding: 1.25rem; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(18 31 67 / .42); }
dialog input, dialog select { width: 100%; }
dialog input + label { margin-top: .8rem; }
.dialog-error:not(:empty) { color: #8c2e35; }
.dialog-error { min-height: .5rem; margin: .25rem 0 .65rem; }
#status {
  position: fixed;
  bottom: 1.25rem;
  right: clamp(1rem, 4vw, 2rem);
  max-width: min(30rem, calc(100% - 2rem));
  margin: 0;
}
#status:not(:empty) { padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--secondary); border-radius: .5rem; color: var(--primary); box-shadow: var(--shadow); }

@media (max-width: 640px) {
  main { padding-top: 1rem; }
  .account-bar { gap: .3rem; }
  #signed-in { max-width: 24ch; }
  .device-toolbar { align-items: stretch; }
  .device-view-options { justify-content: flex-start; }
  .device-search { max-width: none; }
  .device-columns { display: none; }
  .device-row { grid-template-columns: minmax(0, 1fr) auto; padding-inline: .85rem; }
  .device-row:nth-child(2) { border-top: 1px solid var(--line); }
  .device-actions { grid-column: 1 / -1; }
}
@media (max-width: 440px) {
  .masthead-inner { padding-bottom: .35rem; }
  .account-bar { width: 100%; justify-content: space-between; }
  .section-heading { align-items: flex-start; }
  .device-icon { display: none; }
  .device-filters { column-gap: .1rem; }
  .device-filters button { padding-inline: .45rem; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
}
