:root {
  --viewer-viewport-offset: 300px;
  --viewer-max-height: min(680px, calc(100dvh - var(--viewer-viewport-offset)));
  --portal-header-h: 73px;
  --portal-footer-h: 40px;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 76px 0 48px 0;
  background: #f5f5f5;
  color: #222;
}

h1,
h2,
h3 {
  margin-top: 0;
}

button {
  cursor: pointer;
}

input,
select,
button {
  padding: 8px;
  box-sizing: border-box;
}

label {
  display: block;
  margin-top: 12px;
  margin-bottom: 4px;
  font-weight: bold;
}

input,
select {
  width: 100%;
}

.password-row {
  position: relative;
}

.password-row input {
  width: 100%;
  padding-right: 44px;
}

.password-row button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: #555;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.password-row button:hover {
  color: #222;
}

.container {
  padding: 24px;
}

#loginCard,
#statusCard {
  max-width: 480px;
}

.hidden {
  display: none !important;
}

.portal-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #1e3555;
  border-bottom: 1px solid #1f7fa2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  color: #fff;
  z-index: 30;
}

.portal-header-inner {
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.portal-logo {
  height: 48px;
  max-width: 320px;
  object-fit: contain;
}

.portal-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: nowrap;
}

.portal-title {
  font-weight: bold;
  font-size: 1rem;
  color: #fff;
}

.mode-drawer-logout {
  padding-top: 4px;
}

.mode-drawer-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #a33;
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  font-weight: 600;
}

.mode-drawer-logout-btn:hover {
  background: #fff0f0;
  border-color: #f5c6c6;
}

.mode-drawer-logout-btn i {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.mode-drawer-logout-btn span {
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-layout.mode-drawer-expanded .mode-drawer-logout-btn span {
  display: inline;
}

.mode-drawer-placeholder {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.portal-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #333;
  color: #fff;
  text-align: center;
  padding: 10px 0;
  font-size: 0.9rem;
  z-index: 20;
}

.card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.toolbar h1 {
  margin: 0;
}

.portal-layout {
  display: grid;
  grid-template-columns: 56px 360px 1fr;
  gap: 16px;
  align-items: start;
}

.portal-layout.mode-drawer-expanded {
  grid-template-columns: 164px 360px 1fr;
}

.portal-layout.admin-workspace,
.portal-layout.profile-workspace {
  grid-template-columns: 56px 1fr;
}

.portal-layout.mode-drawer-expanded.admin-workspace,
.portal-layout.mode-drawer-expanded.profile-workspace {
  grid-template-columns: 164px 1fr;
}

.mode-drawer {
  grid-column: 1;
}

.left-panel-sidebar {
  grid-column: 2;
}

.right-panel {
  grid-column: 3;
}

.portal-layout.admin-workspace .right-panel,
.portal-layout.profile-workspace .right-panel {
  grid-column: 2;
}

.left-panel,
.right-panel {
  min-width: 0;
}

.left-panel-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workspace-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid #d5deea;
  background: #f7faff;
  color: #1e3555;
  border-radius: 6px;
  font-weight: 600;
}

.workspace-nav-item.active {
  background: #1e3555;
  color: #fff;
  border-color: #1e3555;
}

.workspace-nav-item:hover:not(.active) {
  background: #edf4ff;
}

.workspace-nav-item i {
  font-size: 1rem;
}

.operations-selectors.hidden {
  display: none;
}

.workspace-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.workspace-title-group h2 {
  margin: 0;
}

.help-icon-btn {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.25px solid #2596be;
  color: #2596be;
  background: transparent;
  font-size: 10px;
  font-weight: bold;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.help-icon-btn:hover,
.help-icon-btn[aria-expanded="true"] {
  background: #2596be;
  color: #fff;
}

.help-popover {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  width: min(340px, 90vw);
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  padding: 14px 16px;
  z-index: 60;
}

.help-popover.open { display: block; }

.help-popover-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.help-popover-head strong { flex: 1; font-size: 14px; }

.help-popover p { margin: 0 0 12px; font-size: 13px; color: #333; }

.help-popover .help-popover-issues-label {
  font-size: 10.5px;
  font-weight: bold;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #b45309;
  margin: 0 0 6px;
}

.help-popover ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: #333;
}

.help-popover li { margin-bottom: 6px; }
.help-popover li:last-child { margin-bottom: 0; }

.sidebar-toggle {
  display: none;
}

.camera-list {
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
}

.tower-block {
  border-bottom: 1px solid #ddd;
}

.tower-block:last-child {
  border-bottom: none;
}

.tower-header {
  padding: 12px;
  background: #f0f0f0;
  border-bottom: 1px solid #ddd;
  cursor: pointer;
  user-select: none;
}

.tower-header:hover {
  background: #e8e8e8;
}

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

.tower-toggle {
  font-size: 0.85rem;
  color: #666;
}

.tower-cameras {
  display: block;
}

.tower-block.collapsed .tower-cameras {
  display: none;
}

.download-hint {
  margin-top: 6px;
  color: #555;
  font-size: 0.9rem;
}

.tower-name {
  font-weight: bold;
}

.tower-location {
  font-size: 0.9rem;
  color: #555;
  margin-top: 3px;
}

.camera-button {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-bottom: 1px solid #eee;
  background: #fff;
  text-align: left;
  font-size: 0.95rem;
}

.camera-button:hover {
  background: #f7f7f7;
}

.camera-button.selected {
  background: #e8f1ff;
  font-weight: bold;
}

.camera-button.disabled {
  color: #888;
  background: #f9f9f9;
  cursor: not-allowed;
}

.selected-camera-summary {
  background: #f7f7f7;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}

.selected-camera-title {
  font-weight: bold;
}

.selected-camera-meta {
  font-size: 0.9rem;
  color: #555;
  margin-top: 4px;
}

.video-wrap {
  position: relative;
  background: #111;
  border-radius: 6px;
  overflow: hidden;
  min-height: min(360px, var(--viewer-max-height));
  display: flex;
  align-items: center;
  justify-content: center;
}

video {
  width: 100%;
  max-height: min(680px, calc(100dvh - 280px));
  background: #000;
}

#playbackVideo {
  max-height: min(680px, calc(100dvh - 420px));
}

.empty-video-message {
  color: #ccc;
  padding: 24px;
  text-align: center;
}

.clip-summary {
  margin-top: 12px;
  padding: 12px;
  background: #f7f7f7;
  border: 1px solid #ddd;
  border-radius: 6px;
}

.clip-summary div {
  margin-bottom: 4px;
}

.error {
  color: #b00020;
  margin-top: 12px;
}

.success {
  color: #176b2c;
  margin-top: 12px;
}

.busy {
  color: #555;
  margin-top: 10px;
  font-size: 0.9rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #ddd;
  border-top: 3px solid #333;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.playback-view-wrap {
  --playback-view-max-height: min(680px, calc(100dvh - 470px));
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  min-height: 0;
  max-height: var(--playback-view-max-height);
  width: min(100%, calc(var(--playback-view-max-height) * 16 / 9));
  margin: 0 auto;
}

#playbackViewCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.playback-last-frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
}

.playback-view-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #ccc;
  text-align: center;
  padding: 24px;
}

.playback-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.playback-overlay-content {
  text-align: center;
}

.playback-overlay .spinner {
  width: 36px;
  height: 36px;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-top: 4px solid #fff;
  margin: 0 auto 12px auto;
}

.playback-overlay-text {
  font-size: 1rem;
}

.playback-view-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.playback-view-button-row button {
  width: auto;
}

.playback-debug-status {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: #334155;
  background: #eef2f7;
  border: 1px solid #dbe3ef;
  word-break: break-word;
}

.playback-hint-icon {
  margin-left: 6px;
  color: #666;
  font-size: 1rem;
  cursor: help;
}

.playback-hint-icon:hover {
  color: #222;
}

.playback-seeking-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.playback-seeking-overlay.nonblocking {
  inset: auto 12px 12px auto;
  background: transparent;
  display: block;
}

.playback-seeking-overlay.nonblocking .playback-overlay-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
}

.playback-seeking-overlay.nonblocking .spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  margin: 0;
}

.playback-seeking-diag-line {
  margin-top: 6px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.8);
  font-family: monospace;
  text-align: center;
}

.playback-seeking-overlay.nonblocking .playback-seeking-diag-line {
  padding: 3px 10px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  display: inline-block;
  text-align: left;
}

.playback-timeline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f7f7f7;
}

.playback-timeline-track-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  padding-bottom: 22px;
}

.playback-timeline-bar {
  position: relative;
  height: 8px;
  background: #ddd;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.playback-timeline-played {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: #2596be;
  border-radius: 4px 0 0 4px;
  pointer-events: none;
  width: 0;
}

.playback-timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #2596be;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.playback-timeline-thumb.dragging {
  cursor: grabbing;
  background: #1f7fa2;
}

.playback-timeline-thumb.seeking {
  background: #888;
  cursor: wait;
  border-color: #ccc;
}

.playback-timeline-ticks {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  pointer-events: none;
}

.playback-timeline-tick {
  position: absolute;
  top: 0;
  width: 1px;
  background: #bbb;
}

.playback-timeline-tick.major {
  height: 8px;
  background: #888;
}

.playback-timeline-tick.minor {
  height: 5px;
}

.playback-timeline-tick-label {
  position: absolute;
  top: 10px;
  font-size: 0.65rem;
  color: #666;
  transform: translateX(-50%);
  white-space: nowrap;
  line-height: 1;
}

.playback-timeline-preview {
  position: absolute;
  top: -30px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.75rem;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 2;
}

@media (max-width: 600px) {
  .playback-timeline {
    gap: 4px;
    padding: 8px 6px;
  }
}

.playback-control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f7f7f7;
  align-items: center;
}

.playback-icon-button {
  width: auto;
  min-width: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #fff;
  color: #222;
}

.playback-icon-button i {
  font-size: 1rem;
  line-height: 1;
}

.playback-icon-button:hover {
  background: #f0f0f0;
}

.playback-primary-button {
  min-width: 92px;
  background: #2596be;
  border-color: #2596be;
  color: #fff;
  font-weight: bold;
}

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

.playback-button-label {
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .playback-control-bar {
    justify-content: center;
  }
}

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

details {
  margin-top: 12px;
}

pre {
  background: #222;
  color: #eee;
  padding: 12px;
  overflow: auto;
  font-size: 0.85rem;
  border-radius: 6px;
}

.muted {
  color: #666;
  font-size: 0.9rem;
}

.mode-drawer-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  align-self: start;
  overflow: hidden;
  position: sticky;
  top: 88px;
}

.mode-drawer-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 4px;
  border: 1px solid #d5deea;
  background: #f7faff;
  color: #1e3555;
  border-radius: 4px;
  font-size: 1rem;
  margin-bottom: 6px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.mode-drawer-toggle-btn:hover {
  background: #edf4ff;
}

.mode-drawer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #1e3555;
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  font-weight: 600;
}

.mode-drawer-item:hover:not(.active) {
  background: #edf4ff;
  border-color: #d5deea;
}

.mode-drawer-item.active {
  background: #2596be;
  border-color: #2596be;
  color: #fff;
}

.mode-drawer-item i {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.mode-drawer-label {
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-layout.mode-drawer-expanded .mode-drawer-label {
  display: inline;
}

.mode-drawer-separator {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 4px 0;
}

/* workspace-nav items styled to fit inside the mode drawer */
.mode-drawer-panel .workspace-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-drawer-panel .workspace-nav-item {
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.9rem;
  padding: 10px 8px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.mode-drawer-panel .workspace-nav-item:hover:not(.active) {
  background: #edf4ff;
  border-color: #d5deea;
}

.mode-drawer-panel .workspace-nav-item.active {
  background: #1e3555;
  border-color: #1e3555;
  color: #fff;
}

.mode-drawer-panel .workspace-nav-item i {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.mode-drawer-panel .workspace-nav-item span {
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-layout.mode-drawer-expanded .mode-drawer-panel .workspace-nav-item span {
  display: inline;
}

.live-placeholder {
  min-height: min(360px, var(--viewer-max-height));
  border: 1px dashed #bbb;
  border-radius: 6px;
  background: #fafafa;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: min(100%, calc(var(--viewer-max-height) * 16 / 9));
  max-height: var(--viewer-max-height);
  aspect-ratio: 16 / 9;
  margin: 0 auto;
}

.live-tile {
  background: #111;
  border-radius: 6px;
  overflow: hidden;
  min-height: 0;
  position: relative;
  border: 1px solid #222;
}

.live-tile canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.live-tile-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.live-tile-status {
  position: absolute;
  inset: 0;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  pointer-events: none;
  font-weight: bold;
  z-index: 2;
}

.live-tile {
  cursor: pointer;
}

.live-grid.single-view {
  grid-template-columns: 1fr;
}

.live-grid.single-view .live-tile {
  display: none;
}

.live-grid.single-view .live-tile.enlarged {
  display: block;
  min-height: 0;
  max-height: var(--viewer-max-height);
  aspect-ratio: 16 / 9;
  width: min(100%, calc(var(--viewer-max-height) * 16 / 9));
  margin: 0 auto;
}

.live-grid.single-view .live-tile.enlarged canvas {
  width: 100%;
  height: 100%;
}

@media (max-width: 900px) {
  .live-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    width: 100%;
    max-height: none;
    aspect-ratio: auto;
  }

  .live-tile {
    min-height: min(320px, var(--viewer-max-height));
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 900px) {
  body {
    padding: 12px;
  }

  .portal-layout,
  .portal-layout.mode-drawer-expanded,
  .portal-layout.admin-workspace,
  .portal-layout.profile-workspace,
  .portal-layout.mode-drawer-expanded.admin-workspace,
  .portal-layout.mode-drawer-expanded.profile-workspace {
    grid-template-columns: 1fr;
  }

  .mode-drawer,
  .left-panel-sidebar,
  .right-panel,
  .portal-layout.admin-workspace .right-panel,
  .portal-layout.profile-workspace .right-panel {
    grid-column: 1;
  }

  .mode-drawer-panel {
    flex-direction: row;
    flex-wrap: wrap;
    position: static;
    min-height: unset;
  }

  .mode-drawer-toggle-btn {
    display: none;
  }

  .mode-drawer-label {
    display: inline;
  }

  .mode-drawer-panel .workspace-nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .mode-drawer-panel .workspace-nav-item span {
    display: inline;
  }

  .mode-drawer-separator {
    width: 100%;
  }

  .mode-drawer-logout {
    margin-top: 0;
    width: 100%;
  }

  .mode-drawer-logout-btn span {
    display: inline;
  }

  .camera-list {
    max-height: 320px;
  }
}
.admin-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.admin-toolbar input[type="search"] {
  width: auto;
  flex: 1;
  min-width: 160px;
  padding: 0 10px;
  font-size: 13px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 4px;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
  line-height: normal;
}

.admin-toolbar .admin-btn-primary {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
}

.admin-toolbar .loc-switch-label {
  height: 32px;
}

.admin-toolbar .muted { margin-left: auto; white-space: nowrap; font-size: 13px; }

.admin-btn-primary {
  background: #2596be;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 14px;
  font-weight: bold;
  white-space: nowrap;
}

.admin-btn-primary:hover { background: #1f7fa2; }
.admin-btn-primary:disabled { background: #aaa; cursor: not-allowed; }

.admin-btn-danger {
  background: #b00020;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 0.85rem;
}

.admin-btn-danger:hover { background: #8c0018; }
.admin-btn-danger:disabled { background: #d0d0d0; color: #999; cursor: not-allowed; }

.admin-btn-secondary {
  background: #f0f0f0;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 0.85rem;
}

.admin-btn-secondary:hover { background: #e0e0e0; }

.admin-icon-btn {
  background: transparent;
  border: none;
  color: #555;
  font-size: 1.1rem;
  padding: 4px 6px;
  line-height: 1;
}

.admin-icon-btn:hover { color: #222; }

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  background: #f0f0f0;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #ddd;
  white-space: nowrap;
}

.admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr:hover td { background: #f9f9f9; }

.admin-table-row-clickable { cursor: pointer; }

.admin-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: bold;
  white-space: nowrap;
}

.admin-status-active   { background: #d4edda; color: #155724; }
.admin-status-locked   { background: #fff3cd; color: #856404; }
.admin-status-suspended { background: #f8d7da; color: #721c24; }

.admin-action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-sub-panel {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
  background: #fafafa;
}

.admin-sub-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.admin-tower-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

.admin-tower-item:last-child { border-bottom: none; }

/* ── Location card grid ────────────────────────────────────────────── */
.loc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  background: #eef0f3;
  border-radius: 8px;
  padding: 16px;
  min-height: 80px;
}
.loc-card {
  position: relative;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.loc-card-logo {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 3px;
}
.loc-card:has(.loc-card-logo) .loc-card-name,
.loc-card:has(.loc-card-logo) .loc-card-address { padding-right: 46px; }
.loc-logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.loc-logo-preview-wrap { display: inline-flex; }
.loc-logo-preview {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 3px;
}
.loc-logo-upload-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0; }
.loc-field-hint { font-size: 11px; color: #888; margin-top: 5px; line-height: 1.4; }

.loc-card-logo.loc-logo-placeholder,
.loc-logo-preview.loc-logo-placeholder,
.loc-display-logo.loc-logo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  border: none;
  padding: 0;
}
.loc-card-logo.loc-logo-placeholder { font-size: 12px; }
.loc-logo-preview.loc-logo-placeholder { font-size: 15px; }

.loc-display-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f0f0f0;
}
.loc-display-logo-wrap { display: inline-flex; flex-shrink: 0; }
.loc-display-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 3px;
  font-size: 15px;
}
.loc-display-header-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.loc-display-name { font-size: 16px; font-weight: 600; color: #1a1a1a; }
.loc-display-address { font-size: 12px; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.loc-contacts-list { display: flex; flex-direction: column; gap: 6px; }
.loc-contact-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  background: #f9f9fa;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}
.loc-contact-row-actions { display: flex; gap: 2px; flex-shrink: 0; }
.loc-contact-form {
  margin-top: 10px;
  padding: 10px;
  background: #f9f9fa;
  border: 1px solid #eee;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.loc-contact-form-actions { display: flex; gap: 8px; margin-top: 4px; }

#profilePanel { max-width: 480px; }
.loc-card:not(.loc-deleted):hover { box-shadow: 0 2px 10px rgba(0,0,0,0.1); border-color: #1a91b8; }
.loc-card.loc-deleted { opacity: 0.6; background: #f7f7f7; }
.loc-card-name { font-size: 14px; font-weight: 600; color: #1a1a1a; }
.loc-card.loc-deleted .loc-card-name { text-decoration: line-through; color: #888; }
.loc-card-address { font-size: 12px; color: #666; min-height: 16px; }
.loc-badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.loc-badge { font-size: 11px; padding: 1px 6px; border-radius: 3px; font-weight: 500; }
.loc-badge-gps { background: #e8f4fd; color: #1565c0; }
.loc-badge-w3w { background: #fde8e8; color: #c62828; }
.loc-badge-deleted { background: #f0f0f0; color: #888; border: 1px solid #ddd; }
.loc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  gap: 6px;
}
.loc-entity-chip { font-size: 11px; background: #f1f3f4; color: #555; padding: 2px 8px; border-radius: 10px; }
.loc-card-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Right-side drawer ─────────────────────────────────────────────── */
.loc-drawer-overlay {
  display: none;
  position: fixed;
  top: var(--portal-header-h); left: 0; right: 0;
  height: calc(100vh - var(--portal-header-h) - var(--portal-footer-h));
  background: rgba(0,0,0,0.25);
  z-index: 300;
}
.loc-drawer-overlay.open { display: block; }
.loc-drawer {
  position: fixed;
  top: var(--portal-header-h); right: 0;
  width: 570px;
  max-width: 100vw;
  height: calc(100vh - var(--portal-header-h) - var(--portal-footer-h));
  background: #fff;
  box-shadow: -3px 0 20px rgba(0,0,0,0.12);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
.loc-drawer.open { transform: translateX(0); }
.loc-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}
.loc-drawer-title { font-size: 15px; font-weight: 600; }
.loc-drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ── Drawer form ───────────────────────────────────────────────────── */
.loc-form-group { margin-bottom: 16px; }
.loc-label { display: block; font-size: 13px; font-weight: 500; color: #333; margin-bottom: 5px; }
.loc-required { color: #c62828; }
.loc-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.loc-input:focus { outline: none; border-color: #1a91b8; box-shadow: 0 0 0 2px rgba(26,145,184,0.12); }
.loc-w3w-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid #ccc;
  border-radius: 5px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.loc-w3w-wrap:focus-within { border-color: #c62828; box-shadow: 0 0 0 2px rgba(198,40,40,0.1); }
.loc-w3w-prefix {
  padding: 8px 8px 8px 10px;
  font-weight: 700;
  color: #c62828;
  font-size: 14px;
  background: #fef7f7;
  border-right: 1px solid #f0d0d0;
  user-select: none;
}
.loc-w3w-input { border: none; flex: 1; padding: 8px 10px; font-size: 13px; background: transparent; }
.loc-w3w-input:focus { outline: none; }
.loc-usage { margin-bottom: 14px; }
.loc-usage-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px 6px 0 0;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #5d4037;
}
.loc-usage-panel {
  background: #fff;
  border: 1px solid #ffe082;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px 14px;
}
.loc-usage-row { font-size: 12px; color: #444; margin-top: 4px; }
.loc-usage-row:first-child { margin-top: 0; }
.loc-message { font-size: 13px; margin: 10px 0 6px; min-height: 18px; }
.loc-message.success { color: #1a7a3c; }
.loc-message.error { color: #b00020; }
.loc-toggle-wrap { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; cursor: pointer; user-select: none; }
.loc-toggle-wrap input[type=checkbox] { width: auto; margin: 0; cursor: pointer; }
.loc-input-row { display: flex; gap: 6px; align-items: stretch; }
.loc-input-row .loc-input { flex: 1; }
.loc-resolve-btn { flex-shrink: 0; background: #f4f4f5; border: 1px solid #ccc; border-radius: 5px; padding: 7px 10px; font-size: 12px; color: #555; cursor: pointer; white-space: nowrap; transition: background 0.15s; }
.loc-resolve-btn:hover:not(:disabled) { background: #e4e4e6; }
.loc-resolve-btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* ── Toggle switch ─────────────────────────────────────────────────── */
.loc-switch-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; cursor: pointer; user-select: none; white-space: nowrap; margin: 0; font-weight: normal; }
.loc-switch { position: relative; display: inline-block; width: 34px; height: 18px; flex-shrink: 0; }
.loc-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.loc-switch-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 18px; transition: background 0.2s; }
.loc-switch-slider:before { content: ""; position: absolute; width: 12px; height: 12px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.loc-switch input:checked + .loc-switch-slider { background: #1a91b8; }
.loc-switch input:checked + .loc-switch-slider:before { transform: translateX(16px); }
/* ── Location map ──────────────────────────────────────────────────── */
.loc-map-container { width: 100%; height: 220px; border-radius: 6px; overflow: hidden; border: 1px solid #ddd; margin-bottom: 14px; }
.loc-card-map { display: block; width: calc(100% + 32px); margin: -14px -16px 12px; height: 100px; object-fit: cover; border-radius: 8px 8px 0 0; }
.loc-gps-hint { font-size: 11px; color: #888; margin-top: 5px; line-height: 1.4; }
.loc-gps-hint a { color: #c62828; text-decoration: none; }
.loc-gps-hint a:hover { text-decoration: underline; }
