:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --paper: #fff;
  --ink: #202627;
  --muted: #6d7679;
  --line: #dfe4e5;
  --accent: #176f54;
  --soft: #e7f3ed;
  --danger: #ad343c;
  --amber: #865d18;
  --code: #f3f5f6;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a1b;
  --paper: #202526;
  --ink: #e8edeb;
  --muted: #a1aeac;
  --line: #384141;
  --accent: #7bccab;
  --soft: #263e35;
  --danger: #f38b92;
  --amber: #e8bc68;
  --code: #191f20;
}
* {
  box-sizing: border-box;
  letter-spacing: 0;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.6 system-ui,
    -apple-system,
    "Noto Sans",
    sans-serif;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover {
  border-color: var(--accent);
  background: var(--soft);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}
button.danger {
  color: var(--danger);
}
svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
input,
select,
textarea {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 9px 10px;
  border-radius: 5px;
  min-width: 0;
}
textarea {
  resize: vertical;
  min-height: 72px;
}
label {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
h1 {
  font-size: 24px;
  line-height: 1.4;
  margin: 0 0 6px;
}
h2 {
  font-size: 17px;
  margin: 20px 0 12px;
}
p {
  margin: 0 0 12px;
}
strong {
  font-weight: 600;
}
.muted {
  color: var(--muted);
}
.error {
  color: var(--danger);
}
.shell {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 16px;
}
.brand svg {
  color: var(--accent);
  width: 24px;
  height: 24px;
}
.sidebar nav {
  display: grid;
  gap: 6px;
}
.sidebar nav button {
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  min-height: 42px;
}
.sidebar nav button.active {
  background: var(--soft);
  color: var(--accent);
}
.sidebar-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
}
.topbar {
  height: 65px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  background: var(--paper);
}
.topbar > div {
  display: flex;
  gap: 12px;
  align-items: center;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.page-head {
  padding: 24px 28px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.page-head p {
  margin: 0;
}
.agents {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
  margin: 0 28px 22px;
}
.agent {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}
.agent-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.agent-title strong {
  overflow-wrap: anywhere;
}
.agent-title .badge {
  margin-left: auto;
}
.agent p {
  margin: 2px 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.agent-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 12px;
}
.dot {
  height: 7px;
  width: 7px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  margin-right: 5px;
}
.dot.online {
  background: var(--accent);
}
.badge {
  font-size: 11px;
  background: var(--code);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.badge.green {
  color: var(--accent);
  background: var(--soft);
}
.badge.amber {
  color: var(--amber);
}
.badge.red {
  color: var(--danger);
}
.view {
  margin: 0 28px 28px;
}
.console-grid {
  display: grid;
  grid-template-columns: minmax(230px, 29%) minmax(0, 1fr);
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  min-height: 530px;
  overflow: hidden;
}
.job-list {
  border-right: 1px solid var(--line);
  max-height: 760px;
  overflow: auto;
}
.section-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.job {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}
.job > strong {
  display: block;
  overflow-wrap: anywhere;
  padding: 0 5px 7px;
}
.task-row {
  display: flex;
  width: 100%;
  gap: 8px;
  text-align: left;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  padding: 10px 7px;
  min-height: 56px;
  margin: 3px 0;
}
.task-row.active {
  background: var(--soft);
  border-color: var(--line);
}
.task-row .task-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.task-row small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.task-row .badge {
  align-self: center;
}
.task-workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.task-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 80px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.task-heading strong {
  font-size: 17px;
  overflow-wrap: anywhere;
}
.task-heading p {
  font-size: 12px;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  gap: 20px;
}
.tabs button {
  border: 0;
  border-radius: 0;
  padding: 12px 2px;
  background: transparent;
  font-size: 13px;
  min-width: 50px;
}
.tabs button.active {
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
}
.task-output {
  padding: 20px;
  flex: 1;
  min-height: 260px;
  max-height: 540px;
  overflow: auto;
}
.task-output pre,
.message p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font:
    13px/1.7 system-ui,
    sans-serif;
  margin: 0;
}
.task-output pre.code,
pre.code {
  font:
    12px/1.7 ui-monospace,
    monospace;
  background: var(--code);
  padding: 14px;
  border-radius: 5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.message:first-child {
  padding-top: 0;
}
.message small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 7px;
}
.message.user p {
  color: var(--muted);
}
.composer {
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.composer textarea {
  min-height: 66px;
}
.composer button {
  height: 38px;
  min-width: 80px;
  white-space: nowrap;
  flex-shrink: 0;
}
.approvals:empty {
  display: none;
}
.approvals {
  padding: 0 20px 16px;
}
.approval {
  background: var(--code);
  border-left: 3px solid var(--amber);
  padding: 14px;
  margin-top: 12px;
}
.approval pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  max-height: 160px;
  overflow: auto;
}
.empty {
  text-align: center;
  padding: 52px 16px;
  color: var(--muted);
}
.empty svg {
  width: 32px;
  height: 32px;
  margin-bottom: 12px;
}
.empty p {
  margin: 0;
}
.filterbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 16px 0;
}
.filterbar label {
  width: 260px;
  margin: 0;
}
.data-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.data-row .grow {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.data-row p {
  margin: 3px 0;
  font-size: 12px;
  color: var(--muted);
}
.settings-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  gap: 16px;
  flex-wrap: wrap;
}
.settings-line > div:first-child {
  flex: 1 1 220px;
  min-width: 0;
}
.inline-help,
.command-help {
  margin: 4px 0 14px;
  font-size: 13px;
}
details summary {
  cursor: pointer;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}
details summary svg {
  width: 15px;
  height: 15px;
}
details p {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.help-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.help-row p {
  color: var(--muted);
  margin: 5px 0;
}
.settings-line h2 {
  margin: 0 0 4px;
}
.settings-line p {
  margin: 0;
  overflow-wrap: anywhere;
}
dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop {
  background: #0007;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 1;
}
.modal-head h2 {
  margin: 0;
}
#modal-body {
  padding: 20px 22px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-top: 18px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.task-editor {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.task-editor select[multiple] {
  min-height: 72px;
}
.task-editor textarea {
  min-height: 85px;
}
.stack {
  display: grid;
  gap: 12px;
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(380px, 100%);
}
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.auth-links button { border: 0; background: transparent; padding: 4px 0; color: var(--accent); }
#username { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-password { max-width: 420px; }
#account-content h2 { overflow-wrap: anywhere; }
.account-note { padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--amber); }
.account-user { flex-wrap: wrap; }
.account-user .grow { min-width: min(220px, 100%); overflow-wrap: anywhere; }
.form-message { margin-top: 12px; overflow-wrap: anywhere; }
.login-form .brand {
  margin-bottom: 42px;
}
.login-form h1 {
  margin-bottom: 10px;
}
.login-form > p {
  margin-bottom: 26px;
}
.login-form > button {
  width: 100%;
}
.login-form .error {
  margin-bottom: 12px;
  font-size: 13px;
}
.toast {
  position: fixed;
  bottom: 22px;
  right: 24px;
  max-width: min(480px, calc(100vw - 32px));
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 6px;
  z-index: 10;
  overflow-wrap: anywhere;
}
.status-line {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0;
}
.snapshot-messages {
  max-height: 390px;
  overflow: auto;
}
.device-path {
  font-family: ui-monospace, monospace;
}
button small {
  font-size: 11px;
}
a {
  color: var(--accent);
}
[hidden] {
  display: none !important;
}
@media (max-width: 1000px) {
  .shell {
    grid-template-columns: 175px minmax(0, 1fr);
  }
  .sidebar {
    padding: 20px 10px;
  }
  .brand {
    font-size: 14px;
    gap: 7px;
  }
  .page-head,
  .topbar {
    padding-left: 20px;
    padding-right: 20px;
  }
  #username { max-width: 140px; }
  .agents,
  .view {
    margin-left: 20px;
    margin-right: 20px;
  }
  .console-grid {
    grid-template-columns: 230px minmax(0, 1fr);
  }
  .task-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .task-row .badge {
    font-size: 10px;
  }
}
@media (max-width: 700px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 12px 14px;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .brand {
    font-size: 16px;
  }
  .sidebar nav {
    display: flex;
    overflow: auto;
    gap: 3px;
  }
  .sidebar nav button {
    flex-shrink: 0;
    min-height: 36px;
    padding: 7px 9px;
    font-size: 12px;
  }
  .sidebar nav button svg {
    width: 15px;
    height: 15px;
  }
  .sidebar-footer {
    position: absolute;
    right: 14px;
    top: 9px;
  }
  .sidebar-footer > span {
    display: none;
  }
  .topbar {
    height: 48px;
    padding: 0 16px;
    font-size: 12px;
  }
  .page-head {
    padding: 18px 16px 14px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  h1 {
    font-size: 22px;
  }
  .agents {
    margin: 0 16px 16px;
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }
  .agent {
    padding: 12px;
    flex: 0 0 260px;
  }
  .view {
    margin: 0 16px 20px;
  }
  .console-grid {
    display: flex;
    flex-direction: column;
    min-height: 500px;
  }
  .job-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 250px;
  }
  .job {
    padding: 10px;
  }
  .task-row {
    min-height: 48px;
  }
  .task-heading {
    padding: 14px;
  }
  .task-output {
    padding: 14px;
    max-height: 450px;
    min-height: 220px;
  }
  .composer {
    padding: 12px;
    gap: 8px;
  }
  .composer button {
    padding: 8px;
  }
  .data-row {
    gap: 10px;
    flex-wrap: wrap;
  }
  .data-row .grow {
    min-width: calc(100% - 35px);
  }
  .data-row .toolbar {
    margin-left: 0;
  }
  .filterbar label {
    flex: 1;
    width: auto;
  }
  .filterbar button {
    font-size: 12px;
  }
  .form-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  #modal-body {
    padding: 16px;
  }
  .modal-head {
    padding: 14px 16px;
  }
  .toast {
    right: 16px;
    bottom: 16px;
  }
  .approvals {
    padding: 0 14px 14px;
  }
}
