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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

header { margin-bottom: 24px; }

h1 { font-size: 2rem; color: #38bdf8; margin-bottom: 2px; }
.subtitle { color: #94a3b8; font-size: 0.9rem; }

/* ═══ 탭 ═══ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 0;
}
.tab {
  padding: 10px 24px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab:hover { color: #e2e8f0; }
.tab.active { color: #38bdf8; border-bottom-color: #38bdf8; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ═══ 위젯 ═══ */
.widget {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.widget h2 {
  font-size: 1rem;
  color: #94a3b8;
  margin-bottom: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ═══ 서버 상태 ═══ */
.server-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.server-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  transition: all 0.3s;
}
.server-card.online { border-color: #10b981; }
.server-card.offline { border-color: #ef4444; }

.svc-indicator {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #475569;
  margin: 0 auto 8px;
  transition: background 0.3s;
}
.server-card.online .svc-indicator { background: #10b981; box-shadow: 0 0 8px rgba(16,185,129,0.4); }
.server-card.offline .svc-indicator { background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.4); }

.svc-name { font-weight: 700; font-size: 0.85rem; color: #e2e8f0; margin-bottom: 2px; }
.svc-detail { font-size: 0.75rem; color: #64748b; }
.server-card.online .svc-detail { color: #34d399; }
.server-card.offline .svc-detail { color: #f87171; }

/* 리소스 바 */
.resource-bars { display: flex; flex-direction: column; gap: 10px; }
.resource-row { display: flex; align-items: center; gap: 10px; }
.resource-label { font-size: 0.8rem; color: #94a3b8; width: 48px; font-weight: 600; }
.resource-bar-wrap {
  flex: 1; height: 8px;
  background: #0f172a; border-radius: 4px; overflow: hidden;
}
.resource-bar {
  height: 100%; width: 0%;
  background: #38bdf8; border-radius: 4px;
  transition: width 0.5s;
}
.resource-bar.warn { background: #f59e0b; }
.resource-bar.danger { background: #ef4444; }
.resource-pct { font-size: 0.75rem; color: #94a3b8; min-width: 160px; text-align: right; }

/* ═══ API 사용량 ═══ */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.usage-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.usage-period { font-size: 0.8rem; color: #64748b; margin-bottom: 6px; font-weight: 600; }
.usage-tokens { font-size: 1.3rem; font-weight: 800; color: #e2e8f0; }
.usage-cost { font-size: 0.85rem; color: #38bdf8; margin-top: 4px; }
.usage-calls { font-size: 0.75rem; color: #64748b; margin-top: 2px; }

.budget-section { margin-top: 12px; }
.budget-bar-wrap {
  height: 10px; background: #0f172a;
  border-radius: 5px; overflow: hidden;
  margin-bottom: 8px;
}
.budget-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  border-radius: 5px; transition: width 0.5s;
}
.budget-bar.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.budget-bar.danger { background: linear-gradient(90deg, #ef4444, #f87171); }

.budget-info {
  display: flex; justify-content: space-between; align-items: center;
}
.budget-info span { font-size: 0.8rem; color: #94a3b8; }
.budget-btn {
  width: auto; padding: 5px 14px;
  background: #334155; color: #94a3b8;
  font-size: 0.75rem; font-weight: 600;
  border-radius: 6px;
}
.budget-btn:hover { background: #475569; color: #e2e8f0; }

.budget-warning {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(239,68,68,0.1);
  border: 1px solid #ef4444;
  color: #f87171;
}

/* ═══ 프로젝트 테이블 ═══ */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
thead th {
  text-align: left;
  padding: 8px 10px;
  color: #64748b;
  font-weight: 600;
  border-bottom: 1px solid #334155;
  font-size: 0.75rem;
  text-transform: uppercase;
}
tbody td {
  padding: 10px;
  border-bottom: 1px solid rgba(51,65,85,0.5);
  color: #cbd5e1;
}
tbody tr:hover { background: rgba(56,189,248,0.04); }

.proj-name { font-weight: 600; color: #e2e8f0; }
.empty-row { text-align: center; color: #64748b; padding: 24px !important; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge-ok { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-fail { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-run { background: rgba(59,130,246,0.15); color: #60a5fa; }

table a { color: #38bdf8; text-decoration: none; }
table a:hover { text-decoration: underline; }

/* ═══ 모달 ═══ */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  width: 340px;
}
.modal-content h3 { color: #e2e8f0; margin-bottom: 16px; font-size: 1rem; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-cancel {
  flex: 1; padding: 10px; background: #334155; color: #94a3b8;
  border-radius: 8px; font-weight: 600;
}
.modal-cancel:hover { background: #475569; }
.modal-save {
  flex: 1; padding: 10px; background: #2563eb; color: white;
  border-radius: 8px; font-weight: 600;
}
.modal-save:hover { background: #1d4ed8; }

/* ═══ 옵션 그룹 ═══ */
.option-group {
  margin-bottom: 18px;
  padding: 14px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
}
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 0.9rem; font-weight: 600; color: #cbd5e1;
}
.checkbox-label input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: #38bdf8; cursor: pointer;
}
.sub-option {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid #1e293b;
}
.sub-option label { font-size: 0.8rem; margin-bottom: 4px; }
.sub-option input { font-size: 0.85rem; padding: 8px 10px; }
.option-hint {
  font-size: 0.72rem; color: #64748b; margin-top: 4px;
}

/* ═══ 폼 (프로젝트 생성) ═══ */
.form-group { margin-bottom: 18px; }

label {
  display: block; margin-bottom: 6px;
  font-weight: 600; color: #cbd5e1; font-size: 0.9rem;
}

input, textarea {
  width: 100%; padding: 12px;
  border: 1px solid #334155; border-radius: 8px;
  background: #1e293b; color: #e2e8f0;
  font-size: 1rem; font-family: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus {
  outline: none; border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56,189,248,0.15);
}

button {
  width: 100%; padding: 14px;
  background: #2563eb; color: white; border: none;
  border-radius: 8px; font-size: 1.05rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
button:hover { background: #1d4ed8; }
button:disabled { background: #475569; cursor: not-allowed; }

.btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none; }

/* ═══ 파이프라인 ═══ */
.pipeline { margin-top: 28px; }
.pipeline h2 { color: #38bdf8; font-size: 1.1rem; margin-bottom: 14px; }

.progress-bar-wrap {
  position: relative; height: 28px;
  background: #1e293b; border-radius: 14px;
  margin-bottom: 20px; overflow: hidden; border: 1px solid #334155;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  border-radius: 14px; transition: width 0.5s ease;
}
.progress-text {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem; font-weight: 700; color: #e2e8f0;
}

.steps-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.step-card {
  background: #1e293b; border: 1px solid #334155;
  border-radius: 8px; padding: 14px 10px;
  text-align: center; transition: all 0.3s;
  position: relative; overflow: hidden;
}
.step-num { font-size: 1.4rem; font-weight: 800; color: #475569; margin-bottom: 6px; transition: color 0.3s; }
.step-label { font-size: 0.78rem; font-weight: 600; color: #94a3b8; margin-bottom: 6px; transition: color 0.3s; }
.step-status { font-size: 0.7rem; color: #64748b; transition: color 0.3s; }

.step-card.running { border-color: #3b82f6; box-shadow: 0 0 16px rgba(59,130,246,0.2); }
.step-card.running .step-num { color: #60a5fa; }
.step-card.running .step-label { color: #e2e8f0; }
.step-card.running .step-status { color: #60a5fa; }
.step-card.running::after {
  content: ''; position: absolute; bottom: 0; left: 0; height: 3px;
  background: #3b82f6; animation: progress-slide 1.5s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { width: 0%; left: 0; }
  50% { width: 60%; left: 20%; }
  100% { width: 0%; left: 100%; }
}

.step-card.done { border-color: #10b981; background: rgba(16,185,129,0.08); }
.step-card.done .step-num { color: #10b981; }
.step-card.done .step-label { color: #d1fae5; }
.step-card.done .step-status { color: #34d399; }

.step-card.failed { border-color: #ef4444; background: rgba(239,68,68,0.08); }
.step-card.failed .step-num { color: #ef4444; }
.step-card.failed .step-label { color: #fecaca; }
.step-card.failed .step-status { color: #f87171; }

.log-section { margin-top: 8px; }
.log-section h3 { font-size: 0.9rem; color: #94a3b8; margin-bottom: 8px; }

#log {
  background: #0f172a; border: 1px solid #1e293b;
  padding: 16px; border-radius: 8px;
  font-size: 0.8rem; font-family: 'SF Mono', 'Fira Code', monospace;
  max-height: 240px; overflow-y: auto;
  white-space: pre-wrap; color: #94a3b8; line-height: 1.6;
}

.result-section {
  margin-top: 20px; padding: 20px;
  background: rgba(16,185,129,0.1);
  border: 1px solid #10b981; border-radius: 8px;
}
.result-section h3 { color: #10b981; margin-bottom: 8px; }
.result-section a { color: #38bdf8; text-decoration: underline; }

/* ═══ 반응형 ═══ */
@media (max-width: 640px) {
  .server-grid { grid-template-columns: 1fr; }
  .usage-grid { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .step-card { padding: 10px 6px; }
  .step-num { font-size: 1.1rem; }
  .step-label { font-size: 0.7rem; }
  .resource-pct { min-width: 100px; font-size: 0.65rem; }
}
