:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --text: #172026;
  --muted: #66737c;
  --line: #dce3e1;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #c77800;
  --danger: #b42318;
  --ok: #16845c;
  --ink: #111827;
  --shadow: 0 18px 50px rgba(27, 38, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 32px;
  align-items: center;
  padding: 42px;
}

.login-art {
  position: relative;
  min-height: calc(100vh - 84px);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.82), rgba(199, 120, 0, 0.58)),
    url("https://images.unsplash.com/photo-1516321318423-f06f85e504b3?auto=format&fit=crop&w=1800&q=80");
  background-position: center;
  background-size: cover;
  box-shadow: var(--shadow);
}

.login-copy {
  position: absolute;
  left: 46px;
  right: 46px;
  bottom: 42px;
  color: #fff;
}

.login-copy h1 {
  max-width: 760px;
  margin: 8px 0;
  font-size: clamp(42px, 6vw, 78px);
  line-height: 0.95;
}

.login-copy p {
  max-width: 620px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 17px;
}

.login-phone {
  position: absolute;
  top: 62px;
  right: 9%;
  width: 190px;
  height: 380px;
  border: 10px solid rgba(255, 255, 255, 0.88);
  border-radius: 30px;
  background: #101820;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.phone-top {
  width: 54px;
  height: 5px;
  margin: 11px auto 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.phone-screen {
  display: grid;
  height: calc(100% - 26px);
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: #fff;
}

.phone-screen strong {
  font-size: 32px;
}

.phone-screen small {
  color: rgba(255, 255, 255, 0.62);
}

.pulse-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #2ee59d;
  box-shadow: 0 0 0 10px rgba(46, 229, 157, 0.15);
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-mark {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-row h1,
.brand-row h2 {
  font-size: 20px;
}

.brand-row p,
.topbar p,
.section-head p,
.device-card p,
.side-footer p {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

select[multiple] {
  min-height: 126px;
  padding: 8px;
}

textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 118, 110, 0.15);
}

.btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.quiet {
  border-color: var(--line);
  background: #fff;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.wide {
  width: 100%;
}

.form-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-right: 1px solid var(--line);
  background: #ffffff;
  padding: 22px;
}

.side-brand {
  margin-bottom: 20px;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-item {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: #44515a;
  text-align: left;
  font-weight: 750;
}

.nav-item.active,
.nav-item:hover {
  background: #e8f3f1;
  color: var(--primary-strong);
}

.side-footer {
  display: grid;
  gap: 12px;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar,
.section-head,
.filter-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: 26px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-view {
  min-width: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.filter-bar {
  align-items: center;
}

.filter-bar input {
  max-width: 520px;
}

.filter-bar select {
  max-width: 160px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.device-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.device-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.device-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.device-card h3 {
  margin-top: 8px;
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #edf0f2;
  color: #61707b;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.online {
  background: #def7ec;
  color: var(--ok);
}

.permission-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.perm {
  border: 1px solid #e3e7e5;
  border-radius: 999px;
  padding: 5px 8px;
  color: #6b747a;
  font-size: 12px;
  font-weight: 700;
}

.perm.ok {
  border-color: rgba(22, 132, 92, 0.25);
  background: #eefaf4;
  color: var(--ok);
}

.device-meta-list {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.device-meta-list div {
  min-width: 0;
}

.device-meta-list dt {
  float: left;
  width: 70px;
  color: #48565e;
  font-weight: 800;
}

.device-meta-list dd {
  overflow-wrap: anywhere;
}

.device-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-table {
  margin-bottom: 22px;
}

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

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

th {
  color: #4b5963;
  font-size: 12px;
  text-transform: uppercase;
}

td span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

.stat-number {
  color: var(--primary-strong);
  font-size: 18px;
}

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

.comm-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.comm-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.comm-card h3 {
  margin-bottom: 12px;
}

.comm-list {
  display: grid;
  gap: 8px;
}

.comm-row {
  display: grid;
  gap: 4px;
  border: 1px solid #edf1ef;
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px;
}

.comm-row span,
.muted-row {
  color: var(--muted);
  font-size: 12px;
}

.audit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 16px;
}

.audit-item p,
.audit-item time {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-content: center;
  justify-items: center;
  gap: 8px;
  border: 1px dashed #c7d0ce;
  border-radius: 8px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.control-view {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr;
  background: #101418;
  color: #fff;
}

.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #fff;
  color: var(--text);
  padding: 14px 18px;
}

.control-bar h2 {
  font-size: 22px;
}

#controlState {
  display: inline-block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.viewer-layout {
  display: grid;
  min-height: 0;
  grid-template-columns: 116px minmax(0, 1fr) 260px;
}

.control-tools,
.session-panel {
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  background: #171c21;
  padding: 14px;
}

.session-panel {
  border-right: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-btn {
  width: 100%;
  min-height: 42px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  background: #222a31;
  color: #fff;
  font-weight: 800;
}

.viewer-shell {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
}

#remoteVideo,
#remoteImage {
  max-width: 100%;
  max-height: calc(100vh - 72px);
  background: #000;
  object-fit: contain;
  touch-action: none;
  user-select: none;
}

#remoteImage {
  display: none;
}

.empty-video {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: #cbd5df;
  pointer-events: none;
}

.empty-video strong {
  color: #fff;
}

.session-panel h3 {
  margin-bottom: 14px;
}

.session-details {
  display: grid;
  gap: 10px;
}

.session-details div {
  display: grid;
  gap: 3px;
}

.session-details span {
  color: #9aa6b2;
  font-size: 12px;
}

.session-details strong {
  overflow-wrap: anywhere;
}

.modal {
  width: min(520px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.48);
}

.modal form {
  padding: 18px;
}

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

.modal footer {
  justify-content: flex-end;
  margin-top: 18px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #53606a;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  border-radius: 8px;
  background: #172026;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@media (max-width: 1040px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 360px;
  }

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    gap: 14px;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-brand {
    margin-bottom: 0;
  }

  .side-nav {
    display: flex;
    overflow: auto;
  }

  .side-footer {
    min-width: 150px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .control-tools,
  .session-panel {
    display: none;
  }
}

@media (max-width: 720px) {
  .login-view,
  .workspace {
    padding: 16px;
  }

  .login-art {
    min-height: 300px;
  }

  .login-phone {
    display: none;
  }

  .login-copy {
    left: 22px;
    right: 22px;
    bottom: 22px;
  }

  .login-copy h1 {
    font-size: 42px;
  }

  .topbar,
  .filter-bar,
  .control-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions,
  .control-actions {
    justify-content: flex-start;
  }

  .metric-grid,
  .device-grid,
  .device-grid.compact,
  .comm-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    padding: 14px;
  }

  .side-footer {
    grid-column: 1 / -1;
  }
}
