/* machinator dashboard styles. No framework: a system font stack, a light and
   a dark palette picked by prefers-color-scheme, and the handful of patterns
   every page reuses — nav, tiles, tables, badges. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e3e5e9;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --muted-badge: #4b5563;
  --muted-badge-bg: #e5e7eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c1f26;
    --text: #e7e8ec;
    --muted: #9aa1ac;
    --border: #2c303a;
    --accent: #60a5fa;
    --ok: #4ade80;
    --ok-bg: #123a20;
    --warn: #fbbf24;
    --warn-bg: #3a2c0a;
    --bad: #f87171;
    --bad-bg: #3a1414;
    --muted-badge: #cbd0d8;
    --muted-badge-bg: #2a2e36;
  }
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav .brand {
  font-weight: 700;
  color: var(--text);
  margin-right: 0.5rem;
}

.nav a {
  color: var(--muted);
}

.nav a.active {
  color: var(--text);
  font-weight: 600;
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem;
}

footer {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
  font-size: 0.8rem;
}

h1, h2, h3 {
  margin: 0 0 0.75rem;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
}

.tile-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.tile-label {
  color: var(--muted);
  font-size: 0.8rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

td.empty {
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

/* The projects page nests projects, environments and applications rather
   than one flat table, so its own empty states sit in a <p>, not a <td>. */
.empty {
  color: var(--muted);
}

/* A small aside under a form -- the cloud page's own note that region, size
   and image are the provider's ids, not this page's. */
.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.badge.warn {
  color: var(--warn);
  background: var(--warn-bg);
}

.badge.bad {
  color: var(--bad);
  background: var(--bad-bg);
}

.badge.muted {
  color: var(--muted-badge);
  background: var(--muted-badge-bg);
}

.host-header dl.host-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0 0 1.5rem;
}

.host-info div {
  display: flex;
  flex-direction: column;
}

.host-info dt {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.host-info dd {
  margin: 0;
}

.charts {
  margin-bottom: 1.5rem;
}

.chart-range {
  margin-bottom: 0.75rem;
}

.range-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}

.range-btn:first-child {
  border-radius: 0.4rem 0 0 0.4rem;
}

.range-btn:last-child {
  border-radius: 0 0.4rem 0.4rem 0;
}

.range-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem;
}

.chart {
  width: 100%;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.filters input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.35rem 0.5rem;
  color: var(--text);
}

.filters button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 0.35rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-right form {
  display: flex;
  gap: 0.35rem;
}

.nav-right select,
.nav-right button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.25rem 0.5rem;
  color: var(--text);
  cursor: pointer;
}

.nav-right .who,
.nav-right .org-name {
  color: var(--muted);
  font-size: 0.85rem;
}

.signin {
  max-width: 22rem;
  margin: 4rem auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.signin form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.signin label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.signin input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.45rem 0.5rem;
  color: var(--text);
}

.signin button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 0.35rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

.error {
  color: var(--bad);
  font-size: 0.85rem;
}

.status-header {
  margin-bottom: 1.5rem;
}

.status-description {
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.status-overall {
  display: inline-block;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 0.4rem;
}

.status-overall.ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.status-overall.bad {
  color: var(--bad);
  background: var(--bad-bg);
}

.status-check {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.status-check-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.status-check-header h2 {
  margin: 0;
  font-size: 1rem;
}

.daybar {
  display: flex;
  gap: 2px;
  margin-bottom: 0.75rem;
  overflow-x: auto;
}

.day {
  flex: 1 0 4px;
  min-width: 4px;
  height: 1.75rem;
  border-radius: 2px;
}

.day.ok {
  background: var(--ok);
}

.day.warn {
  background: var(--warn);
}

.day.bad {
  background: var(--bad);
}

.day.unknown {
  background: var(--muted-badge-bg);
}

.status-check-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0;
}

.status-check-stats div {
  display: flex;
  flex-direction: column;
}

.status-check-stats dt {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.status-check-stats dd {
  margin: 0;
}

.banner {
  background: var(--surface);
  border: 1px solid var(--bad);
  border-radius: 0.35rem;
  padding: 0.6rem 0.8rem;
  margin: 0 0 1.25rem;
  color: var(--text);
  font-size: 0.9rem;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.6rem 0.8rem;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}

.billing form {
  display: inline;
}

.billing button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 0.35rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.statuspage-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 32rem;
  margin-bottom: 1.5rem;
}

.statuspage-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.statuspage-form input,
.statuspage-form textarea,
.statuspage-form select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.4rem 0.5rem;
  color: var(--text);
  font: inherit;
}

.statuspage-form button {
  align-self: flex-start;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 0.35rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}

.check-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  max-width: 32rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.4rem;
  cursor: grab;
}

.check-row.dragging {
  opacity: 0.5;
}

.check-handle {
  color: var(--muted);
}

.check-name {
  flex: 1;
}

.check-row button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 0.3rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.check-row button.remove {
  color: var(--bad);
}

.check-list li.empty {
  list-style: none;
  color: var(--muted);
  padding: 0.5rem 0;
}

.check-add {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.check-add select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.4rem 0.5rem;
  color: var(--text);
}

.check-add button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 0.35rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}

.statuspage-delete {
  margin-bottom: 1.5rem;
}

.statuspage-delete button {
  background: var(--bad-bg);
  border: 1px solid var(--bad);
  color: var(--bad);
  border-radius: 0.35rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}

/* The Approve and Reject buttons on a pending runbook run: two forms side by
   side rather than one under the other, which is the one layout nothing
   above already gives a pair of buttons. */
.runbook-run-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* A build log is the one place a page shows a host's own output verbatim:
   it scrolls in its own box rather than stretching the page to the width of
   the longest line docker printed. */
pre.log {
  max-height: 32rem;
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--muted-badge-bg);
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre;
}

/* A tail's own controls sit above the log it filters: a search box wide
   enough to hold a search, and the Stop that lets go of the stream. */
.tail-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.tail-controls input[type="search"] {
  min-width: 18rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
}

.tail-controls button {
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}

.tail-controls button:disabled {
  cursor: default;
  opacity: 0.6;
}

/* A tail fills more of the screen than a build log does: it is the whole of
   what its page is for. */
.tail-header {
  margin-bottom: 1rem;
}

#tail-log {
  max-height: 60vh;
}

/* A terminal is a tail with a way back: the same scrolling pane above, and one
   line of input below it. */
#terminal-output {
  max-height: 55vh;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.terminal-input input[type="text"] {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.terminal-input input[type="text"]:disabled {
  opacity: 0.6;
}

.terminal-input button,
.host-terminal button {
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
}

/* The one button on a host's header: it sits under the host's own details
   rather than beside the heading, so a narrow window does not have to choose
   between them. */
.host-terminal {
  margin-top: 0.75rem;
}
