* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0f1316;
  color: #d7dde4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 32px;
  background: #242a31;
  border: 1px solid #37414b;
  color: #e7edf3;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

button:hover:not(:disabled) { background: #303942; }
button:disabled { color: #69727d; cursor: not-allowed; }

input,
textarea {
  width: 100%;
  background: #0b0f12;
  border: 1px solid #37414b;
  border-radius: 6px;
  color: #d7dde4;
  padding: 7px 9px;
}

textarea {
  min-height: 240px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

::placeholder { color: #69727d; }

.app-shell { min-height: 100vh; }

.banner {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 10px 20px;
  font-size: 14px;
}

.banner.error { background: #b92f2f; color: #fff; }
.banner.info { background: #173d35; color: #d9fff5; border-bottom: 1px solid #286e5e; }

.topbar {
  background: #171c21;
  border-bottom: 1px solid #303943;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

h1 {
  margin: 0;
  color: #f4f7fa;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0;
  white-space: nowrap;
}

.page-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.page-nav a {
  color: #a9b4bf;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}

.page-nav a:hover,
.page-nav a.active {
  color: #f4f7fa;
  background: #26313a;
}

.topbar-actions,
.button-row,
.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions { flex-wrap: wrap; justify-content: flex-end; }

.topbar-auth-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.topbar-auth-state.on { background: #153b32; color: #61d394; }

.topbar-auth-state.off { background: #27303a; color: #a9b4bf; }

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #a9b4bf;
  font-size: 13px;
  white-space: nowrap;
}

.check-row input { width: auto; }

.page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
}

.single-column { grid-template-columns: minmax(0, 1fr); }
.dashboard-grid { grid-template-columns: minmax(300px, 0.7fr) minmax(380px, 1.3fr); }
.jobs-grid { grid-template-columns: minmax(420px, 1.1fr) minmax(360px, 0.9fr); align-items: start; }
.create-grid,
.admin-grid { grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr); }
.wide-panel { grid-column: 1 / -1; }
.events-panel { grid-column: 2; }

.panel {
  background: #171c21;
  border: 1px solid #303943;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h2 {
  margin: 0;
  color: #9faab5;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h3 {
  margin: 12px 0 6px;
  color: #e7edf3;
  font-size: 13px;
  font-weight: 650;
}

.muted,
.hint {
  color: #9aa5af;
  font-size: 13px;
}

.hint { margin: 0 0 8px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid #303943;
  border-radius: 8px;
  padding: 10px;
  background: #11161a;
}

.metric span { display: block; color: #9aa5af; font-size: 12px; }
.metric strong { display: block; margin-top: 4px; color: #f4f7fa; font-size: 20px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  color: #9aa5af;
  font-weight: 600;
  font-size: 12px;
  padding: 7px 8px;
  border-bottom: 1px solid #303943;
}

td {
  padding: 7px 8px;
  border-bottom: 1px solid #252d35;
  vertical-align: top;
}

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #1e2830; }
.selected-row { background: #213747; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.pending { background: #27303a; color: #a9b4bf; }
.leased,
.busy { background: #17364b; color: #7fc7ff; }
.running,
.succeeded { background: #153b32; color: #61d394; }
.failed,
.offline { background: #421f22; color: #ff8d8d; }
.stale { background: #42351b; color: #e4bd5d; }
.removed { background: #202326; color: #737c85; }
.unknown { background: #27303a; color: #a9b4bf; }

.stat-row { margin: 5px 0; font-size: 13px; }
.stat-label { display: inline-block; min-width: 110px; color: #9aa5af; }
.caps { color: #9aa5af; font-size: 12px; }

.detail-stack { display: grid; gap: 10px; }
.detail-label { width: 120px; color: #9aa5af; }

pre {
  margin: 0;
  background: #0b0f12;
  border: 1px solid #303943;
  border-radius: 6px;
  color: #d7dde4;
  padding: 10px;
  overflow-x: auto;
  font-size: 12px;
}

.error-msg { color: #ff8d8d; }
.artifact { margin: 4px 0; font-size: 13px; }
.artifact code { color: #7fc7ff; word-break: break-all; }

.events-list {
  max-height: 520px;
  overflow: auto;
}

.event-row {
  padding: 8px 0;
  border-bottom: 1px solid #252d35;
  font-size: 13px;
}

.event-time { color: #9aa5af; font-size: 11px; margin-right: 8px; }
.event-type { color: #7fc7ff; font-weight: 700; }
.event-payload { margin-top: 6px; padding: 8px; font-size: 11px; }

.field-row input { flex: 1; }
.footer-actions { margin-top: 10px; justify-content: flex-end; }

.auth-only-shell { min-height: 100vh; }

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

.auth-card {
  width: min(420px, 100%);
  background: #171c21;
  border: 1px solid #303943;
  border-radius: 8px;
  padding: 22px;
}

.auth-title {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.auth-title h1 {
  white-space: normal;
}

.auth-title h2 {
  text-transform: none;
  color: #9aa5af;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: #9aa5af;
  font-size: 13px;
}

.auth-form .footer-actions { justify-content: stretch; }
.auth-form button[type="submit"] { width: 100%; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: 1fr; }
  .topbar-actions { justify-content: flex-start; }
  .dashboard-grid,
  .jobs-grid,
  .create-grid,
  .admin-grid { grid-template-columns: 1fr; }
  .events-panel { grid-column: auto; }
}

@media (max-width: 720px) {
  .topbar { padding: 12px; }
  .brand-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .page-grid { padding: 12px; gap: 12px; }
  .topbar-actions,
  .field-row,
  .stacked-mobile { width: 100%; flex-direction: column; align-items: stretch; }
  .topbar-auth-state { justify-content: center; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  h1 { white-space: normal; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

