:root {
  --canvas: #f3f1ea;
  --surface: #faf9f5;
  --surface-strong: #ffffff;
  --ink: #202522;
  --muted: #6c736e;
  --line: #d9d8d0;
  --line-strong: #bfc1b9;
  --green: #276247;
  --green-bright: #6cdb9f;
  --green-soft: #e1eee6;
  --amber: #9b681c;
  --amber-soft: #f3ead7;
  --red: #a23f3a;
  --red-soft: #f5e3e1;
  --charcoal: #252a28;
  --zone-outside: oklch(0.68 0.12 79);
  --zone-doorway: oklch(0.61 0.14 34);
  --zone-inside: oklch(0.55 0.11 154);
  --shadow-1: 0 1px 2px rgba(29, 33, 30, 0.06), 0 8px 24px rgba(29, 33, 30, 0.04);
  --radius-panel: 18px;
  --radius-control: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--canvas);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-size: 16px;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(37, 42, 40, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 42, 40, 0.025) 1px, transparent 1px),
    var(--canvas);
  background-size: 32px 32px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(39, 98, 71, 0.25);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--charcoal);
  color: white;
  transform: translateY(-150%);
  transition: transform 160ms var(--ease);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 16px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(243, 241, 234, 0.92);
  backdrop-filter: blur(18px);
}

.identity,
.topbar-status,
.panel-heading,
.camera-meta,
.button-row,
.confidence-row,
.arm-switch,
.device-actions,
.event-meta {
  display: flex;
  align-items: center;
}

.identity {
  gap: 14px;
}

.identity-mark {
  width: 16px;
  height: 42px;
  border: 1px solid var(--green);
  background: linear-gradient(to bottom, var(--green) 50%, transparent 50%);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.13em;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.025em;
}

h1 {
  font-size: clamp(1.25rem, 2vw, 1.55rem);
}

h2 {
  font-size: clamp(1.1rem, 1.8vw, 1.35rem);
}

h3 {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
}

.topbar-status {
  gap: 18px;
  color: var(--muted);
  font-size: 0.82rem;
}

.badge,
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 6px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.badge-simulation {
  border: 1px solid #d7c49c;
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-live {
  border: 1px solid #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(191, 193, 185, 0.18);
}

.is-healthy .status-dot,
.camera-meta .is-healthy.status-dot,
.status-dot.is-healthy {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(39, 98, 71, 0.12);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(310px, 0.75fr);
  gap: 20px;
  width: min(1500px, calc(100% - 40px));
  margin: 24px auto 48px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: rgba(250, 249, 245, 0.94);
  box-shadow: var(--shadow-1);
}

.camera-panel {
  min-width: 0;
  padding: 20px;
}

.panel-heading {
  justify-content: space-between;
  min-height: 46px;
  margin-bottom: 16px;
}

.panel-heading.compact {
  margin-bottom: 10px;
}

.camera-meta {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
}

#camera-health {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.camera-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid #414744;
  border-radius: 12px;
  background: var(--charcoal);
}

.camera-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  pointer-events: none;
}

.camera-corner-top {
  top: 12px;
  right: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  border-right: 1px solid rgba(255, 255, 255, 0.5);
}

.camera-corner-bottom {
  bottom: 12px;
  left: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  border-left: 1px solid rgba(255, 255, 255, 0.5);
}

.live-label {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  background: rgba(24, 28, 27, 0.74);
  color: #eceee9;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  backdrop-filter: blur(10px);
}

.live-label span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-bright);
}

.simulation-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: #f5f2e9;
}

.control-title {
  margin: 0 0 2px;
  font-size: 0.9rem;
  font-weight: 650;
}

.simulation-controls p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.button-row {
  flex-shrink: 0;
  gap: 8px;
}

.button,
.text-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
  font-weight: 650;
  transition: transform 130ms var(--ease), background-color 160ms var(--ease), color 160ms var(--ease);
}

.button {
  padding: 0 15px;
  font-size: 0.78rem;
}

.button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.button:active,
.text-button:active {
  transform: translateY(0);
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button-primary {
  background: var(--green);
  color: white;
}

.button-primary:hover {
  background: #1f523b;
}

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

.control-column {
  display: grid;
  align-content: start;
  gap: 20px;
}

.occupancy-card {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  padding: 24px;
  transition: background-color 250ms var(--ease), border-color 250ms var(--ease);
}

.occupancy-card.is-occupied {
  border-color: #a9cbb7;
  background: var(--green-soft);
}

.occupancy-orbit {
  position: absolute;
  top: 24px;
  right: 24px;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.occupancy-orbit::before,
.occupancy-orbit span {
  content: "";
  display: block;
  border-radius: 50%;
}

.occupancy-orbit::before {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
}

.occupancy-orbit span {
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--line-strong);
  transition: background-color 250ms var(--ease), box-shadow 250ms var(--ease);
}

.is-occupied .occupancy-orbit {
  border-color: rgba(39, 98, 71, 0.35);
  animation: slow-spin 8s linear infinite;
}

.is-occupied .occupancy-orbit::before {
  border-color: rgba(39, 98, 71, 0.35);
}

.is-occupied .occupancy-orbit span {
  background: var(--green);
  box-shadow: 0 0 0 7px rgba(39, 98, 71, 0.12);
}

.occupancy-state {
  margin: 34px 0 6px;
  font-size: clamp(2.5rem, 5vw, 4.2rem);
  font-weight: 560;
  letter-spacing: -0.065em;
  line-height: 0.96;
}

.occupancy-detail {
  min-height: 42px;
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.confidence-row {
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid rgba(32, 37, 34, 0.12);
  color: var(--muted);
  font-size: 0.78rem;
}

.confidence-row strong {
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.devices-panel {
  padding: 20px;
}

.arm-switch {
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 650;
}

.arm-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--line);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}

.switch-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(32, 37, 34, 0.3);
  transition: transform 180ms var(--ease);
}

.arm-switch input:checked + .switch-track {
  border-color: var(--green);
  background: var(--green);
}

.arm-switch input:checked + .switch-track span {
  transform: translateX(16px);
}

.device-list {
  display: grid;
}

.device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  border-top: 1px solid var(--line);
}

.device-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.device-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.device-name {
  overflow: hidden;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-physical-state {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #eeeee8;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.58rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
}

.device-physical-state.is-on {
  border-color: #9cc5ad;
  background: var(--green-soft);
  color: var(--green);
}

.device-physical-state.is-off {
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--charcoal);
}

.device-physical-state.is-mixed {
  border-color: #d4b478;
  background: var(--amber-soft);
  color: var(--amber);
}

.device-physical-state.is-unknown {
  border-color: var(--line);
  background: #eeeee8;
  color: var(--muted);
}

.device-status {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.device-status .status-dot {
  width: 6px;
  height: 6px;
}

.channel-state-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.channel-state {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #eeeee8;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.57rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.channel-state.is-on {
  border-color: #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.device-row.is-offline .device-name {
  color: var(--muted);
}

.device-row.is-mixed {
  background: linear-gradient(90deg, rgba(243, 234, 215, 0.46), transparent 55%);
}

.device-actions {
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f2f1eb;
}

.state-button {
  min-width: 48px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
}

.state-button.active {
  background: var(--surface-strong);
  color: var(--green);
  box-shadow: 0 1px 3px rgba(32, 37, 34, 0.12);
}

.activity-panel {
  grid-column: 1 / -1;
  padding: 20px;
}

.text-button {
  min-height: 36px;
  padding: 0 8px;
  background: transparent;
  color: var(--green);
  font-size: 0.75rem;
}

.event-list {
  display: grid;
}

.event-row {
  display: grid;
  grid-template-columns: 20px minmax(150px, 0.45fr) minmax(200px, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 58px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
}

.event-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}

.event-indicator.success {
  background: var(--green);
}

.event-indicator.warning {
  background: var(--amber);
}

.event-indicator.error {
  background: var(--red);
}

.event-title {
  font-weight: 650;
}

.event-detail,
.event-time {
  color: var(--muted);
}

.event-time {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.7rem;
}

.empty-state {
  padding: 24px 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--charcoal);
  color: white;
  box-shadow: 0 16px 44px rgba(32, 37, 34, 0.2);
  font-size: 0.8rem;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.dashboard-multi {
  grid-template-columns: 1fr;
}

.section-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 2px 0;
}

.section-intro > p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

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

.zone-panel {
  transition: border-color 220ms var(--ease), background-color 220ms var(--ease);
}

.zone-panel.is-occupied {
  border-color: #9fc6ae;
  background: linear-gradient(180deg, rgba(225, 238, 230, 0.82), rgba(250, 249, 245, 0.96) 42%);
}

.camera-role-chip {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  margin-left: 5px;
  padding: 2px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.54rem;
  letter-spacing: 0.07em;
  vertical-align: 1px;
}

.camera-role-chip.is-control {
  border-color: #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.zone-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 88px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.62);
}

.zone-presence {
  display: flex;
  align-items: center;
  gap: 12px;
}

.occupancy-orbit-small {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
}

.occupancy-orbit-small::before {
  width: 26px;
  height: 26px;
}

.zone-state {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.035em;
}

.zone-detail {
  min-width: 0;
  padding-left: 18px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.zone-detail p {
  margin: 0 0 5px;
}

.zone-detail strong {
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.system-devices {
  grid-column: auto;
}

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

.device-grid .device-row {
  padding: 0 2px;
}

.state-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.energy-saver-panel {
  overflow: hidden;
  box-shadow: inset 4px 0 0 var(--line-strong), var(--shadow-1);
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

.energy-saver-panel.is-enabled {
  border-color: #a9cbb7;
  background: rgba(246, 250, 247, 0.96);
  box-shadow: inset 4px 0 0 var(--green), var(--shadow-1);
}

.energy-saver-panel.has-error {
  border-color: #d8aba7;
}

.energy-saver-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  min-height: 92px;
  padding: 18px 22px;
}

.energy-saver-heading,
.energy-saver-title-row,
.energy-saver-toggle {
  display: flex;
  align-items: center;
}

.energy-saver-heading {
  min-width: 0;
  gap: 13px;
}

.energy-saver-mark {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-strong);
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}

.energy-saver-mark::before,
.energy-saver-mark::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease), transform 220ms var(--ease);
}

.energy-saver-mark::before {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-strong);
}

.energy-saver-mark::after {
  width: 6px;
  height: 6px;
  background: var(--line-strong);
}

.energy-saver-panel.is-enabled .energy-saver-mark {
  border-color: #a9cbb7;
  background: var(--green-soft);
}

.energy-saver-panel.is-enabled .energy-saver-mark::before {
  border-color: var(--green);
  transform: scale(1.08);
}

.energy-saver-panel.is-enabled .energy-saver-mark::after {
  background: var(--green);
}

.energy-saver-title-row {
  flex-wrap: wrap;
  gap: 9px;
}

.energy-saver-status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.075em;
}

.energy-saver-status.is-active {
  border-color: #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.energy-saver-status.is-standby,
.energy-saver-status.is-saving {
  border-color: #d7c49c;
  background: var(--amber-soft);
  color: var(--amber);
}

.energy-saver-status.is-disabled,
.energy-saver-status.is-loading {
  background: #efeee8;
}

.energy-saver-toggle {
  position: relative;
  justify-content: flex-end;
  gap: 12px;
  min-width: 245px;
  min-height: 56px;
  padding: 9px 11px 9px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease), transform 130ms var(--ease);
}

.energy-saver-toggle:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.energy-saver-toggle:active {
  transform: translateY(0);
}

.energy-saver-toggle:has(input:disabled) {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.energy-saver-toggle-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
  margin-right: auto;
  text-align: right;
}

.energy-saver-toggle-copy strong {
  font-size: 0.75rem;
}

.energy-saver-toggle-copy small {
  color: var(--muted);
  font-size: 0.64rem;
}

.energy-saver-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.energy-saver-toggle input:focus-visible {
  outline: none;
}

.energy-saver-switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--line);
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease), outline-color 180ms var(--ease);
}

.energy-saver-switch-track span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(32, 37, 34, 0.3);
  transition: transform 200ms var(--ease);
}

.energy-saver-toggle input:focus-visible + .energy-saver-switch-track {
  outline: 3px solid rgba(39, 98, 71, 0.25);
  outline-offset: 3px;
}

.energy-saver-toggle input:checked + .energy-saver-switch-track {
  border-color: var(--green);
  background: var(--green);
}

.energy-saver-toggle input:checked + .energy-saver-switch-track span {
  transform: translateX(20px);
}

.energy-saver-body {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(0, 1.3fr);
  border-top: 1px solid var(--line);
}

.energy-saver-explanation {
  display: grid;
  align-content: center;
  gap: 16px;
  min-width: 0;
  padding: 20px 22px;
  border-right: 1px solid var(--line);
}

.energy-saver-explanation > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.energy-saver-rule {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  border-top: 1px solid var(--line);
}

.energy-saver-rule > div {
  min-width: 0;
  padding: 11px 12px 0 0;
}

.energy-saver-rule > div + div {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.energy-saver-rule dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.65rem;
}

.energy-saver-rule dd {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.69rem;
  font-weight: 700;
  line-height: 1.35;
}

.energy-saver-device-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 0;
}

.energy-saver-device-group {
  min-width: 0;
  padding: 18px 20px;
}

.energy-saver-device-group + .energy-saver-device-group {
  border-left: 1px solid var(--line);
}

.energy-saver-device-group.is-pending {
  background: rgba(243, 234, 215, 0.38);
}

.energy-saver-device-heading {
  min-height: 42px;
}

.energy-saver-device-heading > p:last-child {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.4;
}

.energy-saver-device-list {
  display: grid;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.energy-saver-device-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 49px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.energy-saver-device-list li.is-placeholder {
  display: block;
  min-height: auto;
  padding: 12px 0 3px;
  color: var(--muted);
  font-size: 0.69rem;
}

.energy-saver-device-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(39, 98, 71, 0.1);
}

.is-setup-required .energy-saver-device-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(155, 104, 28, 0.1);
}

.energy-saver-device-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.energy-saver-device-copy strong {
  overflow: hidden;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.energy-saver-device-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.61rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.energy-saver-device-tag {
  padding: 4px 5px;
  border: 1px solid #a9cbb7;
  border-radius: 5px;
  color: var(--green);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.52rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  white-space: nowrap;
}

.is-setup-required .energy-saver-device-tag {
  border-color: #d7c49c;
  color: var(--amber);
}

.energy-saver-feedback {
  margin: 0;
  padding: 11px 22px;
  border-top: 1px solid #d8aba7;
  background: var(--red-soft);
  color: var(--red);
  font-size: 0.72rem;
  line-height: 1.4;
}

.counter-section {
  display: grid;
  gap: 20px;
}

.counter-intro > p {
  max-width: 470px;
}

.counter-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 20px;
}

.counter-summary,
.authority-panel,
.adjustment-panel,
.crossing-panel {
  padding: 24px;
}

.counter-summary {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.counter-summary.is-unavailable {
  background: rgba(250, 249, 245, 0.72);
}

.count-primary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.counter-value {
  display: block;
  min-height: 5.1rem;
  margin-top: 6px;
  font-size: 5.25rem;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.075em;
  line-height: 0.92;
}

.counter-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.counter-status-badge,
.authority-chip,
.calibration-status,
.crossing-direction,
.crossing-confidence {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.075em;
  white-space: nowrap;
}

.counter-status-badge.is-live,
.counter-status-badge.is-high,
.calibration-status.is-reviewed {
  border-color: #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.counter-status-badge.is-shadow,
.counter-status-badge.is-review {
  border-color: #d7c49c;
  background: var(--amber-soft);
  color: var(--amber);
}

.counter-status-badge.is-unavailable,
.counter-status-badge.is-unknown,
.counter-status-badge.is-loading {
  background: #efeee8;
  color: var(--muted);
}

.counter-totals {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(170px, 1.2fr);
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.counter-totals > div {
  min-width: 0;
  padding: 16px 18px;
}

.counter-totals > div:first-child {
  padding-left: 0;
}

.counter-totals > div + div {
  border-left: 1px solid var(--line);
}

.counter-totals dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.counter-totals dd {
  overflow: hidden;
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.off-state {
  display: grid;
  grid-template-columns: auto minmax(150px, auto) minmax(190px, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 72px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f6f4ed;
}

.off-state-mark {
  width: 10px;
  height: 10px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}

.off-state p {
  margin: 0;
}

.off-state > div p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.7rem;
}

.off-state > div strong {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.28rem;
  font-variant-numeric: tabular-nums;
}

.off-state > p {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.off-state.is-held,
.off-state.is-ready {
  border-color: #b6d1c1;
  background: var(--green-soft);
}

.off-state.is-held .off-state-mark,
.off-state.is-ready .off-state-mark {
  border-color: var(--green);
  background: var(--green);
}

.off-state.is-counting {
  border-color: #d7c49c;
  background: var(--amber-soft);
}

.off-state.is-counting .off-state-mark {
  border-color: var(--amber);
}

.off-state.is-paused {
  border-color: #d7c49c;
  background: var(--amber-soft);
}

.off-state.is-paused .off-state-mark {
  border-color: var(--amber);
  background: var(--amber);
}

.authority-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-color: rgba(37, 42, 40, 0.7);
  background: var(--charcoal);
  color: var(--canvas);
}

.authority-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.authority-panel .eyebrow,
.authority-panel p {
  color: #aeb5b0;
}

.authority-chip {
  border-color: rgba(108, 219, 159, 0.4);
  background: rgba(108, 219, 159, 0.1);
  color: var(--green-bright);
}

.authority-flow {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.authority-flow li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(243, 241, 234, 0.12);
}

.authority-flow li > span {
  color: var(--green-bright);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.65rem;
  font-weight: 700;
}

.authority-flow strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.84rem;
}

.authority-flow p {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.45;
}

.verification-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(243, 241, 234, 0.14);
  border-radius: 10px;
  background: rgba(243, 241, 234, 0.045);
}

.verification-note .status-dot {
  margin-top: 5px;
}

.verification-note strong {
  font-size: 0.77rem;
}

.verification-note p {
  margin: 3px 0 0;
  font-size: 0.7rem;
  line-height: 1.4;
}

.verification-note.is-clear .status-dot {
  background: var(--green-bright);
  box-shadow: 0 0 0 4px rgba(108, 219, 159, 0.1);
}

.verification-note.is-mismatch {
  border-color: rgba(236, 181, 94, 0.45);
  background: rgba(155, 104, 28, 0.16);
}

.verification-note.is-mismatch .status-dot {
  background: #ecb55e;
  box-shadow: 0 0 0 4px rgba(236, 181, 94, 0.12);
}

.authority-footnote {
  margin: 12px 0 0;
  font-size: 0.68rem;
  line-height: 1.45;
}

.counter-config {
  overflow: hidden;
}

.counter-config > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
  padding: 16px 22px;
  cursor: pointer;
  list-style: none;
}

.counter-config > summary::-webkit-details-marker {
  display: none;
}

.counter-config > summary::after {
  content: "+";
  display: grid;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--green);
  font-size: 1.1rem;
}

.counter-config[open] > summary::after {
  content: "−";
}

.counter-config > summary > span:first-child {
  display: grid;
  gap: 2px;
}

.counter-config > summary strong {
  font-size: 0.92rem;
}

.details-state {
  margin-left: auto;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.details-state.is-dirty {
  color: var(--amber);
}

.details-state.is-error {
  color: var(--red);
}

.counter-config-body {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  border-top: 1px solid var(--line);
}

.calibration-editor,
.counter-settings-form {
  min-width: 0;
  padding: 24px;
}

.counter-settings-form {
  border-left: 1px solid var(--line);
  background: rgba(243, 241, 234, 0.5);
}

.config-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.config-heading p {
  max-width: 58ch;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.calibration-status {
  flex: 0 0 auto;
  border-color: #d7c49c;
  background: var(--amber-soft);
  color: var(--amber);
}

.calibration-frame {
  background: #1e2321;
}

.calibration-frame img:not([src]) {
  visibility: hidden;
}

.calibration-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.calibration-zone {
  --zone-color: var(--green);
}


.calibration-zone-outside {
  --zone-color: var(--zone-outside);
}

.calibration-zone-doorway {
  --zone-color: var(--zone-doorway);
}

.calibration-zone-inside {
  --zone-color: var(--zone-inside);
}

.calibration-zone rect {
  fill: color-mix(in oklch, var(--zone-color) 18%, transparent);
  stroke: color-mix(in oklch, var(--zone-color) 82%, #f3f1ea);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  cursor: move;
}

.calibration-zone:not(.is-selected) rect {
  opacity: 0.76;
}

.calibration-zone circle {
  fill: #f3f1ea;
  stroke: var(--zone-color);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  cursor: nwse-resize;
  opacity: 0;
  pointer-events: none;
}

.calibration-zone.is-selected circle {
  opacity: 1;
  pointer-events: auto;
}

.calibration-zone [tabindex]:focus-visible {
  outline: none;
  stroke: #f3f1ea;
  stroke-width: 7;
}

.calibration-legend {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  max-width: calc(100% - 20px);
  padding: 6px;
  border: 1px solid rgba(243, 241, 234, 0.16);
  border-radius: 7px;
  background: rgba(30, 35, 33, 0.78);
  color: #e8e9e4;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.045em;
}

.calibration-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.calibration-legend span::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--zone-color);
}

.calibration-legend [data-zone-legend="outside"] { --zone-color: var(--zone-outside); }
.calibration-legend [data-zone-legend="doorway"] { --zone-color: var(--zone-doorway); }
.calibration-legend [data-zone-legend="inside"] { --zone-color: var(--zone-inside); }

.zone-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}

.zone-selector {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 3px;
  overflow-x: auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #efeee8;
}

.zone-selector-button {
  min-height: 36px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 650;
  white-space: nowrap;
}

.zone-selector-button.active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(32, 37, 34, 0.12);
}

.coordinate-fieldset,
.adjustment-actions {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.coordinate-fieldset legend,
.adjustment-actions legend {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 650;
}

.coordinate-grid {
  display: grid;
  grid-template-columns: repeat(4, 62px);
  gap: 5px;
}

.coordinate-grid label {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.58rem;
  font-weight: 700;
}

.coordinate-grid input,
.input-suffix input,
.form-field input {
  width: 100%;
  min-height: 40px;
  margin-top: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
}

.coordinate-grid input {
  padding: 0 6px;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.calibration-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.setting-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px;
  gap: 16px;
  align-items: center;
  min-height: 77px;
  border-top: 1px solid var(--line);
}

.setting-field > span:first-child,
.review-check > span {
  display: grid;
  gap: 3px;
}

.setting-field strong,
.review-check strong {
  font-size: 0.78rem;
}

.setting-field small,
.review-check small {
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.35;
}

.input-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-strong);
}

.input-suffix input {
  min-width: 0;
  min-height: 38px;
  margin: 0;
  padding: 0 4px 0 10px;
  border: 0;
  border-radius: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.input-suffix > span {
  padding-right: 9px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.64rem;
}

.review-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-height: 74px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.review-check input {
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--green);
}

.device-mapping {
  display: grid;
  gap: 11px;
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.device-mapping > div > p:last-child {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
}

.device-mapping ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.device-mapping li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(250, 249, 245, 0.78);
  font-size: 0.72rem;
  text-transform: capitalize;
}

.device-mapping li::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.device-mapping li span {
  margin-right: auto;
  font-weight: 650;
}

.device-mapping li small {
  color: var(--muted);
  font-size: 0.62rem;
  text-transform: none;
}

.device-mapping li.mapping-placeholder::before {
  background: var(--line-strong);
}

.safety-note {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.safety-note strong {
  font-size: 0.72rem;
}

.safety-note p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.4;
}

.button-wide {
  width: 100%;
  margin-top: 14px;
}

.inline-message {
  margin-bottom: 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.7rem;
  line-height: 1.4;
}

.inline-message.is-error {
  border-color: #d8aba7;
  background: var(--red-soft);
  color: var(--red);
}

.counter-operations {
  display: grid;
  grid-template-columns: minmax(310px, 0.72fr) minmax(0, 1.28fr);
  gap: 20px;
}

.adjustment-intro {
  margin: 4px 0 18px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.adjustment-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #efeee8;
}

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

.adjustment-actions label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.adjustment-actions input {
  position: absolute;
  opacity: 0;
}

.adjustment-actions span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
  text-align: center;
}

.adjustment-actions input:checked + span {
  background: var(--surface-strong);
  color: var(--green);
  box-shadow: 0 1px 3px rgba(32, 37, 34, 0.12);
}

.adjustment-actions input:focus-visible + span {
  outline: 3px solid rgba(39, 98, 71, 0.25);
  outline-offset: 2px;
}

.form-field {
  display: grid;
  gap: 6px;
  margin-top: 13px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 650;
}

.form-field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.form-field small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
}

.form-field input {
  margin: 0;
  padding: 0 11px;
  font-size: 0.76rem;
}

.crossing-panel {
  min-width: 0;
}

.crossing-history {
  min-height: 176px;
  max-height: 410px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.crossing-row {
  display: grid;
  grid-template-columns: 62px minmax(160px, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
}

.crossing-direction {
  justify-content: center;
}

.crossing-direction.is-enter {
  border-color: #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.crossing-direction.is-exit {
  border-color: #d7c49c;
  background: var(--amber-soft);
  color: var(--amber);
}

.crossing-copy {
  min-width: 0;
}

.crossing-copy strong {
  display: block;
  margin-bottom: 3px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.crossing-copy p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crossing-confidence {
  min-width: 58px;
  justify-content: center;
  padding-inline: 6px;
}

.crossing-row time {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.65rem;
  font-variant-numeric: tabular-nums;
}

.history-state {
  display: grid;
  min-height: 176px;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
}

.history-state strong {
  font-size: 0.82rem;
}

.history-state p {
  max-width: 50ch;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.history-state.is-error strong,
.history-state.is-error p {
  color: var(--red);
}

.history-skeleton {
  display: grid;
  gap: 12px;
  padding: 18px 0;
}

.history-skeleton span {
  display: block;
  height: 42px;
  border-radius: 8px;
  background: #ebeae4;
  animation: skeleton-pulse 1.2s var(--ease) infinite alternate;
}

.history-skeleton span:nth-child(2) {
  animation-delay: 120ms;
}

.history-skeleton span:nth-child(3) {
  animation-delay: 240ms;
}

.text-button:disabled,
.zone-selector-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

@keyframes skeleton-pulse {
  to { opacity: 0.48; }
}

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

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .control-column {
    grid-template-columns: 1fr 1fr;
  }

  .activity-panel {
    grid-column: auto;
  }

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

  .counter-overview,
  .counter-config-body,
  .counter-operations {
    grid-template-columns: 1fr;
  }

  .energy-saver-body {
    grid-template-columns: 1fr;
  }

  .energy-saver-explanation {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .counter-settings-form {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    gap: 16px;
  }

  .topbar-status {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }

  #clock {
    width: 100%;
    text-align: right;
  }

  .dashboard {
    width: min(100% - 24px, 1500px);
    margin-top: 12px;
  }

  .control-column {
    grid-template-columns: 1fr;
  }

  .section-intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .section-intro > p {
    text-align: left;
  }

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

  .energy-saver-header {
    gap: 16px;
  }

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

  .energy-saver-device-group + .energy-saver-device-group {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .simulation-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row,
  .button {
    flex: 1;
  }

  .event-row {
    grid-template-columns: 14px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 0;
  }

  .event-detail {
    grid-column: 2 / -1;
    grid-row: 2;
  }

  .counter-totals {
    grid-template-columns: 1fr 1fr;
  }

  .counter-totals > div:nth-child(3) {
    grid-column: 1 / -1;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .off-state {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .off-state > p {
    grid-column: 2;
  }

  .zone-editor {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .coordinate-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .crossing-row {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 0;
  }

  .crossing-row time {
    grid-column: 2 / -1;
  }
}

@media (max-width: 470px) {
  .topbar {
    flex-direction: column;
  }

  .topbar-status {
    justify-content: flex-start;
  }

  #clock {
    text-align: left;
  }

  .camera-panel,
  .devices-panel,
  .activity-panel,
  .occupancy-card,
  .counter-summary,
  .authority-panel,
  .adjustment-panel,
  .crossing-panel,
  .calibration-editor,
  .counter-settings-form {
    padding: 16px;
  }

  .camera-meta #camera-fps {
    display: none;
  }

  .zone-summary {
    grid-template-columns: 1fr;
  }

  .device-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 0;
  }

  .device-actions {
    width: 100%;
  }

  .state-button {
    flex: 1;
  }

  .zone-detail {
    padding-top: 10px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .count-primary {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .counter-value {
    min-height: 4rem;
    font-size: 4.2rem;
  }

  .counter-badges {
    justify-content: flex-start;
  }

  .energy-saver-header {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .energy-saver-toggle {
    width: 100%;
    min-width: 0;
  }

  .energy-saver-toggle-copy {
    text-align: left;
  }

  .energy-saver-explanation,
  .energy-saver-device-group {
    padding: 16px;
  }

  .energy-saver-rule {
    grid-template-columns: 1fr;
  }

  .energy-saver-rule > div + div {
    padding-left: 0;
    border-left: 0;
  }

  .energy-saver-device-list li {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .energy-saver-device-tag {
    grid-column: 2;
    justify-self: start;
  }

  .counter-config > summary {
    align-items: flex-start;
    min-height: 72px;
    padding: 14px 16px;
  }

  .details-state {
    display: none;
  }

  .calibration-legend {
    left: 8px;
    right: 8px;
    bottom: 8px;
    justify-content: flex-start;
  }

  .setting-field {
    grid-template-columns: minmax(0, 1fr) 86px;
    gap: 10px;
  }

  .adjustment-actions {
    grid-template-columns: 1fr;
  }

  .crossing-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .crossing-confidence {
    grid-column: 1;
    grid-row: 2;
  }

  .crossing-row time {
    grid-column: 2;
    grid-row: 2;
  }
}

.identity-link {
  color: inherit;
  text-decoration: none;
}

.identity-title {
  display: block;
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(250, 249, 245, 0.72);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 650;
  text-decoration: none;
  transition: transform 130ms var(--ease), border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.topbar-link:hover {
  border-color: var(--green);
  background: var(--surface-strong);
  color: var(--green);
  transform: translateY(-1px);
}

.topbar-link:active {
  transform: translateY(0);
}

.notification-page {
  min-height: 100dvh;
}

.notification-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
}

.notification-shell {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(42px, 7vw, 86px) 0 64px;
}

.notification-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.45fr);
  gap: clamp(44px, 8vw, 124px);
  align-items: end;
  margin-bottom: 30px;
}

.notification-hero h1 {
  max-width: 780px;
  margin-top: 7px;
  font-size: clamp(2rem, 4.5vw, 4.45rem);
  font-weight: 590;
  letter-spacing: -0.065em;
  line-height: 0.98;
}

.notification-lede {
  max-width: 68ch;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(0.92rem, 1.4vw, 1.05rem);
  line-height: 1.65;
}

.readiness-summary {
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr);
  gap: 16px;
  min-height: 104px;
  padding: 5px 0;
}

.readiness-rule {
  width: 3px;
  height: 100%;
  min-height: 92px;
  border-radius: 99px;
  background: var(--line-strong);
}

.readiness-summary.is-ready .readiness-rule {
  background: var(--green);
}

.readiness-summary.is-disabled .readiness-rule {
  background: var(--amber);
}

.readiness-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.readiness-summary p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.notification-page-message {
  margin: 0 0 20px;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.5;
}

.notification-page-message.is-error {
  border-color: #d8aba7;
  background: var(--red-soft);
  color: var(--red);
}

.notification-page-message.is-success {
  border-color: #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.notification-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.45fr);
  gap: 20px;
  align-items: start;
}

.notification-form {
  overflow: hidden;
}

.notification-section {
  min-width: 0;
  margin: 0;
  padding: 28px 30px;
  border: 0;
}

.notification-section + .notification-section {
  border-top: 1px solid var(--line);
}

.notification-section-heading {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  margin: 0 0 22px;
  padding: 0;
}

.notification-section-heading h2,
.section-legend-title {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.notification-section-heading p,
.section-legend-copy {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.45;
}

.step-number {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--green);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.64rem;
  font-weight: 750;
}

.service-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 20px 48px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.service-facts > div {
  min-width: 0;
  padding: 13px 16px 13px 0;
}

.service-facts > div + div {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.service-facts dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.67rem;
}

.service-facts dd {
  overflow: hidden;
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-field {
  display: grid;
  gap: 5px;
  margin-left: 48px;
}

.notification-field > span {
  font-size: 0.76rem;
  font-weight: 650;
}

.notification-field > small {
  color: var(--muted);
  font-size: 0.66rem;
}

.notification-field select {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
}

.notification-field select:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.notification-section .inline-message {
  margin: 10px 0 0 48px;
}

.group-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-left: 48px;
}

.group-option {
  position: relative;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-height: 68px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.46);
  cursor: pointer;
  transition: transform 130ms var(--ease), border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.group-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.group-option:active {
  transform: translateY(0);
}

.group-option:has(input:checked) {
  border-color: #8ebda3;
  background: var(--green-soft);
}

.group-option:has(input:focus-visible) {
  outline: 3px solid rgba(39, 98, 71, 0.25);
  outline-offset: 2px;
}

.group-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.group-radio {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-strong);
}

.group-radio::after {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  content: "";
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 150ms var(--ease), transform 180ms var(--ease);
}

.group-option input:checked + .group-radio::after {
  opacity: 1;
  transform: scale(1);
}

.group-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.group-copy strong {
  overflow: hidden;
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-copy small {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.62rem;
}

.group-state {
  display: grid;
  grid-column: 1 / -1;
  min-height: 126px;
  place-content: center;
  justify-items: center;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  text-align: center;
}

.group-state strong {
  font-size: 0.78rem;
}

.group-state p {
  max-width: 52ch;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.45;
}

.group-state.is-error strong,
.group-state.is-error p {
  color: var(--red);
}

.group-skeleton {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.group-skeleton span {
  display: block;
  height: 68px;
  border-radius: 10px;
  background: #e8e7e0;
  animation: skeleton-pulse 1.2s var(--ease) infinite alternate;
}

.group-skeleton span:nth-child(2) {
  animation-delay: 120ms;
}

.group-skeleton span:nth-child(3) {
  animation-delay: 240ms;
}

.notification-toggle-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.notification-rule-block {
  margin-left: 48px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.notification-rule-block:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.notification-rule-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.notification-rule-heading h3 {
  margin-top: 4px;
  font-size: 0.94rem;
}

.notification-rule-heading p {
  max-width: 68ch;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.5;
}

.compact-toggle {
  display: grid;
  cursor: pointer;
}

.compact-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.compact-toggle input:focus-visible + .switch-track {
  outline: 3px solid rgba(39, 98, 71, 0.25);
  outline-offset: 3px;
}

.compact-toggle input:checked + .switch-track {
  border-color: var(--green);
  background: var(--green);
}

.compact-toggle input:checked + .switch-track span {
  transform: translateX(16px);
}

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

.detection-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: opacity 160ms var(--ease);
}

.detection-controls.is-disabled {
  opacity: 0.48;
}

.notification-number-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: center;
  min-height: 78px;
}

.notification-number-field + .notification-number-field {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.notification-number-field > span:first-child {
  display: grid;
  gap: 4px;
}

.notification-number-field strong {
  font-size: 0.73rem;
}

.notification-number-field small {
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.4;
}

.notification-number-field .input-suffix {
  min-height: 40px;
}

.notification-number-field input {
  min-width: 0;
  width: 100%;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: right;
}

.notification-number-field input:disabled {
  cursor: not-allowed;
}

.episode-example {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.45;
}

.crossing-rule-block .notification-toggle-list {
  margin-top: 14px;
}

.evidence-rule-block {
  padding-top: 0;
  border-top: 0;
}

.notification-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.notification-toggle > span:first-child {
  display: grid;
  gap: 4px;
}

.notification-toggle strong {
  font-size: 0.77rem;
}

.notification-toggle small {
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.4;
}

.notification-toggle input,
.master-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.notification-toggle .switch-track,
.master-toggle .switch-track {
  grid-column: 2;
  grid-row: 1;
}

.notification-toggle input:focus-visible + .switch-track,
.master-toggle input:focus-visible + .switch-track {
  outline: 3px solid rgba(39, 98, 71, 0.25);
  outline-offset: 3px;
}

.notification-toggle input:checked + .switch-track,
.master-toggle input:checked + .switch-track {
  border-color: var(--green);
  background: var(--green);
}

.notification-toggle input:checked + .switch-track span,
.master-toggle input:checked + .switch-track span {
  transform: translateX(16px);
}

.trigger-boundary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 18px 0 0 48px;
  padding: 13px 14px;
  border: 1px solid #bad2c4;
  border-radius: 9px;
  background: var(--green-soft);
  color: var(--green);
}

.trigger-boundary svg {
  margin-top: 1px;
}

.trigger-boundary p {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.5;
}

.notification-savebar {
  display: grid;
  grid-template-columns: minmax(200px, 0.8fr) minmax(280px, 1.2fr);
  gap: 24px;
  align-items: center;
  padding: 22px 30px;
  border-top: 1px solid var(--line);
  background: #eeede6;
}

.master-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  cursor: pointer;
}

.master-toggle > span:first-child {
  display: block;
}

.master-toggle strong {
  display: block;
  font-size: 0.88rem;
}

.save-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.save-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  text-align: right;
}

.save-actions .button {
  min-width: 220px;
}

.notification-page .button:disabled {
  cursor: not-allowed;
}

.notification-aside {
  display: grid;
  gap: 28px;
  padding: 28px 24px;
  border-top: 3px solid var(--green);
}

.delivery-path h2 {
  margin-top: 7px;
  font-size: 1.35rem;
}

.delivery-path ol {
  display: grid;
  gap: 0;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.delivery-path li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  min-height: 91px;
}

.delivery-path li > span {
  position: relative;
  color: var(--green);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 750;
}

.delivery-path li:not(:last-child) > span::after {
  position: absolute;
  top: 19px;
  bottom: 8px;
  left: 7px;
  width: 1px;
  background: var(--line-strong);
  content: "";
}

.delivery-path li p {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.45;
}

.delivery-path li strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 0.76rem;
}

.privacy-note {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.privacy-note p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.55;
}

.delivery-history-section {
  margin-top: 20px;
  padding: 24px 28px;
}

.delivery-history {
  display: grid;
}

.delivery-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 74px;
  border-top: 1px solid var(--line);
}

.delivery-direction,
.delivery-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 25px;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.delivery-direction.is-entry,
.delivery-direction.is-person,
.delivery-status.is-sent {
  border-color: #a9cbb7;
  background: var(--green-soft);
  color: var(--green);
}

.delivery-direction.is-exit,
.delivery-status.is-pending,
.delivery-status.is-retry,
.delivery-status.is-sending {
  border-color: #d7c49c;
  background: var(--amber-soft);
  color: var(--amber);
}

.delivery-status.is-failed {
  border-color: #d8aba7;
  background: var(--red-soft);
  color: var(--red);
}

.delivery-row-detail {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.delivery-row-detail strong {
  font-size: 0.78rem;
}

.delivery-row-detail p,
.delivery-row-detail small {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.67rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delivery-row-detail .delivery-error {
  color: var(--red);
}

.delivery-row-timing {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.delivery-row-timing time,
.delivery-row-timing small {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.61rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
  .notification-hero,
  .notification-layout {
    grid-template-columns: 1fr;
  }

  .notification-hero {
    gap: 28px;
  }

  .readiness-summary {
    max-width: 620px;
  }

  .notification-aside {
    grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr);
    gap: 36px;
  }

  .privacy-note {
    padding: 0 0 0 24px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}

@media (max-width: 700px) {
  .notification-shell {
    width: min(100% - 24px, 1320px);
    padding-top: 34px;
  }

  .notification-hero h1 {
    font-size: clamp(2.35rem, 12vw, 3.6rem);
  }

  .notification-topbar .topbar-status {
    align-items: flex-end;
  }

  .group-list,
  .group-skeleton {
    grid-template-columns: 1fr;
  }

  .notification-aside {
    grid-template-columns: 1fr;
  }

  .privacy-note {
    padding: 20px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .notification-savebar {
    grid-template-columns: 1fr;
  }

  .save-actions {
    justify-items: stretch;
  }

  .save-actions p {
    text-align: left;
  }

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

  .delivery-row {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
    padding: 11px 0;
  }

  .delivery-row-timing {
    grid-column: 2;
    grid-template-columns: auto auto auto;
    justify-content: start;
    align-items: center;
    gap: 8px;
  }
}

@media (max-width: 470px) {
  .notification-topbar .topbar-status {
    align-items: flex-start;
  }

  .notification-topbar .health-badge {
    display: none;
  }

  .notification-section,
  .notification-savebar,
  .delivery-history-section {
    padding: 18px 16px;
  }

  .notification-section-heading {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
  }

  .step-number {
    width: 30px;
    height: 30px;
  }

  .service-facts,
  .notification-field,
  .notification-section .inline-message,
  .group-list,
  .notification-rule-block,
  .trigger-boundary {
    margin-left: 0;
  }

  .detection-controls {
    grid-template-columns: 1fr;
  }

  .notification-number-field + .notification-number-field {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .service-facts {
    grid-template-columns: 1fr;
  }

  .service-facts > div + div {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .notification-toggle {
    min-height: 82px;
  }

  .delivery-history-section .panel-heading {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.counter-tracking-health {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1.45;
}

.counter-tracking-health:empty {
  display: none;
}

.counter-tracking-health.is-healthy {
  color: var(--muted, #9aa1a0);
}

.counter-tracking-health.is-degraded {
  color: var(--warning, #d7a13b);
}

.detection-zones {
  border: 1px solid var(--hairline, rgba(140, 150, 145, 0.28));
  border-radius: 10px;
  padding: 0.7rem 0.85rem 0.85rem;
  margin: 0;
}

.detection-zones legend {
  padding: 0 0.35rem;
}

.detection-zones legend small {
  display: block;
  font-weight: 400;
  opacity: 0.75;
}

.detection-zone-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.zone-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

/* Detection history */
.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.1rem;
}

.filter-chip {
  border: 1px solid var(--hairline, rgba(140, 150, 145, 0.32));
  background: transparent;
  color: inherit;
  border-radius: 999px;
  padding: 0.34rem 0.85rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.filter-chip.is-active {
  background: #276247;
  border-color: #276247;
  color: #fff;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.history-card {
  border: 1px solid var(--hairline, rgba(140, 150, 145, 0.28));
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel, #fff);
  display: flex;
  flex-direction: column;
}

.history-card.is-entry { border-left: 3px solid #2f9e63; }
.history-card.is-exit { border-left: 3px solid #d0603a; }
.history-card.is-on { border-left: 3px solid #d8a13c; }
.history-card.is-off { border-left: 3px solid #8b9490; }
.history-card.is-detection { border-left: 3px solid #3d7fb8; }

.history-media {
  padding: 0;
  border: 0;
  background: #14181a;
  cursor: zoom-in;
  display: block;
  width: 100%;
}

.history-media[disabled] { cursor: default; }

.history-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.history-thumb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: #8b9490;
  font-size: 0.82rem;
}

.history-thumb-empty span { font-size: 0.7rem; opacity: 0.7; }

.history-body {
  padding: 0.7rem 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.history-kind { font-weight: 600; font-size: 0.9rem; }
.history-body time { font-size: 0.78rem; opacity: 0.75; }
.history-meta { margin: 0; font-size: 0.75rem; opacity: 0.7; }
.history-detail { margin: 0.15rem 0 0; font-size: 0.78rem; }
.history-more { display: block; margin: 1.4rem auto 0; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 13, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 1.5rem;
}

.lightbox[hidden] { display: none; }

.lightbox-figure { margin: 0; max-width: min(1100px, 96vw); }
.lightbox-figure img { width: 100%; height: auto; border-radius: 10px; display: block; }

.lightbox-figure figcaption {
  color: #e7e9e8;
  font-size: 0.85rem;
  padding-top: 0.6rem;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.3rem;
  background: transparent;
  border: 0;
  color: #e7e9e8;
  font-size: 2.1rem;
  line-height: 1;
  cursor: pointer;
}

/* Sign-in */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: min(400px, 100%);
  padding: 2rem 1.9rem 1.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.login-card h1 { margin: 0.1rem 0 0; font-size: 1.6rem; }
.login-lede { margin: 0 0 0.6rem; font-size: 0.86rem; opacity: 0.78; line-height: 1.5; }
.login-card input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--hairline, rgba(140, 150, 145, 0.4));
  font-size: 1rem;
}


/* Per-device automation switch */
.device-automation {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
  font-size: 0.76rem;
  cursor: pointer;
  user-select: none;
}

.device-automation input { position: absolute; opacity: 0; width: 0; height: 0; }

.device-automation-track {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #8b9490;
  position: relative;
  transition: background 0.15s;
}

.device-automation-track span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.device-automation input:checked + .device-automation-track { background: #276247; }
.device-automation input:checked + .device-automation-track span { transform: translateX(14px); }
.device-automation.is-manual .device-automation-text { color: #d7a13b; font-weight: 600; }
.is-manual-only { outline: 1px dashed rgba(215, 161, 59, 0.6); outline-offset: 2px; }
