@import url("https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;700&family=Space+Grotesk:wght@400;500;700&display=swap");

:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #0f2138;
  --muted: #4f5d73;
  --line: #d9e4f3;
  --brand: #0a6bd8;
  --brand-soft: #e5f0ff;
  --normal: #0aa868;
  --alert: #f08b22;
  --fault: #d62d2d;
  --offline: #77839a;
  --comm-loss-cross: #b10d0d;
  --comm-loss-outline: rgba(255, 255, 255, 0.92);
  --shadow: 0 20px 40px rgba(4, 26, 54, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, #dfe9f8 0, #f4f7fb 38%),
    radial-gradient(circle at 88% 8%, #dae8ff 0, transparent 40%),
    var(--bg);
  min-height: 100vh;
}

a {
  color: inherit;
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 28px;
}

@media (min-width: 1700px) {
  .shell {
    max-width: calc(100vw - 52px);
    padding-left: 16px;
    padding-right: 16px;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.title {
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.92rem;
  font-weight: 600;
}

.nav-link.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.nav-user-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d5e3f8;
  background: #f5f9ff;
  color: #2f4a6d;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.83rem;
  font-weight: 700;
}

.nav-link.nav-link-logout {
  cursor: pointer;
}

.nav-link.nav-link-logout[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(430px, 100%);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.layout {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 12px;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  font-size: 1.45rem;
}

.panel h3 {
  margin: 0 0 8px;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
}

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

input,
select,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fcfdff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

button,
.button-link {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.button-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.warn {
  background: #b73131;
}

.status {
  margin-top: 10px;
  min-height: 20px;
  color: var(--muted);
  font-size: 0.88rem;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.state-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.state-normal {
  background: rgba(10, 168, 104, 0.14);
  color: var(--normal);
}

.state-alert {
  background: rgba(240, 139, 34, 0.15);
  color: var(--alert);
}

.state-fault {
  background: rgba(214, 45, 45, 0.15);
  color: var(--fault);
}

.state-offline {
  background: rgba(119, 131, 154, 0.18);
  color: var(--offline);
}

.lpr-row-normal td {
  background: #effaf1;
}

.lpr-row-warning td {
  background: #fff6ea;
}

.lpr-row-critical td {
  background: #ffefef;
}

.lpr-pill-normal {
  background: #e2f5e8;
  color: #0f8b57;
}

.lpr-pill-warning {
  background: #ffedcf;
  color: #ca7b00;
}

.lpr-pill-critical {
  background: #ffd8d8;
  color: #be2c2c;
}

.lpr-tabs-panel {
  margin-bottom: 16px;
}

.lpr-tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lpr-tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.lpr-tab-btn.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.license-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.license-pill-ok {
  background: rgba(10, 168, 104, 0.14);
  color: var(--normal);
}

.license-pill-warn {
  background: rgba(240, 139, 34, 0.15);
  color: var(--alert);
}

.license-pill-over {
  background: rgba(214, 45, 45, 0.15);
  color: var(--fault);
}

.plan-board {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #eef4ff;
  height: min(74vh, 780px);
  min-height: 520px;
}

.plan-workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.plan-palette {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
  padding: 10px;
  max-height: min(74vh, 780px);
  overflow: auto;
}

.plan-palette h3 {
  margin: 0 0 8px;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
}

.palette-toolbar {
  margin-top: 10px;
  margin-bottom: 10px;
}

.palette-filter {
  width: 100%;
  font-size: 0.86rem;
  background: #fff;
}

.palette-tree {
  display: grid;
  gap: 8px;
}

.palette-dropzone {
  margin-top: 10px;
  border: 1px dashed #b9cbdf;
  border-radius: 12px;
  background: #eff6ff;
  color: #52657f;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 12px 10px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.palette-dropzone.drop-ready {
  border-color: #c44a4a;
  background: #fff0f0;
  color: #a62a2a;
}

.tree-group,
.tree-server {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.tree-group[open],
.tree-server[open] {
  border-color: #c7d9f0;
}

.tree-summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
}

.tree-summary::-webkit-details-marker {
  display: none;
}

.tree-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  transform: translateY(-1px);
}

details[open] > .tree-summary::before {
  content: "▾";
}

.tree-body {
  display: grid;
  gap: 8px;
  padding: 0 8px 8px;
}

.palette-list {
  display: grid;
  gap: 8px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  cursor: grab;
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item.placed {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.palette-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex: 0 0 auto;
}

.palette-icon .type-icon {
  width: 20px;
  height: 20px;
}

.palette-icon .type-icon.type-icon-camera {
  width: 24px;
  height: 24px;
}

.palette-body {
  min-width: 0;
}

.palette-name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.palette-meta {
  margin: 2px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.plan-board.drop-ready {
  outline: 2px dashed var(--brand);
  outline-offset: 2px;
}

.plan-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.plan-layer {
  position: absolute;
  inset: 0;
}

.plan-node {
  position: absolute;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.plan-node-readonly {
  cursor: pointer;
}

.plan-node-visual {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(4, 26, 54, 0.25);
  pointer-events: none;
}

.type-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}

.plan-node .type-icon {
  width: 24px;
  height: 24px;
}

.plan-node .type-icon.type-icon-camera {
  width: 28px;
  height: 28px;
}

.plan-node span {
  pointer-events: none;
}

.plan-node-label {
  display: inline-block;
  max-width: 140px;
  border-radius: 999px;
  background: rgba(15, 33, 56, 0.82);
  color: #fff;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plan-node.normal {
  background: transparent;
}

.plan-node.alert {
  background: transparent;
}

.plan-node.fault {
  background: transparent;
}

.plan-node.offline {
  background: transparent;
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.legend .state-pill {
  font-size: 0.78rem;
}

.plan-switcher-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.plan-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.plan-switcher-wrap > .plan-switcher {
  margin: 0;
  flex: 1 1 auto;
}

.plan-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 8px;
}

.plan-actions .danger {
  border-color: #d37a7a;
  color: #b73131;
  background: #fff;
}

.plan-actions .danger:hover:not(:disabled) {
  background: #fdecec;
}

.plan-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.event-stream {
  display: grid;
  gap: 10px;
}

.events-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin: 10px 0 6px;
}

.events-toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
}

.events-toggle input {
  width: auto;
  margin: 0;
}

.events-filter {
  width: 100%;
  font-size: 0.86rem;
  background: #fff;
}

.events-actions {
  margin-top: auto;
}

.analytics-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin: 10px 0 8px;
}

.analytics-actions {
  margin-top: auto;
}

.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.analytics-kpi {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
}

.analytics-kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.analytics-kpi-value {
  margin: 6px 0 0;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
}

.analytics-kpi-normal .analytics-kpi-value {
  color: var(--normal);
}

.analytics-kpi-alert .analytics-kpi-value {
  color: var(--alert);
}

.analytics-kpi-fault .analytics-kpi-value {
  color: var(--fault);
}

.analytics-kpi-offline .analytics-kpi-value {
  color: var(--offline);
}

.analytics-chart-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.analytics-chart {
  margin-top: 8px;
}

.analytics-chart-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.analytics-bar-chart {
  width: 100%;
  min-height: 210px;
}

.analytics-bar-grid {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 170px;
  padding: 8px 8px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
}

.analytics-bar-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.analytics-bar-track {
  width: 100%;
  height: 132px;
  border-radius: 8px;
  background: linear-gradient(180deg, #edf3ff 0%, #e2ecfb 100%);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.analytics-bar-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 8px;
  background: linear-gradient(180deg, #3f89ff 0%, #0a6bd8 100%);
}

.analytics-bar-label {
  font-size: 0.68rem;
  line-height: 1;
  color: var(--muted);
  min-height: 0.68rem;
  white-space: nowrap;
}

.analytics-chart-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.analytics-distribution {
  display: grid;
  gap: 10px;
}

.analytics-distribution-item {
  display: grid;
  grid-template-columns: minmax(84px, auto) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.analytics-distribution-label {
  font-size: 0.82rem;
  color: var(--ink);
  font-weight: 600;
}

.analytics-distribution-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #e5edf9;
  overflow: hidden;
}

.analytics-distribution-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3f89ff 0%, #0a6bd8 100%);
}

.analytics-distribution-value {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.event-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.event-item.is-mapped {
  border-color: #bcd1eb;
  background: #f8fbff;
}

.event-item.event-state-normal {
  border-color: #70c59b;
  background: #eaf8ef;
}

.event-item.event-state-alert {
  border-color: #d95a5a;
  background: #fdecec;
}

.event-item.event-state-fault {
  border-color: #e3a24c;
  background: #fff5e9;
}

.event-item.event-state-offline {
  border-color: #9aa7bc;
  background: #eef2f8;
}

.event-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.event-head-mapping {
  align-items: center;
}

.event-head-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.event-message {
  margin: 0;
  font-weight: 600;
}

.event-code {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  background: #e6eef9;
  color: #1f3e63;
  text-transform: uppercase;
}

.event-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.event-action-btn {
  padding: 6px 9px;
  font-size: 0.78rem;
}

.event-playback-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.event-playback-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1f4a79;
}

.event-playback-icon .type-icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.6;
}

.raw-json-wrap {
  margin-top: 8px;
}

.raw-json-wrap summary {
  cursor: pointer;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 700;
}

.raw-json {
  margin: 8px 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  color: #113154;
  font-size: 0.76rem;
  line-height: 1.35;
  padding: 10px;
  overflow: auto;
  max-height: 250px;
  white-space: pre-wrap;
  word-break: break-word;
}

.synoptic-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.synoptic-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.synoptic-filter,
.synoptic-select {
  width: 100%;
  font-size: 0.86rem;
  background: #fff;
}

.tile {
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px;
  background: #fff;
}

.tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tile-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.synoptic-equipment-icon {
  flex: 0 0 auto;
}

.tile-icon {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.tile-icon .type-icon {
  width: 24px;
  height: 24px;
}

.tile-icon .type-icon.type-icon-camera {
  width: 28px;
  height: 28px;
}

.tile-icon.state-normal {
  background: rgba(10, 168, 104, 0.14);
  color: var(--normal);
}

.tile-icon.state-alert {
  background: rgba(240, 139, 34, 0.15);
  color: var(--alert);
}

.tile-icon.state-fault {
  background: rgba(214, 45, 45, 0.15);
  color: var(--fault);
}

.tile-icon.state-offline {
  background: rgba(119, 131, 154, 0.18);
  color: var(--offline);
}

.tile-icon.state-disarmed {
  background: rgba(150, 164, 184, 0.2);
  color: #7f8ca0;
}

.tile h3 {
  margin: 0;
  font-size: 1rem;
}

.tile .meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 5px;
}

.tile-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tile-actions button {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.tile-footer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.equipment-content {
  display: grid;
  gap: 12px;
}

.equipment-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.equipment-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  color: #fff;
  font-weight: 700;
}

.equipment-icon .type-icon {
  width: 24px;
  height: 24px;
}

.equipment-icon .type-icon.type-icon-camera {
  width: 28px;
  height: 28px;
}

.equipment-icon.state-normal {
  background: var(--normal);
}

.equipment-icon.state-alert {
  background: var(--alert);
}

.equipment-icon.state-fault {
  background: var(--fault);
}

.equipment-icon.state-offline {
  background: var(--offline);
}

.equipment-icon.state-disarmed {
  background: #dbe3ef;
  color: #6c7a90;
}

.comm-loss-overlay {
  position: relative;
}

.comm-loss-overlay::before,
.comm-loss-overlay::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76%;
  height: 3px;
  border-radius: 999px;
  background: var(--comm-loss-cross);
  box-shadow: 0 0 0 1px var(--comm-loss-outline);
  transform-origin: center;
  pointer-events: none;
  z-index: 2;
}

.comm-loss-overlay::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.comm-loss-overlay::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

/* HALO event detection widgets (même design que les métriques) */
.halo-metric-event-ok {
  border-color: #a5d6a7;
  background: #f1f8f1;
}

.halo-metric-event-ok .halo-metric-value {
  color: #2e7d32;
}

.halo-metric-event-alarm {
  border-color: #ef9a9a;
  background: #fff5f5;
  animation: halo-alarm-pulse 1.1s ease-in-out infinite;
}

.halo-metric-event-alarm .halo-metric-value {
  color: #c62828;
}

@keyframes halo-alarm-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* HALO config guide modal */
.halo-guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 60, 0.48);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 900;
  padding: 32px 12px;
  overflow-y: auto;
}

.halo-guide-box {
  background: #fff;
  border-radius: 12px;
  padding: 22px 26px 26px;
  max-width: 800px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.22);
}

.halo-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.halo-guide-head strong {
  font-size: 1.05rem;
}

.halo-guide-section {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.halo-guide-section h4 {
  margin: 0 0 4px 0;
  font-size: 0.93rem;
  color: var(--accent);
}

.halo-guide-url-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
}

.halo-guide-url-wrap code {
  display: block;
  background: #f4f6fa;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.74rem;
  word-break: break-all;
  flex: 1;
  line-height: 1.55;
  user-select: all;
}

.action-btn {
  width: 100%;
}

.equipment-zones {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  padding: 10px 12px;
}

.equipment-zones h4 {
  margin: 0;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  font-size: 1.05rem;
}

.zone-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.zone-save-btn {
  padding: 7px 11px;
  font-size: 0.82rem;
}

.zone-check-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.zone-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

.zone-checkbox {
  width: auto;
  margin: 0;
}

.output-action-menu {
  position: fixed;
  left: 16px;
  top: 88px;
  width: min(300px, calc(100vw - 24px));
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 14px 28px rgba(8, 24, 44, 0.28);
  padding: 10px 12px;
  z-index: 150;
}

.output-action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.output-action-title {
  display: inline-block;
  max-width: 195px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.output-action-head .output-action-close {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.output-action-meta {
  margin: 10px 0 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.output-action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.output-action-buttons .button-link,
.output-action-buttons button {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.output-action-buttons button[disabled] {
  opacity: 0.62;
  cursor: not-allowed;
}

.plan-action-menu {
  position: fixed;
  z-index: 280;
  width: min(360px, calc(100vw - 24px));
  border: 1px solid #d1deef;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 18px 34px rgba(8, 28, 56, 0.28);
  padding: 12px;
}

.plan-action-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.plan-action-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.plan-action-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.plan-action-title-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.plan-action-title {
  display: inline-block;
  max-width: 205px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.92rem;
  color: #15324f;
}

.plan-action-subtitle {
  margin-top: 2px;
  font-size: 0.74rem;
  color: #587595;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.plan-action-close {
  padding: 6px 10px;
  font-size: 0.76rem;
  flex: 0 0 auto;
}

.plan-action-meta {
  margin: 10px 0 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

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

.plan-action-btn {
  width: 100%;
  border: 1px solid #d1deef;
  background: #fff;
  border-radius: 10px;
  text-align: left;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: #17314f;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.plan-action-btn:hover {
  background: #eef5ff;
  box-shadow: 0 6px 14px rgba(20, 56, 96, 0.16);
  transform: translateY(-1px);
}

.plan-action-btn.is-primary {
  border-color: #0d5cb8;
  background: #0d5cb8;
  color: #fff;
}

.plan-action-btn.is-primary:hover {
  background: #0b4c97;
}

.plan-action-btn.is-secondary {
  border-color: #9cc0ea;
  background: #e9f3ff;
  color: #0e4a88;
}

.plan-action-btn.is-neutral {
  border-color: #c7d8ec;
  background: #f6f9fd;
  color: #2a4a6d;
}

.plan-action-btn.is-danger {
  border-color: #f1b6b6;
  background: #fff3f3;
  color: #a52e2e;
}

.plan-action-btn.is-link {
  grid-column: 1 / -1;
}

.plan-action-btn[disabled] {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.plan-context-menu {
  position: fixed;
  z-index: 260;
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(4, 26, 54, 0.25);
  padding: 6px;
}

.plan-context-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  padding: 8px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: #17314f;
}

.plan-context-menu button:hover {
  background: #edf4ff;
}

.plan-context-menu button.danger {
  color: #b73131;
}

.plan-context-menu button.danger:hover {
  background: #fdecec;
}

.live-preview-widget {
  position: fixed;
  left: 20px;
  top: 92px;
  width: min(560px, calc(100vw - 24px));
  --preview-ratio: 16 / 9;
  border-radius: 0;
  border: 1px solid #bed0e6;
  background: rgba(10, 20, 38, 0.95);
  color: #fff;
  box-shadow: 0 16px 36px rgba(3, 16, 30, 0.42);
  overflow: hidden;
  z-index: 80;
  touch-action: none;
}

.live-preview-widget.dragging {
  opacity: 0.96;
}

.live-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  cursor: grab;
  user-select: none;
}

.live-preview-widget.dragging .live-preview-head {
  cursor: grabbing;
}

.live-preview-title {
  display: inline-block;
  max-width: 240px;
  font-size: 0.9rem;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.live-preview-head .live-preview-close {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  background: transparent;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.live-preview-head .live-preview-rtsps {
  border-color: rgba(130, 214, 255, 0.55);
  color: #c7eeff;
  background: rgba(24, 70, 105, 0.25);
  padding: 6px 10px;
  font-size: 0.78rem;
}

.live-preview-body {
  padding: 10px;
}

.live-preview-video,
.live-preview-image {
  display: block;
  width: 100%;
  aspect-ratio: var(--preview-ratio, 16 / 9);
  object-fit: contain;
  border-radius: 0;
  background: #0f1928;
}

.live-preview-video[hidden],
.live-preview-image[hidden] {
  display: none !important;
}

.live-preview-info {
  margin: 8px 0 2px;
  font-size: 0.78rem;
  color: #c6dbf6;
}

.live-preview-info.is-error {
  color: #ff9d9d;
}

.halo-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-top: 10px;
}

.halo-kpi-grid {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.halo-kpi {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fbff;
}

.halo-kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.halo-kpi-value {
  margin: 6px 0 0;
  font-size: 1.36rem;
  font-weight: 700;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
}

.halo-kpi-normal {
  border-color: #cce9db;
  background: #f1fbf5;
}

.halo-kpi-alert {
  border-color: #f4dfc2;
  background: #fff8ed;
}

.halo-kpi-offline {
  border-color: #d7e2f0;
  background: #f6f9fd;
}

.halo-device-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.halo-device-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.halo-device-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.halo-device-message {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: #163250;
}

.halo-metrics-grid {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.halo-metric {
  border: 1px solid #dbe6f4;
  background: #f8fbff;
  border-radius: 10px;
  padding: 8px;
}

.halo-metric-label {
  margin: 0;
  font-size: 0.76rem;
  color: #51627a;
}

.halo-metric-value {
  margin: 5px 0 0;
  font-size: 1.04rem;
  font-weight: 700;
  font-family: "Rajdhani", "Segoe UI", sans-serif;
  color: #103050;
}

@media (max-width: 720px) {
  .shell {
    padding: 14px 12px 20px;
  }

  .title {
    font-size: 1.56rem;
  }

  .panel {
    border-radius: 14px;
    padding: 12px;
  }
}

@media (max-width: 760px) {
  .plan-workspace {
    grid-template-columns: 1fr;
  }

  .synoptic-toolbar {
    grid-template-columns: 1fr;
  }

  .plan-palette {
    max-height: none;
  }

  .plan-board {
    height: min(58vh, 620px);
    min-height: 340px;
  }

  .live-preview-widget {
    left: 12px;
    top: 84px;
    width: min(460px, calc(100vw - 24px));
  }

  .plan-action-menu {
    width: min(340px, calc(100vw - 24px));
  }

  .plan-action-grid {
    grid-template-columns: 1fr;
  }
}
