:root {
  --fg: #1d2327;
  --muted: #5f6b73;
  --bg: #f6f7f5;
  --card: #ffffff;
  --line: #dde2dc;
  --accent: #3f6f4f;
  --accent-fg: #ffffff;
  --warn: #9a5b00;
  --danger: #b3261e;
  --ok: #3f8f5f;
  --low: #c98a00;
  --critical: #b3261e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.app { max-width: 64rem; margin: 0 auto; padding: 0 1rem 3rem; }
main.narrow { max-width: 28rem; }

nav.top { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
nav.top > a { font-weight: 600; text-decoration: none; color: var(--fg); }
.who { color: var(--muted); font-size: 0.9rem; }

header.page { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: baseline; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); margin-bottom: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 0.5rem; padding: 1rem; }
section.card { margin-bottom: 1rem; }
ul.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }

.badge { display: inline-block; font-size: 0.8rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: #e8ece6; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.warn { color: var(--warn); }

button { font: inherit; padding: 0.4rem 0.9rem; border-radius: 0.375rem; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg); cursor: pointer; }
a.button { display: inline-block; padding: 0.4rem 0.9rem; border-radius: 0.375rem; background: var(--accent); color: var(--accent-fg); text-decoration: none; }
.notice { padding: 0.6rem 1rem; border-radius: 0.375rem; background: #eef3f8; }
.notice.warn { background: #fdf3e1; }
button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

form { display: grid; gap: 0.5rem; }
input { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 0.375rem; }

.banner { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 1rem; border-radius: 0.375rem; margin-bottom: 1rem; }
.banner.error { background: #fbeae8; color: var(--danger); }
.banner.paused { display: block; background: #fdf3dc; }
.banner.paused p { margin: 0.25rem 0; }

.meter .bar { height: 0.6rem; background: #e8ece6; border-radius: 999px; overflow: hidden; margin-bottom: 0.75rem; }
.meter .used { height: 100%; background: var(--ok); }
.meter.band-low .used { background: var(--low); }
.meter.band-critical .used, .meter.band-empty .used { background: var(--critical); }
.figures { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0 0 0.5rem; }
.figures dt { font-size: 0.8rem; color: var(--muted); }
.figures dd { margin: 0; }
.figures dd.big { font-size: 1.4rem; font-weight: 600; }
.rate { margin: 0.25rem 0; }

table.gpus { width: 100%; border-collapse: collapse; }
table.gpus th, table.gpus td { text-align: left; padding: 0.45rem 0.5rem 0.45rem 0; border-top: 1px solid var(--line); vertical-align: middle; }
table.gpus thead th { border-top: none; font-size: 0.8rem; color: var(--muted); font-weight: 500; }

.machine header { display: flex; justify-content: space-between; align-items: center; }
.machine p { margin: 0.25rem 0; }
.machine progress { width: 12rem; vertical-align: middle; }
.state-running { border-left: 4px solid var(--ok); }
.state-starting, .state-saving, .state-stopping { border-left: 4px solid var(--low); }
.state-failed { border-left: 4px solid var(--danger); }

.demo { margin-top: 2rem; }
.demo ul { list-style: none; padding: 0; display: grid; gap: 0.5rem; }

@media (max-width: 40rem) {
  table.gpus thead { display: none; }
  table.gpus tr { display: grid; grid-template-columns: 1fr auto; padding: 0.5rem 0; border-top: 1px solid var(--line); }
  table.gpus th, table.gpus td { border: none; padding: 0.1rem 0; }
}

/* manager pages */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
input[type="search"] { width: 100%; max-width: 28rem; margin-bottom: 0.75rem; }
textarea { font: inherit; width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 0.375rem; }
input.money { width: 7rem; text-align: right; }
input.invalid { border-color: var(--danger); outline-color: var(--danger); }
table.members, table.machines, table.teams, table.projects, table.saves { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
table.members th, table.members td, table.machines th, table.machines td, table.teams th, table.teams td, table.projects th, table.projects td, table.saves th, table.saves td { text-align: left; padding: 0.35rem 0.5rem 0.35rem 0; border-top: 1px solid var(--line); vertical-align: middle; }
table.members thead th, table.machines thead th, table.teams thead th, table.projects thead th, table.saves thead th { border-top: none; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
table.members td.storage { white-space: nowrap; }
table.members thead button.link { color: var(--muted); text-decoration: none; font-weight: 500; }
table.members th[aria-sort="ascending"] button::after { content: " ▲"; }
table.members th[aria-sort="descending"] button::after { content: " ▼"; }
tr.band-low td:nth-child(n) { background: #fdf6e8; }
tr.band-critical td:nth-child(n), tr.band-empty td:nth-child(n) { background: #fbeae8; }
button.link.danger { color: var(--danger); }
.bulk { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; padding: 0.6rem; background: #eef2ec; border-radius: 0.375rem; }
section.card label { display: block; margin-top: 0.5rem; font-size: 0.875rem; color: var(--muted); }
details.settings { margin-bottom: 1rem; }
details.settings summary { cursor: pointer; }
details.settings summary h2 { display: inline; }
details.settings fieldset { border: 1px solid var(--line); border-radius: 0.375rem; margin: 1rem 0; padding: 0.5rem 1rem 1rem; }
details.settings label { display: block; margin-top: 0.5rem; font-size: 0.875rem; color: var(--muted); }
details.settings textarea { width: 100%; font-family: ui-monospace, monospace; }
@media (max-width: 40rem) { table.members, table.saves { display: block; overflow-x: auto; } }
.saves-areas { display: grid; gap: 1rem; }
.save-with-name { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
td.nowrap { white-space: nowrap; }

/* terminal */
section.terminal { margin-top: 0.75rem; border: 1px solid var(--line); border-radius: 0.375rem; overflow: hidden; background: #1e1e1e; }
section.terminal header { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0.6rem; background: #f0f2ee; }
section.terminal header .actions { margin: 0 0 0 auto; }
section.terminal .screen { height: 22rem; padding: 0.25rem; }
