:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d8dee8;
  --text: #172033;
  --muted: #687386;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --warning: #b7791f;
  --ok: #15803d;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Arial, sans-serif;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}


[hidden] {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef4f8 0%, #f7f8fb 52%, #eaf6f2 100%);
}

.auth-panel {
  width: min(390px, 100%);
  padding: 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel p {
  margin: 2px 0 4px;
  color: var(--muted);
}

.auth-error {
  padding: 9px 10px;
  border: 1px solid #f0c8c4;
  border-radius: 8px;
  background: #fff5f4;
  color: var(--danger);
}

.shell.viewer-mode .workbench {
  grid-template-columns: minmax(0, 1fr);
}

.tab-item:not(.can-edit) .tab-button {
  border-radius: 8px;
}
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
}

.system-line {
  min-height: 20px;
  color: var(--muted);
  margin-top: 4px;
}

.top-actions,
.editor-head,
.form-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.segmented button {
  height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: #e2f3f0;
  color: var(--accent-dark);
  font-weight: 600;
}

button,
.modal-actions a {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 7px 12px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.modal-actions a:hover {
  border-color: #aeb8c8;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.ghost {
  background: transparent;
}

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

.workbench {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 0;
  min-height: 0;
}

.monitor {
  min-width: 0;
  padding: 16px;
  overflow: auto;
}

.camera-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-item {
  display: inline-flex;
  min-width: 0;
  max-width: 300px;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  max-width: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  background: #ffffff;
}

.tab-item.active .tab-button,
.tab-button.active {
  background: #e2f3f0;
  border-color: #8fc9c0;
  color: var(--accent-dark);
  font-weight: 600;
}

.tab-edit {
  width: 34px;
  padding: 7px 0;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  color: var(--muted);
}

.tab-item.active .tab-edit {
  background: #e2f3f0;
  border-color: #8fc9c0;
  color: var(--accent-dark);
  font-weight: 600;
}

.tab-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-button em {
  min-width: 24px;
  border-radius: 999px;
  padding: 1px 7px;
  background: #eef2f7;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  text-align: center;
}

.tab-item.active .tab-button em,
.tab-button.active em {
  background: #ffffff;
  color: var(--accent-dark);
}
.camera-grid {
  display: grid;
  gap: 12px;
  align-items: start;
}

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

.grid-3 {
  grid-template-columns: repeat(3, minmax(230px, 1fr));
}

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

.camera-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}

.camera-toolbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.camera-title {
  min-width: 0;
}

.camera-title strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camera-title span {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: #eef2f7;
  color: var(--muted);
  white-space: nowrap;
}

.badge.ok {
  background: #e6f4ea;
  color: var(--ok);
}

.badge.warn {
  background: #fff4db;
  color: var(--warning);
}

.camera-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.camera-actions button {
  min-height: 30px;
  padding: 5px 8px;
}

.frame-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #151922;
}

.stream-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: #cbd5e1;
  font-size: 12px;
}

.frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  border: 1px dashed #b9c3d2;
  border-radius: 8px;
  background: #ffffff;
}

.empty.small {
  min-height: 68px;
  padding: 12px;
  font-size: 12px;
}

.editor {
  min-width: 0;
  padding: 16px;
  background: #ffffff;
  border-left: 1px solid var(--line);
  overflow: auto;
}

.editor-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--text);
  background: #ffffff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 118, 110, 0.12);
}

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

.compact {
  align-items: end;
}

.check-row {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding-top: 18px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.custom-fields {
  display: none;
  gap: 12px;
}

.custom-fields.visible {
  display: grid;
}

.form-actions {
  justify-content: space-between;
  padding-top: 6px;
}


.admin-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
}

.admin-tabs button {
  min-width: 0;
  padding: 7px 8px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-tabs button.active {
  background: #e2f3f0;
  border-color: #8fc9c0;
  color: var(--accent-dark);
  font-weight: 600;
}

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

.user-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.user-row.active {
  border-color: #8fc9c0;
  background: #eaf7f4;
}

.user-meta {
  min-width: 0;
}

.user-meta strong,
.user-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta span {
  color: var(--muted);
  font-size: 12px;
}

.empty.small {
  min-height: 76px;
  padding: 14px;
}

.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.backup-note {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.backup-list,
.backup-section {
  display: grid;
  gap: 10px;
}

.backup-section {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.backup-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.backup-section-head,
.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.backup-section-head span {
  color: var(--muted);
  font-size: 12px;
}

.backup-row {
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.backup-row-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.backup-row-main strong,
.backup-row-main span,
.backup-warnings span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.backup-row-main strong {
  font-size: 12px;
  white-space: nowrap;
}

.backup-row-main span,
.backup-row-note,
.backup-warnings span {
  color: var(--muted);
  font-size: 12px;
}

.backup-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.backup-row-actions a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 7px 12px;
  text-decoration: none;
}

.backup-warnings {
  display: grid;
  gap: 2px;
}
button:disabled,
input:disabled,
select:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: #080b10;
}

.modal[hidden] {
  display: none;
}

.modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #111827;
  color: #ffffff;
}

.modal-actions a,
.modal-actions button {
  min-height: 30px;
  color: #ffffff;
  background: #1f2937;
  border-color: #374151;
}

.modal iframe {
  width: 100%;
  height: 100%;
  border: 0;
}


.modal-title-block {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.modal-title-block strong,
.modal-title-block span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-title-block span {
  color: #cbd5e1;
  font-size: 12px;
}

.modal-actions button.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
  font-weight: 600;
}

.modal-archive-controls {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #243042;
  border-bottom: 1px solid #243042;
  background: #0f172a;
  color: #ffffff;
}

.archive-control-row,
.archive-timeline-row {
  display: grid;
  gap: 8px;
  align-items: end;
}

.archive-control-row {
  grid-template-columns: auto minmax(190px, 240px) auto 110px auto auto;
}

.archive-control-row label {
  gap: 4px;
}

.archive-control-row label span,
.archive-hint,
.archive-timeline-row span {
  color: #cbd5e1;
  font-size: 12px;
}

.archive-control-row input,
.archive-control-row select {
  min-height: 34px;
  border-color: #334155;
  background: #111827;
  color: #ffffff;
}

.archive-control-row button {
  min-height: 34px;
  color: #ffffff;
  background: #1f2937;
  border-color: #374151;
}

.archive-timeline-row {
  grid-template-columns: auto minmax(160px, 1fr) auto 74px;
}

.archive-timeline-row input[type="range"] {
  width: 100%;
  padding: 0;
}

.archive-timeline-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  background: #111827;
  color: #ffffff;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 80;
}


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

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

@media (max-width: 760px) {
  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

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

  .modal-bar {
    align-items: stretch;
    flex-direction: column;
    min-height: 88px;
  }

  .archive-control-row,
  .archive-timeline-row {
    grid-template-columns: 1fr;
  }

  .archive-timeline-row strong {
    text-align: left;
  }
}



.status-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.status-stat,
.status-row,
.event-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 9px 10px;
}

.status-stat strong {
  display: block;
  font-size: 18px;
}

.status-stat span,
.status-row span,
.event-row span,
.notification-meta {
  color: var(--muted);
  font-size: 12px;
}

.status-list,
.event-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.event-list {
  max-height: 260px;
  overflow: auto;
}

.status-row,
.event-row {
  display: grid;
  gap: 4px;
}

.status-row-head,
.event-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.camera-status-line {
  min-height: 24px;
  padding: 5px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}



.status-tab .tab-button {
  border-radius: 8px;
}

.status-page {
  display: grid;
  gap: 14px;
  align-items: start;
}

.status-page-head,
.status-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-page-head h2,
.status-section-title h2 {
  font-size: 20px;
}

.status-page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(220px, 420px);
  gap: 10px;
  align-items: end;
}
.status-page-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.status-page-summary .status-stat {
  text-align: left;
  cursor: pointer;
}

.status-page-summary .status-stat.active {
  background: #e2f3f0;
  border-color: #8fc9c0;
  color: var(--accent-dark);
}

.status-camera-list {
  display: grid;
  gap: 10px;
}

.status-camera-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.status-camera-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.status-camera-head div {
  min-width: 0;
}

.status-camera-head strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-camera-head span:not(.badge) {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-camera-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.status-metric {
  min-width: 0;
  padding: 9px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.status-metric:nth-child(4n) {
  border-right: 0;
}

.status-metric.wide {
  grid-column: 1 / -1;
  border-right: 0;
}

.status-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.status-metric strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}


@media (max-width: 1180px) {
  .status-page-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-camera-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-metric:nth-child(4n) {
    border-right: 1px solid var(--line);
  }

  .status-metric:nth-child(2n) {
    border-right: 0;
  }
}

@media (max-width: 760px) {
  .status-page-head,
  .status-section-title,
  .status-camera-head {
    align-items: stretch;
    flex-direction: column;
  }

  .status-page-summary,
  .status-filter-panel,
  .status-camera-grid {
    grid-template-columns: 1fr;
  }

  .status-metric,
  .status-metric:nth-child(2n),
  .status-metric:nth-child(4n) {
    border-right: 0;
  }
}
.status-camera-events {
  display: grid;
  gap: 6px;
  padding: 10px 12px 12px;
  background: #fbfcfd;
  border-top: 1px solid var(--line);
}

.status-camera-events-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-camera-events-title strong {
  font-size: 13px;
}

.status-camera-events-title span,
.status-camera-event span,
.status-camera-event time,
.status-camera-events-empty {
  color: var(--muted);
  font-size: 12px;
}

.status-camera-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.status-camera-event div {
  min-width: 0;
}

.status-camera-event strong {
  display: block;
  font-size: 12px;
}

.status-camera-event p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.badge.danger {
  background: #fff1f0;
  color: var(--danger);
}

.badge.neutral {
  background: #eef2f7;
  color: var(--muted);
}

.badge.maintenance {
  background: #f3f4f6;
  color: #4b5563;
}

.dlna-note {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.dlna-profile-list,
.dlna-camera-list {
  display: grid;
  gap: 10px;
}

.dlna-profile,
.dlna-camera-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.dlna-profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.dlna-profile-head strong,
.dlna-camera-group h3,
.dlna-camera-row strong,
.dlna-camera-row em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dlna-profile-head strong {
  min-width: 0;
}

.dlna-profile-head span,
.dlna-camera-row em,
.dlna-warning {
  color: var(--muted);
  font-size: 12px;
}

.dlna-grid-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dlna-warning {
  margin-top: 8px;
  color: var(--warning);
}

.dlna-camera-list {
  margin-top: 2px;
}

.dlna-camera-group {
  display: grid;
  gap: 6px;
}

.dlna-camera-group h3 {
  margin: 0 0 2px;
  font-size: 13px;
}

.dlna-camera-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 0;
}

.dlna-camera-row input {
  width: 18px;
  min-height: 18px;
}

.dlna-camera-row span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.dlna-camera-row strong,
.dlna-camera-row em {
  display: block;
}

.dlna-camera-row em {
  font-style: normal;
}


.dlna-page {
  display: grid;
  gap: 14px;
  align-items: start;
}

.dlna-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dlna-page-head h2 {
  font-size: 20px;
}

.dlna-page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.dlna-main-form {
  display: grid;
  gap: 12px;
}

.dlna-layout-panel {
  display: grid;
  grid-template-columns: minmax(100px, 150px) minmax(100px, 150px) minmax(150px, 190px) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.dlna-layout-facts {
  min-height: 36px;
  display: grid;
  align-content: center;
  gap: 2px;
  min-width: 0;
}

.dlna-layout-facts strong {
  font-size: 18px;
  line-height: 1;
}

.dlna-layout-facts span,
.dlna-selected-note span {
  color: var(--muted);
  font-size: 12px;
}

.dlna-selected-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.dlna-camera-list.wide {
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

@media (max-width: 1180px) {
  .dlna-layout-panel,
  .dlna-camera-list.wide {
    grid-template-columns: 1fr 1fr;
  }

  .dlna-layout-panel .primary,
  .dlna-layout-facts {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .dlna-page-head,
  .dlna-selected-note {
    align-items: stretch;
    flex-direction: column;
  }

  .dlna-layout-panel,
  .dlna-camera-list.wide {
    grid-template-columns: 1fr;
  }
}


.archive-page {
  display: grid;
  gap: 14px;
  align-items: start;
}

.archive-page-head,
.archive-search-panel,
.archive-player-panel,
.archive-results-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.archive-page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.archive-page-head h2,
.archive-player-head h3,
.archive-results-head h3 {
  margin: 0;
}

.archive-page-head p,
.archive-player-head p,
.archive-results-head span,
.archive-meta,
.archive-result span {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.archive-search-panel {
  padding: 14px 16px;
}

.archive-form-grid {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(160px, 1fr) minmax(160px, 1fr) 110px auto;
  gap: 10px;
  align-items: end;
}

.archive-camera-select {
  min-width: 0;
}

.archive-meta {
  min-height: 18px;
}

.archive-player-head,
.archive-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.archive-player-frame {
  aspect-ratio: 16 / 9;
  background: #151922;
}

.archive-player-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.archive-player-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background: #151922;
}

.archive-results {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
}

.archive-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.archive-result strong,
.archive-result span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .archive-form-grid {
    grid-template-columns: minmax(260px, 1.5fr) repeat(2, minmax(150px, 1fr));
  }

  .archive-form-grid button,
  .archive-form-grid label:nth-child(4) {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .archive-page-head,
  .archive-player-head,
  .archive-results-head,
  .archive-result {
    grid-template-columns: 1fr;
    display: grid;
    align-items: stretch;
  }

  .archive-form-grid {
    grid-template-columns: 1fr;
  }

  .archive-result button,
  .archive-page-head button,
  .archive-player-head button {
    width: 100%;
  }
}

.users-page {
  display: grid;
  gap: 14px;
  align-items: start;
}

.users-page-head,
.user-page-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.users-page-head h2,
.user-page-form-head h3 {
  font-size: 20px;
}

.users-page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.users-list-panel,
.user-page-form,
.user-access-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.users-list-panel h3,
.user-access-column h3,
.access-camera-group h4 {
  margin: 0;
  font-size: 14px;
}

.user-list.wide {
  margin: 10px 0 0;
}

.user-list.wide .user-row {
  width: 100%;
  text-align: left;
  background: #f8fafc;
}

.user-list.wide .user-row.active {
  background: #eaf7f4;
}

.user-page-form {
  display: grid;
  gap: 12px;
}

.user-access-section {
  display: grid;
  gap: 10px;
}

.user-access-note {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

.user-access-columns {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 12px;
}

.user-access-column {
  display: grid;
  gap: 8px;
  align-content: start;
}

.access-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 5px 0;
}

.access-check input {
  width: 18px;
  min-height: 18px;
}

.access-check span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.access-check strong,
.access-check em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-check em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.access-camera-group {
  display: grid;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.access-camera-group:first-of-type {
  border-top: 0;
  padding-top: 0;
}

@media (max-width: 1180px) {
  .users-layout,
  .user-access-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .users-page-head,
  .user-page-form-head {
    align-items: stretch;
    flex-direction: column;
  }
}
/* mobile-pwa-20260710-1115 */


@media (max-width: 760px) {
  body {
    font-size: 15px;
    background: #eef2f6;
  }

  .auth-screen {
    min-height: 100dvh;
    padding: 16px;
  }

  .auth-panel {
    padding: 18px;
  }

  .shell {
    min-height: 100dvh;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: auto;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  }

  .topbar h1 {
    font-size: 18px;
  }

  .system-line {
    min-height: 18px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
  }

  .segmented {
    min-width: 0;
  }

  .segmented button,
  button,
  .modal-actions a {
    min-height: 42px;
  }

  .monitor {
    padding: 10px;
    overflow: visible;
  }

  .camera-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    gap: 7px;
    margin: 0 -10px 10px;
    padding: 0 10px 4px;
    scrollbar-width: none;
  }

  .camera-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-item {
    flex: 0 0 auto;
    max-width: min(78vw, 320px);
  }

  .tab-button,
  .tab-edit {
    min-height: 42px;
  }

  .camera-grid {
    gap: 10px;
  }

  .camera-card {
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  }

  .camera-toolbar {
    min-height: 44px;
    padding: 8px;
  }

  .camera-title span,
  .camera-status-line {
    font-size: 11px;
  }

  .camera-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .camera-actions button {
    min-height: 38px;
    padding: 6px 8px;
  }

  .modal {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 100dvh;
  }

  .modal-bar {
    min-height: auto;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  }

  .modal-bar strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .modal-actions a,
  .modal-actions button {
    min-width: 0;
    text-align: center;
  }

  .toast {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 20px);
  }
}

@media (max-width: 520px) {
  .top-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #newCameraButton:not([hidden]) {
    grid-column: 1 / -1;
  }

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


/* Compact archive controls in the camera player. */
.modal {
  grid-template-rows: 42px auto minmax(0, 1fr);
}

.modal-bar {
  min-height: 42px;
  padding: 6px 10px;
}

.modal-actions {
  flex-wrap: wrap;
  gap: 6px;
}

.modal-actions a,
.modal-actions button {
  min-height: 28px;
  padding: 4px 9px;
}

.modal-archive-controls {
  padding: 6px 10px;
  gap: 5px;
  align-content: start;
}

.archive-control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: 980px;
}

.archive-control-row label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.archive-control-row label span {
  display: none;
}

.archive-control-row input[type="datetime-local"] {
  width: 186px;
}

.archive-stream-select select {
  width: 78px;
}

.archive-control-row button,
.archive-control-row input,
.archive-control-row select {
  min-height: 28px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.archive-timeline-row {
  grid-template-columns: 34px minmax(180px, 760px) 34px 48px;
  max-width: 980px;
  gap: 6px;
  align-items: center;
}

.archive-hint {
  display: none;
}

