:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #677084;
  --line: #dfe5ee;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9f4ef;
  --warn: #b45309;
  --off: #98a2b3;
  --shadow: 0 16px 40px rgba(22, 32, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.sidebar {
  min-height: 100vh;
  background: #101828;
  color: white;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo,
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.brand-logo {
  object-fit: contain;
  background: #0b1220;
}

.brand span,
.session-card span,
.session-card small {
  display: block;
  color: #b8c0cf;
  font-size: 13px;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  color: #d7deea;
  background: transparent;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: #1d2939;
  color: white;
}

.session-card {
  margin-top: auto;
  border: 1px solid #2e3b4e;
  border-radius: 8px;
  padding: 14px;
  background: #172033;
}

.shell {
  padding: 28px;
  min-width: 0;
}

.topbar,
.topbar-actions,
.toolbar,
.company-header,
.device-row,
.detail-heading,
.action-row,
menu {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 31px;
}

.topbar-actions {
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button,
.danger-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.icon-button {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.danger-button {
  background: #fff7f7;
  color: #b42318;
  border-color: #f3b8b8;
}

.danger-button:hover {
  background: #fee4e2;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.ops-strip,
.session-log-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.ops-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px;
}

.ops-strip h2,
.panel-heading h2 {
  margin-bottom: 0;
  font-size: 19px;
}

.ops-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ops-stats span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: #fbfcfe;
  font-size: 13px;
}

.ops-stats strong {
  color: var(--ink);
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 6px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.panel {
  overflow: hidden;
}

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

.list-pane,
.detail-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.list-pane {
  overflow: hidden;
}

.toolbar {
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.toolbar input {
  width: 100%;
}

.toolbar input,
.toolbar select,
dialog input,
dialog select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
  background: white;
}

.company-list {
  display: grid;
}

.empty-panel {
  display: grid;
  justify-items: start;
  gap: 9px;
  padding: 24px;
  color: var(--muted);
}

.empty-panel strong {
  color: var(--ink);
}

.inline-empty {
  padding: 18px 52px;
  color: var(--muted);
  background: #fbfcfe;
}

.company {
  border-bottom: 1px solid var(--line);
}

.company:last-child {
  border-bottom: 0;
}

.company-header {
  width: 100%;
  gap: 12px;
  border: 0;
  background: white;
  padding: 14px;
  cursor: pointer;
  text-align: left;
}

.chevron {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef2f7;
  color: var(--muted);
  flex: 0 0 auto;
}

.company-title {
  min-width: 0;
  flex: 1;
}

.company-title strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-title span,
.device-meta,
.detail-muted {
  color: var(--muted);
  font-size: 13px;
}

.company-count {
  color: var(--muted);
  font-size: 13px;
}

.device-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.device-row {
  width: 100%;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid #edf1f6;
  background: #fbfcfe;
  min-height: 62px;
  padding: 10px 14px 10px 52px;
  text-align: left;
  cursor: pointer;
}

.device-row:last-child {
  border-bottom: 0;
}

.device-row:hover,
.device-row.active {
  background: var(--accent-soft);
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--off);
  flex: 0 0 auto;
}

.status-dot.online {
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.13);
}

.device-main {
  flex: 1;
  min-width: 0;
}

.device-main strong {
  display: block;
}

.device-specs {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.detail-pane {
  position: sticky;
  top: 20px;
  min-height: 480px;
  padding: 18px;
}

.empty-state {
  min-height: 440px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
}

.detail-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.detail-heading h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 13px;
}

.badge.online {
  background: #dcfce7;
  color: #166534;
}

.spec-grid {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.spec {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  border-bottom: 1px solid #edf1f6;
  padding-bottom: 10px;
}

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

.client-box {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.client-box span {
  color: var(--muted);
  font-size: 13px;
}

.action-row {
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.activity {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.activity h3 {
  font-size: 15px;
}

.activity ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.session-log-panel {
  margin-top: 18px;
  overflow: hidden;
}

.session-log {
  display: grid;
}

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

.table-head,
.table-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  align-items: center;
  min-width: 780px;
}

.table-head {
  padding: 11px 16px;
  color: var(--muted);
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.table-row {
  min-height: 56px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf1f6;
}

.table-row:last-child {
  border-bottom: 0;
}

#techniciansTable .table-head,
#techniciansTable .table-row {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

#logsTable .session-row {
  grid-template-columns: 150px minmax(0, 1fr) 90px;
}

.session-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 110px 110px;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf1f6;
}

.session-row:last-child {
  border-bottom: 0;
}

.session-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.session-time,
.session-status {
  color: var(--muted);
  font-size: 13px;
}

.session-status {
  justify-self: end;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #fbfcfe;
}

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

#remoteDialog {
  width: min(1280px, calc(100vw - 20px));
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.45);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.dialog-card h2 {
  margin-bottom: 0;
}

.remote-card {
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: #0b1220;
}

.remote-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.remote-toolbar h2 {
  font-size: 20px;
}

.remote-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.remote-controlbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.remote-controlbar input {
  min-width: 240px;
  flex: 1;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.remote-output {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0f172a;
  color: #d1fae5;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.screen-viewer {
  height: min(82vh, 820px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #0b1220;
}

.screen-layer {
  position: relative;
  display: grid;
  place-items: center;
  max-width: 100%;
  max-height: 100%;
  outline: none;
}

.screen-placeholder {
  color: #d1d5db;
  font-size: 14px;
}

.remote-screen {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: none;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

.remote-cursor {
  position: fixed;
  z-index: 3;
  width: 18px;
  height: 18px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-2px, -2px);
}

.remote-cursor::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-left: 14px solid #16a34a;
  border-top: 10px solid transparent;
  border-bottom: 4px solid transparent;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.screen-layer:hover .remote-cursor,
.screen-layer:focus-within .remote-cursor {
  opacity: 1;
}

.remote-status {
  color: #475467;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fbfcfe;
  white-space: nowrap;
}

.remote-command-row {
  display: none;
}

.remote-line {
  display: grid;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.remote-line:last-child {
  border-bottom: 0;
}

.remote-line small,
.remote-line.muted {
  color: #93a4b8;
}

.remote-line pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.check-row {
  display: flex;
  align-items: center;
}

menu {
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  border: 1px solid #b7e4dc;
  border-radius: 8px;
  padding: 12px 14px;
  background: #ecfdf8;
  color: #134e4a;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1080px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

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

  .detail-pane {
    position: static;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 18px;
  }

  .topbar,
  .toolbar,
  .ops-strip,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    flex-direction: column;
  }

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

  .device-row {
    padding-left: 14px;
    align-items: flex-start;
  }

  .device-specs {
    white-space: normal;
  }

  .spec {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .session-row {
    grid-template-columns: 1fr;
  }

  .session-status {
    justify-self: start;
  }
}
