@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary:        #DC4A2E;
  --primary-light:  #FEF2F0;
  --primary-dark:   #A83520;
  --bg:             #FAFAFA;
  --bg-warm:        #FBF9F7;
  --bg-card:        #FFFFFF;
  --bg-surface:     #F5F5F4;
  --text:           #1C1917;
  --text-secondary: #57534E;
  --text-muted:     #78716C;
  --text-light:     #A8A29E;
  --border:         #E7E5E4;
  --success:        #16A34A;
  --success-bg:     #F0FDF4;
  --warning:        #EA580C;
  --warning-bg:     #FFF7ED;
  --danger:         #DC2626;
  --danger-bg:      #FEF2F2;
  --info:           #2563EB;
  --info-bg:        #EFF6FF;
  --font:           'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius:         8px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --nav-h:          56px;
  --tab-h:          64px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06);
  --shadow:         0 4px 12px rgba(0,0,0,0.07);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
}

/* ── TOP NAV ──────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(250,250,250,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}

.nav-logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.nav-logo-icon svg { width: 18px; height: 18px; }

.nav-logo-text {
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.3px;
}
.nav-logo-text b { font-weight: 800; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-bg);
}

.nav-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ── SCROLL CONTAINER ─────────────────────────────── */
.page-wrap {
  padding-top: var(--nav-h);
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ── TAB VIEWS ────────────────────────────────────── */
.tab-view {
  display: none;
  padding: 20px 16px 8px;
  animation: fadeIn 0.18s ease;
}
.tab-view.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── BOTTOM TAB BAR ───────────────────────────────── */
.bottom-tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(250,250,250,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 100;
  display: flex;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.tab-btn svg {
  width: 22px; height: 22px;
  stroke: var(--text-light);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.15s;
}

.tab-btn span {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-light);
  transition: color 0.15s;
}

.tab-btn.active svg { stroke: var(--primary); }
.tab-btn.active span { color: var(--primary); }

.tab-badge {
  position: absolute;
  top: 4px; right: calc(50% - 18px);
  width: 16px; height: 16px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.tab-badge.hidden { display: none; }

/* ── SECTION HEADERS ──────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-light);
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* ── CARDS ────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 12px;
}

.card-row {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-row:last-child { border-bottom: none; }

.card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.card-icon svg { width: 18px; height: 18px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.card-body { flex: 1; min-width: 0; }
.card-label { font-size: 13px; font-weight: 600; color: var(--text); }
.card-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── STATUS PILLS ─────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill.ok   { background: var(--success-bg); color: var(--success); }
.pill.ok .pill-dot { background: var(--success); }
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.warn .pill-dot { background: var(--warning); }
.pill.err  { background: var(--danger-bg);  color: var(--danger); }
.pill.err .pill-dot  { background: var(--danger); }
.pill.idle { background: var(--bg-surface); color: var(--text-muted); }
.pill.idle .pill-dot { background: var(--text-light); }

/* ── METRIC CARDS ─────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-card.accent {
  background: var(--primary);
  border-color: var(--primary);
}
.metric-card.accent .metric-value { color: white; }
.metric-card.accent .metric-label { color: rgba(255,255,255,0.75); }

/* ── BUTTONS ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

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

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #FECACA; }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid #BBF7D0; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ── PIPELINE STEPS ───────────────────────────────── */
.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 16px 0;
  overflow-x: auto;
  padding: 0 2px 8px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 52px;
  position: relative;
}

.step::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step:last-child::after { display: none; }
.step.done::after { background: var(--success); }
.step.running::after { background: linear-gradient(90deg, var(--success), var(--border)); }

.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
  position: relative;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.step.done .step-dot { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.step.running .step-dot { background: var(--warning-bg); border-color: var(--warning); animation: pulse 1s infinite; }
.step.fail .step-dot { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234,88,12,0.3); }
  50% { box-shadow: 0 0 0 5px rgba(234,88,12,0); }
}

.step-label { font-size: 10px; font-weight: 500; color: var(--text-muted); text-align: center; line-height: 1.3; }
.step.done .step-label,
.step.running .step-label { color: var(--text-secondary); }

/* ── LOG BLOCK ────────────────────────────────────── */
.log-block {
  background: #1C1917;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: #D4D0CA;
  margin-top: 8px;
  overflow-x: auto;
  max-height: 180px;
  overflow-y: auto;
}
.log-line-ok   { color: #86EFAC; }
.log-line-err  { color: #FCA5A5; }
.log-line-warn { color: #FCD34D; }
.log-line-dim  { color: #78716C; }

/* ── COLLAPSIBLE ──────────────────────────────────── */
.collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid var(--border);
}
.collapse-header:last-child { border-bottom: none; }
.collapse-header .chevron {
  width: 16px; height: 16px;
  stroke: var(--text-light);
  fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.2s;
}
.collapse-header.open .chevron { transform: rotate(180deg); }
.collapse-body { padding: 12px 16px; display: none; }
.collapse-body.open { display: block; }

/* ── TEXTFIELD ────────────────────────────────────── */
.field-wrap { margin-bottom: 12px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; display: block; }
.field-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.field-input:focus { border-color: var(--primary); }
textarea.field-input { resize: vertical; min-height: 80px; line-height: 1.6; }

/* ── DEPLOY TARGETS ───────────────────────────────── */
.deploy-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.deploy-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.deploy-card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.deploy-card-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.file-list { font-size: 12px; color: var(--text-secondary); }
.file-list-item { padding: 4px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; }
.file-list-item:last-child { border-bottom: none; }
.file-tag { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.file-tag.mod { background: var(--info-bg); color: var(--info); }
.file-tag.new { background: var(--success-bg); color: var(--success); }
.file-tag.del { background: var(--danger-bg); color: var(--danger); }

/* ── EMPTY STATE ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; stroke: var(--text-light); fill: none; stroke-width: 1.5; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── TOAST ────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px);
  left: 16px; right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: white;
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s;
  pointer-events: all;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: #15803D; }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ── DEMO BANNER ──────────────────────────────────── */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  padding: 9px 13px;
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 600;
  color: #92400E;
}
.demo-banner svg {
  width: 14px; height: 14px;
  flex-shrink: 0;
  stroke: #D97706;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}
.demo-banner span { flex: 1; }
