:root {
  --bg: #061416;
  --panel: #0b2022;
  --panel-2: #10292b;
  --line: #1b3b3d;
  --line-light: #2a5355;
  --text: #f4f1e9;
  --muted: #83a3a3;
  --orange: #ff9f43;
  --orange-bright: #ffba73;
  --teal: #35d0c2;
  --teal-dark: #0d3b3a;
  --amber: #ffc56b;
  --red: #ff7d77;
  --blue: #69c9d0;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, Manrope, system-ui, sans-serif; }
body { min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted, .field-hint { color: var(--muted); }
.eyebrow { color: var(--orange); font: 500 11px/1.4 'DM Mono', monospace; letter-spacing: .16em; text-transform: uppercase; margin: 0 0 8px; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 25%, #154447 0, var(--bg) 48%); }
.login-view::before { content: ''; position: fixed; inset: 0; opacity: .16; background-image: linear-gradient(#2d5c5d 1px, transparent 1px), linear-gradient(90deg, #2d5c5d 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(to bottom, black, transparent 70%); pointer-events: none; }
.login-panel { position: relative; width: min(430px, 100%); padding: 42px; border: 1px solid var(--line-light); border-radius: 16px; background: rgba(8, 29, 31, .95); box-shadow: 0 24px 80px #0008; }
.login-panel h1 { margin: 0 0 28px; }
.login-logo { display: block; width: 100%; height: auto; }
.brand-icon { display: block; width: 42px; height: 42px; flex: 0 0 auto; object-fit: contain; }

form label { display: grid; gap: 8px; color: #b8cdcc; font-size: 13px; font-weight: 600; margin: 18px 0; }
input, textarea { width: 100%; border: 1px solid var(--line-light); border-radius: 8px; color: var(--text); background: #071719; padding: 13px 14px; outline: none; resize: vertical; }
input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #35d0c21c; }
.mono { font-family: 'DM Mono', monospace; font-size: 13px; }
button { border: 0; cursor: pointer; }
.primary { border-radius: 8px; padding: 13px 18px; color: #1b1007; background: var(--orange); font-weight: 700; display: inline-flex; justify-content: center; gap: 24px; align-items: center; }
.primary:hover { background: var(--orange-bright); }
.primary.compact { padding: 10px 14px; gap: 8px; }
.login-panel .primary { width: 100%; margin-top: 6px; }
.auth-switch { width: 100%; margin-top: 16px; color: var(--muted); background: transparent; font-size: 11px; }
.auth-switch:hover { color: var(--orange); }
.form-error { min-height: 18px; color: var(--red); font-size: 13px; }

.app-view { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 230px; padding: 26px 18px; display: flex; flex-direction: column; background: #071719; border-right: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 14px; padding: 0 8px 32px; font: 700 14px 'DM Mono', monospace; letter-spacing: .15em; }
nav { display: grid; gap: 6px; }
.nav-item { width: 100%; padding: 11px 12px; border-radius: 7px; color: var(--muted); background: transparent; text-align: left; font-weight: 600; }
.nav-item span { display: inline-block; width: 26px; font-size: 17px; }
.nav-item:hover, .nav-item.active { color: var(--text); background: #102b2d; }
.nav-item.active { box-shadow: inset 2px 0 var(--orange); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 8px; }
.scope-note { display: flex; gap: 10px; padding: 14px 10px; border-top: 1px solid var(--line); }
.scope-note strong, .scope-note small { display: block; font-size: 11px; }
.scope-note small { color: var(--muted); margin-top: 3px; }
.status-dot { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px var(--teal); }
.user-note { min-width: 0; max-width: 240px; padding: 5px 8px; text-align: right; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 7px; }
.user-note:hover { border-color: var(--line-light); }
.user-note strong, .user-note small { display: block; font-size: 11px; }
.user-note strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-note small { margin-top: 3px; color: var(--orange); font: 9px 'DM Mono', monospace; letter-spacing: .08em; text-transform: uppercase; }
.logout { flex-shrink: 0; white-space: nowrap; padding: 9px 12px; border: 1px solid var(--line-light); border-radius: 7px; color: var(--muted); background: transparent; font-weight: 600; }
.logout:hover { color: var(--orange); border-color: #8d6037; }

main { margin-left: 230px; min-height: 100vh; }
header { height: 94px; padding: 20px 42px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
header > div:first-child { flex: 1; min-width: 0; }
header h2 { margin: 0; font-size: 24px; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 12px; min-width: 0; max-width: 60%; }
form select { width: 100%; padding: 12px 13px; border: 1px solid var(--line-light); border-radius: 8px; color: var(--text); background: #071719; outline: none; }
.page { padding: 34px 42px 60px; max-width: 1500px; margin: 0 auto; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 38px; }
.metrics article { position: relative; min-height: 132px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(135deg, var(--panel), #09191b); }
.metrics small { display: block; color: var(--muted); }
.metrics strong { display: block; margin: 10px 0 2px; font: 500 32px 'DM Mono', monospace; }
.metrics article > span:not(.live-label) { color: #668887; font-size: 11px; }
.live-label { position: absolute; top: 23px; right: 20px; color: var(--teal); font: 500 10px 'DM Mono', monospace; letter-spacing: .1em; }
.section-heading, .card-title { display: flex; justify-content: space-between; align-items: center; }
.section-heading { margin: 0 0 14px; }
h3 { margin: 0; font-size: 17px; }
.section-heading p, .card-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.ghost { padding: 10px 14px; color: #b4c9c7; background: transparent; border: 1px solid var(--line-light); border-radius: 8px; }
.ghost:hover { border-color: #4e7a79; color: white; }
.ghost.compact { padding: 7px 10px; }
button:disabled { cursor: not-allowed; opacity: .42; }
.list-actions { display: flex; align-items: center; gap: 8px; }
.selection-count { margin-right: 4px; color: #617d7c; font: 10px 'DM Mono', monospace; text-transform: uppercase; }
.selection-count.active { color: var(--orange); }

.table-shell { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; color: #719392; background: #09191b; text-align: left; font: 500 10px 'DM Mono', monospace; text-transform: uppercase; letter-spacing: .1em; }
td { height: 72px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #102a2c; }
tbody tr:has(.selection-check:checked) { background: #153032; }
.selection-cell { width: 46px; padding-left: 16px; padding-right: 6px; }
.selection-check { width: 15px; height: 15px; margin: 0; padding: 0; accent-color: var(--orange); cursor: pointer; }
.target-cell strong, .target-cell small, .task-cell strong, .task-cell small { display: block; }
.target-cell strong { max-width: 290px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: 'DM Mono', monospace; font-size: 12px; }
.target-cell small, .task-cell small { color: var(--muted); margin-top: 5px; }
.task-cell strong { font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 20px; background: #173032; color: #aac3c1; font: 500 10px 'DM Mono', monospace; text-transform: uppercase; }
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.running, .badge.completed { color: var(--teal); background: #103b39; }
.badge.paused, .badge.queued { color: var(--amber); background: #332a17; }
.badge.failed, .badge.canceled { color: var(--red); background: #351d1b; }
.badge.missing { color: var(--orange); background: #351d1b; }
.mini-progress { min-width: 110px; }
.mini-progress span { font: 11px 'DM Mono', monospace; }
.mini-progress div { height: 3px; margin-top: 8px; background: #234143; border-radius: 3px; }
.mini-progress i { display: block; height: 100%; background: var(--orange); border-radius: 3px; }
.empty { padding: 70px 20px; text-align: center; }
.empty .radar { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 18px; border: 1px solid #39706f; border-radius: 50%; color: var(--orange); font-size: 27px; }
.empty p { color: var(--muted); }

.form-grid { display: grid; grid-template-columns: minmax(0, 760px) minmax(250px, 320px); gap: 20px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.task-form { padding: 26px; }
.step { display: flex; gap: 16px; align-items: flex-start; }
.step > span { color: var(--orange); font: 500 11px 'DM Mono', monospace; padding-top: 4px; }
.step p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.field-hint { margin: -10px 0 16px; font-size: 11px; }
.divider { height: 1px; background: var(--line); margin: 28px 0; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.task-types { display: grid; gap: 10px; margin-top: 18px; }
.task-type { position: relative; display: flex; align-items: center; gap: 14px; margin: 0; padding: 15px; border: 1px solid var(--line-light); border-radius: 9px; cursor: pointer; }
.task-type:has(input:checked) { border-color: var(--orange); background: #123032; box-shadow: 0 0 0 1px var(--orange); }
.task-type input { position: absolute; opacity: 0; }
.task-type > span { color: var(--orange); font-size: 20px; }
.task-type strong, .task-type small { display: block; }
.task-type small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.choice-card { position: relative; display: block; margin: 0; padding: 15px; border: 1px solid var(--line-light); border-radius: 9px; cursor: pointer; }
.choice-card:has(input:checked) { border-color: var(--orange); background: #123032; box-shadow: 0 0 0 1px var(--orange); }
.choice-card input { position: absolute; opacity: 0; }
.choice-card strong, .choice-card small { display: block; }
.choice-card strong { font-size: 12px; }
.choice-card small { min-height: 44px; margin: 7px 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.choice-card em { color: var(--teal); font: normal 9px 'DM Mono', monospace; text-transform: uppercase; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.queue-warning { margin: 18px 0 4px; padding: 13px 14px; border: 1px solid #65502c; border-radius: 8px; background: #272114; color: var(--amber); font-size: 12px; line-height: 1.5; }

.back { margin-bottom: 25px; padding: 0; color: var(--muted); background: none; }
.detail-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px) auto; align-items: center; gap: 26px; }
.detail-top h3 { max-width: 800px; margin: 4px 0 12px; font: 500 19px 'DM Mono', monospace; word-break: break-word; }
.task-kind { margin-right: 8px; color: var(--orange); font: 500 10px 'DM Mono', monospace; text-transform: uppercase; }
.actions { display: flex; gap: 8px; }
.danger { color: var(--red); border-color: #683b38; }
.detail-progress { min-width: 220px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #091b1d; }
.detail-progress > div:first-child { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.detail-progress strong { color: var(--text); font-family: 'DM Mono', monospace; }
.progress-track { height: 6px; margin-top: 12px; background: #234143; border-radius: 6px; overflow: hidden; }
.progress-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), var(--orange)); border-radius: 6px; transition: width .4s; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .7fr); gap: 16px; margin-top: 16px; }
.terminal-card, .facts, .downloads, .results-card { padding: 20px; }
.terminal-card { display: flex; contain: size; min-height: 470px; flex-direction: column; }
.terminal-card pre { flex: 1; height: 0; min-height: 390px; margin: 16px -20px -20px; padding: 20px; overflow: auto; background: #041012; border-radius: 0 0 var(--radius) var(--radius); color: #9ee0da; font: 11px/1.65 'DM Mono', monospace; white-space: pre-wrap; word-break: break-all; }
.streaming { color: var(--muted); font: 9px 'DM Mono', monospace; text-transform: uppercase; }
.streaming i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 5px var(--teal); }
.facts { margin-bottom: 16px; }
dl { margin: 15px 0 0; }
dl > div { display: flex; justify-content: space-between; gap: 15px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 11px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-family: 'DM Mono', monospace; word-break: break-word; }
.downloads a { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 0; border-top: 1px solid var(--line); color: #b9cecc; font-size: 12px; text-decoration: none; cursor: pointer; }
.downloads a:first-of-type { margin-top: 14px; }
.downloads a:hover { color: var(--orange); }
.downloads a.unavailable { color: #5f7776; pointer-events: none; }
.artifact-action { padding: 6px 9px; border: 1px solid var(--line-light); border-radius: 6px; color: var(--teal); font: 500 9px 'DM Mono', monospace; text-transform: uppercase; }
.downloads a:hover .artifact-action { border-color: var(--orange); color: var(--orange); }
.downloads a.unavailable .artifact-action { color: #5f7776; }
.results-card { margin-top: 22px; }
.results-heading { display: flex; align-items: center; gap: 10px; }
.result-state { padding: 4px 7px; border-radius: 20px; background: #332a17; color: var(--amber); font: 500 9px 'DM Mono', monospace; text-transform: uppercase; }
.results-empty { display: grid; min-height: 100px; place-items: center; margin-top: 16px; border: 1px dashed var(--line-light); border-radius: 8px; color: var(--muted); font: 11px 'DM Mono', monospace; text-transform: uppercase; }
.results-empty.pending { color: var(--amber); }
.results-card #results { max-height: 520px; overflow: auto; padding-right: 4px; }
.host-result { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.host-head { padding: 12px 14px; background: #091b1d; font: 11px 'DM Mono', monospace; }
.port-row { display: grid; grid-template-columns: 100px 90px 1fr; padding: 10px 14px; border-top: 1px solid var(--line); color: #aac2c0; font-size: 11px; }
.port-row span:first-child { color: var(--orange); font-family: 'DM Mono', monospace; }
#toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 16px; border: 1px solid var(--line-light); border-radius: 8px; background: #123032; color: var(--text); font-size: 12px; box-shadow: 0 12px 30px #0008; transform: translateY(120px); opacity: 0; transition: .25s; }
#toast.show { transform: translateY(0); opacity: 1; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.admin-card { padding: 24px; }
.admin-card > .muted { margin: 6px 0 20px; font-size: 12px; }
.admin-card .primary { min-width: 150px; }
.invite-result { margin-top: 18px; padding: 14px; border: 1px solid #33706d; border-radius: 8px; background: #103130; }
.invite-result small, .invite-result code { display: block; }
.invite-result small { color: var(--orange); font: 9px 'DM Mono', monospace; text-transform: uppercase; letter-spacing: .08em; }
.invite-result code { margin: 10px 0; padding: 10px; overflow-wrap: anywhere; border-radius: 6px; background: #061719; color: #bdf7f1; font: 11px/1.5 'DM Mono', monospace; }
.users-heading { margin-top: 32px; }
.account-heading { margin-top: 32px; }
.user-log-table { overflow-x: auto; }
.user-log-table table { min-width: 650px; }
.user-log-table tbody tr { cursor: default; }
.user-log-table code { display: block; max-width: 280px; overflow-wrap: anywhere; color: var(--teal); font-size: 10px; }
.audit-hint { margin: 12px 0 20px; }
#admin-page > .table-shell, #workers-page > .table-shell { margin-bottom: 20px; }
.profile-card { max-width: 650px; }
#profile-page > .card + .card { margin-top: 20px; }
.panel-stack { display: flex; flex-direction: column; gap: 20px; }
.panel-stack > .card { flex-shrink: 0; min-width: 0; }
.form-success { color: var(--teal); font-size: 13px; }
#user-details { width: min(1050px, calc(100vw - 36px)); max-height: calc(100dvh - 36px); box-sizing: border-box; padding: 24px; overflow: auto; border: 1px solid var(--line-light); border-radius: var(--radius); background: var(--bg); color: var(--text); }
#user-details::backdrop { background: #020b0dcc; }
#user-details .table-shell { overflow-x: auto; }
#user-details table { min-width: 900px; }
#user-details .list-actions { margin-top: 16px; flex-wrap: wrap; }
#user-details .login-history-list { max-height: 240px; }
#user-details-facts { margin-top: 0; }
#user-details-facts dd { overflow-wrap: anywhere; }
#password-history { max-height: 240px; overflow-y: auto; }
.password-history-entry { padding: 10px 0; border-bottom: 1px solid var(--line); font: 12px 'DM Mono', monospace; }
.password-history-entry > div { margin-top: 8px; color: var(--muted); overflow-wrap: anywhere; }
.password-history-entry code { color: var(--teal); }
.session-uuid { min-width: 225px; overflow-wrap: anywhere; }
#session-list td small { display: block; margin-top: 6px; color: var(--muted); }
.dialog-heading { gap: 16px; }
.invitation-panel summary { display: flex; justify-content: space-between; padding: 20px 24px; cursor: pointer; color: var(--orange); font-weight: 600; }
.invitation-panel summary span { color: var(--teal); }
.invitation-panel .admin-card { border-top: 1px solid var(--line); }
.invitation-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 600px; }
.recycle-config { padding: 24px; }
.recycle-config .muted { margin: 8px 0 20px; max-width: 850px; line-height: 1.6; }
.recycle-controls { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.recycle-controls input[type=number] { max-width: 150px; }
.checkbox-label { display: flex; align-items: center; gap: 10px; }
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--teal); }
.config-card { display: grid; grid-template-columns: minmax(0, 1fr) 180px auto; gap: 24px; align-items: end; padding: 24px; }
.config-copy > .muted { max-width: 680px; margin: 6px 0 0; font-size: 12px; line-height: 1.55; }
.config-card label { margin: 0; }
.config-card .primary { min-height: 43px; }
.worker-table { overflow-x: auto; background: var(--bg); }
.status-dot.offline { background: var(--muted); box-shadow: none; }
.worker-table table { min-width: 1100px; border-collapse: separate; border-spacing: 0 8px; }
.worker-table tbody tr { cursor: default; }
.worker-table tbody td { background: var(--panel); border-bottom: 1px solid var(--line); }
.worker-table tbody tr:hover td { background: var(--panel-2); }
.worker-table tbody td:first-child { border-left: 1px solid var(--line); border-radius: 8px 0 0 8px; }
.worker-table tbody td:last-child { border-right: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.worker-table td small { display: block; margin-top: 6px; color: var(--muted); }
#worker-credentials-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.login-history summary { cursor: pointer; white-space: nowrap; color: var(--teal); }
.login-history-list { max-height: 240px; min-width: 190px; overflow-y: auto; margin-top: 10px; }
.login-history-entry { padding: 8px 0; border-bottom: 1px solid var(--line); }
.login-history-entry small { display: block; margin-top: 4px; }
.users-heading + .table-shell { overflow-x: auto; }
.users-heading + .table-shell table { min-width: 930px; }
.retention-note { margin-bottom: 16px; padding: 13px 15px; border: 1px solid #65502c; border-radius: 8px; background: #272114; color: var(--amber); font-size: 12px; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.deleted-table { overflow-x: auto; }
.deleted-table table { min-width: 900px; }
.deleted-table tbody tr { cursor: default; }

@media (max-width: 920px) {
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 12px 18px; }
  .logo { padding: 0; margin-right: auto; }
  nav { display: flex; }
  .sidebar-bottom { margin: 0 0 0 8px; display: flex; }
  .nav-item { width: auto; }
  .nav-item span { width: auto; }
  .scope-note { display: none; }
  main { margin-left: 0; }
  .form-grid, .detail-grid, .admin-grid, .config-card { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 650px) {
  header, .page { padding-left: 18px; padding-right: 18px; }
  header { height: 78px; }
  .sidebar { overflow-x: auto; }
  .logo strong, .nav-item span { display: none; }
  .metrics, .choice-grid, .invitation-fields { grid-template-columns: 1fr; }
  .metrics article { min-height: 100px; }
  .table-shell { overflow-x: auto; }
  table { min-width: 760px; }
  .detail-top { display: block; }
  .detail-progress { margin-top: 18px; }
  .actions { margin-top: 18px; }
  .login-panel { padding: 28px; }
}
