:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-alt: #f7f9f8;
  --text: #17201d;
  --muted: #66736f;
  --line: #dfe6e2;
  --primary: #236b51;
  --primary-strong: #174d3b;
  --primary-soft: #dff2e9;
  --warning: #9a5d00;
  --warning-soft: #fff1d7;
  --danger: #a52c35;
  --danger-strong: #791d25;
  --danger-soft: #ffeaec;
  --info: #245d92;
  --info-soft: #e6f1fb;
  --shadow: 0 14px 36px rgb(31 52 45 / 7%);
  --radius: 16px;
  --focus: 0 0 0 3px rgb(35 107 81 / 25%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
dialog:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2vw, 1.85rem);
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
  padding: 0.8rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(16px);
}

.brand,
.topbar-actions,
.card-heading,
.section-heading,
.button-row,
.quota-meta,
.device-title,
.candidate-topline,
.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 0.75rem;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 0.6rem;
}

.eyebrow {
  margin-bottom: 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  width: min(1440px, 100%);
  margin-inline: auto;
  padding: 2rem clamp(1rem, 3vw, 2.5rem) 5rem;
}

.sidebar {
  position: sticky;
  top: 105px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar a {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}

.sidebar a:hover,
.sidebar a:focus-visible {
  background: var(--surface);
  color: var(--text);
}

main {
  min-width: 0;
}

section {
  scroll-margin-top: 100px;
  margin-bottom: 3.3rem;
}

.section-heading {
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.75fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.quota-unavailable {
  margin: 1rem 0 0;
  color: var(--danger);
  font-weight: 650;
}

.quota-card,
.control-card,
.schedule-card,
.audit-card,
.danger-card {
  padding: clamp(1rem, 2vw, 1.5rem);
}

.card-heading,
.quota-meta,
.device-title,
.candidate-topline {
  justify-content: space-between;
  gap: 0.75rem;
}

.quota-value {
  margin: 1rem 0 0.55rem;
  font-size: clamp(2.25rem, 6vw, 4.3rem);
  font-weight: 780;
  line-height: 1;
  letter-spacing: -0.05em;
}

.progress {
  overflow: hidden;
  height: 10px;
  margin: 0.8rem 0;
  border-radius: 999px;
  background: #e8eeeb;
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 250ms ease;
}

.quota-meta {
  flex-wrap: wrap;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.86rem;
}

.button-row {
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.3rem;
}

.button {
  min-height: 42px;
  padding: 0.62rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
}

.button-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.button-secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  border-color: #c7d1cc;
  background: var(--surface-alt);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--primary-strong);
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-strong);
}

.button-full {
  width: 100%;
}

.control-card {
  display: flex;
  flex-direction: column;
}

.control-card > .subtle {
  flex: 1;
  margin: 1rem 0;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(150px, 1fr);
  gap: 0.55rem 0.75rem;
  align-items: end;
  margin-top: 1rem;
}

.inline-form label {
  grid-column: 1 / -1;
  font-weight: 650;
}

.inline-form input {
  width: 100%;
}

.inline-form select {
  width: 100%;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.segmented-control button {
  min-height: 44px;
  border: 0;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.segmented-control button + button {
  border-left: 1px solid var(--line);
}

.segmented-control button:hover:not(:disabled) {
  background: var(--primary-soft);
}

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

.hint {
  margin: 0.9rem 0 0;
  font-size: 0.84rem;
}

.subtle {
  margin-bottom: 0;
  font-size: 0.88rem;
}

.status-pill,
.count-badge,
.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.status-ok {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.status-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-info {
  background: var(--info-soft);
  color: var(--info);
}

.status-muted,
.source-badge,
.count-badge {
  background: #e9eeec;
  color: #52605b;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.device-card {
  padding: 1.15rem;
}

.device-name {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.device-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}

.device-dot.online {
  background: #25885f;
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.device-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.device-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.device-details div {
  padding: 0.7rem;
  border-radius: 10px;
  background: var(--surface-alt);
}

.device-details dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.device-details dd {
  overflow: hidden;
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.candidate-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  padding: 1.15rem;
}

.candidate-info {
  min-width: 0;
}

.candidate-topline {
  justify-content: flex-start;
}

.candidate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.candidate-path {
  overflow-wrap: anywhere;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
}

.candidate-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.schedule-card {
  padding-bottom: 1rem;
}

.table-scroll {
  overflow-x: auto;
  margin: 0.7rem 0;
}

table {
  width: 100%;
  min-width: 570px;
  border-collapse: collapse;
}

th,
td {
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

td input[type="time"] {
  width: 100%;
  max-width: 160px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.switch input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--primary);
}

input,
select {
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  border: 1px solid #cbd5d0;
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
}

.audit-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.audit-item {
  display: grid;
  grid-template-columns: minmax(140px, 0.25fr) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}

.audit-item:last-child {
  border-bottom: 0;
}

.audit-time {
  color: var(--muted);
  font-size: 0.82rem;
}

.audit-title {
  margin: 0;
  font-weight: 700;
}

.audit-detail {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.danger-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  border-color: #e7b9bd;
  background: #fffafb;
}

.danger-card p {
  max-width: 720px;
  margin: 0.5rem 0 0;
  color: #76555a;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid;
  border-radius: 12px;
}

.banner p {
  margin: 0.2rem 0 0;
}

.banner-error {
  border-color: #e7b9bd;
  background: var(--danger-soft);
  color: var(--danger-strong);
}

.banner-warning {
  border-color: #e7c58d;
  background: var(--warning-soft);
  color: #704400;
}

.mode-banner {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-left: 6px solid var(--muted);
  border-radius: 12px;
  background: var(--surface);
}

.mode-banner.mode-audit {
  border-left-color: var(--warning);
  background: #fffcf5;
}

.mode-banner.mode-shadow {
  border-left-color: var(--info);
  background: #f8fcff;
}

.mode-banner.mode-enforcement {
  border-left-color: var(--primary);
  background: #f8fdfa;
}

.mode-banner.mode-disabled {
  border-left-color: var(--danger);
  background: #fffafb;
}

.mode-value {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.1;
}

.mode-description {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  padding: 1.4rem;
  color: var(--muted);
  text-align: center;
}

.skeleton-card {
  min-height: 165px;
  background:
    linear-gradient(90deg, transparent, rgb(255 255 255 / 70%), transparent),
    #e8eeeb;
  background-size: 220px 100%, 100% 100%;
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  from {
    background-position: -220px 0, 0 0;
  }
  to {
    background-position: calc(100% + 220px) 0, 0 0;
  }
}

.toast-region {
  position: fixed;
  z-index: 60;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  width: min(380px, calc(100% - 2rem));
  gap: 0.5rem;
}

.toast {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
}

dialog {
  width: min(500px, calc(100% - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 25px 80px rgb(0 0 0 / 24%);
}

dialog::backdrop {
  background: rgb(13 25 21 / 65%);
  backdrop-filter: blur(3px);
}

dialog form {
  display: grid;
  gap: 0.8rem;
  padding: 1.4rem;
}

.dialog-heading,
.dialog-actions {
  justify-content: space-between;
  gap: 0.75rem;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 0.6rem;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-alt);
}

.login-dialog form {
  padding: clamp(1.4rem, 5vw, 2.3rem);
}

.login-dialog h2 {
  margin-bottom: 0.2rem;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--surface);
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.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;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding-top: 1rem;
  }

  .sidebar {
    position: static;
    overflow-x: auto;
    flex-direction: row;
    padding-bottom: 0.3rem;
  }

  .sidebar a {
    flex: 0 0 auto;
  }

  .overview-grid,
  .quota-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form label {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .topbar-actions .status-pill {
    margin-right: auto;
  }

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

  .candidate-card,
  .audit-item {
    grid-template-columns: 1fr;
  }

  .candidate-actions {
    justify-content: flex-start;
  }

  .danger-card,
  .section-heading {
    align-items: flex-start;
  }

  .mode-banner {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .danger-card {
    flex-direction: column;
  }

  .danger-card .button {
    width: 100%;
  }

  .quota-meta {
    flex-direction: column;
    gap: 0.25rem;
  }
}

@media (max-width: 480px) {
  body {
    overflow-x: hidden;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
    min-height: auto;
    padding:
      max(0.7rem, env(safe-area-inset-top))
      max(0.75rem, env(safe-area-inset-right))
      0.7rem
      max(0.75rem, env(safe-area-inset-left));
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .brand h1 {
    font-size: 1.08rem;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    width: 100%;
    gap: 0.45rem;
  }

  .topbar-actions .status-pill {
    min-width: 0;
    margin-right: 0;
    padding-inline: 0.55rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-actions .button,
  .button,
  input,
  select {
    min-height: 44px;
  }

  input,
  select {
    font-size: 16px;
  }

  .shell {
    gap: 0.85rem;
    padding:
      0
      max(0.75rem, env(safe-area-inset-right))
      max(4.5rem, calc(3.5rem + env(safe-area-inset-bottom)))
      max(0.75rem, env(safe-area-inset-left));
  }

  .sidebar {
    position: sticky;
    z-index: 15;
    top: 0;
    gap: 0.2rem;
    margin-inline:
      calc(-1 * max(0.75rem, env(safe-area-inset-left)))
      calc(-1 * max(0.75rem, env(safe-area-inset-right)));
    padding:
      0.55rem
      max(0.75rem, env(safe-area-inset-right))
      0.55rem
      max(0.75rem, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: rgb(243 246 244 / 97%);
    backdrop-filter: blur(14px);
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .sidebar a {
    min-height: 42px;
    padding: 0.58rem 0.75rem;
    background: var(--surface);
    font-size: 0.88rem;
    white-space: nowrap;
  }

  main {
    padding-top: 0.25rem;
  }

  section {
    scroll-margin-top: 66px;
    margin-bottom: 2.25rem;
  }

  .section-heading,
  .banner,
  .card-heading,
  .device-title,
  .candidate-topline {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .section-heading {
    gap: 0.65rem;
    margin-bottom: 0.8rem;
  }

  .section-heading > .button {
    width: 100%;
  }

  .banner {
    flex-direction: column;
    padding: 0.85rem;
  }

  .banner .button {
    width: 100%;
  }

  .mode-banner,
  .quota-card,
  .control-card,
  .device-card,
  .candidate-card,
  .schedule-card,
  .audit-card,
  .danger-card {
    padding: 1rem;
  }

  .quota-value {
    margin-top: 0.85rem;
    font-size: clamp(2.35rem, 14vw, 3.7rem);
  }

  .button-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row .button {
    width: 100%;
  }

  .button-row .custom-grant-button {
    grid-column: 1 / -1;
  }

  .inline-form {
    gap: 0.45rem;
  }

  .segmented-control button {
    min-height: 46px;
  }

  .device-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .device-details div {
    min-width: 0;
    padding: 0.65rem;
  }

  .device-details dd {
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }

  .candidate-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .candidate-actions .button {
    width: 100%;
  }

  .candidate-actions .button-danger {
    grid-column: 1 / -1;
  }

  .table-scroll {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  table,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  #schedule-body {
    display: grid;
    gap: 0.75rem;
  }

  #schedule-body tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-alt);
  }

  #schedule-body th,
  #schedule-body td {
    padding: 0;
    border: 0;
  }

  #schedule-body th[scope="row"],
  #schedule-body .schedule-enabled,
  #schedule-body .schedule-actions {
    grid-column: 1 / -1;
  }

  #schedule-body th[scope="row"] {
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font-size: 0.94rem;
    letter-spacing: normal;
    text-transform: none;
  }

  #schedule-body td::before {
    display: block;
    margin-bottom: 0.28rem;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  #schedule-body .schedule-enabled::before {
    display: none;
  }

  #schedule-body .schedule-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  #schedule-body .schedule-actions::before {
    grid-column: 1 / -1;
    margin-bottom: -0.15rem;
  }

  #schedule-body .schedule-actions .button:only-child {
    grid-column: 1 / -1;
  }

  td input[type="time"] {
    max-width: none;
  }

  .audit-item {
    gap: 0.35rem;
    padding-block: 0.8rem;
  }

  .toast-region {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    width: auto;
    left: max(0.75rem, env(safe-area-inset-left));
  }

  dialog {
    width: calc(
      100% - max(1.5rem, calc(env(safe-area-inset-left) + env(safe-area-inset-right)))
    );
    max-height: calc(100dvh - max(1.5rem, env(safe-area-inset-top)) - max(1.5rem, env(safe-area-inset-bottom)));
    overflow: auto;
  }

  dialog form {
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-actions .button {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .topbar-actions,
  .device-details,
  .candidate-actions,
  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .candidate-actions .button-danger {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #87948e;
  }

  .button {
    border-width: 2px;
  }
}
