:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --border: #d0d7de;
  --line: #e7ebef;
  --text: #1f2328;
  --muted: #59636e;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --warn-soft: #fff8c5;
  --error: #cf222e;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 15px; margin: 0 0 12px; }
p { margin: 0; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.warn-text { color: var(--warn); }
.prewrap { white-space: pre-wrap; }
.stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stack-lg { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.empty { color: var(--muted); padding: 12px 0; }
.loading { color: var(--muted); padding: 32px 0; }
.footnote { padding-bottom: 24px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 6px 12px; border-radius: 6px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tabs a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--accent-soft); color: var(--accent); }
.tabs.sub { border-bottom: 1px solid var(--border); gap: 0; }
.tabs.sub a { border-radius: 0; padding: 8px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs.sub a.active { background: none; border-bottom-color: var(--accent); color: var(--text); }
.account { margin-left: auto; display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.who { color: var(--muted); }

.page { max-width: 1440px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.title-row { display: flex; align-items: baseline; gap: 12px; }

/* Buttons and inputs */
.button, .primary, .small-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; padding: 7px 14px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.button:hover, .primary:hover { text-decoration: none; filter: brightness(1.08); }
.button.secondary, .small-button { background: var(--surface); color: var(--text); border-color: var(--border); }
.small-button { padding: 3px 10px; font-size: 12px; }
button:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
input[type=search], input:not([type]), input[type=password], input[type=number], input[type=time], textarea { border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; background: var(--surface); width: 100%; }
textarea { resize: vertical; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); flex-shrink: 0; }
.segmented button { border: 0; background: none; padding: 5px 12px; cursor: pointer; color: var(--muted); }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 320px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
button.stat { cursor: pointer; }
button.stat:hover { border-color: var(--accent); }
.stat strong { font-size: 22px; font-weight: 600; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; }

/* Panels and tables */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel .table-wrap { border: 0; border-radius: 0; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr[tabindex] { cursor: pointer; }
.grid tbody tr[tabindex]:hover { background: #f6f8fa; }
.grid th.num { text-align: right; }

.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--border); }
.dot.on { background: var(--ok); }
.dot.off { background: #8c959f; }
.dot.never { background: transparent; border: 1px solid #8c959f; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.chip.warn { background: var(--warn-soft); border-color: #d4a72c; color: var(--warn); }
.chip.info { background: var(--accent-soft); border-color: #a5d6ff; color: var(--accent); }
.chip.ok { background: #dafbe1; border-color: #82e596; color: var(--ok); }

.bar { display: block; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-fill.warn { background: #d4a72c; }

.cards { display: none; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: var(--text); }
.card:hover { text-decoration: none; border-color: var(--accent); }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
dl.mini { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 13px; }
dl.mini dt { color: var(--muted); }
dl.mini dd { margin: 0; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.events li:last-child { border-bottom: 0; }
.events li .muted { margin-left: auto; }
.event-kind { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex-shrink: 0; align-self: center; }
.event-kind.online { background: var(--ok); }
.event-kind.offline { background: #8c959f; }
.event-kind.version { background: var(--accent); }
.event-kind.registered { background: #8250df; }

/* Computer detail */
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
dl.facts { display: grid; grid-template-columns: 150px 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.meters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.meter { display: flex; flex-direction: column; gap: 4px; }
.meter strong { font-size: 20px; font-weight: 600; }
.chart { margin: 0; }
.chart svg { width: 100%; height: 160px; display: block; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; }
.chart .line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart .line.cpu { stroke: var(--accent); }
.chart .line.memory { stroke: #8250df; }
.chart .grid-line { stroke: var(--line); vector-effect: non-scaling-stroke; }
.chart .offline-band { fill: #eaeef2; }
.legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 12px; margin-top: 6px; }
.key::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--border); }
.key.cpu::before, .key.use::before { background: var(--accent); }
.key.memory::before { background: #8250df; }
.key.offline::before { background: #eaeef2; border: 1px solid var(--border); }
.key.online::before { background: #b6e3ff; }
.drives { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.drive-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }

.day-bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; align-items: end; height: 180px; }
.day-bar { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.day-bar .small { white-space: nowrap; font-size: 11px; }
.day-stack { position: relative; flex: 1; width: 100%; max-width: 36px; }
.day-stack span { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 3px 3px 0 0; }
.day-stack .online { background: #b6e3ff; }
.day-stack .use { background: var(--accent); left: 20%; right: 20%; }
ol.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
ol.bars li { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 70px; gap: 12px; align-items: center; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.suggestions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.suggestions li { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }

/* Usage heat map */
table.usage td.heat { --heat: 0; background: rgba(9, 105, 218, calc(var(--heat) * .35)); font-size: 12px; }
table.usage .day-col { font-size: 11px; }

/* Files */
.crumbs { margin: 10px 0; display: flex; flex-wrap: wrap; gap: 2px; align-items: baseline; }
table.files td:first-child { word-break: break-word; }
.icon-folder, .icon-file { display: inline-block; width: 14px; height: 11px; margin-right: 8px; border-radius: 2px; vertical-align: -1px; }
.icon-folder { background: #54aeff; }
.icon-file { width: 10px; height: 13px; border: 1px solid #8c959f; background: var(--surface); }
.file-detail { margin-top: 12px; border: 1px solid var(--border); border-radius: 6px; padding: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; }

.dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; width: min(520px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(31, 35, 40, .4); }
.dialog form { display: flex; flex-direction: column; gap: 10px; }
.dialog label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.dialog label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

details.runs { margin-top: 16px; }
details.runs .table-wrap { margin-top: 8px; }

/* People */
.invite { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.invite label, .dialog label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.invite .row, .dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select { border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; background: var(--surface); }
input[type=email] { border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; background: var(--surface); width: 100%; }
.picks { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; }
.picks legend { color: var(--muted); font-size: 12px; font-weight: 500; padding: 0 4px; }
label.check { flex-direction: row !important; align-items: center; gap: 6px !important; color: var(--text) !important; font-size: 13px !important; font-weight: 400 !important; }
details summary { cursor: pointer; color: var(--accent); }
details .picks { margin-top: 8px; border: 0; padding: 0; flex-direction: column; }
.link-box { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.row-inline { display: flex; gap: 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 8px; }
.login-card label { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 6px; }
.login-card .primary { margin-top: 12px; padding: 9px; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { color: var(--muted); font-size: 13px; }
.builder-sign-in { padding: 10px; font-size: 15px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 10px 0 2px; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.login-card .primary.secondary-look { background: var(--surface); color: var(--text); border-color: var(--border); }
.form-error { color: var(--error); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--text); color: #fff; border-radius: 6px; padding: 10px 14px; font-size: 13px; }
.toast.error { background: var(--error); }

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

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px 12px; }
  .topbar .tabs { order: 3; width: 100%; }
  .who { display: none; }
  .page { padding: 16px 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:last-child { grid-column: span 2; }
  .computers-table { display: none; }
  .cards { display: flex; flex-direction: column; gap: 10px; }
  .toolbar input[type=search] { max-width: none; }
  dl.facts { grid-template-columns: 1fr; gap: 0; }
  dl.facts dd { margin-bottom: 8px; }
  .meters { grid-template-columns: 1fr 1fr; }
  ol.bars li { grid-template-columns: 110px 1fr 56px; gap: 8px; }
  .dialog .row, .invite .row { grid-template-columns: 1fr; }
  .day-bars { gap: 2px; }
  .day-bar .small { display: none; }
  .tabs.sub { flex-wrap: wrap; border-bottom: 0; gap: 4px; }
  .tabs.sub a { border: 1px solid var(--border); border-radius: 6px; margin: 0; padding: 4px 10px; }
  .tabs.sub a.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
}
