:root {
  --bg: #0b0e14;
  --panel: #11151f;
  --panel-border: #232838;
  --text: #e8eaf0;
  --text-dim: #8b93a7;
  --accent-blue: #6d8bf5;
  --accent-green: #4ade80;
  --accent-purple: #b18df5;
  --accent-amber: #f5b942;
  --accent-red: #f56d6d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a {
  color: inherit;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.sidebar h1 {
  font-size: 1.1rem;
  margin: 0 0 24px;
}

.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 500;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: rgba(109, 139, 245, 0.15);
  color: var(--text);
}

.main {
  flex: 1;
  padding: 24px 32px 48px;
  max-width: 1400px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.provider-toggle {
  display: flex;
  gap: 8px;
}

.provider-toggle a {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  text-decoration: none;
  color: var(--text-dim);
  font-weight: 600;
}

.provider-toggle a.active {
  background: var(--accent-blue);
  color: #08101f;
  border-color: var(--accent-blue);
}

h2.hero {
  font-size: 1.8rem;
  margin: 8px 0 24px;
}

.hero-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.hero-row h2.hero {
  margin: 8px 0;
}

.refresh-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.refresh-btn {
  margin-top: 0;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
}

.refresh-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent-blue);
}

.refresh-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.refresh-progress {
  width: 70px;
  height: 4px;
  border-radius: 2px;
  background: var(--panel-border);
  overflow: hidden;
}

.refresh-progress-bar {
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--accent-blue);
  animation: refresh-progress-slide 1.1s ease-in-out infinite;
}

@keyframes refresh-progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(280%);
  }
}

.refresh-countdown {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.tile-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-top: 3px solid var(--accent-blue);
  border-radius: 10px;
  padding: 16px 18px;
}

.tile.green {
  border-top-color: var(--accent-green);
}

.tile.purple {
  border-top-color: var(--accent-purple);
}

.tile.amber {
  border-top-color: var(--accent-amber);
}

.tile .label {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

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

.content-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 20px;
}

.panel h3 {
  margin-top: 0;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.machine-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.machine-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--panel-border);
}

.machine-list li:last-child {
  border-bottom: none;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--text-dim);
}

.status-dot.unknown {
  background: var(--accent-amber);
}

.status-dot.ok {
  background: var(--accent-green);
}

.status-dot.bad {
  background: var(--accent-red);
}

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

.fleet-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.fleet-table th,
.fleet-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--panel-border);
  font-size: 0.85rem;
}

.fleet-table th {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.fleet-table tbody tr:hover {
  background: rgba(109, 139, 245, 0.06);
}

.panel-hint {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin: -8px 0 14px;
}

.form-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 24px;
  max-width: 520px;
}

.form-hint {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 4px 0 4px;
}

.machine-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--panel-border);
}

.machine-row:last-child {
  border-bottom: none;
}

.machine-name {
  font-weight: 600;
}

.machine-id {
  color: var(--text-dim);
  font-weight: 400;
}

.machine-sub {
  color: var(--text-dim);
  font-size: 0.76rem;
  margin-top: 4px;
  word-break: break-all;
}

.machine-sub > div {
  line-height: 1.3;
}

.machine-sub code {
  font-size: 0.76rem;
}

.machine-head {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 4px;
}

.machine-head span:last-child {
  width: 190px;
  flex-shrink: 0;
}

.machine-rename {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.machine-agent-row {
  flex-wrap: wrap;
  padding-top: 0;
}

.form-card .machine-rename input[type="text"] {
  margin-top: 0;
  width: 190px;
}

/* Wide enough for a full Cloudflare Tunnel hostname (e.g.
   https://dps22.collectivecompute.io) without truncating — needs the extra class
   selector to out-specificity the 190px rule above, since both apply here. */
.form-card .machine-rename input.agent-url-input[type="text"] {
  width: 320px;
}

.form-card .machine-rename button {
  margin-top: 0;
}

.form-card label {
  display: block;
  margin-top: 16px;
  margin-bottom: 4px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.form-card input[type="text"],
.form-card input[type="password"],
.form-card input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
}

.form-card .errors {
  color: var(--accent-red);
  font-size: 0.8rem;
  margin-top: 4px;
}

button, input[type="submit"] {
  margin-top: 20px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent-blue);
  color: #08101f;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.machine-delete {
  margin-left: auto;
}

.flash {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.flash.success {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent-green);
}

.flash.error {
  background: rgba(245, 109, 109, 0.15);
  color: var(--accent-red);
}

#alert-banner {
  position: fixed;
  top: 16px;
  right: 16px;
  max-width: 360px;
  z-index: 100;
}

#alert-banner .alert-item {
  background: var(--panel);
  border: 1px solid var(--accent-red);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

#alert-banner .alert-item button {
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
