/* Artifact platform tokens — auto-resolved */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
code, pre {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text);
}
.muted { color: var(--text-muted); }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--neutral);
  padding: 1.25rem 2rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand h1 { color: var(--text); }
.brand-sub {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
  font-family: var(--font-mono);
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--primary-tint);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-meta {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
}
.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font-sans);
  transition: color 0.15s;
}
.tab:hover { color: var(--text); }
.tab-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  background: var(--surface-2);
  color: var(--text);
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  border-color: var(--neutral);
}
.btn-ghost:hover:not(:disabled) { background: var(--primary-tint); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--primary-tint); }
.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ---------- Overview ---------- */
.overview {
  display: grid;
  gap: 1.5rem;
}
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: center;
}
.hero-text h2 { margin-bottom: 0.5rem; }
.hero-text .muted { max-width: 56ch; margin-bottom: 1.25rem; }
.hero-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1.5rem;
}
.hero-meta > div { display: flex; flex-direction: column; gap: 2px; }
.meta-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hero-meta code {
  background: var(--primary-tint);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--primary-dark);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero-action { text-align: right; }
.hero-action .hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.pill {
  background: var(--primary-tint);
  color: var(--primary-dark);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.phases {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.phase {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}
.phase-marker {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
}
.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.4;
}
.phase-spin {
  width: 14px;
  height: 14px;
  border: 2px solid var(--primary-tint);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.phase-pending { color: var(--text-muted); }
.phase-active { color: var(--text); font-weight: 500; }
.phase-done { color: var(--text); }
.phase-done .phase-marker { color: var(--success); }
.phase-failed { color: var(--danger); }

.endpoint {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--primary-tint);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.endpoint-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.endpoint code { color: var(--primary-dark); font-weight: 500; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.25rem;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 600;
}
.stat-sm { font-size: 1rem; font-family: var(--font-mono); }

/* ---------- Deployments ---------- */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.filters {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--neutral);
}
.filter {
  background: transparent;
  border: none;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  text-transform: capitalize;
}
.filter:hover { color: var(--text); }
.filter-active {
  background: var(--primary-tint);
  color: var(--primary-dark);
  font-weight: 500;
}

.deploy-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.deploy-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
}
.deploy-main { flex: 1; min-width: 0; }
.deploy-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.badge {
  color: white;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sha {
  background: var(--primary-tint);
  color: var(--primary-dark);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}
.deploy-branch {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: var(--font-mono);
}
.deploy-msg {
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deploy-meta {
  display: flex;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.deploy-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.empty {
  text-align: center;
  padding: 3rem 2rem;
}
.empty h3 { margin-bottom: 0.5rem; }

/* ---------- Logs ---------- */
.log-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.log-viewport {
  background: var(--bg);
  padding: 1rem;
  max-height: 540px;
  overflow-y: auto;
  font-family: var(--font-mono);
}
.log-empty { text-align: center; padding: 2rem; }
.log-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.3rem;
}
.log-row {
  display: grid;
  grid-template-columns: 80px 70px 1fr;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  align-items: baseline;
}
.log-row:hover { background: var(--surface); }
.log-ts { color: var(--text-muted); font-size: 0.75rem; }
.log-level {
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  text-align: center;
}
.log-level-info { background: var(--primary-tint); color: var(--primary-dark); }
.log-level-success { background: var(--primary-tint); color: var(--success); }
.log-level-warning { background: var(--primary-tint); color: var(--warning); }
.log-level-error { background: var(--primary-tint); color: var(--danger); }
.log-msg { color: var(--text); word-break: break-word; }

/* ---------- Config ---------- */
.config-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.config-form fieldset {
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem 1.5rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.config-form legend {
  padding: 0 0.5rem;
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 0.9rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.field > span {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="number"],
.field textarea {
  background: var(--bg);
  border: 1px solid var(--neutral);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  transition: border-color 0.15s;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.field textarea { resize: vertical; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
}
.field-check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.field-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.field-check > span { color: var(--text); }

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}
.saved-chip {
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 500;
}

.dockerfile {
  margin-top: 1.5rem;
}
.dockerfile h3 { margin-bottom: 0.75rem; }
.dockerfile pre {
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
}

@media (max-width: 760px) {
  .main { padding: 1rem; }
  .header { padding: 1rem 1rem 0; }
  .hero { grid-template-columns: 1fr; }
  .hero-action { text-align: left; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero-meta { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 60px 60px 1fr; }
  .deploy-item { flex-direction: column; align-items: stretch; }
}
