/* simpliCD dashboard.
 *
 * An operator console: dense, quiet, and legible at a glance on a phone at
 * 2am. Monochrome by default — colour is reserved for status, so if
 * something is red it is broken and nothing else is red. Chrome, buttons,
 * links and headings are all foreground-on-background, which is what makes
 * a single red dot readable across the page.
 *
 * No framework, no build step, and no webfont. The whole stylesheet ships
 * inside the Python package, which is the point: `pip install simplicd`
 * gets you a working dashboard with no Node in the picture, and no request
 * to a font CDN from a box that may have no outbound access at all.
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f2f2f2;
  --border: #eaeaea;
  --border-strong: #d4d4d4;
  --text: #000000;
  --text-dim: #666666;
  --text-faint: #8f8f8f;

  /* The "accent" is the foreground. A solid black button against white is
   * the whole visual system; a coloured one would compete with status. */
  --accent: #000000;
  --accent-fg: #ffffff;
  --accent-hover: #383838;

  --ok: #067a3d;
  --ok-bg: #eaf6ee;
  --warn: #8a5700;
  --warn-bg: #fdf3e2;
  --bad: #c62b1e;
  --bad-bg: #fdeceb;
  --idle: #8f8f8f;
  --idle-bg: #f2f2f2;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  /* As close to Geist as a machine can get without downloading anything. */
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #0a0a0a;
    --surface-2: #111111;
    --surface-3: #1a1a1a;
    --border: #262626;
    --border-strong: #3d3d3d;
    --text: #ededed;
    --text-dim: #a1a1a1;
    --text-faint: #707070;

    --accent: #ededed;
    --accent-fg: #000000;
    --accent-hover: #ffffff;

    --ok: #3ecf74;
    --ok-bg: #0e2a19;
    --warn: #e0a13a;
    --warn-bg: #2b1f08;
    --bad: #ff6166;
    --bad-bg: #2c1214;
    --idle: #8f8f8f;
    --idle-bg: #1a1a1a;

    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

::selection { background: var(--text); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ------------------------------------------------------------- layout */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 15px;
}

/* The mark is inline SVG (templates/_logo.html), so it costs no request
 * and picks up `currentColor` — one asset for both themes. */
.mark { width: 20px; height: 20px; flex: none; }

/* The wordmark is one element so the flex gap separates it from the mark
 * and not from its own second half; `em` carries the weight change with
 * no styling hook of its own. */
.wordmark { white-space: nowrap; }
.wordmark em { font-style: normal; color: var(--text-faint); font-weight: 500; }

.topbar nav { display: flex; gap: 4px; margin-left: 4px; }
.topbar nav a {
  color: var(--text-dim);
  font-size: 13.5px;
  padding: 6px 10px;
  border-radius: var(--radius);
}
.topbar nav a:hover { color: var(--text); background: var(--surface-3); }
.topbar nav a[aria-current] { color: var(--text); background: var(--surface-3); }

.spacer { flex: 1; }

.whoami {
  color: var(--text-dim);
  font-size: 13px;
  padding-right: 4px;
}

main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 4px;
}

h2 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
  margin: 32px 0 12px;
}

.subtitle { color: var(--text-dim); margin: 0 0 24px; font-size: 14px; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

/* -------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card + .card { margin-top: 16px; }
.card-body { padding: 16px 18px; }

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

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}

td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.name-cell a { font-weight: 500; }
.name-cell a:hover { text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: 0; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

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

/* A dot and a word, with no tinted capsule behind it. On a page of
 * fifteen projects the capsules read as fifteen competing badges; the dot
 * is the only thing the eye needs, and it stays the only colour on the
 * row. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dim);
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  color: var(--idle);
}

.status-online::before { color: var(--ok); }
.status-crashed::before { color: var(--bad); }
.status-stopped::before { color: var(--warn); }
.status-notdeployed::before { color: var(--idle); }

/* A live process that disagrees with the version pointer: online, but
 * serving code nobody asked for. Worth shouting about, so this one keeps
 * its colour on the label too. */
.status-drift { color: var(--bad); font-weight: 500; }
.status-drift::before { color: var(--bad); }

/* ------------------------------------------------------------ buttons */

.btn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--text-faint); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-fg);
}

.btn-danger { color: var(--bad); border-color: var(--border-strong); }
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); border-color: var(--bad); }

.btn-block { width: 100%; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }

/* -------------------------------------------------------------- forms */

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--surface-3);
}

textarea {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  resize: vertical;
  min-height: 200px;
}

.field { margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--text-faint); margin-top: 6px; }

/* Reveal toggle. Sits inside the input's box rather than beside it, so
 * the field keeps its full width and the control cannot wrap away from
 * the thing it belongs to on a narrow screen. */
.field-control { position: relative; display: flex; }
.field-control input { padding-right: 42px; }

.reveal {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.reveal:hover { color: var(--text); background: var(--surface-3); }
.reveal-icon { width: 17px; height: 17px; }

/* The slash turns the "show" eye into a "hide" one, so the icon always
 * describes what the next click does. */
.reveal .slash { display: none; }
.reveal[aria-pressed="true"] .slash { display: block; }

/* -------------------------------------------------------------- auth */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  margin-bottom: 22px;
}
.auth-mark .mark { width: 22px; height: 22px; }

.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .subtitle { margin-bottom: 24px; }
.auth-card .btn { width: 100%; }

/* Identity providers. Each is a full-width secondary button; the local
 * form below it keeps the primary, because on a box with both configured
 * the password is still the one that works with no network. */
.providers { display: grid; gap: 8px; }
.btn-provider { height: 38px; font-size: 14px; }
.provider-mark { width: 16px; height: 16px; flex: none; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-faint);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ------------------------------------------------------------ notices */

.notice {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.notice-error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-bg); }
.notice-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bg); }
.notice-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-bg); }
.notice-info { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }
.notice code {
  font-family: var(--mono);
  font-size: 12.5px;
}

/* --------------------------------------------------------------- logs */

.log {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
  margin: 0;
  letter-spacing: 0;
}

.log:empty::before {
  content: "No output yet.";
  color: var(--text-faint);
  font-family: var(--sans);
}

/* --------------------------------------------------------------- meta */

.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 20px;
  font-size: 13.5px;
  align-items: baseline;
}

.meta dt { color: var(--text-dim); white-space: nowrap; }
.meta dd { margin: 0; word-break: break-word; }

.checks { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.pill-ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.pill-bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-dim);
}
.empty code {
  font-family: var(--mono);
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

.running-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: pulse 1.4s ease-in-out infinite;
  margin-right: 7px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .running-dot { animation: none; }
  * { transition: none !important; }
}

/* ------------------------------------------------------------- mobile */

@media (max-width: 640px) {
  main { padding: 20px 16px 56px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .whoami { display: none; }
  h1 { font-size: 21px; }

  /* The projects table becomes a stack of cards: a six-column table on a
   * 375px screen is unreadable, and this page has to work from a phone. */
  .stack-mobile thead { display: none; }
  .stack-mobile tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .stack-mobile td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border: none;
  }
  .stack-mobile td::before {
    content: attr(data-label);
    color: var(--text-faint);
    font-size: 12.5px;
  }
  .stack-mobile td:first-child { padding-bottom: 8px; font-size: 15px; }
  .stack-mobile td:first-child::before { content: none; }
}
