* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  background: transparent; /* 회색 배경 제거 */
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  margin: 0;
  overflow: hidden;
}

.dialog-container {
  width: 500px;
  min-height: 600px;
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  position: relative;
}

/* iframe 모달 안에서 사용될 때 닫기 버튼 숨기기 */
body:has(+ *) .close-btn,
iframe .close-btn {
  display: none;
}

/* Header */
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.dialog-title {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.close-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.close-btn:hover {
  background: #f3f4f6;
  border-radius: 4px;
}

.close-icon {
  width: 24px;
  height: 24px;
  stroke: #6b7280;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Storage Selection */
.storage-section {
  margin-bottom: 16px;
}

.section-label {
  color: #374151;
  font-weight: 500;
  margin-bottom: 8px;
}

.storage-buttons {
  display: grid;
  grid-template-columns: 1fr 8px 1fr;
  gap: 0;
}

.storage-btn {
  height: 110px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.storage-btn:hover {
  border-color: #3b82f6;
}

.storage-btn.selected {
  border-color: #3b82f6;
  border-width: 2px;
}

.storage-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  object-fit: contain;
}

.storage-label {
  font-weight: 500;
  color: #111827;
}

/* Certificate Select Header */
.cert-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.cert-header-info {
  flex: 1;
}

.cert-header-label {
  font-weight: 500;
  color: #374151;
  margin-bottom: 2px;
}

.cert-path-text {
  font-size: 11px;
  color: #9ca3af;
}

.find-pfx-btn {
  padding: 6px 12px;
  height: 32px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 15px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  transition: all 0.2s;
}

.find-pfx-btn:hover {
  border-color: #3b82f6;
}

/* Certificate List */
.cert-list-container {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  height: 200px;
  margin-bottom: 16px;
}

.cert-list-header {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 8px;
  display: grid;
  grid-template-columns: 50px 1fr 100px 100px;
  gap: 0;
}

.cert-list-header-item {
  font-size: 13px;
  color: #6b7280;
}

.cert-list-header-item:nth-child(2) {
  padding-left: 8px;
}

.cert-list-header-item:nth-child(3),
.cert-list-header-item:nth-child(4) {
  text-align: center;
}

.cert-list {
  height: calc(200px - 44px);
  overflow-y: auto;
  background: white;
}

.cert-list-item {
  display: grid;
  grid-template-columns: 50px 1fr 100px 100px;
  height: 48px;
  border-bottom: 1px solid #f3f4f6;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s;
}

.cert-list-item:hover {
  background: #f9fafb;
}

.cert-list-item.selected {
  background: #eff6ff;
}

.selection-indicator {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  background: transparent;
  margin: auto;
  transition: all 0.2s;
}

.cert-list-item.selected .selection-indicator {
  background: #3b82f6;
  border-color: #3b82f6;
}

.cert-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 8px;
}

.cert-category {
  font-size: 11px;
  color: #6b7280;
}

.cert-user {
  font-size: 13px;
  color: #111827;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-expires {
  font-size: 12px;
  color: #111827;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-issuer {
  font-size: 12px;
  color: #111827;
  padding-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

/* Password Input */
.password-section {
  margin-bottom: 20px;
}

.password-input {
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Pretendard', sans-serif;
  transition: border-color 0.2s;
}

.password-input:focus {
  outline: none;
  border-color: #3b82f6;
}

/* Connect Button */
.connect-btn {
  width: 100%;
  height: 48px;
  background: #111827;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.connect-btn:hover:not(:disabled) {
  background: #1f2937;
}

.connect-btn:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

/* 로딩 및 에러 메시지 */
.cert-loading,
.cert-empty,
.cert-error {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

.cert-error {
  color: #ef4444;
}

/* Agent Check Container */
.agent-check-container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: auto;
  padding: 20px 20px 40px 20px;
}

/* Loading Skeleton */
.agent-check-loading {
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 16px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 13px;
  color: #6b7280;
}

/* Agent Status Indicator */
.agent-status-indicator {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: #f0fdf4;
  border-radius: 6px;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.status-text {
  color: #059669;
  font-weight: 500;
}

/* Install Guide */
.agent-install-guide {
  max-width: 420px;
  text-align: center;
}

.install-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.install-title {
  font-size: 20px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 12px;
}

.install-description {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 32px;
}

.install-steps {
  text-align: left;
  margin-bottom: 32px;
}

.install-step {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.install-step:last-child {
  margin-bottom: 0;
}

.step-number {
  width: 32px;
  height: 32px;
  background: #3b82f6;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
  padding-top: 4px;
}

.step-title {
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 8px;
}

.step-note {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
}

.install-download-btn {
  width: 100%;
  padding: 12px 24px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.install-download-btn:hover {
  background: #2563eb;
}

.install-help {
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.install-help p {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
}

.install-refresh-btn {
  padding: 8px 16px;
  background: white;
  color: #3b82f6;
  border: 1px solid #3b82f6;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.install-refresh-btn:hover {
  background: #eff6ff;
}

