:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9dee8;
  --primary: #2454ff;
  --primary-dark: #193bc2;
  --danger: #c0362c;
  --ok: #117a43;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: #111827; color: #fff; }
.topbar a { color: #fff; margin-right: 14px; }
.brand { font-weight: 700; font-size: 18px; }
.container { max-width: 1180px; margin: 28px auto; padding: 0 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: 0 4px 20px rgba(17, 24, 39, 0.06); }
.narrow { max-width: 480px; margin: 0 auto; }
.wide { max-width: 900px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
h1 { margin: 0 0 8px; font-size: 30px; }
h2 { margin-top: 0; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
label { display: block; font-weight: 650; margin-bottom: 14px; }
input, select, textarea { width: 100%; display: block; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 14px; padding: 14px; }
legend { font-weight: 700; padding: 0 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; margin: 0; }
.help { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-top: 4px; }
button, .button { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 9px 12px; border-radius: 10px; font: inherit; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { text-decoration: none; border-color: #9aa6bd; }
.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.inline { display: inline; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full, .form-actions.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { background: #f0f2f7; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
.actions { white-space: nowrap; }
.pill { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #eef2ff; color: #243b7a; font-size: 12px; font-weight: 700; margin: 1px; }
.ok { background: #e8f7ee; color: var(--ok); }
.muted-pill { background: #f2f4f7; color: #475467; }
.flash { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--line); background: #fff; }
.flash.success { border-color: #9dd8b2; background: #ecfdf3; }
.flash.error { border-color: #e7aaa4; background: #fff0ef; }
code { display: inline-block; max-width: 320px; overflow: auto; padding: 4px 6px; background: #f2f4f7; border-radius: 6px; }
.player-card video { width: 100%; max-height: 72vh; background: #000; border-radius: 12px; }
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 10px; }
  .page-head { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
}
.notice { border: 1px solid #b7caef; background: #eef4ff; border-radius: 12px; padding: 12px 14px; margin: 12px 0 18px; }
.notice.warn { border-color: #efc36b; background: #fff8e8; }
.compact { margin: 8px 0 0 18px; padding: 0; }
.compact li { margin: 4px 0; }
td code, .notice code { max-width: 520px; white-space: nowrap; }
.offline { background: #fff1f0; color: #b42318; }
.card-head, .matrix-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.stream-card h2, .matrix-card h2 { margin-bottom: 4px; }
.matrix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.matrix-card { padding: 18px; position: relative; overflow: hidden; }
.matrix-card.online-card { border-color: #a6e7bc; }
.matrix-card.offline-card { border-color: #f2b8b5; }
.matrix-preview { height: 150px; border-radius: 12px; background: #111827; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: 0.08em; margin: 14px 0; }
.matrix-card.offline-card .matrix-preview { background: #344054; color: #d0d5dd; }
.matrix-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0 0 14px; }
.matrix-meta div { min-width: 0; }
.matrix-meta dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.matrix-meta dd { margin: 2px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.matrix-actions { display: flex; flex-wrap: wrap; gap: 8px; white-space: normal; }
details { margin-top: 12px; }
details code { max-width: 100%; white-space: nowrap; }
@media (max-width: 760px) {
  .matrix-grid { grid-template-columns: 1fr; }
  .matrix-meta { grid-template-columns: 1fr; }
  .actions { white-space: normal; }
}

/* Operationele matrix met live players */
.matrix-page { margin-top: -12px; }
.compact-head { margin-bottom: 12px; }
.live-matrix {
  --matrix-cols: 2;
  display: grid;
  grid-template-columns: repeat(var(--matrix-cols), minmax(0, 1fr));
  gap: 10px;
  height: calc(100vh - 178px);
  min-height: 460px;
}
.live-tile {
  min-width: 0;
  min-height: 0;
  background: #05070d;
  border: 1px solid #202736;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 8px 28px rgba(17,24,39,.12);
}
.tile-header {
  position: absolute;
  z-index: 2;
  left: 10px;
  right: 10px;
  top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  pointer-events: none;
}
.tile-header .pill { text-shadow: none; opacity: .94; }
.tile-frame { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.player-embed-body { margin: 0; background: #000; overflow: hidden; width: 100vw; height: 100vh; }
.embed-video { width: 100vw; height: 100vh; object-fit: contain; background: #000; display: block; }
.embed-overlay {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 8px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 4px rgba(0,0,0,.9);
  pointer-events: none;
}
.embed-title { font-weight: 700; }
@media (max-width: 900px) {
  .live-matrix { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .live-tile { height: 58vh; }
}
.pending { background: #fff8e8; color: #92400e; }

/* Futurised dark operation style */
:root {
  --bg: #000000;
  --card: #071315;
  --text: #f3f7f7;
  --muted: #9fb3b6;
  --line: #f3f7f7;
  --primary: #f3f7f7;
  --primary-dark: #d9e3e5;
  --danger: #ff5b57;
  --ok: #3cff9c;
  --panel: #102f33;
  --panel2: #1a2224;
}
html, body { min-height: 100%; background: #000; color: var(--text); }
body { background: #000; }
a { color: #f3f7f7; }
a:hover { color: #fff; text-decoration: none; }
.topbar {
  background: #000;
  border-bottom: 2px solid #f3f7f7;
  color: #f3f7f7;
  min-height: 58px;
}
.topbar a { color: #f3f7f7; }
.brand, .matrix-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .02em; }
.brand-logo { width: 30px; height: 30px; object-fit: contain; display: inline-block; }
.container { max-width: 1280px; }
.card, .flash, .notice, fieldset, .table-wrap, .matrix-card, .live-tile {
  background: var(--card);
  border-color: rgba(243,247,247,.75);
  box-shadow: none;
}
input, select, textarea {
  background: #000;
  color: var(--text);
  border-color: rgba(243,247,247,.75);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f3f7f7; outline-offset: 1px; }
button, .button {
  background: #000;
  color: #f3f7f7;
  border: 2px solid #f3f7f7;
  font-weight: 700;
}
button:hover, .button:hover { background: #f3f7f7; color: #000; border-color: #f3f7f7; }
.primary { background: #f3f7f7; color: #000; border-color: #f3f7f7; }
.primary:hover { background: #000; color: #f3f7f7; }
.danger { background: #000; color: #ff716d; border-color: #ff716d; }
.danger:hover { background: #ff716d; color: #000; }
th { background: #071315; color: #f3f7f7; border-bottom-color: rgba(243,247,247,.75); }
td, th { border-bottom-color: rgba(243,247,247,.28); }
code { background: #000; color: #f3f7f7; border: 1px solid rgba(243,247,247,.35); }
.pill { background: #102f33; color: #f3f7f7; border: 1px solid rgba(243,247,247,.32); }
.ok { background: rgba(60,255,156,.12); color: #3cff9c; border-color: rgba(60,255,156,.75); }
.offline { background: rgba(255,91,87,.12); color: #ff716d; border-color: rgba(255,91,87,.65); }
.pending { background: rgba(255,210,80,.13); color: #ffd872; border-color: rgba(255,210,80,.55); }
.muted-pill { background: #111; color: #c9d5d7; }
.notice { background: #071315; }
.notice.warn { background: #1d1600; border-color: #ffd872; }
.player-card video { border: 2px solid rgba(243,247,247,.75); }

/* Fullscreen live matrix: only a title bar and stream/player tiles */
.matrix-shell-body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
  margin: 0;
}
.matrix-titlebar {
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: #000;
  border-bottom: 3px solid #f3f7f7;
}
.matrix-brand {
  color: #f3f7f7;
  font-size: 18px;
  text-decoration: none;
}
.matrix-brand:hover { text-decoration: none; }
.matrix-only {
  width: 100vw;
  height: calc(100vh - 54px);
  padding: 0;
  margin: 0;
  background: #000;
  overflow: hidden;
}
.live-matrix-full {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--matrix-cols), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  grid-auto-flow: row;
  gap: 0;
  align-items: stretch;
  justify-items: stretch;
}
.live-tile-clean {
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.tile-frame {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #000;
}
.player-embed-body.clean-embed {
  background: #000;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}
.clean-embed .embed-video {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background: #000;
  display: block;
}
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
@media (max-width: 900px) {
  .live-matrix-full { grid-template-columns: repeat(var(--matrix-cols), minmax(0, 1fr)); height: 100%; }
  .live-matrix-full .live-tile { height: auto; }
}
/* Final operational matrix layout: exact columns, top-left, bordered screens. */
.matrix-only {
  width: 100vw;
  height: calc(100vh - 54px);
  padding: 10px;
  margin: 0;
  background: #000;
  overflow: hidden;
  box-sizing: border-box;
}
.live-matrix-full {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--matrix-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--matrix-rows), minmax(0, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: minmax(0, 1fr);
  gap: 10px;
  align-content: start;
  justify-content: start;
  align-items: stretch;
  justify-items: stretch;
}
.live-tile-screen {
  border: 3px solid #f3f7f7;
  border-radius: 0;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(243,247,247,.28);
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}
.matrix-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}
.live-tile-screen.matrix-test-fallback::before {
  content: "TESTBEELD";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f3f7f7;
  font: 800 clamp(24px, 5vw, 72px)/1 Arial, sans-serif;
  background: linear-gradient(135deg, #12373b 0 35%, #1d2325 35% 60%, #000 60% 100%);
}
@media (max-width: 900px) {
  .matrix-only { padding: 8px; }
  .live-matrix-full {
    grid-template-columns: repeat(var(--matrix-cols), minmax(0, 1fr));
    grid-template-rows: repeat(var(--matrix-rows), minmax(0, 1fr));
    height: 100%;
  }
  .live-matrix-full .live-tile { height: auto; }
}

/* Matrix polish: exact configured columns, stable top-left placement, no centering. */
.matrix-shell-body {
  background: #000 !important;
}
.matrix-titlebar {
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid rgba(243,247,247,.22);
  background: linear-gradient(180deg, #071618 0%, #000 100%) !important;
}
.matrix-only {
  height: calc(100vh - 52px) !important;
  padding: 10px !important;
  background: #000 !important;
  overflow: hidden !important;
}
.live-matrix-full {
  grid-template-columns: repeat(var(--matrix-cols), minmax(0, 1fr)) !important;
  grid-template-rows: repeat(var(--matrix-rows), minmax(0, 1fr)) !important;
  grid-auto-flow: row !important;
  gap: 10px !important;
  align-content: start !important;
  justify-content: start !important;
  align-items: stretch !important;
  justify-items: stretch !important;
}
.live-tile-screen {
  border: 2px solid rgba(243,247,247,.92) !important;
  border-radius: 16px !important;
  background: #020607 !important;
  box-shadow: 0 0 0 1px rgba(18,55,59,.95), 0 10px 32px rgba(0,0,0,.55), inset 0 0 0 1px rgba(243,247,247,.10) !important;
  overflow: hidden !important;
  display: flex !important;
}
.matrix-video {
  flex: 1 1 auto !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  object-fit: cover !important;
  background: #000 !important;
  border-radius: 14px !important;
  display: block !important;
}
@media (max-width: 900px) {
  .live-matrix-full {
    grid-template-columns: repeat(var(--matrix-cols), minmax(0, 1fr)) !important;
    grid-template-rows: repeat(var(--matrix-rows), minmax(0, 1fr)) !important;
  }
}


/* Matrix aspect-ratio fix: tiles preserve video proportions and never crop. */
.matrix-only {
  --matrix-tile-w: 320px;
  --matrix-tile-h: 180px;
}
.live-matrix-full {
  grid-template-columns: repeat(var(--matrix-cols), var(--matrix-tile-w)) !important;
  grid-template-rows: repeat(var(--matrix-rows), var(--matrix-tile-h)) !important;
  grid-auto-rows: var(--matrix-tile-h) !important;
  width: 100% !important;
  height: 100% !important;
  align-content: start !important;
  justify-content: start !important;
  align-items: start !important;
  justify-items: start !important;
}
.live-tile-screen {
  width: var(--matrix-tile-w) !important;
  height: var(--matrix-tile-h) !important;
  box-sizing: border-box !important;
  display: block !important;
  padding: 0 !important;
}
.matrix-video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  border-radius: 14px !important;
  background: #000 !important;
}

/* Matrix polish: balanced outer spacing, non-cropping video and clean screen frames. */
.matrix-only {
  padding: 14px !important;
  box-sizing: border-box !important;
}
.live-matrix-full {
  gap: 14px !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
  align-content: start !important;
  justify-content: start !important;
}
.live-tile-screen {
  border: 2px solid rgba(243,247,247,.82) !important;
  border-radius: 18px !important;
  overflow: hidden !important;
  background: #000 !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 10px 28px rgba(0,0,0,.6) !important;
}
.matrix-video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  background: #000 !important;
  border-radius: 14px !important;
  display: block !important;
}
@media (max-width: 900px) {
  .matrix-only { padding: 10px !important; }
  .live-matrix-full { gap: 10px !important; }
}

/* Final matrix spacing fix: keep a visible right gutter equal to the left gutter. */
.matrix-only {
  padding: 14px 18px 14px 18px !important;
}
@media (max-width: 900px) {
  .matrix-only { padding: 10px 12px 10px 12px !important; }
}

/* Grouped stream administration */
.stream-group, .admin-stream-group { margin-top: 24px; }
.group-title { font-size: 1rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.group-title::after { content: ""; height: 1px; flex: 1; background: rgba(255,255,255,.12); }
.mini-toggle { min-width: 112px; margin: 2px 4px 2px 0; padding: 6px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.05); color: var(--muted); font-size: .78rem; font-weight: 800; }
.mini-toggle.is-on { color: #05170d; background: #a6e7bc; border-color: #a6e7bc; }
.access-tags { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }

/* RTMP key modal */
.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  background: #050809;
  color: #f3f7f7;
  box-shadow: 0 30px 80px rgba(0,0,0,.75);
  padding: 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close { border: 0; background: transparent; color: #f3f7f7; font-size: 2rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; margin: 6px 0 14px; }
.copy-row input { width: 100%; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
body.modal-open { overflow: hidden; }
.button.small { padding: 6px 10px; font-size: .82rem; }

/* Matrix stream name overlay. Keep pointer-events disabled so native video controls remain usable. */
.live-tile-screen { position: relative !important; }
.matrix-name-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  max-width: 86%;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  background: rgba(0,0,0,.48);
  color: #fff;
  font-weight: 800;
  letter-spacing: .02em;
  text-shadow: 0 2px 8px rgba(0,0,0,.85);
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: .9;
}
.live-tile-screen:hover .matrix-name-overlay,
.live-tile-screen:focus-within .matrix-name-overlay { opacity: .35; }
.matrix-video { object-fit: contain !important; }

/* Admin overview polish: full-width blocks, compact toggles and modal previews. */
.admin-wide {
  width: calc(100vw - 36px);
  margin-left: calc(50% - 50vw + 18px);
  margin-right: calc(50% - 50vw + 18px);
}
.admin-wide .table-wrap { width: 100%; }
.admin-wide table { min-width: 1180px; width: 100%; }
.source-cell { white-space: nowrap; }
.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 6px;
  align-items: center;
  max-width: 260px;
}
.toggle-grid .inline { display: block; }
.toggle-grid .mini-toggle { width: 100%; min-width: 0; margin: 0; padding: 7px 9px; }
.matrix-toggles { max-width: 300px; }
.admin-wide td.actions { min-width: 310px; }
.admin-wide td.actions .button,
.admin-wide td.actions button { margin-bottom: 6px; }
.frame-modal-card { width: min(1200px, calc(100vw - 28px)); height: min(820px, calc(100vh - 28px)); display: flex; flex-direction: column; padding: 16px; }
.modal-iframe { flex: 1; width: 100%; min-height: 0; border: 1px solid rgba(255,255,255,.22); border-radius: 16px; background: #000; }
.embed-body { background: #000; margin: 0; min-height: 100vh; overflow: hidden; }
.embed-watch { height: 100vh; padding: 14px; display: flex; }
.embed-player-card { width: 100%; flex: 1; padding: 14px; display: flex; flex-direction: column; min-height: 0; }
.embed-player-title { font-size: 1rem; font-weight: 800; margin: 0 0 10px; color: #f3f7f7; }
.embed-player-card video { flex: 1; min-height: 0; max-height: none; object-fit: contain; }
.embed-player-card #status { margin-top: 8px; }

/* Matrix label belongs to the player chrome, not to the center of the video. */
.live-tile-screen { overflow: hidden; }
.matrix-name-overlay {
  left: 0 !important;
  right: 0 !important;
  top: 0 !important;
  transform: none !important;
  max-width: none !important;
  width: 100% !important;
  border-radius: 0 !important;
  border-width: 0 0 1px 0 !important;
  padding: 7px 12px !important;
  background: linear-gradient(180deg, rgba(0,0,0,.82), rgba(0,0,0,.44)) !important;
  text-align: left;
  font-size: .92rem;
  opacity: .96 !important;
}
.live-tile-screen:hover .matrix-name-overlay,
.live-tile-screen:focus-within .matrix-name-overlay { opacity: .96 !important; }
.matrix-video { border-radius: 14px; }


/* Admin streams table final polish: full-width rows, checkbox matrix toggles and modal edit/view/debug. */
.admin-streams-page .page-head { padding-left: 0; padding-right: 0; }
.admin-stream-table-wrap { padding: 0; overflow-x: auto; }
.admin-stream-table { width: 100% !important; min-width: 1060px !important; border-collapse: separate; border-spacing: 0; table-layout: auto; }
.admin-stream-table th,
.admin-stream-table td { vertical-align: middle !important; padding: 12px 14px; }
.admin-stream-table thead th { white-space: nowrap; }
.admin-stream-table tbody tr { min-height: 58px; }
.admin-stream-table .name-cell { width: 26%; font-size: 1rem; }
.admin-stream-table .source-cell { width: 150px; white-space: nowrap; }
.admin-stream-table .check-cell { width: 92px; text-align: center; }
.admin-stream-table .status-cell { width: 115px; white-space: nowrap; }
.admin-stream-table .key-cell { width: 100px; text-align: center; white-space: nowrap; }
.admin-stream-table .action-cell { width: 430px; white-space: nowrap; display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.admin-stream-table .action-cell .inline { display: inline-flex; margin: 0; }
.admin-stream-table .action-cell .button,
.admin-stream-table .action-cell button,
.admin-stream-table .row-button { height: 34px; min-height: 34px; display: inline-flex; align-items: center; justify-content: center; margin: 0 !important; padding: 0 12px; line-height: 1; }
.source-pill { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; }
.matrix-check-form { display: inline-flex; align-items: center; justify-content: center; margin: 0; }
.admin-check-toggle { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 26px; cursor: pointer; }
.admin-check-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.admin-check-toggle span { position: relative; width: 44px; height: 26px; border-radius: 999px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); transition: background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.admin-check-toggle span::after { content: ''; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; border-radius: 50%; background: #8b969b; transition: transform .16s ease, background .16s ease; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.admin-check-toggle input:checked + span { background: rgba(166,231,188,.28); border-color: #a6e7bc; box-shadow: 0 0 0 3px rgba(166,231,188,.08); }
.admin-check-toggle input:checked + span::after { transform: translateX(18px); background: #a6e7bc; }
.admin-check-toggle:focus-within span { outline: 2px solid rgba(166,231,188,.55); outline-offset: 2px; }
.frame-modal-card { width: min(1280px, calc(100vw - 28px)); height: min(900px, calc(100vh - 28px)); }
@media (max-width: 900px) {
  .admin-stream-table { min-width: 920px !important; }
  .admin-stream-table .action-cell { width: 360px; }
}

/* Admin streams grouped compact table + dropdown menu refinements. */
.topbar nav { align-items: center; }
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-drop-button {
  border: 1px solid rgba(255,255,255,.20);
  background: rgba(255,255,255,.05);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}
.nav-drop-button::after { content: " ▾"; color: var(--muted); }
.nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  display: none;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 14px;
  background: #050809;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
  z-index: 30;
}
.nav-dropdown:hover .nav-menu,
.nav-dropdown:focus-within .nav-menu { display: grid; gap: 4px; }
.nav-menu a { display: block; padding: 8px 10px; border-radius: 10px; white-space: nowrap; }
.nav-menu a:hover { background: rgba(166,231,188,.12); text-decoration: none; }

.admin-streams-compact {
  width: min-content;
  max-width: calc(100vw - 36px);
  margin-left: auto !important;
  margin-right: auto !important;
}
.admin-streams-head { width: 100%; }
.admin-streams-stack { display: grid; gap: 16px; justify-items: center; }
.collapsible-stream-group {
  width: max-content;
  max-width: calc(100vw - 36px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  background: rgba(255,255,255,.035);
  overflow: clip;
}
.collapsible-stream-group > summary { list-style: none; }
.collapsible-stream-group > summary::-webkit-details-marker { display: none; }
.group-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
}
.group-caret::before { content: "▾"; color: var(--muted); display: inline-block; transition: transform .15s ease; }
.collapsible-stream-group:not([open]) .group-caret::before { transform: rotate(-90deg); }
.group-title-text { font-weight: 900; letter-spacing: .05em; text-transform: uppercase; color: #f3f7f7; }
.group-count { color: var(--muted); font-weight: 800; font-size: .85rem; }
.group-bulk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.22);
}
.group-bulk-label { color: var(--muted); font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; margin-left: 8px; }
.group-bulk-label:first-child { margin-left: 0; }
.group-bulk-form { display: inline-flex; margin: 0; }
.group-bulk-form .button { min-height: 30px; height: 30px; padding: 0 10px; }

.admin-stream-table-wrap { width: max-content !important; max-width: calc(100vw - 36px); overflow-x: auto; border-radius: 0 0 18px 18px; }
.admin-stream-table.compact-stream-table {
  width: auto !important;
  min-width: 0 !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
}
.admin-stream-table col.col-name { width: 240px; }
.admin-stream-table col.col-source { width: 145px; }
.admin-stream-table col.col-internal { width: 92px; }
.admin-stream-table col.col-external { width: 92px; }
.admin-stream-table col.col-status { width: 110px; }
.admin-stream-table col.col-key { width: 84px; }
.admin-stream-table col.col-actions { width: 388px; }
.admin-stream-table th,
.admin-stream-table td {
  border-bottom: 1px solid rgba(255,255,255,.10) !important;
  vertical-align: middle !important;
}
.admin-stream-table tr:last-child td { border-bottom: 0 !important; }
.admin-stream-table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.admin-stream-table .name-cell { width: auto !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-stream-table .source-cell,
.admin-stream-table .status-cell,
.admin-stream-table .key-cell,
.admin-stream-table .check-cell { width: auto !important; text-align: center; }
.admin-stream-table .source-cell { text-align: left; }
.admin-stream-table .check-cell { padding-top: 0 !important; padding-bottom: 0 !important; }
.admin-stream-table .matrix-check-form { height: 100%; min-height: 58px; display: flex !important; align-items: center !important; justify-content: center !important; }
.admin-stream-table .key-cell { text-align: center !important; }
.admin-stream-table .key-cell .row-button { width: 58px; }
.admin-stream-table .key-head { text-align: center; }
.admin-stream-table .action-cell {
  display: table-cell !important;
  width: auto !important;
  white-space: nowrap;
}
.action-row { display: inline-flex; flex-wrap: nowrap; gap: 6px; align-items: center; justify-content: flex-start; }
.action-row .inline { margin: 0; display: inline-flex; }
.action-row .button,
.action-row button,
.admin-stream-table .row-button {
  height: 34px !important;
  min-height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 12px !important;
  line-height: 1 !important;
}
.header-link { color: inherit; text-decoration: none; border-bottom: 1px dotted rgba(255,255,255,.35); }
.header-link:hover { color: #a6e7bc; border-bottom-color: #a6e7bc; text-decoration: none; }

.embed-admin-body { background: #000; min-height: 100vh; margin: 0; }
.embed-admin-main { padding: 16px; }
.modal-form-card { margin: 0 !important; width: 100% !important; box-sizing: border-box; }
.modal-form-card h1 { margin-top: 0; }
@media (max-width: 900px) {
  .admin-streams-compact, .collapsible-stream-group, .admin-stream-table-wrap { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px); }
  .admin-stream-table col.col-actions { width: 360px; }
  .group-bulk-row { flex-wrap: wrap; }
}

/* Final admin/menu/access refinements */
.nav-dropdown.hover-dropdown { position: relative; padding: 10px 0; margin-top: -10px; margin-bottom: -10px; }
.nav-dropdown.hover-dropdown .nav-menu { top: 100%; margin-top: 0; min-width: 160px; }
.nav-dropdown.hover-dropdown:hover .nav-menu,
.nav-dropdown.hover-dropdown:focus-within .nav-menu { display: grid !important; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: #ff716d; color: #000; font-size: 12px; font-weight: 900; }

.admin-streams-stack { align-items: center; }
.collapsible-stream-group { width: max-content !important; max-width: calc(100vw - 36px) !important; min-width: min(1060px, calc(100vw - 36px)); }
.collapsible-stream-group .group-summary { width: 100%; min-width: inherit; }
.collapsible-stream-group:not([open]) { min-width: min(1060px, calc(100vw - 36px)); }
.group-bulk-row { display: none !important; }
.matrix-toggle-head { text-align: center !important; vertical-align: middle !important; }
.group-toggle-icons { display: inline-flex; gap: 4px; justify-content: center; margin-top: 4px; }
.icon-button { width: 24px; height: 22px; min-height: 22px; padding: 0 !important; border-radius: 8px; font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; opacity: .8; }
.icon-button:hover { opacity: 1; }
.admin-stream-table.compact-stream-table { border-collapse: collapse !important; }
.admin-stream-table th, .admin-stream-table td { vertical-align: middle !important; }
.admin-stream-table tr td { border-bottom: 1px solid rgba(243,247,247,.28) !important; }
.admin-stream-table .check-cell { text-align: center !important; vertical-align: middle !important; }
.admin-stream-table .matrix-check-form { min-height: 52px !important; display: flex !important; align-items: center !important; justify-content: center !important; }
.admin-stream-table .key-cell { text-align: center !important; }
.admin-stream-table .key-cell .row-button { margin: 0 auto !important; height: 34px; }
.admin-stream-table .action-cell { display: table-cell !important; text-align: left; vertical-align: middle !important; }
.admin-stream-table .action-row { display: inline-flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.admin-stream-table-wrap { width: max-content !important; max-width: calc(100vw - 36px) !important; }
.admin-stream-table { width: max-content !important; min-width: 0 !important; }
.admin-stream-table col.col-name { width: 240px !important; }
.admin-stream-table col.col-source { width: 118px !important; }
.admin-stream-table col.col-internal { width: 94px !important; }
.admin-stream-table col.col-external { width: 94px !important; }
.admin-stream-table col.col-status { width: 112px !important; }
.admin-stream-table col.col-key { width: 78px !important; }
.admin-stream-table col.col-actions { width: 410px !important; }

.stream-form-card.modal-form-card { max-width: 860px; margin: 0 auto; }
.stream-dynamic-form [hidden] { display: none !important; }
.access-table-wrap code { max-width: 190px; }
.access-table-wrap .copy-row input { min-width: 280px; }

@media (max-width: 980px) {
  .collapsible-stream-group, .admin-stream-table-wrap { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px) !important; }
}

/* Iframe source type */
.matrix-iframe,
.player-iframe,
.embed-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #050505;
  border-radius: inherit;
}
.live-tile-iframe {
  background: #050505;
}
.player-card .iframe-shell {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 420px;
  border: 1px solid rgba(243,247,247,.16);
  border-radius: 18px;
  overflow: hidden;
  background: #050505;
}
.embed-player-card .iframe-shell,
.embed-watch .iframe-shell {
  min-height: min(70vh, 720px);
}
.player-embed-body .embed-iframe {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

/* No chrome in operational matrix: full viewport for tiles only. */
.matrix-shell-body .matrix-only {
  height: 100vh !important;
  padding: 14px 18px !important;
}

/* Matrix density + dynamic columns polish */
.matrix-shell-body .matrix-only {
  padding: 6px 8px !important;
}
.live-matrix-full {
  gap: 3px !important;
  justify-content: start !important;
  align-content: start !important;
}
.live-tile-screen {
  border-width: 1px !important;
  border-radius: 12px !important;
}
.matrix-video,
.matrix-iframe {
  border-radius: 10px !important;
}
.external-black-body {
  min-height: 100vh;
  margin: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.external-black-logo {
  width: min(220px, 32vw);
  height: auto;
  opacity: .95;
}
.settings-check { align-items: center; }
.compact-access-table td,
.compact-access-table th { vertical-align: middle; }
.access-edit-table input[type="text"],
.access-edit-table input[type="email"],
.access-edit-table input:not([type]) {
  min-width: 120px;
}
.access-edit-table .copy-row input { min-width: 300px; }

/* Admin table side spacing and long-name wrapping refinement. */
.admin-streams-page.admin-streams-compact {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  padding-left: clamp(28px, 3.2vw, 58px);
  padding-right: clamp(28px, 3.2vw, 58px);
}
.admin-streams-page .admin-streams-head {
  max-width: none;
}
.admin-streams-stack {
  width: 100%;
  align-items: center;
}
.collapsible-stream-group {
  max-width: calc(100vw - clamp(56px, 6.4vw, 116px)) !important;
}
.admin-stream-table-wrap {
  max-width: calc(100vw - clamp(56px, 6.4vw, 116px)) !important;
}
.admin-stream-table col.col-name {
  width: clamp(260px, 24vw, 420px) !important;
}
.admin-stream-table .name-cell {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  line-height: 1.25 !important;
  vertical-align: middle !important;
}
.admin-stream-table .name-cell strong {
  display: block;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
.admin-stream-table td,
.admin-stream-table th {
  vertical-align: middle !important;
}
@media (max-width: 900px) {
  .admin-streams-page.admin-streams-compact {
    padding-left: 18px;
    padding-right: 18px;
  }
  .collapsible-stream-group,
  .admin-stream-table-wrap {
    max-width: calc(100vw - 36px) !important;
  }
}


/* Iframe matrix span sizing + muted autoplay build */
.live-tile-screen {
  grid-column: span var(--tile-col-span, 1) !important;
  grid-row: span var(--tile-row-span, 1) !important;
}
.live-tile-iframe .matrix-iframe {
  width: 100% !important;
  height: 100% !important;
}
.stream-dynamic-form [data-source-field="iframe"] select {
  width: 100%;
}

/* Admin table viewport fit: balanced side spacing, no horizontal scrollbars. */
.admin-streams-page.admin-streams-compact {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding-left: clamp(18px, 2.4vw, 42px) !important;
  padding-right: clamp(18px, 2.4vw, 42px) !important;
  box-sizing: border-box !important;
}
.admin-streams-page .admin-streams-head,
.admin-streams-page .page-head {
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box !important;
}
.admin-streams-stack {
  width: 100% !important;
  max-width: 100% !important;
  justify-items: stretch !important;
  align-items: stretch !important;
}
.collapsible-stream-group {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}
.collapsible-stream-group .group-summary {
  min-width: 0 !important;
}
.admin-stream-table-wrap {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}
.admin-stream-table,
.admin-stream-table.compact-stream-table {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
  box-sizing: border-box !important;
}
.admin-stream-table col.col-name { width: 24% !important; }
.admin-stream-table col.col-source { width: 9% !important; }
.admin-stream-table col.col-internal { width: 7.5% !important; }
.admin-stream-table col.col-external { width: 7.5% !important; }
.admin-stream-table col.col-status { width: 9% !important; }
.admin-stream-table col.col-key { width: 7% !important; }
.admin-stream-table col.col-actions { width: 36% !important; }
.admin-stream-table th,
.admin-stream-table td {
  box-sizing: border-box !important;
  padding-left: clamp(8px, .75vw, 14px) !important;
  padding-right: clamp(8px, .75vw, 14px) !important;
  vertical-align: middle !important;
}
.admin-stream-table .name-cell,
.admin-stream-table .name-cell strong {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  hyphens: auto !important;
  line-height: 1.25 !important;
}
.admin-stream-table .source-cell,
.admin-stream-table .status-cell,
.admin-stream-table .key-cell,
.admin-stream-table .check-cell,
.admin-stream-table .action-cell {
  overflow-wrap: anywhere !important;
}
.admin-stream-table .action-cell {
  white-space: normal !important;
}
.admin-stream-table .action-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 6px !important;
  max-width: 100% !important;
}
.admin-stream-table .action-row .button,
.admin-stream-table .action-row button,
.admin-stream-table .row-button {
  flex: 0 0 auto !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
@media (max-width: 1180px) {
  .admin-stream-table col.col-name { width: 22% !important; }
  .admin-stream-table col.col-source { width: 9% !important; }
  .admin-stream-table col.col-internal { width: 8% !important; }
  .admin-stream-table col.col-external { width: 8% !important; }
  .admin-stream-table col.col-status { width: 9% !important; }
  .admin-stream-table col.col-key { width: 7% !important; }
  .admin-stream-table col.col-actions { width: 37% !important; }
  .admin-stream-table th,
  .admin-stream-table td { padding-left: 7px !important; padding-right: 7px !important; }
  .admin-stream-table .action-row { gap: 5px !important; }
  .admin-stream-table .action-row .button,
  .admin-stream-table .action-row button,
  .admin-stream-table .row-button { padding-left: 8px !important; padding-right: 8px !important; }
}
@media (max-width: 860px) {
  .admin-streams-page.admin-streams-compact {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .admin-stream-table th,
  .admin-stream-table td { font-size: .82rem !important; padding-left: 5px !important; padding-right: 5px !important; }
  .admin-stream-table col.col-name { width: 24% !important; }
  .admin-stream-table col.col-source { width: 10% !important; }
  .admin-stream-table col.col-internal { width: 8% !important; }
  .admin-stream-table col.col-external { width: 8% !important; }
  .admin-stream-table col.col-status { width: 9% !important; }
  .admin-stream-table col.col-key { width: 7% !important; }
  .admin-stream-table col.col-actions { width: 34% !important; }
  .source-pill,
  .admin-stream-table .row-button,
  .admin-stream-table .action-row .button,
  .admin-stream-table .action-row button { min-height: 30px !important; height: 30px !important; padding-left: 6px !important; padding-right: 6px !important; }
}

/* Matrix iframe span fix: span values must change the actual rendered tile size. */
.live-matrix-full {
  grid-auto-flow: row dense !important;
}
.live-matrix-full .live-tile-screen {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  align-self: stretch !important;
  justify-self: stretch !important;
}
.live-matrix-full .live-tile-iframe {
  grid-column: span var(--tile-col-span, 1) !important;
  grid-row: span var(--tile-row-span, 1) !important;
}
.live-matrix-full .live-tile-iframe .matrix-iframe {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  display: block !important;
}

/* Final adjustments: admin table uses viewport with 20px gutters, access spacing, viewer-safe switches. */
.container:has(.admin-streams-page),
.container:has(.access-page) {
  max-width: none !important;
  width: 100% !important;
  margin: 20px 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.admin-streams-page.admin-streams-compact {
  width: calc(100vw - 40px) !important;
  max-width: calc(100vw - 40px) !important;
  margin-left: 20px !important;
  margin-right: 20px !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.admin-streams-page .admin-streams-head { width: 100% !important; }
.admin-streams-stack { width: 100% !important; align-items: stretch !important; justify-items: stretch !important; }
.collapsible-stream-group,
.collapsible-stream-group:not([open]) {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}
.admin-stream-table-wrap {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}
.admin-stream-table.compact-stream-table,
.admin-stream-table {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}
.admin-stream-table col.col-name { width: 28% !important; }
.admin-stream-table col.col-source { width: 9% !important; }
.admin-stream-table col.col-internal { width: 7% !important; }
.admin-stream-table col.col-external { width: 7% !important; }
.admin-stream-table col.col-status { width: 8.5% !important; }
.admin-stream-table col.col-key { width: 6.5% !important; }
.admin-stream-table col.col-actions { width: 34% !important; }
.admin-stream-table th,
.admin-stream-table td { padding-left: 8px !important; padding-right: 8px !important; vertical-align: middle !important; }
.admin-stream-table .name-cell,
.admin-stream-table .name-cell strong {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  line-height: 1.25 !important;
}
.admin-stream-table .action-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: normal !important;
}
.admin-stream-table .action-cell { white-space: normal !important; }
@media (max-width: 980px) {
  .admin-streams-page.admin-streams-compact { width: calc(100vw - 24px) !important; max-width: calc(100vw - 24px) !important; margin-left: 12px !important; margin-right: 12px !important; }
  .admin-stream-table th, .admin-stream-table td { padding-left: 5px !important; padding-right: 5px !important; }
}
.access-page { width: calc(100vw - 40px); max-width: 1480px; margin: 0 auto; }
.access-overview-card { margin-bottom: 24px !important; }
.access-overview-card + .access-overview-card { margin-top: 24px !important; }
.access-table-wrap { overflow-x: auto; }
.compact-access-table .check-cell { text-align: center; vertical-align: middle; }
.compact-access-table .admin-check-toggle { margin: 0 auto; }
.compact-access-table td, .compact-access-table th { vertical-align: middle !important; }
.nav-dropdown.hover-dropdown .nav-menu { pointer-events: auto; }
.nav-dropdown.hover-dropdown::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px; }


/* Requested refinements: Bronnen/admin menu, tables, access, matrix labels. */
.topbar nav .nav-dropdown.hover-dropdown { padding-bottom: 14px; }
.topbar nav .nav-dropdown.hover-dropdown .nav-menu { top: calc(100% - 4px); }
.admin-streams-compact { width: calc(100vw - 40px) !important; max-width: calc(100vw - 40px) !important; }
.admin-streams-head { max-width: calc(100vw - 40px); margin-left: auto; margin-right: auto; }
.admin-streams-stack { width: 100%; align-items: center; }
.collapsible-stream-group { width: min(max-content, calc(100vw - 40px)) !important; max-width: calc(100vw - 40px) !important; min-width: min(1060px, calc(100vw - 40px)) !important; }
.collapsible-stream-group:not([open]) { width: min(1060px, calc(100vw - 40px)) !important; max-width: calc(100vw - 40px) !important; }
.admin-stream-table-wrap { max-width: calc(100vw - 40px) !important; overflow-x: hidden !important; }
.admin-stream-table { max-width: calc(100vw - 40px) !important; table-layout: fixed !important; }
.admin-stream-table .name-cell { white-space: normal !important; overflow-wrap: anywhere !important; word-break: break-word !important; line-height: 1.25; }
.admin-stream-table .name-cell strong { display: block; white-space: normal; overflow-wrap: anywhere; }
.admin-stream-table .action-row { flex-wrap: wrap !important; }
.admin-stream-table .action-row .button,
.admin-stream-table .action-row button { white-space: nowrap; }
.access-overview-card + .access-overview-card { margin-top: 28px; }
.access-expires-cell.is-hidden input { display: none !important; }
.access-expires-cell .access-unlimited-label { display: none; }
.access-expires-cell.is-hidden .access-unlimited-label { display: inline; }
.matrix-name-overlay { top: 8px; left: 8px; right: 8px; text-align: center; }
@media (max-width: 980px) {
  .admin-streams-compact,
  .collapsible-stream-group,
  .collapsible-stream-group:not([open]),
  .admin-stream-table-wrap { width: calc(100vw - 32px) !important; max-width: calc(100vw - 32px) !important; min-width: 0 !important; }
}

/* Organization multi-tenant refinements */
.org-switcher {
  min-width: 150px;
  max-width: 240px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: #050708;
  color: #f3f7f7;
  padding: 7px 12px;
  font-size: 13px;
}
fieldset.full {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 14px;
}
fieldset.full legend {
  padding: 0 8px;
  color: rgba(243,247,247,.82);
}

/* Organization sharing/menu refinements */
.topbar { gap: 18px; }
.topnav { flex: 1 1 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-width: 0; }
.nav-main { display: flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; }
.nav-account { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-left: auto; flex: 0 0 auto; }
.nav-account .logout-form { display: inline-flex; margin: 0; }
.account-control, .org-switcher.account-control {
  min-height: 38px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: #050708;
  color: #f3f7f7;
  padding: 8px 13px;
  font-weight: 800;
  line-height: 1;
}
.org-switcher.account-control { width: auto; min-width: 170px; margin: 0; }
.logout-form .account-control { cursor: pointer; }
.nav-dropdown.hover-dropdown { padding: 12px 0 16px; margin-top: -12px; margin-bottom: -16px; }
.nav-dropdown.hover-dropdown .nav-menu { top: calc(100% - 2px); margin-top: 0; }
.nav-dropdown.hover-dropdown::after { height: 18px; }
.matrix-toggle-head { vertical-align: top !important; padding-top: 10px !important; }
.matrix-toggle-head .header-link { display: block; line-height: 1.15; }
.group-toggle-icons { display: flex !important; justify-content: center !important; align-items: center; margin: 6px auto 0 !important; }
.share-target-list { display: grid; gap: 10px; }
.share-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0; padding: 10px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; background: rgba(255,255,255,.035); }
.share-org-text { display: grid; gap: 2px; min-width: 0; }
.share-org-text small { color: var(--muted); overflow-wrap: anywhere; }
.action-row .button { white-space: nowrap; }
@media (max-width: 900px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .topnav { flex-direction: column; align-items: stretch; }
  .nav-account { justify-content: flex-start; margin-left: 0; flex-wrap: wrap; }
}

/* Admin/org UI polish patch */
.nav-badge[hidden] { display: none !important; }
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-streams-page { padding-left: 20px !important; padding-right: 20px !important; box-sizing: border-box; }
.admin-streams-stack { align-items: center !important; width: 100%; }
.collapsible-stream-group,
.collapsible-stream-group:not([open]),
.collapsible-stream-group[open] {
  width: min-content !important;
  min-width: min(1120px, calc(100vw - 40px)) !important;
  max-width: calc(100vw - 40px) !important;
}
.collapsible-stream-group .group-summary {
  width: 100% !important;
  box-sizing: border-box;
}
.admin-stream-table-wrap {
  width: auto !important;
  max-width: calc(100vw - 40px) !important;
  overflow-x: visible !important;
}
.admin-stream-table {
  width: auto !important;
  max-width: calc(100vw - 40px) !important;
  table-layout: fixed !important;
}
.admin-stream-table th { vertical-align: top !important; }
.admin-stream-table .status-cell,
.admin-stream-table th:nth-child(5) { text-align: center !important; }
.admin-stream-table .name-cell,
.admin-stream-table .name-cell strong {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  line-height: 1.25;
}
.admin-stream-table td,
.admin-stream-table th { vertical-align: middle !important; }
.admin-stream-table thead th { vertical-align: top !important; }
.admin-stream-table col.col-name { width: 300px !important; }
.admin-stream-table col.col-source { width: 115px !important; }
.admin-stream-table col.col-internal { width: 92px !important; }
.admin-stream-table col.col-external { width: 92px !important; }
.admin-stream-table col.col-status { width: 112px !important; }
.admin-stream-table col.col-key { width: 78px !important; }
.admin-stream-table col.col-actions { width: 430px !important; }
.admin-stream-table .action-row { flex-wrap: nowrap !important; }
.frame-modal-card {
  width: min(1180px, calc(100vw - 48px)) !important;
  max-height: calc(100vh - 48px) !important;
}
.frame-modal-card .modal-iframe {
  min-height: min(760px, calc(100vh - 140px)) !important;
}
.modal-card:not(.frame-modal-card) {
  width: fit-content;
  min-width: min(560px, calc(100vw - 48px));
  max-width: min(980px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
}
@media (max-width: 1180px) {
  .admin-stream-table col.col-name { width: 250px !important; }
  .admin-stream-table col.col-actions { width: 390px !important; }
}

/* Final modal/table fit patch */
.container:has(.admin-streams-page) {
  max-width: none !important;
  width: 100% !important;
  margin: 20px 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.admin-streams-page.admin-streams-compact {
  width: calc(100vw - 40px) !important;
  max-width: calc(100vw - 40px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.admin-streams-page .admin-streams-head,
.admin-streams-page .page-head {
  width: 100% !important;
  max-width: calc(100vw - 40px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
.admin-streams-stack {
  width: 100% !important;
  max-width: calc(100vw - 40px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  align-items: center !important;
  justify-items: center !important;
}
.collapsible-stream-group,
.collapsible-stream-group[open],
.collapsible-stream-group:not([open]) {
  width: min(100%, 1260px) !important;
  max-width: calc(100vw - 40px) !important;
  min-width: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
.admin-stream-table-wrap {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
.admin-stream-table,
.admin-stream-table.compact-stream-table {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}
.admin-stream-table col.col-name { width: 30% !important; }
.admin-stream-table col.col-source { width: 9% !important; }
.admin-stream-table col.col-internal { width: 7% !important; }
.admin-stream-table col.col-external { width: 7% !important; }
.admin-stream-table col.col-status { width: 9% !important; }
.admin-stream-table col.col-key { width: 7% !important; }
.admin-stream-table col.col-actions { width: 31% !important; }
.admin-stream-table th,
.admin-stream-table td {
  vertical-align: middle !important;
  overflow: hidden !important;
}
.admin-stream-table .name-cell,
.admin-stream-table .name-cell strong {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  hyphens: auto !important;
}
.admin-stream-table .action-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
}
.admin-stream-table .action-row .button,
.admin-stream-table .action-row button,
.admin-stream-table .row-button {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}
@media (min-width: 1500px) {
  .collapsible-stream-group,
  .collapsible-stream-group[open],
  .collapsible-stream-group:not([open]) { width: min(100%, 1480px) !important; }
  .admin-stream-table col.col-actions { width: 29% !important; }
  .admin-stream-table col.col-name { width: 32% !important; }
}
@media (max-width: 980px) {
  .admin-streams-page.admin-streams-compact,
  .admin-streams-stack,
  .admin-streams-page .admin-streams-head,
  .admin-streams-page .page-head,
  .collapsible-stream-group,
  .collapsible-stream-group[open],
  .collapsible-stream-group:not([open]) {
    max-width: calc(100vw - 24px) !important;
    width: calc(100vw - 24px) !important;
  }
  .admin-stream-table th,
  .admin-stream-table td { padding-left: 5px !important; padding-right: 5px !important; }
}

/* Modal sizing: content-aware defaults with explicit variants for view/debug/form. */
.modal-backdrop {
  padding: 18px !important;
  align-items: center !important;
  justify-content: center !important;
}
.modal-card {
  width: auto !important;
  min-width: min(520px, calc(100vw - 36px)) !important;
  max-width: min(980px, calc(100vw - 36px)) !important;
  max-height: calc(100vh - 36px) !important;
  overflow: auto !important;
  padding: 18px !important;
}
.frame-modal-card {
  display: flex !important;
  flex-direction: column !important;
  width: min(980px, calc(100vw - 36px)) !important;
  height: auto !important;
  max-height: calc(100vh - 36px) !important;
}
.frame-modal-card .modal-iframe {
  flex: 0 1 auto !important;
  width: 100% !important;
  height: min(640px, calc(100vh - 126px)) !important;
  min-height: min(420px, calc(100vh - 126px)) !important;
}
.frame-modal-card.modal-kind-view {
  width: min(1280px, calc(100vw - 36px)) !important;
}
.frame-modal-card.modal-kind-view .modal-iframe {
  height: min(720px, calc(100vh - 112px)) !important;
  min-height: min(520px, calc(100vh - 112px)) !important;
}
.frame-modal-card.modal-kind-debug {
  width: min(980px, calc(100vw - 36px)) !important;
}
.frame-modal-card.modal-kind-debug .modal-iframe {
  height: min(620px, calc(100vh - 112px)) !important;
  min-height: min(420px, calc(100vh - 112px)) !important;
}
.frame-modal-card.modal-kind-form,
.frame-modal-card.modal-kind-share {
  width: min(900px, calc(100vw - 36px)) !important;
}
.frame-modal-card.modal-kind-form .modal-iframe,
.frame-modal-card.modal-kind-share .modal-iframe {
  height: min(720px, calc(100vh - 112px)) !important;
  min-height: min(500px, calc(100vh - 112px)) !important;
}
@media (max-height: 660px) {
  .modal-card { padding: 14px !important; }
  .frame-modal-card .modal-iframe,
  .frame-modal-card.modal-kind-view .modal-iframe,
  .frame-modal-card.modal-kind-debug .modal-iframe,
  .frame-modal-card.modal-kind-form .modal-iframe,
  .frame-modal-card.modal-kind-share .modal-iframe {
    height: calc(100vh - 104px) !important;
    min-height: 280px !important;
  }
}

/* Admin sources table: keep row actions on one line. The name column is the flexible column. */
.admin-stream-table,
.admin-stream-table.compact-stream-table {
  table-layout: fixed !important;
  width: 100% !important;
  max-width: 100% !important;
}
.admin-stream-table col.col-source { width: 96px !important; }
.admin-stream-table col.col-internal { width: 76px !important; }
.admin-stream-table col.col-external { width: 76px !important; }
.admin-stream-table col.col-status { width: 86px !important; }
.admin-stream-table col.col-key { width: 64px !important; }
.admin-stream-table col.col-actions { width: 490px !important; }
.admin-stream-table col.col-name { width: auto !important; }
.admin-stream-table .action-cell {
  white-space: nowrap !important;
  overflow: visible !important;
}
.admin-stream-table .action-row {
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 5px !important;
  white-space: nowrap !important;
  max-width: none !important;
}
.admin-stream-table .action-row .button,
.admin-stream-table .action-row button,
.admin-stream-table .row-button {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
  min-width: 0 !important;
  padding-left: 8px !important;
  padding-right: 8px !important;
  font-size: .86rem !important;
}
.admin-stream-table .name-cell,
.admin-stream-table .name-cell strong {
  min-width: 0 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
@media (max-width: 1180px) {
  .admin-stream-table col.col-source { width: 86px !important; }
  .admin-stream-table col.col-internal { width: 70px !important; }
  .admin-stream-table col.col-external { width: 70px !important; }
  .admin-stream-table col.col-status { width: 78px !important; }
  .admin-stream-table col.col-key { width: 58px !important; }
  .admin-stream-table col.col-actions { width: 455px !important; }
  .admin-stream-table .action-row { gap: 4px !important; }
  .admin-stream-table .action-row .button,
  .admin-stream-table .action-row button,
  .admin-stream-table .row-button {
    padding-left: 6px !important;
    padding-right: 6px !important;
    font-size: .8rem !important;
  }
}
@media (max-width: 920px) {
  .admin-stream-table col.col-source { width: 78px !important; }
  .admin-stream-table col.col-internal { width: 62px !important; }
  .admin-stream-table col.col-external { width: 62px !important; }
  .admin-stream-table col.col-status { width: 72px !important; }
  .admin-stream-table col.col-key { width: 52px !important; }
  .admin-stream-table col.col-actions { width: 410px !important; }
  .admin-stream-table .action-row .button,
  .admin-stream-table .action-row button,
  .admin-stream-table .row-button {
    padding-left: 5px !important;
    padding-right: 5px !important;
    font-size: .74rem !important;
  }
}

/* Final requested admin fit patch: wider Key column, iframe edit modal, mobile/tablet source list. */
.admin-stream-table col.col-key { width: 78px !important; }
.admin-stream-table .key-cell,
.admin-stream-table .key-head {
  text-align: center !important;
  overflow: visible !important;
}
.admin-stream-table .key-cell .key-button {
  min-width: 52px !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
.admin-stream-table col.col-actions { width: 486px !important; }
.admin-stream-table col.col-name { width: auto !important; }

/* Iframe stream forms need extra vertical space because extra iframe options are shown. */
.frame-modal-card.modal-kind-form.modal-kind-iframe-form {
  width: min(980px, calc(100vw - 36px)) !important;
}
.frame-modal-card.modal-kind-form.modal-kind-iframe-form .modal-iframe {
  height: min(820px, calc(100vh - 92px)) !important;
  min-height: min(660px, calc(100vh - 92px)) !important;
}

@media (max-width: 1180px) {
  .admin-stream-table col.col-key { width: 72px !important; }
  .admin-stream-table col.col-actions { width: 450px !important; }
}

/* Tablet and phone: convert the sources table to responsive cards, while keeping actions on one horizontal line. */
@media (max-width: 760px) {
  .admin-streams-page.admin-streams-compact,
  .admin-streams-stack,
  .admin-streams-page .admin-streams-head,
  .admin-streams-page .page-head,
  .collapsible-stream-group,
  .collapsible-stream-group[open],
  .collapsible-stream-group:not([open]) {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    min-width: 0 !important;
  }
  .admin-streams-page .admin-streams-head {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    align-items: start !important;
  }
  .admin-streams-page .admin-streams-head .actions {
    justify-content: start !important;
  }
  .admin-stream-table-wrap {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  .admin-stream-table,
  .admin-stream-table.compact-stream-table,
  .admin-stream-table thead,
  .admin-stream-table tbody,
  .admin-stream-table tr,
  .admin-stream-table th,
  .admin-stream-table td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .admin-stream-table colgroup,
  .admin-stream-table thead {
    display: none !important;
  }
  .admin-stream-table tbody {
    display: grid !important;
    gap: 12px !important;
  }
  .admin-stream-table tr {
    background: rgba(255,255,255,.045) !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    border-radius: 16px !important;
    padding: 10px !important;
    overflow: hidden !important;
  }
  .admin-stream-table td {
    display: grid !important;
    grid-template-columns: minmax(86px, 32%) minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: center !important;
    border-bottom: 1px solid rgba(255,255,255,.08) !important;
    padding: 8px 2px !important;
    overflow: visible !important;
    min-height: 38px !important;
    text-align: left !important;
  }
  .admin-stream-table td:last-child {
    border-bottom: 0 !important;
  }
  .admin-stream-table td::before {
    content: attr(data-label);
    color: rgba(243,247,247,.62);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .admin-stream-table .name-cell strong {
    font-size: 1rem !important;
  }
  .admin-stream-table .check-cell .matrix-check-form,
  .admin-stream-table .check-cell .admin-check-toggle,
  .admin-stream-table .key-cell .key-button,
  .admin-stream-table .status-cell .pill {
    justify-self: start !important;
  }
  .admin-stream-table .action-cell {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    overflow: hidden !important;
  }
  .admin-stream-table .action-cell::before {
    display: none !important;
  }
  .admin-stream-table .action-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 4px !important;
    max-width: 100% !important;
    -webkit-overflow-scrolling: touch;
  }
  .admin-stream-table .action-row .button,
  .admin-stream-table .action-row button,
  .admin-stream-table .row-button {
    flex: 0 0 auto !important;
    min-height: 34px !important;
    font-size: .82rem !important;
    padding-left: 9px !important;
    padding-right: 9px !important;
  }
  .group-summary {
    border-radius: 14px !important;
  }
  .frame-modal-card,
  .frame-modal-card.modal-kind-form,
  .frame-modal-card.modal-kind-form.modal-kind-iframe-form,
  .frame-modal-card.modal-kind-view,
  .frame-modal-card.modal-kind-debug,
  .frame-modal-card.modal-kind-share {
    width: calc(100vw - 18px) !important;
    max-width: calc(100vw - 18px) !important;
    max-height: calc(100vh - 18px) !important;
  }
  .frame-modal-card .modal-iframe,
  .frame-modal-card.modal-kind-form .modal-iframe,
  .frame-modal-card.modal-kind-form.modal-kind-iframe-form .modal-iframe,
  .frame-modal-card.modal-kind-view .modal-iframe,
  .frame-modal-card.modal-kind-debug .modal-iframe,
  .frame-modal-card.modal-kind-share .modal-iframe {
    height: calc(100vh - 96px) !important;
    min-height: 360px !important;
  }
}

/* Matrix snapshots: timeline, snapshot button and annotation modal. */
.matrix-shell-body .matrix-only {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) clamp(220px, 18vw, 320px) !important;
  gap: 8px !important;
  align-items: stretch !important;
}
.matrix-shell-body .live-matrix-full {
  min-width: 0 !important;
  min-height: 0 !important;
}
.snapshot-timeline {
  min-width: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(243,247,247,.14);
  border-radius: 12px;
  background: rgba(0,0,0,.72);
  display: flex;
  flex-direction: column;
}
.snapshot-timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(243,247,247,.12);
  color: #f3f7f7;
  font-size: .88rem;
}
.snapshot-timeline-refresh,
.snapshot-delete,
.snapshot-tile-button,
.snapshot-close,
.snapshot-tools button {
  border: 1px solid rgba(243,247,247,.18);
  background: rgba(255,255,255,.06);
  color: #f3f7f7;
  border-radius: 999px;
  cursor: pointer;
}
.snapshot-timeline-refresh { width: 30px; height: 30px; }
.snapshot-timeline-list {
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.snapshot-empty { color: #8d989b; font-size: .84rem; padding: 12px 4px; }
.snapshot-card {
  border: 1px solid rgba(243,247,247,.14);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,.045);
}
.snapshot-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: contain;
  background: #000;
}
.snapshot-meta { padding: 8px 9px; display: grid; gap: 3px; font-size: .75rem; color: #b9c3c5; }
.snapshot-meta strong { color: #f3f7f7; font-size: .78rem; line-height: 1.2; }
.snapshot-delete { margin: 0 9px 9px; padding: 5px 10px; font-size: .74rem; }
.matrix-name-overlay {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 5px 7px !important;
}
.matrix-label-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snapshot-tile-button {
  flex: 0 0 auto;
  width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(0,0,0,.48);
}
.snapshot-tile-button:hover { background: rgba(255,255,255,.14); }
.snapshot-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.snapshot-modal[hidden] { display: none !important; }
.snapshot-modal-card {
  width: min(1180px, 96vw);
  max-height: 96vh;
  background: #07090a;
  border: 1px solid rgba(243,247,247,.18);
  border-radius: 18px;
  box-shadow: 0 26px 90px rgba(0,0,0,.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.snapshot-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(243,247,247,.12);
}
.snapshot-close { width: 32px; height: 32px; font-size: 20px; }
.snapshot-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(243,247,247,.10);
}
.snapshot-tools button { padding: 7px 12px; }
.snapshot-tools button.active,
.snapshot-tools button.primary { background: #f3f7f7; color: #050708; }
.snapshot-canvas-wrap {
  padding: 12px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
}
#snapshot-canvas {
  max-width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 10px;
  border: 1px solid rgba(243,247,247,.14);
  touch-action: none;
}
.snapshot-help { padding: 0 14px 12px; color: #8d989b; font-size: .82rem; }
@media (max-width: 980px) {
  .matrix-shell-body .matrix-only {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) minmax(180px, 28vh) !important;
  }
  .snapshot-timeline { min-height: 180px; }
}

/* Snapshot panel repair: collapsible timeline + clickable snapshot icon. */
.matrix-shell-body .matrix-only.snapshot-panel-collapsed {
  grid-template-columns: minmax(0, 1fr) 44px !important;
}
.snapshot-timeline-toggle {
  border: 1px solid rgba(243,247,247,.18);
  background: rgba(255,255,255,.06);
  color: #f3f7f7;
  border-radius: 999px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: rotate(180deg);
  flex: 0 0 auto;
}
.snapshot-timeline.collapsed .snapshot-timeline-toggle {
  transform: rotate(0deg);
}
.snapshot-timeline.collapsed .snapshot-timeline-head {
  justify-content: center;
  padding-left: 6px;
  padding-right: 6px;
}
.snapshot-timeline.collapsed .snapshot-timeline-head strong,
.snapshot-timeline.collapsed .snapshot-timeline-refresh,
.snapshot-timeline.collapsed .snapshot-timeline-list {
  display: none !important;
}
/* The matrix title bar used to disable pointer events for video controls; keep video controls intact but allow the snapshot button. */
.matrix-name-overlay {
  pointer-events: auto !important;
}
.matrix-label-text {
  pointer-events: none !important;
}
.snapshot-tile-button {
  pointer-events: auto !important;
  position: relative;
  z-index: 8;
}
.snapshot-modal-card {
  color: #f3f7f7;
}

/* Snapshot restrictions and color/viewer refinements. */
.live-tile[data-can-snapshot="0"] .snapshot-tile-button,
.matrix-only[data-snapshot-enabled="0"] .snapshot-tile-button {
  display: none !important;
}
.snapshot-color-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(243,247,247,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: #f3f7f7;
  font-size: .86rem;
}
.snapshot-color-label input[type="color"] {
  width: 34px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.snapshot-card img {
  cursor: zoom-in;
}
.snapshot-viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0,0,0,.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.snapshot-viewer-modal[hidden] { display: none !important; }
.snapshot-viewer-card {
  position: relative;
  width: min(1280px, 96vw);
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.snapshot-viewer-card img {
  max-width: 100%;
  max-height: calc(96vh - 64px);
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(243,247,247,.18);
  background: #000;
  box-shadow: 0 26px 90px rgba(0,0,0,.7);
}
.snapshot-viewer-close {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
  background: rgba(0,0,0,.72) !important;
}
.snapshot-viewer-caption {
  color: #d8e2e3;
  font-size: .92rem;
  text-align: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
}


/* Snapshot external timeline + color picker refinements */
.snapshot-color-picker { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.snapshot-color-swatch { width: 34px; height: 34px; padding: 0 !important; border-radius: 999px !important; background: var(--swatch) !important; border: 2px solid rgba(243,247,247,.26) !important; box-shadow: inset 0 0 0 2px rgba(0,0,0,.20); }
.snapshot-color-swatch.active { outline: 2px solid #f3f7f7; outline-offset: 2px; }
.snapshot-color-label { min-height: 34px; box-sizing: border-box; font-weight: 800; }
.snapshot-color-label input[type="color"] { border-radius: 999px; overflow: hidden; }
.matrix-only[data-matrix-scope="external"] .snapshot-delete,
.matrix-only[data-matrix-scope="external"] .snapshot-tile-button { display: none !important; }
.matrix-only[data-matrix-scope="external"] .snapshot-card img { cursor: zoom-in; }
.live-tile-iframe[data-iframe-overlay-enabled="0"] .matrix-name-overlay { display: none !important; }


/* Snapshot panel polish: centered icons, corrected arrow direction, compact timeline actions. */
.snapshot-timeline-refresh,
.snapshot-timeline-toggle,
.snapshot-close,
.snapshot-delete,
.snapshot-tile-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  line-height: 1 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}
.snapshot-timeline-toggle {
  transform: rotate(0deg) !important; /* open panel: arrow points right */
  font-size: 22px !important;
  font-weight: 900 !important;
}
.snapshot-timeline.collapsed .snapshot-timeline-toggle {
  transform: rotate(180deg) !important; /* closed panel: arrow points left */
}
.snapshot-timeline-refresh {
  font-size: 17px !important;
  font-weight: 900 !important;
}
.snapshot-viewer-close,
.snapshot-close {
  line-height: 1 !important;
  font-size: 22px !important;
  font-weight: 900 !important;
}
.snapshot-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px 9px;
}
.snapshot-card-body .snapshot-meta {
  padding: 0 !important;
  min-width: 0;
}
.snapshot-card-body .snapshot-delete {
  width: 32px !important;
  height: 32px !important;
  margin: 0 !important;
  font-size: 16px !important;
  color: #ffb4b4 !important;
  border-color: rgba(255,120,120,.28) !important;
  background: rgba(255,80,80,.10) !important;
  flex: 0 0 auto;
}
.snapshot-card-body .snapshot-delete:hover {
  background: rgba(255,80,80,.20) !important;
  border-color: rgba(255,160,160,.48) !important;
}
.matrix-only[data-matrix-scope="external"] .snapshot-card-body {
  grid-template-columns: minmax(0, 1fr);
}

/* PTZ matrix controls: compact overlay that keeps the camera image visible. */
.ptz-settings-fieldset { margin-top: 4px; }
.ptz-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ptz-settings-grid .full { grid-column: 1 / -1; }
.matrix-name-overlay { display: flex !important; align-items: center !important; gap: 6px !important; }
.matrix-name-overlay .matrix-label-text { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptz-tile-button {
  flex: 0 0 auto;
  height: 24px;
  min-height: 24px;
  padding: 0 8px !important;
  border: 1px solid rgba(243,247,247,.24);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #f3f7f7;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  line-height: 1;
  pointer-events: auto !important;
  cursor: pointer;
  position: relative;
  z-index: 9;
}
.ptz-tile-button:hover { background: rgba(166,231,188,.18); border-color: rgba(166,231,188,.55); }
.ptz-panel {
  position: absolute;
  z-index: 7;
  top: 44px;
  right: 8px;
  width: min(248px, calc(100% - 16px));
  max-height: calc(100% - 56px);
  overflow: auto;
  border: 1px solid rgba(243,247,247,.20);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(8,13,14,.92), rgba(0,0,0,.78));
  box-shadow: 0 18px 48px rgba(0,0,0,.55);
  padding: 10px;
  display: none;
  color: #f3f7f7;
  backdrop-filter: blur(8px);
}
.live-tile.ptz-panel-open .ptz-panel { display: grid; gap: 6px; }
.ptz-panel-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: .82rem; }
.ptz-panel-head button,
.ptz-control-grid button,
.ptz-zoom-row button {
  border: 1px solid rgba(243,247,247,.22);
  background: rgba(255,255,255,.07);
  color: #f3f7f7;
  border-radius: 12px;
  min-height: 34px;
  font-weight: 900;
  cursor: pointer;
}
.ptz-panel-head button { width: 28px; height: 28px; min-height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.ptz-control-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ptz-control-grid button { min-width: 0; font-size: 16px; }
.ptz-control-grid .ptz-home-button { display: inline-flex; align-items: center; justify-content: center; padding: 0; line-height: 0; }
.ptz-home-icon { display: block; width: 18px; height: 18px; flex: 0 0 18px; }
.ptz-zoom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ptz-range-stack { display: grid; gap: 0; margin-top: 0; }
.ptz-range { display: grid; grid-template-columns: 58px 34px minmax(0, 1fr); align-items: center; gap: 6px; min-height: 20px; margin: 0; padding: 0; line-height: 1.05; color: #c9d2d4; font-size: .74rem; font-weight: 800; }
.ptz-range input { width: 100%; min-width: 0; margin: 0; accent-color: #a6e7bc; }
.ptz-range-name { white-space: nowrap; }
.ptz-range-value { color: #a6e7bc; text-align: right; font-variant-numeric: tabular-nums; }
.ptz-status { min-width: 0; color: #a6e7bc; font-size: .72rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.ptz-status.error { color: #ff9b97; }
@media (max-width: 760px) {
  .ptz-settings-grid { grid-template-columns: 1fr; }
  .ptz-panel { width: min(230px, calc(100% - 12px)); top: 42px; right: 6px; padding: 8px; }
  .ptz-control-grid { gap: 5px; }
  .ptz-control-grid button,
  .ptz-zoom-row button { min-height: 32px; }
  .ptz-range { grid-template-columns: 54px 32px minmax(0, 1fr); gap: 5px; }
}

/* Sensordata bronnen */
.live-tile-sensor {
  background: radial-gradient(circle at 20% 0%, #172554 0, #07111f 42%, #020617 100%);
  color: #e5eefb;
}
.sensor-tile-panel,
.sensor-player-full {
  width: 100%;
  height: 100%;
  padding: 44px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}
.sensor-player-full {
  min-height: 100vh;
  padding: 42px;
  background: radial-gradient(circle at 20% 0%, #172554 0, #07111f 42%, #020617 100%);
  color: #e5eefb;
}
.sensor-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  color: #f8fafc;
}
.sensor-card-head strong { font-size: 18px; }
.sensor-card-head span { color: #93a4b8; font-size: 13px; }
.sensor-latest {
  font-size: clamp(26px, 6vw, 54px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #ffffff;
}
.sensor-line-chart {
  width: 100%;
  height: 38%;
  min-height: 90px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .72);
  border: 1px solid rgba(148, 163, 184, .24);
  overflow: visible;
}
.sensor-line-chart polyline {
  fill: none;
  stroke: #7dd3fc;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}
.sensor-threshold {
  stroke: #f97316;
  stroke-width: 2;
  stroke-dasharray: 7 6;
  vector-effect: non-scaling-stroke;
}
.sensor-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.sensor-values div {
  border: 1px solid rgba(148, 163, 184, .2);
  background: rgba(15, 23, 42, .58);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.sensor-values span {
  display: block;
  color: #9ca3af;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sensor-values strong {
  display: block;
  color: #f8fafc;
  font-size: 15px;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.sensor-gauge {
  position: relative;
  width: min(78%, 320px);
  aspect-ratio: 2 / 1;
  margin: 8px auto 0;
  overflow: hidden;
}
.sensor-gauge-arc {
  position: absolute;
  inset: 0;
  border-radius: 999px 999px 0 0;
  background: conic-gradient(from 270deg at 50% 100%, #22c55e 0deg, #f59e0b 90deg, #ef4444 180deg, transparent 180deg);
}
.sensor-gauge.reverse .sensor-gauge-arc {
  background: conic-gradient(from 270deg at 50% 100%, #ef4444 0deg, #f59e0b 90deg, #22c55e 180deg, transparent 180deg);
}
.sensor-gauge::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0;
  height: 76%;
  border-radius: 999px 999px 0 0;
  background: #07111f;
}
.sensor-gauge-needle {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 2;
  width: 3px;
  height: 86%;
  background: #f8fafc;
  transform-origin: bottom center;
  box-shadow: 0 0 12px rgba(255,255,255,.6);
}
.sensor-gauge-center {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: -7px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: #f8fafc;
}
.sensor-gauge-scale {
  display: flex;
  justify-content: space-between;
  color: #93a4b8;
  font-size: 12px;
  margin: -4px auto 0;
  width: min(78%, 320px);
}
.sensor-empty {
  color: #cbd5e1;
  text-align: center;
  padding: 20px;
  border: 1px dashed rgba(148, 163, 184, .35);
  border-radius: 12px;
  background: rgba(15, 23, 42, .48);
}
.sensor-empty.error { color: #fecaca; border-color: rgba(248, 113, 113, .45); }
.sensor-field-table input[type="checkbox"] { width: auto; margin: 0; }
.sensor-field-table input[type="text"] { min-width: 140px; }
.sensor-field-table code { max-width: 280px; white-space: normal; overflow-wrap: anywhere; }

/* Sensordata lijngrafiek update: live, multi-series, grid, assen en klikbare legenda */
.live-tile-sensor .sensor-tile-panel,
.sensor-player-full {
  justify-content: stretch;
  gap: 8px;
}

.sensor-chart-layout {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(70px, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.sensor-chart-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sensor-line-chart {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 220px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .74);
  border: 1px solid rgba(148, 163, 184, .24);
  overflow: visible;
}

.live-tile .sensor-line-chart {
  min-height: 160px;
}

.sensor-chart-bg {
  fill: rgba(15, 23, 42, .72);
}

.sensor-grid-line {
  stroke: rgba(148, 163, 184, .22);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.sensor-axis-line {
  stroke: rgba(226, 232, 240, .55);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.sensor-line-series {
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.sensor-point {
  stroke: rgba(2, 6, 23, .95);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  cursor: crosshair;
}

.sensor-point:hover {
  r: 6;
  stroke: #ffffff;
}

.sensor-x-label,
.sensor-y-label,
.sensor-threshold-label {
  fill: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  paint-order: stroke;
  stroke: rgba(2, 6, 23, .84);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.sensor-x-label {
  text-anchor: middle;
}

.sensor-y-label {
  text-anchor: end;
}

.sensor-threshold-label {
  text-anchor: end;
  fill: #fed7aa;
}

.sensor-y-axis-list {
  min-width: 72px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  padding: 2px 0;
}

.sensor-y-axis-item {
  border-left: 4px solid var(--series-color, #7dd3fc);
  border-radius: 9px;
  background: rgba(15, 23, 42, .52);
  border-top: 1px solid rgba(148, 163, 184, .18);
  border-right: 1px solid rgba(148, 163, 184, .18);
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  padding: 7px 7px 7px 8px;
  color: #e5eefb;
}

.sensor-y-axis-item strong {
  display: block;
  max-width: 120px;
  margin-bottom: 5px;
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sensor-y-axis-item span {
  display: block;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}

.sensor-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.sensor-legend-item {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, .28);
  background: rgba(15, 23, 42, .64);
  color: #e5eefb;
  border-radius: 999px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.sensor-legend-item span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--series-color, #7dd3fc);
  box-shadow: 0 0 0 2px rgba(255,255,255,.08);
}

.sensor-legend-item.is-off {
  opacity: .55;
  text-decoration: line-through;
}

.sensor-legend-item.is-off span {
  background: transparent;
  border: 2px solid var(--series-color, #7dd3fc);
}

@media (max-width: 720px) {
  .sensor-chart-layout {
    grid-template-columns: 1fr;
  }
  .sensor-y-axis-list {
    order: 2;
    flex-direction: row;
    overflow-x: auto;
  }
  .sensor-chart-main {
    order: 1;
  }
}

/* Sensordata layout refinements: use the full matrix cell for the graph. */
.live-tile-sensor {
  padding: 0;
}
.live-tile-sensor .sensor-tile-panel {
  position: absolute;
  inset: 0;
  padding: 4px;
  gap: 0;
}
.live-tile-sensor .sensor-chart-layout,
.sensor-player-full .sensor-chart-layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}
.live-tile-sensor .sensor-chart-main,
.sensor-player-full .sensor-chart-main {
  height: 100%;
  gap: 4px;
}
.live-tile-sensor .sensor-line-chart,
.sensor-player-full .sensor-line-chart {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  border-radius: 8px;
}
.live-tile-sensor .sensor-legend {
  flex: 0 0 auto;
  max-height: 38px;
  overflow: auto;
  padding: 0 2px 2px;
}
.sensor-y-axis-list,
.sensor-y-label {
  display: none;
}
.sensor-field-table .compact-check {
  margin: 0;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sensor-field-table .compact-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.sensor-field-table input[type="number"] {
  min-width: 100px;
}

/* Sensordata refinement: compact form, full graph cell and visible axis/tooltip. */
.sensor-settings-fieldset {
  min-width: 0;
}
.sensor-settings-fieldset > label:not(.full) {
  min-width: 0;
}
.sensor-field-table-wrap {
  min-width: 0;
  overflow-x: auto;
}
.sensor-field-table {
  width: 100%;
  min-width: 720px;
  table-layout: fixed;
}
.sensor-field-table th,
.sensor-field-table td {
  padding: 7px 8px;
  vertical-align: middle;
}
.sensor-field-table th:nth-child(1),
.sensor-field-table td:nth-child(1) { width: 58px; text-align: center; }
.sensor-field-table th:nth-child(2),
.sensor-field-table td:nth-child(2) { width: 28%; }
.sensor-field-table th:nth-child(3),
.sensor-field-table td:nth-child(3) { width: 24%; }
.sensor-field-table th:nth-child(4),
.sensor-field-table td:nth-child(4) { width: 78px; }
.sensor-field-table th:nth-child(5),
.sensor-field-table td:nth-child(5) { width: 92px; }
.sensor-field-table th:nth-child(6),
.sensor-field-table td:nth-child(6) { width: 86px; text-align: center; }
.sensor-field-table .sensor-table-toggle {
  margin: 0 auto;
  transform: scale(.82);
  transform-origin: center;
}
.sensor-field-table input.sensor-name-input {
  min-width: 0;
  width: 100%;
}
.sensor-field-table input.sensor-unit-input {
  min-width: 0;
  width: 58px;
  padding-left: 8px;
  padding-right: 8px;
}
.sensor-field-table input.sensor-threshold-input {
  min-width: 0;
  width: 82px;
  padding-left: 8px;
  padding-right: 8px;
}
.sensor-field-table .sensor-path-cell code {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 12px;
}
.frame-modal-card.modal-kind-form .modal-iframe {
  width: 100%;
}
.live-tile-sensor .sensor-tile-panel {
  padding: 18px 6px 5px;
}
.live-tile-sensor .sensor-chart-layout,
.sensor-player-full .sensor-chart-layout {
  height: 100%;
}
.live-tile-sensor .sensor-chart-main,
.sensor-player-full .sensor-chart-main {
  position: relative;
}
.sensor-y-value-label {
  fill: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  text-anchor: start;
  paint-order: stroke;
  stroke: rgba(2, 6, 23, .88);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.sensor-line-chart .sensor-y-value-label {
  display: block;
}
.sensor-hover-tooltip {
  position: absolute;
  z-index: 12;
  max-width: min(260px, calc(100% - 24px));
  pointer-events: none;
  transform: translateY(-100%);
  border: 1px solid rgba(226, 232, 240, .28);
  border-radius: 10px;
  background: rgba(2, 6, 23, .94);
  color: #f8fafc;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  box-shadow: 0 12px 26px rgba(0,0,0,.35);
}
.sensor-hover-tooltip[hidden] {
  display: none;
}
.sensor-point:hover {
  r: 6;
}
@media (max-width: 760px) {
  .sensor-field-table {
    min-width: 660px;
  }
}

/* Sensordata snelheidsmeter: alleen de meter tonen en actuele waarde in het midden. */
.sensor-gauge-only {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.live-tile-sensor .sensor-gauge-only {
  position: absolute;
  inset: 0;
  padding: 6px;
}

.live-tile-sensor .sensor-tile-panel:has(.sensor-gauge-only) {
  padding: 0;
}

.sensor-gauge-only .sensor-gauge {
  width: min(96%, 520px);
  max-height: 96%;
  margin: 0 auto;
}

.live-tile-sensor .sensor-gauge-only .sensor-gauge {
  width: min(98%, 100%);
}

.sensor-player-full .sensor-gauge-only .sensor-gauge {
  width: min(88vw, 760px);
}

.sensor-gauge-readout {
  position: absolute;
  z-index: 4;
  left: 17%;
  right: 17%;
  bottom: 10%;
  min-height: 32%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #f8fafc;
  pointer-events: none;
}

.sensor-gauge-readout strong {
  display: block;
  max-width: 100%;
  font-size: clamp(22px, 6vw, 52px);
  line-height: .95;
  font-weight: 850;
  letter-spacing: -.045em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 10px rgba(0,0,0,.65);
}

.sensor-gauge-readout span {
  display: block;
  max-width: 100%;
  margin-top: 5px;
  color: #cbd5e1;
  font-size: clamp(10px, 1.8vw, 15px);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 8px rgba(0,0,0,.7);
}

.live-tile-sensor .sensor-gauge-readout {
  left: 15%;
  right: 15%;
  bottom: 8%;
}

.live-tile-sensor .sensor-gauge-readout strong {
  font-size: clamp(18px, 5.4vw, 38px);
}

.live-tile-sensor .sensor-gauge-readout span {
  font-size: clamp(9px, 1.6vw, 12px);
}

/* Sensordata per-field display update: wider modal table, stable tooltips and clearer dense lines. */
.frame-modal-card.modal-kind-form,
.frame-modal-card.modal-kind-form .modal-iframe {
  width: min(1500px, calc(100vw - 20px));
}
.stream-form-card.modal-form-card:has(.sensor-settings-wide) {
  max-width: 1380px;
}
.sensor-field-table-config {
  min-width: 1180px;
}
.sensor-field-table-config th,
.sensor-field-table-config td {
  padding: 6px 7px;
}
.sensor-field-table-config th:nth-child(1),
.sensor-field-table-config td:nth-child(1) { width: 54px; }
.sensor-field-table-config th:nth-child(2),
.sensor-field-table-config td:nth-child(2) { width: 22%; }
.sensor-field-table-config th:nth-child(3),
.sensor-field-table-config td:nth-child(3) { width: 16%; }
.sensor-field-table-config th:nth-child(4),
.sensor-field-table-config td:nth-child(4) { width: 70px; }
.sensor-field-table-config th:nth-child(5),
.sensor-field-table-config td:nth-child(5) { width: 132px; }
.sensor-field-table-config th:nth-child(6),
.sensor-field-table-config td:nth-child(6) { width: 88px; }
.sensor-field-table-config th:nth-child(7),
.sensor-field-table-config td:nth-child(7) { width: 74px; text-align: center; }
.sensor-field-table-config th:nth-child(8),
.sensor-field-table-config td:nth-child(8),
.sensor-field-table-config th:nth-child(9),
.sensor-field-table-config td:nth-child(9) { width: 72px; }
.sensor-field-table-config th:nth-child(10),
.sensor-field-table-config td:nth-child(10) { width: 130px; }
.sensor-field-table-config select,
.sensor-field-table-config input {
  min-width: 0;
}
.sensor-field-table-config .sensor-field-view-select {
  width: 122px;
}
.sensor-field-table-config input.sensor-minmax-input,
.sensor-field-table-config input.sensor-threshold-input {
  width: 70px;
  padding-left: 7px;
  padding-right: 7px;
}
.sensor-field-table-config .sensor-color-select {
  width: 122px;
}
.sensor-line-series {
  stroke-width: 3.4;
  opacity: .98;
}
.sensor-point {
  stroke-width: 1.8;
  cursor: pointer;
}
.sensor-point:hover {
  r: 7;
  stroke: #fff;
}
.sensor-hover-tooltip {
  z-index: 50;
  opacity: 1 !important;
  transition: none !important;
}

/* Sensordata warning/gauge/form refinement. */
.frame-modal-card.modal-kind-form,
.frame-modal-card.modal-kind-form .modal-iframe {
  width: min(1760px, calc(100vw - 12px));
}
.stream-form-card.modal-form-card:has(.sensor-settings-wide) {
  max-width: 1680px;
}
.sensor-field-table-config {
  min-width: 1420px;
}
.sensor-field-table-config th,
.sensor-field-table-config td {
  padding: 7px 8px;
  vertical-align: middle;
}
.sensor-field-table-config th:nth-child(1),
.sensor-field-table-config td:nth-child(1) { width: 56px; text-align: center; }
.sensor-field-table-config th:nth-child(2),
.sensor-field-table-config td:nth-child(2) { width: 24%; }
.sensor-field-table-config th:nth-child(3),
.sensor-field-table-config td:nth-child(3) { width: 17%; }
.sensor-field-table-config th:nth-child(4),
.sensor-field-table-config td:nth-child(4) { width: 72px; }
.sensor-field-table-config th:nth-child(5),
.sensor-field-table-config td:nth-child(5) { width: 136px; }
.sensor-field-table-config th:nth-child(6),
.sensor-field-table-config td:nth-child(6) { width: 86px; }
.sensor-field-table-config th:nth-child(7),
.sensor-field-table-config td:nth-child(7) { width: 86px; text-align: center; }
.sensor-field-table-config th:nth-child(8),
.sensor-field-table-config td:nth-child(8),
.sensor-field-table-config th:nth-child(9),
.sensor-field-table-config td:nth-child(9) { width: 82px; }
.sensor-field-table-config th:nth-child(10),
.sensor-field-table-config td:nth-child(10) { width: 140px; }
.sensor-field-table-config .sensor-path-input {
  width: 100%;
  min-width: 0;
  font-family: inherit;
  color: #dbeafe;
  background: rgba(15, 23, 42, .72);
  border: 1px solid rgba(148, 163, 184, .32);
  cursor: default;
}
.sensor-field-table-config .sensor-unit-input {
  width: 62px;
}
.sensor-field-table-config .sensor-threshold-input,
.sensor-field-table-config .sensor-minmax-input {
  width: 78px;
}
.sensor-field-table-config .sensor-field-view-select,
.sensor-field-table-config .sensor-color-select {
  width: 132px;
}
.sensor-field-table-config tr.is-disabled td:not(.sensor-check-cell):not(.sensor-path-cell) {
  opacity: .35;
}
.sensor-field-table-config tr.is-disabled .sensor-path-input {
  opacity: .62;
}
.sensor-field-table-config td[hidden],
.sensor-field-table-config th[hidden] {
  display: none !important;
}
.sensor-tile-title {
  position: absolute;
  z-index: 9;
  left: 7px;
  right: 7px;
  top: 5px;
  min-height: 22px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(2, 6, 23, .78), rgba(2, 6, 23, .42));
  color: #f8fafc;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.15;
  pointer-events: none;
}
.sensor-tile-title span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sensor-warning-icon {
  flex: 0 0 auto;
  color: #facc15;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.75));
}
.live-tile-sensor .sensor-tile-panel {
  padding: 34px 6px 5px;
}
.sensor-player-full .sensor-tile-title {
  position: static;
  margin-bottom: 8px;
  font-size: 15px;
  background: rgba(15, 23, 42, .72);
}
.sensor-gauge-only {
  padding-top: 14px;
}
.live-tile-sensor .sensor-gauge-only {
  padding: 28px 6px 6px;
}
.live-tile-sensor .sensor-tile-panel:has(.sensor-gauge-only) {
  padding: 0;
}
.sensor-gauge-threshold {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 0;
  width: 3px;
  height: 92%;
  transform-origin: bottom center;
  background: linear-gradient(to top, transparent 0 15%, #facc15 15% 100%);
  box-shadow: 0 0 8px rgba(250, 204, 21, .65);
}
.sensor-gauge-threshold span {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(2, 6, 23, .86);
  border: 1px solid rgba(250, 204, 21, .65);
  color: #fde68a;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.sensor-hover-tooltip {
  transform: translateY(-100%);
}


/* Sensordata alert refinement. */
.admin-stream-table col.col-source { width: 150px !important; }
.admin-stream-table .source-cell { min-width: 150px; }
.source-pill { min-width: 112px; }

.frame-modal-card.modal-kind-form,
.frame-modal-card.modal-kind-form .modal-iframe {
  width: min(1880px, calc(100vw - 8px)) !important;
}
.stream-form-card.modal-form-card:has(.sensor-settings-wide) {
  max-width: 1800px !important;
}
.sensor-field-table-config {
  min-width: 1580px;
}
.sensor-field-table-config th:nth-child(1),
.sensor-field-table-config td:nth-child(1) { width: 58px; }
.sensor-field-table-config th:nth-child(2),
.sensor-field-table-config td:nth-child(2) { width: 21%; }
.sensor-field-table-config th:nth-child(3),
.sensor-field-table-config td:nth-child(3) { width: 15%; }
.sensor-field-table-config th:nth-child(4),
.sensor-field-table-config td:nth-child(4) { width: 70px; }
.sensor-field-table-config th:nth-child(5),
.sensor-field-table-config td:nth-child(5) { width: 132px; }
.sensor-field-table-config th:nth-child(6),
.sensor-field-table-config td:nth-child(6) { width: 86px; }
.sensor-field-table-config th:nth-child(7),
.sensor-field-table-config td:nth-child(7) { width: 86px; text-align: center; }
.sensor-field-table-config th:nth-child(8),
.sensor-field-table-config td:nth-child(8) { width: 86px; text-align: center; }
.sensor-field-table-config th:nth-child(9),
.sensor-field-table-config td:nth-child(9),
.sensor-field-table-config th:nth-child(10),
.sensor-field-table-config td:nth-child(10) { width: 80px; }
.sensor-field-table-config th:nth-child(11),
.sensor-field-table-config td:nth-child(11) { width: 138px; }

.live-tile-sensor .matrix-name-overlay {
  display: flex;
  align-items: center;
  gap: 6px;
}
.live-tile-sensor .matrix-name-overlay .matrix-label-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-tile-sensor .sensor-tile-panel {
  padding-top: 30px;
}
.live-tile-sensor .sensor-gauge-only {
  padding-top: 36px;
}
.sensor-tile-title { display: none !important; }

.sensor-gauge-threshold { display: none !important; }
.sensor-gauge-threshold-line {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 96%;
  transform-origin: bottom center;
  pointer-events: none;
}
.sensor-gauge-threshold-line i {
  position: absolute;
  left: -2px;
  top: 0;
  width: 4px;
  height: 18%;
  border-radius: 999px;
  background: #facc15;
  box-shadow: 0 0 8px rgba(250, 204, 21, .65);
}
.sensor-gauge-threshold-line span {
  position: absolute;
  left: 8px;
  top: 2px;
  transform: rotate(var(--threshold-label-rotation, 0deg));
  transform-origin: left center;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(2, 6, 23, .78);
  border: 1px solid rgba(250, 204, 21, .55);
  color: #fde68a;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

/* Sensordata period/retention refinement. */
.frame-modal-card.modal-kind-form:not(.modal-kind-sensor-form),
.frame-modal-card.modal-kind-form:not(.modal-kind-sensor-form) .modal-iframe {
  width: min(900px, calc(100vw - 36px)) !important;
}
.frame-modal-card.modal-kind-form.modal-kind-sensor-form,
.frame-modal-card.modal-kind-form.modal-kind-sensor-form .modal-iframe {
  width: min(1960px, calc(100vw - 8px)) !important;
}
.frame-modal-card.modal-kind-form.modal-kind-sensor-form .modal-iframe {
  height: min(780px, calc(100vh - 104px)) !important;
  min-height: min(560px, calc(100vh - 104px)) !important;
}
.stream-form-card.modal-form-card:has(.sensor-settings-wide) {
  max-width: 1880px !important;
}
.sensor-field-table-wrap {
  overflow-x: visible !important;
}
.sensor-field-table-config {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed;
}
.sensor-field-table-config th,
.sensor-field-table-config td {
  padding: 6px 6px !important;
}
.sensor-field-table-config th:nth-child(1),
.sensor-field-table-config td:nth-child(1) { width: 54px !important; }
.sensor-field-table-config th:nth-child(2),
.sensor-field-table-config td:nth-child(2) { width: 23% !important; }
.sensor-field-table-config th:nth-child(3),
.sensor-field-table-config td:nth-child(3) { width: 16% !important; }
.sensor-field-table-config th:nth-child(4),
.sensor-field-table-config td:nth-child(4) { width: 62px !important; }
.sensor-field-table-config th:nth-child(5),
.sensor-field-table-config td:nth-child(5) { width: 118px !important; }
.sensor-field-table-config th:nth-child(6),
.sensor-field-table-config td:nth-child(6) { width: 72px !important; }
.sensor-field-table-config th:nth-child(7),
.sensor-field-table-config td:nth-child(7) { width: 78px !important; text-align: center; }
.sensor-field-table-config th:nth-child(8),
.sensor-field-table-config td:nth-child(8) { width: 82px !important; text-align: center; }
.sensor-field-table-config th:nth-child(9),
.sensor-field-table-config td:nth-child(9),
.sensor-field-table-config th:nth-child(10),
.sensor-field-table-config td:nth-child(10) { width: 72px !important; }
.sensor-field-table-config th:nth-child(11),
.sensor-field-table-config td:nth-child(11) { width: 126px !important; }
.sensor-field-table-config select,
.sensor-field-table-config input {
  max-width: 100%;
}
.sensor-field-table-config .sensor-field-view-select,
.sensor-field-table-config .sensor-color-select {
  width: 100% !important;
}
.sensor-field-table-config .sensor-unit-input {
  width: 54px !important;
}
.sensor-field-table-config .sensor-threshold-input,
.sensor-field-table-config .sensor-minmax-input {
  width: 64px !important;
}
.sensor-field-table-config .sensor-table-toggle input:disabled + span {
  opacity: .72;
  cursor: not-allowed;
}
.sensor-field-table-config .sensor-table-toggle input:disabled + span::after {
  opacity: .85;
}
.sensor-period-select {
  position: absolute;
  z-index: 8;
  top: 6px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  margin: 0;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, .28);
  background: rgba(2, 6, 23, .72);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
}
.sensor-period-select select {
  width: auto;
  min-width: 108px;
  height: 25px;
  margin: 0;
  padding: 2px 22px 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background-color: rgba(15, 23, 42, .95);
}
.live-tile-sensor .sensor-line-chart {
  padding-top: 4px;
}
.sensor-gauge-threshold-line span {
  display: none !important;
}
.sensor-gauge-threshold-value {
  display: block;
  max-width: 100%;
  margin-top: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, .46);
  background: rgba(2, 6, 23, .52);
  color: #fde68a;
  font-style: normal;
  font-size: clamp(10px, 1.6vw, 13px);
  line-height: 1.15;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 8px rgba(0,0,0,.7);
}
.live-tile-sensor .sensor-gauge-threshold-value {
  font-size: clamp(9px, 1.5vw, 11px);
  margin-top: 4px;
}
.sensor-gauge-threshold-line i {
  height: 20%;
}
@media (max-width: 1250px) {
  .sensor-field-table-config {
    font-size: 11px;
  }
  .sensor-field-table-config th,
  .sensor-field-table-config td {
    padding: 5px 4px !important;
  }
}

/* Sensordata final refinements: wider editor modal, empty chart, local-time graph and gauge threshold tooltip. */
.frame-modal-card.modal-kind-form.modal-kind-sensor-form {
  width: min(98vw, 2200px) !important;
  max-width: min(98vw, 2200px) !important;
}
.frame-modal-card.modal-kind-form.modal-kind-sensor-form .modal-iframe {
  width: 100% !important;
  max-width: 100% !important;
  height: min(840px, calc(100vh - 92px)) !important;
  min-height: min(620px, calc(100vh - 92px)) !important;
}
.stream-form-card.modal-form-card:has(.sensor-settings-wide) {
  width: min(96vw, 2140px) !important;
  max-width: min(96vw, 2140px) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
.sensor-settings-wide .sensor-field-table-wrap {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}
.sensor-settings-wide .sensor-field-table-config {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
}
.sensor-settings-wide .sensor-field-table-config th,
.sensor-settings-wide .sensor-field-table-config td {
  padding-left: 5px !important;
  padding-right: 5px !important;
}
.sensor-settings-wide .sensor-field-table-config th:nth-child(1),
.sensor-settings-wide .sensor-field-table-config td:nth-child(1) { width: 50px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(2),
.sensor-settings-wide .sensor-field-table-config td:nth-child(2) { width: 22% !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(3),
.sensor-settings-wide .sensor-field-table-config td:nth-child(3) { width: 15% !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(4),
.sensor-settings-wide .sensor-field-table-config td:nth-child(4) { width: 56px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(5),
.sensor-settings-wide .sensor-field-table-config td:nth-child(5) { width: 112px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(6),
.sensor-settings-wide .sensor-field-table-config td:nth-child(6) { width: 66px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(7),
.sensor-settings-wide .sensor-field-table-config td:nth-child(7) { width: 72px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(8),
.sensor-settings-wide .sensor-field-table-config td:nth-child(8) { width: 78px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(9),
.sensor-settings-wide .sensor-field-table-config td:nth-child(9),
.sensor-settings-wide .sensor-field-table-config th:nth-child(10),
.sensor-settings-wide .sensor-field-table-config td:nth-child(10) { width: 62px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(11),
.sensor-settings-wide .sensor-field-table-config td:nth-child(11) { width: 118px !important; }
.sensor-empty-chart-text {
  fill: rgba(203, 213, 225, .82);
  font-size: 18px;
  font-weight: 750;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(2, 6, 23, .9);
  stroke-width: 5px;
  stroke-linejoin: round;
}
.sensor-line-chart-empty .sensor-grid-line {
  stroke: rgba(148, 163, 184, .18);
}
.sensor-gauge-threshold-value {
  display: none !important;
}
.sensor-gauge-threshold-line {
  pointer-events: auto !important;
  cursor: help;
}
.sensor-gauge-threshold-line i {
  pointer-events: auto !important;
}
.sensor-gauge-only {
  position: relative;
}

/* Sensordata follow-up fix: responsive editor modal, compact aligned fields and snapshot/gauge polish. */
.frame-modal-card.modal-kind-form.modal-kind-sensor-form {
  width: min(99vw, 2280px) !important;
  max-width: min(99vw, 2280px) !important;
  height: min(99vh, 1120px) !important;
  max-height: calc(100vh - 8px) !important;
  padding: 8px !important;
}
.frame-modal-card.modal-kind-form.modal-kind-sensor-form .modal-head {
  margin-bottom: 6px !important;
}
.frame-modal-card.modal-kind-form.modal-kind-sensor-form .modal-iframe {
  width: 100% !important;
  max-width: 100% !important;
  height: calc(100vh - 76px) !important;
  min-height: min(760px, calc(100vh - 76px)) !important;
  flex: 1 1 auto !important;
}
.stream-form-card.modal-form-card:has(.sensor-settings-wide) {
  width: calc(100vw - 28px) !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding: 14px !important;
  box-sizing: border-box !important;
}
.sensor-settings-wide {
  overflow: visible !important;
}
.sensor-settings-wide .sensor-field-table-wrap {
  overflow-x: hidden !important;
  overflow-y: visible !important;
}
.sensor-settings-wide .sensor-field-table-config {
  width: 100% !important;
  min-width: 0 !important;
  table-layout: fixed !important;
  font-size: 10.5px !important;
}
.sensor-settings-wide .sensor-field-table-config th,
.sensor-settings-wide .sensor-field-table-config td {
  padding: 4px 4px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}
.sensor-settings-wide .sensor-field-table-config input,
.sensor-settings-wide .sensor-field-table-config select {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: 34px !important;
  padding-left: 6px !important;
  padding-right: 6px !important;
  font-size: 11px !important;
}
.sensor-settings-wide .sensor-field-table-config th:nth-child(1),
.sensor-settings-wide .sensor-field-table-config td:nth-child(1) { width: 48px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(2),
.sensor-settings-wide .sensor-field-table-config td:nth-child(2) { width: 20% !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(3),
.sensor-settings-wide .sensor-field-table-config td:nth-child(3) { width: 14% !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(4),
.sensor-settings-wide .sensor-field-table-config td:nth-child(4) { width: 54px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(5),
.sensor-settings-wide .sensor-field-table-config td:nth-child(5) { width: 110px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(6),
.sensor-settings-wide .sensor-field-table-config td:nth-child(6) { width: 92px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(7),
.sensor-settings-wide .sensor-field-table-config td:nth-child(7) { width: 70px !important; text-align: center; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(8),
.sensor-settings-wide .sensor-field-table-config td:nth-child(8) { width: 76px !important; text-align: center; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(9),
.sensor-settings-wide .sensor-field-table-config td:nth-child(9),
.sensor-settings-wide .sensor-field-table-config th:nth-child(10),
.sensor-settings-wide .sensor-field-table-config td:nth-child(10) { width: 86px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(11),
.sensor-settings-wide .sensor-field-table-config td:nth-child(11) { width: 120px !important; }
.sensor-settings-wide .sensor-field-table-config .sensor-threshold-input,
.sensor-settings-wide .sensor-field-table-config .sensor-minmax-input {
  width: 100% !important;
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}
.sensor-settings-wide .sensor-field-table-config .sensor-unit-input {
  width: 100% !important;
}
.sensor-settings-wide .sensor-field-table-config .sensor-field-view-select,
.sensor-settings-wide .sensor-field-table-config .sensor-color-select {
  width: 100% !important;
}
.sensor-settings-wide .sensor-field-table-config .sensor-path-input {
  width: 100% !important;
  text-overflow: ellipsis;
}
.sensor-settings-wide .sensor-field-table-config .sensor-table-toggle span {
  transform: scale(.88);
  transform-origin: center;
}
.sensor-gauge-threshold-line i {
  background: #facc15 !important;
  box-shadow: 0 0 9px rgba(250,204,21,.70) !important;
}


/* Sensordata refinements - snapshots, period select, responsive modals, clock */
.admin-streams-head { position: relative; display: grid !important; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.admin-streams-head > div:first-child { justify-self: start; }
.admin-streams-head .actions { justify-self: end; }
.admin-live-clock { justify-self: center; text-align: center; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--text); border: 1px solid rgba(243,247,247,.35); border-radius: 999px; padding: 7px 14px; background: rgba(7,19,21,.78); white-space: nowrap; min-width: 240px; }

.frame-modal-card { width: min(1500px, calc(100vw - 18px)) !important; height: min(940px, calc(100vh - 18px)) !important; max-width: calc(100vw - 18px) !important; max-height: calc(100vh - 18px) !important; }
.frame-modal-card .modal-iframe { flex: 1 1 auto !important; width: 100% !important; min-height: 0 !important; }
.frame-modal-card.modal-kind-sensor-form { width: min(1780px, calc(100vw - 10px)) !important; height: min(1080px, calc(100vh - 10px)) !important; max-width: calc(100vw - 10px) !important; max-height: calc(100vh - 10px) !important; padding: 10px !important; }
.frame-modal-card.modal-kind-sensor-form .modal-iframe { min-height: 0 !important; }
@media (max-width: 900px) {
  .admin-streams-head { grid-template-columns: 1fr; }
  .admin-live-clock { justify-self: stretch; min-width: 0; }
  .admin-streams-head .actions { justify-self: stretch; }
  .admin-streams-head .actions .button { width: 100%; }
}

.sensor-period-select {
  top: auto !important;
  right: 10px !important;
  bottom: 10px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  z-index: 12 !important;
}
.sensor-period-select select {
  min-width: 112px !important;
  height: 28px !important;
  border-radius: 999px !important;
  background-color: rgba(2, 6, 23, .88) !important;
  border: 1px solid rgba(148,163,184,.45) !important;
  color: #e5e7eb !important;
  font-size: 11px !important;
}
.sensor-chart-main { padding-bottom: 34px !important; }
.sensor-line-chart { height: calc(100% - 58px) !important; }

.sensor-field-table-config input.sensor-small-field,
.sensor-field-table-config select.sensor-small-field,
.sensor-field-table-config input.sensor-threshold-field,
.sensor-field-table-config input.sensor-unit-field { min-width: 0 !important; box-sizing: border-box !important; }
.sensor-field-table-config .sensor-gauge-options { display: grid !important; grid-template-columns: minmax(70px, 1fr) minmax(70px, 1fr) minmax(110px, 1.15fr) !important; gap: 6px !important; align-items: end !important; }
.sensor-field-table-config .sensor-gauge-options label { min-width: 0 !important; }
.sensor-field-table-config .sensor-gauge-options input,
.sensor-field-table-config .sensor-gauge-options select { width: 100% !important; }
.sensor-field-table-config .sensor-threshold-field { width: 96px !important; min-width: 96px !important; }

/* Let gauge threshold marker accept pointer events for tooltip while keeping the visual subtle. */
.sensor-gauge-threshold-line { pointer-events: auto !important; cursor: help; }
.sensor-gauge-threshold-line i { pointer-events: auto !important; }


/* Refinements: align period control with legend, improve gauge snapshot parity, clock text, form readability and modal height. */
.sensor-chart-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 2px !important;
  gap: 3px !important;
}
.sensor-line-chart {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
}
.sensor-chart-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 1px;
  min-height: 30px;
}
.sensor-chart-footer .sensor-legend {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 31px;
  overflow: auto;
  padding: 0;
}
.sensor-chart-footer .sensor-period-select {
  position: static !important;
  flex: 0 0 auto;
  margin-left: auto !important;
}
.sensor-period-select select {
  font-size: 12px !important;
  height: 27px !important;
}
.live-tile-sensor .sensor-legend {
  max-height: 31px !important;
  overflow: auto;
}

.admin-live-clock {
  min-width: 310px;
}

.frame-modal-card {
  height: min(98vh, 1180px) !important;
  max-height: calc(100vh - 12px) !important;
  display: flex !important;
  flex-direction: column !important;
}
.frame-modal-card .modal-iframe {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
}
.frame-modal-card.modal-kind-form:not(.modal-kind-sensor-form),
.frame-modal-card.modal-kind-form:not(.modal-kind-sensor-form) .modal-iframe {
  height: min(98vh, 1100px) !important;
}
.frame-modal-card.modal-kind-sensor-form {
  height: min(99vh, 1240px) !important;
}

.sensor-settings-wide .sensor-field-table-config {
  font-size: 13px !important;
}
.sensor-settings-wide .sensor-field-table-config th,
.sensor-settings-wide .sensor-field-table-config td {
  font-size: 13px !important;
}
.sensor-settings-wide .sensor-field-table-config input,
.sensor-settings-wide .sensor-field-table-config select {
  font-size: 13px !important;
  height: 36px !important;
}
.sensor-settings-wide .sensor-field-table-config .sensor-table-toggle span {
  transform: none !important;
}
.sensor-settings-wide .sensor-field-table-config th:nth-child(2),
.sensor-settings-wide .sensor-field-table-config td:nth-child(2) { width: 19% !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(3),
.sensor-settings-wide .sensor-field-table-config td:nth-child(3) { width: 14% !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(5),
.sensor-settings-wide .sensor-field-table-config td:nth-child(5) { width: 112px !important; }
.sensor-settings-wide .sensor-field-table-config th:nth-child(11),
.sensor-settings-wide .sensor-field-table-config td:nth-child(11) { width: 132px !important; }

.language-select {
  width: 100%;
}
.compact-access-table td.center,
.compact-access-table th.center {
  text-align: center;
}
.compact-access-table input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #1d4ed8;
}

/* User role column/readability and snapshot custom-color button refinements. */
.user-org-role-cell {
  min-width: 190px;
  width: 220px;
}
.user-org-role-select {
  min-width: 180px;
  width: 100%;
}
.compact-access-table th:nth-child(2) {
  min-width: 190px;
}
.snapshot-color-label {
  min-height: 34px !important;
  padding: 7px 12px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(243,247,247,.22) !important;
  background: rgba(255,255,255,.08) !important;
  color: #f3f7f7 !important;
  font-weight: 800 !important;
  cursor: pointer;
  line-height: 1.1;
}
.snapshot-color-label:hover {
  background: rgba(255,255,255,.14) !important;
  border-color: rgba(243,247,247,.38) !important;
}
.snapshot-color-label input[type="color"] {
  width: 28px !important;
  height: 22px !important;
  opacity: .95;
}

/* Final user/role and snapshot polish. */
.compact-access-table th:nth-child(2),
.compact-access-table td.user-org-role-cell {
  min-width: 190px;
}
.user-org-role-select {
  min-width: 180px;
  width: 100%;
}
.snapshot-color-label {
  min-height: 34px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
}
.snapshot-color-label:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(243,247,247,.32);
}
.snapshot-color-label:focus-within {
  outline: 2px solid rgba(243,247,247,.42);
  outline-offset: 2px;
}
.snapshot-color-label span {
  display: inline-flex;
  align-items: center;
  height: 100%;
}

/* User edit modal, role table fit and final snapshot/color controls. */
.frame-modal-card.modal-kind-user-form,
.user-edit-frame-modal {
  width: min(1360px, calc(100vw - 18px)) !important;
  height: min(920px, calc(100vh - 18px)) !important;
  max-width: calc(100vw - 18px) !important;
  max-height: calc(100vh - 18px) !important;
}
.frame-modal-card.modal-kind-user-form .modal-iframe,
.user-edit-frame-modal .modal-iframe {
  flex: 1 1 auto !important;
  width: 100% !important;
  min-height: 0 !important;
}
.user-modal-form-card,
.user-form-card {
  max-width: 1180px !important;
  width: min(1180px, 100%) !important;
  box-sizing: border-box;
}
.user-modal-form-card fieldset,
.user-form-card fieldset {
  min-width: 0;
}
.user-modal-form-card .table-wrap,
.user-form-card .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.user-modal-form-card .compact-access-table,
.user-form-card .compact-access-table {
  width: 100%;
  table-layout: fixed;
}
.user-modal-form-card .compact-access-table th:nth-child(1),
.user-form-card .compact-access-table th:nth-child(1) { width: 34%; }
.user-modal-form-card .compact-access-table th:nth-child(2),
.user-form-card .compact-access-table th:nth-child(2),
.user-modal-form-card .compact-access-table td.user-org-role-cell,
.user-form-card .compact-access-table td.user-org-role-cell {
  width: 46%;
  min-width: 260px;
}
.user-modal-form-card .compact-access-table th:nth-child(3),
.user-form-card .compact-access-table th:nth-child(3) { width: 20%; }
.user-modal-form-card .user-org-role-select,
.user-form-card .user-org-role-select {
  min-width: 0;
  width: 100%;
}
.snapshot-tools .snapshot-color-label {
  min-height: 34px !important;
  height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  box-sizing: border-box !important;
  padding: 0 12px !important;
  line-height: 1 !important;
}
.snapshot-tools .snapshot-color-label input[type="color"] {
  height: 22px !important;
  width: 28px !important;
  flex: 0 0 auto;
}
