/* Redesigned back office (templates/admin_base.html). Shares the palette of style.css. */
:root {
  --bg: #f2f5f7;
  --card: #ffffff;
  --ink: #1f2a33;
  --muted: #5d6b77;
  --line: #d5dde4;
  --accent: #007a78;
  --accent-ink: #ffffff;
  --sidebar: #17313a;
  --sidebar-ink: #d8e6ea;
  --ok: #1d7a46;
  --ok-bg: #e5f4ec;
  --warning: #8a5a00;
  --warning-bg: #fdf1d8;
  --critical: #b3261e;
  --critical-bg: #fbe7e5;
  --info: #3b5b75;
  --info-bg: #e6eef5;
  --sidebar-width: 220px;
}

* {
  box-sizing: border-box;
}

body.admin {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid #f0b429;
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--card);
}

.skip-link:focus {
  left: 0.5rem;
}

/* Sidebar */
.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  overflow-y: auto;
  z-index: 30;
}

.admin-brand {
  padding: 0.25rem 0.5rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  overflow-wrap: anywhere;
}

.admin-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}

.admin-nav a,
.admin-nav-soon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--sidebar-ink);
  text-decoration: none;
}

.admin-nav a:hover {
  background: rgb(255 255 255 / 8%);
}

.admin-nav a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.admin-nav-soon {
  opacity: 0.55;
  cursor: default;
}

.admin-nav-soon small {
  font-size: 0.7rem;
}

.admin-public-link {
  margin-top: auto;
  padding: 0.55rem 0.75rem;
  color: var(--sidebar-ink);
  font-size: 0.9rem;
}

.admin-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 35%);
  z-index: 20;
}

/* Page */
.admin-page {
  margin-left: var(--sidebar-width);
  min-width: 0;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.admin-menu-button {
  display: none;
  padding: 0.35rem 0.6rem;
  font-size: 1.2rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.admin-context select {
  max-width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font: inherit;
}

.admin-main {
  max-width: 1200px;
  padding: 1rem 1.25rem 2rem;
}

.admin-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-breadcrumb li + li::before {
  content: "/";
  margin-right: 0.35rem;
}

.admin-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 0.4rem 0 1rem;
}

.admin-heading h1 {
  margin: 0;
  font-size: 1.6rem;
}

.admin-flash:empty {
  display: none;
}

.admin-flash {
  margin-bottom: 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
}

.admin-flash.is-success {
  background: var(--ok-bg);
  color: var(--ok);
}

.admin-flash.is-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.admin-flash.is-error {
  background: var(--critical-bg);
  color: var(--critical);
}

/* Buttons */
.button-primary,
.button-secondary {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

a.button-primary,
a.button-secondary {
  display: inline-block;
  text-decoration: none;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
}

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

/* Panels and states */
.panel {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.panel-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

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

.state-error {
  color: var(--critical);
}

.state-error p {
  margin: 0 0 0.75rem;
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  vertical-align: -0.15rem;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

/* Overview */
.summary-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 10px;
}

.summary-card.is-ok {
  border-left-color: var(--ok);
}

.summary-card.is-warning {
  border-left-color: #d99a00;
}

.summary-card.is-critical {
  border-left-color: var(--critical);
}

.summary-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.summary-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.summary-hint {
  font-size: 0.8rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.pending-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding: 0.7rem 0.25rem;
  border-top: 1px solid var(--line);
}

.pending-item:first-child {
  border-top: none;
}

.pending-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.pending-location {
  font-size: 0.85rem;
  color: var(--muted);
}

.pending-message {
  flex-basis: 100%;
  padding-left: 3.6rem;
  font-size: 0.9rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  min-width: 3rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-neutral {
  background: #eef1f4;
  color: var(--muted);
}

.badge-critical {
  background: var(--critical-bg);
  color: var(--critical);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.data-table tbody th {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tr.is-inactive {
  color: var(--muted);
}

.button-link {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* A column header that sorts the list: reads as a header, not a link. */
.button-link.sort-header {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.button-link.sort-header:hover {
  text-decoration: underline;
}

.text-critical {
  color: var(--critical);
  font-weight: 600;
}

/* Dialogs and forms */
.admin-dialog {
  width: min(560px, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
}

.admin-dialog::backdrop {
  background: rgb(0 0 0 / 35%);
}

.admin-dialog-wide {
  width: min(720px, calc(100vw - 2rem));
}

.dialog-section-title {
  margin: 1.25rem 0 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.dialog-section-title:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.form-grid + .form-grid:not(:empty) {
  margin-top: 0.9rem;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.section-heading .section-title {
  margin: 0;
}

.section-heading + div {
  margin-top: 0.5rem;
}

.field-table input:not([type="checkbox"]),
.field-table select {
  width: 100%;
  min-width: 6rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

#catalog-add-field {
  align-self: flex-start;
  margin-top: 0.5rem;
}

.device-test {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.check-grid {
  display: grid;
  gap: 0.3rem 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  font-weight: 400;
}

.admin-dialog h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.form-grid {
  display: grid;
  gap: 0.9rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
}

.form-check {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.form-help {
  flex-basis: 100%;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.form-error {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--critical);
}

.form-error:empty {
  display: none;
}

.form-error-general {
  margin: 0.75rem 0 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* Detail pages */
.detail-meta {
  margin: -0.5rem 0 0.5rem;
  color: var(--muted);
}

.detail-description {
  margin: 0 0 1rem;
}

.panel-columns {
  display: grid;
  gap: 0 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.event-list,
.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-list li,
.link-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.event-list li:first-child,
.link-list li:first-child {
  border-top: none;
}

.event-list time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.event-type {
  font-weight: 600;
}

.link-name {
  flex-basis: 100%;
  font-weight: 600;
}

/* Monitor list */
.filter-panel {
  margin-top: 0;
}

.filter-bar {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.filter-search {
  grid-column: span 2;
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.view-toggle {
  display: flex;
}

.view-toggle button {
  border-radius: 0;
}

.view-toggle button:first-child {
  border-radius: 8px 0 0 8px;
}

.view-toggle button:last-child {
  border-radius: 0 8px 8px 0;
  border-left: none;
}

.view-toggle button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.batch-bar {
  position: sticky;
  top: 3.4rem;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--info-bg);
  border: 1px solid #c7d6e4;
  border-radius: 10px;
}

.batch-bar[hidden] {
  display: none;
}

.batch-move select {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pagination:empty {
  display: none;
}

.tag {
  display: inline-block;
  padding: 0 0.4rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}

.monitor-cards {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.monitor-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
}

.monitor-card.is-inactive {
  color: var(--muted);
}

.monitor-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.monitor-card-head strong {
  flex: 1;
  overflow-wrap: anywhere;
}

.monitor-card-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.monitor-card-meta {
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Wizard */
.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
}

.wizard-steps li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  font-weight: 600;
}

.wizard-steps li.is-done .step-number {
  border-color: var(--ok);
  color: var(--ok);
}

.wizard-steps li.is-current {
  color: var(--ink);
  font-weight: 600;
}

.wizard-steps li.is-current .step-number {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.wizard-panel {
  margin-top: 0;
}

.wizard-title {
  margin: 0;
  font-size: 1.2rem;
}

.wizard-help {
  margin: 0.25rem 0 1rem;
  color: var(--muted);
}

.wizard-help:empty {
  display: none;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.wizard-actions a {
  text-decoration: none;
}

.choice-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: none;
}

.choice-group {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: #e8f4f3;
}

.choice span {
  display: grid;
  gap: 0.15rem;
}

.choice small {
  color: var(--muted);
}

.metric-checks {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-bottom: 1rem;
}

.test-result {
  margin-top: 0.75rem;
}

.preview-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
}

.preview-list div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.75rem;
}

.preview-list dt {
  color: var(--muted);
}

.preview-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Monitor page */
.monitor-head-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  padding: 0.6rem 0.9rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.tab-panel {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
}

.section-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}

.iaq-reason {
  margin: 0.75rem 0 0;
  font-weight: 600;
}

.summary-value small {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.trend-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.trend-metric {
  min-width: 10rem;
}

.trend-chart {
  position: relative;
  height: 320px;
}

.diagnostics-card {
  padding: 0.25rem 0 1rem;
  border-bottom: 1px solid var(--line);
}

.diagnostics-card:last-child {
  border-bottom: none;
}

.diagnostics-card h3 {
  margin: 0.5rem 0 0.75rem;
  font-size: 1rem;
}

.diagnostics-card .dialog-actions {
  justify-content: space-between;
  align-items: center;
}

.event-filters {
  margin-bottom: 0.75rem;
}

.threshold-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}

.threshold-row {
  display: grid;
  /* minmax(0, ...) lets each column shrink below its input's default width, so
     neighbouring fields never overlap. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.threshold-row legend {
  padding: 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.threshold-row .form-error {
  grid-column: 1 / -1;
}

.threshold-row .form-field {
  min-width: 0;
}

.threshold-row .form-field input {
  width: 100%;
  min-width: 0;
}

.danger-zone {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.danger-zone summary {
  color: var(--critical);
  cursor: pointer;
}

.danger-zone p {
  font-size: 0.9rem;
  color: var(--muted);
}

.button-danger {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--critical);
  border-radius: 8px;
  background: var(--critical);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

/* Settings */
.settings-nav a {
  padding: 0.6rem 0.9rem;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.settings-nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}

.mqtt-status {
  margin: 0 0 1rem;
}

/* Signed-in user and login page */
.admin-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

.admin-user-name {
  display: grid;
  text-align: right;
  font-size: 0.9rem;
  line-height: 1.2;
}

.admin-user-name small {
  color: var(--muted);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-box {
  width: min(380px, 100%);
  padding: 1.75rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.login-box h1 {
  margin: 0;
  font-size: 1.4rem;
}

.login-subtitle {
  margin: 0.25rem 0 1.25rem;
  color: var(--muted);
}

.login-box form {
  display: grid;
  gap: 0.9rem;
}

.login-submit {
  width: 100%;
  padding: 0.65rem;
}

.login-footer {
  margin: 1.25rem 0 0;
  font-size: 0.9rem;
  text-align: center;
}

.login-register {
  margin: 1rem 0 0;
  text-align: center;
}

.register-box {
  width: min(440px, 100%);
}

.register-box .required::after {
  content: " *";
  color: var(--critical);
}

/* Robots fill in what people cannot see. */
.register-trap {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.register-done {
  margin: 0;
  line-height: 1.6;
}

.scope-list {
  display: grid;
  gap: 0.5rem;
  max-height: 16rem;
  overflow-y: auto;
}

.scope-group {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scope-location {
  padding-left: 1.5rem;
  font-weight: 400;
}

.scope-field[hidden],
.form-field[hidden] {
  display: none;
}

/* MQTT message format: a sample message is JSON. */
#mqtt-preview-payload {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 400;
}

/* In a column of fields, flex-basis is a height: a full-width help line must not
   become a full-height block (it left a large gap above the scope list). */
.form-field > .form-help {
  flex-basis: auto;
}

.audit-details {
  flex-basis: 100%;
  font-size: 0.8rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Report center */
.report-builder form {
  display: grid;
  gap: 1.1rem;
}

.report-builder fieldset {
  margin: 0;
  padding: 0;
  border: none;
}

.report-builder legend {
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.report-monitor-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin-bottom: 0.5rem;
}

.report-monitor-tools input {
  flex: 1;
  min-width: 12rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.report-monitor-list {
  display: grid;
  gap: 0.35rem 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  max-height: 18rem;
  padding: 0.6rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-monitor {
  align-items: flex-start;
  font-weight: 400;
}

.report-monitor span {
  display: grid;
}

.report-monitor small {
  color: var(--muted);
}

.report-quick {
  margin-bottom: 0.6rem;
}

.report-dates {
  max-width: 32rem;
}

/* Narrow screens: the sidebar becomes a drawer. */
@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .admin-sidebar.is-open {
    transform: none;
  }

  .admin-page {
    margin-left: 0;
  }

  .admin-menu-button {
    display: inline-block;
  }

  .admin-topbar,
  .admin-main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .admin-context {
    flex: 1;
    min-width: 0;
  }

  .admin-context select {
    width: 100%;
  }

  .pending-message {
    padding-left: 0;
  }

  .admin-user-name {
    display: none;
  }

  .filter-search {
    grid-column: 1 / -1;
  }

  .batch-bar {
    top: 3.2rem;
  }

  .step-label {
    display: none;
  }

  .wizard-steps li.is-current .step-label {
    display: inline;
  }

  .preview-list div {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
}

fieldset.form-field {
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.form-field legend {
  margin-bottom: 0.3rem;
  padding: 0;
}

/* A customer's lobby screen: its pictures and settings. */
.lobby-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem 1.5rem;
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.lobby-image {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lobby-image-title {
  margin: 0;
  font-size: 0.95rem;
}

.lobby-image-preview {
  width: 240px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-size: cover;
  background-position: center;
}

/* Logos keep their shape, on the dark of the screen's corner box. */
.lobby-image-preview.is-logo {
  background-color: #16232b;
  background-size: contain;
  background-repeat: no-repeat;
  background-origin: content-box;
  padding: 0.75rem;
}

.lobby-image-preview.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
}

.lobby-settings-actions,
.lobby-slide-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem 1rem;
}

.lobby-slide-form .form-field input {
  width: 8rem;
}

.lobby-brand-check {
  grid-column: auto;
  padding-bottom: 0.5rem;
}

/* The lobby screen's styles: a small picture of each (background and a panel). */
.lobby-themes {
  flex-basis: 100%;
}

.lobby-theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.lobby-theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  font-weight: 400;
  cursor: pointer;
}

.lobby-theme-option:has(input:checked) {
  border-color: var(--accent);
}

.lobby-theme-option input {
  position: absolute;
  opacity: 0;
}

.lobby-theme-option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lobby-theme-swatch {
  position: relative;
  display: block;
  width: 128px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
}

/* The panel on the left and the name box on the right. */
.lobby-theme-swatch span {
  position: absolute;
  border-radius: 3px;
}

.lobby-theme-swatch span:first-child {
  left: 6%;
  top: 8%;
  width: 34%;
  height: 84%;
}

.lobby-theme-swatch span:last-child {
  right: 6%;
  top: 8%;
  width: 26%;
  height: 22%;
}

.lobby-theme-swatch.is-neutral {
  background: radial-gradient(ellipse at 82% 18%, rgba(255, 255, 255, 0.28) 0%, transparent 42%),
    linear-gradient(155deg, #a3abad 0%, #7e888c 48%, #5c666b 100%);
}

.lobby-theme-swatch.is-neutral span {
  background: rgba(30, 36, 40, 0.8);
}

.lobby-theme-swatch.is-light {
  background: radial-gradient(ellipse at 12% 92%, rgba(170, 214, 200, 0.55) 0%, transparent 42%),
    linear-gradient(160deg, #f4f7f9 0%, #e1e9ed 55%, #cfdbe1 100%);
}

.lobby-theme-swatch.is-light span {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(30, 60, 75, 0.18);
}

.lobby-theme-swatch.is-dark {
  background: radial-gradient(ellipse at 78% 22%, rgba(38, 110, 130, 0.45) 0%, transparent 45%),
    linear-gradient(160deg, #101c22 0%, #0b1317 60%, #070d10 100%);
}

.lobby-theme-swatch.is-dark span {
  background: rgba(255, 255, 255, 0.1);
}

.lobby-panels {
  flex-basis: 100%;
}

.lobby-panel-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

.lobby-panel-options .form-check {
  grid-column: auto;
}

/* Each platform logo on its corner's color. */
.lobby-image-preview.is-logo.is-on-light {
  background-color: #ffffff;
}

/* IAQ 試算的案例清單 */
.iaq-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
}

/* IAQ 專案清單上方的固定範例 */
.iaq-pinned {
  margin: 0 0 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line, #d9e0e5);
  border-radius: 10px;
}
.iaq-pinned h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}
.iaq-pinned ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.iaq-pinned li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  align-items: baseline;
}
.iaq-pinned .muted {
  color: var(--muted);
  font-size: 0.875rem;
}
