:root {
  --accent: #2457d6;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --bg: #f5f6f8;
  --panel: #ffffff;
  --sidebar: #0f1729;
  --sidebar-text: #c6cede;
  --text: #182033;
  --muted: #627089;
  --line: #e2e6ee;
  --ok: #16833a;
  --warn: #b26b00;
  --bad: #c62828;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1220; --panel: #151c2e; --sidebar: #080c17; --text: #e6eaf2; --muted: #93a0b8; --line: #263049;
    --ok: #4cc777; --warn: #f0a937; --bad: #ff6b6b; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.offscreen { position: fixed; left: -9999px; top: 0; }

/* Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand img, .brand svg { width: 28px; height: 28px; border-radius: 7px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--sidebar-text); }
.nav a:hover { background: rgb(255 255 255 / 6%); text-decoration: none; }
.nav a.active { background: rgb(255 255 255 / 10%); color: #fff; }
.nav svg { width: 18px; height: 18px; opacity: .85; }
.sidebar .me { margin-top: auto; padding: 10px; font-size: 12px; border-top: 1px solid rgb(255 255 255 / 8%); }
.sidebar .me button { margin-top: 8px; }
.main { padding: 26px 32px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* Panels and tiles */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel.pad { padding: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { padding: 16px 18px; }
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 6px; }
.tile .value.bad { color: var(--bad); }
.tile .value.ok { color: var(--ok); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: color-mix(in srgb, var(--bg) 60%, var(--panel)); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.narrow, td.narrow { width: 1%; padding-right: 0; }
td .sub { color: var(--muted); font-size: 12px; }
.name-cell { display: flex; align-items: center; gap: 10px; }
.name-cell svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.name-cell .folder { color: #d8a31a; }
.clickable { cursor: pointer; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* Badges */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.pill.partial, .pill.running, .pill.queued { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.failed, .pill.error, .pill.suspended { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }

/* Forms */
button, .button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
button:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.small, .button.small { padding: 4px 9px; font-size: 12px; }
.button:hover { text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
.sidebar button { background: transparent; color: var(--sidebar-text); border-color: rgb(255 255 255 / 15%); }
input, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
label.field { display: grid; gap: 6px; font-weight: 550; }
label.field span.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.form { display: grid; gap: 14px; max-width: 460px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.switch { position: relative; width: 36px; height: 20px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

/* Sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 30% 20%, var(--accent-soft), transparent 60%), var(--bg); }
.login .panel { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { color: var(--text); padding: 0 0 18px; font-size: 18px; }
.login .form { max-width: none; }

/* Messages, dialogs and the side panel */
.error { color: var(--bad); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--panel); padding: 11px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgb(0 0 0 / 20%); z-index: 50; max-width: 420px; }
.toast.bad { background: var(--bad); color: #fff; }
.dialog-bg { position: fixed; inset: 0; background: rgb(8 12 24 / 45%); display: grid; place-items: center; z-index: 40; padding: 20px; }
.dialog { width: 100%; max-width: 480px; padding: 22px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgb(0 0 0 / 12%); z-index: 30; display: flex; flex-direction: column; }
.drawer header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer .body { overflow-y: auto; flex: 1; }
.list-item { padding: 12px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.device-code { display: grid; gap: 10px; padding: 14px; margin: 12px 0; border-radius: 8px; background: var(--accent-soft); }
.code-big { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 26px; font-weight: 700; letter-spacing: .12em; }
.dialog .actions .grow { margin-right: auto; align-self: center; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 4px 10px; }
  .nav { display: flex; flex-wrap: wrap; }
  .sidebar .me { margin: 0 0 0 auto; border: 0; }
  .main { padding: 18px 16px 40px; }
}
