:root {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #f4f4f5;
  background-color: #0f111a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
}

.hidden {
  display: none !important;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  background: #151828;
  border-bottom: 1px solid #1f2236;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.6rem;
}

.top-bar p {
  margin: 0.2rem 0 0;
  color: #a5a8c2;
  font-size: 0.95rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #a5a8c2;
}

.status-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  display: inline-block;
}

.status-dot.offline {
  background: #f87171;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.4);
}

.status-dot.online {
  background: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
}

main {
  padding: 0rem 0 4rem;
  margin: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0rem;
}

.disk-free {
  margin: 0 1.25rem 1.5rem;
  color: #a5a8c2;
  font-size: 0.95rem;
}

.archive-layout {
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.archive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.archive-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.back-link {
  color: #a5a8c2;
  text-decoration: none;
  font-weight: 600;
}

.back-link:hover {
  color: #f4f4f5;
}

.archive-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 640px) {
  .archive-layout {
    padding: 1rem 0 3rem;
  }
  .archive-player {
    padding: 0 0 1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .player-shell {
    margin: 0;
    width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
  }
  .archive-player video {
    width: 100%;
    max-width: 100%;
    display: block;
    margin: 0;
    border-radius: 0;
  }
  .player-controls {
    padding: 0.65rem 1rem 0.75rem;
    border-radius: 0;
  }
}

@media (min-width: 900px) {
  .archive-content {
    flex-direction: row;
    align-items: flex-start;
  }
}

.recordings-panel,
.archive-player {
  background: #151828;
  border: 1px solid #1f2236;
  border-radius: 12px;
  padding: 1.25rem;
}

.recordings-panel {
  flex: 1;
}

.archive-player {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.custom-clip {
  border-top: 1px solid #1f2236;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.custom-clip h3 {
  margin: 0;
  font-size: 1rem;
}

.custom-clip form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.time-fields {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.time-fields label {
  flex: 1;
  min-width: 5rem;
}

.custom-clip label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: #cdd0e0;
}

.custom-clip input {
  border: 1px solid #1f2236;
  border-radius: 8px;
  background: #0f111a;
  color: #f4f4f5;
  padding: 0.4rem 0.5rem;
  font-size: 0.95rem;
}

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

.custom-clip-actions button {
  flex: 1;
  min-width: 8rem;
}

.form-error {
  color: #fca5a5;
  font-size: 0.85rem;
  margin: 0;
}

.recordings-items {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recordings-items button {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 1px solid #1f2236;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  background: #0f111a;
  color: #f4f4f5;
  cursor: pointer;
  transition: border 0.15s ease, background 0.15s ease;
  font-size: 0.95rem;
}

.recordings-items button:hover {
  border-color: #2563eb;
}

.recordings-items button.active {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.15);
}

.recording-time {
  font-weight: 600;
  font-size: 0.95rem;
}

.recording-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: #a5a8c2;
  font-size: 0.85rem;
}

.archive-player video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 0px;
  background: #000;
}

.player-shell {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  position: relative;
  overflow: hidden;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(15, 17, 26, 0.85), rgba(15, 17, 26, 0.65));
  z-index: 1;
  padding: 1rem;
}

.player-overlay.hidden {
  display: none;
}

.overlay-button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.overlay-button:hover {
  background: #1d4ed8;
}

.player-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.65rem 0.75rem 0.75rem;
  background: #0f1220;
  border: 1px solid #1f2236;
  border-radius: 0px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.skip-row {
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.25rem;
  gap: 0.4rem;
}

.meta-row {
  justify-content: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}

.volume-group {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 140px;
}

.volume-group input[type="range"] {
  width: 100%;
  accent-color: #2563eb;
  cursor: pointer;
  margin-left: 0.25rem;
}

.control-button {
  border: none;
  background: #2563eb;
  color: #fff;
  padding: 0.12rem 0.3rem;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
  min-width: 24px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.control-button.audio-button {
  position: relative;
  font-size: 0.95rem;
  width: 38px;
  height: 32px;
  padding: 0;
}

.control-button.audio-button.muted::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 70%;
  background: #ef4444;
  transform: rotate(-45deg);
  top: 15%;
  left: 50%;
  translate: -50% 0;
}

.control-button:hover {
  background: #1d4ed8;
}

.control-button:active {
  transform: translateY(1px);
}

.progress-bar {
  position: relative;
  flex: 1;
  height: 10px;
  background: #1f2236;
  border-radius: 999px;
  overflow: visible;
  cursor: pointer;
}

.progress-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  bottom: -8px;
  background: transparent;
  pointer-events: auto;
}

.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 10px;
  width: 0%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  transition: width 0.1s linear;
}

.progress-hover {
  position: absolute;
  top: -28px;
  transform: translateX(-50%);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: #111324;
  border: 1px solid #1f2236;
  color: #e5e7eb;
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.time-label {
  color: #e5e7eb;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  min-width: 90px;
  text-align: right;
}

.recording-details {
  color: #a5a8c2;
  font-size: 0.9rem;
  margin: 0;
}

@media (min-width: 1024px) {
  .camera-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .camera-grid > :only-child {
    grid-column: 1 / -1;
  }
}

.camera-card {
  background: #151828;
  border: 1px solid #1f2236;
  border-radius: 0px;
  padding: 0rem;
  display: flex;
  flex-direction: column;
  gap: 0rem;
}

.camera-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.camera-card video {
  width: 100%;
  border-radius: 0px;
  background: #0d0f18;
}

.camera-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem 0.5rem;
}

.camera-actions .live-offset {
  font-size: 0.95rem;
  color: #a5a8c2;
  font-weight: 500;
}

.camera-actions .go-live {
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 0.95rem;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.2);
}

.camera-actions .go-live:hover {
  background: #1d4ed8;
}

.camera-archive-link {
  display: block;
  padding: 0.65rem 1.25rem 0.9rem;
  border-top: 1px solid #1f2236;
  color: #60a5fa;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.camera-archive-link:hover {
  color: #93c5fd;
}

.camera-card video.portrait-video {
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.timeline-control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.timeline-control input[type="range"] {
  width: 100%;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #a5a8c2;
}

.panel {
  background: #151828;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid #1f2236;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.panel-header button {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  border: none;
  cursor: pointer;
}

.panel-header button:hover {
  background: #1d4ed8;
}

.empty-state {
  text-align: center;
  color: #7c7f96;
  font-size: 0.9rem;
  margin-top: 0.8rem;
}

@media (max-width: 640px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.auth-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.auth-dialog {
  width: min(320px, 90vw);
  background: #151828;
  border: 1px solid #1f2236;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.auth-dialog h2 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
}

.auth-message {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #a5a8c2;
  font-size: 0.95rem;
}

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

.auth-dialog label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.auth-dialog input {
  border-radius: 8px;
  border: 1px solid #2b2f4b;
  background: #0f111a;
  color: #f4f4f5;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
}

.auth-dialog button[type="submit"] {
  margin-top: 0.5rem;
  border: none;
  border-radius: 8px;
  padding: 0.6rem;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.auth-dialog button[type="submit"]:disabled {
  opacity: 0.7;
  cursor: progress;
}

.auth-error {
  color: #f87171;
  font-size: 0.85rem;
  margin: -0.5rem 0 0;
}
