/* ------------------------------------------------------------------
   LAN Monitor — 3 warna: midnight black, electric blue, cantaloupe.
   Neutral adalah tint dari midnight black, bukan warna keempat.

   Radius: 8px input/tombol, 12px panel, 999px pill status.
   Angka selalu monospace tabular agar tidak bergeser saat nilai berubah.
   ------------------------------------------------------------------ */

:root {
  color-scheme: dark;

  --ink: #07080c;
  --ink-2: #0b0d13;
  --ink-3: #101319;

  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.16);

  --text: #e9ebf2;
  --muted: #9aa1b2;
  --dim: #767c8c;

  --blue: #2e6bff;
  --blue-text: #7fa3ff;
  --blue-soft: rgba(46, 107, 255, 0.14);
  --blue-line: rgba(46, 107, 255, 0.42);

  --orange: #f0a15c;
  --orange-text: #f5b57e;
  --orange-soft: rgba(240, 161, 92, 0.13);
  --orange-line: rgba(240, 161, 92, 0.38);

  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--blue-soft);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

button,
input {
  font: inherit;
  color: inherit;
}

a {
  color: var(--blue-text);
}

/* ------------------------------------------------------------ shell */

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

.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--ink-2);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px;
}

.brand-mark {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--blue);
  border-radius: 4px;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--blue);
  border-radius: 1px;
}

.brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-sub {
  margin: 1px 0 0;
  font: 10px/1.2 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.nav-item[aria-current="page"] {
  color: var(--text);
  background: var(--blue-soft);
  border-color: var(--blue-line);
}

.nav-item .count {
  font: 11px/1 var(--mono);
  color: var(--dim);
}

.nav-item[aria-current="page"] .count {
  color: var(--blue-text);
}

.rail-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.rail-label {
  padding: 0 9px 4px;
  font: 10px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.device-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease;
}

.device-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.device-item[aria-pressed="true"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-2);
}

.device-item .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-item .time {
  font: 10.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
}

.dot.online {
  background: var(--blue);
}

.rail-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 2px;
  border-top: 1px solid var(--line);
  font: 11px/1.2 var(--mono);
  color: var(--muted);
}

.rail-foot .user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-foot button {
  margin-left: auto;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: 10.5px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}

.rail-foot button:hover {
  color: var(--text);
  border-color: var(--line-2);
}

/* ------------------------------------------------------------ main */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar p {
  margin: 1px 0 0;
  font: 11px/1.2 var(--mono);
  color: var(--dim);
}

.topbar-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-2);
}

.segmented button {
  padding: 5px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--dim);
  font: 11px/1 var(--mono);
  cursor: pointer;
  transition: color 120ms ease, background-color 120ms ease;
}

.segmented button:hover {
  color: var(--muted);
}

.segmented button[aria-pressed="true"] {
  color: var(--text);
  background: var(--blue-soft);
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 10px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.conn.down {
  color: var(--orange-text);
  border-color: var(--orange-line);
}

.conn.down .dot {
  background: var(--orange);
}

.conn .dot {
  background: var(--blue);
}

.views {
  flex: 1;
  padding: 16px 20px 48px;
  min-width: 0;
}

.view[hidden] {
  display: none;
}

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

.search {
  flex: 1 1 240px;
  max-width: 360px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-2);
  font-size: 12.5px;
}

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

.search:focus {
  border-color: var(--blue-line);
}

.meta {
  font: 11px/1.3 var(--mono);
  color: var(--dim);
}

.meta strong {
  color: var(--muted);
  font-weight: 500;
}

/* ------------------------------------------------------------ live grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-2);
  overflow: hidden;
  cursor: zoom-in;
  transition: border-color 120ms ease;
}

.card:hover {
  border-color: var(--line-2);
}

.card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.card.offline {
  cursor: default;
  border-style: dashed;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.card-head .name {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 55%;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-head .os {
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
  font: 10px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.screen canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.card.offline canvas {
  filter: grayscale(1);
  opacity: 0.4;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 10px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.card.has-frame .placeholder {
  display: none;
}

.offline-tag {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--orange-line);
  background: var(--ink);
  color: var(--orange-text);
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card.offline .offline-tag {
  display: block;
}

.res {
  position: absolute;
  right: 7px;
  bottom: 7px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(7, 8, 12, 0.78);
  color: var(--muted);
  font: 9.5px/1 var(--mono);
  opacity: 0;
}

.card.has-frame .res {
  opacity: 1;
}

.card-now {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  min-width: 0;
  font: 11px/1.3 var(--mono);
  color: var(--muted);
}

.card-now .app {
  flex: none;
  color: var(--text);
}

.card-now .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
}

.card-now.kind-browser .app {
  color: var(--orange-text);
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 10px 7px;
  font: 10.5px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}

.card-foot .age {
  margin-left: auto;
}

.card.stale .card-foot .age {
  color: var(--orange-text);
}

/* ------------------------------------------------------------ empty */

.empty {
  padding: 56px 24px;
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  text-align: center;
}

.empty h2 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
}

.empty p {
  margin: 0 auto;
  max-width: 52ch;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}

.empty code {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-2);
  color: var(--orange-text);
  font: 11.5px/1.5 var(--mono);
  text-align: left;
  max-width: 100%;
  overflow-x: auto;
}

.empty code.inline {
  display: inline;
  margin: 0;
  padding: 2px 6px;
  overflow: visible;
}

/* ------------------------------------------------------------ tables */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  background: var(--ink-2);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  background: var(--ink-3);
  border-bottom: 1px solid var(--line);
  font: 10px/1 var(--mono);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:first-child td {
  border-top: 0;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.022);
}

td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--muted);
}

td.strong {
  color: var(--text);
  font-weight: 500;
}

td .sub {
  display: block;
  margin-top: 1px;
  font: 10.5px/1.3 var(--mono);
  color: var(--dim);
  max-width: 52ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kind {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font: 9.5px/1.3 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line-2);
  color: var(--muted);
  white-space: nowrap;
}

.kind.browser {
  border-color: var(--orange-line);
  color: var(--orange-text);
}

.table-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.more {
  display: flex;
  justify-content: center;
  padding: 12px 0 0;
}

.btn {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-2);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, transform 60ms ease;
}

.btn:hover {
  color: var(--text);
  border-color: var(--line-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

/* ------------------------------------------------------------ apps */

.bars {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--ink-2);
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(80px, 2.4fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
}

.bar-row:first-child {
  border-top: 0;
}

.bar-name {
  min-width: 0;
}

.bar-name b {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-name span {
  display: block;
  font: 10.5px/1.3 var(--mono);
  color: var(--dim);
}

.bar-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
}

.bar-value {
  font: 11px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

/* ------------------------------------------------------------ viewer */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 8, 12, 0.92);
}

.viewer[hidden] {
  display: none;
}

.viewer-shell {
  width: min(1400px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--ink-2);
  overflow: hidden;
}

.viewer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.viewer-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-head p {
  margin: 0;
  font: 10.5px/1 var(--mono);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-head .btn {
  margin-left: auto;
  flex: none;
}

.viewer-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.viewer-screen canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ------------------------------------------------------------ login */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(720px 420px at 50% -10%, var(--blue-soft), transparent 70%),
    var(--ink);
}

.auth-panel {
  width: min(380px, 100%);
  padding: 26px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink-2);
}

.auth .brand {
  padding: 0;
  margin-bottom: 18px;
}

.auth h1 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth .lede {
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font: 10.5px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--ink);
  font-size: 13px;
}

.field input:focus {
  border-color: var(--blue);
  outline: none;
}

.submit {
  width: 100%;
  margin-top: 6px;
  padding: 10px 14px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 60ms ease, filter 120ms ease;
}

.submit:hover {
  filter: brightness(1.08);
}

.submit:active {
  transform: translateY(1px);
}

.submit[disabled] {
  opacity: 0.6;
  cursor: default;
}

.form-error {
  min-height: 18px;
  margin: 2px 0 8px;
  font: 11.5px/1.4 var(--mono);
  color: var(--orange-text);
}

.auth-foot {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font: 10.5px/1.5 var(--mono);
  color: var(--dim);
}

/* ------------------------------------------------------------ responsive */

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

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .rail .brand-sub,
  .rail-label,
  .rail-foot .user {
    display: none;
  }

  .nav {
    flex-direction: row;
    flex: 0 0 auto;
  }

  .rail-section {
    flex-direction: row;
    align-items: center;
    flex: 0 0 auto;
  }

  .device-list {
    flex-direction: row;
    flex: 0 0 auto;
  }

  .device-item {
    grid-template-columns: 8px auto;
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .device-item .time {
    display: none;
  }

  .rail-foot {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  .views {
    padding: 12px 14px 40px;
  }

  .topbar {
    padding: 9px 14px;
    flex-wrap: wrap;
  }
}

@media (max-width: 620px) {
  .topbar-tools {
    width: 100%;
    margin-left: 0;
  }

  .segmented {
    flex: 1;
  }

  .segmented button {
    flex: 1;
  }

  .bar-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .bar-track {
    display: none;
  }

  .card-now .title {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------------ connect */
/* Halaman /connect: perangkat tanpa install membagikan layar lewat browser. */

.auth-panel.connect {
  width: min(440px, 100%);
}

.field select {
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--ink);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.field select:focus {
  border-color: var(--blue);
  outline: none;
}

.connect-stop {
  border-color: var(--orange-line);
  background: var(--orange-soft);
  color: var(--orange-text);
}

.connect-status {
  margin: 12px 0 0;
  font: 11px/1.5 var(--mono);
  letter-spacing: 0.04em;
  color: var(--dim);
  overflow-wrap: anywhere;
}

.connect-status[data-tone='ok'] { color: var(--blue-text); }
.connect-status[data-tone='warn'] { color: var(--orange-text); }
.connect-status[data-tone='bad'] { color: var(--orange-text); }

.connect-preview {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
}

.connect-alternate {
  display: inline-block;
  margin-top: 10px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--blue-line);
  font: 11px/1 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--blue-text);
  text-decoration: none;
}

.connect-alternate:hover {
  color: var(--text);
  border-bottom-color: var(--line-2);
}

.connect-steps {
  margin: 14px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.connect-steps li {
  margin-bottom: 6px;
}

.connect-steps strong {
  color: var(--text);
  font-weight: 600;
}

.connect-steps em {
  color: var(--orange-text);
  font-style: normal;
}

/* Tombol hentikan agent, hanya tampil di kartu perangkat yang online. */
.card-stop {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid var(--orange-line);
  border-radius: 5px;
  background: transparent;
  font: 10px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--orange-text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.card-stop:hover {
  background: var(--orange-soft);
}

.card-stop[disabled] {
  opacity: 0.5;
  cursor: default;
}
