* {
  box-sizing: border-box;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0a0;
  --accent: #e94560;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;
  --border: #374151;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.header {
  background: var(--bg-secondary);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 2rem;
  gap: 1.5rem;
  min-height: 0;
  overflow: hidden;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1rem;
}

.service-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--border);
}

.service-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.service-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.service-name h3 {
  margin: 0;
  font-size: 1.1rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.running { background: var(--success); }
.status-dot.stopped { background: var(--text-secondary); }
.status-dot.failed { background: var(--error); }
.status-dot.starting { background: var(--warning); }
.status-dot.stopping { background: var(--warning); }
.status-dot.retrying { background: var(--warning); }
.status-dot.gave_up { background: var(--error); }
.status-dot.pending { background: var(--text-secondary); }

.service-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.service-status.running { color: var(--success); }
.service-status.healthy { color: var(--success); }
.service-status.unhealthy { color: var(--error); }
.service-status.waiting { color: var(--warning); }

.service-details {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.service-details code {
  background: var(--bg-secondary);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.8rem;
}

.service-url {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

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

.service-url a:hover {
  text-decoration: underline;
}

.service-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-secondary {
  background: var(--border);
  color: var(--text-primary);
}

.btn-success {
  background: var(--success);
  color: #1a1a2e;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.logs-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  min-height: 200px;
  overflow: hidden;
}

.logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logs-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.logs-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.logs-controls select {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.logs-controls input[type="text"] {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  width: 150px;
}

.logs-controls label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.logs-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line .timestamp {
  color: var(--text-secondary);
}

.log-line .service {
  color: #60a5fa;
}

.log-line.stderr .content {
  color: var(--error);
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.error {
  padding: 1rem;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--error);
  border-radius: 4px;
  color: var(--error);
}
