.card {
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top-color: var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.card-head {
  background: rgba(255, 255, 255, 0.18);
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 48px;
  padding: 12px 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.card-body {
  padding: 14px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 118px;
}

.metric-label {
  color: var(--text-secondary);
  font-size: 13px;
}

.metric-value {
  font-size: 28px;
  font-weight: 760;
  line-height: 1.1;
}

.metric-foot {
  color: var(--text-muted);
  font-size: 12px;
}

.badge {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  gap: 5px;
  line-height: 1;
  padding: 6px 9px;
  white-space: nowrap;
}

.badge.success {
  background: var(--success-soft);
  color: var(--success);
}

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

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.badge.neutral {
  background: #f3f4f6;
  color: var(--text-secondary);
}

.button {
  align-items: center;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--text-main);
  display: inline-flex;
  font-weight: 650;
  gap: 7px;
  min-height: 34px;
  padding: 7px 11px;
}

.button:hover {
  background: rgba(255, 255, 255, 0.96);
}

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: #1d4ed8;
}

.button.danger {
  border-color: #fecaca;
  color: var(--danger);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.button.small {
  min-height: 29px;
  padding: 5px 8px;
  font-size: 12px;
}

.button[data-action="refresh"] {
  justify-content: center;
  min-width: 82px;
}

.button.small[data-action="refresh"] {
  min-width: 68px;
}

.refresh-status {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  min-width: 106px;
}

.refresh-spinner {
  animation: refresh-spin 0.72s linear infinite;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 13px;
  width: 13px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label,
.field-label {
  align-items: center;
  color: var(--text-secondary);
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  gap: 6px;
}

.input,
.select,
.textarea {
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  color: var(--text-main);
  min-height: 36px;
  padding: 8px 10px;
  width: 100%;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.table-wrap {
  overflow: auto;
}

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

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.table th {
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  background: rgba(241, 245, 249, 0.84);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tr:hover td {
  background: rgba(239, 246, 255, 0.62);
}

.camera-catalog .table {
  min-width: 1060px;
}

.camera-catalog .table td {
  overflow-wrap: anywhere;
}

.camera-catalog .table td:nth-child(2) {
  max-width: 320px;
}

.camera-catalog .table td:nth-child(3) {
  max-width: 360px;
}

.camera-catalog .camera-catalog-invalid td:first-child {
  box-shadow: inset 3px 0 var(--danger);
}

.camera-catalog .camera-catalog-invalid td:nth-child(2) .secondary-text {
  color: var(--danger);
  margin-top: 6px;
}

.kv {
  display: grid;
  gap: 8px;
}

.kv-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 120px minmax(0, 1fr);
}

.kv-key {
  color: var(--text-muted);
}

.kv-value {
  min-width: 0;
  word-break: break-word;
}

.tabs {
  align-items: center;
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-secondary);
  padding: 7px 12px;
}

.tab.active {
  background: var(--primary-soft);
  border-color: #bfdbfe;
  color: var(--primary);
  font-weight: 700;
}

.empty,
.error-box,
.loading {
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  align-items: center;
  background: var(--bg-panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  color: var(--text-secondary);
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 150px;
  padding: 24px;
  text-align: center;
}

.error-box {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #991b1b;
  justify-items: start;
  text-align: left;
}

.drawer-backdrop,
.modal-backdrop {
  background: rgba(15, 23, 42, 0.34);
  inset: 0;
  position: fixed;
  z-index: 60;
}

.drawer {
  -webkit-backdrop-filter: blur(22px) saturate(138%);
  backdrop-filter: blur(22px) saturate(138%);
  background: rgba(255, 255, 255, 0.91);
  border-left: 1px solid var(--border);
  bottom: 0;
  box-shadow: -12px 0 28px rgba(15, 23, 42, 0.12);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  position: fixed;
  right: 0;
  top: 0;
  width: min(560px, calc(100vw - 32px));
  z-index: 70;
}

.drawer-head,
.modal-head {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.drawer-title,
.modal-title {
  align-items: center;
  display: flex;
  font-size: 17px;
  font-weight: 760;
  gap: 8px;
  margin: 0;
}

.title-help {
  align-items: center;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: var(--primary);
  cursor: help;
  display: inline-flex;
  font-size: 12px;
  height: 19px;
  justify-content: center;
  line-height: 1;
  position: relative;
  width: 19px;
}

.title-help::after {
  background: #0f172a;
  border-radius: 9px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.2);
  color: #fff;
  content: attr(data-tooltip);
  display: none;
  font-size: 12px;
  font-weight: 500;
  left: 50%;
  line-height: 1.5;
  max-width: min(520px, calc(100vw - 64px));
  min-width: 320px;
  padding: 10px 12px;
  position: absolute;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  white-space: pre-line;
  z-index: 100;
}

.title-help:hover::after,
.title-help:focus::after {
  display: block;
}

.field-help {
  align-items: center;
  background: #eef6ff;
  border: 1px solid #cfe4ff;
  border-radius: 999px;
  color: var(--primary);
  cursor: help;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 11px;
  height: 16px;
  justify-content: center;
  line-height: 1;
  position: relative;
  width: 16px;
}

.field-help::after {
  background: #0f172a;
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.2);
  color: #fff;
  content: attr(data-tooltip);
  display: none;
  font-size: 12px;
  font-weight: 500;
  left: 0;
  line-height: 1.45;
  max-width: min(420px, calc(100vw - 72px));
  min-width: 260px;
  padding: 9px 10px;
  position: absolute;
  top: calc(100% + 8px);
  white-space: normal;
  z-index: 110;
}

.field-help:hover::after,
.field-help:focus::after {
  display: block;
}

.field-description {
  color: var(--text-muted);
  display: block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.drawer-body,
.modal-body {
  overflow: auto;
  padding: 16px;
}

.modal {
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-top-color: rgba(255, 255, 255, 0.88);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  left: 50%;
  max-height: min(82vh, 760px);
  overflow: hidden;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 32px));
  z-index: 80;
}

.modal.event-detail-modal {
  max-height: min(94vh, 1040px);
  width: min(1440px, calc(100vw - 36px));
}

.event-detail-modal .modal-body {
  padding: 18px;
}

.modal-actions {
  align-items: center;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
}

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

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

.rule-param-section {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  display: grid;
  gap: 12px;
  padding: 12px;
}

.rule-param-section-head {
  align-items: start;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
}

.rule-param-section-head h3 {
  font-size: 14px;
  margin: 0;
}

.rule-param-section-head p {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  margin: 4px 0 0;
}

.rule-section-grid {
  gap: 12px;
}

.rule-choice-grid {
  background: var(--bg-panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  max-height: 220px;
  overflow: auto;
  padding: 10px;
}

.rule-choice,
.rule-switch {
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  display: flex;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
}

.rule-choice span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-switch {
  justify-content: space-between;
}

.toast-host {
  display: grid;
  gap: 8px;
  position: fixed;
  right: 18px;
  top: 76px;
  z-index: 100;
}

.toast {
  -webkit-backdrop-filter: blur(18px) saturate(132%);
  backdrop-filter: blur(18px) saturate(132%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  min-width: 260px;
  padding: 10px 12px;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.danger {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

.json-box {
  background: #0f172a;
  border-radius: 10px;
  color: #e5e7eb;
  max-height: 440px;
  overflow: auto;
  padding: 12px;
}

.copyable {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  max-width: 100%;
}
