:root {
  --bg: #0c0e10;
  --surface: #131619;
  --surface-2: #191d21;
  --surface-3: #1f2429;
  --border: #262b31;
  --border-strong: #333a41;
  --text: #e7eaed;
  --text-2: #a6aeb6;
  --muted: #6d767f;
  --accent: #dfa440;
  --accent-ink: #1b1204;
  --ok: #82ab7c;
  --warn: #dfa440;
  --err: #d07a69;
  --run: #7fa7c4;
  --radius-ctl: 8px;
  --radius-card: 12px;
  --radius-panel: 14px;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: #fff; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.dim { color: var(--text-2); }

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

/* sidebar */
.side {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand-mark {
  width: 22px; height: 22px; border: 1px solid var(--border-strong); border-radius: 6px;
  display: grid; place-items: center; color: var(--accent);
}
.brand-name { font-weight: 500; letter-spacing: .01em; }
.brand-sub { color: var(--muted); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  color: var(--muted); font-size: 11px; padding: 0 8px; margin: 16px 0 6px;
}
.nav-label:first-child { margin-top: 0; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px;
  border-radius: 7px; color: var(--text-2); position: relative;
}
.nav a svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-3); color: var(--text); }
.nav a.active::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 2px;
  background: var(--accent);
}
.nav a.active svg { color: var(--text); }
.nav .count { margin-left: auto; color: var(--muted); font: 11px var(--mono); }

.side-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 8px 0; color: var(--muted); font-size: 11px; }
.side-foot .row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

/* content */
.main { min-width: 0; }
.top {
  height: 56px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px;
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px); z-index: 5;
}
.crumb { display: flex; align-items: center; gap: 10px; color: var(--muted); min-width: 0; }
.crumb strong, .crumb a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb strong { color: var(--text); font-weight: 500; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.content { padding: 28px; max-width: 1440px; }
.content.narrow { max-width: 960px; }

h1 { font-size: 22px; line-height: 1.25; font-weight: 500; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 500; margin: 0; }
h3 { font-size: 12px; font-weight: 500; margin: 0; color: var(--text-2); }
p { margin: 0; }
.lede { color: var(--text-2); max-width: 620px; margin-top: 6px; }

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

/* controls */
.btn, .icon-btn {
  white-space: nowrap;
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-ctl);
  height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover, .icon-btn:hover { background: var(--surface-3); border-color: #3d454d; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--text); color: #101315; border-color: var(--text); font-weight: 500; }
.btn.primary:hover { background: #fff; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { width: 28px; height: 28px; padding: 0; justify-content: center; color: var(--text-2); }
.icon-btn svg { width: 15px; height: 15px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.input, .textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctl); font: 13px/1.5 var(--sans); padding: 8px 10px;
}
.textarea { font-family: var(--mono); font-size: 12px; min-height: 88px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--text-2); }
.hint { color: var(--muted); font-size: 11px; }

/* custom select */
.select { position: relative; min-width: 200px; }
.select-btn {
  width: 100%; height: 32px; padding: 0 10px; display: flex; align-items: center; gap: 8px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctl); font: inherit; cursor: pointer; text-align: left;
}
.select-btn .val { flex: 1; }
.select-btn svg { width: 14px; height: 14px; color: var(--muted); transition: transform .12s ease; }
.select[data-open] .select-btn svg { transform: rotate(180deg); }
.select-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 4px; max-height: 260px; overflow: auto;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
}
.select[data-open] .select-menu { opacity: 1; transform: none; pointer-events: auto; }
.select-opt {
  width: 100%; display: flex; flex-direction: column; gap: 1px; padding: 7px 9px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.select-opt .sub { color: var(--muted); font: 11px var(--mono); }
.select-opt:hover, .select-opt[aria-selected="true"] { background: var(--surface-3); }
.select-opt .tick { margin-left: auto; color: var(--accent); }

/* dropzone */
.drop {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-card);
  background: var(--surface); padding: 28px; display: grid; place-items: center; gap: 8px;
  text-align: center; cursor: pointer; transition: border-color .12s ease, background-color .12s ease;
}
.drop:hover, .drop.hot { border-color: var(--accent); background: var(--surface-2); }
.drop svg { width: 22px; height: 22px; color: var(--muted); }
.drop .prompt { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop strong { font-weight: 500; }
.drop .file { display: none; align-items: center; gap: 8px; color: var(--text); font: 12px var(--mono); }
.drop.has .file { display: flex; }
.drop.has .prompt { display: none; }
.drop .bar { height: 2px; width: 100%; background: var(--surface-3); border-radius: 2px; overflow: hidden; display: none; }
.drop.busy .bar { display: block; }
.drop .bar i { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* status */
.led { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.led.ok { background: var(--ok); }
.led.warn { background: var(--warn); }
.led.err { background: var(--err); }
.led.run { background: var(--run); }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); white-space: nowrap; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.run { color: var(--run); }
.status.warn { color: var(--warn); }

/* surfaces */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-panel); }
.panel-pad { padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > .btn { align-self: flex-start; }
.row { display: flex; align-items: center; gap: 10px; }

/* stats */
.stats { display: grid; grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 11px; }
.stat .v { font: 500 26px/1.2 var(--mono); margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat .d { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* tables */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0 12px; height: 40px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 500; height: 32px; background: var(--surface); }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .1s ease; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td .sub { color: var(--muted); font-size: 11px; }

.empty { padding: 28px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }

/* device head */
.dev-head { padding: 20px; min-width: 0; display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.signal { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-2); font: 11px var(--mono); }
.rail { display: flex; gap: 2px; align-items: flex-end; height: 14px; }
.rail i { width: 3px; background: var(--border-strong); border-radius: 1px; }
.rail i.on { background: var(--accent); }
.dev-head .mono { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border-top: 1px solid var(--border); }
.meta div { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.meta div { padding: 10px 14px; min-width: 0; }
.meta .k { color: var(--muted); font-size: 11px; }
.meta .v { margin-top: 2px; font: 12px var(--mono); overflow: hidden; text-overflow: ellipsis; }

/* console */
.console { background: #0a0c0e; border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px; max-height: 520px; overflow: auto; }
.console .line { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; }
.console .stream { color: var(--muted); font: 11px var(--mono); text-align: right; padding-top: 2px; }
.console pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.6 var(--mono); color: var(--text-2); }
.console .err pre { color: var(--err); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font: 11px var(--mono); color: var(--text-2); }
.badge .led { width: 5px; height: 5px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; padding: 28px; }
.login-card .brand { padding: 0; margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 16px; }
.login-meta { margin-top: 14px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

/* toast */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 12px; font-size: 12px; }

@media (max-width: 1000px) {
  .shell { display: block; min-width: 0; }
  .side { position: static; height: auto; width: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; gap: 14px; }
  .nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .nav-label, .nav .count, .side-foot { display: none; }
  .nav a { height: 34px; }
  .nav a.active::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 2px; }
  .split { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 14px; }
  .stat .v { font-size: 22px; }
  .meta { grid-template-columns: 1fr 1fr; }
  .content { padding: 20px 16px; }
  .top { padding: 0 16px; }
  th { position: static; padding: 0 8px; }
  td { padding: 0 8px; }
  .t-mini th:nth-child(3), .t-mini td:nth-child(3),
  .t-devices th:nth-child(3), .t-devices td:nth-child(3),
  .t-devices th:nth-child(4), .t-devices td:nth-child(4),
  .t-builds th:nth-child(2), .t-builds td:nth-child(2),
  .t-builds th:nth-child(3), .t-builds td:nth-child(3),
  .t-passwords th:nth-child(3), .t-passwords td:nth-child(3),
  .t-passwords th:nth-child(4), .t-passwords td:nth-child(4),
  .t-tasks th:nth-child(2), .t-tasks td:nth-child(2),
  .t-device-tasks th:nth-child(4), .t-device-tasks td:nth-child(4) { display: none; }
}
