@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Spline+Sans+Mono:wght@400;600&display=swap');

:root {
  color-scheme: light;
  --ink: #0c1b1f;
  --muted: #4a5a5f;
  --surface: #fff9f2;
  --surface-strong: #f3ede4;
  --accent: #f4a261;
  --accent-strong: #e76f51;
  --amber: #e9c46a;
  --teal: #2a9d8f;
  --navy: #264653;
  --offline: #d1495b;
  --online: #2a9d8f;
  --chart-boxhost: #2a9d8f;
  --chart-dc-bfn: #e9c46a;
  --chart-dc-hou: #264653;
  --chart-other: #7a8c78;
  --bg: #f7f3ed;
  --shadow: 0 18px 40px rgba(14, 23, 26, 0.12);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', 'Trebuchet MS', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 20%, #fff1e1 0%, transparent 55%),
    radial-gradient(circle at 80% 10%, #dfeef0 0%, transparent 60%),
    var(--bg);
}

body::after {
  content: '';
  position: fixed;
  inset: 40% -10% auto -10%;
  height: 60vh;
  background: radial-gradient(circle at 70% 20%, rgba(244, 162, 97, 0.22), transparent 60%),
    radial-gradient(circle at 20% 80%, rgba(42, 157, 143, 0.2), transparent 55%);
  z-index: -1;
}

body.cctv-page {
  color: #f5efe6;
  background:
    radial-gradient(circle at 18% 10%, rgba(42, 157, 143, 0.2) 0%, transparent 44%),
    radial-gradient(circle at 85% 0%, rgba(209, 73, 91, 0.18) 0%, transparent 42%),
    #04090c;
}

body.cctv-page::after {
  inset: 35% -10% auto -10%;
  height: 65vh;
  background:
    radial-gradient(circle at 70% 20%, rgba(209, 73, 91, 0.2), transparent 62%),
    radial-gradient(circle at 20% 80%, rgba(42, 157, 143, 0.16), transparent 56%);
}

.page-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 36px 24px 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: stretch;
}

main {
  margin: 0;
  padding: 0;
  min-width: 0;
}

h1,
h2 {
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.4rem, 3.5vw, 3.6rem);
  color: var(--navy);
}

h2 {
  font-size: clamp(1.4rem, 2vw, 2rem);
  color: var(--navy);
}

p {
  margin: 0 0 20px;
  color: var(--muted);
  max-width: 420px;
  line-height: 1.5;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-family: inherit;
  font-weight: 600;
  color: var(--navy);
  background: linear-gradient(135deg, #f4a261, #e9c46a);
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(244, 162, 97, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px rgba(244, 162, 97, 0.35);
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 28px;
  align-items: center;
  margin-bottom: 40px;
}

.hero-copy {
  background: rgba(255, 249, 242, 0.8);
  border-radius: var(--radius);
  padding: 28px 28px 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.eyebrow {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent-strong);
  margin-bottom: 16px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.updated {
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.note {
  font-size: 0.9rem;
  color: var(--navy);
  background: rgba(42, 157, 143, 0.12);
  padding: 10px 14px;
  border-radius: 12px;
}

.hero-panel {
  display: grid;
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--navy);
}

.stat-value.online {
  color: var(--online);
}

.stat-value.offline {
  color: var(--offline);
}

.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  box-shadow: var(--shadow);
}

.trend-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

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

.trend-title {
  font-weight: 600;
  color: var(--navy);
}

.trend-subtitle {
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.trend-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 249, 242, 0.9);
  border: 1px solid rgba(38, 70, 83, 0.08);
}

.trend-pill {
  border: 1px solid rgba(38, 70, 83, 0.16);
  background: var(--surface);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.trend-pill.active,
.trend-pill:focus-visible {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.trend-pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.2);
}

.trend-card canvas {
  width: 100%;
  height: 140px;
  display: block;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(42, 157, 143, 0.12), rgba(255, 249, 242, 0));
}

.donut {
  width: 160px;
  height: 160px;
  position: relative;
  display: grid;
  place-items: center;
}

.donut::after {
  content: none;
  display: none;
}

.donut-chart {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.donut-track {
  fill: none;
  stroke: var(--surface-strong);
  stroke-width: 18;
}

.donut-segment {
  transition: opacity 0.2s ease;
  cursor: help;
}

.donut-segment:hover {
  opacity: 0.85;
}

.donut-center {
  position: absolute;
  inset: 0;
  margin: auto;
  z-index: 1;
  text-align: center;
  background: var(--surface);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(38, 70, 83, 0.08);
  pointer-events: none;
}

.donut-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
}

.donut-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.legend {
  display: grid;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.online {
  background: var(--online);
}

.dot.offline {
  background: var(--offline);
}

.section {
  margin-top: 24px;
}

.device-detail {
  display: grid;
  gap: 18px;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.back-button {
  border: 1px solid rgba(38, 70, 83, 0.2);
  background: var(--surface);
  color: var(--navy);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 10px 18px rgba(14, 23, 26, 0.12);
}

.detail-title h2 {
  margin-bottom: 4px;
}

.detail-subtitle {
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.detail-card-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.detail-list {
  display: grid;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.detail-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-label {
  font-weight: 600;
  color: var(--navy);
}

.detail-uptime {
  display: grid;
  gap: 12px;
}

.detail-uptime-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.detail-uptime-percent {
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
}

.detail-uptime-caption {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.detail-uptime-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.uptime-strip.detail .uptime-segment {
  height: 10px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-direction: column;
  align-items: flex-start;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(38, 70, 83, 0.12);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(14, 23, 26, 0.08);
}

.filter-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--online);
  cursor: pointer;
}

.filter-toggle input:checked + span {
  color: var(--navy);
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 249, 242, 0.9);
  border: 1px solid rgba(38, 70, 83, 0.08);
}

.filter-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.filter-pill {
  border: 1px solid rgba(38, 70, 83, 0.16);
  background: var(--surface);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.filter-pill.active,
.filter-pill:focus-visible {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.filter-pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.2);
}

.search-input {
  border: 1px solid rgba(38, 70, 83, 0.16);
  background: var(--surface);
  color: var(--navy);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  min-width: 200px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  outline: none;
  border-color: rgba(38, 70, 83, 0.5);
  box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.14);
}

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  align-items: start;
}

.activity-log {
  position: relative;
  align-self: stretch;
  display: grid;
  gap: 18px;
  align-content: start;
}

.log-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 249, 242, 0.9);
  border: 1px solid rgba(38, 70, 83, 0.08);
  align-self: flex-start;
}

.log-tab {
  border: 1px solid rgba(38, 70, 83, 0.16);
  background: var(--surface);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.log-tab.active,
.log-tab:focus-visible {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.log-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.2);
}

.log-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.log-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.sticky-log {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
}

.log-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.log-list {
  display: grid;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.log-entry {
  background: var(--surface-strong);
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(38, 70, 83, 0.08);
  display: grid;
  gap: 6px;
}

.activity-entry.online .activity-name {
  color: var(--online);
}

.activity-entry.offline .activity-name {
  color: var(--offline);
}

.log-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--navy);
}

.log-meta {
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.group-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  align-self: start;
}

.group-card.status-online {
  border-top: 5px solid var(--online);
}

.group-card.status-mixed {
  border-top: 5px solid var(--amber);
}

.group-card.status-offline {
  border-top: 5px solid var(--offline);
}

.group-card-header {
  padding: 14px 18px;
  background: rgba(255, 249, 242, 0.9);
  border-bottom: 1px solid rgba(38, 70, 83, 0.08);
}

.group-card-body {
  padding: 12px 18px 16px;
}

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

.group-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}

.group-meta {
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

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

.device {
  background: var(--surface-strong);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  border: 1px solid rgba(38, 70, 83, 0.08);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.device:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(14, 23, 26, 0.12);
}

.device:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.device-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.remind-button {
  border: 1px solid rgba(38, 70, 83, 0.2);
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
}

.remind-button.active {
  background: rgba(42, 157, 143, 0.18);
  color: var(--online);
  border-color: rgba(42, 157, 143, 0.45);
}

.remind-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.18);
}

.remind-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.device-name {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.98rem;
}

.status-chip {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.status-chip.online {
  background: rgba(42, 157, 143, 0.18);
  color: var(--online);
}

.status-chip.offline {
  background: rgba(209, 73, 91, 0.16);
  color: var(--offline);
}

.device-meta {
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.device-meta-item {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.device-status {
  font-size: 0.82rem;
  color: var(--muted);
}

.device-uptime {
  display: grid;
  gap: 6px;
}

.uptime-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.uptime-percent {
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.04em;
}

.uptime-strip {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 3px;
}

.uptime-segment {
  height: 6px;
  border-radius: 4px;
  background: rgba(38, 70, 83, 0.12);
}

.uptime-segment.online {
  background: rgba(42, 157, 143, 0.75);
}

.uptime-segment.offline {
  background: rgba(209, 73, 91, 0.6);
}

.uptime-segment.unknown {
  background: rgba(38, 70, 83, 0.18);
}

.button-link {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-family: inherit;
  font-weight: 600;
  color: var(--navy);
  background: linear-gradient(135deg, #f4a261, #e9c46a);
  box-shadow: 0 10px 20px rgba(244, 162, 97, 0.35);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px rgba(244, 162, 97, 0.35);
}

.cctv-shell {
  max-width: 1680px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  display: grid;
  gap: 18px;
}

body.cctv-page h1,
body.cctv-page h2 {
  color: #fdf7ef;
}

body.cctv-page .eyebrow {
  color: rgba(253, 247, 239, 0.74);
}

.cctv-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.cctv-subtitle {
  margin: 8px 0 0;
  max-width: 760px;
}

body.cctv-page .cctv-subtitle {
  color: rgba(229, 234, 236, 0.85);
}

.cctv-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cctv-pinned-section {
  display: grid;
  gap: 10px;
}

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

.cctv-section-heading h2 {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0.02em;
}

.cctv-section-count {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fdf7ef;
  background: rgba(38, 70, 83, 0.58);
}

.cctv-section-heading-main {
  margin-top: 4px;
}

.cctv-status-bar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

body.cctv-page .cctv-status-bar {
  background: rgba(9, 16, 20, 0.86);
  border: 1px solid rgba(253, 247, 239, 0.12);
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.52);
}

.cctv-counters {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
  font-size: 0.82rem;
  min-width: min(100%, 420px);
}

body.cctv-page .cctv-counters {
  color: rgba(236, 243, 245, 0.8);
}

.cctv-environment-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.cctv-environment-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(236, 243, 245, 0.78);
  font-family: 'Spline Sans Mono', 'Courier New', monospace;
}

.cctv-environment-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(9, 16, 20, 0.72);
  border: 1px solid rgba(253, 247, 239, 0.14);
}

.cctv-env-filter-pill {
  border: 1px solid rgba(253, 247, 239, 0.26);
  background: rgba(255, 255, 255, 0.06);
  color: #fdf7ef;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cctv-env-filter-pill.active,
.cctv-env-filter-pill:focus-visible {
  border-color: rgba(233, 196, 106, 0.9);
  background: rgba(233, 196, 106, 0.3);
  color: #fff7de;
}

.cctv-env-filter-pill.active.status-connected {
  border-color: rgba(42, 157, 143, 0.95);
  background: rgba(42, 157, 143, 0.3);
  color: #e8fff9;
}

.cctv-env-filter-pill.active.status-connecting {
  border-color: rgba(233, 196, 106, 0.9);
  background: rgba(233, 196, 106, 0.3);
  color: #fff7de;
}

.cctv-env-filter-pill.active.status-disconnected {
  border-color: rgba(209, 73, 91, 0.95);
  background: rgba(209, 73, 91, 0.28);
  color: #ffecef;
}

.cctv-env-filter-pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(233, 196, 106, 0.22);
}

.cctv-environment-hint {
  color: rgba(236, 243, 245, 0.58);
  font-size: 0.72rem;
  line-height: 1.25;
}

.cctv-search-input {
  width: min(100%, 360px);
  min-width: 220px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(253, 247, 239, 0.24);
  background: rgba(9, 16, 20, 0.72);
  color: #fdf7ef;
  padding: 0 12px;
  font-size: 0.78rem;
}

.cctv-search-input::placeholder {
  color: rgba(236, 243, 245, 0.64);
}

.cctv-search-input:focus-visible {
  outline: none;
  border-color: rgba(233, 196, 106, 0.88);
  box-shadow: 0 0 0 3px rgba(233, 196, 106, 0.18);
}

body.cctv-page .back-button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(253, 247, 239, 0.3);
  color: #fdf7ef;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
}

body.cctv-page .back-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

body.cctv-page .cctv-section-count {
  background: rgba(253, 247, 239, 0.18);
}

.cctv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}

.cctv-grid-pinned {
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.cctv-tile {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #081116;
  aspect-ratio: 16 / 9;
  box-shadow: 0 14px 24px rgba(14, 23, 26, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
}

.cctv-tile.state-streaming {
  border-color: rgba(42, 157, 143, 0.7);
}

.cctv-tile.state-offscreen {
  border-color: rgba(255, 255, 255, 0.18);
}

.cctv-tile.state-error {
  border-color: rgba(209, 73, 91, 0.7);
}

.cctv-tile.is-pinned {
  border-color: rgba(233, 196, 106, 0.76);
}

.cctv-tile.has-bot-peer {
  border-color: rgba(255, 66, 90, 1);
  border-width: 3px;
  box-shadow:
    0 0 0 2px rgba(255, 66, 90, 0.76),
    0 0 20px rgba(255, 66, 90, 0.46),
    0 14px 24px rgba(14, 23, 26, 0.25);
  animation: cctv-bot-alert-pulse 1.35s ease-in-out infinite;
}

.cctv-tile.has-bot-peer .cctv-badge {
  background: rgba(255, 66, 90, 0.94);
  box-shadow: 0 0 12px rgba(255, 66, 90, 0.45);
}

@keyframes cctv-bot-alert-pulse {
  0% {
    border-color: rgba(255, 66, 90, 0.92);
    box-shadow:
      0 0 0 2px rgba(255, 66, 90, 0.62),
      0 0 14px rgba(255, 66, 90, 0.32),
      0 14px 24px rgba(14, 23, 26, 0.25);
  }
  45% {
    border-color: rgba(255, 124, 142, 1);
    box-shadow:
      0 0 0 4px rgba(255, 124, 142, 0.82),
      0 0 36px rgba(255, 89, 111, 0.62),
      0 14px 24px rgba(14, 23, 26, 0.25);
  }
  70% {
    border-color: rgba(255, 90, 112, 0.98);
    box-shadow:
      0 0 0 3px rgba(255, 90, 112, 0.72),
      0 0 24px rgba(255, 89, 111, 0.48),
      0 14px 24px rgba(14, 23, 26, 0.25);
  }
  100% {
    border-color: rgba(255, 66, 90, 0.92);
    box-shadow:
      0 0 0 2px rgba(255, 66, 90, 0.62),
      0 0 14px rgba(255, 66, 90, 0.32),
      0 14px 24px rgba(14, 23, 26, 0.25);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cctv-tile.has-bot-peer {
    animation: none;
  }
}

.cctv-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0c1b1f;
}

.cctv-overlay {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(3, 8, 12, 0.86), rgba(3, 8, 12, 0));
}

.cctv-overlay-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cctv-env-badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff7de;
  background: rgba(233, 196, 106, 0.24);
  border: 1px solid rgba(233, 196, 106, 0.58);
}

.cctv-device-name {
  color: #fdf7ef;
  font-size: 0.84rem;
  font-weight: 600;
  max-width: calc(100% - 96px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cctv-badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fdf7ef;
  background: rgba(38, 70, 83, 0.72);
}

.cctv-pin-button {
  border: 1px solid rgba(253, 247, 239, 0.32);
  background: rgba(255, 255, 255, 0.1);
  color: #fdf7ef;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: none;
}

.cctv-pin-button:hover {
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.18);
}

.cctv-pin-button[aria-pressed='true'] {
  border-color: rgba(233, 196, 106, 0.92);
  background: rgba(233, 196, 106, 0.26);
  color: #fff7de;
}

.state-streaming .cctv-badge {
  background: rgba(42, 157, 143, 0.76);
}

.state-offscreen .cctv-badge {
  background: rgba(255, 255, 255, 0.24);
}

.state-error .cctv-badge {
  background: rgba(209, 73, 91, 0.86);
}

.cctv-error {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  color: #ffe5e7;
  background: rgba(209, 73, 91, 0.84);
  border-radius: 10px;
  padding: 8px 9px;
  font-size: 0.74rem;
  line-height: 1.35;
}

.cctv-tile.clickable-live {
  cursor: zoom-in;
}

body.cctv-modal-open {
  overflow: hidden;
}

.cctv-lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 8, 12, 0.9);
  display: grid;
  place-items: center;
  padding: 2vh 2vw;
}

.cctv-lightbox-panel {
  width: min(96vw, 1800px);
  max-height: 94vh;
  border-radius: 16px;
  overflow: hidden;
  background: #081116;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5);
  display: grid;
  grid-template-rows: auto 1fr;
}

.cctv-lightbox-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(3, 8, 12, 0.95), rgba(3, 8, 12, 0.75));
}

.cctv-lightbox-title-wrap {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.cctv-lightbox-title {
  color: #fdf7ef;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: copy;
  border-radius: 8px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.cctv-lightbox-title-content {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.cctv-lightbox-env-tag {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff7de;
  background: rgba(233, 196, 106, 0.24);
  border: 1px solid rgba(233, 196, 106, 0.58);
  flex: 0 0 auto;
}

.cctv-lightbox-device-name {
  min-width: 0;
  max-width: min(60vw, 880px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cctv-lightbox-title-meta {
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(233, 241, 244, 0.82);
  border-left: 1px solid rgba(253, 247, 239, 0.24);
  padding-left: 10px;
  flex: 0 0 auto;
}

.cctv-lightbox-title:hover,
.cctv-lightbox-title:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.cctv-lightbox-title.copy-success {
  color: #b5ffdf;
  background: rgba(42, 157, 143, 0.22);
}

.cctv-lightbox-title.copy-error {
  color: #ffd6da;
  background: rgba(209, 73, 91, 0.25);
}

.cctv-copy-notice {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(181, 255, 223, 0.95);
  background: rgba(42, 157, 143, 0.16);
  border: 1px solid rgba(42, 157, 143, 0.34);
  border-radius: 999px;
  padding: 3px 9px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  white-space: nowrap;
}

.cctv-copy-notice.active {
  opacity: 1;
  transform: translateY(0);
}

.cctv-copy-notice.error {
  color: rgba(255, 214, 218, 0.95);
  background: rgba(209, 73, 91, 0.16);
  border-color: rgba(209, 73, 91, 0.38);
}

.cctv-lightbox-close {
  border: 1px solid rgba(253, 247, 239, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #fdf7ef;
  padding: 6px 12px;
  box-shadow: none;
  border-radius: 999px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.cctv-lightbox-close:hover {
  transform: none;
  box-shadow: none;
}

.cctv-lightbox-video {
  width: 100%;
  height: min(88vh, 100%);
  background: #000;
  object-fit: contain;
}

.error-banner {
  background: rgba(209, 73, 91, 0.15);
  color: var(--offline);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
}

.hidden {
  display: none;
}

.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: grid;
  gap: 10px;
  z-index: 5;
}

.toast {
  background: rgba(38, 70, 83, 0.92);
  color: #fdf7ef;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: 0 12px 24px rgba(14, 23, 26, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.toast.important {
  background: rgba(42, 157, 143, 0.95);
  color: #fdf7ef;
  box-shadow: 0 16px 28px rgba(42, 157, 143, 0.3);
}

.toast-message {
  font-weight: 600;
}

.toast-close {
  border: 1px solid rgba(253, 247, 239, 0.5);
  background: transparent;
  color: inherit;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: none;
}

.toast.is-sticky .toast-close {
  display: inline-flex;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.reveal {
  animation: fadeRise 0.6s ease both;
  animation-delay: var(--delay, 0ms);
}

@keyframes fadeRise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 840px) {
  .chart-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .donut {
    width: 140px;
    height: 140px;
  }

  .cctv-shell {
    padding: 20px 14px 30px;
  }

  .cctv-header {
    flex-direction: column;
  }

  .cctv-search-input {
    min-width: 0;
    width: 100%;
  }

  .cctv-status-bar {
    align-items: stretch;
  }

  .cctv-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }
}

@media (max-width: 1100px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .sticky-log {
    position: static;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    animation: none;
  }
}
