:root {
  color-scheme: dark;
  --bg: #080b0e;
  --panel: #11161c;
  --panel-2: #171d24;
  --line: #29323d;
  --text: #f4f7fa;
  --muted: #9aa7b7;
  --lime: #b8ff3d;
  --lime-dark: #86c51d;
  --danger: #ff7b7b;
  --shadow: 0 18px 50px rgb(0 0 0 / 32%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

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

h1 {
  margin-bottom: 0.25rem;
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -0.05em;
}

h2,
h3 {
  letter-spacing: -0.025em;
}

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

.eyebrow {
  margin-bottom: 0.35rem;
  color: #a8b5c5;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button-primary {
  border-color: var(--lime);
  background: var(--lime);
  color: #101600;
}

.button-primary:hover {
  background: #c8ff6b;
}

.button-secondary {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.button-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.login-page {
  background:
    radial-gradient(circle at 50% 5%, rgb(184 255 61 / 12%), transparent 33%),
    var(--bg);
}

.login-layout {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: min(100%, 430px);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgb(17 22 28 / 96%);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 1.25rem;
  place-items: center;
  border: 1px solid #5d811c;
  border-radius: 16px;
  background: #111b08;
}

.brand-mark span {
  width: 25px;
  height: 17px;
  border: 2px solid var(--lime);
  border-radius: 5px;
}

.form-stack,
.admin-form,
.create-user-form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.42rem;
  color: #c9d2dc;
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #0b1015;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--lime-dark);
  box-shadow: 0 0 0 3px rgb(184 255 61 / 10%);
}

.form-message {
  padding: 0.75rem;
  border: 1px solid #704242;
  border-radius: 10px;
  background: #2a1618;
  color: #ffc2c2;
}

.portal-shell,
.admin-shell {
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
}

.topbar-actions,
.admin-actions,
.form-row {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.topbar-actions form,
.admin-actions form {
  margin: 0;
}

.welcome-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--muted);
}

.live-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.45rem;
  border-radius: 999px;
  background: var(--lime);
  box-shadow: 0 0 0 5px rgb(184 255 61 / 10%);
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 1.25rem;
}

.camera-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.stream-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.stream-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.feed-status {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.6rem;
  border: 1px solid #2b343f;
  border-radius: 8px;
  background: rgb(9 13 17 / 86%);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.feed-status span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--lime);
}

.expand-button {
  position: absolute;
  right: 0.9rem;
  bottom: 0.9rem;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(9 13 17 / 88%);
  text-decoration: none;
}

.camera-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.05rem 1.2rem 1.2rem;
}

.camera-meta h2 {
  margin-bottom: 0.2rem;
  font-size: 1rem;
}

.camera-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.permission-label {
  color: #b9c5d3;
  font-size: 0.75rem;
}

.camera-grid.is-paused .stream-frame {
  background:
    linear-gradient(135deg, rgb(184 255 61 / 4%), transparent),
    #10151a;
}

.camera-grid.is-paused .stream-frame::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  content: "Streams paused";
}

.empty-state {
  grid-column: 1 / -1;
  padding: 4rem 2rem;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
}

.watch-body,
.watch-page {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.watch-page {
  position: fixed;
  inset: 0;
}

.watch-page video-stream {
  display: block;
  width: 100%;
  height: 100%;
}

.watch-label {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 10px;
  background: rgb(0 0 0 / 72%);
  pointer-events: none;
}

.watch-label span {
  color: #b8c1cc;
  font-size: 0.72rem;
}

.admin-shell {
  width: min(100%, 1440px);
}

.admin-panel {
  margin-top: 1.5rem;
  padding: clamp(1rem, 2.5vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading > span {
  color: var(--muted);
  font-size: 0.82rem;
}

.form-row > label {
  min-width: min(100%, 220px);
  flex: 1;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 0.55rem;
}

.camera-choice {
  display: flex;
  min-height: 58px;
  align-items: center;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1217;
  cursor: pointer;
}

.camera-choice input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--lime);
}

.camera-choice span {
  display: grid;
}

.camera-choice small {
  color: var(--muted);
  font-weight: 500;
}

.user-list {
  display: grid;
  gap: 1rem;
}

.user-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0d1217;
}

.user-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.user-card h3,
.user-card header p {
  margin-bottom: 0;
}

.user-card header p {
  color: var(--muted);
  font-size: 0.82rem;
}

.account-status {
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-good {
  background: rgb(184 255 61 / 12%);
  color: var(--lime);
}

.status-off {
  background: rgb(255 123 123 / 12%);
  color: var(--danger);
}

.admin-actions,
.reset-form {
  margin-top: 1rem;
}

.reset-form {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

.reset-form label {
  max-width: 360px;
  flex: 1;
}

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

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

th,
td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 780px) {
  .topbar,
  .welcome-row,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar-actions form,
  .topbar-actions .button {
    width: 100%;
  }

  .reset-form {
    align-items: stretch;
    flex-direction: column;
  }
}
