:root {
  --color-bg: #0b0f14;
  --color-surface: #121820;
  --color-surface-elevated: #1a2330;
  --color-border: #243044;
  --color-text: #e8edf3;
  --color-text-muted: #9aa8ba;
  --color-accent: #14b8a6;
  --color-live: #14b8a6;
  --color-error: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.875rem;
  background: var(--color-bg);
  color: var(--color-text);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.25rem;
  background: color-mix(in srgb, var(--color-accent) 20%, transparent);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
}

.page-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.poll-status {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: calc(100vh - 65px);
}

.streams-section {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.panel-heading h2 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.live-count {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  color: var(--color-accent);
  font-weight: 500;
}

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  flex: 1;
}

.grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-muted);
}

.stream-card {
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: var(--color-surface-elevated);
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 7rem;
}

.stream-card:hover {
  border-color: color-mix(in srgb, var(--color-accent) 50%, var(--color-border));
}

.stream-card.selected,
.stream-card[aria-selected="true"] {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-accent) 35%, transparent);
}

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

.skeleton-card {
  min-height: 7rem;
  border-radius: 0.75rem;
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-elevated) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border: none;
  cursor: default;
}

.stream-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
}

.stream-row {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.25rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stream-row:hover {
  border-color: var(--color-border);
  background: var(--color-surface-elevated);
}

.stream-row[aria-selected="true"] {
  border-color: var(--color-accent);
  background: var(--color-surface-elevated);
}

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

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-live);
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px rgba(20, 184, 166, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(20, 184, 166, 0);
  }
}

.stream-label {
  margin: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-meta {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.skeleton-row {
  height: 3.5rem;
  border-radius: 0.5rem;
  margin: 0.25rem 0;
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-elevated) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.empty-state {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

.player-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.player-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.player-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.player-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.player-stage {
  position: relative;
  background: #000;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-height: 70vh;
}

#player {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.error-banner {
  display: none;
  margin-bottom: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--color-error) 15%, transparent);
  border: 1px solid var(--color-error);
  color: var(--color-error);
}

.error-banner.visible {
  display: block;
}

.player-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-nav a,
.btn-link {
  color: var(--color-accent);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 28rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.auth-card-wide {
  max-width: 36rem;
}

.auth-title {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.auth-subtitle {
  margin: 0 0 1.25rem;
  color: var(--color-text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.field input,
.table-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface-elevated);
  color: var(--color-text);
  font: inherit;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border: none;
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  font: inherit;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-accent);
  color: #042f2e;
  font-weight: 600;
}

.btn-secondary {
  background: var(--color-surface-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-danger {
  background: color-mix(in srgb, var(--color-error) 20%, transparent);
  color: var(--color-error);
  border: 1px solid var(--color-error);
}

.form-message {
  margin: 0.75rem 0 0;
  min-height: 1.25rem;
}

.form-message.success {
  color: var(--color-accent);
}

.form-message.error {
  color: var(--color-error);
}

.form-message.inline {
  margin: 0;
}

.auth-footer {
  margin: 1rem 0 0;
  color: var(--color-text-muted);
}

.auth-footer a {
  color: var(--color-accent);
}

.hidden {
  display: none !important;
}

.provision-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.qr-image {
  align-self: center;
  border-radius: 0.5rem;
  background: #fff;
  padding: 0.5rem;
}

.mono-block {
  margin: 0;
  word-break: break-all;
}

.mono-block .label {
  display: block;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

.admin-shell {
  padding: 1.5rem;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.create-result {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: var(--color-surface);
}

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

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

.device-table th,
.device-table td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
