:root {
  --paper: #f4f2ec;
  --surface: #fffef9;
  --surface-alt: #eceae3;
  --ink: #17221c;
  --muted: #667068;
  --line: #d6d4cc;
  --brand: #146b53;
  --brand-dark: #0d513f;
  --brand-soft: #dcece5;
  --amber: #9a5a08;
  --amber-soft: #f7e9ce;
  --danger: #a3312b;
  --danger-soft: #f6dfdc;
  --ok: #18754f;
  --shadow: 0 12px 40px rgb(23 34 28 / 10%);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(90deg, rgb(20 107 83 / 4%) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.small {
  font-size: 0.82rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.12em;
}

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

.login-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 1rem;
  padding: 2rem;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel p {
  margin: 0;
}

.login-fields,
.mfa-setup-fields {
  display: grid;
  gap: 0.9rem;
}

.remember-field {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.remember-field input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.otp-modal {
  width: min(92vw, 480px);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}

.otp-modal form {
  gap: 1.1rem;
}

.otp-heading {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.otp-heading > div {
  display: grid;
  gap: 0.2rem;
}

.otp-heading h2 {
  font-size: 1.25rem;
}

.otp-heading p:last-child {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.otp-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.otp-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.55rem;
}

.otp-inputs input {
  width: 100%;
  min-width: 0;
  height: 54px;
  min-height: 54px;
  padding: 0;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.otp-inputs input:valid {
  border-color: #9bc5b6;
  background: var(--brand-soft);
}

.otp-inputs.invalid input {
  border-color: #dca09a;
  background: var(--danger-soft);
}

.mfa-setup-qr {
  width: min(230px, 100%);
  height: auto;
  justify-self: center;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.mfa-secret-block {
  display: grid;
  gap: 0.35rem;
  padding: 0.7rem;
  border-left: 3px solid var(--brand);
  color: var(--muted);
  background: var(--surface-alt);
  font-size: 0.78rem;
}

.mfa-secret-block code {
  color: var(--ink);
  overflow-wrap: anywhere;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.74rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--brand);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  font-size: 0.8rem;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 0.62rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: white;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgb(20 107 83 / 22%);
  outline-offset: 2px;
  border-color: var(--brand);
}

.button {
  min-height: 38px;
  padding: 0.52rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  border-color: #9faaa2;
  background: #f7f8f5;
}

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

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

.button.primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.button.secondary {
  color: var(--brand-dark);
  border-color: #9bc5b6;
  background: var(--brand-soft);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
}

.button.warning {
  color: var(--amber);
  border-color: #e1bf87;
  background: var(--amber-soft);
}

.button.danger {
  color: var(--danger);
  border-color: #dca09a;
  background: var(--danger-soft);
}

.button.compact {
  min-height: 32px;
  padding: 0.38rem 0.62rem;
  font-size: 0.78rem;
}

.button.wide {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgb(255 254 249 / 94%);
  backdrop-filter: blur(12px);
}

.brand,
.topbar-actions,
.device-summary,
.system-actions,
.process-tools,
.file-command-row,
.modal-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 0.7rem;
}

.brand > div {
  display: grid;
  gap: 0.08rem;
}

.brand .muted {
  font-size: 0.72rem;
}

.topbar-actions {
  gap: 0.5rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.22rem 0.58rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
}

.status-pill.neutral {
  color: var(--muted);
  background: var(--surface-alt);
}

.status-pill.online {
  color: var(--ok);
  background: var(--brand-soft);
}

.status-pill.offline {
  color: var(--danger);
  background: var(--danger-soft);
}

.workspace {
  padding: 1rem;
}

.device-strip {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr auto;
  align-items: end;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.device-control {
  min-width: 0;
  display: grid;
  gap: 0.3rem;
}

.device-selector {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.device-selector-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
}

.device-summary {
  min-height: 40px;
  gap: 0.55rem;
  padding-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgb(24 117 79 / 12%);
}

.status-dot.offline {
  background: var(--danger);
}

.system-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.process-workspace,
.activity-rail {
  min-width: 0;
}

.process-workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.compact-heading {
  padding: 0;
}

.process-tools {
  gap: 0.6rem;
}

.count-chip {
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 0.74rem;
  font-weight: 750;
}

.search-field {
  min-width: 250px;
}

.search-field input {
  min-height: 36px;
}

.file-command {
  display: grid;
  gap: 0.4rem;
  padding: 0 1rem 1rem;
  border-bottom: 1px solid var(--line);
}

.file-command > label {
  color: var(--muted);
  font-size: 0.76rem;
}

.file-command-row {
  gap: 0.5rem;
}

.file-command-row input {
  min-width: 0;
}

.table-frame {
  min-height: 420px;
  max-height: calc(100vh - 290px);
  overflow: auto;
}

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

th,
td {
  padding: 0.58rem 0.7rem;
  border-bottom: 1px solid #e8e5de;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  z-index: 2;
  top: 0;
  color: var(--muted);
  background: #f6f5ef;
  font-size: 0.68rem;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

th:nth-child(2) {
  width: 19%;
}

th:nth-child(3) {
  width: 96px;
}

th:nth-child(4) {
  width: 108px;
}

th:nth-child(5) {
  width: 37%;
}

.sortable-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.sort-button {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
}

.sort-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sort-button[data-process-sort-direction="desc"] svg {
  transform: rotate(180deg);
}

.sort-button:hover {
  border-color: #bec8c0;
  color: var(--ink);
  background: #ebeee8;
}

.sort-button[aria-pressed="true"] {
  border-color: var(--brand);
  color: white;
  background: var(--brand);
}

.icon-column {
  width: 48px;
}

.actions-column {
  width: 132px;
}

td {
  font-size: 0.8rem;
}

tbody tr:hover {
  background: #f8f8f3;
}

tbody tr.foreground {
  box-shadow: inset 3px 0 var(--brand);
  background: #f1f8f4;
}

.process-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  object-fit: contain;
  background: white;
  font-size: 0.65rem;
  color: var(--muted);
}

.process-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.foreground-label {
  display: inline-block;
  margin-top: 0.18rem;
  color: var(--brand);
  font-size: 0.66rem;
  font-weight: 760;
}

.path-cell {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.71rem;
}

.row-actions {
  display: flex;
  gap: 0.3rem;
}

.row-actions .button {
  min-height: 27px;
  padding: 0.25rem 0.45rem;
  font-size: 0.69rem;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.86rem;
}

.activity-rail {
  display: grid;
  gap: 1rem;
}

.rail-section {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.screenshot-frame {
  min-height: 180px;
  display: grid;
  place-items: center;
  margin-top: 0.8rem;
  border: 1px dashed #b9beb9;
  border-radius: 6px;
  color: var(--muted);
  background: #f7f6f0;
  overflow: hidden;
}

.screenshot-frame img {
  width: 100%;
  height: auto;
  display: block;
}

.screenshot-preview-trigger {
  width: 100%;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.screenshot-preview-trigger:hover img {
  opacity: 0.92;
}

.screenshot-preview-trigger:focus-visible {
  outline-offset: -3px;
}

.activity-list {
  max-height: 390px;
  display: grid;
  gap: 0;
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}

.activity-item {
  display: grid;
  gap: 0.16rem;
  padding: 0.62rem 0;
  border-bottom: 1px solid #e8e5de;
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-title {
  font-size: 0.79rem;
  font-weight: 700;
}

.activity-time {
  color: var(--muted);
  font-size: 0.68rem;
}

.modal {
  width: min(92vw, 480px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgb(15 24 19 / 62%);
}

.modal form {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}

.modal h2,
.modal p {
  margin: 0;
}

.modal-actions {
  justify-content: flex-end;
  gap: 0.5rem;
}

.device-details-modal {
  width: min(94vw, 820px);
  max-height: calc(100dvh - 2rem);
  overflow: hidden;
}

.device-details-shell {
  max-height: calc(100dvh - 2rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.device-details-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}

.device-details-toolbar h2 {
  font-size: 1.15rem;
}

.device-details-toolbar p:last-child {
  margin-top: 0.2rem;
  font-size: 0.76rem;
}

.device-details-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
}

.device-details-close:hover {
  color: var(--ink);
  border-color: #aeb7b1;
}

.device-details-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.device-details-content {
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  overflow-y: auto;
}

.device-details-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.device-details-overview > div:first-child {
  min-width: 0;
  display: grid;
  gap: 0.18rem;
}

.device-details-overview strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.device-details-overview span {
  overflow-wrap: anywhere;
  font-size: 0.72rem;
}

.device-details-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.device-details-list {
  margin: 0;
  border-top: 1px solid var(--line);
}

.device-detail-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.3fr) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.device-detail-row dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.device-detail-row dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
  user-select: text;
}

.device-detail-row code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.device-details-empty {
  min-height: 120px;
}

.screenshot-preview-modal {
  width: min(96vw, 1500px);
  max-width: none;
  height: min(92vh, 1000px);
  max-height: 92vh;
  padding: 0;
  border: 1px solid #344438;
  border-radius: 8px;
  color: #f4f7f4;
  background: #101612;
  box-shadow: 0 24px 80px rgb(0 0 0 / 55%);
  overflow: hidden;
}

.screenshot-preview-modal::backdrop {
  background: rgb(5 10 7 / 84%);
}

.screenshot-preview-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.screenshot-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #344438;
  background: #17221c;
}

.screenshot-preview-toolbar .eyebrow {
  color: #8fbaa8;
}

.screenshot-preview-toolbar h2 {
  margin: 0;
  font-size: 1rem;
}

.screenshot-preview-toolbar p:last-child {
  margin: 0.2rem 0 0;
  color: #b9c8c0;
  font-size: 0.72rem;
}

.screenshot-preview-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid #46594e;
  border-radius: 6px;
  color: #f4f7f4;
  background: #223028;
}

.screenshot-preview-close:hover {
  border-color: #779587;
  background: #2d3e34;
}

.screenshot-preview-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screenshot-preview-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #0b100d;
  overflow: auto;
}

.screenshot-preview-stage img {
  max-width: 100%;
  max-height: calc(92vh - 112px);
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.toast-region {
  position: fixed;
  z-index: 100;
  top: 1rem;
  right: 1rem;
  bottom: auto;
  left: auto;
  width: min(380px, calc(100vw - 2rem));
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.toast {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-left: 4px solid var(--brand);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  animation: toast-enter 180ms ease-out;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateX(0.75rem);
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(-0.35rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
    transition: none;
  }
}

@media (max-width: 1100px) {
  .device-strip {
    grid-template-columns: minmax(220px, 1fr) auto;
  }

  .device-summary {
    display: none;
  }

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

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

@media (max-width: 720px) {
  .topbar,
  .section-heading,
  .process-tools,
  .file-command-row,
  .device-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    gap: 0.7rem;
  }

  .topbar-actions,
  .system-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .workspace {
    padding: 0.65rem;
  }

  .device-strip {
    display: grid;
    grid-template-columns: 1fr;
  }

  .device-details-overview {
    align-items: flex-start;
    flex-direction: column;
  }

  .device-details-badges {
    justify-content: flex-start;
  }

  .device-detail-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .main-grid,
  .activity-rail {
    grid-template-columns: 1fr;
  }

  .search-field {
    width: 100%;
    min-width: 0;
  }

  .table-frame {
    max-height: 62vh;
  }

  table {
    min-width: 560px;
  }

  th:nth-child(5),
  td:nth-child(5) {
    display: none;
  }

  th:nth-child(2) {
    width: auto;
  }

  .actions-column {
    width: 118px;
  }

  .screenshot-preview-modal {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .screenshot-preview-toolbar {
    padding: 0.7rem 0.8rem;
  }

  .screenshot-preview-stage {
    padding: 0.5rem;
  }

  .screenshot-preview-stage img {
    max-height: calc(100dvh - 106px);
  }
}
