/* One hand-written sheet, no framework. Dark by default because this is an ops console that
   mostly gets opened at night, with a light scheme for anyone whose system asks for it. */

:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --panel-2: #23272f;
  --line: #313742;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #6ea8fe;
  --ok: #4ec98a;
  --warn: #e5b567;
  --bad: #ef6f6c;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-2: #f0f2f5;
    --line: #d9dde4;
    --text: #1b1f27;
    --muted: #5f6979;
    --accent: #1d64d8;
    --ok: #1a8a55;
    --warn: #9a6a12;
    --bad: #c0392f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.centred {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

a { color: var(--accent); }

/* --- chrome ------------------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .7rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 650; text-decoration: none; color: var(--text); }

.topbar nav { display: flex; gap: .3rem; flex-wrap: wrap; flex: 1; }

.topbar nav a {
  padding: .35rem .7rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--muted);
}
.topbar nav a:hover { background: var(--panel-2); color: var(--text); }
.topbar nav a.on { background: var(--accent); color: #fff; }

.logout { margin: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }

h1 { font-size: 1.5rem; margin: .3rem 0 1.2rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }

/* --- surfaces ---------------------------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.stat { font-size: 1.7rem; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.error { color: var(--bad); }
.right { text-align: right; }

/* --- tables ------------------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; }

/* --- controls ---------------------------------------------------------------------------- */

button, .btn {
  font: inherit;
  padding: .45rem .9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: default; }

button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.danger { background: var(--bad); }
button.small { padding: .25rem .6rem; font-size: .85rem; }

label { display: block; font-size: .88rem; color: var(--muted); margin: .7rem 0 .25rem; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: .45rem .6rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}
input[type="checkbox"] { width: auto; }
textarea { min-height: 6rem; font-family: ui-monospace, Consolas, monospace; }

.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; }
.row > .shrink { flex: 0 0 auto; }

.inline { display: flex; gap: .5rem; align-items: center; }
.inline label { margin: 0; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
legend { color: var(--muted); font-size: .88rem; padding: 0 .4rem; }

/* --- status ------------------------------------------------------------------------------ */

.pill {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok   { background: color-mix(in srgb, var(--ok) 22%, transparent);   color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.pill.bad  { background: color-mix(in srgb, var(--bad) 22%, transparent);  color: var(--bad); }

.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.notice {
  border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  padding: .6rem .8rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .9rem;
  margin: .8rem 0;
}

.code-block {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .85rem;
}

.pairing-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 2.6rem;
  letter-spacing: .35em;
  text-align: center;
  padding: .6rem 0;
}

/* --- toast ------------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  z-index: 50;
  max-width: min(90vw, 34rem);
}
.toast.bad { border-color: var(--bad); color: var(--bad); }

/* --- login ------------------------------------------------------------------------------- */

.login { width: min(24rem, 100%); }
.login h1 { margin-top: 0; }
.login button { width: 100%; margin-top: 1rem; }
