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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ============ Login Screen ============ */

.login-box {
  max-width: 400px;
  margin: 100px auto;
  padding: 40px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.login-box h1 {
  margin-bottom: 10px;
  color: #1f2937;
}

.login-box p {
  color: #666;
  margin-bottom: 30px;
}

/* Stage environment badge */
.stage-badge {
  display: inline-block;
  background: #f59e0b;
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.stage-badge-small {
  background: #f59e0b;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 8px;
}

/* ============ Dashboard Header ============ */

header {
  background: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.25rem;
  color: #1f2937;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#user-email {
  color: #666;
  font-size: 0.875rem;
}

/* ============ Main Content ============ */

main {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 24px;
}

.card {
  background: white;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card h2 {
  font-size: 1rem;
  margin-bottom: 16px;
  color: #374151;
}

/* ============ Form ============ */

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-row input,
.form-row select {
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row input {
  flex: 1;
  min-width: 200px;
}

.form-row select {
  min-width: 160px;
}

/* ============ Buttons ============ */

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.75rem;
}

/* ============ New Key Display ============ */

.new-key-box {
  margin-top: 20px;
  padding: 16px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
}

.new-key-box p {
  color: #92400e;
}

.key-value {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.key-value code {
  flex: 1;
  padding: 12px;
  background: #1f2937;
  color: #10b981;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  word-break: break-all;
  user-select: all;
}

/* ============ Table ============ */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  font-weight: 600;
  color: #6b7280;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td code {
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.8rem;
}

tr:hover {
  background: #f9fafb;
}

.empty,
.loading {
  color: #6b7280;
  font-style: italic;
  padding: 20px 0;
}

.error {
  color: #dc2626;
  padding: 20px 0;
}

/* ============ Modal ============ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: white;
  padding: 24px;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-content h3 {
  margin-bottom: 12px;
  color: #1f2937;
}

.modal-content .warning {
  color: #dc2626;
  font-size: 0.875rem;
  margin: 12px 0;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ============ Responsive ============ */

@media (max-width: 640px) {
  header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .header-right {
    flex-direction: column;
    gap: 8px;
  }

  main {
    padding: 0 16px;
  }

  .card {
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row input,
  .form-row select {
    width: 100%;
  }

  table {
    font-size: 0.75rem;
  }

  th,
  td {
    padding: 8px 6px;
  }

  /* Hide less important columns on mobile */
  th:nth-child(4),
  td:nth-child(4) {
    display: none;
  }
}
