:root {
  color-scheme: dark;
  --bg: #07111e;
  --bg-deep: #040b14;
  --sidebar: #081522;
  --surface: #0d1b2b;
  --surface-2: #102238;
  --surface-3: #142940;
  --surface-soft: rgba(20, 41, 64, 0.62);
  --border: rgba(151, 185, 211, 0.16);
  --border-strong: rgba(151, 185, 211, 0.28);
  --text: #e8f3fc;
  --text-soft: #c4d5e3;
  --muted: #8ea6ba;
  --muted-strong: #a9bdcd;
  --primary: #38bdf8;
  --primary-strong: #0ea5e9;
  --primary-soft: rgba(56, 189, 248, 0.12);
  --cyan: #22d3ee;
  --blue: #60a5fa;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.12);
  --violet: #a78bfa;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.24);
  --radius-xl: 20px;
  --radius-lg: 15px;
  --radius-md: 11px;
  --radius-sm: 8px;
  --sidebar-width: 258px;
  --font-size-base: 15px;
  --transition: 160ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 80% -10%, rgba(14, 165, 233, 0.09), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

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

button {
  color: inherit;
}

button,
select,
label,
input[type="checkbox"] {
  cursor: pointer;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
  cursor: text;
}

select {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.38);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

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

h1,
h2,
h3,
strong {
  font-weight: 500;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.48rem, 2vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.1rem, 1.5vw, 1.28rem);
  line-height: 1.3;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.4;
}

svg {
  display: block;
}

.sr-only {
  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;
}

.eyebrow,
.section-kicker,
.nav-caption {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--bg-deep);
  color: var(--muted-strong);
}

.boot-screen p {
  margin: 0;
}

.boot-mark {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 20px;
}

.boot-mark span {
  width: 5px;
  height: 11px;
  border-radius: 10px;
  background: var(--primary);
  animation: boot-wave 900ms ease-in-out infinite;
}

.boot-mark span:nth-child(2) {
  height: 19px;
  animation-delay: 120ms;
}

.boot-mark span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes boot-wave {
  0%, 100% { transform: scaleY(0.65); opacity: 0.55; }
  50% { transform: scaleY(1); opacity: 1; }
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(rgba(4, 11, 20, 0.35), rgba(4, 11, 20, 0.82)),
    radial-gradient(circle at 20% 20%, rgba(34, 211, 238, 0.13), transparent 29rem),
    radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.11), transparent 28rem),
    var(--bg-deep);
}

.login-panel {
  width: min(100%, 480px);
  padding: clamp(25px, 5vw, 42px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: rgba(10, 25, 41, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 31px;
}

.login-brand h1 {
  margin-bottom: 8px;
}

.login-brand p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.18), rgba(34, 211, 238, 0.06));
  color: var(--cyan);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-mark-large {
  width: 54px;
  height: 54px;
  border-radius: 16px;
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.login-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
}

.field > label,
.compact-field > span {
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 500;
}

.field input,
.field textarea,
.field select,
.compact-field select,
.search-field input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(5, 15, 26, 0.72);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.field input,
.field select,
.compact-field select,
.search-field input {
  min-height: 43px;
  padding: 9px 12px;
}

.field textarea {
  min-height: 96px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.45;
}

.field input:hover,
.field textarea:hover,
.field select:hover,
.compact-field select:hover,
.search-field:hover input {
  border-color: rgba(151, 185, 211, 0.4);
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.compact-field select:focus,
.search-field input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
  background: rgba(7, 20, 34, 0.94);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.77rem;
}

.field-error {
  margin: 0;
  color: #fda4af;
  font-size: 0.78rem;
}

.form-message {
  margin: -3px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
}

.error-message {
  border: 1px solid rgba(251, 113, 133, 0.25);
  background: var(--red-soft);
  color: #fecdd3;
}

.login-note {
  margin: 25px 0 0;
  padding-top: 21px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.79rem;
  text-align: center;
}

.button,
.icon-button,
.nav-item,
.mobile-nav-item,
.quick-action,
.add-card-button,
.danger-button,
.ghost-button,
.collapse-button {
  border: 0;
  font-weight: 500;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
}

.button {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.button svg,
.icon-button svg,
.nav-item svg,
.mobile-nav-item svg,
.quick-action svg,
.ghost-button svg,
.danger-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.button:not(:disabled):active,
.icon-button:not(:disabled):active,
.quick-action:not(:disabled):active,
.add-card-button:not(:disabled):active {
  transform: translateY(1px);
}

.button-primary {
  border-color: rgba(56, 189, 248, 0.35);
  background: linear-gradient(135deg, var(--primary-strong), #1686d8);
  color: #f8fcff;
  box-shadow: 0 7px 18px rgba(14, 165, 233, 0.15);
}

.button-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1bb5ec, #1a91e5);
}

.button-secondary {
  border-color: var(--border-strong);
  background: rgba(16, 34, 56, 0.8);
  color: var(--text-soft);
}

.button-secondary:hover:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.34);
  background: var(--surface-3);
  color: var(--text);
}

.button-large {
  min-height: 47px;
  margin-top: 4px;
  padding-inline: 18px;
  border-radius: var(--radius-md);
}

.icon-button {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.icon-button:hover {
  border-color: var(--border);
  background: var(--surface-3);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 22px 17px 17px;
  border-right: 1px solid var(--border);
  background: rgba(8, 21, 34, 0.96);
  backdrop-filter: blur(18px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 24px;
}

.sidebar-brand > div:last-child {
  display: grid;
}

.sidebar-brand strong {
  font-size: 1.06rem;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
}

.nav-caption {
  padding: 0 12px;
  margin: 12px 0 7px;
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 11px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-strong);
  text-align: left;
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.nav-item:hover {
  background: rgba(56, 189, 248, 0.07);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--primary-soft);
  color: #b9e9fd;
}

.nav-item.is-active::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -17px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
  content: "";
}

.nav-dirty,
.mobile-dirty {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.09);
}

.sidebar-footer {
  display: grid;
  gap: 13px;
  margin-top: auto;
}

.connection-state,
.account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(16, 34, 56, 0.42);
}

.connection-state > div {
  display: grid;
  min-width: 0;
}

.connection-state span:not(.status-dot),
.account-copy strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-state small,
.account-copy span {
  color: var(--muted);
  font-size: 0.7rem;
}

.status-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status-ok {
  background: var(--green) !important;
  box-shadow: 0 0 0 4px var(--green-soft);
}

.status-warning {
  background: var(--amber) !important;
  box-shadow: 0 0 0 4px var(--amber-soft);
}

.status-error {
  background: var(--red) !important;
  box-shadow: 0 0 0 4px var(--red-soft);
}

.status-unknown {
  background: var(--muted) !important;
}

.account-row {
  padding: 9px;
}

.account-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 9px;
  background: var(--primary-soft);
  color: #bae9fc;
  font-size: 0.79rem;
  font-weight: 500;
}

.account-copy {
  display: grid;
  min-width: 0;
  flex: 1;
}

.workspace {
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  min-height: 87px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--border);
  background: rgba(7, 17, 30, 0.88);
  backdrop-filter: blur(18px);
}

.topbar-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.freshness-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(16, 34, 56, 0.52);
  color: var(--muted-strong);
  font-size: 0.77rem;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.freshness-chip.is-error .pulse-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}

.content {
  width: min(100%, 1660px);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 38px) clamp(18px, 3vw, 42px) 56px;
}

.page {
  animation: page-enter 180ms ease-out;
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-soft);
  font-size: 0.87rem;
}

.notice-warning {
  border-color: rgba(251, 191, 36, 0.25);
  background: var(--amber-soft);
  color: #fde68a;
}

.notice-error {
  border-color: rgba(251, 113, 133, 0.28);
  background: var(--red-soft);
  color: #fecdd3;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card,
.skeleton-card {
  min-width: 0;
  min-height: 128px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(16, 34, 56, 0.86), rgba(10, 25, 41, 0.82));
}

.kpi-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  gap: 5px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

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

.kpi-value {
  align-self: end;
  overflow: hidden;
  font-size: clamp(1.55rem, 2.6vw, 2.15rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
}

.kpi-meta {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-icon {
  display: grid;
  grid-row: 1 / 3;
  grid-column: 2;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}

.kpi-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.kpi-icon.icon-alert { background: var(--red-soft); color: var(--red); }
.kpi-icon.icon-activity { background: var(--green-soft); color: var(--green); }
.kpi-icon.icon-people { background: rgba(167, 139, 250, 0.12); color: var(--violet); }

.skeleton-card,
.skeleton-line {
  position: relative;
  overflow: hidden;
}

.skeleton-card::after,
.skeleton-line::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.045), transparent);
  content: "";
  transform: translateX(-100%);
  animation: skeleton 1.5s infinite;
}

@keyframes skeleton {
  to { transform: translateX(100%); }
}

.overview-grid,
.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(13, 27, 43, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.panel-wide,
.chart-span-2 {
  grid-column: span 1;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.status-badge,
.feature-badge,
.camera-count-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 0.72rem;
  white-space: nowrap;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-badge.status-good {
  border-color: rgba(52, 211, 153, 0.2);
  background: var(--green-soft);
  color: #6ee7b7;
}

.status-badge.status-warn {
  border-color: rgba(251, 191, 36, 0.2);
  background: var(--amber-soft);
  color: #fcd34d;
}

.status-badge.status-bad {
  border-color: rgba(251, 113, 133, 0.2);
  background: var(--red-soft);
  color: #fda4af;
}

.status-neutral {
  color: var(--muted-strong);
}

.service-grid,
.freshness-list {
  display: grid;
  gap: 9px;
}

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

.service-item,
.freshness-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid rgba(151, 185, 211, 0.1);
  border-radius: var(--radius-md);
  background: rgba(16, 34, 56, 0.42);
}

.service-icon {
  display: grid;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-3);
  color: var(--muted-strong);
}

.service-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.service-copy,
.freshness-copy {
  display: grid;
  min-width: 0;
  flex: 1;
}

.service-copy strong,
.freshness-copy strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-copy span,
.freshness-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-item .status-dot,
.freshness-item .status-dot {
  margin-left: auto;
}

.freshness-time {
  flex: 0 0 auto;
  color: var(--muted-strong);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.empty-inline {
  padding: 18px 3px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.quick-actions {
  display: grid;
  gap: 9px;
}

.quick-action {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 59px;
  padding: 10px 11px;
  border: 1px solid rgba(151, 185, 211, 0.1);
  border-radius: var(--radius-md);
  background: rgba(16, 34, 56, 0.42);
  text-align: left;
}

.quick-action:hover {
  border-color: rgba(56, 189, 248, 0.25);
  background: rgba(20, 41, 64, 0.68);
}

.quick-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}

.quick-action > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.quick-action strong {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.quick-action small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.71rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-arrow {
  color: var(--muted);
}

.page-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 21px;
}

.page-toolbar h2 {
  margin-bottom: 5px;
  font-size: 1.35rem;
}

.page-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.dirty-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fcd34d;
  font-size: 0.78rem;
  white-space: nowrap;
}

.dirty-indicator > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.config-meta {
  min-height: 21px;
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 0.77rem;
  overflow-wrap: anywhere;
}

.client-list {
  display: grid;
  gap: 15px;
}

.client-card {
  overflow: clip;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(13, 27, 43, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.client-card.has-error {
  border-color: rgba(251, 113, 133, 0.4);
}

.client-header {
  display: flex;
  min-height: 75px;
  align-items: center;
  gap: 13px;
  padding: 14px 17px;
  border-bottom: 1px solid transparent;
}

.client-card.is-open .client-header {
  border-bottom-color: var(--border);
}

.client-index {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: #a5e3fb;
  font-size: 0.78rem;
  font-weight: 500;
}

.client-title {
  display: grid;
  min-width: 0;
  flex: 1;
}

.client-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-title span {
  color: var(--muted);
  font-size: 0.75rem;
}

.client-header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.client-status-button {
  min-height: 35px;
  padding: 7px 10px;
  font-size: 0.76rem;
}

.collapse-button {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.collapse-button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.collapse-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  transition: transform var(--transition);
}

.client-card.is-open .collapse-button svg {
  transform: rotate(180deg);
}

.client-body {
  display: none;
  padding: 19px;
}

.client-card.is-open .client-body {
  display: grid;
  gap: 20px;
}

.form-section {
  display: grid;
  gap: 14px;
}

.form-section + .form-section {
  padding-top: 19px;
  border-top: 1px solid var(--border);
}

.form-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-section-heading h3 {
  color: var(--text-soft);
}

.form-section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

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

.field-span-2 {
  grid-column: span 2;
}

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

.feature-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(151, 185, 211, 0.12);
  border-radius: var(--radius-md);
  background: rgba(16, 34, 56, 0.4);
}

.feature-panel.feature-wide {
  grid-column: span 3;
}

.feature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.feature-header h3 {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.feature-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.toggle-control,
.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-soft);
  font-size: 0.8rem;
  white-space: nowrap;
}

.toggle-control input,
.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(5, 15, 26, 0.8);
  transition: background var(--transition), border-color var(--transition);
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
  transition: transform var(--transition), background var(--transition);
}

.toggle-control input:checked + .switch-track,
.switch-control input:checked + .switch-track {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(14, 165, 233, 0.26);
}

.toggle-control input:checked + .switch-track::after,
.switch-control input:checked + .switch-track::after {
  background: var(--cyan);
  transform: translateX(16px);
}

.toggle-control input:focus-visible + .switch-track,
.switch-control input:focus-visible + .switch-track {
  outline: 3px solid rgba(56, 189, 248, 0.38);
  outline-offset: 2px;
}

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

.desktop-app-list {
  display: grid;
  gap: 10px;
}

.desktop-pairing-controls {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.desktop-pairing-controls input {
  min-height: 42px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  letter-spacing: 0.065em;
}

.desktop-pairing-button {
  min-height: 42px;
  white-space: nowrap;
}

.desktop-pairing-hint {
  grid-column: 1 / -1;
  margin: 0;
}

.desktop-app-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: end;
  padding: 13px;
  border: 1px solid rgba(151, 185, 211, 0.12);
  border-radius: var(--radius-md);
  background: rgba(16, 34, 56, 0.38);
}

.desktop-app-card.has-error {
  border-color: rgba(251, 113, 133, 0.42);
  box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.08);
}

.desktop-app-number {
  display: grid;
  align-self: center;
  width: 28px;
  height: 28px;
  grid-row: 1 / span 3;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted-strong);
  font-size: 0.7rem;
}

.desktop-app-fields {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px 12px;
}

.desktop-app-fields .field {
  gap: 5px;
}

.desktop-app-fields input {
  min-height: 38px;
}

.desktop-app-fields input[readonly] {
  color: #b7e9fd;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.035em;
}

.desktop-key-status {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.desktop-key-status.is-available {
  color: #7dd3fc;
}

.desktop-app-card > .toggle-control {
  align-self: center;
}

.desktop-app-status {
  display: flex;
  min-width: 0;
  grid-column: 2 / 4;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 9px;
}

.desktop-status-badge {
  flex: 0 0 auto;
}

.desktop-status-detail {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.desktop-app-actions {
  display: flex;
  grid-column: 2 / 4;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.desktop-action-button {
  white-space: nowrap;
}

.desktop-delete-button {
  width: 36px;
  padding-inline: 7px;
}

.desktop-app-error {
  grid-column: 2 / 4;
}

.camera-card {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto auto;
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid rgba(151, 185, 211, 0.12);
  border-radius: var(--radius-md);
  background: rgba(16, 34, 56, 0.38);
}

.camera-number {
  display: grid;
  align-self: center;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--muted-strong);
  font-size: 0.7rem;
}

.camera-fields {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.camera-fields-ipeye {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.camera-fields-ipeye .field-span-2 {
  min-width: 0;
}

.camera-card .field {
  gap: 5px;
}

.camera-card .field input,
.camera-card .field select {
  min-height: 38px;
}

.camera-card .toggle-control {
  align-self: center;
}

.camera-schedule {
  display: grid;
  grid-column: 2 / -1;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(151, 185, 211, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(8, 24, 42, 0.32);
}

.camera-schedule.is-enabled {
  border-color: rgba(56, 189, 248, 0.24);
  background: rgba(14, 55, 80, 0.22);
}

.camera-schedule-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.camera-schedule-copy {
  display: grid;
  gap: 2px;
}

.camera-schedule-copy strong {
  color: var(--text);
  font-size: 0.82rem;
}

.camera-schedule-copy span {
  color: var(--muted);
  font-size: 0.74rem;
}

.camera-schedule-intervals {
  display: grid;
  gap: 8px;
}

.camera-schedule-interval {
  display: grid;
  grid-template-columns: minmax(130px, 190px) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(151, 185, 211, 0.1);
}

.camera-schedule-interval .field-hint {
  margin-top: 2px;
}

.camera-schedule-add {
  justify-self: start;
}

.camera-test-alarm-button {
  align-self: center;
  min-height: 35px;
  padding: 7px 10px;
  border-color: rgba(251, 191, 36, 0.3);
  color: #fcd34d;
  font-size: 0.76rem;
}

.camera-test-alarm-button:hover:not(:disabled) {
  border-color: rgba(251, 191, 36, 0.58);
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
}

.ghost-button,
.danger-button {
  display: inline-flex;
  min-height: 35px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-strong);
  font-size: 0.76rem;
}

.ghost-button:hover {
  border-color: rgba(56, 189, 248, 0.28);
  background: var(--primary-soft);
  color: #b7e9fd;
}

.danger-button {
  border-color: rgba(251, 113, 133, 0.2);
  color: #fda4af;
}

.danger-button:hover {
  border-color: rgba(251, 113, 133, 0.42);
  background: var(--red-soft);
  color: #fecdd3;
}

.camera-card .danger-button {
  align-self: center;
  width: 36px;
  padding: 7px;
}

.camera-card .camera-schedule-remove {
  grid-column: auto;
  grid-row: auto;
}

.add-card-button {
  display: grid;
  width: 100%;
  min-height: 94px;
  place-items: center;
  margin-top: 15px;
  padding: 16px;
  border: 1px dashed rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-lg);
  background: rgba(56, 189, 248, 0.035);
  color: var(--muted-strong);
}

.add-card-button:hover {
  border-color: rgba(56, 189, 248, 0.55);
  background: var(--primary-soft);
  color: #c2ecfc;
}

.add-card-button > span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.2rem;
  line-height: 1;
}

.add-card-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.73rem;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  min-height: 190px;
  place-content: center;
  justify-items: center;
  gap: 11px;
  color: var(--muted);
  text-align: center;
}

.loading-state p,
.empty-state p,
.error-state p {
  max-width: 440px;
  margin: 0;
}

.spinner {
  width: 25px;
  height: 25px;
  border: 2px solid rgba(142, 166, 186, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

.compact-field {
  display: grid;
  grid-template-columns: auto minmax(130px, 220px);
  align-items: center;
  gap: 8px;
}

.compact-field select {
  min-height: 39px;
  padding: 7px 30px 7px 10px;
}

.inline-state {
  min-height: 21px;
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 0.77rem;
}

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

.chart-span-2 {
  grid-column: span 2;
}

.panel-chart {
  overflow: hidden;
}

.chart {
  position: relative;
  width: 100%;
  min-height: 255px;
}

.chart-compact {
  min-height: 210px;
}

.chart-tall {
  min-height: 315px;
}

.chart > svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-empty {
  display: grid;
  min-height: inherit;
  place-content: center;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}

.chart-empty strong {
  color: var(--muted-strong);
  font-size: 0.85rem;
}

.chart-empty span {
  max-width: 300px;
  font-size: 0.75rem;
}

.chart-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.chart-grid-line {
  stroke: rgba(151, 185, 211, 0.11);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis-line {
  stroke: rgba(151, 185, 211, 0.22);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-axis-label,
.chart-value-label,
.chart-series-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 11px;
}

.chart-value-label {
  fill: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.chart-bar {
  fill: rgba(96, 165, 250, 0.34);
  stroke: rgba(96, 165, 250, 0.58);
  stroke-width: 1;
}

.chart-bar:hover {
  fill: rgba(96, 165, 250, 0.5);
}

.chart [tabindex="0"]:focus-visible {
  outline: none;
  filter: brightness(1.35);
  stroke: #e5f7ff;
  stroke-width: 2;
}

.chart-bar-secondary {
  fill: rgba(56, 189, 248, 0.16);
  stroke: rgba(56, 189, 248, 0.45);
}

.chart-line-frames,
.chart-line-alerts,
.chart-line-absence,
.chart-line-people,
.chart-line-activity {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-line-frames { stroke: var(--blue); }
.chart-line-alerts { stroke: var(--red); }
.chart-line-absence { stroke: var(--amber); }
.chart-line-people { stroke: var(--cyan); }
.chart-line-activity { stroke: var(--green); }

.people-series-0 { stroke: var(--cyan); }
.people-series-1 { stroke: var(--blue); }
.people-series-2 { stroke: var(--violet); }
.people-series-3 { stroke: var(--green); }
.people-series-4 { stroke: var(--amber); }

.chart-point {
  stroke: var(--surface);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-point-alert { fill: var(--red); }
.chart-point-absence { fill: var(--amber); }
.chart-point-people { fill: var(--cyan); }
.chart-point-activity { fill: var(--green); }

.people-fill-0 { fill: var(--cyan); }
.people-fill-1 { fill: var(--blue); }
.people-fill-2 { fill: var(--violet); }
.people-fill-3 { fill: var(--green); }
.people-fill-4 { fill: var(--amber); }

.chart-area-people {
  fill: rgba(34, 211, 238, 0.07);
  stroke: none;
}

.comparison-track {
  fill: rgba(151, 185, 211, 0.08);
}

.comparison-bar {
  fill: rgba(56, 189, 248, 0.38);
}

.comparison-bar.is-selected {
  fill: rgba(34, 211, 238, 0.58);
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.7rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.series-frames { background: var(--blue); }
.series-alerts { background: var(--red); }
.series-absence { background: var(--amber); }

.quality-panel {
  margin-top: 18px;
}

.warning-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.warning-list li {
  position: relative;
  padding: 9px 11px 9px 33px;
  border: 1px solid rgba(251, 191, 36, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.055);
  color: var(--text-soft);
  font-size: 0.8rem;
}

.warning-list li::before {
  position: absolute;
  top: 9px;
  left: 12px;
  color: var(--amber);
  content: "!";
  font-weight: 500;
}

.warning-list li.quality-ok {
  border-color: rgba(52, 211, 153, 0.14);
  background: rgba(52, 211, 153, 0.05);
}

.warning-list li.quality-ok::before {
  color: var(--green);
  content: "✓";
}

.logs-page {
  min-width: 0;
}

.log-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 11px;
  align-items: center;
  margin-bottom: 13px;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field svg {
  position: absolute;
  left: 12px;
  z-index: 1;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.search-field input {
  padding-left: 38px;
}

.log-count {
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.log-viewer {
  min-height: 520px;
  max-height: calc(100vh - 270px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #040b13;
  box-shadow: inset 0 1px 14px rgba(0, 0, 0, 0.18);
  scrollbar-color: rgba(142, 166, 186, 0.3) transparent;
}

.loading-state-dark {
  min-height: 490px;
}

.log-list {
  padding: 8px 0;
  margin: 0;
  list-style: none;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  line-height: 1.6;
}

.log-entry {
  display: grid;
  grid-template-columns: 156px 68px minmax(0, 1fr);
  gap: 10px;
  min-width: max-content;
  padding: 3px 13px;
  border-left: 2px solid transparent;
}

.log-entry:hover {
  background: rgba(56, 189, 248, 0.045);
}

.log-entry.log-error,
.log-entry.log-critical { border-left-color: var(--red); background: rgba(251, 113, 133, 0.035); }
.log-entry.log-warning { border-left-color: var(--amber); }
.log-entry.log-debug { opacity: 0.72; }

.log-time {
  color: #648197;
  font-variant-numeric: tabular-nums;
}

.log-level {
  color: #89a5ba;
  font-weight: 500;
}

.log-error .log-level,
.log-critical .log-level { color: #fda4af; }
.log-warning .log-level { color: #fcd34d; }
.log-info .log-level { color: #7dd3fc; }
.log-debug .log-level { color: #a7b8c5; }

.log-message {
  color: #bdcddd;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-empty {
  display: grid;
  min-height: 490px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.mobile-nav {
  display: none;
}

.dialog {
  width: min(calc(100% - 32px), 460px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(2, 7, 13, 0.76);
  backdrop-filter: blur(4px);
}

.dialog form {
  display: grid;
  justify-items: center;
  padding: 27px;
  text-align: center;
}

.dialog-icon {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  margin-bottom: 15px;
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 1.2rem;
  font-weight: 500;
}

.dialog h2 {
  margin-bottom: 9px;
}

.dialog p {
  margin-bottom: 10px;
  color: var(--muted-strong);
  font-size: 0.85rem;
}

.dialog .dialog-warning {
  color: #fcd34d;
  font-size: 0.77rem;
}

.dialog-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 12px;
}

.toast-region {
  position: fixed;
  z-index: 1200;
  right: 20px;
  bottom: 20px;
  display: grid;
  width: min(calc(100% - 40px), 370px);
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: rgba(13, 27, 43, 0.97);
  color: var(--text-soft);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  animation: toast-in 180ms ease-out;
}

.toast::before {
  color: var(--green);
  content: "✓";
  font-weight: 500;
}

.toast.toast-error::before {
  color: var(--red);
  content: "!";
}

.toast.toast-warning::before {
  color: var(--amber);
  content: "!";
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .feature-panel.feature-wide {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 218px;
  }

  .sidebar {
    padding-inline: 12px;
  }

  .nav-item.is-active::before {
    left: -12px;
  }

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

  .chart-span-2 {
    grid-column: span 1;
  }

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

  .camera-card {
    grid-template-columns: auto minmax(140px, 1fr) auto auto;
  }

  .camera-card .danger-button {
    grid-column: 4;
    grid-row: 1;
  }

  .camera-card .camera-test-alarm-button {
    grid-column: 3;
    grid-row: 1;
  }

  .camera-card .toggle-control {
    grid-column: 2 / 5;
    justify-self: start;
  }

  .camera-schedule {
    grid-column: 2 / 5;
  }

  .camera-card .camera-schedule-remove {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  :root {
    --font-size-base: 14px;
  }

  .panel-chart {
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  #overviewHourlyChart {
    min-width: 680px;
  }

  #hourlyChart,
  #snapshotsChart {
    min-width: 820px;
  }

  #clientComparisonChart {
    min-width: 520px;
  }

  #peopleCounterChart {
    min-width: 620px;
  }

  body {
    padding-bottom: 71px;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    margin-left: 0;
  }

  .topbar {
    min-height: 72px;
    padding: 12px 16px;
  }

  .topbar .eyebrow,
  .topbar-actions .button span,
  .freshness-chip {
    display: none;
  }

  .topbar-actions .button {
    width: 39px;
    padding: 8px;
  }

  .content {
    padding: 18px 14px 30px;
  }

  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: 65px;
    padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--border-strong);
    background: rgba(7, 18, 31, 0.96);
    backdrop-filter: blur(18px);
  }

  .mobile-nav-item {
    position: relative;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    min-width: 0;
    padding: 5px 3px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
  }

  .mobile-nav-item svg {
    width: 19px;
    height: 19px;
  }

  .mobile-nav-item.is-active {
    background: var(--primary-soft);
    color: #b9e9fd;
  }

  .mobile-dirty {
    position: absolute;
    top: 5px;
    right: calc(50% - 17px);
  }

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

  .kpi-card,
  .skeleton-card {
    min-height: 112px;
    padding: 14px;
  }

  .kpi-icon {
    width: 30px;
    height: 30px;
  }

  .panel {
    padding: 15px;
  }

  .page-toolbar {
    display: grid;
  }

  .page-toolbar .toolbar-actions {
    justify-content: flex-start;
  }

  .stats-toolbar .toolbar-actions,
  .logs-toolbar .toolbar-actions {
    width: 100%;
  }

  .compact-field {
    flex: 1;
    grid-template-columns: auto minmax(110px, 1fr);
  }

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

  .field-span-2,
  .feature-panel.feature-wide {
    grid-column: span 1;
  }

  .client-header {
    align-items: flex-start;
    padding: 13px;
  }

  .client-index,
  .camera-count-badge {
    display: none;
  }

  .client-header-actions {
    gap: 5px;
  }

  .client-header-actions .toggle-control > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .client-body {
    padding: 14px;
  }

  .desktop-app-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .desktop-pairing-controls {
    grid-template-columns: 1fr;
  }

  .desktop-pairing-button {
    width: 100%;
  }

  .desktop-app-number {
    display: none;
  }

  .desktop-app-fields {
    grid-column: 1 / 3;
    grid-template-columns: 1fr;
  }

  .desktop-app-card > .toggle-control {
    grid-column: 1;
    justify-self: start;
  }

  .desktop-app-status,
  .desktop-app-actions,
  .desktop-app-error {
    grid-column: 1 / 3;
  }

  .desktop-app-actions {
    justify-content: flex-start;
  }

  .camera-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .camera-number {
    display: none;
  }

  .camera-card > .camera-fields {
    grid-column: 1 / 3;
  }

  .camera-card .camera-fields .field {
    grid-column: auto;
  }

  .camera-card .toggle-control {
    grid-column: 1;
    grid-row: 2;
  }

  .camera-card .camera-test-alarm-button {
    grid-column: 1;
    grid-row: 3;
    justify-self: start;
  }

  .camera-card .danger-button {
    grid-column: 2;
    grid-row: 3;
  }

  .camera-schedule {
    grid-column: 1 / 3;
    grid-row: auto;
  }

  .camera-schedule-interval {
    grid-template-columns: 1fr 1fr auto;
  }

  .camera-card .camera-schedule-remove {
    grid-column: auto;
    grid-row: auto;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .panel-heading {
    flex-wrap: wrap;
  }

  .log-controls {
    grid-template-columns: 1fr;
  }

  .log-controls .compact-field {
    width: 100%;
  }

  .log-count {
    justify-self: end;
  }

  .log-viewer {
    min-height: 430px;
    max-height: 64vh;
  }

  .log-entry {
    grid-template-columns: 125px 61px minmax(240px, 1fr);
  }

  .toast-region {
    right: 12px;
    bottom: 78px;
    width: calc(100% - 24px);
  }
}

@media (max-width: 430px) {
  .login-view {
    align-items: stretch;
    padding: 0;
  }

  .login-panel {
    width: 100%;
    min-height: 100vh;
    padding: 28px 20px;
    border: 0;
    border-radius: 0;
    background: rgba(7, 17, 30, 0.9);
  }

  .login-brand {
    grid-template-columns: 1fr;
  }

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

  .kpi-label {
    min-height: 2.5em;
  }

  .kpi-meta {
    white-space: normal;
  }

  .toolbar-actions {
    width: 100%;
  }

  .page-toolbar:not(.stats-toolbar):not(.logs-toolbar) .toolbar-actions .button {
    flex: 1;
  }

  .dirty-indicator {
    width: 100%;
  }

  .dialog-actions {
    width: 100%;
    flex-direction: column-reverse;
  }

  .dialog-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
