:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #ffffff;
  --surface: #f4f7fb;
  --nav: #0d2746;
  --nav-2: #12385f;
  --orange: #f28c28;
  --orange-2: #ffd9b0;
  --green: #1f9d69;
  --red: #c94848;
  --blue: #1f66ad;
  --shadow: 0 18px 40px rgba(15, 39, 70, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  background: var(--paper);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  border-right: 1px solid var(--line);
}

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

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

.brand-copy strong {
  display: block;
  font-size: 1rem;
}

.brand-copy span {
  color: var(--muted);
  font-size: 0.86rem;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1;
  color: var(--nav);
}

.login-panel p {
  margin: 0 0 28px;
  color: var(--muted);
  max-width: 34rem;
}

.login-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #344054;
  font-size: 0.86rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 102, 173, 0.14);
}

.hero-side {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(13, 39, 70, 0.96), rgba(23, 84, 134, 0.88)),
    linear-gradient(45deg, #0d2746, #1f66ad);
}

.hero-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 44px 44px;
}

.ops-board {
  position: relative;
  width: min(720px, 84%);
  min-height: 440px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.32);
  padding: 22px;
}

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

.ops-screen {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.monitor-preview {
  min-height: 260px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(242, 140, 40, 0.2) 0 8px, transparent 8px),
    linear-gradient(180deg, #1f2d3d, #253e5a);
  padding: 18px;
  color: #fff;
}

.preview-bar {
  height: 12px;
  width: 68%;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.preview-tile {
  min-height: 82px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.login-note {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.sidebar {
  background: var(--nav);
  color: #eaf2fb;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar .brand-mark {
  background: #fff;
  color: var(--nav);
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  color: #dce9f7;
  background: transparent;
}

.nav-button:hover,
.nav-button.active {
  color: #fff;
  background: var(--nav-2);
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.11);
  font-size: 0.75rem;
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

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

.topbar h2 {
  margin: 0;
  color: var(--nav);
  font-size: 1.35rem;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.content {
  padding: 24px;
  overflow: auto;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 39, 70, 0.06);
}

.card.pad {
  padding: 18px;
}

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

.metric span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.metric strong {
  font-size: 2rem;
  color: var(--nav);
  line-height: 1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h3 {
  margin: 0;
  color: var(--nav);
  font-size: 1.05rem;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.toolbar input,
.toolbar select {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--nav);
  color: #fff;
  font-weight: 800;
}

.btn:hover {
  background: #173c68;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn.secondary {
  background: #eef3f8;
  color: var(--nav);
}

.btn.secondary:hover {
  background: #dfe9f3;
}

.btn.warn {
  background: var(--orange);
  color: #172033;
}

.btn.danger {
  background: var(--red);
}

.btn.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: #344054;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8fafc;
}

td {
  color: #263448;
  font-size: 0.92rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef3f8;
  color: var(--nav);
  font-size: 0.78rem;
  font-weight: 800;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status.online,
.status.active,
.status.open,
.status.authorized {
  background: #e8f7ef;
  color: var(--green);
}

.status.offline,
.status.rejected,
.status.closed {
  background: #fdecec;
  color: var(--red);
}

.status.awaiting_connection,
.status.awaiting_consent,
.status.in_progress {
  background: #fff5e8;
  color: #b9600f;
}

.quick-connect {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) repeat(4, auto);
  gap: 10px;
  align-items: end;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
}

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

.remote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 16px;
}

.remote-viewer {
  min-height: 520px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(242, 140, 40, 0.2) 0 7px, transparent 7px),
    linear-gradient(180deg, #152337, #27496e 64%, #20364f);
  color: #fff;
  overflow: hidden;
  position: relative;
}

.remote-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: rgba(8, 20, 34, 0.44);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.monitor-tabs {
  display: flex;
  gap: 8px;
}

.monitor-tabs button {
  border-radius: 7px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

.monitor-tabs button.active {
  background: var(--orange);
  color: #172033;
}

.desktop-window {
  margin: 34px auto;
  width: min(760px, calc(100% - 48px));
  min-height: 330px;
  border-radius: 8px;
  background: #f6f8fb;
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.window-top {
  height: 42px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c5ced8;
}

.window-body {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.fake-row {
  height: 12px;
  border-radius: 999px;
  background: #dce4ee;
}

.fake-row.short {
  width: 58%;
}

.fake-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.fake-tile {
  min-height: 86px;
  border: 1px solid #dce4ee;
  border-radius: 8px;
  background: #fff;
}

.remote-video-frame {
  position: relative;
  width: min(920px, calc(100% - 40px));
  aspect-ratio: 16 / 9;
  margin: 26px auto;
  overflow: hidden;
  border-radius: 8px;
  background: #07111e;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.remote-video-frame[data-control="1"] {
  cursor: crosshair;
}

.remote-video-frame:focus {
  outline: 3px solid rgba(242, 140, 40, 0.75);
  outline-offset: 3px;
}

.remote-video-frame video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #050b13;
}

.remote-video-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(242, 140, 40, 0.16) 0 7px, transparent 7px),
    linear-gradient(180deg, #152337, #20364f);
}

.remote-video-empty strong {
  font-size: 1.1rem;
}

.remote-video-empty span {
  color: #dce9f7;
}

.chat-box {
  display: grid;
  grid-template-rows: minmax(220px, 1fr) auto;
  min-height: 360px;
}

.messages {
  overflow: auto;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.message {
  max-width: 86%;
  border-radius: 8px;
  padding: 10px 12px;
  background: #eef3f8;
}

.message.technician {
  justify-self: end;
  background: var(--nav);
  color: #fff;
}

.message strong {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
}

.stack {
  display: grid;
  gap: 12px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--nav);
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast.error {
  background: var(--red);
}

.toast.success {
  background: var(--green);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 32, 51, 0.48);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 30;
}

.modal {
  width: min(620px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal h3 {
  margin: 0 0 14px;
  color: var(--nav);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.mobile-menu {
  display: none;
}

@media (max-width: 1100px) {
  .grid.cols-4,
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .remote-layout,
  .ops-screen {
    grid-template-columns: 1fr;
  }

  .quick-connect {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .hero-side {
    display: none;
  }

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
  }

  .sidebar .brand-row,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-button {
    white-space: nowrap;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 16px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .split {
    grid-template-columns: 1fr;
  }

  .quick-connect {
    grid-template-columns: 1fr;
  }
}
