/* Shared status indicators */
.status-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status--ok {
  background-color: #e6f9ed;
  color: #176437;
}

.status--warning {
  background-color: #fff4d6;
  color: #8a6100;
}

.status--danger {
  background-color: #fde2e1;
  color: #a12424;
}

.status--muted {
  background-color: #eef1f5;
  color: #4f5d75;
}

.text-danger {
  color: #c00;
}

.table-align-middle td,
.table-align-middle th {
  vertical-align: middle;
}

.table-align-top td,
.table-align-top th {
  vertical-align: top;
}

/* Buttons */
.btn-danger {
  background: #c81e1e;
  border-color: #a81616;
  color: #fff;
}

.btn-danger:hover,
.btn-danger:focus {
  background: #a81616;
  border-color: #861010;
}

.btn-delete {
  background-color: #c00;
  color: #fff;
}

.btn-delete:hover,
.btn-delete:focus {
  background-color: #9b0000;
  color: #fff;
}

.btn-reissue {
  background-color: #176437;
  color: #fff;
}

.btn-reissue:hover,
.btn-reissue:focus {
  background-color: #0f4f2e;
  color: #fff;
}

/* Admin users */
.admin-users-create {
  margin-bottom: 1rem;
}

.admin-users-create summary {
  width: fit-content;
}

.admin-users,
.admin-users-table-wrap,
.admin-users-table {
  max-width: 100%;
}

.admin-users-table {
  width: 100%;
  table-layout: auto;
}

.admin-users-table th,
.admin-users-table td {
  text-align: left;
}

.admin-users-email-cell {
  overflow-wrap: anywhere;
}

.admin-users td form {
  margin: 0;
}

.admin-users .admin-users-actions button {
  width: auto;
  margin: 0;
}

.admin-users-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

/* Admin devices registry */
.admin-devices {
  max-width: 100%;
  --admin-device-cell-padding-y: 0.62rem;
  --admin-device-control-height: 2.55rem;
  --admin-device-form-gap: 0.15rem;
}

.admin-devices > form,
.admin-devices-table-wrap,
.admin-devices-table {
  max-width: 100%;
}

.admin-devices > form button {
  max-width: 100%;
  white-space: normal;
}

.admin-devices-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.admin-devices-table th,
.admin-devices-table td {
  min-width: 0;
  padding: var(--admin-device-cell-padding-y) 0.45rem;
  vertical-align: middle;
  text-align: left;
  overflow-wrap: anywhere;
}

.admin-devices-table tbody tr {
  transition: background-color 0.15s ease;
}

.admin-devices-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.035);
}

.admin-devices-table code,
.admin-devices-table small {
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-devices .device-id-cell code {
  display: inline-block;
  max-width: 100%;
  padding: 0.28rem 0.45rem;
  border-radius: 0.35rem;
  background: rgba(148, 163, 184, 0.14);
  line-height: 1.25;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-devices .date-cell {
  overflow-wrap: normal;
  white-space: normal;
}

.admin-devices .date-stamp {
  display: inline-flex;
  max-width: 100%;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.admin-devices .date-stamp__date,
.admin-devices .date-stamp__time {
  display: block;
  white-space: nowrap;
}

.admin-devices .date-stamp__date {
  font-size: 0.88rem;
}

.admin-devices .date-stamp__time {
  color: #6b7280;
  font-size: 0.78rem;
}

.admin-devices .date-cell small,
.admin-devices .status-cell small {
  display: block;
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.78rem;
  line-height: 1.3;
}

.admin-devices .ca-cell code {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}

.admin-devices .status-pill {
  max-width: 100%;
  padding: 0.12rem 0.42rem;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  vertical-align: middle;
}

.admin-devices .danger-cell form,
.admin-devices .bundle-cell form {
  display: flex;
  justify-content: center;
  margin: var(--admin-device-form-gap) 0;
}

.admin-devices .danger-cell button,
.admin-devices .bundle-cell button,
.admin-devices .actions-cell a {
  margin: 0;
}

.admin-devices .danger-cell form button,
.admin-devices .bundle-cell form button {
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.admin-devices .danger-cell form button {
  width: 10.5rem;
}

.admin-devices .bundle-cell form button {
  min-width: 7.75rem;
  white-space: nowrap;
  overflow-wrap: normal;
}

.admin-devices .actions-cell {
  min-width: 0;
}

.admin-devices .actions-cell a {
  display: inline-flex;
  width: auto;
  min-width: 7.75rem;
  max-width: 100%;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.admin-devices .bundle-cell form button,
.admin-devices .actions-cell a {
  height: var(--admin-device-control-height);
  line-height: 1.15;
}

@media (min-width: 1180px) {
  .admin-devices .bundle-cell form + form {
    margin-top: calc(var(--admin-device-form-gap) + 1.1rem);
  }

  .admin-devices .admin-devices-table th:nth-child(1) {
    width: 8%;
  }

  .admin-devices .admin-devices-table th:nth-child(2) {
    width: 14%;
  }

  .admin-devices .admin-devices-table th:nth-child(3),
  .admin-devices .admin-devices-table th:nth-child(4) {
    width: 9%;
  }

  .admin-devices .admin-devices-table th:nth-child(5) {
    width: 7%;
  }

  .admin-devices .admin-devices-table th:nth-child(6) {
    width: 12%;
  }

  .admin-devices .admin-devices-table th:nth-child(7) {
    width: 12%;
  }

  .admin-devices .admin-devices-table th:nth-child(8) {
    width: 13%;
  }

  .admin-devices .admin-devices-table th:nth-child(9) {
    width: 17%;
  }
}

/* Software administration tables */
.admin-software .admin-devices-table {
  table-layout: auto;
}

.admin-software .admin-devices-table th,
.admin-software .admin-devices-table td {
  text-align: left;
  overflow-wrap: normal;
}

.admin-software .admin-devices-table-wrap {
  overflow-x: auto;
}

.admin-software .software-releases-table {
  width: 100%;
  table-layout: fixed;
}

.admin-software .software-release-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.admin-software .software-release-actions form {
  margin: 0;
}

.admin-software .software-release-actions button {
  width: auto;
  margin: 0;
  white-space: nowrap;
}

.admin-software .software-devices-table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  font-size: 0.92rem;
}

.admin-software .software-devices-table th,
.admin-software .software-devices-table td {
  padding: 0.5rem 0.35rem;
}

.admin-software .software-devices-table th {
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.admin-software .software-devices-table .device-id-cell code {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-software .software-devices-table .installed-version-cell,
.admin-software .software-devices-table .installed-release-cell {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-software .software-devices-table .installed-release-cell code {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-software .software-devices-table .status-pill {
  max-width: 100%;
  white-space: nowrap;
}

.admin-software .software-devices-table .update-status-cell .status-pill {
  min-width: 6.75rem;
  box-sizing: border-box;
  text-align: center;
}

.admin-software .software-devices-table .timestamp-cell {
  white-space: normal;
  overflow-wrap: normal;
}

.admin-software .software-devices-table .error-cell {
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-devices .bundle-cell small,
.admin-devices .danger-cell small {
  display: block;
  margin-top: 0.2rem;
  color: #5f5f5f;
}

@media (max-width: 1179px) {
  .admin-devices-table-wrap {
    overflow: visible;
  }

  .admin-devices-table,
  .admin-devices-table tbody,
  .admin-devices-table tr,
  .admin-devices-table td {
    display: block;
  }

  .admin-devices-table {
    border: 0;
  }

  .admin-devices-table thead {
    display: none;
  }

  .admin-devices-table tr {
    padding: 0.75rem;
    border: 1px solid #dfe3e6;
    border-radius: 0.5rem;
    background: #fff;
  }

  .admin-devices-table tr + tr {
    margin-top: 0.75rem;
  }

  .admin-devices-table td {
    display: grid;
    grid-template-columns: minmax(7.5rem, 34%) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: center;
    justify-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #edf0f2;
  }

  .admin-devices-table td:last-child {
    border-bottom: 0;
  }

  .admin-devices-table td::before {
    content: attr(data-label);
    color: #4f5d75;
    font-size: 0.85rem;
    font-weight: 600;
  }

  .admin-devices .bundle-cell form:first-child,
  .admin-devices .danger-cell form:first-child,
  .admin-devices .actions-cell a:first-child {
    margin-top: 0;
  }
}

@media (max-width: 560px) {
  .admin-devices-table td {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .admin-devices-table td::before {
    font-size: 0.78rem;
    text-transform: uppercase;
  }
}

@media (max-width: 1179px) {
  .admin-software .software-releases-table,
  .admin-software .software-devices-table {
    min-width: 0;
  }

  .admin-software .admin-devices-table td {
    justify-items: start;
    text-align: left;
  }

  .admin-software .software-devices-table .device-id-cell,
  .admin-software .software-devices-table .installed-version-cell,
  .admin-software .software-devices-table .installed-release-cell,
  .admin-software .software-devices-table .timestamp-cell,
  .admin-software .software-devices-table .error-cell {
    width: auto;
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 1179px) {
  .admin-users-table {
    min-width: 0;
  }

  .admin-users .admin-devices-table td {
    justify-items: start;
    text-align: left;
  }

  .admin-users-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .admin-users-create summary,
  .admin-users-create button[type="submit"] {
    width: 100%;
  }

  .admin-users-create .grid {
    grid-template-columns: 1fr;
  }

  .admin-users-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .admin-users-actions form,
  .admin-users .admin-users-actions button {
    width: 100%;
  }
}

/* Dashboard panels */
.telemetry-panel {
  border: 1px solid #dfe3e6;
  border-radius: 0.5rem;
  padding: 1rem;
  margin: 1rem 0;
  background: #fff;
}

.dashboard-panel {
  overflow: hidden;
}

.dashboard-panel.has-open-popover {
  overflow: visible;
}

.dashboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #edf0f2;
}

.telemetry-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.dashboard-command-controls {
  flex: 1 1 22rem;
  margin-bottom: 0;
}

.dashboard-tab-list,
.config-tab-list {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.dashboard-tab-button {
  width: auto;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid #cfd5e2;
  border-radius: 0.35rem;
  background: #f8fafb;
  color: #2f3a45;
  line-height: 1.2;
}

.dashboard-tab-button:hover,
.dashboard-tab-button:focus {
  border-color: #8a97a8;
  background: #eef2f5;
  color: #1f2933;
}

.dashboard-tab-button[aria-selected="true"] {
  border-color: #0172ad;
  background: #0172ad;
  color: #fff;
}

.dashboard-tab-panel[hidden],
.config-group[hidden] {
  display: none;
}

.dashboard-placeholder {
  padding: 1rem;
  border: 1px dashed #cfd5e2;
  border-radius: 0.5rem;
  background: #f8fafb;
  color: #4f5d75;
}

.dashboard-placeholder h3,
.dashboard-placeholder p {
  margin-bottom: 0.35rem;
}

.data-panel-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.data-panel-header h3 {
  margin: 0;
}

.data-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.data-controls button {
  width: auto;
  margin: 0 0 0.15rem;
  white-space: nowrap;
}

.data-date-picker {
  position: relative;
}

.data-date-picker > button {
  min-width: 13rem;
}

.data-calendar-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 20;
  width: min(92vw, 22rem);
  padding: 0.75rem;
  border: 1px solid #d8dee6;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.data-calendar-header,
.data-calendar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.data-calendar-header {
  margin-bottom: 0.6rem;
}

.data-calendar-header strong {
  color: #243244;
  font-size: 0.95rem;
}

.data-calendar-header button,
.data-calendar-actions button {
  margin: 0;
  padding: 0.35rem 0.55rem;
}

.data-calendar-weekdays,
.data-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}

.data-calendar-weekdays {
  margin-bottom: 0.25rem;
  color: #64748b;
  font-size: 0.72rem;
  text-align: center;
}

.data-calendar-day {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  background: #f8fafc;
  color: #334155;
  font-size: 0.85rem;
}

.data-calendar-day:hover:not(:disabled),
.data-calendar-day:focus-visible:not(:disabled) {
  border-color: #0172ad;
}

.data-calendar-day.is-selected,
.data-calendar-day.is-range {
  border-color: #0172ad;
  background: #e7f2f8;
  color: #0f4f78;
}

.data-calendar-day.is-selected {
  background: #0172ad;
  color: #fff;
}

.data-calendar-day:disabled {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

.data-calendar-day.is-empty {
  visibility: hidden;
}

.data-calendar-actions {
  margin-top: 0.75rem;
}

.data-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.data-chart-card {
  position: relative;
  border: 1px solid #e4e7eb;
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: #fff;
  cursor: zoom-in;
}

.data-chart-card:focus-visible {
  outline: 3px solid #9ec5fe;
  outline-offset: 2px;
}

.data-chart-card header {
  margin-bottom: 0.45rem;
  color: #4f5d75;
  font-size: 0.92rem;
  font-weight: 600;
}

.data-chart-card canvas {
  display: block;
  width: 100%;
  height: 250px;
}

.simple-chart-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 9.5rem;
  max-width: 15rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #d8dee6;
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  color: #334155;
  font-size: 0.78rem;
  line-height: 1.35;
  pointer-events: none;
}

.simple-chart-tooltip strong,
.simple-chart-tooltip span {
  display: block;
}

.data-chart-dialog {
  width: min(94vw, 1100px);
  max-width: 1100px;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
}

.data-chart-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.data-chart-dialog-inner {
  padding: 1rem;
  background: #fff;
}

.data-chart-dialog-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.data-chart-dialog-header h3,
.data-chart-dialog-header button {
  margin: 0;
}

.data-chart-dialog-body {
  position: relative;
}

.data-chart-dialog-body canvas {
  display: block;
  width: 100%;
  height: min(68vh, 620px);
  min-height: 360px;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.telemetry-card {
  border: 1px solid #e4e7eb;
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: #fff;
}

.telemetry-card header {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: #4f5d75;
}

.telemetry-value {
  font-size: 1.2rem;
  margin: 0;
}

.telemetry-status-message {
  font-size: 0.9rem;
  color: #4f5d75;
}

.telemetry-status-message.error {
  color: #a12424;
}

.telemetry-status-message.warning {
  color: #8a6100;
}

.telemetry-meta {
  font-size: 0.85rem;
  color: #4f5d75;
}

.admin-device-dashboard .telemetry-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.device-overview .telemetry-panel {
  margin-top: 1rem;
  margin-bottom: 0;
  background: #fefefe;
}

.device-overview .telemetry-value {
  font-size: 1.4rem;
}

/* Machine visualization */
.machine-visual-panel h3 {
  margin-bottom: 0.75rem;
}

.machine-visual-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 1rem;
  align-items: stretch;
}

.machine-visual-scene {
  margin: 0;
  overflow: hidden;
  border: 1px solid #d5dde5;
  border-radius: 0.5rem;
  background:
    linear-gradient(180deg, rgba(247, 250, 252, 0.92), rgba(247, 250, 252, 0) 42%),
    linear-gradient(135deg, #eef3f6 0%, #d2dde4 52%, #b6c4cf 100%);
}

.machine-visual-stage {
  position: relative;
  min-height: clamp(260px, 38vw, 430px);
  height: clamp(260px, 38vw, 430px);
  overflow: hidden;
  isolation: isolate;
}

.machine-visual-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.machine-visual-tooltip {
  position: absolute;
  z-index: 2;
  max-width: min(18rem, calc(100% - 1rem));
  padding: 0.4rem 0.55rem;
  border-radius: 0.35rem;
  background: rgba(22, 30, 38, 0.92);
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: pre-line;
  pointer-events: none;
  box-shadow: 0 0.35rem 1rem rgba(15, 23, 42, 0.22);
}

.machine-visual-tooltip[hidden] {
  display: none;
}

.machine-visual-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1rem;
  color: #4f5d75;
  text-align: center;
}

.machine-visual-stage.is-rendered .machine-visual-fallback {
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.lease-state-panel {
  border: 1px solid #d5dde5;
  border-radius: 0.5rem;
  padding: 0.9rem;
  background: #f8fafc;
}

.lease-state-panel h3 {
  margin-top: 0;
}

.lease-state-list {
  display: grid;
  gap: 0.7rem;
  margin: 0;
}

.lease-state-list div {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: baseline;
}

.lease-state-list dt {
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 600;
}

.lease-state-list dd {
  margin: 0;
  color: #0f172a;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.lease-state-messages {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.45rem;
}

.lease-state-messages[hidden] {
  display: none;
}

.lease-state-message {
  border-left: 3px solid #2563eb;
  padding: 0.45rem 0.6rem;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .machine-visual-layout {
    grid-template-columns: 1fr;
  }

  .machine-visual-stage {
    min-height: 250px;
    height: 250px;
  }
}

.console-terminal {
  min-height: 320px;
  background: #000;
  color: #e5e7eb;
}

/* Configuration editor */
.config-panel h3 {
  margin-bottom: 0.25rem;
}

.config-tabs {
  margin-top: 0.75rem;
}

.config-tab-list {
  padding-bottom: 0.75rem;
  margin-top: 0.75rem;
  border-bottom: 1px solid #edf0f2;
}

.config-tab-list .dashboard-tab-button {
  padding: 0.4rem 0.65rem;
  font-size: 0.95rem;
}

.config-group {
  margin-top: 1rem;
}

.config-group h4 {
  margin-bottom: 0.5rem;
}

.config-general {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1rem;
  align-items: start;
}

.config-general-heading {
  grid-column: 1 / -1;
  margin: 0;
}

.config-general-container {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  padding: 1rem;
  border: 1px solid #e1e6ea;
  border-radius: 0.5rem;
  background: #fff;
}

.config-general-container + .config-general-container {
  margin-top: 0;
}

.config-group--disabled {
  opacity: 0.58;
}

.config-group--disabled input,
.config-group--disabled select,
.config-group--disabled button {
  cursor: not-allowed;
}

.config-general-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, 1.2fr) minmax(180px, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid #edf0f2;
}

.config-general-container .config-general-row:first-child,
.config-general-row--header {
  border-top: 0;
  padding-top: 0;
}

.config-general-card-header {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title status"
    "actions actions";
  gap: 0.75rem;
  align-items: start;
  padding: 0;
}

.config-general-title {
  grid-area: title;
  color: #243244;
  font-size: 1.05rem;
  line-height: 1.25;
}

.config-general-card-header .config-general-actions {
  grid-area: actions;
}

.config-general-card-header .config-status-line {
  grid-area: status;
  justify-self: end;
}

.config-general-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.config-general-actions button {
  width: auto;
  margin: 0;
  min-height: 2.35rem;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.manual-command-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding-top: 0.85rem;
  border-top: 1px solid #edf0f2;
}

.manual-command-actions button {
  width: auto;
  margin: 0;
}

.manual-command-status {
  min-width: 8rem;
}

.config-netatmo {
  margin-top: 0.85rem;
}

.config-netatmo-selection {
  padding-left: 0;
}

.config-openweather {
  margin-top: 0.85rem;
}

.config-openweather-location-control {
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.config-general .config-row {
  grid-template-columns: 1fr;
  gap: 0.4rem;
  padding: 0.65rem 0 0;
}

.config-general .config-row .config-control {
  width: 100%;
}

.config-general .config-row-status:empty {
  display: none;
}

.config-general .openweather-location-preview {
  width: 100%;
}

.config-openweather-location-control [data-openweather-location] {
  display: block;
  max-width: 100%;
  color: #4f5d75;
  overflow-wrap: anywhere;
}

.openweather-location-preview {
  width: min(100%, 280px);
  aspect-ratio: 16 / 10;
  border: 1px solid #cfd8df;
  border-radius: 0.35rem;
  overflow: hidden;
  background: #eef3f6;
  cursor: zoom-in;
}

.openweather-location-preview:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}

.openweather-map-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 18, 31, 0.55);
}

.openweather-map-dialog {
  width: min(960px, 100%);
  max-height: min(760px, 94vh);
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  gap: 0.75rem;
  padding: 0.9rem;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 20px 60px rgba(9, 24, 43, 0.3);
}

.openweather-map-dialog--readonly {
  grid-template-rows: minmax(320px, 1fr) auto;
}

.openweather-map-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  margin: 0;
}

.openweather-map-body {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 0.75rem;
  min-height: 320px;
}

.openweather-map-body--readonly {
  grid-template-columns: minmax(0, 1fr);
}

.openweather-map-results {
  overflow-y: auto;
  border: 1px solid #e1e6ea;
  border-radius: 0.35rem;
  padding: 0.5rem;
}

.openweather-map-result {
  width: 100%;
  margin: 0 0 0.4rem;
  text-align: left;
}

.openweather-map {
  min-height: 320px;
  border: 1px solid #cfd8df;
  border-radius: 0.35rem;
  overflow: hidden;
}

.openweather-map-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.config-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(120px, 240px) minmax(180px, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-top: 1px solid #edf0f2;
}

.config-label {
  margin: 0;
  font-weight: 600;
  min-width: 0;
}

.config-label-title,
.config-key {
  display: block;
}

.config-key {
  margin-top: 0.15rem;
  color: #667085;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.config-control {
  display: flex;
  align-items: center;
  min-width: 0;
}

.config-control input,
.config-control select {
  margin: 0;
}

.config-control input:not([type="checkbox"]),
.config-control select {
  width: 100%;
}

.config-control input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  flex: 0 0 auto;
}

.config-row-status {
  color: #4f5d75;
  min-width: 0;
  overflow-wrap: anywhere;
}

.config-row-status.warning {
  color: #8a6100;
}

.config-row-status.error {
  color: #a12424;
}

.config-row-advisory {
  grid-column: 2 / -1;
  margin: -0.35rem 0 0;
}

.config-status-line {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  color: #4f5d75;
  font-size: 0.9rem;
  justify-self: start;
  white-space: nowrap;
}

.config-status-line[hidden] {
  display: none;
}

.config-status-label {
  font-weight: 600;
}

.config-row.is-pending {
  opacity: 0.75;
}

.config-row--full {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.scheduled-cleaning-row {
  gap: 0.65rem;
  padding: 0.55rem 0 0.9rem;
  overflow: visible;
}

.scheduled-cleaning-header,
.scheduled-cleaning-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
}

.scheduled-cleaning-title {
  color: inherit;
}

.scheduled-action-enabled {
  color: #344054;
  font-weight: 600;
}

.scheduled-cleaning-actions button,
.scheduled-action-delete {
  width: auto;
  margin: 0;
  min-height: 2.25rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.95rem;
}

.scheduled-action-list {
  display: grid;
  gap: 0.7rem;
}

.scheduled-action {
  --scheduled-action-control-height: calc(
    1rem * var(--pico-line-height) +
    var(--pico-form-element-spacing-vertical) * 2 +
    var(--pico-border-width) * 2
  );
  display: grid;
  gap: 0.55rem;
  padding: 0.7rem 0 0;
  border-top: 1px solid #e5eaf0;
  background: transparent;
}

.scheduled-action-enabled {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  align-self: end;
  grid-area: enabled;
  min-height: var(--scheduled-action-control-height);
  margin: 0;
  min-width: 0;
}

.scheduled-action-enabled input {
  margin: 0;
  flex: 0 0 auto;
}

.scheduled-action-enabled span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.scheduled-action-grid {
  display: grid;
  grid-template-columns:
    minmax(8.5rem, 1.1fr)
    minmax(5.5rem, 0.65fr)
    minmax(8rem, 0.85fr)
    minmax(8rem, 0.9fr)
    minmax(5rem, 0.55fr)
    auto;
  grid-template-areas: "enabled passes time repeat spray delete";
  gap: 0.65rem;
  padding: 0;
  align-items: end;
  background: transparent;
}

.scheduled-action-grid--no-spray {
  grid-template-columns:
    minmax(8.5rem, 1.1fr)
    minmax(5.5rem, 0.65fr)
    minmax(8rem, 0.85fr)
    minmax(8rem, 0.9fr)
    auto;
  grid-template-areas: "enabled passes time repeat delete";
}

.scheduled-action-grid--has-secondary {
  grid-template-areas:
    "enabled passes time repeat spray delete"
    "secondary secondary secondary secondary secondary secondary";
}

.scheduled-action-grid--no-spray.scheduled-action-grid--has-secondary {
  grid-template-areas:
    "enabled passes time repeat delete"
    "secondary secondary secondary secondary secondary";
}

.scheduled-action-secondary {
  display: grid;
  grid-area: secondary;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 0.65rem;
  align-items: start;
  min-width: 0;
}

.scheduled-action-field {
  display: grid;
  grid-template-rows: auto minmax(var(--scheduled-action-control-height), auto);
  gap: 0.3rem;
  margin: 0;
  min-width: 0;
  padding: 0;
  background: transparent;
  font-weight: 600;
}

.scheduled-action-field--passes {
  grid-area: passes;
}

.scheduled-action-field--time {
  grid-area: time;
}

.scheduled-action-field--repeat {
  grid-area: repeat;
}

.scheduled-action-field--spray {
  grid-area: spray;
}

.scheduled-action-secondary .scheduled-action-field {
  grid-area: auto;
  grid-template-rows: auto var(--scheduled-action-control-height);
}

.scheduled-action-field > span {
  color: #667085;
  font-size: 0.78rem;
  line-height: 1.2;
}

.scheduled-action-field input,
.scheduled-action-field select {
  margin: 0;
}

.scheduled-action-field input:not([type="checkbox"]),
.scheduled-action-field select {
  width: 100%;
}

.scheduled-action-field input:not([type="checkbox"]),
.scheduled-action-field select {
  box-sizing: border-box;
  height: var(--scheduled-action-control-height);
  min-height: var(--scheduled-action-control-height);
}

.scheduled-action-field input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
}

.scheduled-action-field--checkbox {
  grid-template-rows: auto var(--scheduled-action-control-height);
}

.scheduled-action-field--checkbox input {
  align-self: center;
}

.scheduled-action-delete {
  grid-area: delete;
  align-self: end;
  justify-self: end;
  white-space: nowrap;
}

.scheduled-date-picker {
  height: var(--scheduled-action-control-height);
  min-width: 0;
}

.scheduled-date-picker > button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  height: var(--scheduled-action-control-height);
  min-height: var(--scheduled-action-control-height);
  padding-right: 0.75rem;
  padding-left: 0.75rem;
  overflow: hidden;
  overflow-wrap: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scheduled-date-picker > button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scheduled-calendar-menu {
  right: 0;
  left: auto;
  z-index: 1000;
}

.scheduled-date-picker.is-open-up .scheduled-calendar-menu {
  top: auto;
  bottom: calc(100% + 0.35rem);
}

.scheduled-choice-grid {
  display: grid;
  gap: 0.25rem;
}

.scheduled-choice-grid--weekdays {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.scheduled-action-warning {
  margin: 0;
}

.scheduled-cleaning-status {
  min-height: 1.1rem;
}

@media (max-width: 980px) {
  .scheduled-action-grid,
  .scheduled-action-grid--no-spray {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "enabled delete"
      "passes time"
      "repeat spray";
  }

  .scheduled-action-grid--has-secondary {
    grid-template-areas:
      "enabled delete"
      "passes time"
      "repeat spray"
      "secondary secondary";
  }

  .scheduled-action-grid--no-spray {
    grid-template-areas:
      "enabled delete"
      "passes time"
      "repeat repeat";
  }

  .scheduled-action-grid--no-spray.scheduled-action-grid--has-secondary {
    grid-template-areas:
      "enabled delete"
      "passes time"
      "repeat repeat"
      "secondary secondary";
  }
}

@media (max-width: 560px) {
  .scheduled-action-grid,
  .scheduled-action-grid--no-spray {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "enabled"
      "passes"
      "time"
      "repeat"
      "spray"
      "delete";
  }

  .scheduled-action-grid--has-secondary {
    grid-template-areas:
      "enabled"
      "passes"
      "time"
      "repeat"
      "spray"
      "secondary"
      "delete";
  }

  .scheduled-action-grid--no-spray {
    grid-template-areas:
      "enabled"
      "passes"
      "time"
      "repeat"
      "delete";
  }

  .scheduled-action-grid--no-spray.scheduled-action-grid--has-secondary {
    grid-template-areas:
      "enabled"
      "passes"
      "time"
      "repeat"
      "secondary"
      "delete";
  }

  .scheduled-action-delete {
    justify-self: start;
  }
}

.master-command-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.master-command-list button {
  width: auto;
  margin: 0;
}

@media (max-width: 760px) {
  .config-row,
  .config-general-row:not(.config-general-card-header) {
    grid-template-columns: 1fr;
  }

  .config-row-advisory {
    grid-column: 1 / -1;
    margin-top: -0.25rem;
  }

  .config-general-card-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "status"
      "actions";
  }

  .config-general-card-header .config-status-line {
    justify-self: start;
  }

  .openweather-map-dialog,
  .openweather-map-body,
  .openweather-map-footer {
    grid-template-columns: 1fr;
  }

  .openweather-map-body {
    grid-template-rows: auto minmax(300px, 1fr);
  }
}

/* Event log */
.event-log-list {
  max-height: 320px;
  overflow-y: auto;
  background: #0c1724;
  color: #dfe7f2;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #15263b;
  font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
}

.event-log-entry {
  padding: 0.1rem 0.25rem;
  border-left: 3px solid transparent;
}

.event-log-entry + .event-log-entry {
  margin-top: 0.1rem;
}

.event-log-entry--info {
  border-color: #4fa3ff;
  color: #e4f1ff;
}

.event-log-entry--warning {
  border-color: #ffc857;
  color: #ffe9b0;
}

.event-log-entry--error {
  border-color: #f26b6b;
  color: #ffd6d6;
}

.event-log-list .muted {
  color: #93a4bd;
}

/* Welcome page */
.welcome-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.welcome-header h2,
.welcome-header p {
  margin-bottom: 0.35rem;
}

.welcome-device-count {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid #d8dee6;
  border-radius: 999px;
  background: #f8fafc;
  color: #4f5d75;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}

.welcome-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.welcome-device-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0;
  padding: 1rem;
  border: 1px solid #dfe3e6;
  border-radius: 0.5rem;
  background: #fff;
}

.welcome-device-card-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.welcome-device-title {
  min-width: 0;
}

.welcome-device-title h3 {
  margin: 0 0 0.25rem;
  color: #243244;
  font-size: 1.1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.welcome-device-id {
  display: flex;
  max-width: 100%;
  gap: 0.35rem;
  align-items: baseline;
  color: #64748b;
}

.welcome-device-id code {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.welcome-device-card .status-pill {
  flex: 0 0 auto;
  max-width: 45%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.welcome-open-dashboard {
  display: inline-flex;
  width: 100%;
  min-height: 2.55rem;
  align-items: center;
  justify-content: center;
  margin: auto 0 0;
  text-align: center;
}

.welcome-rename-form {
  margin: 0;
}

.welcome-rename-form label {
  margin-bottom: 0.35rem;
  color: #4f5d75;
  font-size: 0.88rem;
  font-weight: 600;
}

.welcome-rename-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.welcome-rename-row input,
.welcome-rename-row button {
  margin: 0;
}

.welcome-rename-row input {
  width: 100%;
}

.welcome-rename-row button {
  width: auto;
  white-space: nowrap;
}

.welcome-empty-state {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px dashed #cfd5e2;
  border-radius: 0.5rem;
  background: #f8fafb;
}

.welcome-empty-state h3,
.welcome-empty-state p {
  margin-bottom: 0.35rem;
}

/* Navigation tweaks */
header.container nav,
header.container nav ul {
  flex-wrap: wrap;
}

header.container nav ul {
  min-width: 0;
}

.nav-logout {
  display: flex;
  align-items: center;
}

.nav-logout form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.nav-link-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  margin: 0;
  padding: var(--pico-nav-link-spacing-vertical) var(--pico-nav-link-spacing-horizontal);
  color: inherit;
  font: inherit;
  line-height: var(--pico-line-height);
  cursor: pointer;
}

.nav-link-btn:hover,
.nav-link-btn:focus {
  text-decoration: underline;
}

/* Cookie notice */
body.has-cookie-notice {
  padding-bottom: 7rem;
}

.cookie-notice {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 1000;
}

.cookie-notice[hidden] {
  display: none;
}

.cookie-notice__content {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  max-width: 68rem;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  border: 1px solid #cfd5e2;
  border-radius: 0.4rem;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.cookie-notice__content p {
  margin: 0;
  color: #2f3a45;
  font-size: 0.95rem;
  line-height: 1.4;
}

.cookie-notice__button {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  padding: 0.55rem 0.85rem;
  white-space: nowrap;
}

.cookie-notice__button:focus-visible {
  outline: 3px solid rgba(1, 114, 173, 0.35);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .welcome-device-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .welcome-device-card .status-pill {
    max-width: 100%;
    align-self: flex-start;
  }

  .welcome-rename-row {
    grid-template-columns: 1fr;
  }

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

  body.has-cookie-notice {
    padding-bottom: 11rem;
  }

  .cookie-notice {
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
  }

  .cookie-notice__content {
    display: block;
    padding: 0.85rem;
  }

  .cookie-notice__button {
    width: 100%;
    margin-top: 0.75rem;
  }
}
