* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--tg-theme-bg-color, #fff);
  color: var(--tg-theme-text-color, #000);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.screen { display: none; }
.screen.active { display: block; }

.container {
  padding: 16px 20px;
  max-width: 480px;
  margin: 0 auto;
}

.center {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  opacity: 0.5;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--tg-theme-hint-color, #999);
  margin-bottom: 20px;
  font-size: 14px;
}

/* Cards */
.card {
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.info-card p { margin-bottom: 8px; font-size: 14px; }
.info-card ol { margin-left: 20px; font-size: 14px; }
.info-card ol li { margin-bottom: 4px; }
.info-card code {
  background: var(--tg-theme-bg-color, #fff);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Agent card */
.agent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.agent-card:active { opacity: 0.7; }

.agent-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-running { background: #34C759; }
.status-stopped { background: #FF3B30; }
.status-pending { background: #FF9500; }
.status-creating { background: #007AFF; animation: pulse 1.5s infinite; }
.status-error { background: #FF3B30; }
.status-destroyed { background: #8E8E93; }

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

.agent-info { flex: 1; min-width: 0; }
.agent-name { font-weight: 600; font-size: 16px; }
.agent-bot {
  font-size: 13px;
  color: var(--tg-theme-hint-color, #999);
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--tg-theme-bg-color, #fff);
}
.icon-btn:active { opacity: 0.6; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  text-align: center;
}

.btn-primary {
  background: var(--tg-theme-button-color, #007AFF);
  color: var(--tg-theme-button-text-color, #fff);
}
.btn-primary:active { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.btn-secondary {
  background: transparent;
  color: var(--tg-theme-link-color, #007AFF);
}

.btn-danger {
  background: #FF3B30;
  color: #fff;
}

.btn-small {
  display: inline-block;
  width: auto;
  padding: 8px 16px;
  font-size: 14px;
  margin: 4px;
}

/* Fields */
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-theme-hint-color, #999);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 6px;
}

.field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--tg-theme-hint-color, #ccc);
  border-radius: 10px;
  font-size: 16px;
  background: var(--tg-theme-secondary-bg-color, #f5f5f5);
  color: var(--tg-theme-text-color, #000);
  outline: none;
}
.field:focus { border-color: var(--tg-theme-button-color, #007AFF); }

.field-hint {
  font-size: 12px;
  color: var(--tg-theme-hint-color, #999);
  margin-top: 4px;
  min-height: 18px;
}

.field-hint.error { color: #FF3B30; }
.field-hint.success { color: #34C759; }

/* Progress */
.progress-bar {
  height: 6px;
  background: var(--tg-theme-secondary-bg-color, #eee);
  border-radius: 3px;
  margin: 16px 0;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: var(--tg-theme-button-color, #007AFF);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s;
}

.step { padding: 4px 0; font-size: 14px; }
.step-ok::before { content: '✓ '; color: #34C759; }
.step-err::before { content: '✗ '; color: #FF3B30; }
.step-info::before { content: '● '; color: #007AFF; }
.step-warn::before { content: '! '; color: #FF9500; }

/* Detail */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--tg-theme-secondary-bg-color, #eee);
}
.detail-label { color: var(--tg-theme-hint-color, #999); }
.detail-value { font-weight: 500; text-align: right; }

/* Confirm dialog */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}
.dialog {
  background: var(--tg-theme-bg-color, #fff);
  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px;
}
.dialog h2 { font-size: 18px; margin-bottom: 12px; }
.dialog p { font-size: 14px; margin-bottom: 16px; color: var(--tg-theme-hint-color, #999); }

.radio-group { margin-bottom: 16px; }
.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  font-size: 14px;
}
.radio-option input { accent-color: var(--tg-theme-button-color, #007AFF); }
